-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
monitor installation with helm (#661)
- Loading branch information
1 parent
3aaa800
commit 1c92eb2
Showing
4 changed files
with
152 additions
and
72 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
lib/interface/cli/commands/hybrid/execute-test-pipeline.cmd.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const Command = require('../../Command'); | ||
const runnerRoot = require('../root/runner.cmd'); | ||
const colors = require('colors'); | ||
const InstallationPlan = require('./InstallationPlan'); | ||
const { addPipelineToInstallationPlan } = require('./pipeline-helper'); | ||
const { createErrorHandler } = require('./helper'); | ||
|
||
const handleError = createErrorHandler(`\nIf you had any issues with the installation please report them at:\ | ||
${colors.blue('https://github.com/codefresh-io/cli/issues/new')}`); | ||
|
||
const defaultDockerRegistry = 'quay.io'; | ||
|
||
const command = new Command({ | ||
command: 'execute-test-pipeline', | ||
parent: runnerRoot, | ||
requiresAuthentication: true, | ||
description: 'Executes test pipeline', | ||
webDocs: { | ||
category: 'Runner', | ||
title: 'Execute test pipeline', | ||
}, | ||
builder: yargs => yargs | ||
.option('runtime-name', { | ||
describe: 'Runtime name to execute pipeline on', | ||
}), | ||
handler: async (argv) => { | ||
const { runtimeName } = argv; | ||
|
||
const installationPlan = new InstallationPlan({ errHandler: handleError }); | ||
installationPlan.addContext('runtimeName', runtimeName ? runtimeName.trim() : runtimeName); | ||
await addPipelineToInstallationPlan(installationPlan, defaultDockerRegistry, true); | ||
await installationPlan.execute(); | ||
process.exit(); // TODO : This is not needed - needed to be fixed | ||
}, | ||
}); | ||
|
||
module.exports = command; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
const sdk = require('../../../../logic/sdk'); | ||
const colors = require('colors'); | ||
const installationProgress = require('./installation-process'); | ||
const _ = require('lodash'); | ||
|
||
const { | ||
createTestPipeline, | ||
executeTestPipeline, | ||
updateTestPipelineRuntime, | ||
INSTALLATION_DEFAULTS, | ||
} = require('./helper'); | ||
|
||
const defaultDockerRegistry = 'quay.io'; | ||
|
||
async function addPipelineToInstallationPlan(installationPlan, dockerRegistry = '', executePipeline = true) { | ||
if (!dockerRegistry) { | ||
// eslint-disable-next-line no-param-reassign | ||
dockerRegistry = defaultDockerRegistry; | ||
} | ||
|
||
const pipelines = await sdk.pipelines.list({ id: `${INSTALLATION_DEFAULTS.PROJECT_NAME}/${INSTALLATION_DEFAULTS.DEMO_PIPELINE_NAME}` }); | ||
const testPipelineExists = !!_.get(pipelines, 'docs.length'); | ||
|
||
if (!testPipelineExists) { | ||
installationPlan.addStep({ | ||
name: 'create test pipeline', | ||
func: async () => { | ||
await createTestPipeline( | ||
installationPlan.getContext('runtimeName'), | ||
INSTALLATION_DEFAULTS.DEMO_PIPELINE_NAME, | ||
['echo hello Codefresh Runner!'], | ||
dockerRegistry, | ||
); | ||
}, | ||
installationEvent: installationProgress.events.PIPELINE_CREATED, | ||
}); | ||
} else { | ||
installationPlan.addStep({ | ||
name: 'update test pipeline runtime', | ||
func: async () => { | ||
await updateTestPipelineRuntime( | ||
undefined, | ||
installationPlan.getContext('runtimeName'), | ||
INSTALLATION_DEFAULTS.DEMO_PIPELINE_NAME, | ||
dockerRegistry, | ||
); | ||
}, | ||
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', | ||
exitOnError: false, | ||
}); | ||
} | ||
|
||
installationPlan.addStep({ | ||
name: 'execute test pipeline', | ||
func: async () => { | ||
await executeTestPipeline( | ||
installationPlan.getContext('runtimeName'), | ||
INSTALLATION_DEFAULTS.DEMO_PIPELINE_NAME, | ||
); | ||
}, | ||
errMessage: 'Failed to execute test pipeline', | ||
installationEvent: installationProgress.events.PIPELINE_EXECUTED, | ||
condition: executePipeline, | ||
}); | ||
} | ||
|
||
module.exports = { | ||
addPipelineToInstallationPlan, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters