@@ -109,7 +109,7 @@ func InstallCmd(ctx context.Context, appSlug, appTitle string) *cobra.Command {
109109 ki := kubernetesinstallation .New (nil )
110110
111111 short := fmt .Sprintf ("Install %s" , appTitle )
112- if os . Getenv ( "ENABLE_V3" ) == "1" {
112+ if isV3Enabled () {
113113 short = fmt .Sprintf ("Install %s onto Linux or Kubernetes" , appTitle )
114114 }
115115
@@ -169,7 +169,7 @@ func InstallCmd(ctx context.Context, appSlug, appTitle string) *cobra.Command {
169169 if err := addInstallAdminConsoleFlags (cmd , & flags ); err != nil {
170170 panic (err )
171171 }
172- if err := addManagerExperienceFlags (cmd , & flags ); err != nil {
172+ if err := addManagementConsoleFlags (cmd , & flags ); err != nil {
173173 panic (err )
174174 }
175175
@@ -197,15 +197,15 @@ const (
197197)
198198
199199func installCmdExample (appSlug string ) string {
200- if os . Getenv ( "ENABLE_V3" ) != "1" {
200+ if ! isV3Enabled () {
201201 return ""
202202 }
203203
204204 return fmt .Sprintf (installCmdExampleText , appSlug , appSlug )
205205}
206206
207207func mustAddInstallFlags (cmd * cobra.Command , flags * InstallCmdFlags ) {
208- enableV3 := os . Getenv ( "ENABLE_V3" ) == "1"
208+ enableV3 := isV3Enabled ()
209209
210210 normalizeFuncs := []func (f * pflag.FlagSet , name string ) pflag.NormalizedName {}
211211
@@ -215,7 +215,7 @@ func mustAddInstallFlags(cmd *cobra.Command, flags *InstallCmdFlags) {
215215 normalizeFuncs = append (normalizeFuncs , fn )
216216 }
217217
218- linuxFlagSet := newLinuxInstallFlags (flags )
218+ linuxFlagSet := newLinuxInstallFlags (flags , enableV3 )
219219 cmd .Flags ().AddFlagSet (linuxFlagSet )
220220 if fn := linuxFlagSet .GetNormalizeFunc (); fn != nil {
221221 normalizeFuncs = append (normalizeFuncs , fn )
@@ -241,8 +241,10 @@ func mustAddInstallFlags(cmd *cobra.Command, flags *InstallCmdFlags) {
241241func newCommonInstallFlags (flags * InstallCmdFlags , enableV3 bool ) * pflag.FlagSet {
242242 flagSet := pflag .NewFlagSet ("common" , pflag .ContinueOnError )
243243
244- flagSet .StringVar (& flags .target , "target" , "linux" , "The target platform to install to. Valid options are 'linux' or 'kubernetes'." )
245- if ! enableV3 {
244+ flagSet .StringVar (& flags .target , "target" , "" , "The target platform to install to. Valid options are 'linux' or 'kubernetes'." )
245+ if enableV3 {
246+ mustMarkFlagRequired (flagSet , "target" )
247+ } else {
246248 mustMarkFlagHidden (flagSet , "target" )
247249 }
248250
@@ -259,12 +261,12 @@ func newCommonInstallFlags(flags *InstallCmdFlags, enableV3 bool) *pflag.FlagSet
259261 return flagSet
260262}
261263
262- func newLinuxInstallFlags (flags * InstallCmdFlags ) * pflag.FlagSet {
264+ func newLinuxInstallFlags (flags * InstallCmdFlags , enableV3 bool ) * pflag.FlagSet {
263265 flagSet := pflag .NewFlagSet ("linux" , pflag .ContinueOnError )
264266
265267 // Use the app slug as default data directory only when ENABLE_V3 is set
266268 defaultDataDir := ecv1beta1 .DefaultDataDir
267- if os . Getenv ( "ENABLE_V3" ) == "1" {
269+ if enableV3 {
268270 defaultDataDir = filepath .Join ("/var/lib" , runtimeconfig .AppSlug ())
269271 }
270272
@@ -335,30 +337,21 @@ func addInstallAdminConsoleFlags(cmd *cobra.Command, flags *InstallCmdFlags) err
335337 cmd .Flags ().StringVar (& flags .adminConsolePassword , "admin-console-password" , "" , "Password for the Admin Console" )
336338 cmd .Flags ().IntVar (& flags .adminConsolePort , "admin-console-port" , ecv1beta1 .DefaultAdminConsolePort , "Port on which the Admin Console will be served" )
337339 cmd .Flags ().StringVarP (& flags .licenseFile , "license" , "l" , "" , "Path to the license file" )
338- if err := cmd .MarkFlagRequired ("license" ); err != nil {
339- panic (err )
340- }
340+ mustMarkFlagRequired (cmd .Flags (), "license" )
341341 cmd .Flags ().StringVar (& flags .configValues , "config-values" , "" , "Path to the config values to use when installing" )
342342
343343 return nil
344344}
345345
346- func addManagerExperienceFlags (cmd * cobra.Command , flags * InstallCmdFlags ) error {
347- // If the ENABLE_V3 environment variable is set, default to the new manager experience and do
348- // not hide the new flags.
349- enableV3 := os .Getenv ("ENABLE_V3" ) == "1"
350-
351- cmd .Flags ().BoolVar (& flags .enableManagerExperience , "manager-experience" , enableV3 , "Run the browser-based installation experience." )
352- if err := cmd .Flags ().MarkHidden ("manager-experience" ); err != nil {
353- return err
354- }
355-
346+ func addManagementConsoleFlags (cmd * cobra.Command , flags * InstallCmdFlags ) error {
356347 cmd .Flags ().IntVar (& flags .managerPort , "manager-port" , ecv1beta1 .DefaultManagerPort , "Port on which the Manager will be served" )
357348 cmd .Flags ().StringVar (& flags .tlsCertFile , "tls-cert" , "" , "Path to the TLS certificate file" )
358349 cmd .Flags ().StringVar (& flags .tlsKeyFile , "tls-key" , "" , "Path to the TLS key file" )
359350 cmd .Flags ().StringVar (& flags .hostname , "hostname" , "" , "Hostname to use for TLS configuration" )
360351
361- if ! enableV3 {
352+ // If the ENABLE_V3 environment variable is set, default to the new manager experience and do
353+ // not hide the new flags.
354+ if ! isV3Enabled () {
362355 if err := cmd .Flags ().MarkHidden ("manager-port" ); err != nil {
363356 return err
364357 }
@@ -377,8 +370,12 @@ func addManagerExperienceFlags(cmd *cobra.Command, flags *InstallCmdFlags) error
377370}
378371
379372func preRunInstall (cmd * cobra.Command , flags * InstallCmdFlags , rc runtimeconfig.RuntimeConfig , ki kubernetesinstallation.Installation ) error {
373+ if ! isV3Enabled () {
374+ flags .target = "linux"
375+ }
376+
380377 if ! slices .Contains ([]string {"linux" , "kubernetes" }, flags .target ) {
381- return fmt .Errorf (`invalid target (must be one of: "linux", "kubernetes")` )
378+ return fmt .Errorf (`invalid -- target (must be one of: "linux", "kubernetes")` )
382379 }
383380
384381 if err := preRunInstallCommon (cmd , flags , rc , ki ); err != nil {
@@ -396,6 +393,8 @@ func preRunInstall(cmd *cobra.Command, flags *InstallCmdFlags, rc runtimeconfig.
396393}
397394
398395func preRunInstallCommon (cmd * cobra.Command , flags * InstallCmdFlags , rc runtimeconfig.RuntimeConfig , ki kubernetesinstallation.Installation ) error {
396+ flags .enableManagerExperience = isV3Enabled ()
397+
399398 // license file can be empty for restore
400399 if flags .licenseFile != "" {
401400 b , err := os .ReadFile (flags .licenseFile )
0 commit comments