1- package process
1+ package provider
22
33import (
44 "context"
@@ -10,9 +10,9 @@ import (
1010 "github.com/polarn/env-exec/internal/config"
1111)
1212
13- // Find GCP secret env vars and add them to the envVars map
14- func EnvVarsGCP ( config * config.RootConfig , envVars * map [string ]string ) {
15- if ! checkIfGCPSecretKeyRefExists ( config ) {
13+ // Provide fetches GCP secrets and adds them to the envVars map.
14+ func ( p * GCPProvider ) Provide ( cfg * config.RootConfig , envVars map [string ]string ) {
15+ if ! hasGCPSecrets ( cfg ) {
1616 return
1717 }
1818
@@ -23,7 +23,7 @@ func EnvVarsGCP(config *config.RootConfig, envVars *map[string]string) {
2323 }
2424 defer client .Close ()
2525
26- for _ , env := range config .Env {
26+ for _ , env := range cfg .Env {
2727 if env .ValueFrom .GCPSecretKeyRef .Name != "" {
2828 name := env .ValueFrom .GCPSecretKeyRef .Name
2929 version := env .ValueFrom .GCPSecretKeyRef .Version
@@ -33,11 +33,11 @@ func EnvVarsGCP(config *config.RootConfig, envVars *map[string]string) {
3333 version = "latest"
3434 }
3535
36- if project == "" && config .Defaults .GCP .Project == "" {
36+ if project == "" && cfg .Defaults .GCP .Project == "" {
3737 log .Printf ("Error: No GCP project found for secret '%s'" , env .Name )
3838 continue
3939 } else if project == "" {
40- project = config .Defaults .GCP .Project
40+ project = cfg .Defaults .GCP .Project
4141 }
4242
4343 reqName := fmt .Sprintf ("projects/%s/secrets/%s/versions/%s" , project , name , version )
@@ -50,13 +50,13 @@ func EnvVarsGCP(config *config.RootConfig, envVars *map[string]string) {
5050 continue
5151 }
5252
53- ( * envVars ) [env .Name ] = string (resp .Payload .Data )
53+ envVars [env .Name ] = string (resp .Payload .Data )
5454 }
5555 }
5656}
5757
58- func checkIfGCPSecretKeyRefExists ( config * config.RootConfig ) bool {
59- for _ , env := range config .Env {
58+ func hasGCPSecrets ( cfg * config.RootConfig ) bool {
59+ for _ , env := range cfg .Env {
6060 if env .ValueFrom .GCPSecretKeyRef .Name != "" {
6161 return true
6262 }
0 commit comments