Skip to content

Commit

Permalink
move the rest over to framework_provider_clients.go.tmpl
Browse files Browse the repository at this point in the history
  • Loading branch information
BBBmau committed Oct 23, 2024
1 parent 799cb87 commit 7e15243
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging"

"github.com/hashicorp/terraform-provider-google/google/fwmodels"
iamcredentials "google.golang.org/api/iamcredentials/v1"
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
"github.com/hashicorp/terraform-provider-google/google/verify"

Expand Down Expand Up @@ -523,12 +522,6 @@ func (p *FrameworkProviderConfig) SetupGrpcLogging() {
)
}

// Remove the `/{{version}}/` from a base path if present.
func RemoveBasePathVersion(url string) string {
re := regexp.MustCompile(`(?P<base>http[s]://.*)(?P<version>/[^/]+?/$)`)
return re.ReplaceAllString(url, "$1/")
}

func (p *FrameworkProviderConfig) logGoogleIdentities(ctx context.Context, data fwmodels.ProviderModel, diags *diag.Diagnostics) {
// GetCurrentUserEmailFramework doesn't pass an error back from logGoogleIdentities, so we want
// a separate diagnostics here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package fwtransport

import (
"fmt"
"log"
"strings"

"google.golang.org/api/dns/v1"
{{- if ne $.TargetVersionName "ga" }}
firebase "google.golang.org/api/firebase/v1beta1"
{{- end }}
"google.golang.org/api/option"
iamcredentials "google.golang.org/api/iamcredentials/v1"

"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-log/tflog"
Expand Down Expand Up @@ -38,7 +40,7 @@ func (p *FrameworkProviderConfig) NewDnsClient(userAgent string, diags *diag.Dia
}

func (p *FrameworkProviderConfig) NewIamCredentialsClient(userAgent string) *iamcredentials.Service {
iamCredentialsClientBasePath := RemoveBasePathVersion(p.IAMCredentialsBasePath)
iamCredentialsClientBasePath := transport_tpg.RemoveBasePathVersion(p.IAMCredentialsBasePath)
log.Printf("[INFO] Instantiating Google Cloud IAMCredentials client for path %s", iamCredentialsClientBasePath)
clientIamCredentials, err := iamcredentials.NewService(p.Context, option.WithHTTPClient(p.Client))
if err != nil {
Expand Down

0 comments on commit 7e15243

Please sign in to comment.