@@ -15,6 +15,8 @@ const sdk = require('../../../../logic/sdk');
1515const installationProgress = require ( './installation-process' ) ;
1616const { to } = require ( './../../../../logic/cli-config/errors/awaitTo' ) ;
1717const { createErrorHandler } = require ( './helper' ) ;
18+ const YAML = require ( 'yaml' ) ;
19+ const fs = require ( 'fs' ) ;
1820const {
1921 createTestPipeline,
2022 executeTestPipeline,
@@ -87,7 +89,6 @@ const initCmd = new Command({
8789 } )
8890 . option ( 'url' , {
8991 describe : 'Codefresh system custom url' ,
90- default : DEFAULTS . URL ,
9192 } )
9293 . option ( 'kube-context-name' , {
9394 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({
136137 . option ( 'kube-config-path' , {
137138 describe : 'Path to kubeconfig file (default is $HOME/.kube/config)' ,
138139 } )
140+ . option ( 'values' , {
141+ describe : 'specify values in a YAML file' ,
142+ } )
139143 . option ( 'set-value' , {
140144 describe : 'Set values for templates, example: --set-value LocalVolumesDir=/mnt/disks/ssd0/codefresh-volumes' ,
141145 } )
@@ -177,23 +181,23 @@ const initCmd = new Command({
177181 _argv = Object . assign ( oldInstallationPlan . getContext ( 'argv' ) , _argv ) ; // restore previous installation environment
178182 }
179183
180- const {
184+ let {
181185 'kube-node-selector' : kubeNodeSelector ,
182186 'build-node-selector' : buildNodeSelector ,
183187 tolerations,
184188 'kube-config-path' : kubeConfigPath ,
185189 'storage-class-name' : storageClassName ,
186- yes : noQuestions ,
190+ ' yes' : noQuestions ,
187191 verbose,
188192 name, url,
189193 token,
194+ 'values' : valuesFile ,
190195 'set-value' : setValue ,
191196 'set-file' : setFile ,
192197 'skip-cluster-test' : skipClusterTest ,
193198 'install-monitor' : installMonitor ,
194199 'docker-registry' : dockerRegistry ,
195- } = _argv ;
196- let {
200+
197201 'kube-context-name' : kubeContextName ,
198202 'kube-namespace' : kubeNamespace ,
199203 'set-default-runtime' : shouldMakeDefaultRe ,
@@ -203,6 +207,35 @@ const initCmd = new Command({
203207 'https-proxy' : httpsProxy ,
204208 } = _argv ;
205209
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+
206239 if ( _ . get ( sdk , 'config.context.isNoAuth' ) && ! token ) {
207240 console . log ( 'Not authenticated as a Codefresh account: ' ) ;
208241 console . log ( 'In order to install a Codefresh Runner you need to provide ' +
@@ -363,14 +396,15 @@ const initCmd = new Command({
363396 installationPlan . addContext ( 'argv' , _argv ) ;
364397
365398 // 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+ }
374408 // generate new agent name
375409 installationPlan . addContext ( 'agentName' , name ? name . trim ( ) : name ) ;
376410 installationPlan . addStep ( {
@@ -414,6 +448,9 @@ const initCmd = new Command({
414448 verbose,
415449 agentId : installationPlan . getContext ( 'agentName' ) ,
416450 envVars,
451+ valuesFile, // --values
452+ setValue, // --set-value
453+ setFile, // --set-file
417454 } ) ;
418455 } ,
419456 installationEvent : installationProgress . events . AGENT_INSTALLED ,
@@ -538,6 +575,7 @@ const initCmd = new Command({
538575 verbose,
539576 kubeNodeSelector,
540577 dockerRegistry,
578+ valuesFile,
541579 setValue,
542580 setFile,
543581 storageClassName,
0 commit comments