Skip to content

Commit

Permalink
Merge pull request #440 from joelddiaz/gcp-serviceaccountnames-list-c…
Browse files Browse the repository at this point in the history
…heck

Bug 2036827: ensure GCP CredsReq has a list of ServiceAccounts
  • Loading branch information
openshift-merge-robot committed Jan 4, 2022
2 parents 2e091dd + 6ebbcf2 commit 895e9c1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/cmd/provisioning/gcp/create_service_accounts.go
Expand Up @@ -105,6 +105,12 @@ func processCredentialsRequests(ctx context.Context, client gcp.Client, credReqs
}

func createServiceAccount(ctx context.Context, client gcp.Client, name string, credReq *credreqv1.CredentialsRequest, serviceAccountNum int, workloadIdentityPool, workloadIdentityProvider, project, targetDir string, generateOnly bool) (string, error) {
// The credReq must have a non zero-length list of ServiceAccountNames
// that can be used to restrict which k8s ServiceAccounts can use the GCP ServiceAccount.
if len(credReq.Spec.ServiceAccountNames) == 0 {
return "", fmt.Errorf("CredentialsRequest %s/%s must provide at least one ServiceAccount in .spec.ServiceAccountNames", credReq.Namespace, credReq.Name)
}

// The service account id has a max length of 30 chars
// split it into 12-11-5 where the resuling string becomes:
// <infraName chopped to 12 chars>-<crName chopped to 11 chars>-<random 5 chars>
Expand Down

0 comments on commit 895e9c1

Please sign in to comment.