Skip to content

Commit b8bafdc

Browse files
add prepare context option (#365)
1 parent e1662d7 commit b8bafdc

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

lib/interface/cli/commands/context/get.cmd.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ const command = new Command({
3131
.option('decrypt', {
3232
describe: 'Either to show decoded credentials or not',
3333
})
34+
.option('prepare', {
35+
describe: 'Activate tokens in case its invalid',
36+
})
3437
.example('codefresh get context NAME', 'Get context NAME')
3538
.example('codefresh get contexts', 'Get all contexts')
3639
.example('codefresh get context --decrypt', 'Get all contexts with credentials decrypted')
@@ -45,10 +48,15 @@ const command = new Command({
4548
data.type = argv.type;
4649
}
4750
data.decrypt = argv.decrypt || undefined;
51+
data.prepare = argv.prepare || undefined;
4852

4953
let contexts = [];
5054
if (!_.isEmpty(names)) {
51-
contexts = await Promise.map(names, name => sdk.contexts.get({ name, decrypt: data.decrypt }));
55+
if (data.prepare) {
56+
contexts = await Promise.map(names, name => sdk.contexts.prepare({ name }));
57+
} else {
58+
contexts = await Promise.map(names, name => sdk.contexts.get({ name, decrypt: data.decrypt }));
59+
}
5260
} else {
5361
contexts = await sdk.contexts.list(data);
5462
}

openapi.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2588,6 +2588,31 @@
25882588
"x-sdk-interface": "contexts.get"
25892589
}
25902590
},
2591+
"/contexts/{name}/prepare": {
2592+
"get": {
2593+
"responses": {
2594+
"200": {
2595+
"$ref": "#/components/responses/Json"
2596+
}
2597+
},
2598+
"tags": [
2599+
"contexts"
2600+
],
2601+
"operationId": "contexts-prepare",
2602+
"parameters": [
2603+
{
2604+
"in": "path",
2605+
"name": "name",
2606+
"schema": {
2607+
"type": "string"
2608+
},
2609+
"required": true,
2610+
"description": "Name"
2611+
}],
2612+
"summary": "Get",
2613+
"x-sdk-interface": "contexts.prepare"
2614+
}
2615+
},
25912616
"/environments": {
25922617
"get": {
25932618
"responses": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codefresh",
3-
"version": "0.34.0",
3+
"version": "0.35.0",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)