Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/interface/cli/commands/hybrid/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,7 @@ async function attachRuntime({
valuesFile, // --values
setValue, // --set-value
setFile, // --set-file
dryRun,
}) {
const binLocation = await downloadVeonona();
const componentRunner = new Runner(binLocation);
Expand Down Expand Up @@ -885,6 +886,9 @@ async function attachRuntime({
if (setFile) {
cmd.push(`--set-file=${setFile}`);
}
if (dryRun) {
cmd.push('--dry-run');
}
await componentRunner.run(components.venona, cmd);
}

Expand Down
50 changes: 36 additions & 14 deletions lib/interface/cli/commands/hybrid/init.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function printInstallationOptionsSummary({
noProxy,
appProxy,
appProxyHost,
dryRun,
}) {
let summary = `\n${colors.green('Installation options summary:')}
1. Kubernetes Context: ${colors.cyan(kubeContextName)}
Expand All @@ -73,6 +74,9 @@ function printInstallationOptionsSummary({
if (appProxy) {
summary += `7. App-Proxy hostname: ${colors.cyan(appProxyHost)}\n`;
}
if (dryRun) {
summary += '**** running in dry run mode';
}
console.log(summary);
}

Expand Down Expand Up @@ -194,6 +198,11 @@ const initCmd = new Command({
default: true,
type: 'boolean',
})
.option('dry-run', {
describe: 'dry run',
default: false,
type: 'boolean',
})
.example('codefresh runner init --values values.yaml (see values file example here: '
+ 'https://github.com/codefresh-io/venona/blob/release-1.0/venonactl/example/values-example.yaml)'),
handler: async (argv) => {
Expand Down Expand Up @@ -249,6 +258,7 @@ const initCmd = new Command({
reResources,
userVolumeMounts,
userVolumes,
'dry-run': dryRun,
} = _argv;
let {
'kube-context-name': kubeContextName,
Expand Down Expand Up @@ -395,6 +405,7 @@ const initCmd = new Command({
noProxy,
appProxy,
appProxyHost,
dryRun,
});

if (token) {
Expand All @@ -417,7 +428,7 @@ const initCmd = new Command({
shouldMakeDefaultRe,
shouldExecutePipeline,
},
}));
}, dryRun));
const progressReporter = installationProgress.buildReporter(sdk['runner-installation'], progress);

let installationPlan;
Expand Down Expand Up @@ -457,7 +468,7 @@ const initCmd = new Command({
setFile,
},
installationEvent: installationProgress.events.ACCEPTANCE_TESTS_RAN,
condition: !skipClusterTest,
condition: !skipClusterTest && !dryRun,
});

// generate new agent name
Expand All @@ -469,7 +480,7 @@ const initCmd = new Command({
installationPlan.addContext('agentName', agentName);
},
args: [kubeContextName, kubeNamespace],
condition: async () => !installationPlan.getContext('agentName'),
condition: async () => !installationPlan.getContext('agentName') && !dryRun,
});

// create new agent
Expand All @@ -484,7 +495,7 @@ const initCmd = new Command({
installationPlan.addContext('agentToken', agentToken);
},
installationEvent: installationProgress.events.AGENT_CREATED,
condition: async () => !installationPlan.getContext('agentToken'),
condition: async () => !installationPlan.getContext('agentToken') && !dryRun,
});

// install agent
Expand All @@ -495,17 +506,18 @@ const initCmd = new Command({
apiHost: sdk.config.context.url,
kubeContextName,
kubeNamespace,
token: installationPlan.getContext('agentToken'),
token: dryRun ? 'dry-run-token' : installationPlan.getContext('agentToken'),
kubeNodeSelector,
tolerations,
kubeConfigPath,
dockerRegistry,
verbose,
agentId: installationPlan.getContext('agentName'),
agentId: dryRun ? 'dry-run-agent-id' : installationPlan.getContext('agentName'),
envVars,
valuesFile, // --values
setValue, // --set-value
setFile, // --set-file
dryRun,
});
},
installationEvent: installationProgress.events.AGENT_INSTALLED,
Expand All @@ -520,14 +532,14 @@ const initCmd = new Command({
installationPlan.addContext('runtimeName', reName);
},
args: [kubeContextName, kubeNamespace],
condition: async () => !installationPlan.getContext('runtimeName'),
condition: async () => !installationPlan.getContext('runtimeName') && !dryRun,
});

// create new runtime
installationPlan.addStep({
name: 'create new runtime',
func: async () => {
const reName = installationPlan.getContext('runtimeName');
const reName = dryRun ? 'dry-run-runtime-name' : installationPlan.getContext('runtimeName');
const runtimeCreateOpt = {
namespace: kubeNamespace,
storageClassName: storageClassName || `${INSTALLATION_DEFAULTS.STORAGE_CLASS_PREFIX}-${kubeNamespace}`,
Expand Down Expand Up @@ -561,7 +573,7 @@ const initCmd = new Command({
await sdk.runtimeEnvs.update({ name: reName }, _.merge(re, body));
console.log(`Runtime environment "${colors.cyan(reName)}" has been updated with the specified docker-registry images`);
},
condition: !!dockerRegistry,
condition: !!dockerRegistry && !dryRun,
});

// update env vars
Expand Down Expand Up @@ -604,7 +616,7 @@ const initCmd = new Command({
await sdk.runtimeEnvs.update({ name: reName }, re);
console.log(`Runtime environment "${colors.cyan(reName)}" has been updated with env vars`);
},
condition: envVars.length || reResources || userVolumeMounts || userVolumes || reEnvVars,
condition: !dryRun && (envVars.length || reResources || userVolumeMounts || userVolumes || reEnvVars),
});

// set runtime as default
Expand All @@ -618,7 +630,7 @@ const initCmd = new Command({
await sdk.runtimeEnvs.setDefault({ account: re.accountId, name: re.metadata.name });
console.log(`Runtime environment "${colors.cyan(reName)}" has been set as the default runtime`);
},
condition: shouldMakeDefaultRe,
condition: shouldMakeDefaultRe && !dryRun,
});

// add cluster integration
Expand All @@ -639,6 +651,10 @@ const initCmd = new Command({
console.log('Cluster integration was not added , please add it via codefresh "create clusters [name]"');
return false;
}
if (dryRun) {
console.log('Cluster integration was not added , dry run mode');
return false;
}
const clusters = await sdk.clusters.list() || [];
if (clusters.find(cluster => cluster.selector === kubeContextName)) {
return false; // cluster already exists
Expand All @@ -654,7 +670,7 @@ const initCmd = new Command({
func: async () => {
await installRuntime({
apiHost: sdk.config.context.url,
name: installationPlan.getContext('runtimeName'),
name: dryRun ? 'dry-run-runtime-name' : installationPlan.getContext('runtimeName'),
kubeContextName,
kubeNamespace,
token: sdk.config.context.token,
Expand All @@ -667,6 +683,7 @@ const initCmd = new Command({
setValue,
setFile,
storageClassName,
dryRun,
});
},
installationEvent: installationProgress.events.RUNTIME_INSTALLED,
Expand All @@ -693,7 +710,7 @@ const initCmd = new Command({
installationPlan.addContext('appProxyIP', `${appProxyUrl}`);
},
installationEvent: installationProgress.events.APP_PROXY_INSTALLED,
condition: !!appProxy,
condition: !!appProxy && !dryRun,
});

// update runtime with ingress IP
Expand Down Expand Up @@ -735,6 +752,7 @@ const initCmd = new Command({
throw new Error(`Runtime ${name} already attached`);
}
},
condition: !dryRun,
installationEvent: installationProgress.events.AGENT_UPDATED,
});

Expand All @@ -752,6 +770,7 @@ const initCmd = new Command({
restartAgent: true, // --restart-agent
verbose, // --verbose
runtimeName: installationPlan.getContext('runtimeName'), // --runtimeName
dryRun,
});
},
installationEvent: installationProgress.events.RUNNER_INSTALLED,
Expand All @@ -770,6 +789,7 @@ const initCmd = new Command({
'env-vars': envVars,
'set-value': setValue,
'set-file': setFile,
'dry-run': dryRun,
token: _.get(sdk, 'config.context.token'),
verbose,
noExit: true, // to prevent if from calling inner: process.exit()
Expand All @@ -793,7 +813,7 @@ const initCmd = new Command({
});

// Post Installation
if (shouldExecutePipeline) {
if (shouldExecutePipeline && !dryRun) {
const pipelines = await sdk.pipelines.list({ id: `${INSTALLATION_DEFAULTS.PROJECT_NAME}/${INSTALLATION_DEFAULTS.DEMO_PIPELINE_NAME}` });
const testPipelineExists = !!_.get(pipelines, 'docs.length');
if (!testPipelineExists) {
Expand All @@ -818,6 +838,7 @@ const initCmd = new Command({
INSTALLATION_DEFAULTS.DEMO_PIPELINE_NAME,
);
},
condition: !dryRun,
errMessage: colors.yellow('*warning* could not update test pipeline runtime, you can' +
' change it manually if you want to run it again on this runtime'),
successMessage: 'Updated test pipeline runtime',
Expand All @@ -834,6 +855,7 @@ const initCmd = new Command({
},
errMessage: 'Failed to execute test pipeline',
installationEvent: installationProgress.events.PIPELINE_EXECUTED,
condition: !dryRun,
});
}

Expand Down
5 changes: 4 additions & 1 deletion lib/interface/cli/commands/hybrid/installation-process.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const Promise = require('bluebird');
const { to } = require('./../../../../logic/cli-config/errors/awaitTo');

async function create(installer, event) {
async function create(installer, event, dryRun) {
if (dryRun) {
return {};
}
const [err, res] = await to(installer.createNewInstallationProgress(event));
if (err) {
return {};
Expand Down
9 changes: 9 additions & 0 deletions lib/interface/cli/commands/monitor/install.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ const installMonitorCmd = new Command({
})
.option('verbose', {
describe: 'Print logs',
})
.option('dry-run', {
describe: 'dry run',
default: false,
type: 'boolean',
}),
handler: async (argv) => {
const {
Expand All @@ -63,6 +68,7 @@ const installMonitorCmd = new Command({
'env-vars': envVars,
'set-value': setValue,
'set-file': setFile,
'dry-run': dryRun,
// noExit,
} = argv;
const binLocation = await downloadVeonona();
Expand Down Expand Up @@ -137,6 +143,9 @@ const installMonitorCmd = new Command({
commands.push(`--set-value=EnvVars.${parts[0]}=${parts[1].replace(/,/g, '\\,')}`);
});
}
if (dryRun) {
commands.push('--dry-run');
}

await componentRunner.run(components.venona, commands);
},
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.74.6",
"version": "0.74.7",
"description": "Codefresh command line utility",
"main": "index.js",
"preferGlobal": true,
Expand Down