forked from nodeshift/nodeshift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
151 lines (138 loc) · 12.1 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
'use strict';
const cli = require('./bin/cli');
/*
This is the public facing API of nodeshift. The commands here mirror the commands from the CLI.
All methods take an options object
*/
/**
The deploy function will do the combination of resource, build and apply-resource
@param {object} [options] - Options object for the deploy function
@param {string} [options.projectLocation] - the location(directory) of your projects package.json. Defaults to `process.cwd`
@param {boolean} [options.expose] - Set to true to create a default Route and expose the default service. defaults to false
@param {object} [options.namespace] -
@param {string} [options.namespace.displayName] - flag to specify the project namespace display name to build/deploy into. Overwrites any namespace settings in your OpenShift or Kubernetes configuration files
@param {boolean} [options.namespace.create] - flag to create the namespace if it does not exist. Only applicable for the build and deploy command. Must be used with namespace.name
@param {string} [options.namespace.name] - flag to specify the project namespace name to build/deploy into. Overwrites any namespace settings in your OpenShift or Kubernetes configuration files
@param {string} [options.imageTag] - set the version to use for the ubi8/nodejs-10. Versions are ubi8/nodejs-10 tags: https://access.redhat.com/containers/?tab=tags#/registry.access.redhat.com/ubi8/nodejs-10
@param {string} [options.outputImageStream] - the name of the ImageStream to output to. Defaults to project name from package.json
@param {string} [options.outputImageTag] - The tag of the ImageStream to output to. Defaults to latest
@param {boolean} [options.quiet] - suppress 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
@param {Array} [options.deploy.env] - an array of objects to pass deployment config environment variables. [{name: NAME_PROP, value: VALUE}]
@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
@param {boolean} [options.build.forcePull] - flag to make your BuildConfig always pull a new image from dockerhub or not. Defaults to false
@param {Array} [options.build.env] - an array of objects to pass build config environment variables. [{name: NAME_PROP, value: VALUE}]
@param {array} [options.definedProperties] - Array of objects with the format { key: value }. Used for template substitution
@returns {Promise<object>} - Returns a JSON Object
*/
function deploy (options = {}) {
options.cmd = 'deploy';
return cli(options);
}
/**
The resource function will find and enrich all the resource fragments from the .nodeshift directory and create missing service and deployment configs.
An openshift.yaml and openshift.json will also be created in the ./tmp/nodeshift/resource directory
@param {object} [options] - Options object for the resource function
@param {string} [options.projectLocation] - the location(directory) of your projects package.json. Defaults to `process.cwd`
@param {boolean} [options.expose] - Set to true to create a default Route and expose the default service. defaults to false
@param {object} [options.namespace] -
@param {string} [options.namespace.displayName] - flag to specify the project namespace display name to build/deploy into. Overwrites any namespace settings in your OpenShift or Kubernetes configuration files
@param {string} [options.namespace.name] - flag to specify the project namespace name to build/deploy into. Overwrites any namespace settings in your OpenShift or Kubernetes configuration files
@param {string} [options.imageTag] - set the version to use for the ubi8/nodejs-10. Versions are ubi8/nodejs-10 tags: https://access.redhat.com/containers/?tab=tags#/registry.access.redhat.com/ubi8/nodejs-10
@param {string} [options.outputImageStream] - the name of the ImageStream to output to. Defaults to project name from package.json
@param {string} [options.outputImageTag] - The tag of the ImageStream to output to. Defaults to latest
@param {boolean} [options.quiet] - suppress 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
@param {boolean} [options.build.forcePull] - flag to make your BuildConfig always pull a new image from dockerhub or not. Defaults to false
@param {array} [options.definedProperties] - Array of objects with the format { key: value }. Used for template substitution
@returns {Promise<object>} - Returns a JSON Object
*/
function resource (options = {}) {
options.cmd = 'resource';
return cli(options);
}
/**
The apply-resource function does what resource does, but also pushes those resource fragments to your cluster
@param {object} [options] - Options object for the apply-resource function
@param {string} [options.projectLocation] - the location(directory) of your projects package.json. Defaults to `process.cwd`
@param {boolean} [options.expose] - Set to true to create a default Route and expose the default service. defaults to false
@param {object} [options.namespace] -
@param {string} [options.namespace.displayName] - flag to specify the project namespace display name to build/deploy into. Overwrites any namespace settings in your OpenShift or Kubernetes configuration files
@param {boolean} [options.namespace.create] - flag to create the namespace if it does not exist. Only applicable for the build and deploy command. Must be used with namespace.name
@param {string} [options.namespace.name] - flag to specify the project namespace name to build/deploy into. Overwrites any namespace settings in your OpenShift or Kubernetes configuration files
@param {string} [options.imageTag] - set the version to use for the ubi8/nodejs-10. Versions are ubi8/nodejs-10 tags: https://access.redhat.com/containers/?tab=tags#/registry.access.redhat.com/ubi8/nodejs-10
@param {string} [options.outputImageStream] - the name of the ImageStream to output to. Defaults to project name from package.json
@param {string} [options.outputImageTag] - The tag of the ImageStream to output to. Defaults to latest
@param {boolean} [options.quiet] - suppress 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
@param {Array} [options.deploy.env] - an array of objects to pass deployment config environment variables. [{name: NAME_PROP, value: VALUE}]
@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
@param {boolean} [options.build.forcePull] - flag to make your BuildConfig always pull a new image from dockerhub or not. Defaults to false
@param {array} [options.definedProperties] - Array of objects with the format { key: value }. Used for template substitution
@returns {Promise<object>} - Returns a JSON Object
*/
function applyResource (options = {}) {
options.cmd = 'apply-resource';
return cli(options);
}
/**
The undeploy function will use the openshift.yaml/openshift.json from the resource function and remove those values from your cluster.
@param {object} [options] - Options object for the undeploy function
@param {string} [options.projectLocation] - the location(directory) of your projects package.json. Defaults to `process.cwd`
@param {object} [options.namespace] -
@param {string} [options.namespace.displayName] - flag to specify the project namespace display name to build/deploy into. Overwrites any namespace settings in your OpenShift or Kubernetes configuration files
@param {boolean} [options.namespace.remove] - flag to remove the user created namespace. Only applicable for the undeploy command. Must be used with namespace.name
@param {string} [options.namespace.name] - flag to specify the project namespace name to build/deploy into. Overwrites any namespace settings in your OpenShift or Kubernetes configuration files
@param {string} [options.imageTag] - set the version to use for the ubi8/nodejs-10. Versions are ubi8/nodejs-10 tags: https://access.redhat.com/containers/?tab=tags#/registry.access.redhat.com/ubi8/nodejs-10
@param {string} [options.outputImageStream] - the name of the ImageStream to output to. Defaults to project name from package.json
@param {string} [options.outputImageTag] - The tag of the ImageStream to output to. Defaults to latest
@param {boolean} [options.quiet] - suppress 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] -
@param {number} [options.deploy.port] - flag to update the default ports on the resource files. Defaults to 8080
@param {Array} [options.deploy.env] - an array of objects to pass deployment config environment variables. [{name: NAME_PROP, value: VALUE}]
@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
@param {boolean} [options.build.forcePull] - flag to make your BuildConfig always pull a new image from dockerhub or not. Defaults to false
@param {array} [options.definedProperties] - Array of objects with the format { key: value }. Used for template substitution
@returns {Promise<object>} - Returns a JSON Object
*/
function undeploy (options = {}) {
options.cmd = 'undeploy';
return cli(options);
}
/**
The build function will archive your code, create a BuildConfig and Imagestream and then upload the archived code to your cluster
@param {object} [options] - Options object for the build function
@param {string} [options.projectLocation] - the location(directory) of your projects package.json. Defaults to `process.cwd`
@param {object} [options.namespace] -
@param {string} [options.namespace.displayName] - flag to specify the project namespace display name to build/deploy into. Overwrites any namespace settings in your OpenShift or Kubernetes configuration files
@param {boolean} [options.namespace.create] - flag to create the namespace if it does not exist. Only applicable for the build and deploy command. Must be used with namespace.name
@param {string} [options.namespace.name] - flag to specify the project namespace name to build/deploy into. Overwrites any namespace settings in your OpenShift or Kubernetes configuration files
@param {string} [options.imageTag] - set the version to use for the ubi8/nodejs-10. Versions are ubi8/nodejs-10 tags: https://access.redhat.com/containers/?tab=tags#/registry.access.redhat.com/ubi8/nodejs-10
@param {string} [options.outputImageStream] - the name of the ImageStream to output to. Defaults to project name from package.json
@param {string} [options.outputImageTag] - The tag of the ImageStream to output to. Defaults to latest
@param {boolean} [options.quiet] - suppress 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
@param {boolean} [options.build.forcePull] - flag to make your BuildConfig always pull a new image from dockerhub or not. Defaults to false
@param {Array} [options.build.env] - an array of objects to pass build config environment variables. [{name: NAME_PROP, value: VALUE}]
@param {array} [options.definedProperties] - Array of objects with the format { key: value }. Used for template substitution
@returns {Promise<object>} - Returns a JSON Object
*/
function build (options = {}) {
options.cmd = 'build';
return cli(options);
}
module.exports = {
deploy,
resource,
applyResource,
undeploy,
build
};