Skip to content

Commit

Permalink
feat(docker): gtm-worker 1.7.0+ support to overlay/import scripts int…
Browse files Browse the repository at this point in the history
…o execution workspace at runtim
  • Loading branch information
wyvern8 committed Jul 12, 2018
1 parent 6a57bf2 commit 9ecd1d5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .envExample
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ GTM_SLS_EXECUTOR_VPC_SUBNET_A=
GTM_SLS_EXECUTOR_VPC_SUBNET_B=
GTM_SLS_EXECUTOR_VPC_SUBNET_C=
GTM_SLS_EXECUTOR_AWS_KMS_KEY_ID=
GTM_WORKER_SCRIPTS_CLONE=<optional git repo https url to clone and overlay>
GTM_WORKER_SCRIPTS_PATH=<path within scripts dir to use as overlay>

GTM_CRYPT_GITHUB_TOKEN=<redacted>
GTM_CRYPT_GITHUB_WEBHOOK_SECRET=<redacted>
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ Create an asynchronous CI agnostic mechanism for running custom test stage gates
|GTM_SLS_EXECUTOR_VPC_SUBNET_B| vpc az subnet |
|GTM_SLS_EXECUTOR_VPC_SUBNET_C| vpc az subnet |
|GTM_SLS_EXECUTOR_AWS_KMS_KEY_ID| kms key id for sls env var encryption |
|GTM_WORKER_SCRIPTS_CLONE| for docker executors using https://github.com/zotoio/gtm-worker based image - url of git repo to overlay on workspace eg. https://github.com/zotoio/gtm-worker-scripts.git |
|GTM_WORKER_SCRIPTS_PATH| directory within scripts clone repo to overlay|

> important: values of env vars prefixed with `GTM_CRYPT_*` must be created via `npm run sls-encrypt [name] [value]`
Expand Down
8 changes: 7 additions & 1 deletion src/executors/ExecutorDockerServerless.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ export class ExecutorDockerServerless extends ExecutorDocker {
SLS_VPC_SUBNET_A: process.env.GTM_SLS_EXECUTOR_VPC_SUBNET_A,
SLS_VPC_SUBNET_B: process.env.GTM_SLS_EXECUTOR_VPC_SUBNET_B,
SLS_VPC_SUBNET_C: process.env.GTM_SLS_EXECUTOR_VPC_SUBNET_C,
SLS_AWS_KMS_KEY_ID: process.env.GTM_SLS_EXECUTOR_AWS_KMS_KEY_ID
SLS_AWS_KMS_KEY_ID: process.env.GTM_SLS_EXECUTOR_AWS_KMS_KEY_ID,
GTM_WORKER_SCRIPTS_CLONE: process.env.GTM_WORKER_SCRIPTS_CLONE,
GTM_WORKER_SCRIPTS_PATH: process.env.GTM_WORKER_SCRIPTS_PATH
},
validator: {
type: 'outputRegex',
Expand Down Expand Up @@ -140,6 +142,10 @@ export class ExecutorDockerServerless extends ExecutorDocker {
if (process.env.GTM_CRYPT_GITHUB_TOKEN) {
let decyptedToken = await KmsUtils.decrypt(process.env.GTM_CRYPT_GITHUB_TOKEN);
task.options.env.GIT_CLONE = task.options.env.GIT_CLONE.replace('https://', `https://${decyptedToken}@`);
task.options.env.GTM_WORKER_SCRIPTS_CLONE = task.options.env.GTM_WORKER_SCRIPTS_CLONE.replace(
'https://',
`https://${decyptedToken}@`
);
}

return task.options;
Expand Down

0 comments on commit 9ecd1d5

Please sign in to comment.