cue modules: move stdlib to pkg/alpha.dagger.io
In preparation for Europa, we will vendor multiple CUE modules: - `pkg/alpha.dagger.io`: legacy non-europa packages - `pkg/dagger.io`: core Europa packages - `pkg/universe.dagger.io`: Europa universe Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
66
pkg/alpha.dagger.io/gcp/cloudrun/cloudrun.cue
Normal file
66
pkg/alpha.dagger.io/gcp/cloudrun/cloudrun.cue
Normal file
@@ -0,0 +1,66 @@
|
||||
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: {
|
||||
// GCP Config
|
||||
config: gcp.#Config
|
||||
|
||||
// Cloud Run service name
|
||||
name: string @dagger(input)
|
||||
|
||||
// GCR image ref
|
||||
image: string @dagger(input)
|
||||
|
||||
// Cloud Run platform
|
||||
platform: *"managed" | string @dagger(input)
|
||||
|
||||
// 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 & {
|
||||
"config": config
|
||||
}
|
||||
},
|
||||
|
||||
op.#Exec & {
|
||||
args: [
|
||||
"/bin/bash",
|
||||
"--noprofile",
|
||||
"--norc",
|
||||
"-eo",
|
||||
"pipefail",
|
||||
"-c",
|
||||
#"""
|
||||
gcloud run deploy "$SERVICE_NAME" \
|
||||
--image "$IMAGE" \
|
||||
--region "$REGION" \
|
||||
--port "$PORT" \
|
||||
--platform "$PLATFORM" \
|
||||
--allow-unauthenticated \
|
||||
--set-env-vars "$ENV_VARS"
|
||||
"""#,
|
||||
]
|
||||
env: {
|
||||
SERVICE_NAME: name
|
||||
PLATFORM: platform
|
||||
REGION: config.region
|
||||
IMAGE: image
|
||||
PORT: port
|
||||
ENV_VARS: strings.Join(_envVars, ",")
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
18
pkg/alpha.dagger.io/gcp/cloudrun/tests/cloudrun.cue
Normal file
18
pkg/alpha.dagger.io/gcp/cloudrun/tests/cloudrun.cue
Normal file
@@ -0,0 +1,18 @@
|
||||
package cloudrun
|
||||
|
||||
import (
|
||||
"alpha.dagger.io/gcp"
|
||||
"alpha.dagger.io/gcp/cloudrun"
|
||||
)
|
||||
|
||||
TestConfig: gcpConfig: gcp.#Config
|
||||
|
||||
TestCloudRun: deploy: cloudrun.#Service & {
|
||||
config: TestConfig.gcpConfig
|
||||
name: "todoapp"
|
||||
image: "gcr.io/dagger-ci/todoapp:latest"
|
||||
env: {
|
||||
FOO: "foo"
|
||||
BAR: "bar"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user