Skip to content

Commit

Permalink
ephemeral: add IAMBasePath support (#12269)
Browse files Browse the repository at this point in the history
  • Loading branch information
BBBmau authored Nov 7, 2024
2 parents 9d0b5d6 + 8b56903 commit 1474051
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type FrameworkProviderConfig struct {

// paths for client setup
IAMCredentialsBasePath string // TODO: This will be removed once we resove the muxing issues
IAMBasePath string // TODO: This will be removed once we resove the muxing issues
{{- range $product := $.Products }}
{{ $product.Name }}BasePath string
{{- end }}
Expand Down Expand Up @@ -106,6 +107,7 @@ func (p *FrameworkProviderConfig) LoadAndValidateFramework(ctx context.Context,
// Setup Base Paths for clients
// Generated products
p.IAMCredentialsBasePath = data.IamCredentialsCustomEndpoint.ValueString() // TODO: This will be removed once we resove the muxing issues
p.IAMBasePath = data.IAMCustomEndpoint.ValueString() // TODO: This will be removed once we resove the muxing issues
{{- range $product := $.Products }}
p.{{ $product.Name }}BasePath = data.{{ $product.Name }}CustomEndpoint.ValueString()
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

"google.golang.org/api/dns/v1"
"google.golang.org/api/iam/v1"
{{- if ne $.TargetVersionName "ga" }}
firebase "google.golang.org/api/firebase/v1beta1"
{{- end }}
Expand Down Expand Up @@ -53,6 +54,20 @@ func (p *FrameworkProviderConfig) NewIamCredentialsClient(userAgent string) *iam
return clientIamCredentials
}

func (p *FrameworkProviderConfig) NewIamClient(userAgent string) *iam.Service {
iamClientBasePath := transport_tpg.RemoveBasePathVersion(p.IAMBasePath)
log.Printf("[INFO] Instantiating Google Cloud IAM client for path %s", iamClientBasePath)
clientIAM, err := iam.NewService(p.Context, option.WithHTTPClient(p.Client))
if err != nil {
log.Printf("[WARN] Error creating client iam: %s", err)
return nil
}
clientIAM.UserAgent = userAgent
clientIAM.BasePath = iamClientBasePath

return clientIAM
}

{{ if ne $.TargetVersionName `ga` -}}
func (p *FrameworkProviderConfig) NewFirebaseClient(userAgent string, diags *diag.Diagnostics) *firebase.Service {
firebaseClientBasePath := transport_tpg.RemoveBasePathVersion(p.FirebaseBasePath)
Expand Down

0 comments on commit 1474051

Please sign in to comment.