Skip to content

Commit da993ad

Browse files
authored
Merge pull request #1416 from diggerhq/fix/google-storage-env-variables-for-plan-storage
update env variables to only use inputs
2 parents b8f566d + e91e019 commit da993ad

File tree

7 files changed

+20
-13
lines changed

7 files changed

+20
-13
lines changed

action.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ inputs:
3434
description: "'audience' parameter configured in Google's Workload Identity Provider (if specified). To be used when the 'google-workload-identity-provider' input is specified"
3535
required: false
3636
google-service-account:
37-
description: Service account to be used when the 'google-workload-identity-provider' input is specified)
38-
required: false
37+
description: Service account to be used when the 'google-workload-identity-provider' input is specified)
38+
required: false
39+
google-lock-bucket:
40+
description: The GCP bucket to use for locks
41+
required: false
3942
setup-azure:
4043
description: Setup Azure
4144
required: false
@@ -292,7 +295,8 @@ runs:
292295
shell: bash
293296
env:
294297
PLAN_UPLOAD_DESTINATION: ${{ inputs.upload-plan-destination }}
295-
GOOGLE_STORAGE_BUCKET: ${{ inputs.upload-plan-destination-gcp-bucket }}
298+
GOOGLE_STORAGE_LOCK_BUCKET: ${{ inputs.google-lock-bucket }}
299+
GOOGLE_STORAGE_PLAN_ARTEFACT_BUCKET: ${{ inputs.upload-plan-destination-gcp-bucket }}
296300
AWS_S3_BUCKET: ${{ inputs.upload-plan-destination-s3-bucket }}
297301
ACTIVATE_VENV: ${{ inputs.setup-checkov == 'true' }}
298302
DISABLE_LOCKING: ${{ inputs.disable-locking == 'true' }}
@@ -323,7 +327,8 @@ runs:
323327
env:
324328
actionref: ${{ github.action_ref }}
325329
PLAN_UPLOAD_DESTINATION: ${{ inputs.upload-plan-destination }}
326-
GOOGLE_STORAGE_BUCKET: ${{ inputs.upload-plan-destination-gcp-bucket }}
330+
GOOGLE_STORAGE_LOCK_BUCKET: ${{ inputs.google-lock-bucket }}
331+
GOOGLE_STORAGE_PLAN_ARTEFACT_BUCKET: ${{ inputs.upload-plan-destination-gcp-bucket }}
327332
AWS_S3_BUCKET: ${{ inputs.upload-plan-destination-s3-bucket }}
328333
ACTIVATE_VENV: ${{ inputs.setup-checkov == 'true' }}
329334
DISABLE_LOCKING: ${{ inputs.disable-locking == 'true' }}

cli/cmd/digger/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -918,9 +918,9 @@ func newPlanStorage(ghToken string, ghRepoOwner string, ghRepositoryName string,
918918
}
919919
case uploadDestination == "gcp":
920920
ctx, client := gcp.GetGoogleStorageClient()
921-
bucketName := strings.ToLower(os.Getenv("GOOGLE_STORAGE_BUCKET"))
921+
bucketName := strings.ToLower(os.Getenv("GOOGLE_STORAGE_PLAN_ARTEFACT_BUCKET"))
922922
if bucketName == "" {
923-
reportErrorAndExit(requestedBy, "GOOGLE_STORAGE_BUCKET is not defined", 9)
923+
reportErrorAndExit(requestedBy, "GOOGLE_STORAGE_PLAN_ARTEFACT_BUCKET is not defined", 9)
924924
}
925925
bucket := client.Bucket(bucketName)
926926
planStorage = &storage.PlanStorageGcp{

cli/pkg/locking/locking.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,9 @@ func GetLock() (locking.Lock, error) {
294294
}
295295
}(client)
296296

297-
bucketName := strings.ToLower(os.Getenv("GOOGLE_STORAGE_BUCKET"))
297+
bucketName := strings.ToLower(os.Getenv("GOOGLE_STORAGE_LOCK_BUCKET"))
298298
if bucketName == "" {
299-
return nil, errors.New("GOOGLE_STORAGE_BUCKET is not set")
299+
return nil, errors.New("GOOGLE_STORAGE_LOCK_BUCKET is not set")
300300
}
301301
bucket := client.Bucket(bucketName)
302302
lock := gcp.GoogleStorageLock{Client: client, Bucket: bucket, Context: ctx}

cli_e2e/plan_storage_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestGCPPlanStorageStorageAndRetrieval(t *testing.T) {
2626
fmt.Printf("getting cp client")
2727
ctx, client := gcp.GetGoogleStorageClient()
2828
fmt.Printf("getting bucket")
29-
bucketName := strings.ToLower(os.Getenv("GOOGLE_STORAGE_BUCKET"))
29+
bucketName := strings.ToLower(os.Getenv("GOOGLE_STORAGE_PLAN_ARTEFACT_BUCKET"))
3030
bucket := client.Bucket(bucketName)
3131
planStorage := &storage.PlanStorageGcp{
3232
Client: client,

docs/features/plan-persistence.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ Use the following workflow option to use Artifacts plan storage:
88
```
99
upload-plan-destination: github
1010
```
11-
Or to use a GCP bucket (set environment variable: GOOGLE_STORAGE_BUCKET):
11+
Or to use a GCP bucket:
1212
```
1313
upload-plan-destination: gcp
14+
upload-plan-destination-gcp-bucket: "my-bucket"
1415
```
1516

1617
Similarly you can use an aws bucket (set environment variable: AWS_S3_BUCKET):

docs/howto/using-terragrunt.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ jobs:
7373
google-auth-credentials: '$\'{\'{ secrets.DIGGER_GCP_CREDENTIALS \}\}'
7474
setup-terragrunt: true
7575
terragrunt-version: 0.44.1
76+
google-lock-bucket: please-create-me-for-storing-locks
7677
env:
7778
LOCK_PROVIDER: gcp
78-
GOOGLE_STORAGE_BUCKET: please-create-me-for-storing-locks
79+
GOOGLE_STORAGE_LOCK_BUCKET: please-create-me-for-storing-locks
7980
GOOGLE_ENCRYPTION_KEY: $\'{\'{ secrets.GOOGLE_ENCRYPTION_KEY \}\}
8081
GITHUB_CONTEXT: $\'{\'{ toJson(github) \}\}
8182
GITHUB_TOKEN: $\'{\'{ secrets.GITHUB_TOKEN \}\}

ee/cli/cmd/digger/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -887,9 +887,9 @@ func newPlanStorage(ghToken string, ghRepoOwner string, ghRepositoryName string,
887887
}
888888
} else if uploadDestination == "gcp" {
889889
ctx, client := gcp.GetGoogleStorageClient()
890-
bucketName := strings.ToLower(os.Getenv("GOOGLE_STORAGE_BUCKET"))
890+
bucketName := strings.ToLower(os.Getenv("GOOGLE_STORAGE_PLAN_ARTEFACT_BUCKET"))
891891
if bucketName == "" {
892-
reportErrorAndExit(requestedBy, fmt.Sprintf("GOOGLE_STORAGE_BUCKET is not defined"), 9)
892+
reportErrorAndExit(requestedBy, fmt.Sprintf("GOOGLE_STORAGE_PLAN_ARTEFACT_BUCKET is not defined"), 9)
893893
}
894894
bucket := client.Bucket(bucketName)
895895
planStorage = &storage.PlanStorageGcp{

0 commit comments

Comments
 (0)