Add env var support on GCP cloudrun
Signed-off-by: Benjamin Grandfond <benjamin.grandfond@gmail.com>
This commit is contained in:
parent
db8a92c371
commit
830ad87ced
@ -1,6 +1,8 @@
|
|||||||
package cloudrun
|
package cloudrun
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"alpha.dagger.io/dagger/op"
|
"alpha.dagger.io/dagger/op"
|
||||||
"alpha.dagger.io/gcp"
|
"alpha.dagger.io/gcp"
|
||||||
)
|
)
|
||||||
@ -22,6 +24,10 @@ import (
|
|||||||
// Cloud Run service exposed port
|
// Cloud Run service exposed port
|
||||||
port: *"80" | string @dagger(input)
|
port: *"80" | string @dagger(input)
|
||||||
|
|
||||||
|
// Cloud Run service environment variables
|
||||||
|
env: [string]: string
|
||||||
|
_envVars: [ for key, val in env {key + "=" + val}]
|
||||||
|
|
||||||
#up: [
|
#up: [
|
||||||
op.#Load & {
|
op.#Load & {
|
||||||
from: gcp.#GCloud & {
|
from: gcp.#GCloud & {
|
||||||
@ -38,7 +44,13 @@ import (
|
|||||||
"pipefail",
|
"pipefail",
|
||||||
"-c",
|
"-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: {
|
env: {
|
||||||
@ -47,6 +59,7 @@ import (
|
|||||||
REGION: config.region
|
REGION: config.region
|
||||||
IMAGE: image
|
IMAGE: image
|
||||||
PORT: port
|
PORT: port
|
||||||
|
ENV_VARS: strings.Join(_envVars, ",")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@ -11,4 +11,8 @@ TestCloudRun: deploy: cloudrun.#Service & {
|
|||||||
config: TestConfig.gcpConfig
|
config: TestConfig.gcpConfig
|
||||||
name: "todoapp"
|
name: "todoapp"
|
||||||
image: "gcr.io/dagger-ci/todoapp:latest"
|
image: "gcr.io/dagger-ci/todoapp:latest"
|
||||||
|
env: {
|
||||||
|
FOO: "foo"
|
||||||
|
BAR: "bar"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user