Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support environment variables in gcp_credentials: workload_identity_provider: etc #642

Open
anarazel opened this issue Aug 15, 2023 · 2 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@anarazel
Copy link

Hi,

right now it is not supported to configure gcp_credentials etc via environment variables. It'd be useful to support doing so, to allow different forks of a repository to use different workload identity providers.

I searched through the cirrus_cli code, without finding relevant references to gcp_credentials/workload_identity_provider/.. - presumably that is the problem?

Regards,

Andres

@fkorotkov
Copy link
Contributor

For reference, here is where the credentials are getting parsed

if strings.HasSuffix(fieldName, "credentials") || strings.HasSuffix(fieldName, "config") {
parseCallback := func(node *node.Node) error {
value, err := node.GetCredentials(mergedEnv)
if err != nil {
return err
}
instance.proto.Set(field, protoreflect.ValueOfString(value))
return nil
}
// some trickery to be able to specify top level credentials for instances
instance.CollectibleField(fieldName, schema.String(fieldDescription), parseCallback)
} else {

@fkorotkov fkorotkov added bug Something isn't working enhancement New feature or request labels Aug 15, 2023
@anarazel
Copy link
Author

For reference, here is where the credentials are getting parsed

Hm - if I understand correctly, env vars get expanded, but just at the top-level (e.g. gcp_credentials: $VAR), not when the variables are further down (as in the gcp_credentials: workload_identity_provider: $VAR case):

func (node *Node) GetCredentials(env map[string]string) (string, error) {
switch node.Value.(type) {
case *ScalarValue:
return node.GetExpandedStringValue(env)
case *MapValue:

Looks like GetMapOrListOfMapsWithExpansion might do the trick?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants