.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Giles Bradshaw 2020-04-26 13:21:26 +01:00
parent afadc06966
commit 8e7e549162
2 changed files with 46 additions and 6 deletions

View File

@ -1,9 +1,49 @@
load("@this//:from-secret.star", "fromSecret") load("@this//:fromsecret.star", "example_step")
load("@this//:print-secrets.star", "printSecrets") def fromSecret(name):
load("@this//:print-secrets.star", "environment") return {
load("@this//:print-secrets.star", "export") "from_secret": name
load("@this//:map.star", "map") }
def environment(env):
return dict(
[(x.replace("-", "_").upper(), fromSecret(x)) for x in env]
)
def map(fn, l):
return [fn(x) for x in l]
def secretToEnvironment(secret):
return secret.replace("-", "_").upper()
def echo(secret):
return 'echo "export {environment}=${environment}" >> ***filename*** # {secret}'.format(
secret = secret,
environment = secret.replace("-", "_").upper(),
)
def echoSecret(secret):
return 'echo "export {environment}=???" >> ***filename*** # {secret}'.format(
secret = secret,
environment = secret.replace("-", "_").upper()
)
def export(secret):
return "export {toCaps}=${toCaps}".format(
toCaps = secretToEnvironment(secret),
)
def printSecrets(filename, env, secretEnv):
return {
"name": "print secrets",
"image": "appleboy/drone-ssh",
"environment": environment(env),
"settings": {
"envs": [x.replace("-", "_") for x in env ],
"host": fromSecret("ssh-host"),
"port": fromSecret("ssh-port"),
"username": fromSecret("ssh-user"),
"password": fromSecret("ssh-password"),
"script": [x.replace("***filename***", filename) for x in [
"rm -f env-stack",
] + map(echo, env)
+ map(echoSecret, secretEnv)]
}
}
def wait(delay, name): def wait(delay, name):
return { return {
"name": name, "name": name,

View File

@ -21,7 +21,7 @@ def echoSecret(secret):
def export(secret): def export(secret):
return "export {toCaps}=${toCaps}".format( return "export {toCaps}=${toCaps}".format(
toCaps = secretToEnvironment(secret), toCaps = secret.replace("-", "_").upper(),
) )
def printSecrets(filename, env, secretEnv): def printSecrets(filename, env, secretEnv):
return { return {