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/docker/push-pull/random.cue
Tom Chauveau fdb91a7332 Refactor random generation into a definition to make it reusable
Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
2021-06-07 23:39:41 +02:00

34 lines
472 B
CUE

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