diff --git a/pkg/provider/gcp/secretmanager/auth.go b/pkg/provider/gcp/secretmanager/auth.go index a5122540a..2b80fff13 100644 --- a/pkg/provider/gcp/secretmanager/auth.go +++ b/pkg/provider/gcp/secretmanager/auth.go @@ -35,6 +35,7 @@ func NewTokenSource(ctx context.Context, auth esv1beta1.GCPSMAuth, projectID str if err != nil { return nil, fmt.Errorf("unable to initialize workload identity") } + defer wi.Close() ts, err = wi.TokenSource(ctx, auth, isClusterKind, kube, namespace) if ts != nil || err != nil { return ts, err diff --git a/pkg/provider/gcp/secretmanager/workload_identity.go b/pkg/provider/gcp/secretmanager/workload_identity.go index c0c31a468..ee3f542cd 100644 --- a/pkg/provider/gcp/secretmanager/workload_identity.go +++ b/pkg/provider/gcp/secretmanager/workload_identity.go @@ -78,11 +78,11 @@ type saTokenGenerator interface { } func newWorkloadIdentity(ctx context.Context, projectID string) (*workloadIdentity, error) { - iamc, err := newIAMClient(ctx) + satg, err := newSATokenGenerator() if err != nil { return nil, err } - satg, err := newSATokenGenerator() + iamc, err := newIAMClient(ctx) if err != nil { return nil, err }