tests: fix random

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2021-06-08 11:34:16 -07:00
parent 7ce8dd26f1
commit 4c40a87634
26 changed files with 247 additions and 59 deletions

View File

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

View File

@ -1,21 +1,49 @@
package testing
package main
import (
"strconv"
"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"
},
]
#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"
},
]
}
}

View File

@ -1,4 +1,4 @@
package ecr
package main
import (
"dagger.io/aws"

View File

@ -1,4 +1,4 @@
package ecr
package main
import (
"strconv"
@ -14,12 +14,28 @@ import (
string
#up: [
op.#Load & {from: alpine.#Image},
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", #"""
tr -cd '[:alpha:]' < /dev/urandom | fold -w "$SIZE" | head -n 1 | tr '[A-Z]' '[a-z]' | tr -d '\n' > /rand
printf "$(python3 /entrypoint.py)" > /rand
"""#,
]
env: SIZE: strconv.FormatInt(size, 10)

View File

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

View File

@ -1,4 +1,4 @@
package docker
package main
import (
"strconv"
@ -14,12 +14,28 @@ import (
string
#up: [
op.#Load & {from: alpine.#Image},
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", #"""
tr -cd '[:alpha:]' < /dev/urandom | fold -w "$SIZE" | head -n 1 | tr '[A-Z]' '[a-z]' | tr -d '\n' > /rand
printf "$(python3 /entrypoint.py)" > /rand
"""#,
]
env: SIZE: strconv.FormatInt(size, 10)

View File

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

View File

@ -1,4 +1,4 @@
package docker
package main
import (
"strconv"
@ -14,12 +14,28 @@ import (
string
#up: [
op.#Load & {from: alpine.#Image},
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", #"""
tr -cd '[:alpha:]' < /dev/urandom | fold -w "$SIZE" | head -n 1 | tr '[A-Z]' '[a-z]' | tr -d '\n' > /rand
printf "$(python3 /entrypoint.py)" > /rand
"""#,
]
env: SIZE: strconv.FormatInt(size, 10)

View File

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

View File

@ -1,4 +1,4 @@
package docker
package main
import (
"strconv"
@ -14,12 +14,28 @@ import (
string
#up: [
op.#Load & {from: alpine.#Image},
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", #"""
tr -cd '[:alpha:]' < /dev/urandom | fold -w "$SIZE" | head -n 1 | tr '[A-Z]' '[a-z]' | tr -d '\n' > /rand
printf "$(python3 /entrypoint.py)" > /rand
"""#,
]
env: SIZE: strconv.FormatInt(size, 10)

View File

@ -1,4 +1,4 @@
package docker
package main
import (
"strconv"
@ -14,12 +14,28 @@ import (
string
#up: [
op.#Load & {from: alpine.#Image},
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", #"""
tr -cd '[:alpha:]' < /dev/urandom | fold -w "$SIZE" | head -n 1 | tr '[A-Z]' '[a-z]' | tr -d '\n' > /rand
printf "$(python3 /entrypoint.py)" > /rand
"""#,
]
env: SIZE: strconv.FormatInt(size, 10)

View File

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

View File

@ -1,4 +1,4 @@
package docker
package main
import (
"strconv"
@ -14,12 +14,28 @@ import (
string
#up: [
op.#Load & {from: alpine.#Image},
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", #"""
tr -cd '[:alpha:]' < /dev/urandom | fold -w "$SIZE" | head -n 1 | tr '[A-Z]' '[a-z]' | tr -d '\n' > /rand
printf "$(python3 /entrypoint.py)" > /rand
"""#,
]
env: SIZE: strconv.FormatInt(size, 10)

View File

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

View File

@ -1,4 +1,4 @@
package gcr
package main
import (
"dagger.io/gcp"

View File

@ -1,4 +1,4 @@
package gcr
package main
import (
"strconv"
@ -14,12 +14,28 @@ import (
string
#up: [
op.#Load & {from: alpine.#Image},
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", #"""
tr -cd '[:alpha:]' < /dev/urandom | fold -w "$SIZE" | head -n 1 | tr '[A-Z]' '[a-z]' | tr -d '\n' > /rand
printf "$(python3 /entrypoint.py)" > /rand
"""#,
]
env: SIZE: strconv.FormatInt(size, 10)

View File

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

View File

@ -1,4 +1,4 @@
package helm
package main
import (
"strconv"
@ -14,12 +14,28 @@ import (
string
#up: [
op.#Load & {from: alpine.#Image},
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", #"""
tr -cd '[:alpha:]' < /dev/urandom | fold -w "$SIZE" | head -n 1 | tr '[A-Z]' '[a-z]' | tr -d '\n' > /rand
printf "$(python3 /entrypoint.py)" > /rand
"""#,
]
env: SIZE: strconv.FormatInt(size, 10)

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
package kubernetes
package main
import (
"strconv"
@ -14,12 +14,28 @@ import (
string
#up: [
op.#Load & {from: alpine.#Image},
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", #"""
tr -cd '[:alpha:]' < /dev/urandom | fold -w "$SIZE" | head -n 1 | tr '[A-Z]' '[a-z]' | tr -d '\n' > /rand
printf "$(python3 /entrypoint.py)" > /rand
"""#,
]
env: SIZE: strconv.FormatInt(size, 10)

View File

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

View File

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

View File

@ -1,4 +1,4 @@
package netlify
package main
import (
"strconv"
@ -14,12 +14,28 @@ import (
string
#up: [
op.#Load & {from: alpine.#Image},
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", #"""
tr -cd '[:alpha:]' < /dev/urandom | fold -w "$SIZE" | head -n 1 | tr '[A-Z]' '[a-z]' | tr -d '\n' > /rand
printf "$(python3 /entrypoint.py)" > /rand
"""#,
]
env: SIZE: strconv.FormatInt(size, 10)