Skip to content
Open
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
20 changes: 15 additions & 5 deletions lib/interface/cli/commands/context/get.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,25 @@ const command = new Command({
.option('type', {
describe: 'Context type',
choices: [
'config', 'git.bitbucket-server', 'git.bitbucket', 'git.github', 'git.gitlab',
'git.stash', 'helm-repository', 'secret-yaml', 'secret', 'storage.gc', 'storage.s3', 'yaml',
'secret-store.kubernetes', 'secret-store.kubernetes-runtime',
'config', 'git.bitbucket-server', 'git.bitbucket', 'git.github', 'git.github-app',
'git.codefresh-github-app', 'git.gitlab', 'git.stash', 'helm-repository', 'secret-yaml', 'secret',
'storage.gc', 'storage.s3', 'yaml', 'secret-store.kubernetes', 'secret-store.kubernetes-runtime',
],
})
.option('decrypt', {
describe: 'Either to show decoded credentials or not',
})
.option('prepare', {
describe: 'Activate tokens in case its invalid',
describe: 'Activate tokens in case its invalid. It\'s supported only for types: '
+ '`git.codefresh-github-app`, `git.github-app` and `git.bitbucket` (OAuth2)',
})
.option('force-prepare', {
describe: 'Refresh the token even if the current token is still valid. Unlike `--prepare`, '
+ 'which only refreshes expired tokens, this flag forces a token refresh unconditionally. '
+ 'It\'s supported only for `git.bitbucket` (OAuth2)',
})
.example('codefresh get context NAME', 'Get context NAME')
.example('codefresh get context NAME --prepare', 'Get context by NAME and active token if it\'s expired')
.example('codefresh get contexts', 'Get all contexts')
.example('codefresh get context --decrypt', 'Get all contexts with credentials decrypted')
.example('codefresh get context --type secret', 'Get all secret contexts')
Expand All @@ -50,10 +57,13 @@ const command = new Command({
}
data.decrypt = argv.decrypt || undefined;
data.prepare = argv.prepare || undefined;
data.forcePrepare = argv['force-prepare'] || undefined;

let contexts = [];
if (!_.isEmpty(names)) {
if (data.prepare) {
if (data.forcePrepare) {
contexts = await Promise.map(names, name => sdk.contexts.prepare({ name, forceRefresh: true }));
} else if (data.prepare) {
contexts = await Promise.map(names, name => sdk.contexts.prepare({ name }));
} else {
contexts = await Promise.map(names, name => sdk.contexts.get({ name, decrypt: data.decrypt }));
Expand Down
11 changes: 10 additions & 1 deletion openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3128,7 +3128,16 @@
},
"required": true,
"description": "Name"
}],
},
{
"in": "query",
"name": "forceRefresh",
"schema": {
"type": "boolean"
},
"description": "Refresh the token even if the current token is still valid"
}
],
"summary": "Get",
"x-sdk-interface": "contexts.prepare"
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codefresh",
"version": "1.0.6",
"version": "1.1.0",
"description": "Codefresh command line utility",
"main": "index.js",
"preferGlobal": true,
Expand Down