@@ -109,7 +109,7 @@ func InstallCmd(ctx context.Context, appSlug, appTitle string) *cobra.Command {
109
109
ki := kubernetesinstallation .New (nil )
110
110
111
111
short := fmt .Sprintf ("Install %s" , appTitle )
112
- if os . Getenv ( "ENABLE_V3" ) == "1" {
112
+ if isV3Enabled () {
113
113
short = fmt .Sprintf ("Install %s onto Linux or Kubernetes" , appTitle )
114
114
}
115
115
@@ -169,7 +169,7 @@ func InstallCmd(ctx context.Context, appSlug, appTitle string) *cobra.Command {
169
169
if err := addInstallAdminConsoleFlags (cmd , & flags ); err != nil {
170
170
panic (err )
171
171
}
172
- if err := addManagerExperienceFlags (cmd , & flags ); err != nil {
172
+ if err := addManagementConsoleFlags (cmd , & flags ); err != nil {
173
173
panic (err )
174
174
}
175
175
@@ -197,15 +197,15 @@ const (
197
197
)
198
198
199
199
func installCmdExample (appSlug string ) string {
200
- if os . Getenv ( "ENABLE_V3" ) != "1" {
200
+ if ! isV3Enabled () {
201
201
return ""
202
202
}
203
203
204
204
return fmt .Sprintf (installCmdExampleText , appSlug , appSlug )
205
205
}
206
206
207
207
func mustAddInstallFlags (cmd * cobra.Command , flags * InstallCmdFlags ) {
208
- enableV3 := os . Getenv ( "ENABLE_V3" ) == "1"
208
+ enableV3 := isV3Enabled ()
209
209
210
210
normalizeFuncs := []func (f * pflag.FlagSet , name string ) pflag.NormalizedName {}
211
211
@@ -215,7 +215,7 @@ func mustAddInstallFlags(cmd *cobra.Command, flags *InstallCmdFlags) {
215
215
normalizeFuncs = append (normalizeFuncs , fn )
216
216
}
217
217
218
- linuxFlagSet := newLinuxInstallFlags (flags )
218
+ linuxFlagSet := newLinuxInstallFlags (flags , enableV3 )
219
219
cmd .Flags ().AddFlagSet (linuxFlagSet )
220
220
if fn := linuxFlagSet .GetNormalizeFunc (); fn != nil {
221
221
normalizeFuncs = append (normalizeFuncs , fn )
@@ -241,8 +241,10 @@ func mustAddInstallFlags(cmd *cobra.Command, flags *InstallCmdFlags) {
241
241
func newCommonInstallFlags (flags * InstallCmdFlags , enableV3 bool ) * pflag.FlagSet {
242
242
flagSet := pflag .NewFlagSet ("common" , pflag .ContinueOnError )
243
243
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 {
246
248
mustMarkFlagHidden (flagSet , "target" )
247
249
}
248
250
@@ -259,12 +261,12 @@ func newCommonInstallFlags(flags *InstallCmdFlags, enableV3 bool) *pflag.FlagSet
259
261
return flagSet
260
262
}
261
263
262
- func newLinuxInstallFlags (flags * InstallCmdFlags ) * pflag.FlagSet {
264
+ func newLinuxInstallFlags (flags * InstallCmdFlags , enableV3 bool ) * pflag.FlagSet {
263
265
flagSet := pflag .NewFlagSet ("linux" , pflag .ContinueOnError )
264
266
265
267
// Use the app slug as default data directory only when ENABLE_V3 is set
266
268
defaultDataDir := ecv1beta1 .DefaultDataDir
267
- if os . Getenv ( "ENABLE_V3" ) == "1" {
269
+ if enableV3 {
268
270
defaultDataDir = filepath .Join ("/var/lib" , runtimeconfig .AppSlug ())
269
271
}
270
272
@@ -335,30 +337,21 @@ func addInstallAdminConsoleFlags(cmd *cobra.Command, flags *InstallCmdFlags) err
335
337
cmd .Flags ().StringVar (& flags .adminConsolePassword , "admin-console-password" , "" , "Password for the Admin Console" )
336
338
cmd .Flags ().IntVar (& flags .adminConsolePort , "admin-console-port" , ecv1beta1 .DefaultAdminConsolePort , "Port on which the Admin Console will be served" )
337
339
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" )
341
341
cmd .Flags ().StringVar (& flags .configValues , "config-values" , "" , "Path to the config values to use when installing" )
342
342
343
343
return nil
344
344
}
345
345
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 {
356
347
cmd .Flags ().IntVar (& flags .managerPort , "manager-port" , ecv1beta1 .DefaultManagerPort , "Port on which the Manager will be served" )
357
348
cmd .Flags ().StringVar (& flags .tlsCertFile , "tls-cert" , "" , "Path to the TLS certificate file" )
358
349
cmd .Flags ().StringVar (& flags .tlsKeyFile , "tls-key" , "" , "Path to the TLS key file" )
359
350
cmd .Flags ().StringVar (& flags .hostname , "hostname" , "" , "Hostname to use for TLS configuration" )
360
351
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 () {
362
355
if err := cmd .Flags ().MarkHidden ("manager-port" ); err != nil {
363
356
return err
364
357
}
@@ -377,8 +370,12 @@ func addManagerExperienceFlags(cmd *cobra.Command, flags *InstallCmdFlags) error
377
370
}
378
371
379
372
func preRunInstall (cmd * cobra.Command , flags * InstallCmdFlags , rc runtimeconfig.RuntimeConfig , ki kubernetesinstallation.Installation ) error {
373
+ if ! isV3Enabled () {
374
+ flags .target = "linux"
375
+ }
376
+
380
377
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")` )
382
379
}
383
380
384
381
if err := preRunInstallCommon (cmd , flags , rc , ki ); err != nil {
@@ -396,6 +393,8 @@ func preRunInstall(cmd *cobra.Command, flags *InstallCmdFlags, rc runtimeconfig.
396
393
}
397
394
398
395
func preRunInstallCommon (cmd * cobra.Command , flags * InstallCmdFlags , rc runtimeconfig.RuntimeConfig , ki kubernetesinstallation.Installation ) error {
396
+ flags .enableManagerExperience = isV3Enabled ()
397
+
399
398
// license file can be empty for restore
400
399
if flags .licenseFile != "" {
401
400
b , err := os .ReadFile (flags .licenseFile )
0 commit comments