stdlib: add random package
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
@@ -4,15 +4,18 @@ import (
|
||||
"dagger.io/gcp"
|
||||
"dagger.io/gcp/gcr"
|
||||
"dagger.io/dagger/op"
|
||||
"dagger.io/random"
|
||||
)
|
||||
|
||||
TestConfig: gcpConfig: gcp.#Config
|
||||
|
||||
TestGCR: {
|
||||
random: #Random & {}
|
||||
suffix: random.#String & {
|
||||
seed: ""
|
||||
}
|
||||
|
||||
repository: "gcr.io/dagger-ci/test"
|
||||
tag: "test-gcr-\(random.out)"
|
||||
tag: "test-gcr-\(suffix.out)"
|
||||
|
||||
creds: gcr.#Credentials & {
|
||||
config: TestConfig.gcpConfig
|
||||
@@ -25,7 +28,7 @@ TestGCR: {
|
||||
op.#DockerBuild & {
|
||||
dockerfile: """
|
||||
FROM alpine
|
||||
RUN echo \(random.out) > /test
|
||||
RUN echo \(suffix.out) > /test
|
||||
"""
|
||||
},
|
||||
|
||||
@@ -61,7 +64,7 @@ TestGCR: {
|
||||
op.#Exec & {
|
||||
always: true
|
||||
args: [
|
||||
"sh", "-c", "test $(cat test) = \(random.out)",
|
||||
"sh", "-c", "test $(cat test) = \(suffix.out)",
|
||||
]
|
||||
},
|
||||
]
|
||||
@@ -76,7 +79,7 @@ TestGCR: {
|
||||
op.#DockerBuild & {
|
||||
dockerfile: #"""
|
||||
FROM \#(push.ref)
|
||||
RUN test $(cat test) = \#(random.out)
|
||||
RUN test $(cat test) = \#(suffix.out)
|
||||
"""#
|
||||
},
|
||||
]
|
||||
|
@@ -1,49 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"dagger.io/alpine"
|
||||
"dagger.io/dagger/op"
|
||||
)
|
||||
|
||||
#Random: {
|
||||
size: *12 | number
|
||||
|
||||
out: {
|
||||
string
|
||||
|
||||
#up: [
|
||||
op.#Load & {from: alpine.#Image & {
|
||||
package: python3: "=~3.8"
|
||||
}},
|
||||
|
||||
op.#WriteFile & {
|
||||
dest: "/entrypoint.py"
|
||||
content: #"""
|
||||
import random
|
||||
import string
|
||||
import os
|
||||
|
||||
size = int(os.environ['SIZE'])
|
||||
letters = string.ascii_lowercase
|
||||
|
||||
print ( ''.join(random.choice(letters) for i in range(size)) )
|
||||
"""#
|
||||
},
|
||||
|
||||
op.#Exec & {
|
||||
always: true
|
||||
args: ["sh", "-c", #"""
|
||||
printf "$(python3 /entrypoint.py)" > /rand
|
||||
"""#,
|
||||
]
|
||||
env: SIZE: strconv.FormatInt(size, 10)
|
||||
},
|
||||
|
||||
op.#Export & {
|
||||
source: "/rand"
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user