@@ -45,6 +45,7 @@ func GetToken(ctx context.Context, provider Provider, opts ...Option) (Token, er
45
45
}
46
46
47
47
// Update access token fetcher for a service account if specified.
48
+ var providerAudience string
48
49
var providerIdentity string
49
50
var serviceAccountP * corev1.ServiceAccount
50
51
if o .ServiceAccount != nil {
@@ -63,7 +64,7 @@ func GetToken(ctx context.Context, provider Provider, opts ...Option) (Token, er
63
64
64
65
// Get provider audience.
65
66
var err error
66
- providerAudience , err : = provider .GetAudience (ctx , serviceAccount )
67
+ providerAudience , err = provider .GetAudience (ctx , serviceAccount )
67
68
if err != nil {
68
69
return nil , fmt .Errorf ("failed to get provider audience: %w" , err )
69
70
}
@@ -131,7 +132,8 @@ func GetToken(ctx context.Context, provider Provider, opts ...Option) (Token, er
131
132
}
132
133
133
134
// Build cache key.
134
- cacheKey := buildCacheKey (provider , providerIdentity , artifactRepositoryCacheKey , serviceAccountP , opts ... )
135
+ cacheKey := buildCacheKey (provider , providerAudience , providerIdentity ,
136
+ artifactRepositoryCacheKey , serviceAccountP , opts ... )
135
137
136
138
// Get involved object details.
137
139
kind := o .InvolvedObject .Kind
@@ -163,7 +165,7 @@ func newServiceAccountToken(ctx context.Context, client client.Client,
163
165
return tokenReq .Status .Token , nil
164
166
}
165
167
166
- func buildCacheKey (provider Provider , providerIdentity , artifactRepositoryKey string ,
168
+ func buildCacheKey (provider Provider , providerAudience , providerIdentity , artifactRepositoryKey string ,
167
169
serviceAccount * corev1.ServiceAccount , opts ... Option ) string {
168
170
169
171
var o Options
@@ -174,6 +176,7 @@ func buildCacheKey(provider Provider, providerIdentity, artifactRepositoryKey st
174
176
keyParts = append (keyParts , fmt .Sprintf ("provider=%s" , provider .GetName ()))
175
177
176
178
if serviceAccount != nil {
179
+ keyParts = append (keyParts , fmt .Sprintf ("providerAudience=%s" , providerAudience ))
177
180
keyParts = append (keyParts , fmt .Sprintf ("providerIdentity=%s" , providerIdentity ))
178
181
keyParts = append (keyParts , fmt .Sprintf ("serviceAccountName=%s" , serviceAccount .Name ))
179
182
keyParts = append (keyParts , fmt .Sprintf ("serviceAccountNamespace=%s" , serviceAccount .Namespace ))
0 commit comments