@@ -5,12 +5,13 @@ const installRoot = require('../root/install.cmd');
55const { detectProxy } = require ( '../../helpers/general' ) ;
66const { downloadProvider } = require ( '../hybrid/helper' ) ;
77const { Runner, components } = require ( '../../../../binary' ) ;
8+ const { install : installArgocd } = require ( './install-codefresh' ) ;
89
910const installArgoCmd = new Command ( {
1011 root : false ,
1112 parent : installRoot ,
1213 command : 'gitops <provider>' ,
13- description : 'Install gitops agent ' ,
14+ description : 'Install gitops' ,
1415 webDocs : {
1516 category : 'Gitops' ,
1617 title : 'Install' ,
@@ -20,14 +21,14 @@ const installArgoCmd = new Command({
2021 . env ( 'CF_ARG_' )
2122 . positional ( 'provider' , {
2223 describe : 'Gitops provider' ,
23- choices : [ 'argocd-agent' ] ,
24+ choices : [ 'codefresh' , ' argocd-agent'] ,
2425 required : true ,
2526 } )
2627 . option ( 'git-integration' , {
2728 describe : 'Name of git integration in Codefresh' ,
2829 } )
2930 . option ( 'codefresh-integration' , {
30- describe : 'Name of argocd integration in Codefresh' ,
31+ describe : 'Name of gitops integration in Codefresh' ,
3132 } )
3233 . option ( 'argo-host' , {
3334 describe : 'Host of argocd installation' ,
@@ -36,13 +37,13 @@ const installArgoCmd = new Command({
3637 describe : 'Token of argocd installation. Preferred auth method' ,
3738 } )
3839 . option ( 'argo-username' , {
39- describe : 'Username of argocd installation. Should be used with argo-password' ,
40+ describe : 'Username of existing argocd installation. Should be used with argo-password' ,
4041 } )
4142 . option ( 'argo-password' , {
42- describe : 'Username of argocd installation. Should be used with argo-username' ,
43+ describe : 'Password of existing argocd installation. Should be used with argo-username' ,
4344 } )
4445 . option ( 'update' , {
45- describe : 'Update argocd integration if exists' ,
46+ describe : 'Update gitops integration if exists' ,
4647 } )
4748 . option ( 'kube-config-path' , {
4849 describe : 'Path to kubeconfig file (default is $HOME/.kube/config)' ,
@@ -70,16 +71,41 @@ const installArgoCmd = new Command({
7071 } )
7172 . option ( 'https-proxy' , {
7273 describe : 'https proxy to be used in the runner' ,
74+ } )
75+ // argocd options
76+ . option ( 'install-manifest' , {
77+ describe : 'Url of argocd install manifest' ,
78+ default : 'https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml' ,
79+ } )
80+ . option ( 'set-argo-password' , {
81+ describe : 'Set password for admin user of new argocd installation' ,
7382 } ) ,
7483 handler : async ( argv ) => {
75- let {
76- // eslint-disable-next-line prefer-const
77- 'kube-config-path' : kubeConfigPath ,
78- // eslint-disable-next-line prefer-const
79- provider,
80- 'http-proxy' : httpProxy ,
81- 'https-proxy' : httpsProxy ,
82- } = argv ;
84+ let { provider, httpProxy, httpsProxy, argoHost, argoUsername, argoPassword } = argv ;
85+ const { kubeConfigPath, installManifest, kubeNamespace, setArgoPassword } = argv ;
86+
87+ if ( provider === 'codefresh' ) {
88+ if ( ! setArgoPassword ) {
89+ console . error ( '\nMissing required argument: set-argo-password' ) ;
90+ process . exit ( 1 ) ;
91+ }
92+
93+ if ( ! kubeNamespace ) {
94+ console . error ( '\nMissing required argument: kube-namespace' ) ;
95+ process . exit ( 1 ) ;
96+ }
97+
98+ const result = await installArgocd ( {
99+ installManifest,
100+ kubeNamespace,
101+ setArgoPassword,
102+ } ) ;
103+
104+ provider = 'argocd-agent' ;
105+ argoHost = result . host ;
106+ argoUsername = 'admin' ;
107+ argoPassword = setArgoPassword ;
108+ }
83109
84110 const binLocation = await downloadProvider ( { provider } ) ;
85111 const componentRunner = new Runner ( binLocation ) ;
@@ -93,10 +119,13 @@ const installArgoCmd = new Command({
93119 commands . push ( kubeConfigPath ) ;
94120 }
95121
96- const installOptions = _ . pick ( argv , [ 'git-integration' , 'codefresh-integration' , 'argo-host' , 'argo-token' , 'output' ,
97- 'argo-username' , 'argo-password' , 'update' , 'kube-context-name' , 'kube-namespace' , 'sync-mode' , 'sync-apps' ] ) ;
122+ const installOptions = _ . pick ( argv , [ 'git-integration' , 'codefresh-integration' , 'argo-token' , 'output' ,
123+ 'update' , 'kube-context-name' , 'kube-namespace' , 'sync-mode' , 'sync-apps' ] ) ;
124+ installOptions [ 'argo-host' ] = argoHost ;
125+ installOptions [ 'argo-username' ] = argoUsername ;
126+ installOptions [ 'argo-password' ] = argoPassword ;
98127
99- _ . forEach ( installOptions , ( value , key ) => {
128+ _ . forEach ( _ . pickBy ( installOptions , _ . identity ) , ( value , key ) => {
100129 if ( _ . isArray ( value ) ) {
101130 value . forEach ( ( item ) => {
102131 commands . push ( `--${ key } ` ) ;
0 commit comments