This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
dagger/tests/stdlib/netlify/.dagger/env/default/plan/random.cue
Andrea Luzzardi 4c40a87634 tests: fix random
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
2021-06-08 11:34:16 -07:00

50 lines
726 B
CUE

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"
},
]
}
}