@@ -15,6 +15,8 @@ const sdk = require('../../../../logic/sdk');
15
15
const installationProgress = require ( './installation-process' ) ;
16
16
const { to } = require ( './../../../../logic/cli-config/errors/awaitTo' ) ;
17
17
const { createErrorHandler } = require ( './helper' ) ;
18
+ const YAML = require ( 'yaml' ) ;
19
+ const fs = require ( 'fs' ) ;
18
20
const {
19
21
createTestPipeline,
20
22
executeTestPipeline,
@@ -87,7 +89,6 @@ const initCmd = new Command({
87
89
} )
88
90
. option ( 'url' , {
89
91
describe : 'Codefresh system custom url' ,
90
- default : DEFAULTS . URL ,
91
92
} )
92
93
. option ( 'kube-context-name' , {
93
94
describe : 'Name of the Kubernetes context on which runner should be installed [$CF_ARG_KUBE_CONTEXT_NAME]' ,
@@ -136,6 +137,9 @@ const initCmd = new Command({
136
137
. option ( 'kube-config-path' , {
137
138
describe : 'Path to kubeconfig file (default is $HOME/.kube/config)' ,
138
139
} )
140
+ . option ( 'values' , {
141
+ describe : 'specify values in a YAML file' ,
142
+ } )
139
143
. option ( 'set-value' , {
140
144
describe : 'Set values for templates, example: --set-value LocalVolumesDir=/mnt/disks/ssd0/codefresh-volumes' ,
141
145
} )
@@ -177,23 +181,23 @@ const initCmd = new Command({
177
181
_argv = Object . assign ( oldInstallationPlan . getContext ( 'argv' ) , _argv ) ; // restore previous installation environment
178
182
}
179
183
180
- const {
184
+ let {
181
185
'kube-node-selector' : kubeNodeSelector ,
182
186
'build-node-selector' : buildNodeSelector ,
183
187
tolerations,
184
188
'kube-config-path' : kubeConfigPath ,
185
189
'storage-class-name' : storageClassName ,
186
- yes : noQuestions ,
190
+ ' yes' : noQuestions ,
187
191
verbose,
188
192
name, url,
189
193
token,
194
+ 'values' : valuesFile ,
190
195
'set-value' : setValue ,
191
196
'set-file' : setFile ,
192
197
'skip-cluster-test' : skipClusterTest ,
193
198
'install-monitor' : installMonitor ,
194
199
'docker-registry' : dockerRegistry ,
195
- } = _argv ;
196
- let {
200
+
197
201
'kube-context-name' : kubeContextName ,
198
202
'kube-namespace' : kubeNamespace ,
199
203
'set-default-runtime' : shouldMakeDefaultRe ,
@@ -203,6 +207,35 @@ const initCmd = new Command({
203
207
'https-proxy' : httpsProxy ,
204
208
} = _argv ;
205
209
210
+ let valuesObj ;
211
+ if ( valuesFile ) {
212
+ let valuesFileStr = fs . readFileSync ( valuesFile , 'utf8' ) ;
213
+ valuesObj = YAML . parse ( valuesFileStr ) ;
214
+ noQuestions = true ;
215
+
216
+ if ( ! kubeNamespace && valuesObj . Namespace ) {
217
+ kubeNamespace = valuesObj . Namespace ;
218
+ }
219
+ if ( ! kubeContextName && valuesObj . Context ) {
220
+ kubeContextName = valuesObj . Context ;
221
+ }
222
+ if ( ! url && valuesObj . CodefreshHost ) {
223
+ url = valuesObj . CodefreshHost ;
224
+ }
225
+ if ( ! token && valuesObj . Token ) {
226
+ token = valuesObj . Token ;
227
+ }
228
+ if ( ! name && valuesObj . AgentId ) {
229
+ name = valuesObj . AgentId ;
230
+ }
231
+ if ( typeof _ . get ( valuesObj , "Monitor.Enabled" ) !== 'undefined' ) {
232
+ installMonitor = _ . get ( valuesObj , "Monitor.Enabled" ) ;
233
+ }
234
+ }
235
+ if ( ! url ) {
236
+ url = DEFAULTS . URL ;
237
+ }
238
+
206
239
if ( _ . get ( sdk , 'config.context.isNoAuth' ) && ! token ) {
207
240
console . log ( 'Not authenticated as a Codefresh account: ' ) ;
208
241
console . log ( 'In order to install a Codefresh Runner you need to provide ' +
@@ -363,14 +396,15 @@ const initCmd = new Command({
363
396
installationPlan . addContext ( 'argv' , _argv ) ;
364
397
365
398
// run cluster acceptance tests
366
- installationPlan . addStep ( {
367
- name : 'run cluster acceptance tests' ,
368
- func : runClusterAcceptanceTests ,
369
- arg : { kubeNamespace, kubeConfigPath } ,
370
- installationEvent : installationProgress . events . ACCEPTANCE_TESTS_RAN ,
371
- condition : ! skipClusterTest ,
372
- } ) ;
373
-
399
+ if ( ! _ . get ( valuesObj , "SkipClusterTest" ) ) {
400
+ installationPlan . addStep ( {
401
+ name : 'run cluster acceptance tests' ,
402
+ func : runClusterAcceptanceTests ,
403
+ arg : { kubeNamespace, kubeConfigPath } ,
404
+ installationEvent : installationProgress . events . ACCEPTANCE_TESTS_RAN ,
405
+ condition : ! skipClusterTest ,
406
+ } ) ;
407
+ }
374
408
// generate new agent name
375
409
installationPlan . addContext ( 'agentName' , name ? name . trim ( ) : name ) ;
376
410
installationPlan . addStep ( {
@@ -414,6 +448,9 @@ const initCmd = new Command({
414
448
verbose,
415
449
agentId : installationPlan . getContext ( 'agentName' ) ,
416
450
envVars,
451
+ valuesFile, // --values
452
+ setValue, // --set-value
453
+ setFile, // --set-file
417
454
} ) ;
418
455
} ,
419
456
installationEvent : installationProgress . events . AGENT_INSTALLED ,
@@ -538,6 +575,7 @@ const initCmd = new Command({
538
575
verbose,
539
576
kubeNodeSelector,
540
577
dockerRegistry,
578
+ valuesFile,
541
579
setValue,
542
580
setFile,
543
581
storageClassName,
0 commit comments