@@ -12,7 +12,12 @@ const {
12
12
const { getKubeContext } = require ( '../../helpers/kubernetes' ) ;
13
13
const sdk = require ( '../../../../logic/sdk' ) ;
14
14
const { to } = require ( '../../../../logic/cli-config/errors/awaitTo' ) ;
15
- const { mergeWithValues, selectRuntime } = require ( './helper' ) ;
15
+ const {
16
+ mergeWithValues,
17
+ selectRuntime,
18
+ selectNamespace,
19
+ selectHost,
20
+ } = require ( './helper' ) ;
16
21
17
22
const openIssueMessage = 'If you had any issues with this installation process please report them at:'
18
23
+ ` ${ colors . blue ( 'https://github.com/codefresh-io/cli/issues/new' ) } ` ;
@@ -38,7 +43,7 @@ const installAppProxyHandler = new Command({
38
43
root : false ,
39
44
parent : installRoot ,
40
45
command : 'app-proxy' ,
41
- description : 'Install the App-Proxy component on your Kubernetes cluster' ,
46
+ description : 'Installs the App-Proxy component on your Kubernetes cluster' ,
42
47
webDocs : {
43
48
category : 'App-Proxy' ,
44
49
title : 'Install' ,
@@ -54,7 +59,7 @@ const installAppProxyHandler = new Command({
54
59
} )
55
60
. option ( 'kube-context-name' , {
56
61
describe : 'Name of the kubernetes context on which the app-proxy should be installed'
57
- + ` (default: ${ getKubeContext ( ) } ) [$CF_ARG_KUBE_CONTEXT_NAME]` ,
62
+ + ' (default: current context) [$CF_ARG_KUBE_CONTEXT_NAME]' ,
58
63
} )
59
64
. option ( 'kube-namespace' , {
60
65
describe : 'Name of the namespace on which app-proxy should be installed (default:'
@@ -93,17 +98,17 @@ const installAppProxyHandler = new Command({
93
98
const argv = mergeWithValues ( _argv ) ;
94
99
const {
95
100
'kube-config-path' : kubeConfigPath ,
96
- 'kube-context-name' : kubeContextName ,
97
- 'kube-namespace' : kubeNamespace ,
98
101
'docker-registry' : dockerRegistry ,
99
102
verbose,
100
103
values,
101
104
'set-value' : setValues ,
102
- host,
103
105
'ingress-class' : ingressClass ,
104
106
noExit,
105
107
} = argv ;
106
108
let {
109
+ host,
110
+ 'kube-namespace' : kubeNamespace ,
111
+ 'kube-context-name' : kubeContextName ,
107
112
'runtime-environment' : runtimeEnvironment ,
108
113
} = argv ;
109
114
@@ -122,6 +127,19 @@ const installAppProxyHandler = new Command({
122
127
'Cannot install app-proxy without a Codefresh runtime-environment' ,
123
128
) ;
124
129
}
130
+
131
+ if ( ! kubeContextName ) {
132
+ kubeContextName = getKubeContext ( kubeConfigPath ) ;
133
+ }
134
+
135
+ if ( ! kubeNamespace ) {
136
+ kubeNamespace = await selectNamespace ( ) ;
137
+ }
138
+
139
+ if ( ! host ) {
140
+ host = await selectHost ( ) ;
141
+ }
142
+
125
143
if ( ! runtimeEnvironment || ! runtimeNames . find ( re => re === runtimeEnvironment ) ) {
126
144
if ( runtimeEnvironment ) {
127
145
console . log ( colors . bold ( `Runtime-environment "${ colors . cyan ( runtimeEnvironment ) } " `
@@ -138,7 +156,7 @@ const installAppProxyHandler = new Command({
138
156
} ) ;
139
157
140
158
console . log ( 'installing app-proxy...' ) ;
141
- const appProxyUrl = await installAppProxy ( {
159
+ const [ installationErr ] = await to ( installAppProxy ( {
142
160
apiHost : sdk . config . context . url ,
143
161
appProxyHost : host ,
144
162
appProxyIngressClass : ingressClass ,
@@ -149,11 +167,14 @@ const installAppProxyHandler = new Command({
149
167
valuesFile : values ,
150
168
setValue : setValues ,
151
169
verbose,
152
- } ) ;
170
+ } ) ) ;
171
+ await handleError ( installationErr , 'Failed to install app-proxy' ) ;
153
172
154
173
const [ getREErr , re ] = await to ( sdk . runtimeEnvs . get ( { name : runtimeEnvironment } ) ) ;
155
174
await handleError ( getREErr , 'Failed to get runtime environment' ) ;
156
175
176
+ const appProxyUrl = `https://${ host } ${ argv . pathPrefix } ` ;
177
+
157
178
const body = {
158
179
appProxy : {
159
180
externalIP : appProxyUrl ,
0 commit comments