From aba96f44137a705b5390175a6c00892782c9a6f9 Mon Sep 17 00:00:00 2001 From: Giles Bradshaw Date: Tue, 28 Jul 2020 16:01:03 +0100 Subject: [PATCH] ssh print an env --- .drone-home.jsonnet | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/.drone-home.jsonnet b/.drone-home.jsonnet index fdbc75c..87d14f4 100644 --- a/.drone-home.jsonnet +++ b/.drone-home.jsonnet @@ -2,6 +2,37 @@ local util = { fromSecret(secret): { from_secret: secret, }, + printEnv(file, env): function(step) step { + environment +: { + [std.asciiHigher(env)]: util.fromSecret( + std.asciiLower( + std.strReplace( + env, + '_', + '-', + ), + ), + ), + }, + settings +: { + envs +: [ + std.asciiLower(env), + ], + script +: [ + 'echo "export %(environment)=\'$${%(environment)s}\'" >> %(file) # %(secret)s' % { + environment: std.asciiHigher(env), + file: file, + secret: std.asciiLower( + std.strReplace( + env, + '_', + '-', + ), + ), + }, + ], + }, + }, }; local images = { docker: { @@ -96,9 +127,14 @@ local images = { '/stack/root' ), images.wait(15), - images.ssh { - name: 'ssh nothing', - }, + images.printEnv( + 'afile', + 'ssh_host', + )( + images.ssh { + name: 'will print ssh-host', + }, + ) ], } ]