Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .github/workflows/publish.yml
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .npmignore
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
163 changes: 93 additions & 70 deletions package-lock.json
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
},
"dependencies": {
"command-line-args": "^5.2.0",
"follow-redirects": "^1.14.1"
"follow-redirects": "^1.14.1",
"yargs": "^17.2.0"
}
}
16 changes: 13 additions & 3 deletions scripts/shared/environment.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { existsSync, readFileSync } = require('fs');
const path = require('path');
const yargs = require('yargs');

const currentEnv = {
TFCRC_PATH: undefined,
Expand All @@ -21,19 +22,28 @@ const Environment = (render) => {
});
}

const args = yargs(process.argv.slice(4))
.options('workspace', {
default: process.env.TFC_WORKSPACE || TFC_CONFIG.TFC_WORKSPACE || TFC_CONFIG.WORKSPACE_ID
})
.options('token', {
default: process.env.TFC_TOKEN || TFC_CONFIG.TFC_TOKEN
})
.argv;

currentEnv.config = {
// args: process.argv,
paths: {
pwd: process.env.PWD,
home: process.env.HOME,
},
secrets: {
TFC_TOKEN: process.env.TFC_TOKEN || TFC_CONFIG.TFC_TOKEN,
TFC_WORKSPACE: process.env.TFC_WORKSPACE || TFC_CONFIG.TFC_WORKSPACE || TFC_CONFIG.WORKSPACE_ID,
TFC_TOKEN: args.token,
TFC_WORKSPACE: args.workspace,
},
action: process.argv[3] || '',
resource: process.argv[2] || '',
args: process.argv.slice(4)
args
}
}

Expand Down
Empty file modified scripts/shared/request.js
100644 → 100755
Empty file.
Empty file modified scripts/terraform/help.js
100644 → 100755
Empty file.
8 changes: 6 additions & 2 deletions scripts/terraform/resources/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ const OUTPUT = {
const state = await Request('app.terraform.io', 'GET', `/api/v2/workspaces/${env.secrets.TFC_WORKSPACE}/current-state-version`, {
'Authorization': `Bearer ${env.secrets.TFC_TOKEN}`
});

const output_id = JSON.parse(state).data.relationships.outputs.data[0].id;
const stateObj = JSON.parse(state);
if (stateObj.data.relationships.outputs.data.length <= 0) {
console.log('error: No outputs in current workspace');
return;
}
const output_id = stateObj.data.relationships.outputs.data[0].id;

let outputs = await Request('app.terraform.io', 'GET', `/api/v2/state-version-outputs/${output_id}`, {
'Authorization': `Bearer ${env.secrets.TFC_TOKEN}`
Expand Down