Skip to content

Commit

Permalink
Merge pull request #474 from nais/google-cloud-project-env-var
Browse files Browse the repository at this point in the history
Add support for GOOGLE_CLOUD_PROJECT environment variable
  • Loading branch information
Starefossen authored Nov 6, 2023
2 parents c379453 + 1b96e2d commit 765656a
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/resourcecreator/google/gcp/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ func Create(source Source, ast *resource.Ast, cfg Config) error {

googleServiceAccount := google_iam.CreateServiceAccount(source, projectID)
googleServiceAccountBinding := google_iam.CreatePolicy(source, &googleServiceAccount, projectID)

// Standard environment variable name in Google SDKs
ast.Env = append(ast.Env, v1.EnvVar{
Name: "GOOGLE_CLOUD_PROJECT",
Value: teamProjectID,
})

// Legacy environment variable for backwards compability
ast.Env = append(ast.Env, v1.EnvVar{
Name: "GCP_TEAM_PROJECT_ID",
Value: teamProjectID,
Expand Down
2 changes: 2 additions & 0 deletions pkg/resourcecreator/testdata/gcp_bigquery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ tests:
containers:
- image: navikt/myapplication:1.2.3
env:
- name: GOOGLE_CLOUD_PROJECT
value: team-project-id
- name: GCP_TEAM_PROJECT_ID
value: team-project-id
dnsPolicy: ClusterFirst
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ tests:
containers:
- image: navikt/myapplication:1.2.3
env:
- name: GOOGLE_CLOUD_PROJECT
value: team-project-id
- name: GCP_TEAM_PROJECT_ID
value: team-project-id
dnsPolicy: ClusterFirst
Expand Down
2 changes: 2 additions & 0 deletions pkg/resourcecreator/testdata/gcp_buckets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ tests:
containers:
- image: navikt/myapplication:1.2.3
env:
- name: GOOGLE_CLOUD_PROJECT
value: team-project-id
- name: GCP_TEAM_PROJECT_ID
value: team-project-id
dnsPolicy: ClusterFirst
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ tests:
containers:
- image: navikt/myapplication:1.2.3
env:
- name: GOOGLE_CLOUD_PROJECT
value: team-project-id
- name: GCP_TEAM_PROJECT_ID
value: team-project-id
dnsPolicy: ClusterFirst
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ tests:
containers:
- image: navikt/myapplication:1.2.3
env:
- name: GOOGLE_CLOUD_PROJECT
value: team-project-id
- name: GCP_TEAM_PROJECT_ID
value: team-project-id
dnsPolicy: ClusterFirst
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ tests:
containers:
- image: navikt/myapplication:1.2.3
env:
- name: GOOGLE_CLOUD_PROJECT
value: team-project-id
- name: GCP_TEAM_PROJECT_ID
value: team-project-id
dnsPolicy: ClusterFirst
Expand Down
2 changes: 2 additions & 0 deletions pkg/resourcecreator/testdata/gcp_database.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ tests:
- secretRef:
name: google-sql-myapplication
env:
- name: GOOGLE_CLOUD_PROJECT
value: team-project-id
- name: GCP_TEAM_PROJECT_ID
value: team-project-id
- name: cloudsql-proxy
Expand Down
2 changes: 2 additions & 0 deletions pkg/resourcecreator/testdata/gcp_database_with_insights.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ tests:
- secretRef:
name: google-sql-myapplication
env:
- name: GOOGLE_CLOUD_PROJECT
value: team-project-id
- name: GCP_TEAM_PROJECT_ID
value: team-project-id
- name: cloudsql-proxy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ tests:
containers:
- image: navikt/mynaisjob:1.2.3
env:
- name: GOOGLE_CLOUD_PROJECT
value: team-project-id
- name: GCP_TEAM_PROJECT_ID
value: team-project-id
dnsPolicy: ClusterFirst
Expand Down
2 changes: 2 additions & 0 deletions pkg/resourcecreator/testdata/naisjob/cronjob_gcp_buckets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ tests:
containers:
- image: navikt/mynaisjob:1.2.3
env:
- name: GOOGLE_CLOUD_PROJECT
value: team-project-id
- name: GCP_TEAM_PROJECT_ID
value: team-project-id
dnsPolicy: ClusterFirst
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ tests:
- secretRef:
name: google-sql-mynaisjob
env:
- name: GOOGLE_CLOUD_PROJECT
value: team-project-id
- name: GCP_TEAM_PROJECT_ID
value: team-project-id
- name: cloudsql-proxy
Expand Down

0 comments on commit 765656a

Please sign in to comment.