diff --git a/stdlib/gcp/cloudrun/cloudrun.cue b/stdlib/gcp/cloudrun/cloudrun.cue index ada3fdf0..041a1b5e 100644 --- a/stdlib/gcp/cloudrun/cloudrun.cue +++ b/stdlib/gcp/cloudrun/cloudrun.cue @@ -1,11 +1,13 @@ package cloudrun import ( + "strings" + "alpha.dagger.io/dagger/op" "alpha.dagger.io/gcp" ) -// Service deploys a Cloud Run service based on provided GCR image +// Service deploys a Cloud Run service based on provided GCR image #Service: { // GCP Config config: gcp.#Config @@ -22,6 +24,10 @@ import ( // Cloud Run service exposed port port: *"80" | string @dagger(input) + // Cloud Run service environment variables + env: [string]: string + _envVars: [ for key, val in env {key + "=" + val}] + #up: [ op.#Load & { from: gcp.#GCloud & { @@ -38,7 +44,13 @@ import ( "pipefail", "-c", #""" - gcloud run deploy "$SERVICE_NAME" --image "$IMAGE" --region "$REGION" --port "$PORT" --platform "$PLATFORM" --allow-unauthenticated + gcloud run deploy "$SERVICE_NAME" \ + --image "$IMAGE" \ + --region "$REGION" \ + --port "$PORT" \ + --platform "$PLATFORM" \ + --allow-unauthenticated \ + --set-env-vars "$ENV_VARS" """#, ] env: { @@ -47,6 +59,7 @@ import ( REGION: config.region IMAGE: image PORT: port + ENV_VARS: strings.Join(_envVars, ",") } }, ] diff --git a/stdlib/gcp/cloudrun/tests/cloudrun.cue b/stdlib/gcp/cloudrun/tests/cloudrun.cue index 18112608..a822051c 100644 --- a/stdlib/gcp/cloudrun/tests/cloudrun.cue +++ b/stdlib/gcp/cloudrun/tests/cloudrun.cue @@ -11,4 +11,8 @@ TestCloudRun: deploy: cloudrun.#Service & { config: TestConfig.gcpConfig name: "todoapp" image: "gcr.io/dagger-ci/todoapp:latest" + env: { + FOO: "foo" + BAR: "bar" + } }