codefresh 0.83.1 → 0.83.3
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 +5 -4
- package/codefresh.yml +1 -16
- package/docs/content/pipelines/Run Pipeline.md +8 -30
- package/lib/interface/cli/commands/annotation/create.cmd.js +1 -1
- package/lib/interface/cli/commands/pipeline/pipeline.sdk.spec.js +6 -76
- package/lib/interface/cli/commands/pipeline/run.base.js +6 -24
- package/lib/interface/cli/commands/pipeline/run.cmd.js +0 -7
- package/lib/interface/cli/commands/project/apply.cmd.js +10 -3
- package/lib/interface/cli/commands/project/create.cmd.js +12 -3
- package/lib/interface/cli/completion/tree.json +1 -1
- package/lib/interface/cli/defaults.js +0 -1
- package/lib/interface/cli/helpers/general.js +9 -79
- package/package.json +1 -1
- package/lib/interface/cli/commands/pipeline/var.json +0 -12
- package/lib/interface/cli/commands/pipeline/var.yml +0 -5
package/codefresh-release.yml
CHANGED
|
@@ -445,13 +445,14 @@ steps:
|
|
|
445
445
|
update_documentation:
|
|
446
446
|
stage: documentation
|
|
447
447
|
title: "Update documentation http://cli.codefresh.io"
|
|
448
|
-
image:
|
|
448
|
+
image: docker:18.01
|
|
449
449
|
commands:
|
|
450
|
-
- "
|
|
450
|
+
- "apk update && apk add git nodejs"
|
|
451
|
+
- "npm install"
|
|
451
452
|
- "echo cleaning previous public dir and recreating worktree"
|
|
452
|
-
- "rm -rf public && git worktree prune &&
|
|
453
|
+
- "rm -rf public && git worktree prune && git worktree add -B gh-pages public origin/gh-pages"
|
|
453
454
|
- "echo Building public docs"
|
|
454
|
-
- "
|
|
455
|
+
- "npm run build-public-docs"
|
|
455
456
|
- "echo Push new docs to gh-pages detached branch"
|
|
456
457
|
- 'git config --global user.email "auto-ci@codefresh.io" && git config --global user.name "Automated CI"'
|
|
457
458
|
- '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
|
+
DETACH: true
|
|
332
332
|
BRANCH: master
|
|
333
333
|
VARIABLE:
|
|
334
334
|
- PACKAGE_VERSION=${{PACKAGE_VERSION}}
|
|
@@ -342,18 +342,3 @@ 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,44 +15,22 @@ 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
|
+
- key: value
|
|
19
|
+
key2: key1
|
|
20
|
+
- key: value
|
|
21
|
+
key2: key2
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
#### Variable json file with 2 sets of variables
|
|
25
25
|
```json
|
|
26
26
|
[
|
|
27
27
|
{
|
|
28
|
-
"
|
|
29
|
-
"
|
|
28
|
+
"key": "value",
|
|
29
|
+
"key2": "key1"
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
}
|
|
35
|
-
]
|
|
36
|
-
```
|
|
37
|
-
### Use encrypted variables in Codefresh build runs; supported from CLI version: 0.82.8
|
|
38
|
-
#### Variable yaml file with single variable set with encrypted variables
|
|
39
|
-
```yaml
|
|
40
|
-
- key:
|
|
41
|
-
val: value
|
|
42
|
-
encrypted: true
|
|
43
|
-
key2: key1
|
|
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"
|
|
32
|
+
"key": "value",
|
|
33
|
+
"key2": "key2"
|
|
56
34
|
}
|
|
57
35
|
]
|
|
58
36
|
```
|
|
@@ -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 image 2dfacdaad466 coverage=75% tests_passed=true --display coverage', 'Annotate entity with multiple labels and display selection'),
|
|
35
35
|
handler: async (argv) => {
|
|
36
36
|
const { entityType, entityId, labels, display } = argv;
|
|
37
37
|
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
const yaml = require('js-yaml');
|
|
2
|
-
const request = require('requestretry');
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const _ = require('lodash');
|
|
5
1
|
const DEFAULTS = require('../../defaults');
|
|
6
2
|
const getCmd = require('./get.cmd').toCommand();
|
|
7
3
|
const deleteCmd = require('./delete.cmd').toCommand();
|
|
@@ -14,21 +10,18 @@ jest.mock('../../helpers/validation'); // eslint-disable-line
|
|
|
14
10
|
jest.mock('../../../../../check-version');
|
|
15
11
|
jest.mock('../../completion/helpers', () => { // eslint-disable-line
|
|
16
12
|
return {
|
|
17
|
-
authContextWrapper:
|
|
13
|
+
authContextWrapper: func => func,
|
|
18
14
|
};
|
|
19
15
|
});
|
|
20
16
|
|
|
21
|
-
jest.mock('../../helpers/general', () => ({
|
|
22
|
-
...jest.requireActual('../../helpers/general'),
|
|
23
|
-
isCompatibleApiVersion: () => true,
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
17
|
jest.mock('../../../../logic/entities/Pipeline', () => { // eslint-disable-line
|
|
27
18
|
return {
|
|
28
|
-
fromResponse:
|
|
19
|
+
fromResponse: res => res,
|
|
29
20
|
};
|
|
30
21
|
});
|
|
31
22
|
|
|
23
|
+
const request = require('requestretry');
|
|
24
|
+
|
|
32
25
|
const DEFAULT_RESPONSE = request.__defaultResponse();
|
|
33
26
|
|
|
34
27
|
describe('pipeline', () => {
|
|
@@ -64,11 +57,11 @@ describe('pipeline', () => {
|
|
|
64
57
|
});
|
|
65
58
|
|
|
66
59
|
it('should return default limit', async () => {
|
|
67
|
-
expect(_getLimit(undefined,
|
|
60
|
+
expect(_getLimit(undefined,false)).toEqual(DEFAULTS.GET_LIMIT_RESULTS);
|
|
68
61
|
});
|
|
69
62
|
|
|
70
63
|
it('should return `unlimited` value', async () => {
|
|
71
|
-
expect(_getLimit(undefined,
|
|
64
|
+
expect(_getLimit(undefined,true)).toEqual(DEFAULTS.GET_ALL_PIPELINES_LIMIT);
|
|
72
65
|
});
|
|
73
66
|
});
|
|
74
67
|
|
|
@@ -91,69 +84,6 @@ describe('pipeline', () => {
|
|
|
91
84
|
});
|
|
92
85
|
});
|
|
93
86
|
|
|
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
|
-
|
|
157
87
|
describe('runImpl', () => {
|
|
158
88
|
it('should handle running pipeline', async () => {
|
|
159
89
|
const argv = { name: 'some name', detach: true };
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
const _ = require('lodash');
|
|
2
2
|
const Promise = require('bluebird');
|
|
3
|
-
const
|
|
4
|
-
const { prepareKeyValueFromCLIEnvOption,
|
|
5
|
-
markEncryptedFlagOnRequestedVariables,
|
|
6
|
-
prepareKeyValueObjectsFromEnvFileOption,
|
|
7
|
-
prepareKeyValueObjectsFromCLIEnvOption,
|
|
8
|
-
isCompatibleApiVersion,
|
|
9
|
-
} = require('../../helpers/general');
|
|
3
|
+
const { prepareKeyValueFromCLIEnvOption } = require('../../helpers/general');
|
|
10
4
|
const { validatePipelineYaml } = require('../../helpers/validation');
|
|
11
5
|
const { printResult } = require('../root/validate.cmd');
|
|
6
|
+
const CFError = require('cf-errors');
|
|
12
7
|
const { sdk } = require('../../../../logic');
|
|
13
|
-
const defaults = require('../../defaults');
|
|
14
8
|
|
|
15
9
|
class RunBaseCommand {
|
|
16
10
|
constructor(argv) {
|
|
@@ -61,34 +55,22 @@ class RunBaseCommand {
|
|
|
61
55
|
packName,
|
|
62
56
|
},
|
|
63
57
|
};
|
|
64
|
-
|
|
65
|
-
supportedVersion: defaults.MIN_API_VERSION_FOR_ENCRYPTED_VARS_SUPPORT_IN_RUN_CMD,
|
|
66
|
-
});
|
|
58
|
+
|
|
67
59
|
if (variablesFromFile) {
|
|
68
60
|
_.forEach(variablesFromFile, (variables) => {
|
|
69
61
|
const request = _.cloneDeep(executionRequestTemplate);
|
|
70
|
-
|
|
71
|
-
request.options.variables = prepareKeyValueObjectsFromEnvFileOption(variables);
|
|
72
|
-
} else {
|
|
73
|
-
request.options.variables = variables;
|
|
74
|
-
}
|
|
62
|
+
request.options.variables = variables;
|
|
75
63
|
this.executionRequests.push(request);
|
|
76
64
|
});
|
|
77
65
|
} else {
|
|
78
|
-
|
|
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
|
-
}
|
|
66
|
+
const variables = prepareKeyValueFromCLIEnvOption(this.argv.variable);
|
|
85
67
|
const request = _.cloneDeep(executionRequestTemplate);
|
|
86
68
|
request.options.variables = variables;
|
|
87
69
|
request.options.contexts = contexts;
|
|
88
70
|
this.executionRequests.push(request);
|
|
89
71
|
}
|
|
90
72
|
|
|
91
|
-
const results = await Promise.all(this.executionRequests.map(
|
|
73
|
+
const results = await Promise.all(this.executionRequests.map(request => this.runImpl(request)));
|
|
92
74
|
const findMaxReducer = (accumulator, currentValue) => (currentValue > accumulator ? currentValue : accumulator);
|
|
93
75
|
const exitCode = results.reduce(findMaxReducer);
|
|
94
76
|
await this.postRunRequest();
|
|
@@ -86,12 +86,6 @@ 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
|
-
})
|
|
95
89
|
.option('detach', {
|
|
96
90
|
alias: 'd',
|
|
97
91
|
describe: 'Run pipeline and print build ID',
|
|
@@ -132,7 +126,6 @@ const run = new Command({
|
|
|
132
126
|
.example('codefresh run PIPELINE_ID | PIPELINE_NAME -b=master', 'Defining the source control context using a branch')
|
|
133
127
|
.example('codefresh run PIPELINE_ID | PIPELINE_NAME -s=52b992e783d2f84dd0123c70ac8623b4f0f938d1', 'Defining the source control context using a commit')
|
|
134
128
|
.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')
|
|
136
129
|
.example('codefresh run PIPELINE_ID | PIPELINE_NAME -b=master --var-file ./var_file.yml', 'Settings variables through a yml file')
|
|
137
130
|
.example('codefresh run PIPELINE_ID | PIPELINE_NAME -b=master --context context', 'Inject contexts to the pipeline execution')
|
|
138
131
|
.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
|
|
7
|
+
const { prepareKeyValueObjectsFromCLIEnvOption, ignoreHttpError } = require('../../helpers/general');
|
|
8
8
|
|
|
9
9
|
const command = new Command({
|
|
10
10
|
command: 'project [id|name]',
|
|
@@ -61,7 +61,14 @@ const command = new Command({
|
|
|
61
61
|
encrypted,
|
|
62
62
|
} = argv;
|
|
63
63
|
|
|
64
|
-
const
|
|
64
|
+
const variableMap = _.reduce(variables, (acc, v) => _.assign(acc, { [v.key]: v }), {});
|
|
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
|
+
});
|
|
65
72
|
|
|
66
73
|
let project = await sdk.projects.get({ id }).catch(ignoreHttpError);
|
|
67
74
|
project = project || await sdk.projects.getByName({ name }).catch(ignoreHttpError);
|
|
@@ -74,7 +81,7 @@ const command = new Command({
|
|
|
74
81
|
const updatePayload = _.pickBy({
|
|
75
82
|
projectName,
|
|
76
83
|
tags: tags || existingTags,
|
|
77
|
-
variables:
|
|
84
|
+
variables: variables || existingVariables,
|
|
78
85
|
}, _.identity);
|
|
79
86
|
|
|
80
87
|
await sdk.projects.patch({ id: project.id }, updatePayload);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
const Command = require('../../Command');
|
|
2
|
+
const CFError = require('cf-errors');
|
|
3
|
+
const _ = require('lodash');
|
|
2
4
|
const { sdk } = require('../../../../logic');
|
|
3
5
|
const createRoot = require('../root/create.cmd');
|
|
4
6
|
const { checkOrProjectExists } = require('../../helpers/validation');
|
|
5
|
-
const { prepareKeyValueObjectsFromCLIEnvOption
|
|
7
|
+
const { prepareKeyValueObjectsFromCLIEnvOption } = require('../../helpers/general');
|
|
6
8
|
|
|
7
9
|
const command = new Command({
|
|
8
10
|
command: 'project <name>',
|
|
@@ -50,10 +52,17 @@ const command = new Command({
|
|
|
50
52
|
encrypted,
|
|
51
53
|
} = argv;
|
|
52
54
|
|
|
53
|
-
const
|
|
55
|
+
const variableMap = _.reduce(variables, (acc, v) => _.assign(acc, { [v.key]: v }), {});
|
|
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
|
+
});
|
|
54
63
|
|
|
55
64
|
await checkOrProjectExists(projectName);
|
|
56
|
-
await sdk.projects.create({ projectName, tags, variables
|
|
65
|
+
await sdk.projects.create({ projectName, tags, variables });
|
|
57
66
|
console.log(`Project: "${projectName}" created`);
|
|
58
67
|
},
|
|
59
68
|
});
|
|
@@ -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"]},"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"]}},"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":{},"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":{}}}
|
|
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"}},"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":{},"attach":{},"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,7 +13,6 @@ 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',
|
|
17
16
|
};
|
|
18
17
|
|
|
19
18
|
module.exports = DEFAULTS;
|
|
@@ -1,43 +1,15 @@
|
|
|
1
|
-
const debug = require('debug')('codefresh:cli:helpers:general');
|
|
2
1
|
const Promise = require('bluebird');
|
|
3
2
|
const _ = require('lodash');
|
|
4
3
|
const fs = require('fs');
|
|
5
4
|
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');
|
|
11
8
|
const Output = require('../../../output/Output');
|
|
12
9
|
const { sdk } = require('../../../logic');
|
|
13
10
|
|
|
14
11
|
const isDebug = () => (process.env.DEBUG || '').includes(defaults.DEBUG_PATTERN);
|
|
15
12
|
|
|
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
|
-
}
|
|
41
13
|
|
|
42
14
|
const wrapHandler = (handler, requiresAuthentication) => {
|
|
43
15
|
return async (argv) => {
|
|
@@ -134,39 +106,6 @@ const prepareKeyValueObjectsFromCLIEnvOption = (environmentVariables) => {
|
|
|
134
106
|
return variables;
|
|
135
107
|
};
|
|
136
108
|
|
|
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
|
-
|
|
170
109
|
const crudFilenameOption = (yargs, options = {}) => {
|
|
171
110
|
const filenameOption = {
|
|
172
111
|
alias: options.alias || 'f',
|
|
@@ -183,19 +122,13 @@ const crudFilenameOption = (yargs, options = {}) => {
|
|
|
183
122
|
.coerce(options.name || 'filename', (arg) => {
|
|
184
123
|
try {
|
|
185
124
|
const rawFile = fs.readFileSync(path.resolve(process.cwd(), arg), 'utf8');
|
|
186
|
-
let content;
|
|
187
125
|
if (arg.endsWith('.json')) {
|
|
188
|
-
|
|
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');
|
|
126
|
+
return options.raw ? rawFile : JSON.parse(rawFile);
|
|
193
127
|
}
|
|
194
|
-
if (
|
|
195
|
-
return
|
|
128
|
+
if (arg.endsWith('.yml') || arg.endsWith('yaml')) {
|
|
129
|
+
return options.raw ? rawFile : yaml.safeLoad(rawFile);
|
|
196
130
|
}
|
|
197
|
-
throw new CFError('
|
|
198
|
-
+ 'For more information how to pass a valid file, go to https://codefresh-io.github.io/cli/pipelines/run-pipeline/');
|
|
131
|
+
throw new CFError('File extension is not recognized');
|
|
199
132
|
} catch (err) {
|
|
200
133
|
const error = new CFError({
|
|
201
134
|
message: 'Failed to read file',
|
|
@@ -228,15 +161,15 @@ const selectColumnsOption = (yargs, options = {}) => {
|
|
|
228
161
|
};
|
|
229
162
|
|
|
230
163
|
function pathExists(p) {
|
|
231
|
-
return new Promise(
|
|
232
|
-
.then(
|
|
164
|
+
return new Promise(resolve => fs.access(p, resolve))
|
|
165
|
+
.then(err => !err);
|
|
233
166
|
}
|
|
234
167
|
|
|
235
168
|
const readFile = Promise.promisify(fs.readFile);
|
|
236
169
|
|
|
237
170
|
function watchFile(filename, listener) {
|
|
238
171
|
fs.watchFile(filename, { interval: 500 }, listener);
|
|
239
|
-
const unwatcher =
|
|
172
|
+
const unwatcher = f => () => fs.unwatchFile(f);
|
|
240
173
|
['exit', 'SIGINT', 'SIGUSR1', 'SIGUSR2', 'uncaughtException', 'SIGTERM'].forEach((eventType) => {
|
|
241
174
|
process.on(eventType, unwatcher(filename));
|
|
242
175
|
});
|
|
@@ -244,7 +177,7 @@ function watchFile(filename, listener) {
|
|
|
244
177
|
|
|
245
178
|
function ignoreHttpError(e) {
|
|
246
179
|
if (!e.statusCode) {
|
|
247
|
-
throw e
|
|
180
|
+
throw e
|
|
248
181
|
}
|
|
249
182
|
return undefined;
|
|
250
183
|
}
|
|
@@ -299,7 +232,4 @@ module.exports = {
|
|
|
299
232
|
detectProxy,
|
|
300
233
|
keyValueArrayToObject,
|
|
301
234
|
addProxyVariables,
|
|
302
|
-
markEncryptedFlagOnRequestedVariables,
|
|
303
|
-
prepareKeyValueObjectsFromEnvFileOption,
|
|
304
|
-
isCompatibleApiVersion,
|
|
305
235
|
};
|
package/package.json
CHANGED