Skip to content

Commit

Permalink
Cr 1230 added --insecure flag to root command to solve missing/self-s…
Browse files Browse the repository at this point in the history
…igned certificate issues (#575)
  • Loading branch information
roi-codefresh authored Oct 22, 2020
1 parent 7f42691 commit 2b64b82
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 32 deletions.
10 changes: 10 additions & 0 deletions lib/interface/cli/commad-line-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ async function startCommandLine() {
describe: `Custom path for authentication contexts config file (default: ${DEFAULTS.CFCONFIG})`,
global: false,
})
.option('insecure', {
describe: 'disable certificate validation for TLS connections (e.g. to g.codefresh.io)',
type: 'boolean',
coerce: (insecure) => {
if (insecure) {
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
}
return insecure;
},
})
.option('request-timeout', {
describe: `Request timeout (default: ${cliConfig.request.timeout})`,
global: false,
Expand Down
11 changes: 0 additions & 11 deletions lib/interface/cli/commands/hybrid/delete.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ const deleteCmd = new Command({
})
.option('verbose', {
describe: 'Print logs',
})
.option('insecure', {
describe: 'disable certificate validation for TLS connections (e.g. to g.codefresh.io)',
type: 'boolean',
}),
handler: async (argv) => {
let {
Expand All @@ -100,7 +96,6 @@ const deleteCmd = new Command({
'kube-namespace': kubeNamespace,
name: agentName,
values: valuesFile,
insecure,
} = argv;

const [listReErr, runtimes] = await to(sdk.runtimeEnvs.list({ }));
Expand Down Expand Up @@ -134,16 +129,10 @@ const deleteCmd = new Command({
if (!agentName && valuesObj.AgentId) {
agentName = valuesObj.AgentId;
}
if (_.isUndefined(insecure)) {
insecure = _.get(valuesObj, 'Insecure');
}
}
if (!url) {
url = DEFAULTS.URL;
}
if (insecure) {
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
}

if (!kubeContextName) {
const contexts = getAllKubeContexts(kubeConfigPath);
Expand Down
11 changes: 0 additions & 11 deletions lib/interface/cli/commands/hybrid/init.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,6 @@ const initCmd = new Command({
describe: 'docker daemon access (default true)',
default: true,
type: 'boolean',
})
.option('insecure', {
describe: 'disable certificate validation for TLS connections (e.g. to g.codefresh.io)',
type: 'boolean',
}),
handler: async (argv) => {
let resumedInstallation = false;
Expand Down Expand Up @@ -237,7 +233,6 @@ const initCmd = new Command({
url,
token,
name,
insecure,
'app-proxy': appProxy,
'app-proxy-host': appProxyHost,
'install-monitor': installMonitor,
Expand Down Expand Up @@ -280,16 +275,10 @@ const initCmd = new Command({
if (_.has(valuesObj, 'dockerDaemonScheduler.userAccess')) {
dockerDaemonAccess = _.get(valuesObj, 'dockerDaemonScheduler.userAccess')
}
if (_.isUndefined(insecure)) {
insecure = _.get(valuesObj, 'Insecure');
}
}
if (!url) {
url = DEFAULTS.URL;
}
if (insecure) {
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
}

if (_.get(sdk, 'config.context.isNoAuth') && !token) {
console.log('Not authenticated as a Codefresh account: ');
Expand Down
9 changes: 0 additions & 9 deletions lib/interface/cli/commands/hybrid/upgrade.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,20 @@ const upgradeCmd = new Command({
})
.option('verbose', {
describe: 'Print logs',
})
.option('insecure', {
describe: 'disable certificate validation for TLS connections (e.g. to g.codefresh.io)',
type: 'boolean',
}),
handler: async (argv) => {
const {
'kube-config-path': kubeConfigPath,
'agent-name': agentName,
'install-monitor': installMonitor,
verbose,
insecure,
} = argv;
let {
'kube-context-name': kubeContextName,
'kube-namespace': kubeNamespace,
'runtime-name': runtimeName,
} = argv;

if (insecure) {
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
}

const [listReErr, runtimes] = await to(sdk.runtimeEnvs.list({ }));
await handleError(listReErr, 'Failed to get runtime environments');
const runtimesByName = runtimes.reduce((acc, cur) => ({ ...acc, [cur.metadata.name]: cur }), {});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codefresh",
"version": "0.73.9",
"version": "0.73.10",
"description": "Codefresh command line utility",
"main": "index.js",
"preferGlobal": true,
Expand Down

0 comments on commit 2b64b82

Please sign in to comment.