@@ -5,12 +5,13 @@ const installRoot = require('../root/install.cmd');
5
5
const { detectProxy } = require ( '../../helpers/general' ) ;
6
6
const { downloadProvider } = require ( '../hybrid/helper' ) ;
7
7
const { Runner, components } = require ( '../../../../binary' ) ;
8
+ const { install : installArgocd } = require ( './install-codefresh' ) ;
8
9
9
10
const installArgoCmd = new Command ( {
10
11
root : false ,
11
12
parent : installRoot ,
12
13
command : 'gitops <provider>' ,
13
- description : 'Install gitops agent ' ,
14
+ description : 'Install gitops' ,
14
15
webDocs : {
15
16
category : 'Gitops' ,
16
17
title : 'Install' ,
@@ -20,14 +21,14 @@ const installArgoCmd = new Command({
20
21
. env ( 'CF_ARG_' )
21
22
. positional ( 'provider' , {
22
23
describe : 'Gitops provider' ,
23
- choices : [ 'argocd-agent' ] ,
24
+ choices : [ 'codefresh' , ' argocd-agent'] ,
24
25
required : true ,
25
26
} )
26
27
. option ( 'git-integration' , {
27
28
describe : 'Name of git integration in Codefresh' ,
28
29
} )
29
30
. option ( 'codefresh-integration' , {
30
- describe : 'Name of argocd integration in Codefresh' ,
31
+ describe : 'Name of gitops integration in Codefresh' ,
31
32
} )
32
33
. option ( 'argo-host' , {
33
34
describe : 'Host of argocd installation' ,
@@ -36,13 +37,13 @@ const installArgoCmd = new Command({
36
37
describe : 'Token of argocd installation. Preferred auth method' ,
37
38
} )
38
39
. 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' ,
40
41
} )
41
42
. 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' ,
43
44
} )
44
45
. option ( 'update' , {
45
- describe : 'Update argocd integration if exists' ,
46
+ describe : 'Update gitops integration if exists' ,
46
47
} )
47
48
. option ( 'kube-config-path' , {
48
49
describe : 'Path to kubeconfig file (default is $HOME/.kube/config)' ,
@@ -70,16 +71,41 @@ const installArgoCmd = new Command({
70
71
} )
71
72
. option ( 'https-proxy' , {
72
73
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' ,
73
82
} ) ,
74
83
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
+ }
83
109
84
110
const binLocation = await downloadProvider ( { provider } ) ;
85
111
const componentRunner = new Runner ( binLocation ) ;
@@ -93,10 +119,13 @@ const installArgoCmd = new Command({
93
119
commands . push ( kubeConfigPath ) ;
94
120
}
95
121
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 ;
98
127
99
- _ . forEach ( installOptions , ( value , key ) => {
128
+ _ . forEach ( _ . pickBy ( installOptions , _ . identity ) , ( value , key ) => {
100
129
if ( _ . isArray ( value ) ) {
101
130
value . forEach ( ( item ) => {
102
131
commands . push ( `--${ key } ` ) ;
0 commit comments