Skip to content

Commit 2b64b82

Browse files
Cr 1230 added --insecure flag to root command to solve missing/self-signed certificate issues (#575)
1 parent 7f42691 commit 2b64b82

File tree

5 files changed

+11
-32
lines changed

5 files changed

+11
-32
lines changed

lib/interface/cli/commad-line-interface.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ async function startCommandLine() {
6060
describe: `Custom path for authentication contexts config file (default: ${DEFAULTS.CFCONFIG})`,
6161
global: false,
6262
})
63+
.option('insecure', {
64+
describe: 'disable certificate validation for TLS connections (e.g. to g.codefresh.io)',
65+
type: 'boolean',
66+
coerce: (insecure) => {
67+
if (insecure) {
68+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
69+
}
70+
return insecure;
71+
},
72+
})
6373
.option('request-timeout', {
6474
describe: `Request timeout (default: ${cliConfig.request.timeout})`,
6575
global: false,

lib/interface/cli/commands/hybrid/delete.cmd.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ const deleteCmd = new Command({
8787
})
8888
.option('verbose', {
8989
describe: 'Print logs',
90-
})
91-
.option('insecure', {
92-
describe: 'disable certificate validation for TLS connections (e.g. to g.codefresh.io)',
93-
type: 'boolean',
9490
}),
9591
handler: async (argv) => {
9692
let {
@@ -100,7 +96,6 @@ const deleteCmd = new Command({
10096
'kube-namespace': kubeNamespace,
10197
name: agentName,
10298
values: valuesFile,
103-
insecure,
10499
} = argv;
105100

106101
const [listReErr, runtimes] = await to(sdk.runtimeEnvs.list({ }));
@@ -134,16 +129,10 @@ const deleteCmd = new Command({
134129
if (!agentName && valuesObj.AgentId) {
135130
agentName = valuesObj.AgentId;
136131
}
137-
if (_.isUndefined(insecure)) {
138-
insecure = _.get(valuesObj, 'Insecure');
139-
}
140132
}
141133
if (!url) {
142134
url = DEFAULTS.URL;
143135
}
144-
if (insecure) {
145-
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
146-
}
147136

148137
if (!kubeContextName) {
149138
const contexts = getAllKubeContexts(kubeConfigPath);

lib/interface/cli/commands/hybrid/init.cmd.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,6 @@ const initCmd = new Command({
184184
describe: 'docker daemon access (default true)',
185185
default: true,
186186
type: 'boolean',
187-
})
188-
.option('insecure', {
189-
describe: 'disable certificate validation for TLS connections (e.g. to g.codefresh.io)',
190-
type: 'boolean',
191187
}),
192188
handler: async (argv) => {
193189
let resumedInstallation = false;
@@ -237,7 +233,6 @@ const initCmd = new Command({
237233
url,
238234
token,
239235
name,
240-
insecure,
241236
'app-proxy': appProxy,
242237
'app-proxy-host': appProxyHost,
243238
'install-monitor': installMonitor,
@@ -280,16 +275,10 @@ const initCmd = new Command({
280275
if (_.has(valuesObj, 'dockerDaemonScheduler.userAccess')) {
281276
dockerDaemonAccess = _.get(valuesObj, 'dockerDaemonScheduler.userAccess')
282277
}
283-
if (_.isUndefined(insecure)) {
284-
insecure = _.get(valuesObj, 'Insecure');
285-
}
286278
}
287279
if (!url) {
288280
url = DEFAULTS.URL;
289281
}
290-
if (insecure) {
291-
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
292-
}
293282

294283
if (_.get(sdk, 'config.context.isNoAuth') && !token) {
295284
console.log('Not authenticated as a Codefresh account: ');

lib/interface/cli/commands/hybrid/upgrade.cmd.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,29 +69,20 @@ const upgradeCmd = new Command({
6969
})
7070
.option('verbose', {
7171
describe: 'Print logs',
72-
})
73-
.option('insecure', {
74-
describe: 'disable certificate validation for TLS connections (e.g. to g.codefresh.io)',
75-
type: 'boolean',
7672
}),
7773
handler: async (argv) => {
7874
const {
7975
'kube-config-path': kubeConfigPath,
8076
'agent-name': agentName,
8177
'install-monitor': installMonitor,
8278
verbose,
83-
insecure,
8479
} = argv;
8580
let {
8681
'kube-context-name': kubeContextName,
8782
'kube-namespace': kubeNamespace,
8883
'runtime-name': runtimeName,
8984
} = argv;
9085

91-
if (insecure) {
92-
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
93-
}
94-
9586
const [listReErr, runtimes] = await to(sdk.runtimeEnvs.list({ }));
9687
await handleError(listReErr, 'Failed to get runtime environments');
9788
const runtimesByName = runtimes.reduce((acc, cur) => ({ ...acc, [cur.metadata.name]: cur }), {});

package.json

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

0 commit comments

Comments
 (0)