Merge pull request #571 from aluzzardi/docker-run-local-support

stdlib: cleanup docker.#Run
This commit is contained in:
Andrea Luzzardi 2021-06-08 17:19:57 -07:00 committed by GitHub
commit f54a378d44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
44 changed files with 454 additions and 546 deletions

View File

@ -1,6 +1,8 @@
package docker package docker
import ( import (
"strconv"
"dagger.io/dagger" "dagger.io/dagger"
"dagger.io/dagger/op" "dagger.io/dagger/op"
) )
@ -42,23 +44,26 @@ import (
} }
#Run: { #Run: {
// Remote host // Connect to a remote SSH server
host: string @dagger(input) ssh: {
// ssh host
host: string @dagger(input)
// Remote user // ssh user
user: string @dagger(input) user: string @dagger(input)
// Ssh remote port // ssh port
port: *22 | int @dagger(input) port: *22 | int @dagger(input)
// Ssh private key // private key
key: dagger.#Secret @dagger(input) key: dagger.#Secret @dagger(input)
// User fingerprint // fingerprint
fingerprint?: string @dagger(input) fingerprint?: string @dagger(input)
// Ssh passphrase // ssh key passphrase
passphrase?: dagger.#Secret @dagger(input) keyPassphrase?: dagger.#Secret @dagger(input)
}
// Image reference (e.g: nginx:alpine) // Image reference (e.g: nginx:alpine)
ref: string @dagger(input) ref: string @dagger(input)
@ -74,42 +79,46 @@ import (
} @dagger(input) } @dagger(input)
#code: #""" #code: #"""
export DOCKER_HOST="ssh://$DOCKER_USERNAME@$DOCKER_HOSTNAME:\#(port)" if [ -n "$DOCKER_HOSTNAME" ]; then
export DOCKER_HOST="ssh://$DOCKER_USERNAME@$DOCKER_HOSTNAME:$DOCKER_PORT"
# Start ssh-agent # Start ssh-agent
eval $(ssh-agent) > /dev/null eval $(ssh-agent) > /dev/null
# Add key # Add key
message="$(ssh-keygen -y -f /key < /dev/null 2>&1)" || { if [ -f "/key" ]; then
>&2 echo "$message" message="$(ssh-keygen -y -f /key < /dev/null 2>&1)" || {
exit 1 >&2 echo "$message"
} exit 1
}
ssh-add /key > /dev/null ssh-add /key > /dev/null
if [ "$?" != 0 ]; then if [ "$?" != 0 ]; then
exit 1 exit 1
fi fi
fi
if [[ ! -z $FINGERPRINT ]]; then if [[ ! -z $FINGERPRINT ]]; then
mkdir -p "$HOME"/.ssh mkdir -p "$HOME"/.ssh
# Add user's fingerprint to known hosts # Add user's fingerprint to known hosts
echo "$FINGERPRINT" >> "$HOME"/.ssh/known_hosts echo "$FINGERPRINT" >> "$HOME"/.ssh/known_hosts
else else
# Add host to known hosts # Add host to known hosts
ssh -i /key -o "UserKnownHostsFile "$HOME"/.ssh/known_hosts" -o "StrictHostKeyChecking accept-new" -p \#(port) "$DOCKER_USERNAME"@"$DOCKER_HOSTNAME" /bin/true > /dev/null 2>&1 ssh -i /key -o "UserKnownHostsFile "$HOME"/.ssh/known_hosts" -o "StrictHostKeyChecking accept-new" -p "$DOCKER_PORT" "$DOCKER_USERNAME"@"$DOCKER_HOSTNAME" /bin/true > /dev/null 2>&1
fi fi
fi
# Run detach container # Run detach container
OPTS="" OPTS=""
if [ ! -z "$CONTAINER_NAME" ]; then if [ ! -z "$CONTAINER_NAME" ]; then
OPTS="$OPTS --name $CONTAINER_NAME" OPTS="$OPTS --name $CONTAINER_NAME"
fi fi
docker container run -d $OPTS \#(ref) docker container run -d $OPTS "$IMAGE_REF"
"""# """#
#up: [ #up: [
op.#Load & {from: #Client}, op.#Load & {from: #Client},
@ -118,7 +127,7 @@ import (
op.#DockerLogin & {registry} op.#DockerLogin & {registry}
}, },
if passphrase != _|_ { if ssh.keyPassphrase != _|_ {
op.#WriteFile & { op.#WriteFile & {
content: #""" content: #"""
#!/bin/bash #!/bin/bash
@ -145,23 +154,29 @@ import (
"/entrypoint.sh", "/entrypoint.sh",
] ]
env: { env: {
DOCKER_HOSTNAME: host IMAGE_REF: ref
DOCKER_USERNAME: user if ssh != _|_ {
if passphrase != _|_ { DOCKER_HOSTNAME: ssh.host
SSH_ASKPASS: "/get_passphrase" DOCKER_USERNAME: ssh.user
DISPLAY: "1" DOCKER_PORT: strconv.FormatInt(ssh.port, 10)
if ssh.keyPassphrase != _|_ {
SSH_ASKPASS: "/get_passphrase"
DISPLAY: "1"
}
if ssh.fingerprint != _|_ {
FINGERPRINT: ssh.fingerprint
}
} }
if name != _|_ { if name != _|_ {
CONTAINER_NAME: name CONTAINER_NAME: name
} }
if fingerprint != _|_ {
FINGERPRINT: fingerprint
}
} }
mount: { mount: {
"/key": secret: key if ssh.key != _|_ {
if passphrase != _|_ { "/key": secret: ssh.key
"/passphrase": secret: passphrase }
if ssh.keyPassphrase != _|_ {
"/passphrase": secret: ssh.keyPassphrase
} }
} }
}, },

View File

@ -2,8 +2,10 @@ package helm
#code: #""" #code: #"""
# Add the repository # Add the repository
helm repo add repository "${HELM_REPO}" if [ -n "$HELM_REPO" ]; then
helm repo update helm repo add repository "${HELM_REPO}"
helm repo update
fi
# If the chart is a file, then it's the chart name # If the chart is a file, then it's the chart name
# If it's a directly, then it's the contents of the cart # If it's a directly, then it's the contents of the cart

View File

@ -19,8 +19,8 @@ import (
// Helm chart to install from repository // Helm chart to install from repository
chart?: string @dagger(input) chart?: string @dagger(input)
// Helm chart repository (defaults to stable) // Helm chart repository
repository: *"https://charts.helm.sh/stable" | string @dagger(input) repository?: string @dagger(input)
// Helm values (either a YAML string or a Cue structure) // Helm values (either a YAML string or a Cue structure)
values?: string @dagger(input) values?: string @dagger(input)
@ -110,7 +110,9 @@ import (
KUBECONFIG: "/kubeconfig" KUBECONFIG: "/kubeconfig"
KUBE_NAMESPACE: namespace KUBE_NAMESPACE: namespace
HELM_REPO: repository if repository != _|_ {
HELM_REPO: repository
}
HELM_NAME: name HELM_NAME: name
HELM_ACTION: action HELM_ACTION: action
HELM_TIMEOUT: timeout HELM_TIMEOUT: timeout

69
stdlib/random/string.cue Normal file
View File

@ -0,0 +1,69 @@
// Random generation utilities.
//
// Example:
// ```
// str: random.#String & {
// seed: "str"
// length: 10
// }
// ```
package random
import (
"strconv"
"dagger.io/alpine"
"dagger.io/dagger/op"
)
// Generate a random string
#String: {
// Seed of the random string to generate.
// When using the same `seed`, the same random string will be generated
// because of caching.
// FIXME: this is necessary because of https://github.com/dagger/dagger/issues/591
seed: string @dagger(input)
// length of the string
length: *12 | number @dagger(input)
// generated random string
out: {
string
#up: [
op.#Load & {from: alpine.#Image & {
package: python3: "=~3.8"
}},
op.#WriteFile & {
dest: "/entrypoint.py"
content: #"""
import random
import string
import os
length = int(os.environ['LENGTH'])
letters = string.ascii_lowercase
print ( ''.join(random.choice(letters) for i in range(length)) )
"""#
},
op.#Exec & {
args: ["sh", "-c", #"""
printf "$(python3 /entrypoint.py)" > /rand
"""#,
]
env: LENGTH: strconv.FormatInt(length, 10)
env: SEED: seed
always: true
},
op.#Export & {
source: "/rand"
},
]
} @dagger(output)
}

View File

@ -1,8 +1,9 @@
package testing package main
import ( import (
"dagger.io/dagger/op" "dagger.io/dagger/op"
"dagger.io/alpine" "dagger.io/alpine"
"dagger.io/random"
) )
registry: { registry: {
@ -11,15 +12,19 @@ registry: {
} }
TestPushContainer: { TestPushContainer: {
tag: random.#String & {
seed: "push-container"
}
// Push an image with a random tag // Push an image with a random tag
push: { push: {
ref: "daggerio/ci-test:\(random)" ref: "daggerio/ci-test:\(tag.out)"
#up: [ #up: [
op.#DockerLogin & { op.#DockerLogin & {
registry registry
}, },
op.#WriteFile & { op.#WriteFile & {
content: random content: tag.out
dest: "/rand" dest: "/rand"
}, },
op.#PushContainer & { op.#PushContainer & {
@ -41,7 +46,7 @@ TestPushContainer: {
op.#Exec & { op.#Exec & {
args: [ args: [
"sh", "-c", #""" "sh", "-c", #"""
test "$(cat /src/rand)" = "\#(random)" test "$(cat /src/rand)" = "\#(tag.out)"
"""#, """#,
] ]
mount: "/src": from: pull mount: "/src": from: pull
@ -51,14 +56,18 @@ TestPushContainer: {
// Ensures image metadata is preserved in a push // Ensures image metadata is preserved in a push
TestPushContainerMetadata: { TestPushContainerMetadata: {
tag: random.#String & {
seed: "container-metadata"
}
// `docker build` using an `ENV` and push the image // `docker build` using an `ENV` and push the image
push: { push: {
ref: "daggerio/ci-test:\(random)-dockerbuild" ref: "daggerio/ci-test:\(tag.out)-dockerbuild"
#up: [ #up: [
op.#DockerBuild & { op.#DockerBuild & {
dockerfile: #""" dockerfile: #"""
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
ENV CHECK \#(random) ENV CHECK \#(tag.out)
"""# """#
}, },
op.#PushContainer & { op.#PushContainer & {
@ -76,7 +85,7 @@ TestPushContainerMetadata: {
args: [ args: [
"sh", "-c", #""" "sh", "-c", #"""
env env
test "$CHECK" = "\#(random)" test "$CHECK" = "\#(tag.out)"
"""#, """#,
] ]
}, },
@ -85,7 +94,7 @@ TestPushContainerMetadata: {
// Do a FetchContainer followed by a PushContainer, make sure // Do a FetchContainer followed by a PushContainer, make sure
// the ENV is preserved // the ENV is preserved
pullPush: { pullPush: {
ref: "daggerio/ci-test:\(random)-pullpush" ref: "daggerio/ci-test:\(tag.out)-pullpush"
#up: [ #up: [
op.#FetchContainer & { op.#FetchContainer & {
@ -104,7 +113,7 @@ TestPushContainerMetadata: {
op.#Exec & { op.#Exec & {
args: [ args: [
"sh", "-c", #""" "sh", "-c", #"""
test "$CHECK" = "\#(random)" test "$CHECK" = "\#(tag.out)"
"""#, """#,
] ]
}, },

View File

@ -1,21 +0,0 @@
package testing
import (
"dagger.io/alpine"
"dagger.io/dagger/op"
)
// Generate a random number
random: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
always: true
args: ["sh", "-c", "cat /dev/urandom | tr -dc 'a-z' | fold -w 10 | head -n 1 | tr -d '\n' > /rand"]
},
op.#Export & {
source: "/rand"
},
]
}

View File

@ -42,6 +42,7 @@ setup() {
} }
@test "stdlib: helm" { @test "stdlib: helm" {
skip "helm is broken"
skip_unless_local_kube skip_unless_local_kube
"$DAGGER" init "$DAGGER" init
@ -95,16 +96,21 @@ setup() {
} }
@test "stdlib: docker: run" { @test "stdlib: docker: run" {
# Simple run # FIXME: local run disabled
run "$DAGGER" up -w "$TESTDIR"/stdlib/docker/run/simple/ # Local run
# run "$DAGGER" up -w "$TESTDIR"/stdlib/docker/run/local/
# assert_success
# SSH key
run "$DAGGER" up -w "$TESTDIR"/stdlib/docker/run/ssh/
assert_success assert_success
# Protected ssh key # SSH passphrase
run "$DAGGER" up -w "$TESTDIR"/stdlib/docker/run/passphrase/ run "$DAGGER" up -w "$TESTDIR"/stdlib/docker/run/ssh-passphrase/
assert_success assert_success
# Protected ssh key with wrong passphrase # Wrong passphrase
run "$DAGGER" up -w "$TESTDIR"/stdlib/docker/run/wrong-passphrase/ run "$DAGGER" up -w "$TESTDIR"/stdlib/docker/run/ssh-wrong-passphrase/
assert_failure assert_failure
} }

View File

@ -1,9 +1,10 @@
package ecr package main
import ( import (
"dagger.io/aws" "dagger.io/aws"
"dagger.io/aws/ecr" "dagger.io/aws/ecr"
"dagger.io/dagger/op" "dagger.io/dagger/op"
"dagger.io/random"
) )
TestConfig: awsConfig: aws.#Config & { TestConfig: awsConfig: aws.#Config & {
@ -11,10 +12,12 @@ TestConfig: awsConfig: aws.#Config & {
} }
TestECR: { TestECR: {
random: #Random & {} suffix: random.#String & {
seed: ""
}
repository: "125635003186.dkr.ecr.\(TestConfig.awsConfig.region).amazonaws.com/dagger-ci" repository: "125635003186.dkr.ecr.\(TestConfig.awsConfig.region).amazonaws.com/dagger-ci"
tag: "test-ecr-\(random.out)" tag: "test-ecr-\(suffix.out)"
creds: ecr.#Credentials & { creds: ecr.#Credentials & {
config: TestConfig.awsConfig config: TestConfig.awsConfig
@ -27,7 +30,7 @@ TestECR: {
op.#DockerBuild & { op.#DockerBuild & {
dockerfile: """ dockerfile: """
FROM alpine FROM alpine
RUN echo \(random.out) > /test RUN echo \(suffix.out) > /test
""" """
}, },
@ -63,7 +66,7 @@ TestECR: {
op.#Exec & { op.#Exec & {
always: true always: true
args: [ args: [
"sh", "-c", "test $(cat test) = \(random.out)", "sh", "-c", "test $(cat test) = \(suffix.out)",
] ]
}, },
] ]
@ -78,7 +81,7 @@ TestECR: {
op.#DockerBuild & { op.#DockerBuild & {
dockerfile: #""" dockerfile: #"""
FROM \#(push.ref) FROM \#(push.ref)
RUN test $(cat test) = \#(random.out) RUN test $(cat test) = \#(suffix.out)
"""# """#
}, },
] ]

View File

@ -1,33 +0,0 @@
package ecr
import (
"strconv"
"dagger.io/alpine"
"dagger.io/dagger/op"
)
#Random: {
size: *12 | number
out: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
always: true
args: ["sh", "-c", #"""
tr -cd '[:alpha:]' < /dev/urandom | fold -w "$SIZE" | head -n 1 | tr '[A-Z]' '[a-z]' | tr -d '\n' > /rand
"""#,
]
env: SIZE: strconv.FormatInt(size, 10)
},
op.#Export & {
source: "/rand"
},
]
}
}

View File

@ -1,10 +1,11 @@
package docker package main
import ( import (
"dagger.io/dagger" "dagger.io/dagger"
"dagger.io/dagger/op" "dagger.io/dagger/op"
"dagger.io/alpine" "dagger.io/alpine"
"dagger.io/docker" "dagger.io/docker"
"dagger.io/random"
) )
source: dagger.#Artifact source: dagger.#Artifact
@ -15,9 +16,11 @@ registry: {
} }
TestPushAndPull: { TestPushAndPull: {
random: #Random & {} tag: random.#String & {
seed: ""
}
ref: "daggerio/ci-test:\(random.out)" ref: "daggerio/ci-test:\(tag.out)"
// Create image // Create image
image: docker.#ImageFromDockerfile & { image: docker.#ImageFromDockerfile & {

View File

@ -1,33 +0,0 @@
package docker
import (
"strconv"
"dagger.io/alpine"
"dagger.io/dagger/op"
)
#Random: {
size: *12 | number
out: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
always: true
args: ["sh", "-c", #"""
tr -cd '[:alpha:]' < /dev/urandom | fold -w "$SIZE" | head -n 1 | tr '[A-Z]' '[a-z]' | tr -d '\n' > /rand
"""#,
]
env: SIZE: strconv.FormatInt(size, 10)
},
op.#Export & {
source: "/rand"
},
]
}
}

View File

@ -0,0 +1,18 @@
package main
import (
"dagger.io/docker"
"dagger.io/dagger"
"dagger.io/random"
)
TestRun: {
suffix: random.#String & {
seed: ""
}
run: docker.#Run & {
name: "daggerci-test-local-\(suffix.out)"
ref: "hello-world"
}
}

View File

@ -0,0 +1,21 @@
name: default
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age:
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBpamtuNHB6NjY5L3VNT3hl
TGlmVFFoZURJR1RmZEFvSGUyVFRaSWNnSUMwClJiaDVGZWJoeDBMY21jZTVlREdS
aWg0SjNWN3BrTXRneXJyZy80K1JRSFUKLS0tIFEwKzdkVkNPT2VHTmtiOEdDQlZa
cnh2eHU5TzFjVkNvTzUyczFBL0pwTDQK60+wrLmTaD3Ws5ZAXdqBkMjaVP7Iz69k
UrkqkMbaUlvvSKK7dB5MuTGEEN6A1viAGal9ZjDHlSobkNPuE24QEA==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2021-06-04T23:50:06Z"
mac: ENC[AES256_GCM,data:GTsG9ekL5O04qwUSBb4hqRgQIiXL7keLXLt0gWpwLe0KUTu/JojAt0ALTiU8m5QWGy2q/avKIql8xR3SWWuBahOsKeObFbnx6PbVpU5QvZZKA8c72m2C+fDE82eKT3qZoTbwBEY3A/7v9BsFSCgkg3Hb91zVnBlXjiD949YAgP4=,iv:sYDEUDjyYJCoJFRP7EG19PTZgPaGa98gASs2B4fMAtE=,tag:CL5hhRG16EvuLwhPq5bdKQ==,type:str]
pgp: []
encrypted_suffix: secret
version: 3.7.1

View File

@ -3,6 +3,7 @@ package docker
import ( import (
"dagger.io/docker" "dagger.io/docker"
"dagger.io/dagger" "dagger.io/dagger"
"dagger.io/random"
) )
key: dagger.#Secret @dagger(input) key: dagger.#Secret @dagger(input)
@ -10,14 +11,16 @@ passphrase: dagger.#Secret @dagger(input)
user: string @dagger(input) user: string @dagger(input)
TestRun: { TestRun: {
random: #Random & {} suffix: random.#String & {
seed: ""
}
run: docker.#Run & { run: docker.#Run & {
host: "143.198.64.230" host: "143.198.64.230"
ref: "nginx:alpine" ref: "nginx:alpine"
"user": user "user": user
"passphrase": passphrase "passphrase": passphrase
name: "daggerci-test-simple-\(random.out)" name: "daggerci-test-simple-\(suffix.out)"
"key": key "key": key
} }
} }

View File

@ -1,33 +0,0 @@
package docker
import (
"strconv"
"dagger.io/alpine"
"dagger.io/dagger/op"
)
#Random: {
size: *12 | number
out: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
always: true
args: ["sh", "-c", #"""
tr -cd '[:alpha:]' < /dev/urandom | fold -w "$SIZE" | head -n 1 | tr '[A-Z]' '[a-z]' | tr -d '\n' > /rand
"""#,
]
env: SIZE: strconv.FormatInt(size, 10)
},
op.#Export & {
source: "/rand"
},
]
}
}

View File

@ -1,28 +0,0 @@
name: default
inputs:
key:
secret: ENC[AES256_GCM,data:OCiRUAarKcn5fK3jcAhV9xRS4AmpaXth6Bu8ozQ0dknyeM1ech2gzWMRfnBM1lIfcIxKAD/Dm7V4yJcj0sfGbgEsvpAslal6DYQ47lHDiGmDGDzu3dWAOqJpXwCCgsMagC/PoccsJPN4It0LyBW34dgBTB9NYC4fCX7ZpobLsw9Uf/JMAsxHp/nrUVhYDqHv2RXTV4zmdNIHjam+yFQLvSsSYdUOsEjx5DNMxmGM6Q9WuveqfM4sreetondvVzCVHBBB21dMO4WzJ2TwonobYvoSXxIVP/pHh0W3EIO46jLTvTv4NFAoyalFqTCf4ROPpsnFhCqLn10Iya1jn9h3QOrdsvA263zwv13bByPk+zOPRMJKfMN+VJMuKaT2a5zMVdhx35ULu9lEF6Xci7L1NEKIeRIfkyPHO5gSIdLVFGquU0qAasJ9rl7GDeTwyC9ejTJxOhbvPtmkq3ASFPkk7nC92IpOfjNVa3Y+hxxdmKKKJciSFcENGH0FvgbZo6gXft2dPpSiuwhbaxT42zJheOsLbTlgqzhJA8cHeT15kaOZNj/q0IkQStzo5P88EPdghNnEqq15szlKNS88gxbMIVuFpSFHDySBTHwOXXSmwrs=,iv:jNa+Pm4nOqAoQwa4b1auGvSYVPxNH3MQEagF5BKyyEs=,tag:vx8IUtpi9utnkzKSn/WTQw==,type:str]
passphrase:
secret: ENC[AES256_GCM,data:2pmIFddxYG8=,iv:Oty+wFlDEfzYcfXaJrhr6OOANP6o9gdD7fU0njEHloI=,tag:Ht4FJ0IZzQYazNcj1K0miw==,type:str]
user:
text: daggerci
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age:
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBXV3E3c3h4R0xKcnB5YUo5
eUdkeTZUbjZ4SU9VOTdEVzVPL296ZzRQMVNZCkMxblZKTXE0TDdhdy9PVk1sQ015
VWxxNjlLc2RMdUxFV3FrbVJMYk9KRzQKLS0tIHNGeXIvY3M5MTNHM05XTmNESkpZ
ZXAwa1h2aEhGRGpwVTJzKy9EZGhQb0kKSYnRAiRh7b2LViajHk46ct94PVLHDajC
oaUPwzy4bIMI9UXGobkstC5ObmY3ba+jcPRy6c9moniL+iigZ8YglA==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2021-06-03T11:33:27Z"
mac: ENC[AES256_GCM,data:r3ngidgRewF0HqD3jI0PXeLTBsWw2HmDc1RP0Gtvo+vvgMqVbQEM/5Y/oI3tKDOqpS7iPXC49AHnNAO/NouYk4grebz/Tksn4OjDmwE/TzRV/EmRnC6LrT3/Fwga6NlG4QkxdWop9i7Wc+ND3BoCTVnWYB3Zr8zwOMcQaiUOdjI=,iv:KSYagnxOYKwIYEZzkP61O+rO/u4q61duTUFUy1vARpw=,tag:vxvioVzcIgVRtqLBHGvMfA==,type:str]
pgp: []
encrypted_suffix: secret
version: 3.7.1

View File

@ -1,33 +0,0 @@
package docker
import (
"strconv"
"dagger.io/alpine"
"dagger.io/dagger/op"
)
#Random: {
size: *12 | number
out: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
always: true
args: ["sh", "-c", #"""
tr -cd '[:alpha:]' < /dev/urandom | fold -w "$SIZE" | head -n 1 | tr '[A-Z]' '[a-z]' | tr -d '\n' > /rand
"""#,
]
env: SIZE: strconv.FormatInt(size, 10)
},
op.#Export & {
source: "/rand"
},
]
}
}

View File

@ -1,20 +0,0 @@
package docker
import (
"dagger.io/docker"
"dagger.io/dagger"
)
key: dagger.#Secret @dagger(input)
TestRun: {
random: #Random & {}
run: docker.#Run & {
host: "143.198.64.230"
ref: "nginx:alpine"
user: "root"
name: "daggerci-test-simple-\(random.out)"
"key": key
}
}

View File

@ -1,24 +0,0 @@
name: default
inputs:
key:
secret: ENC[AES256_GCM,data:LdStiF5uyUW82+PE0pH2FxY9REawCC12KkmzP4tg8+GY64AIjoxMERTphmCE/wviTYTRQmzY3UniTd63cEVZ40FhiC+bUr1OnYfLmD/eaU2Sq2dfDdr1B11Vi1tFiq1Bm/InM05OpbUhwVeTGWFmOUuSYJAVcWwAV40nH/nxHg5KJQnPlmIxbmo4xtTkjE8yBgh5YsQy6A1oRap1wq+1GSJDYKDF/4f1C+7KtuNYhz82E+7L9O+OE356pWrVE1ocq4wh9uMIfswKDC1yIz5zdxU+VMfFAqqxLwMpZGJDIaZv5V1PEq7kgfK5xha7N0X3ek6woADd01rrYBTXbTov0Zce4GLXshaLKXDsWgFO75td7dRcH44+mKj9FFJCcBfVzID90fH80Q0JaZTNoZp0EJmLmIZ4p/D9OfziCL+MlMfHJCiK4i69wHxiZWBL7N918fMzr2SJaSqUEyWCZfvytjqzNKH4PGG0k/tO+KUDzDTVwpXU57RCvJU8imp4OpLoevjwEfjZ/i1IjDM+YjuVyHrffCpq1mX1OwkD,iv:A+8vdkhdye6bJfI+QMNOvCDproRsCO6m1CA1I1J9jlg=,tag:ujDkawZMuBfv9FEsKYnJZw==,type:str]
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age:
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBpamtuNHB6NjY5L3VNT3hl
TGlmVFFoZURJR1RmZEFvSGUyVFRaSWNnSUMwClJiaDVGZWJoeDBMY21jZTVlREdS
aWg0SjNWN3BrTXRneXJyZy80K1JRSFUKLS0tIFEwKzdkVkNPT2VHTmtiOEdDQlZa
cnh2eHU5TzFjVkNvTzUyczFBL0pwTDQK60+wrLmTaD3Ws5ZAXdqBkMjaVP7Iz69k
UrkqkMbaUlvvSKK7dB5MuTGEEN6A1viAGal9ZjDHlSobkNPuE24QEA==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2021-06-03T10:42:54Z"
mac: ENC[AES256_GCM,data:KU9f8Pa1hP7E59lmdt4tEIL4XJ+wMFbA8zHc/pzKXYiW9ryL94rDiFOzpcVcEtrSTEYl7J9ObnF0aGISWIMwlctOyBYpTOTz1ornzgdQaQn+ETGclcpi9pDtKWRSd7CQ4NmvbL51FUR0WmDDfBqIIjIg3RBwcWGZBTUCEy6aJjo=,iv:ZfZAedZWylLLvh+7Kka/ceb8XzQ+V/XkmPYKvAc6hHY=,tag:ymzo+Tb9M64BBJQSTNZXVA==,type:str]
pgp: []
encrypted_suffix: secret
version: 3.7.1

View File

@ -0,0 +1,32 @@
package main
import (
"dagger.io/docker"
"dagger.io/dagger"
"dagger.io/random"
)
TestConfig: {
host: string @dagger(input)
user: string @dagger(input)
key: dagger.#Secret @dagger(input)
passphrase: dagger.#Secret @dagger(input)
}
TestRun: {
suffix: random.#String & {
seed: ""
}
run: docker.#Run & {
ref: "hello-world"
name: "daggerci-test-simple-\(suffix.out)"
ssh: {
host: TestConfig.host
user: TestConfig.user
key: TestConfig.key
keyPassphrase: TestConfig.passphrase
}
}
}

View File

@ -0,0 +1,30 @@
name: default
inputs:
TestConfig.host:
text: 143.198.64.230
TestConfig.key:
secret: ENC[AES256_GCM,data:iSpHfMuEYSmLagYZieJSMPvVhNBYjirZRennHJUOgVv4tkQa7wDyXUgSKqEhNxaL8w5ETPJwQ3vQRpXX4B/bZrtogwkGkFIhHLqsQvaRaTzIUtGarIB1ePgfgAhfXPxQwvxdmspsltdJTb3m3sg6aHOf17U2Czxhm4TfYOl+La2z1MCTFCq/d6QVOVJDtxwqyNQma/gDYG6wrbQC8KAu6+8VomuaIg9K6q8GU87oKT6eXoTMMj1DAkjKI9psihP6+GRefepZCHv2uOZHIHCrosnFzbJA7Ui9plFH9SCj29svjD4Dt7lZdoWUNPVKfnKZvXE6DfQQU42PB55EKF1ygRQTuGu89KZK5bPZKXMwVD8bV2rcvQAElmigEzuZQEdWdimOtAHBWsDmybIqHZmoq31Y1PHvrGlV5/413lkh53XJT98dLcMeBHZvxZY9HoWcYOvec+oxrwpbABrGXDEpPC7U5Z/LQ18vPj5BWkKuvhmWdGh+SeAKp19kDHlYJLRuBQvDDzpniMAfhcKr1C5VE6vqusoQ9BtXGfOy0ypGJKXq6NSywXxeeD/D0AwvMJIVvpdsQCzLLd9eiwHcY8VbUHub4AIjYLz51in9wJWtM3g=,iv:FnbOqwiJLLrgyOdOJnt5ap+MSleQtb+h4kzZYH5FCnE=,tag:g1Y0O9zUxeHin8gjGcyO+g==,type:str]
TestConfig.passphrase:
secret: ENC[AES256_GCM,data:C56QpBGR1zc=,iv:TE+Emj96cxno141uaAhQ4xp71ecBA8DmHR6WUZn+Q0Q=,tag:ZarNOVhA2agB0UbToFbtfw==,type:str]
TestConfig.user:
text: daggerci
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age:
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBXV3E3c3h4R0xKcnB5YUo5
eUdkeTZUbjZ4SU9VOTdEVzVPL296ZzRQMVNZCkMxblZKTXE0TDdhdy9PVk1sQ015
VWxxNjlLc2RMdUxFV3FrbVJMYk9KRzQKLS0tIHNGeXIvY3M5MTNHM05XTmNESkpZ
ZXAwa1h2aEhGRGpwVTJzKy9EZGhQb0kKSYnRAiRh7b2LViajHk46ct94PVLHDajC
oaUPwzy4bIMI9UXGobkstC5ObmY3ba+jcPRy6c9moniL+iigZ8YglA==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2021-06-07T21:46:15Z"
mac: ENC[AES256_GCM,data:d+ZtEtXXoemDIuKPR1cVKjLHi4iKyfVz3hwwbvsCiAEqcbjVk19KMZIaxIM+LOL3Jm4O4Ud7Q+JKSLm1FBmUqrb+Q+hiYw67TPGZ7oS0nwUlJ5+JK/PMxWaYGCs4AdJ7wQjHguXX9Nx7td7oH4T47j+UpEKZluLrt8gZNwi8Qyo=,iv:qaTD/Q+cA+dVSsBcClkbWeNJo/3d+OumwKMLxFyQJAw=,tag:dcZ9RE+JUh04N8gMPdK3ZQ==,type:str]
pgp: []
encrypted_suffix: secret
version: 3.7.1

View File

@ -0,0 +1,32 @@
package main
import (
"dagger.io/docker"
"dagger.io/dagger"
"dagger.io/random"
)
TestConfig: {
host: string @dagger(input)
user: string @dagger(input)
key: dagger.#Secret @dagger(input)
passphrase: dagger.#Secret @dagger(input)
}
TestRun: {
suffix: random.#String & {
seed: ""
}
run: docker.#Run & {
name: "daggerci-test-simple-\(suffix.out)"
ref: "hello-world"
ssh: {
host: TestConfig.host
user: TestConfig.user
key: TestConfig.key
keyPassphrase: TestConfig.passphrase
}
}
}

View File

@ -0,0 +1,30 @@
name: default
inputs:
TestConfig,passphrase:
secret: ENC[AES256_GCM,data:HdlbbaOogb6G,iv:Q0D3w/bEtijvaEK2ac9zmj817x7xZM2OspTmPDVBJDg=,tag:i0iGhuqMng2spumFWve18Q==,type:str]
TestConfig.host:
text: 143.198.64.230
TestConfig.key:
secret: ENC[AES256_GCM,data:83GxfuWdylQiJJF9sjOOkr9hBvSxgKEdATWeTej/xGgfPxbXm6gkPSPbZSG/Kl2IRHqsR8vbkPfMEL6FH/Y0yqEtPdf+Jl7a0E6L3coM0LW/xFY0WxBjp6D5HOI8p23rTvGGu+CKg5F38Bay2Oi6OdHGT4rsXZbT3uCCVYpbjNn00euXhCJ1w08WtDHhFUYgCbN5d84Pa7fIVR79wUmoi95/ekPsq89O6fXyI78cWzDcDll4fheqKIif8n/CAiEA96Bmb+ENaYuhPkfvQYJCPSmxixc51lr62JFZbM5iyFHW58qgsEQRPhqPg8DTqLVHP3QEUdrHptn8HfFHxlfi8zm9F3bzXGtHlVNMpYXrEVG/8TjdnpxXXm80U8oSryBkP3DglT/bmuDpO4wX0rjSwM+iwp3nqMMWp/ewLxV10rlWBiJkQaPB38If/zjRuoyuzWM46+4tzOTP0uYdzgbGbzcnnKJKvvFv0Rj8aG93vpL+RPnajnp+H3mPN9PsVPgLIpDroWxsozdQjwFUQZE5V2PeosNwW8QmXtnN8QtLwsahLu5BPQ8UAED7HLJwCKmwTXUkPaWB9FsMyg9QL75ih5vTpNjbZiRskWQbfe8Az30=,iv:SPwVKo+7tbSqnEwxysPd8MCkmZwZq3gf8FfbnDjvieo=,tag:zyYfz/3uGPZ4Iuc1OEQk+A==,type:str]
TestConfig.user:
text: daggerci
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age:
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBDWjNjVWhSUnNuS2xaWFR2
Tm12UFg3elE0MUhILzJ0TkppQzR1VzZiUUMwClBwbncrR2VYVmxlZ09OUk1qV2tE
dURUZG1QVGZLdWM5WFlIQkF2UFB1YkUKLS0tIGFkN1VCajdkcHJRUk1YODBaWDFF
cm02K1NEenRnL25zc3RtaXd6SlA0UXcKFq38uYqZWvSlTOaisnhnQ+Mhbcv+ZifE
Mdxhq5w+Cdj+XhwbZ8UnnRInckD3UKovxAHV3kTSdXf54/QKn5TLVw==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2021-06-07T21:46:27Z"
mac: ENC[AES256_GCM,data:ok+QLvbyYtznT2dqUdMQDq1mSsLA5UdMfo04lZRFcn5NYnqUejwP5VZBA7aqR9QRbWg9h5S6VfSHskBEJklcQ2pKdi1Rd8nGWnmqULfnfB6riJ+oAdKo//+nwOIMEN/cyufjoi1Ptr21mXopnwsTOFlkgLYYYrDcIlvKlMxPrY8=,iv:YdN2OZbE/oMavwQlJig6mzZwGrKLMS/eJjFb743E1nM=,tag:dg4iA5azDhYeVNCCpK2Rsw==,type:str]
pgp: []
encrypted_suffix: secret
version: 3.7.1

View File

@ -0,0 +1,2 @@
# dagger state
state/**

View File

@ -0,0 +1,30 @@
package main
import (
"dagger.io/docker"
"dagger.io/dagger"
"dagger.io/random"
)
TestConfig: {
host: string @dagger(input)
user: string @dagger(input)
key: dagger.#Secret @dagger(input)
}
TestSSH: {
suffix: random.#String & {
seed: ""
}
run: docker.#Run & {
name: "daggerci-test-simple-\(suffix.out)"
ref: "hello-world"
ssh: {
host: TestConfig.host
user: TestConfig.user
key: TestConfig.key
}
}
}

View File

@ -0,0 +1,28 @@
name: default
inputs:
TestConfig.host:
text: 143.198.64.230
TestConfig.key:
secret: ENC[AES256_GCM,data:ewAmTZ7rBhcnl+Gq/OtDHepSypeSWcJU7D2KURc8usPLetdzFB7+3XTgLWmrKS/CUdHdTY1ND2CtviekLZOgfZpOEy1WpyJsVOukivTOcZOH474EguEd8LD9Ka91CiYuyv5gCKQX5QKG1OZ8tS81Nmou7o2gM9J++1HK2YzlPSUUglY5v0oeV+TQNRzSbim+5Xis7W8UoBBZKmw6hbVbyaCJl0eHhpRiBZuOH7/Q2nPwkdAmh75O35V/aBrrfUFNp5CT4OdyR/IrfnzY+Du9v+GpkRnCILFCiHJzd1as5ueVXmCbydNtVTWzhDnkQzJj9q780z9W/2YFMOp6I/cpHNlxBq9gXC3ogcHM34N6VcbVHC9gSHGNcOufuDUOXimbgboLNta9Icosj7GQNAq8hTbV0mbS6P+fYtUnDQMo177pjRPAHVNXpkQnuXb0jhPi2+MgdaywbXydcmD8F/WsWzqRxi3piL+W9QRn3+CzpI/z00svzJPUI6bRuC7gkfJUjUnyOyP+x5RMXzA8aoj1ufHzZS/nB3XesUS/,iv:gfYm2yjbr4IrAoRhPS9jbn2HwfQEhos2Xz4ghNkb0/k=,tag:lUGS4KBVczyzwu+Hp3ehXw==,type:str]
TestConfig.user:
text: root
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age:
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBpamtuNHB6NjY5L3VNT3hl
TGlmVFFoZURJR1RmZEFvSGUyVFRaSWNnSUMwClJiaDVGZWJoeDBMY21jZTVlREdS
aWg0SjNWN3BrTXRneXJyZy80K1JRSFUKLS0tIFEwKzdkVkNPT2VHTmtiOEdDQlZa
cnh2eHU5TzFjVkNvTzUyczFBL0pwTDQK60+wrLmTaD3Ws5ZAXdqBkMjaVP7Iz69k
UrkqkMbaUlvvSKK7dB5MuTGEEN6A1viAGal9ZjDHlSobkNPuE24QEA==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2021-06-07T21:46:00Z"
mac: ENC[AES256_GCM,data:hmw4ffQL+8lcDdevuJFy0lWD4ItISg2XxFCxNqaYhEOBneEkWQLJmrzX35yp3PoMvgDGLCFNFWamKEgU7WkXe9v4h19UmtOBJLRvj2USDguRBNUBMIiEyijwUbp+Eur28U7V3yWfeltCuBMw+woui9waQeG3PbDkoKUyBztuhS8=,iv:9vno6+T8SHeCiGIN+z95a8lKFaFzV0jimrAbsPQSmrc=,tag:uaN4MGeksUSCasaMyitFJQ==,type:str]
pgp: []
encrypted_suffix: secret
version: 3.7.1

View File

@ -1,33 +0,0 @@
package docker
import (
"strconv"
"dagger.io/alpine"
"dagger.io/dagger/op"
)
#Random: {
size: *12 | number
out: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
always: true
args: ["sh", "-c", #"""
tr -cd '[:alpha:]' < /dev/urandom | fold -w "$SIZE" | head -n 1 | tr '[A-Z]' '[a-z]' | tr -d '\n' > /rand
"""#,
]
env: SIZE: strconv.FormatInt(size, 10)
},
op.#Export & {
source: "/rand"
},
]
}
}

View File

@ -1,24 +0,0 @@
package docker
import (
"dagger.io/docker"
"dagger.io/dagger"
)
// Run with --input-file key=$HOME/.ssh/<your private server key>
key: dagger.#Secret @dagger(input)
passphrase: dagger.#Secret @dagger(input)
user: string @dagger(input)
TestRun: {
random: #Random & {}
run: docker.#Run & {
host: "143.198.64.230"
ref: "nginx:alpine"
"user": user
"passphrase": passphrase
name: "daggerci-test-simple-\(random.out)"
"key": key
}
}

View File

@ -1,28 +0,0 @@
name: default
inputs:
key:
secret: ENC[AES256_GCM,data:YbMbZupCsh3LmLK3SmQ9xSnTTC36jtt0GcM5a25222KCLYPIDmrratE/4TpklMBgr/dcCrWQIT7SsiKEjzAuJX0S9a3gvMWEPqixK53d/5D9QkRubxGogPo+UXg9yOEHbKkpKn7veLD+fNPuoWAIzid7aRSx8P01ZHervzTMshJE9yUSdMJSJysgbQborBKD0yV98PAIRbK8OgBKfXSic/ecGX1scxn2HIp8mzKPrpOBMd7YD8z95gROtSveAbKA4yhv3AdtCFZCGFPHsmt+6+rf1dJ+XL9ysfafLtbm507Ms01eAcNtNKuIaT7rtGcDoi77/EAc6ENRAqajVXZnjdA78XYvsiuqsKfXRDkMsFiH/grSxe4AI/goaOZsz6ahS8PDV36cePSsW/9E5ZWWfI5FmWUuDYuBL+NjVKW9EHdP9ERFKdh5U0/i7R4DXYl2vtsUqP1j74YYx9Fbj9OsqSqTA4jIPAMc8G2O8pJx0gJ+vLXr7YxEzW9mp45JA/1SGGlW3L4YW/ENyh2Aoh6PdPJ0XacLWsevIq8kuJYgDrgFpz52dO3vlMHz93U+pdHtelEgaqLmXOVEdvbKimJLmPa0Fe+I2cDrH5THt3APbO0=,iv:fQXqwrVKP2rqdYdRkVWlKxaB0w/Lc+Uf5i42fsdXDW8=,tag:UgTlsBylDI8ZjaM/smF2hA==,type:str]
passphrase:
secret: ENC[AES256_GCM,data:OWA7EULEzMMs,iv:k2WX+BP0qxIPVH5TgT2r2Mg7PRpfTcm89rOdRi2srzc=,tag:AbSGUKMmXcm0RW8+Az3taw==,type:str]
user:
text: daggerci
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age:
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBDWjNjVWhSUnNuS2xaWFR2
Tm12UFg3elE0MUhILzJ0TkppQzR1VzZiUUMwClBwbncrR2VYVmxlZ09OUk1qV2tE
dURUZG1QVGZLdWM5WFlIQkF2UFB1YkUKLS0tIGFkN1VCajdkcHJRUk1YODBaWDFF
cm02K1NEenRnL25zc3RtaXd6SlA0UXcKFq38uYqZWvSlTOaisnhnQ+Mhbcv+ZifE
Mdxhq5w+Cdj+XhwbZ8UnnRInckD3UKovxAHV3kTSdXf54/QKn5TLVw==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2021-06-03T11:42:23Z"
mac: ENC[AES256_GCM,data:FoRbtx3IwLsyVWlhG4+0P5gmYXygURRiHCCnWX9rfYmCtPyCV1GE0nGQg8nSuAVr1AMhEZ8dx0/WU6o/YHpEfZtTywB83RlL7WFFC4Tn9SVsgzpzA9XyB8TIYgGgzj859xn35iDV27jWnAmQEDL+cWKiOgghx8P4hhRoOurH/Qg=,iv:Cm0gX0UGzrWUnuMv2hKaVY9X92VLTUkv1+nDypYPd4o=,tag:bU8fTYrZMDQWFpscckYoPg==,type:str]
pgp: []
encrypted_suffix: secret
version: 3.7.1

View File

@ -1,18 +1,21 @@
package gcr package main
import ( import (
"dagger.io/gcp" "dagger.io/gcp"
"dagger.io/gcp/gcr" "dagger.io/gcp/gcr"
"dagger.io/dagger/op" "dagger.io/dagger/op"
"dagger.io/random"
) )
TestConfig: gcpConfig: gcp.#Config TestConfig: gcpConfig: gcp.#Config
TestGCR: { TestGCR: {
random: #Random & {} suffix: random.#String & {
seed: ""
}
repository: "gcr.io/dagger-ci/test" repository: "gcr.io/dagger-ci/test"
tag: "test-gcr-\(random.out)" tag: "test-gcr-\(suffix.out)"
creds: gcr.#Credentials & { creds: gcr.#Credentials & {
config: TestConfig.gcpConfig config: TestConfig.gcpConfig
@ -25,7 +28,7 @@ TestGCR: {
op.#DockerBuild & { op.#DockerBuild & {
dockerfile: """ dockerfile: """
FROM alpine FROM alpine
RUN echo \(random.out) > /test RUN echo \(suffix.out) > /test
""" """
}, },
@ -61,7 +64,7 @@ TestGCR: {
op.#Exec & { op.#Exec & {
always: true always: true
args: [ args: [
"sh", "-c", "test $(cat test) = \(random.out)", "sh", "-c", "test $(cat test) = \(suffix.out)",
] ]
}, },
] ]
@ -76,7 +79,7 @@ TestGCR: {
op.#DockerBuild & { op.#DockerBuild & {
dockerfile: #""" dockerfile: #"""
FROM \#(push.ref) FROM \#(push.ref)
RUN test $(cat test) = \#(random.out) RUN test $(cat test) = \#(suffix.out)
"""# """#
}, },
] ]

View File

@ -1,33 +0,0 @@
package gcr
import (
"strconv"
"dagger.io/alpine"
"dagger.io/dagger/op"
)
#Random: {
size: *12 | number
out: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
always: true
args: ["sh", "-c", #"""
tr -cd '[:alpha:]' < /dev/urandom | fold -w "$SIZE" | head -n 1 | tr '[A-Z]' '[a-z]' | tr -d '\n' > /rand
"""#,
]
env: SIZE: strconv.FormatInt(size, 10)
},
op.#Export & {
source: "/rand"
},
]
}
}

View File

@ -1,8 +1,9 @@
package helm package main
import ( import (
"dagger.io/dagger" "dagger.io/dagger"
"dagger.io/kubernetes/helm" "dagger.io/kubernetes/helm"
"dagger.io/random"
) )
// We assume that a kinD cluster is running locally // We assume that a kinD cluster is running locally
@ -11,11 +12,13 @@ kubeconfig: dagger.#Secret @dagger(input)
// Deploy user local chart // Deploy user local chart
TestHelmSimpleChart: { TestHelmSimpleChart: {
random: #Random & {} suffix: random.#String & {
seed: "simple"
}
// Deploy chart // Deploy chart
deploy: helm.#Chart & { deploy: helm.#Chart & {
name: "dagger-test-helm-simple-chart-\(random.out)" name: "dagger-test-helm-simple-chart-\(suffix.out)"
namespace: "dagger-test" namespace: "dagger-test"
"kubeconfig": kubeconfig "kubeconfig": kubeconfig
chartSource: dagger.#Artifact chartSource: dagger.#Artifact
@ -30,13 +33,16 @@ TestHelmSimpleChart: {
// Deploy remote chart // Deploy remote chart
TestHelmRepoChart: { TestHelmRepoChart: {
random: #Random & {} suffix: random.#String & {
seed: "repo"
}
// Deploy chart // Deploy chart
deploy: helm.#Chart & { deploy: helm.#Chart & {
name: "dagger-test-helm-repository-\(random.out)" name: "dagger-test-helm-repository-\(suffix.out)"
namespace: "dagger-test" namespace: "dagger-test"
"kubeconfig": kubeconfig "kubeconfig": kubeconfig
repository: "https://charts.bitnami.com/bitnami"
chart: "redis" chart: "redis"
} }

View File

@ -1,33 +0,0 @@
package helm
import (
"strconv"
"dagger.io/alpine"
"dagger.io/dagger/op"
)
#Random: {
size: *12 | number
out: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
always: true
args: ["sh", "-c", #"""
tr -cd '[:alpha:]' < /dev/urandom | fold -w "$SIZE" | head -n 1 | tr '[A-Z]' '[a-z]' | tr -d '\n' > /rand
"""#,
]
env: SIZE: strconv.FormatInt(size, 10)
},
op.#Export & {
source: "/rand"
},
]
}
}

View File

@ -1,4 +1,4 @@
package helm package main
import ( import (
"dagger.io/dagger/op" "dagger.io/dagger/op"

View File

@ -1,9 +1,10 @@
package kubernetes package main
import ( import (
"encoding/yaml" "encoding/yaml"
"dagger.io/dagger" "dagger.io/dagger"
"dagger.io/kubernetes" "dagger.io/kubernetes"
"dagger.io/random"
) )
// We assume that a kinD cluster is running locally // We assume that a kinD cluster is running locally
@ -11,13 +12,15 @@ import (
kubeconfig: dagger.#Secret @dagger(input) kubeconfig: dagger.#Secret @dagger(input)
TestKubeApply: { TestKubeApply: {
random: #Random & {} suffix: random.#String & {
seed: ""
}
// Pod spec // Pod spec
kubeSrc: { kubeSrc: {
apiVersion: "v1" apiVersion: "v1"
kind: "Pod" kind: "Pod"
metadata: name: "kube-test-\(random.out)" metadata: name: "kube-test-\(suffix.out)"
spec: { spec: {
restartPolicy: "Never" restartPolicy: "Never"
containers: [{ containers: [{

View File

@ -1,4 +1,4 @@
package kustomize package main
import ( import (
"encoding/yaml" "encoding/yaml"

View File

@ -1,4 +1,4 @@
package kustomize package main
import ( import (
"dagger.io/dagger/op" "dagger.io/dagger/op"

View File

@ -1,33 +0,0 @@
package kubernetes
import (
"strconv"
"dagger.io/alpine"
"dagger.io/dagger/op"
)
#Random: {
size: *12 | number
out: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
always: true
args: ["sh", "-c", #"""
tr -cd '[:alpha:]' < /dev/urandom | fold -w "$SIZE" | head -n 1 | tr '[A-Z]' '[a-z]' | tr -d '\n' > /rand
"""#,
]
env: SIZE: strconv.FormatInt(size, 10)
},
op.#Export & {
source: "/rand"
},
]
}
}

View File

@ -1,4 +1,4 @@
package kubernetes package main
import ( import (
"dagger.io/dagger/op" "dagger.io/dagger/op"

View File

@ -1,18 +1,21 @@
package netlify package main
import ( import (
"dagger.io/dagger/op" "dagger.io/dagger/op"
"dagger.io/alpine" "dagger.io/alpine"
"dagger.io/netlify" "dagger.io/netlify"
"dagger.io/random"
) )
TestNetlify: { TestNetlify: {
random: #Random & {} data: random.#String & {
seed: ""
}
// Generate a website containing the random number // Generate a website containing the random number
html: #up: [ html: #up: [
op.#WriteFile & { op.#WriteFile & {
content: random.out content: data.out
dest: "index.html" dest: "index.html"
}, },
] ]
@ -40,7 +43,7 @@ TestNetlify: {
"pipefail", "pipefail",
"-c", "-c",
#""" #"""
test "$(curl \#(deploy.deployUrl))" = "\#(random.out)" test "$(curl \#(deploy.deployUrl))" = "\#(data.out)"
"""#, """#,
] ]
}, },

View File

@ -1,33 +0,0 @@
package netlify
import (
"strconv"
"dagger.io/alpine"
"dagger.io/dagger/op"
)
#Random: {
size: *12 | number
out: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
always: true
args: ["sh", "-c", #"""
tr -cd '[:alpha:]' < /dev/urandom | fold -w "$SIZE" | head -n 1 | tr '[A-Z]' '[a-z]' | tr -d '\n' > /rand
"""#,
]
env: SIZE: strconv.FormatInt(size, 10)
},
op.#Export & {
source: "/rand"
},
]
}
}