1
0
Fork 0
mirror of https://github.com/external-secrets/external-secrets.git synced 2024-12-14 11:57:59 +00:00

Merge pull request #279 from zeonin/main

Fix Openshift 4.7 issues
This commit is contained in:
paul-the-alien[bot] 2021-07-25 13:01:17 +00:00 committed by GitHub
commit bd6e868474
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 deletions

View file

@ -21,6 +21,7 @@ rules:
resources:
- "externalsecrets"
- "externalsecrets/status"
- "externalsecrets/finalizers"
verbs:
- "update"
- "patch"

View file

@ -59,6 +59,7 @@ const (
errGetKubeSA = "cannot get Kubernetes service account %q: %w"
errGetKubeSASecrets = "cannot find secrets bound to service account: %q"
errGetKubeSANoToken = "cannot find token in secrets bound to service account: %q"
errGetKubeSecret = "cannot get Kubernetes secret %q: %w"
errSecretKeyFmt = "cannot find secret data for key: %q"
@ -301,13 +302,20 @@ func (v *client) secretKeyRefForServiceAccount(ctx context.Context, serviceAccou
if len(serviceAccount.Secrets) == 0 {
return "", fmt.Errorf(errGetKubeSASecrets, ref.Name)
}
tokenRef := serviceAccount.Secrets[0]
for _, tokenRef := range serviceAccount.Secrets {
retval, err := v.secretKeyRef(ctx, &esmeta.SecretKeySelector{
Name: tokenRef.Name,
Namespace: &ref.Namespace,
Key: "token",
})
return v.secretKeyRef(ctx, &esmeta.SecretKeySelector{
Name: tokenRef.Name,
Namespace: &ref.Namespace,
Key: "token",
})
if err != nil {
continue
}
return retval, nil
}
return "", fmt.Errorf(errGetKubeSANoToken, ref.Name)
}
func (v *client) secretKeyRef(ctx context.Context, secretRef *esmeta.SecretKeySelector) (string, error) {