Skip to content

Commit

Permalink
feat: add the imageTag flag. (#258)
Browse files Browse the repository at this point in the history
* feat: add the imageTag flag.

This also deprecates the use of the --nodeVersion flag, which will be removed in the 2.0 version.

fixes #256

* remove the default choice for nodeVersion
  • Loading branch information
lholmquist committed Aug 14, 2018
1 parent e4256bf commit 399081e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 10 deletions.
14 changes: 12 additions & 2 deletions bin/nodeshift
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ yargs
type: 'string'
})
.options('nodeVersion', {
describe: 'the version of Node.js to use for the deployed application.',
describe: 'DEPRECATED - use imageTag instead. The version of Node.js to use for the deployed application.',
alias: 'n',
type: 'string'
})
.options('imageTag', {
describe: 'The version of the docker image to use for the deployed application.',
type: 'string',
default: 'latest'
})
Expand Down Expand Up @@ -142,7 +146,13 @@ function createOptions (argv) {

options.projectLocation = argv.projectLocation;
options.dockerImage = argv.dockerImage;
options.nodeVersion = argv.nodeVersion;
options.imageTag = argv.imageTag;
// Remove during a major version release
if (argv.nodeVersion) {
console.log('DEPRECATION NOTICE - nodeVersion will be removed in the 2.0 release of Nodeshift. Please use imageTag instead.');
options.imageTag = argv.nodeVersion;
}
//
process.env['NODESHIFT_QUIET'] = argv.quiet === true;
options.metadata = argv.metadata;
options.build = argv.build;
Expand Down
15 changes: 10 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const cli = require('./bin/cli');
@param {boolean} [options.tryServiceAccount] - Set to false to by-pass service account lookup
@param {boolean} [options.expose] - Set to true to create a default Route and expose the default service. defaults to false
@param {string} [options.namespace] - Overwrites any namespace settings in your OpenShift or Kubernetes configuration files
@param {string} [options.nodeVersion] - set the nodeversion to use for the bucharest-gold/centos7-s2i-image. Versions are docker hub tags: https://hub.docker.com/r/bucharestgold/centos7-s2i-nodejs/tags/
@param {string} [options.nodeVersion(deprecated)] - set the nodeversion to use for the bucharest-gold/centos7-s2i-image. Versions are docker hub tags: https://hub.docker.com/r/bucharestgold/centos7-s2i-nodejs/tags/
@param {string} [options.imageTag] - set the version to use for the bucharest-gold/centos7-s2i-image. Versions are docker hub tags: https://hub.docker.com/r/bucharestgold/centos7-s2i-nodejs/tags/
@param {boolean} [options.quiet] - supress INFO and TRACE lines from output logs
@param {object} [options.deploy] -
@param {number} [options.deploy.port] - flag to update the default ports on the resource files. Defaults to 8080
Expand All @@ -45,7 +46,8 @@ function deploy (options = {}) {
@param {boolean} [options.tryServiceAccount] - Set to false to by-pass service account lookup
@param {boolean} [options.expose] - Set to true to create a default Route and expose the default service. defaults to false
@param {string} [options.namespace] - Overwrites any namespace settings in your OpenShift or Kubernetes configuration files
@param {string} [options.nodeVersion] - set the nodeversion to use for the bucharest-gold/centos7-s2i-image. Versions are docker hub tags: https://hub.docker.com/r/bucharestgold/centos7-s2i-nodejs/tags/
@param {string} [options.nodeVersion(deprecated)] - set the nodeversion to use for the bucharest-gold/centos7-s2i-image. Versions are docker hub tags: https://hub.docker.com/r/bucharestgold/centos7-s2i-nodejs/tags/
@param {string} [options.imageTag] - set the version to use for the bucharest-gold/centos7-s2i-image. Versions are docker hub tags: https://hub.docker.com/r/bucharestgold/centos7-s2i-nodejs/tags/
@param {boolean} [options.quiet] - supress INFO and TRACE lines from output logs
@param {object} [options.build] -
@param {string/boolean} [options.build.recreate] - flag to recreate a buildConfig or Imagestream. values are "buildConfig", "imageStream", true, false. Defaults to false
Expand All @@ -67,7 +69,8 @@ function resource (options = {}) {
@param {boolean} [options.tryServiceAccount] - Set to false to by-pass service account lookup
@param {boolean} [options.expose] - Set to true to create a default Route and expose the default service. defaults to false
@param {string} [options.namespace] - Overwrites any namespace settings in your OpenShift or Kubernetes configuration files
@param {string} [options.nodeVersion] - set the nodeversion to use for the bucharest-gold/centos7-s2i-image. Versions are docker hub tags: https://hub.docker.com/r/bucharestgold/centos7-s2i-nodejs/tags/
@param {string} [options.nodeVersion(deprecated)] - set the nodeversion to use for the bucharest-gold/centos7-s2i-image. Versions are docker hub tags: https://hub.docker.com/r/bucharestgold/centos7-s2i-nodejs/tags/
@param {string} [options.imageTag] - set the version to use for the bucharest-gold/centos7-s2i-image. Versions are docker hub tags: https://hub.docker.com/r/bucharestgold/centos7-s2i-nodejs/tags/
@param {boolean} [options.quiet] - supress INFO and TRACE lines from output logs
@param {object} [options.deploy] -
@param {number} [options.deploy.port] - flag to update the default ports on the resource files. Defaults to 8080
Expand All @@ -91,7 +94,8 @@ function applyResource (options = {}) {
@param {boolean} [options.strictSSL] - Set to false to allow self-signed Certs
@param {boolean} [options.tryServiceAccount] - Set to false to by-pass service account lookup
@param {string} [options.namespace] - Overwrites any namespace settings in your OpenShift or Kubernetes configuration files
@param {string} [options.nodeVersion] - set the nodeversion to use for the bucharest-gold/centos7-s2i-image. Versions are docker hub tags: https://hub.docker.com/r/bucharestgold/centos7-s2i-nodejs/tags/
@param {string} [options.nodeVersion(deprecated)] - set the nodeversion to use for the bucharest-gold/centos7-s2i-image. Versions are docker hub tags: https://hub.docker.com/r/bucharestgold/centos7-s2i-nodejs/tags/
@param {string} [options.imageTag] - set the version to use for the bucharest-gold/centos7-s2i-image. Versions are docker hub tags: https://hub.docker.com/r/bucharestgold/centos7-s2i-nodejs/tags/
@param {boolean} [options.quiet] - supress INFO and TRACE lines from output logs
@param {boolean} [options.removeAll] - option to remove builds, buildConfigs and Imagestreams. Defaults to false
@param {object} [options.deploy] -
Expand All @@ -116,7 +120,8 @@ function undeploy (options = {}) {
@param {boolean} [options.strictSSL] - Set to false to allow self-signed Certs
@param {boolean} [options.tryServiceAccount] - Set to false to by-pass service account lookup
@param {string} [options.namespace] - Overwrites any namespace settings in your OpenShift or Kubernetes configuration files
@param {string} [options.nodeVersion] - set the nodeversion to use for the bucharest-gold/centos7-s2i-image. Versions are docker hub tags: https://hub.docker.com/r/bucharestgold/centos7-s2i-nodejs/tags/
@param {string} [options.nodeVersion(deprecated)] - set the nodeversion to use for the bucharest-gold/centos7-s2i-image. Versions are docker hub tags: https://hub.docker.com/r/bucharestgold/centos7-s2i-nodejs/tags/
@param {string} [options.imageTag] - set the version to use for the bucharest-gold/centos7-s2i-image. Versions are docker hub tags: https://hub.docker.com/r/bucharestgold/centos7-s2i-nodejs/tags/
@param {boolean} [options.quiet] - supress INFO and TRACE lines from output logs
@param {object} [options.build] -
@param {string/boolean} [options.build.recreate] - flag to recreate a buildConfig or Imagestream. values are "buildConfig", "imageStream", true, false. Defaults to false
Expand Down
4 changes: 2 additions & 2 deletions lib/build-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ async function createOrUpdateBuildConfig (config) {
logger.info(`creating build configuration ${buildName}`);
const newBuildConfig = createBuildConfig(config, {
outputImageStreamTag: outputImageStreamTag,
nodeVersion: config.nodeVersion,
imageTag: config.imageTag,
forcePull: config.build.forcePull,
incremental: config.build.incremental,
dockerImage: config.dockerImage,
Expand All @@ -109,7 +109,7 @@ async function createOrUpdateBuildConfig (config) {
logger.info(`Re-creating build configuration ${buildName}`);
const newBuildConfig = createBuildConfig(config, {
outputImageStreamTag: outputImageStreamTag,
nodeVersion: config.nodeVersion,
imageTag: config.imageTag,
forcePull: config.build.forcePull,
dockerImage: config.dockerImage,
buildEnv: config.build.env
Expand Down
3 changes: 2 additions & 1 deletion lib/definitions/build-strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const DEFAULT_DOCKER_TAG = 'latest';
module.exports = (options = {}) => {
// Just doing the source strategy
const dockerImage = options.dockerImage ? options.dockerImage : DEFAULT_DOCKER_IMAGE;
const dockerTag = options.nodeVersion ? options.nodeVersion : DEFAULT_DOCKER_TAG;
// remove the options.nodeVersion in 2.0
const dockerTag = options.imageTag ? options.imageTag : (options.nodeVersion ? options.nodeVersion : DEFAULT_DOCKER_TAG);
logger.info(`Using s2i image ${dockerImage} with tag ${dockerTag}`);
const dockerImageName = `${dockerImage}:${dockerTag}`;
const env = options.buildEnv || [];
Expand Down
6 changes: 6 additions & 0 deletions test/build-strategy-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ test('accepts a node version option', t => {
t.equals(buildStrategy.sourceStrategy.from.name, 'bucharestgold/centos7-s2i-nodejs:8.x');
t.end();
});

test('accepts a node version using imageTag option', t => {
const buildStrategy = BuildStrategy({imageTag: '8.x'});
t.equals(buildStrategy.sourceStrategy.from.name, 'bucharestgold/centos7-s2i-nodejs:8.x');
t.end();
});

0 comments on commit 399081e

Please sign in to comment.