Skip to content

Commit

Permalink
Retrieve exclusion list from environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
0x2b3bfa0 committed Oct 11, 2022
1 parent e9be72b commit 251ce86
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
8 changes: 7 additions & 1 deletion src/cml.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,13 @@ class CML {
}

async startRunner(opts = {}) {
return await this.getDriver().startRunner(opts);
const env = {};
const sensitive =
['CML_RUNNER_SENSITIVE_ENV'] +
process.env.CML_RUNNER_SENSITIVE_ENV.split(':');
for (const variable in process.env)
if (!sensitive.includes(variable)) env[variable] = process.env[variable];
return await this.getDriver().startRunner({ ...opts, env });
}

async registerRunner(opts = {}) {
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/bitbucket_cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class BitbucketCloud {

async startRunner(opts) {
const { projectPath } = this;
const { workdir, name, labels } = opts;
const { workdir, name, labels, env } = opts;

winston.warn(
`Bitbucket runner is working under /tmp folder and not under ${workdir} as expected`
Expand Down Expand Up @@ -155,7 +155,7 @@ class BitbucketCloud {
${gpu ? '--runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all' : ''} \
docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-runner:1`;

return spawn(command, { shell: true });
return spawn(command, { shell: true, env });
} catch (err) {
throw new Error(`Failed preparing runner: ${err.message}`);
}
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class Github {
}

async startRunner(opts) {
const { workdir, single, name, labels } = opts;
const { workdir, single, name, labels, env } = opts;

try {
const runnerCfg = resolve(workdir, '.runner');
Expand Down Expand Up @@ -285,7 +285,7 @@ class Github {

return spawn(resolve(workdir, 'run.sh'), {
shell: true,
env: {}
env
});
} catch (err) {
throw new Error(`Failed preparing GitHub runner: ${err.message}`);
Expand Down
5 changes: 3 additions & 2 deletions src/drivers/gitlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ class Gitlab {
single,
labels,
name,
dockerVolumes = []
dockerVolumes = [],
env
} = opts;

const gpu = await gpuPresent();
Expand Down Expand Up @@ -210,7 +211,7 @@ class Gitlab {
${dockerVolumesTpl} \
${single ? '--max-builds 1' : ''}`;

return spawn(command, { shell: true, env: {} });
return spawn(command, { shell: true, env });
} catch (err) {
if (err.message === 'Forbidden')
err.message +=
Expand Down

0 comments on commit 251ce86

Please sign in to comment.