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 ( import (
"dagger.io/dagger/op" "dagger.io/dagger/op"

View File

@ -1,21 +1,49 @@
package testing package main
import ( import (
"strconv"
"dagger.io/alpine" "dagger.io/alpine"
"dagger.io/dagger/op" "dagger.io/dagger/op"
) )
// Generate a random number #Random: {
random: { size: *12 | number
string
#up: [ out: {
op.#Load & {from: alpine.#Image}, string
op.#Exec & {
always: true #up: [
args: ["sh", "-c", "cat /dev/urandom | tr -dc 'a-z' | fold -w 10 | head -n 1 | tr -d '\n' > /rand"] op.#Load & {from: alpine.#Image & {
}, package: python3: "=~3.8"
op.#Export & { }},
source: "/rand"
}, 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 ( import (
"dagger.io/aws" "dagger.io/aws"

View File

@ -1,4 +1,4 @@
package ecr package main
import ( import (
"strconv" "strconv"
@ -14,12 +14,28 @@ import (
string string
#up: [ #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 & { op.#Exec & {
always: true always: true
args: ["sh", "-c", #""" 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) env: SIZE: strconv.FormatInt(size, 10)

View File

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

View File

@ -1,4 +1,4 @@
package docker package main
import ( import (
"strconv" "strconv"
@ -14,12 +14,28 @@ import (
string string
#up: [ #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 & { op.#Exec & {
always: true always: true
args: ["sh", "-c", #""" 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) env: SIZE: strconv.FormatInt(size, 10)

View File

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

View File

@ -1,4 +1,4 @@
package docker package main
import ( import (
"strconv" "strconv"
@ -14,12 +14,28 @@ import (
string string
#up: [ #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 & { op.#Exec & {
always: true always: true
args: ["sh", "-c", #""" 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) env: SIZE: strconv.FormatInt(size, 10)

View File

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

View File

@ -1,4 +1,4 @@
package docker package main
import ( import (
"strconv" "strconv"
@ -14,12 +14,28 @@ import (
string string
#up: [ #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 & { op.#Exec & {
always: true always: true
args: ["sh", "-c", #""" 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) env: SIZE: strconv.FormatInt(size, 10)

View File

@ -1,4 +1,4 @@
package docker package main
import ( import (
"strconv" "strconv"
@ -14,12 +14,28 @@ import (
string string
#up: [ #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 & { op.#Exec & {
always: true always: true
args: ["sh", "-c", #""" 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) env: SIZE: strconv.FormatInt(size, 10)

View File

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

View File

@ -1,4 +1,4 @@
package docker package main
import ( import (
"strconv" "strconv"
@ -14,12 +14,28 @@ import (
string string
#up: [ #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 & { op.#Exec & {
always: true always: true
args: ["sh", "-c", #""" 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) env: SIZE: strconv.FormatInt(size, 10)

View File

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

View File

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

View File

@ -1,4 +1,4 @@
package gcr package main
import ( import (
"strconv" "strconv"
@ -14,12 +14,28 @@ import (
string string
#up: [ #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 & { op.#Exec & {
always: true always: true
args: ["sh", "-c", #""" 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) env: SIZE: strconv.FormatInt(size, 10)

View File

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

View File

@ -1,4 +1,4 @@
package helm package main
import ( import (
"strconv" "strconv"
@ -14,12 +14,28 @@ import (
string string
#up: [ #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 & { op.#Exec & {
always: true always: true
args: ["sh", "-c", #""" 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) env: SIZE: strconv.FormatInt(size, 10)

View File

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

View File

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

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,4 +1,4 @@
package kubernetes package main
import ( import (
"strconv" "strconv"
@ -14,12 +14,28 @@ import (
string string
#up: [ #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 & { op.#Exec & {
always: true always: true
args: ["sh", "-c", #""" 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) env: SIZE: strconv.FormatInt(size, 10)

View File

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

View File

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

View File

@ -1,4 +1,4 @@
package netlify package main
import ( import (
"strconv" "strconv"
@ -14,12 +14,28 @@ import (
string string
#up: [ #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 & { op.#Exec & {
always: true always: true
args: ["sh", "-c", #""" 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) env: SIZE: strconv.FormatInt(size, 10)