This repository has been archived on 2020-08-11. You can view files and clone it, but cannot push or open issues or pull requests.
stack/drone-starlark/repos/print-secrets.star

44 lines
1.3 KiB
Plaintext
Raw Normal View History

2020-04-26 11:56:39 +00:00
load("@this//:map.star", "map")
2020-04-26 12:02:57 +00:00
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]
2020-04-26 12:05:32 +00:00
2020-04-26 12:02:57 +00:00
def secretToEnvironment(secret):
return secret.replace("-", "_").upper()
2020-04-26 11:56:39 +00:00
2020-04-26 11:53:32 +00:00
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)]
}
}