40 lines
1.2 KiB
Plaintext
40 lines
1.2 KiB
Plaintext
load("@this//:map.star", "map")
|
|
load("@this//:from-secret.star", "fromSecret")
|
|
load("@this//:environment.star", "environment")
|
|
|
|
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 = secret.replace("-", "_").upper(),
|
|
)
|
|
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)]
|
|
}
|
|
}
|