From 5e803aa57e73f26e048e99f963ed1e3462dd56cf Mon Sep 17 00:00:00 2001 From: Giles Bradshaw Date: Tue, 28 Jul 2020 17:09:34 +0100 Subject: [PATCH] composed secret printing --- .drone-home.jsonnet | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/.drone-home.jsonnet b/.drone-home.jsonnet index a5bfae0..f72f362 100644 --- a/.drone-home.jsonnet +++ b/.drone-home.jsonnet @@ -1,5 +1,9 @@ -local secrets = [ - 'ssh-host' +local publicSecrets = [ + 'ssh-host', + 'ssh-user', +]; +local secretSecrets = [ + 'ssh-passwoprd', ]; local util = { // the head of an array @@ -52,7 +56,7 @@ local util = { '_', ), ), - printEnv(file, env): function(step) step { + envSet(env): function(step) step { environment +: { [util.environment(env)]: util.fromSecret( util.secret(env) @@ -62,6 +66,10 @@ local util = { envs +: [ util.env(env), ], + }, + }, + printEnv(file, env): function(step) envSet(env)(step) { + settings +: { script +: [ 'echo "export %(environment)s=\'$${%(environment)s}\'" >> %(file)s # "%(secret)s"' % { environment: util.environment(env), @@ -153,12 +161,6 @@ local images = { path: '/etc/docker/certs.d', }, }, - { - name: 'ssh', - host: { - path: '/home/giles/.ssh' - }, - }, ], steps:[ images.scp( @@ -179,7 +181,30 @@ local images = { ], }, }, - ) + ),/* + images.ssh { + name: 'deploy portainer', + "environment": environment(secrets), + "settings": { + "envs": [x.replace("-", "_") for x in secrets ], + username: util.fromSecret("ssh-root-user"), + password: util.fromSecret("ssh-root-password"), + script: [ + 'set -e', + 'echo go', + ] + + map(export, secrets) + + [ + "export DRONE_REPO_LINK=$${{DRONE_GITEA_SERVER}}/{namespace}/{name}".format(name=ctx.repo.name, namespace=ctx.repo.namespace), + "export DRONE_COMMIT={commit}".format(commit=ctx.build.commit), + "docker network prune -f", + "cd {folder}".format(folder=folder), + "docker stack rm {name}".format(name = name), + "sleep 30", + "docker stack deploy -c {filename} {name}".format(name= name, filename = filename), + ] + commands + } + }*/ ], } ]