@@ -109,6 +109,7 @@ type (
109
109
IpsAllowList string
110
110
SkipIngress bool
111
111
BypassIngressClassCheck bool
112
+ DownloadRuntimeDef * runtime.Runtime
112
113
113
114
versionStr string
114
115
kubeContext string
@@ -195,9 +196,11 @@ func NewRuntimeInstallCommand() *cobra.Command {
195
196
196
197
createAnalyticsReporter (ctx , reporter .InstallFlow , installationOpts .DisableTelemetry )
197
198
198
- installationOpts .AccessMode = platmodel .AccessMode (strings .ToUpper (accessMode ))
199
- if ! installationOpts .AccessMode .IsValid () {
200
- return fmt .Errorf ("invalid access-mode %s, must be one of: ingress|tunnel" , accessMode )
199
+ if (accessMode != "" ) {
200
+ installationOpts .AccessMode = platmodel .AccessMode (strings .ToUpper (accessMode ))
201
+ if ! installationOpts .AccessMode .IsValid () {
202
+ return fmt .Errorf ("invalid access-mode %s, must be one of: ingress|tunnel" , accessMode )
203
+ }
201
204
}
202
205
203
206
err := runtimeInstallCommandPreRunHandler (cmd , installationOpts )
@@ -262,7 +265,7 @@ func NewRuntimeInstallCommand() *cobra.Command {
262
265
cmd .Flags ().StringToStringVar (& installationOpts .InternalIngressAnnotation , "internal-ingress-annotation" , nil , "Add annotations to the internal ingress" )
263
266
cmd .Flags ().StringToStringVar (& installationOpts .ExternalIngressAnnotation , "external-ingress-annotation" , nil , "Add annotations to the external ingress" )
264
267
cmd .Flags ().StringVar (& installationOpts .runtimeDef , "runtime-def" , "" , "Install runtime from a specific manifest" )
265
- cmd .Flags ().StringVar (& accessMode , "access-mode" , string ( platmodel . AccessModeIngress ) , "The access mode to the cluster, one of: ingress|tunnel" )
268
+ cmd .Flags ().StringVar (& accessMode , "access-mode" , "" , "The access mode to the cluster, one of: ingress|tunnel" )
266
269
cmd .Flags ().StringVar (& installationOpts .TunnelRegisterHost , "tunnel-register-host" , "register-tunnels.cf-cd.com" , "The host name for registering a new tunnel" )
267
270
cmd .Flags ().StringVar (& installationOpts .TunnelDomain , "tunnel-domain" , "tunnels.cf-cd.com" , "The base domain for the tunnels" )
268
271
cmd .Flags ().StringVar (& installationOpts .IpsAllowList , "ips-allow-list" , "" , "lists the rules to configure which IP addresses (IPv4/IPv6) and subnet masks can access your client (e.g \" 192.168.0.0/16, FE80:CD00:0000:0CDE:1257::/64\" )" )
@@ -301,6 +304,32 @@ func runtimeInstallCommandPreRunHandler(cmd *cobra.Command, opts *RuntimeInstall
301
304
302
305
err = validateVersionIfExists (opts .versionStr )
303
306
handleCliStep (reporter .InstallStepPreCheckValidateRuntimeVersion , "Validating runtime version" , err , true , false )
307
+
308
+ if opts .runtimeDef == "" {
309
+ opts .runtimeDef = runtime .GetRuntimeDefURL (opts .versionStr )
310
+ }
311
+
312
+ runtimeDef := getRuntimeDef (opts .runtimeDef , opts .versionStr )
313
+ rt , err := runtime .Download (runtimeDef , opts .RuntimeName , opts .featuresToInstall )
314
+ handleCliStep (reporter .InstallStepRunPreCheckDownloadRuntimeDefinition , "Downloading runtime definition" , err , true , true )
315
+ if err != nil {
316
+ return fmt .Errorf ("failed to download runtime definition: %w" , err )
317
+ }
318
+
319
+ if rt .Spec .DefVersion != nil {
320
+ if rt .Spec .DefVersion .GreaterThan (store .Get ().MaxDefVersion ) {
321
+ err = fmt .Errorf ("your cli version is out of date. please upgrade to the latest version before installing" )
322
+ } else if rt .Spec .DefVersion .LessThan (store .Get ().MaxDefVersion ) {
323
+ val := store .Get ().DefVersionToLastCLIVersion [rt .Spec .DefVersion .String ()]
324
+ err = fmt .Errorf ("to install this version, please downgrade your cli to version %s" , val )
325
+ }
326
+ } else {
327
+ err = runtime .CheckRuntimeVersionCompatible (rt .Spec .RequiredCLIVersion )
328
+ }
329
+ if err != nil {
330
+ return err
331
+ }
332
+
304
333
if opts .RuntimeName == "" {
305
334
if ! store .Get ().Silent {
306
335
opts .RuntimeName , err = getRuntimeNameFromUserInput ()
@@ -325,29 +354,8 @@ func runtimeInstallCommandPreRunHandler(cmd *cobra.Command, opts *RuntimeInstall
325
354
return err
326
355
}
327
356
328
- if opts .AccessMode == platmodel .AccessModeTunnel {
329
- handleCliStep (reporter .InstallStepPreCheckEnsureIngressClass , "-skipped (ingressless)-" , err , true , false )
330
- handleCliStep (reporter .InstallStepPreCheckEnsureIngressHost , "-skipped (ingressless)-" , err , true , false )
331
- opts .featuresToInstall = append (opts .featuresToInstall , runtime .InstallFeatureIngressless )
332
- accountId , err := cfConfig .GetCurrentContext ().GetAccountId (ctx )
333
- if err != nil {
334
- return fmt .Errorf ("failed creating ingressHost for tunnel: %w" , err )
335
- }
336
-
337
- opts .TunnelSubdomain = fmt .Sprintf ("%s-%s" , accountId , opts .RuntimeName )
338
- opts .IngressHost = fmt .Sprintf ("https://%s.%s" , opts .TunnelSubdomain , opts .TunnelDomain )
339
- } else {
340
- err = ensureRoutingControllerSupported (ctx , opts )
341
- handleCliStep (reporter .InstallStepPreCheckEnsureIngressClass , "Getting ingress class" , err , true , false )
342
- if err != nil {
343
- return err
344
- }
345
-
346
- err = getIngressHost (ctx , opts )
347
- handleCliStep (reporter .InstallStepPreCheckEnsureIngressHost , "Getting ingressHost" , err , true , false )
348
- if err != nil {
349
- return err
350
- }
357
+ if err = ensureAccessMode (ctx , opts ); err != nil {
358
+ return err
351
359
}
352
360
353
361
if err = ensureGitData (cmd , opts ); err != nil {
@@ -384,12 +392,9 @@ func runtimeInstallCommandPreRunHandler(cmd *cobra.Command, opts *RuntimeInstall
384
392
log .G (ctx ).Infof ("using repo '%s' as shared config repo for this account" , sharedConfigRepo )
385
393
}
386
394
387
- if opts .runtimeDef == "" {
388
- opts .runtimeDef = runtime .GetRuntimeDefURL (opts .versionStr )
389
- }
390
-
391
395
opts .Insecure = true // installs argo-cd in insecure mode, we need this so that the eventsource can talk to the argocd-server with http
392
396
opts .CommonConfig = & runtime.CommonConfig {CodefreshBaseURL : cfConfig .GetCurrentContext ().URL }
397
+ opts .DownloadRuntimeDef = rt
393
398
394
399
return nil
395
400
}
@@ -1140,23 +1145,7 @@ func preInstallationChecks(ctx context.Context, opts *RuntimeInstallOptions) (*r
1140
1145
return nil , err
1141
1146
}
1142
1147
1143
- runtimeDef := getRuntimeDef (opts .runtimeDef , opts .versionStr )
1144
- rt , err := runtime .Download (runtimeDef , opts .RuntimeName , opts .featuresToInstall )
1145
- handleCliStep (reporter .InstallStepRunPreCheckDownloadRuntimeDefinition , "Downloading runtime definition" , err , true , true )
1146
- if err != nil {
1147
- return nil , fmt .Errorf ("failed to download runtime definition: %w" , err )
1148
- }
1149
-
1150
- if rt .Spec .DefVersion != nil {
1151
- if rt .Spec .DefVersion .GreaterThan (store .Get ().MaxDefVersion ) {
1152
- err = fmt .Errorf ("your cli version is out of date. please upgrade to the latest version before installing" )
1153
- } else if rt .Spec .DefVersion .LessThan (store .Get ().MaxDefVersion ) {
1154
- val := store .Get ().DefVersionToLastCLIVersion [rt .Spec .DefVersion .String ()]
1155
- err = fmt .Errorf ("to install this version, please downgrade your cli to version %s" , val )
1156
- }
1157
- } else {
1158
- err = runtime .CheckRuntimeVersionCompatible (rt .Spec .RequiredCLIVersion )
1159
- }
1148
+ rt := opts .DownloadRuntimeDef
1160
1149
1161
1150
handleCliStep (reporter .InstallStepRunPreCheckEnsureCliVersion , "Checking CLI version" , err , true , false )
1162
1151
if err != nil {
0 commit comments