@@ -109,6 +109,7 @@ type (
109109 IpsAllowList string
110110 SkipIngress bool
111111 BypassIngressClassCheck bool
112+ DownloadRuntimeDef * runtime.Runtime
112113
113114 versionStr string
114115 kubeContext string
@@ -195,9 +196,11 @@ func NewRuntimeInstallCommand() *cobra.Command {
195196
196197 createAnalyticsReporter (ctx , reporter .InstallFlow , installationOpts .DisableTelemetry )
197198
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+ }
201204 }
202205
203206 err := runtimeInstallCommandPreRunHandler (cmd , installationOpts )
@@ -262,7 +265,7 @@ func NewRuntimeInstallCommand() *cobra.Command {
262265 cmd .Flags ().StringToStringVar (& installationOpts .InternalIngressAnnotation , "internal-ingress-annotation" , nil , "Add annotations to the internal ingress" )
263266 cmd .Flags ().StringToStringVar (& installationOpts .ExternalIngressAnnotation , "external-ingress-annotation" , nil , "Add annotations to the external ingress" )
264267 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" )
266269 cmd .Flags ().StringVar (& installationOpts .TunnelRegisterHost , "tunnel-register-host" , "register-tunnels.cf-cd.com" , "The host name for registering a new tunnel" )
267270 cmd .Flags ().StringVar (& installationOpts .TunnelDomain , "tunnel-domain" , "tunnels.cf-cd.com" , "The base domain for the tunnels" )
268271 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
301304
302305 err = validateVersionIfExists (opts .versionStr )
303306 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+
304333 if opts .RuntimeName == "" {
305334 if ! store .Get ().Silent {
306335 opts .RuntimeName , err = getRuntimeNameFromUserInput ()
@@ -325,29 +354,8 @@ func runtimeInstallCommandPreRunHandler(cmd *cobra.Command, opts *RuntimeInstall
325354 return err
326355 }
327356
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
351359 }
352360
353361 if err = ensureGitData (cmd , opts ); err != nil {
@@ -384,12 +392,9 @@ func runtimeInstallCommandPreRunHandler(cmd *cobra.Command, opts *RuntimeInstall
384392 log .G (ctx ).Infof ("using repo '%s' as shared config repo for this account" , sharedConfigRepo )
385393 }
386394
387- if opts .runtimeDef == "" {
388- opts .runtimeDef = runtime .GetRuntimeDefURL (opts .versionStr )
389- }
390-
391395 opts .Insecure = true // installs argo-cd in insecure mode, we need this so that the eventsource can talk to the argocd-server with http
392396 opts .CommonConfig = & runtime.CommonConfig {CodefreshBaseURL : cfConfig .GetCurrentContext ().URL }
397+ opts .DownloadRuntimeDef = rt
393398
394399 return nil
395400}
@@ -1140,23 +1145,7 @@ func preInstallationChecks(ctx context.Context, opts *RuntimeInstallOptions) (*r
11401145 return nil , err
11411146 }
11421147
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
11601149
11611150 handleCliStep (reporter .InstallStepRunPreCheckEnsureCliVersion , "Checking CLI version" , err , true , false )
11621151 if err != nil {
0 commit comments