codefresh 0.82.9 → 0.83.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/codefresh-release.yml +4 -5
- package/codefresh.yml +16 -1
- package/docs/content/pipelines/Run Pipeline.md +30 -8
- package/lib/interface/cli/commands/annotation/create.cmd.js +1 -1
- package/lib/interface/cli/commands/pipeline/pipeline.sdk.spec.js +76 -6
- package/lib/interface/cli/commands/pipeline/run.base.js +24 -6
- package/lib/interface/cli/commands/pipeline/run.cmd.js +7 -0
- package/lib/interface/cli/commands/pipeline/var.json +12 -0
- package/lib/interface/cli/commands/pipeline/var.yml +5 -0
- package/lib/interface/cli/commands/project/apply.cmd.js +3 -10
- package/lib/interface/cli/commands/project/create.cmd.js +3 -12
- package/lib/interface/cli/completion/tree.json +1 -1
- package/lib/interface/cli/defaults.js +1 -0
- package/lib/interface/cli/helpers/general.js +79 -9
- package/package.json +1 -1
package/codefresh-release.yml
CHANGED
|
@@ -445,14 +445,13 @@ steps:
|
|
|
445
445
|
update_documentation:
|
|
446
446
|
stage: documentation
|
|
447
447
|
title: "Update documentation http://cli.codefresh.io"
|
|
448
|
-
image:
|
|
448
|
+
image: codefresh/build-cli
|
|
449
449
|
commands:
|
|
450
|
-
- "
|
|
451
|
-
- "npm install"
|
|
450
|
+
- "yarn"
|
|
452
451
|
- "echo cleaning previous public dir and recreating worktree"
|
|
453
|
-
- "rm -rf public && git worktree prune &&
|
|
452
|
+
- "rm -rf public && git worktree prune && git worktree add -B gh-pages public origin/gh-pages"
|
|
454
453
|
- "echo Building public docs"
|
|
455
|
-
- "
|
|
454
|
+
- "yarn run build-public-docs"
|
|
456
455
|
- "echo Push new docs to gh-pages detached branch"
|
|
457
456
|
- 'git config --global user.email "auto-ci@codefresh.io" && git config --global user.name "Automated CI"'
|
|
458
457
|
- 'cd public && git add --all && git commit -m "Publish new documentation for version ${{PACKAGE_VERSION}}" && git push https://${{GITHUB_TOKEN}}@github.com/codefresh-io/cli.git'
|
package/codefresh.yml
CHANGED
|
@@ -328,7 +328,7 @@ steps:
|
|
|
328
328
|
type: codefresh-run
|
|
329
329
|
arguments:
|
|
330
330
|
PIPELINE_ID: 'codefresh-io/cli/release'
|
|
331
|
-
|
|
331
|
+
TRIGGER_ID: codefresh-io/cli_1
|
|
332
332
|
BRANCH: master
|
|
333
333
|
VARIABLE:
|
|
334
334
|
- PACKAGE_VERSION=${{PACKAGE_VERSION}}
|
|
@@ -342,3 +342,18 @@ steps:
|
|
|
342
342
|
- name: create_manifest_list
|
|
343
343
|
on:
|
|
344
344
|
- success
|
|
345
|
+
|
|
346
|
+
build_documentation:
|
|
347
|
+
stage: test
|
|
348
|
+
title: "build documentation http://cli.codefresh.io"
|
|
349
|
+
image: codefresh/build-cli
|
|
350
|
+
commands:
|
|
351
|
+
- "echo Building public docs"
|
|
352
|
+
- "npm run build-public-docs"
|
|
353
|
+
environment:
|
|
354
|
+
- HUGO_VERSION=0.32.0
|
|
355
|
+
when:
|
|
356
|
+
steps:
|
|
357
|
+
- name: install_dependencies
|
|
358
|
+
on:
|
|
359
|
+
- success
|
|
@@ -15,22 +15,44 @@ The pipeline will be triggered multiple times according to the array length.
|
|
|
15
15
|
|
|
16
16
|
#### Variable yaml file with 2 sets of variables
|
|
17
17
|
```yaml
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
-
|
|
21
|
-
|
|
18
|
+
- VARIABLE_A: value_a_for_the_first_build
|
|
19
|
+
VARIABLE_B: value_b_for_the_first_build
|
|
20
|
+
- VARIABLE_A: value_a_for_the_first_build
|
|
21
|
+
VARIABLE_B: value_b_for_the_first_build
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
#### Variable json file with 2 sets of variables
|
|
25
25
|
```json
|
|
26
26
|
[
|
|
27
27
|
{
|
|
28
|
-
"
|
|
29
|
-
"
|
|
28
|
+
"VARIABLE_A": "value_a_for_the_first_build",
|
|
29
|
+
"VARIABLE_B": "value_b_for_the_first_build"
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
|
-
"
|
|
33
|
-
"
|
|
32
|
+
"VARIABLE_A": "value_a_for_the_first_build",
|
|
33
|
+
"VARIABLE_B": "value_b_for_the_first_build"
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
```
|
|
37
|
+
### Use encrypted variables in Codefresh build runs; supported from CLI version: 0.83.1
|
|
38
|
+
#### Variable yaml file with single variable set with encrypted variables
|
|
39
|
+
```yaml
|
|
40
|
+
- key:
|
|
41
|
+
val: value
|
|
42
|
+
encrypted: true
|
|
43
|
+
key2: val2
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
#### Variable json file single variable set with encrypted variables
|
|
48
|
+
```json
|
|
49
|
+
[
|
|
50
|
+
{
|
|
51
|
+
"key": {
|
|
52
|
+
"val": "value",
|
|
53
|
+
"encrypted": true
|
|
54
|
+
},
|
|
55
|
+
"key2": "key1"
|
|
34
56
|
}
|
|
35
57
|
]
|
|
36
58
|
```
|
|
@@ -31,7 +31,7 @@ const command = new Command({
|
|
|
31
31
|
.example('codefresh create annotation image 2dfacdaad466 coverage=75%', 'Annotate entity with a single label')
|
|
32
32
|
.example('codefresh create annotation image 2dfacdaad466 coverage=75% tests_passed=true', 'Annotate entity with multiple labels')
|
|
33
33
|
// eslint-disable-next-line max-len
|
|
34
|
-
.example('codefresh create annotation
|
|
34
|
+
.example('codefresh create annotation workflow 643d807b85bbe35931ae2282 ENV=prod tests_passed=true --display ENV', 'Annotate entity with multiple labels and display selection'),
|
|
35
35
|
handler: async (argv) => {
|
|
36
36
|
const { entityType, entityId, labels, display } = argv;
|
|
37
37
|
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
const yaml = require('js-yaml');
|
|
2
|
+
const request = require('requestretry');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const _ = require('lodash');
|
|
1
5
|
const DEFAULTS = require('../../defaults');
|
|
2
6
|
const getCmd = require('./get.cmd').toCommand();
|
|
3
7
|
const deleteCmd = require('./delete.cmd').toCommand();
|
|
@@ -10,18 +14,21 @@ jest.mock('../../helpers/validation'); // eslint-disable-line
|
|
|
10
14
|
jest.mock('../../../../../check-version');
|
|
11
15
|
jest.mock('../../completion/helpers', () => { // eslint-disable-line
|
|
12
16
|
return {
|
|
13
|
-
authContextWrapper: func => func,
|
|
17
|
+
authContextWrapper: (func) => func,
|
|
14
18
|
};
|
|
15
19
|
});
|
|
16
20
|
|
|
21
|
+
jest.mock('../../helpers/general', () => ({
|
|
22
|
+
...jest.requireActual('../../helpers/general'),
|
|
23
|
+
isCompatibleApiVersion: () => true,
|
|
24
|
+
}));
|
|
25
|
+
|
|
17
26
|
jest.mock('../../../../logic/entities/Pipeline', () => { // eslint-disable-line
|
|
18
27
|
return {
|
|
19
|
-
fromResponse: res => res,
|
|
28
|
+
fromResponse: (res) => res,
|
|
20
29
|
};
|
|
21
30
|
});
|
|
22
31
|
|
|
23
|
-
const request = require('requestretry');
|
|
24
|
-
|
|
25
32
|
const DEFAULT_RESPONSE = request.__defaultResponse();
|
|
26
33
|
|
|
27
34
|
describe('pipeline', () => {
|
|
@@ -57,11 +64,11 @@ describe('pipeline', () => {
|
|
|
57
64
|
});
|
|
58
65
|
|
|
59
66
|
it('should return default limit', async () => {
|
|
60
|
-
expect(_getLimit(undefined,false)).toEqual(DEFAULTS.GET_LIMIT_RESULTS);
|
|
67
|
+
expect(_getLimit(undefined, false)).toEqual(DEFAULTS.GET_LIMIT_RESULTS);
|
|
61
68
|
});
|
|
62
69
|
|
|
63
70
|
it('should return `unlimited` value', async () => {
|
|
64
|
-
expect(_getLimit(undefined,true)).toEqual(DEFAULTS.GET_ALL_PIPELINES_LIMIT);
|
|
71
|
+
expect(_getLimit(undefined, true)).toEqual(DEFAULTS.GET_ALL_PIPELINES_LIMIT);
|
|
65
72
|
});
|
|
66
73
|
});
|
|
67
74
|
|
|
@@ -84,6 +91,69 @@ describe('pipeline', () => {
|
|
|
84
91
|
});
|
|
85
92
|
});
|
|
86
93
|
|
|
94
|
+
describe('run', () => {
|
|
95
|
+
it('should handle running pipeline with encrypted variables', async () => {
|
|
96
|
+
const argv = { name: 'some name',
|
|
97
|
+
detach: true,
|
|
98
|
+
annotation: [],
|
|
99
|
+
variable: [
|
|
100
|
+
'secret=secret',
|
|
101
|
+
'VAR1=VAL1',
|
|
102
|
+
],
|
|
103
|
+
encrypted: ['secret'],
|
|
104
|
+
};
|
|
105
|
+
const pip = new CfPipeline(argv);
|
|
106
|
+
await pip.run();
|
|
107
|
+
expect(pip.executionRequests[0].options.variables).toEqual([
|
|
108
|
+
{
|
|
109
|
+
key: 'secret',
|
|
110
|
+
value: 'secret',
|
|
111
|
+
encrypted: true,
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
key: 'VAR1',
|
|
115
|
+
value: 'VAL1',
|
|
116
|
+
},
|
|
117
|
+
]);
|
|
118
|
+
await verifyResponsesReturned([DEFAULT_RESPONSE]); // eslint-disable-line
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('should handle running pipeline with encrypted variables passing inside json file', async () => {
|
|
122
|
+
const rawFile = fs.readFileSync('lib/interface/cli/commands/pipeline/var.json', 'utf8');
|
|
123
|
+
|
|
124
|
+
const argv = { name: 'some name',
|
|
125
|
+
detach: true,
|
|
126
|
+
annotation: [],
|
|
127
|
+
'var-file': JSON.parse(rawFile),
|
|
128
|
+
};
|
|
129
|
+
const pip = new CfPipeline(argv);
|
|
130
|
+
await pip.run();
|
|
131
|
+
expect(pip.executionRequests[0].options.variables).toEqual(
|
|
132
|
+
[{ key: 'help6', value: '85858' },
|
|
133
|
+
{ key: 'should_be_encrepted', value: '0000' },
|
|
134
|
+
{ encrypted: true, key: 'help7', value: 'test' }],
|
|
135
|
+
);
|
|
136
|
+
await verifyResponsesReturned([DEFAULT_RESPONSE]); // eslint-disable-line
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('should handle running pipeline with encrypted variables passing inside yaml file', async () => {
|
|
140
|
+
const rawFile = fs.readFileSync('lib/interface/cli/commands/pipeline/var.yml', 'utf8');
|
|
141
|
+
|
|
142
|
+
const argv = { name: 'some name',
|
|
143
|
+
detach: true,
|
|
144
|
+
annotation: [],
|
|
145
|
+
'var-file': yaml.safeLoad(rawFile),
|
|
146
|
+
};
|
|
147
|
+
const pip = new CfPipeline(argv);
|
|
148
|
+
await pip.run();
|
|
149
|
+
expect(pip.executionRequests[0].options.variables).toEqual(
|
|
150
|
+
[{ key: 'VAR1', value: 'VAL1' },
|
|
151
|
+
{ encrypted: true, key: 'VAR2', value: 'VAL2' }],
|
|
152
|
+
);
|
|
153
|
+
await verifyResponsesReturned([DEFAULT_RESPONSE]); // eslint-disable-line
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
87
157
|
describe('runImpl', () => {
|
|
88
158
|
it('should handle running pipeline', async () => {
|
|
89
159
|
const argv = { name: 'some name', detach: true };
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
const _ = require('lodash');
|
|
2
2
|
const Promise = require('bluebird');
|
|
3
|
-
const
|
|
3
|
+
const CFError = require('cf-errors');
|
|
4
|
+
const { prepareKeyValueFromCLIEnvOption,
|
|
5
|
+
markEncryptedFlagOnRequestedVariables,
|
|
6
|
+
prepareKeyValueObjectsFromEnvFileOption,
|
|
7
|
+
prepareKeyValueObjectsFromCLIEnvOption,
|
|
8
|
+
isCompatibleApiVersion,
|
|
9
|
+
} = require('../../helpers/general');
|
|
4
10
|
const { validatePipelineYaml } = require('../../helpers/validation');
|
|
5
11
|
const { printResult } = require('../root/validate.cmd');
|
|
6
|
-
const CFError = require('cf-errors');
|
|
7
12
|
const { sdk } = require('../../../../logic');
|
|
13
|
+
const defaults = require('../../defaults');
|
|
8
14
|
|
|
9
15
|
class RunBaseCommand {
|
|
10
16
|
constructor(argv) {
|
|
@@ -55,22 +61,34 @@ class RunBaseCommand {
|
|
|
55
61
|
packName,
|
|
56
62
|
},
|
|
57
63
|
};
|
|
58
|
-
|
|
64
|
+
const encryptedVarsSupported = await isCompatibleApiVersion({
|
|
65
|
+
supportedVersion: defaults.MIN_API_VERSION_FOR_ENCRYPTED_VARS_SUPPORT_IN_RUN_CMD,
|
|
66
|
+
});
|
|
59
67
|
if (variablesFromFile) {
|
|
60
68
|
_.forEach(variablesFromFile, (variables) => {
|
|
61
69
|
const request = _.cloneDeep(executionRequestTemplate);
|
|
62
|
-
|
|
70
|
+
if (encryptedVarsSupported) {
|
|
71
|
+
request.options.variables = prepareKeyValueObjectsFromEnvFileOption(variables);
|
|
72
|
+
} else {
|
|
73
|
+
request.options.variables = variables;
|
|
74
|
+
}
|
|
63
75
|
this.executionRequests.push(request);
|
|
64
76
|
});
|
|
65
77
|
} else {
|
|
66
|
-
|
|
78
|
+
let variables;
|
|
79
|
+
if (encryptedVarsSupported) {
|
|
80
|
+
const varsArr = prepareKeyValueObjectsFromCLIEnvOption(this.argv.variable);
|
|
81
|
+
variables = markEncryptedFlagOnRequestedVariables(varsArr, this.argv.encrypted);
|
|
82
|
+
} else {
|
|
83
|
+
variables = prepareKeyValueFromCLIEnvOption(this.argv.variable);
|
|
84
|
+
}
|
|
67
85
|
const request = _.cloneDeep(executionRequestTemplate);
|
|
68
86
|
request.options.variables = variables;
|
|
69
87
|
request.options.contexts = contexts;
|
|
70
88
|
this.executionRequests.push(request);
|
|
71
89
|
}
|
|
72
90
|
|
|
73
|
-
const results = await Promise.all(this.executionRequests.map(request => this.runImpl(request)));
|
|
91
|
+
const results = await Promise.all(this.executionRequests.map((request) => this.runImpl(request)));
|
|
74
92
|
const findMaxReducer = (accumulator, currentValue) => (currentValue > accumulator ? currentValue : accumulator);
|
|
75
93
|
const exitCode = results.reduce(findMaxReducer);
|
|
76
94
|
await this.postRunRequest();
|
|
@@ -86,6 +86,12 @@ const run = new Command({
|
|
|
86
86
|
default: [],
|
|
87
87
|
alias: 'v',
|
|
88
88
|
})
|
|
89
|
+
.option('encrypted', {
|
|
90
|
+
array: true,
|
|
91
|
+
alias: 'e',
|
|
92
|
+
describe: 'Variable names to encrypt',
|
|
93
|
+
default: [],
|
|
94
|
+
})
|
|
89
95
|
.option('detach', {
|
|
90
96
|
alias: 'd',
|
|
91
97
|
describe: 'Run pipeline and print build ID',
|
|
@@ -126,6 +132,7 @@ const run = new Command({
|
|
|
126
132
|
.example('codefresh run PIPELINE_ID | PIPELINE_NAME -b=master', 'Defining the source control context using a branch')
|
|
127
133
|
.example('codefresh run PIPELINE_ID | PIPELINE_NAME -s=52b992e783d2f84dd0123c70ac8623b4f0f938d1', 'Defining the source control context using a commit')
|
|
128
134
|
.example('codefresh run PIPELINE_ID | PIPELINE_NAME -b=master -v key1=value1 -v key2=value2', 'Setting variables through the command')
|
|
135
|
+
.example('codefresh run PIPELINE_ID | PIPELINE_NAME -b=master -v key1=value1 -v key2=value2 -e key1', 'Setting variables through the command with encrypted option')
|
|
129
136
|
.example('codefresh run PIPELINE_ID | PIPELINE_NAME -b=master --var-file ./var_file.yml', 'Settings variables through a yml file')
|
|
130
137
|
.example('codefresh run PIPELINE_ID | PIPELINE_NAME -b=master --context context', 'Inject contexts to the pipeline execution')
|
|
131
138
|
.example('codefresh run PIPELINE_ID | PIPELINE_NAME --skip step1 step2 step3', 'Skip specific steps');
|
|
@@ -4,7 +4,7 @@ const _ = require('lodash');
|
|
|
4
4
|
const { sdk } = require('../../../../logic');
|
|
5
5
|
|
|
6
6
|
const applyRoot = require('../root/apply.cmd');
|
|
7
|
-
const { prepareKeyValueObjectsFromCLIEnvOption, ignoreHttpError } = require('../../helpers/general');
|
|
7
|
+
const { prepareKeyValueObjectsFromCLIEnvOption, ignoreHttpError, markEncryptedFlagOnRequestedVariables } = require('../../helpers/general');
|
|
8
8
|
|
|
9
9
|
const command = new Command({
|
|
10
10
|
command: 'project [id|name]',
|
|
@@ -61,14 +61,7 @@ const command = new Command({
|
|
|
61
61
|
encrypted,
|
|
62
62
|
} = argv;
|
|
63
63
|
|
|
64
|
-
const
|
|
65
|
-
_.forEach(encrypted, (varName) => {
|
|
66
|
-
const variable = variableMap[varName];
|
|
67
|
-
if (!variable) {
|
|
68
|
-
throw new CFError(`Variable is not provided: "${varName}"`);
|
|
69
|
-
}
|
|
70
|
-
variable.encrypted = true;
|
|
71
|
-
});
|
|
64
|
+
const requestedProjectVariables = markEncryptedFlagOnRequestedVariables(variables, encrypted);
|
|
72
65
|
|
|
73
66
|
let project = await sdk.projects.get({ id }).catch(ignoreHttpError);
|
|
74
67
|
project = project || await sdk.projects.getByName({ name }).catch(ignoreHttpError);
|
|
@@ -81,7 +74,7 @@ const command = new Command({
|
|
|
81
74
|
const updatePayload = _.pickBy({
|
|
82
75
|
projectName,
|
|
83
76
|
tags: tags || existingTags,
|
|
84
|
-
variables:
|
|
77
|
+
variables: requestedProjectVariables || existingVariables,
|
|
85
78
|
}, _.identity);
|
|
86
79
|
|
|
87
80
|
await sdk.projects.patch({ id: project.id }, updatePayload);
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
const Command = require('../../Command');
|
|
2
|
-
const CFError = require('cf-errors');
|
|
3
|
-
const _ = require('lodash');
|
|
4
2
|
const { sdk } = require('../../../../logic');
|
|
5
3
|
const createRoot = require('../root/create.cmd');
|
|
6
4
|
const { checkOrProjectExists } = require('../../helpers/validation');
|
|
7
|
-
const { prepareKeyValueObjectsFromCLIEnvOption } = require('../../helpers/general');
|
|
5
|
+
const { prepareKeyValueObjectsFromCLIEnvOption, markEncryptedFlagOnRequestedVariables } = require('../../helpers/general');
|
|
8
6
|
|
|
9
7
|
const command = new Command({
|
|
10
8
|
command: 'project <name>',
|
|
@@ -52,17 +50,10 @@ const command = new Command({
|
|
|
52
50
|
encrypted,
|
|
53
51
|
} = argv;
|
|
54
52
|
|
|
55
|
-
const
|
|
56
|
-
_.forEach(encrypted, (varName) => {
|
|
57
|
-
const variable = variableMap[varName];
|
|
58
|
-
if (!variable) {
|
|
59
|
-
throw new CFError(`Variable is not provided: "${varName}"`);
|
|
60
|
-
}
|
|
61
|
-
variable.encrypted = true;
|
|
62
|
-
});
|
|
53
|
+
const requestedProjectVariables = markEncryptedFlagOnRequestedVariables(variables, encrypted);
|
|
63
54
|
|
|
64
55
|
await checkOrProjectExists(projectName);
|
|
65
|
-
await sdk.projects.create({ projectName, tags, variables });
|
|
56
|
+
await sdk.projects.create({ projectName, tags, variables: requestedProjectVariables });
|
|
66
57
|
console.log(`Project: "${projectName}" created`);
|
|
67
58
|
},
|
|
68
59
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"codefresh":{"analyze":{},"completion":{},"completions":{"alias":"completion"},"tag":{},"untag":{},"offline-logs":{"ensure-index":{},"offload-to-collection":{},"offload-to-file":{}},"run":{"__optionHandlers":["../commands/pipeline/run.completion.js"]},"add":{"repository":{},"repo":{"alias":"repository"}},"patch":{"__optionHandlers":["../commands/root/apply.completion.js"],"agent":{"__optionHandlers":["../commands/root/apply.completion.js"]},"board":{"__optionHandlers":["../commands/root/apply.completion.js"]},"project":{"__optionHandlers":["../commands/root/apply.completion.js"]},"runtime-environments":{"__optionHandlers":["../commands/root/apply.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"section":{"__optionHandlers":["../commands/root/apply.completion.js"]},"system-runtime-environments":{"__optionHandlers":["../commands/root/apply.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"},"teams":{"__optionHandlers":["../commands/root/apply.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"tokens":{"__optionHandlers":["../commands/root/apply.completion.js"]},"token":{"alias":"tokens"},"helm-repo":{"__optionHandlers":["../commands/root/apply.completion.js"]},"context":{"__optionHandlers":["../commands/root/apply.completion.js"]},"ctx":{"alias":"context"}},"annotate":{"image":{},"img":{"alias":"image"}},"auth":{"create-context":{},"current-context":{},"get-contexts":{},"use-context":{}},"components":{"download":{},"update":{}},"create":{"__optionHandlers":["../commands/root/create.completion.js"],"agent":{"__optionHandlers":["../commands/root/create.completion.js"]},"clusters":{"__optionHandlers":["../commands/root/create.completion.js"]},"cluster":{"alias":"clusters"},"annotation":{"__optionHandlers":["../commands/root/create.completion.js"]},"board":{"__optionHandlers":["../commands/root/create.completion.js"]},"composition":{"__optionHandlers":["../commands/composition/create.completion.js","../commands/root/create.completion.js"]},"com":{"alias":"composition"},"project":{"__optionHandlers":["../commands/root/create.completion.js"]},"runtime-environments":{"__optionHandlers":["../commands/root/create.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"section":{"__optionHandlers":["../commands/root/create.completion.js"]},"teams":{"__optionHandlers":["../commands/root/create.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"token":{"__optionHandlers":["../commands/root/create.completion.js"]},"helm-repo":{"__optionHandlers":["../commands/root/create.completion.js"]},"registry":{"__optionHandlers":["../commands/root/create.completion.js"],"standard":{"__optionHandlers":["../commands/root/create.completion.js"]}},"trigger":{"__optionHandlers":["../commands/root/create.completion.js"]},"t":{"alias":"trigger"},"trigger-event":{"__optionHandlers":["../commands/root/create.completion.js"]},"te":{"alias":"trigger-event"},"workflow-data-item":{"__optionHandlers":["../commands/root/create.completion.js"]},"wdi":{"alias":"workflow-data-item"},"context":{"__optionHandlers":["../commands/root/create.completion.js"],"config":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret-yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"git":{"__optionHandlers":["../commands/root/create.completion.js"],"bitbucket":{"__optionHandlers":["../commands/root/create.completion.js"]},"github":{"__optionHandlers":["../commands/root/create.completion.js"]},"gitlab":{"__optionHandlers":["../commands/root/create.completion.js"]},"stash":{"__optionHandlers":["../commands/root/create.completion.js"]}},"secret-store":{"__optionHandlers":["../commands/root/create.completion.js"],"hashicorp-vault":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes-runtime":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes":{"__optionHandlers":["../commands/root/create.completion.js"]}},"helm-repository":{"__optionHandlers":["../commands/root/create.completion.js"],"http":{"__optionHandlers":["../commands/root/create.completion.js"]},"s3":{"__optionHandlers":["../commands/root/create.completion.js"]}}},"ctx":{"alias":"context","config":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret-yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"git":{"__optionHandlers":["../commands/root/create.completion.js"],"bitbucket":{"__optionHandlers":["../commands/root/create.completion.js"]},"github":{"__optionHandlers":["../commands/root/create.completion.js"]},"gitlab":{"__optionHandlers":["../commands/root/create.completion.js"]},"stash":{"__optionHandlers":["../commands/root/create.completion.js"]}},"secret-store":{"__optionHandlers":["../commands/root/create.completion.js"],"hashicorp-vault":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes-runtime":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes":{"__optionHandlers":["../commands/root/create.completion.js"]}},"helm-repository":{"__optionHandlers":["../commands/root/create.completion.js"],"http":{"__optionHandlers":["../commands/root/create.completion.js"]},"s3":{"__optionHandlers":["../commands/root/create.completion.js"]}}}},"delete":{"__optionHandlers":["../commands/root/delete.completion.js"],"agent":{"__optionHandlers":["../commands/root/delete.completion.js"]},"annotation":{"__optionHandlers":["../commands/root/delete.completion.js"]},"board":{"__optionHandlers":["../commands/root/delete.completion.js"]},"cluster":{"__optionHandlers":["../commands/root/delete.completion.js"]},"clusters":{"alias":"cluster"},"composition":{"__optionHandlers":["../commands/root/delete.completion.js"]},"com":{"alias":"composition"},"environment":{"__optionHandlers":["../commands/root/delete.completion.js"]},"env":{"alias":"environment"},"pipeline":{"__optionHandlers":["../commands/root/delete.completion.js"]},"pip":{"alias":"pipeline"},"project":{"__optionHandlers":["../commands/root/delete.completion.js"]},"repository":{"__optionHandlers":["../commands/root/delete.completion.js"]},"repo":{"alias":"repository"},"runtime-environments":{"__optionHandlers":["../commands/root/delete.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"section":{"__optionHandlers":["../commands/root/delete.completion.js"]},"step-type":{"__optionHandlers":["../commands/root/delete.completion.js"]},"system-runtime-environments":{"__optionHandlers":["../commands/root/delete.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"},"teams":{"__optionHandlers":["../commands/root/delete.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"tokens":{"__optionHandlers":["../commands/root/delete.completion.js"]},"token":{"alias":"tokens"},"helm-repo":{"__optionHandlers":["../commands/root/delete.completion.js"]},"registry":{"__optionHandlers":["../commands/root/delete.completion.js"]},"trigger":{"__optionHandlers":["../commands/root/delete.completion.js"]},"t":{"alias":"trigger"},"trigger-event":{"__optionHandlers":["../commands/root/delete.completion.js"]},"te":{"alias":"trigger-event"},"context":{"__optionHandlers":["../commands/root/delete.completion.js"]},"ctx":{"alias":"context"}},"diff":{"__optionHandlers":["../commands/root/diff.completion.js"],"runtime-environments":{"__optionHandlers":["../commands/root/diff.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"system-runtime-environments":{"__optionHandlers":["../commands/root/diff.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"}},"download":{"audit":{}},"generate":{"image-pull-secret":{}},"get":{"__optionHandlers":["../commands/root/get.completion.js"],"agents":{"__optionHandlers":["../commands/root/get.completion.js"]},"agent":{"alias":"agents"},"annotation":{"__optionHandlers":["../commands/root/get.completion.js"]},"boards":{"__optionHandlers":["../commands/root/get.completion.js"]},"board":{"alias":"boards"},"clusters":{"__optionHandlers":["../commands/root/get.completion.js"]},"cluster":{"alias":"clusters"},"compositions":{"__optionHandlers":["../commands/root/get.completion.js"]},"com":{"alias":"compositions"},"composition":{"alias":"compositions"},"environments":{"__optionHandlers":["../commands/root/get.completion.js"]},"env":{"alias":"environments"},"environment":{"alias":"environments"},"images":{"__optionHandlers":["../commands/root/get.completion.js"]},"img":{"alias":"images"},"image":{"alias":"images"},"pipelines":{"__positionalHandler":"../commands/pipeline/get.completion.js","__optionHandlers":["../commands/root/get.completion.js"]},"pip":{"alias":"pipelines"},"pipeline":{"alias":"pipelines"},"projects":{"__optionHandlers":["../commands/root/get.completion.js"]},"project":{"alias":"projects"},"repository":{"__optionHandlers":["../commands/root/get.completion.js"]},"repo":{"alias":"repository"},"runtime-environments":{"__optionHandlers":["../commands/root/get.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"sections":{"__optionHandlers":["../commands/root/get.completion.js"]},"section":{"alias":"sections"},"step-types":{"__positionalHandler":"../commands/step/get.completion.js","__optionHandlers":["../commands/root/get.completion.js"]},"step-type":{"alias":"step-types"},"system-runtime-environments":{"__optionHandlers":["../commands/root/get.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"},"teams":{"__optionHandlers":["../commands/root/get.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"tokens":{"__optionHandlers":["../commands/root/get.completion.js"]},"token":{"alias":"tokens"},"helm-repo":{"__optionHandlers":["../commands/root/get.completion.js"]},"registry":{"__optionHandlers":["../commands/root/get.completion.js"]},"triggers":{"__optionHandlers":["../commands/root/get.completion.js"]},"trigger":{"alias":"triggers"},"t":{"alias":"triggers"},"trigger-events":{"__optionHandlers":["../commands/root/get.completion.js"]},"trigger-event":{"alias":"trigger-events"},"te":{"alias":"trigger-events"},"trigger-types":{"__optionHandlers":["../commands/root/get.completion.js"]},"trigger-type":{"alias":"trigger-types"},"tt":{"alias":"trigger-types"},"builds":{"__optionHandlers":["../commands/root/get.completion.js"]},"build":{"alias":"builds"},"workflow-data-item":{"__optionHandlers":["../commands/root/get.completion.js"]},"wdi":{"alias":"workflow-data-item"},"contexts":{"__optionHandlers":["../commands/root/get.completion.js"]},"ctx":{"alias":"contexts"},"context":{"alias":"contexts"}},"install":{"runtime":{},"agent":{},"app-proxy":{},"monitor":{},"gitops":{}},"replace":{"__optionHandlers":["../commands/root/replace.completion.js"],"composition":{"__optionHandlers":["../commands/composition/replace.completion.js","../commands/root/replace.completion.js"]},"com":{"alias":"composition"}},"runner":{"delete":{},"execute-test-pipeline":{},"info":{},"init":{},"upgrade":{}},"synchronize":{"teams":{},"team":{"alias":"teams"},"tm":{"alias":"teams"}},"uninstall":{"agent":{},"app-proxy":{},"runtime":{},"monitor":{},"gitops":{}},"upgrade":{"app-proxy":{},"gitops":{}},"validate":{"__positionalHandler":"../commands/root/validate.completion.js"},"version":{},"attach":{},"cli-config":{"get":{},"help":{},"profile":{},"set":{}},"set-helm-config":{},"install-chart":{},"helm-promotion":{},"delete-release":{},"rollback-release":{},"test-release":{},"approve":{},"deny":{},"restart":{},"logs":{},"terminate":{},"wait":{}}}
|
|
1
|
+
{"codefresh":{"analyze":{},"completion":{},"completions":{"alias":"completion"},"tag":{},"untag":{},"offline-logs":{"ensure-index":{},"offload-to-collection":{},"offload-to-file":{}},"run":{"__optionHandlers":["../commands/pipeline/run.completion.js"]},"attach":{},"add":{"repository":{},"repo":{"alias":"repository"}},"annotate":{"image":{},"img":{"alias":"image"}},"patch":{"__optionHandlers":["../commands/root/apply.completion.js"],"agent":{"__optionHandlers":["../commands/root/apply.completion.js"]},"board":{"__optionHandlers":["../commands/root/apply.completion.js"]},"project":{"__optionHandlers":["../commands/root/apply.completion.js"]},"runtime-environments":{"__optionHandlers":["../commands/root/apply.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"section":{"__optionHandlers":["../commands/root/apply.completion.js"]},"system-runtime-environments":{"__optionHandlers":["../commands/root/apply.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"},"teams":{"__optionHandlers":["../commands/root/apply.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"tokens":{"__optionHandlers":["../commands/root/apply.completion.js"]},"token":{"alias":"tokens"},"helm-repo":{"__optionHandlers":["../commands/root/apply.completion.js"]},"context":{"__optionHandlers":["../commands/root/apply.completion.js"]},"ctx":{"alias":"context"}},"auth":{"create-context":{},"current-context":{},"get-contexts":{},"use-context":{}},"components":{"download":{},"update":{}},"create":{"__optionHandlers":["../commands/root/create.completion.js"],"agent":{"__optionHandlers":["../commands/root/create.completion.js"]},"clusters":{"__optionHandlers":["../commands/root/create.completion.js"]},"cluster":{"alias":"clusters"},"annotation":{"__optionHandlers":["../commands/root/create.completion.js"]},"board":{"__optionHandlers":["../commands/root/create.completion.js"]},"composition":{"__optionHandlers":["../commands/composition/create.completion.js","../commands/root/create.completion.js"]},"com":{"alias":"composition"},"project":{"__optionHandlers":["../commands/root/create.completion.js"]},"runtime-environments":{"__optionHandlers":["../commands/root/create.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"section":{"__optionHandlers":["../commands/root/create.completion.js"]},"teams":{"__optionHandlers":["../commands/root/create.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"token":{"__optionHandlers":["../commands/root/create.completion.js"]},"helm-repo":{"__optionHandlers":["../commands/root/create.completion.js"]},"registry":{"__optionHandlers":["../commands/root/create.completion.js"],"standard":{"__optionHandlers":["../commands/root/create.completion.js"]}},"trigger":{"__optionHandlers":["../commands/root/create.completion.js"]},"t":{"alias":"trigger"},"trigger-event":{"__optionHandlers":["../commands/root/create.completion.js"]},"te":{"alias":"trigger-event"},"workflow-data-item":{"__optionHandlers":["../commands/root/create.completion.js"]},"wdi":{"alias":"workflow-data-item"},"context":{"__optionHandlers":["../commands/root/create.completion.js"],"config":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret-yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"git":{"__optionHandlers":["../commands/root/create.completion.js"],"bitbucket":{"__optionHandlers":["../commands/root/create.completion.js"]},"github":{"__optionHandlers":["../commands/root/create.completion.js"]},"gitlab":{"__optionHandlers":["../commands/root/create.completion.js"]},"stash":{"__optionHandlers":["../commands/root/create.completion.js"]}},"helm-repository":{"__optionHandlers":["../commands/root/create.completion.js"],"http":{"__optionHandlers":["../commands/root/create.completion.js"]},"s3":{"__optionHandlers":["../commands/root/create.completion.js"]}},"secret-store":{"__optionHandlers":["../commands/root/create.completion.js"],"hashicorp-vault":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes-runtime":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes":{"__optionHandlers":["../commands/root/create.completion.js"]}}},"ctx":{"alias":"context","config":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret-yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"git":{"__optionHandlers":["../commands/root/create.completion.js"],"bitbucket":{"__optionHandlers":["../commands/root/create.completion.js"]},"github":{"__optionHandlers":["../commands/root/create.completion.js"]},"gitlab":{"__optionHandlers":["../commands/root/create.completion.js"]},"stash":{"__optionHandlers":["../commands/root/create.completion.js"]}},"helm-repository":{"__optionHandlers":["../commands/root/create.completion.js"],"http":{"__optionHandlers":["../commands/root/create.completion.js"]},"s3":{"__optionHandlers":["../commands/root/create.completion.js"]}},"secret-store":{"__optionHandlers":["../commands/root/create.completion.js"],"hashicorp-vault":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes-runtime":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes":{"__optionHandlers":["../commands/root/create.completion.js"]}}}},"delete":{"__optionHandlers":["../commands/root/delete.completion.js"],"agent":{"__optionHandlers":["../commands/root/delete.completion.js"]},"annotation":{"__optionHandlers":["../commands/root/delete.completion.js"]},"board":{"__optionHandlers":["../commands/root/delete.completion.js"]},"cluster":{"__optionHandlers":["../commands/root/delete.completion.js"]},"clusters":{"alias":"cluster"},"composition":{"__optionHandlers":["../commands/root/delete.completion.js"]},"com":{"alias":"composition"},"environment":{"__optionHandlers":["../commands/root/delete.completion.js"]},"env":{"alias":"environment"},"pipeline":{"__optionHandlers":["../commands/root/delete.completion.js"]},"pip":{"alias":"pipeline"},"project":{"__optionHandlers":["../commands/root/delete.completion.js"]},"repository":{"__optionHandlers":["../commands/root/delete.completion.js"]},"repo":{"alias":"repository"},"runtime-environments":{"__optionHandlers":["../commands/root/delete.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"section":{"__optionHandlers":["../commands/root/delete.completion.js"]},"step-type":{"__optionHandlers":["../commands/root/delete.completion.js"]},"system-runtime-environments":{"__optionHandlers":["../commands/root/delete.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"},"teams":{"__optionHandlers":["../commands/root/delete.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"tokens":{"__optionHandlers":["../commands/root/delete.completion.js"]},"token":{"alias":"tokens"},"helm-repo":{"__optionHandlers":["../commands/root/delete.completion.js"]},"registry":{"__optionHandlers":["../commands/root/delete.completion.js"]},"trigger":{"__optionHandlers":["../commands/root/delete.completion.js"]},"t":{"alias":"trigger"},"trigger-event":{"__optionHandlers":["../commands/root/delete.completion.js"]},"te":{"alias":"trigger-event"},"context":{"__optionHandlers":["../commands/root/delete.completion.js"]},"ctx":{"alias":"context"}},"diff":{"__optionHandlers":["../commands/root/diff.completion.js"],"runtime-environments":{"__optionHandlers":["../commands/root/diff.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"system-runtime-environments":{"__optionHandlers":["../commands/root/diff.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"}},"download":{"audit":{}},"generate":{"image-pull-secret":{}},"get":{"__optionHandlers":["../commands/root/get.completion.js"],"agents":{"__optionHandlers":["../commands/root/get.completion.js"]},"agent":{"alias":"agents"},"annotation":{"__optionHandlers":["../commands/root/get.completion.js"]},"boards":{"__optionHandlers":["../commands/root/get.completion.js"]},"board":{"alias":"boards"},"clusters":{"__optionHandlers":["../commands/root/get.completion.js"]},"cluster":{"alias":"clusters"},"compositions":{"__optionHandlers":["../commands/root/get.completion.js"]},"com":{"alias":"compositions"},"composition":{"alias":"compositions"},"environments":{"__optionHandlers":["../commands/root/get.completion.js"]},"env":{"alias":"environments"},"environment":{"alias":"environments"},"images":{"__optionHandlers":["../commands/root/get.completion.js"]},"img":{"alias":"images"},"image":{"alias":"images"},"pipelines":{"__positionalHandler":"../commands/pipeline/get.completion.js","__optionHandlers":["../commands/root/get.completion.js"]},"pip":{"alias":"pipelines"},"pipeline":{"alias":"pipelines"},"projects":{"__optionHandlers":["../commands/root/get.completion.js"]},"project":{"alias":"projects"},"repository":{"__optionHandlers":["../commands/root/get.completion.js"]},"repo":{"alias":"repository"},"runtime-environments":{"__optionHandlers":["../commands/root/get.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"sections":{"__optionHandlers":["../commands/root/get.completion.js"]},"section":{"alias":"sections"},"step-types":{"__positionalHandler":"../commands/step/get.completion.js","__optionHandlers":["../commands/root/get.completion.js"]},"step-type":{"alias":"step-types"},"system-runtime-environments":{"__optionHandlers":["../commands/root/get.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"},"teams":{"__optionHandlers":["../commands/root/get.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"tokens":{"__optionHandlers":["../commands/root/get.completion.js"]},"token":{"alias":"tokens"},"helm-repo":{"__optionHandlers":["../commands/root/get.completion.js"]},"registry":{"__optionHandlers":["../commands/root/get.completion.js"]},"triggers":{"__optionHandlers":["../commands/root/get.completion.js"]},"trigger":{"alias":"triggers"},"t":{"alias":"triggers"},"trigger-events":{"__optionHandlers":["../commands/root/get.completion.js"]},"trigger-event":{"alias":"trigger-events"},"te":{"alias":"trigger-events"},"trigger-types":{"__optionHandlers":["../commands/root/get.completion.js"]},"trigger-type":{"alias":"trigger-types"},"tt":{"alias":"trigger-types"},"builds":{"__optionHandlers":["../commands/root/get.completion.js"]},"build":{"alias":"builds"},"workflow-data-item":{"__optionHandlers":["../commands/root/get.completion.js"]},"wdi":{"alias":"workflow-data-item"},"contexts":{"__optionHandlers":["../commands/root/get.completion.js"]},"ctx":{"alias":"contexts"},"context":{"alias":"contexts"}},"install":{"runtime":{},"agent":{},"app-proxy":{},"monitor":{},"gitops":{}},"replace":{"__optionHandlers":["../commands/root/replace.completion.js"],"composition":{"__optionHandlers":["../commands/composition/replace.completion.js","../commands/root/replace.completion.js"]},"com":{"alias":"composition"}},"runner":{"delete":{},"execute-test-pipeline":{},"info":{},"init":{},"upgrade":{}},"synchronize":{"teams":{},"team":{"alias":"teams"},"tm":{"alias":"teams"}},"uninstall":{"agent":{},"app-proxy":{},"runtime":{},"monitor":{},"gitops":{}},"upgrade":{"app-proxy":{},"gitops":{}},"validate":{"__positionalHandler":"../commands/root/validate.completion.js"},"version":{},"cli-config":{"get":{},"help":{},"profile":{},"set":{}},"set-helm-config":{},"install-chart":{},"helm-promotion":{},"delete-release":{},"rollback-release":{},"test-release":{},"approve":{},"deny":{},"logs":{},"restart":{},"terminate":{},"wait":{}}}
|
|
@@ -13,6 +13,7 @@ const DEFAULTS = {
|
|
|
13
13
|
MAX_CONSECUTIVE_ERRORS_LIMIT: 10,
|
|
14
14
|
CODEFRESH_PATH: path.resolve(homedir(), '.Codefresh'),
|
|
15
15
|
ENGINE_IMAGE: process.env.ENGINE_IMAGE || 'codefresh/engine:master',
|
|
16
|
+
MIN_API_VERSION_FOR_ENCRYPTED_VARS_SUPPORT_IN_RUN_CMD: '21.221.14',
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
module.exports = DEFAULTS;
|
|
@@ -1,15 +1,43 @@
|
|
|
1
|
+
const debug = require('debug')('codefresh:cli:helpers:general');
|
|
1
2
|
const Promise = require('bluebird');
|
|
2
3
|
const _ = require('lodash');
|
|
3
4
|
const fs = require('fs');
|
|
4
5
|
const yaml = require('js-yaml');
|
|
5
|
-
const defaults = require('../defaults');
|
|
6
6
|
const CFError = require('cf-errors');
|
|
7
7
|
const path = require('path');
|
|
8
|
+
const semver = require('semver');
|
|
9
|
+
const request = require('requestretry');
|
|
10
|
+
const defaults = require('../defaults');
|
|
8
11
|
const Output = require('../../../output/Output');
|
|
9
12
|
const { sdk } = require('../../../logic');
|
|
10
13
|
|
|
11
14
|
const isDebug = () => (process.env.DEBUG || '').includes(defaults.DEBUG_PATTERN);
|
|
12
15
|
|
|
16
|
+
async function getApiVersion(token, url) {
|
|
17
|
+
const RequestOptions = {
|
|
18
|
+
url: `${url}/api/user`,
|
|
19
|
+
headers: {
|
|
20
|
+
Authorization: token,
|
|
21
|
+
},
|
|
22
|
+
json: true,
|
|
23
|
+
maxAttempts: 3, // Retry up to 3 times
|
|
24
|
+
timeout: 10000,
|
|
25
|
+
};
|
|
26
|
+
try {
|
|
27
|
+
const res = await request(RequestOptions);
|
|
28
|
+
return _.get(res, 'headers.api_version');
|
|
29
|
+
} catch (error) {
|
|
30
|
+
debug('Failed to get API version:', error);
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function isCompatibleApiVersion({ supportedVersion }) {
|
|
36
|
+
const token = _.get(sdk, 'config.context.token');
|
|
37
|
+
const url = _.get(sdk, 'config.context.url', defaults.URL);
|
|
38
|
+
const apiVersion = token ? await getApiVersion(token, url) : null;
|
|
39
|
+
return apiVersion && semver.gte(apiVersion, supportedVersion);
|
|
40
|
+
}
|
|
13
41
|
|
|
14
42
|
const wrapHandler = (handler, requiresAuthentication) => {
|
|
15
43
|
return async (argv) => {
|
|
@@ -106,6 +134,39 @@ const prepareKeyValueObjectsFromCLIEnvOption = (environmentVariables) => {
|
|
|
106
134
|
return variables;
|
|
107
135
|
};
|
|
108
136
|
|
|
137
|
+
/**
|
|
138
|
+
* will return an array of objects { key, value, encrypted } from parsing an array of objects: key=value ,key: {value: "value", encrypted: true }
|
|
139
|
+
* @param environmentVariables
|
|
140
|
+
* @returns Array of { key, value, encrypted }
|
|
141
|
+
*/
|
|
142
|
+
const prepareKeyValueObjectsFromEnvFileOption = (environmentVariables) => _.map(environmentVariables, (value, key) => {
|
|
143
|
+
if (_.isObject(value)) {
|
|
144
|
+
const { value: val, encrypted } = value;
|
|
145
|
+
return { key, value: val, encrypted };
|
|
146
|
+
}
|
|
147
|
+
return { key, value };
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* The function takes in a list of requested variables and an array of encrypted variable names,
|
|
152
|
+
* and sets the encrypted flag to true on each corresponding variable object in the list.
|
|
153
|
+
* @param environmentVariables
|
|
154
|
+
* @param encrypted
|
|
155
|
+
* @returns Array of { key, value, encrypted }
|
|
156
|
+
*/
|
|
157
|
+
const markEncryptedFlagOnRequestedVariables = (requestedVariables, encrypted) => {
|
|
158
|
+
const variables = _.cloneDeep(requestedVariables);
|
|
159
|
+
const variableMap = _.reduce(variables, (acc, v) => _.assign(acc, { [v.key]: v }), {});
|
|
160
|
+
_.forEach(encrypted, (varName) => {
|
|
161
|
+
const variable = variableMap[varName];
|
|
162
|
+
if (!variable) {
|
|
163
|
+
throw new CFError(`Variable is not provided: "${varName}"`);
|
|
164
|
+
}
|
|
165
|
+
variable.encrypted = true;
|
|
166
|
+
});
|
|
167
|
+
return variables;
|
|
168
|
+
};
|
|
169
|
+
|
|
109
170
|
const crudFilenameOption = (yargs, options = {}) => {
|
|
110
171
|
const filenameOption = {
|
|
111
172
|
alias: options.alias || 'f',
|
|
@@ -122,13 +183,19 @@ const crudFilenameOption = (yargs, options = {}) => {
|
|
|
122
183
|
.coerce(options.name || 'filename', (arg) => {
|
|
123
184
|
try {
|
|
124
185
|
const rawFile = fs.readFileSync(path.resolve(process.cwd(), arg), 'utf8');
|
|
186
|
+
let content;
|
|
125
187
|
if (arg.endsWith('.json')) {
|
|
126
|
-
|
|
188
|
+
content = options.raw ? rawFile : JSON.parse(rawFile);
|
|
189
|
+
} else if (arg.endsWith('.yml') || arg.endsWith('yaml')) {
|
|
190
|
+
content = options.raw ? rawFile : yaml.safeLoad(rawFile);
|
|
191
|
+
} else {
|
|
192
|
+
throw new CFError('File extension is not recognized');
|
|
127
193
|
}
|
|
128
|
-
if (
|
|
129
|
-
return
|
|
194
|
+
if (_.isObject(content)) {
|
|
195
|
+
return content;
|
|
130
196
|
}
|
|
131
|
-
throw new CFError('
|
|
197
|
+
throw new CFError('Not a valid file.\n'
|
|
198
|
+
+ 'For more information how to pass a valid file, go to https://codefresh-io.github.io/cli/pipelines/run-pipeline/');
|
|
132
199
|
} catch (err) {
|
|
133
200
|
const error = new CFError({
|
|
134
201
|
message: 'Failed to read file',
|
|
@@ -161,15 +228,15 @@ const selectColumnsOption = (yargs, options = {}) => {
|
|
|
161
228
|
};
|
|
162
229
|
|
|
163
230
|
function pathExists(p) {
|
|
164
|
-
return new Promise(resolve => fs.access(p, resolve))
|
|
165
|
-
.then(err => !err);
|
|
231
|
+
return new Promise((resolve) => fs.access(p, resolve))
|
|
232
|
+
.then((err) => !err);
|
|
166
233
|
}
|
|
167
234
|
|
|
168
235
|
const readFile = Promise.promisify(fs.readFile);
|
|
169
236
|
|
|
170
237
|
function watchFile(filename, listener) {
|
|
171
238
|
fs.watchFile(filename, { interval: 500 }, listener);
|
|
172
|
-
const unwatcher = f => () => fs.unwatchFile(f);
|
|
239
|
+
const unwatcher = (f) => () => fs.unwatchFile(f);
|
|
173
240
|
['exit', 'SIGINT', 'SIGUSR1', 'SIGUSR2', 'uncaughtException', 'SIGTERM'].forEach((eventType) => {
|
|
174
241
|
process.on(eventType, unwatcher(filename));
|
|
175
242
|
});
|
|
@@ -177,7 +244,7 @@ function watchFile(filename, listener) {
|
|
|
177
244
|
|
|
178
245
|
function ignoreHttpError(e) {
|
|
179
246
|
if (!e.statusCode) {
|
|
180
|
-
throw e
|
|
247
|
+
throw e;
|
|
181
248
|
}
|
|
182
249
|
return undefined;
|
|
183
250
|
}
|
|
@@ -232,4 +299,7 @@ module.exports = {
|
|
|
232
299
|
detectProxy,
|
|
233
300
|
keyValueArrayToObject,
|
|
234
301
|
addProxyVariables,
|
|
302
|
+
markEncryptedFlagOnRequestedVariables,
|
|
303
|
+
prepareKeyValueObjectsFromEnvFileOption,
|
|
304
|
+
isCompatibleApiVersion,
|
|
235
305
|
};
|