diff --git a/cli/pkg/kctrl/cmd/app/delete.go b/cli/pkg/kctrl/cmd/app/delete.go index 04f48cac9..5e3dee82c 100644 --- a/cli/pkg/kctrl/cmd/app/delete.go +++ b/cli/pkg/kctrl/cmd/app/delete.go @@ -57,7 +57,6 @@ func NewDeleteCmd(o *DeleteOptions, flagsFactory cmdcore.FlagsFactory) *cobra.Co AllowDisableWait: true, DefaultInterval: 1 * time.Second, DefaultTimeout: 5 * time.Minute, - WaitByDefault: true, }) return cmd diff --git a/cli/pkg/kctrl/cmd/app/kick.go b/cli/pkg/kctrl/cmd/app/kick.go index a223fad28..93b83424c 100644 --- a/cli/pkg/kctrl/cmd/app/kick.go +++ b/cli/pkg/kctrl/cmd/app/kick.go @@ -50,7 +50,6 @@ func NewKickCmd(o *KickOptions, flagsFactory cmdcore.FlagsFactory) *cobra.Comman AllowDisableWait: true, DefaultInterval: 1 * time.Second, DefaultTimeout: 5 * time.Minute, - WaitByDefault: true, }) return cmd diff --git a/cli/pkg/kctrl/cmd/core/config_factory.go b/cli/pkg/kctrl/cmd/core/config_factory.go index bb643041b..5e98d0e4b 100644 --- a/cli/pkg/kctrl/cmd/core/config_factory.go +++ b/cli/pkg/kctrl/cmd/core/config_factory.go @@ -29,9 +29,6 @@ type ConfigFactoryImpl struct { qps float32 burst int - - defaultKubeconfigOverridePath string - defaultKubeconfigOverrideContext string } var _ ConfigFactory = &ConfigFactoryImpl{} @@ -52,11 +49,6 @@ func (f *ConfigFactoryImpl) ConfigureYAMLResolver(resolverFunc func() (string, e f.yamlResolverFunc = resolverFunc } -func (f *ConfigFactoryImpl) ConfigureKubeconfigOverrides(defaultKubeconfigOverridePath string, defaultKubeconfigOverrideContext string) { - f.defaultKubeconfigOverridePath = defaultKubeconfigOverridePath - f.defaultKubeconfigOverrideContext = defaultKubeconfigOverrideContext -} - func (f *ConfigFactoryImpl) ConfigureClient(qps float32, burst int) { f.qps = qps f.burst = burst @@ -131,11 +123,6 @@ func (f *ConfigFactoryImpl) clientConfig() (bool, clientcmd.ClientConfig, error) loadingRules := clientcmd.NewDefaultClientConfigLoadingRules() overrides := &clientcmd.ConfigOverrides{} - if len(path) == 0 && len(context) == 0 && f.defaultKubeconfigOverrideContext != "" && f.defaultKubeconfigOverridePath != "" { - path = f.defaultKubeconfigOverridePath - context = f.defaultKubeconfigOverrideContext - } - if len(path) > 0 { loadingRules.ExplicitPath = path } diff --git a/cli/pkg/kctrl/cmd/core/examples.go b/cli/pkg/kctrl/cmd/core/examples.go index fadf87826..167691b23 100644 --- a/cli/pkg/kctrl/cmd/core/examples.go +++ b/cli/pkg/kctrl/cmd/core/examples.go @@ -15,12 +15,7 @@ type PackageCommandTreeOpts struct { Color bool JSON bool - DefaultKubeconfigOverridePath string - DefaultKubeconfigOverrideContext string - - DefaultServiceAcccountName string - WaitByDefault bool - AllowSharedNamespaces bool + AlwaysAllowTogglingWait bool } type Example struct { diff --git a/cli/pkg/kctrl/cmd/core/secure_namespace_flags.go b/cli/pkg/kctrl/cmd/core/secure_namespace_flags.go index 2566c80e9..303a3d3ba 100644 --- a/cli/pkg/kctrl/cmd/core/secure_namespace_flags.go +++ b/cli/pkg/kctrl/cmd/core/secure_namespace_flags.go @@ -18,8 +18,8 @@ type SecureNamespaceFlags struct { AllowedSharedNamespaces bool } -func (s *SecureNamespaceFlags) Set(cmd *cobra.Command, defaultVal bool) { - cmd.Flags().BoolVar(&s.AllowedSharedNamespaces, "dangerous-allow-use-of-shared-namespace", defaultVal, "Allow use of shared namespaces") +func (s *SecureNamespaceFlags) Set(cmd *cobra.Command) { + cmd.Flags().BoolVar(&s.AllowedSharedNamespaces, "dangerous-allow-use-of-shared-namespace", false, "Allow use of shared namespaces") } func (s *SecureNamespaceFlags) CheckForDisallowedSharedNamespaces(namespace string) error { diff --git a/cli/pkg/kctrl/cmd/core/wait_flags.go b/cli/pkg/kctrl/cmd/core/wait_flags.go index b4e8865d6..76a240ebb 100644 --- a/cli/pkg/kctrl/cmd/core/wait_flags.go +++ b/cli/pkg/kctrl/cmd/core/wait_flags.go @@ -19,14 +19,13 @@ type WaitFlagsOpts struct { AllowDisableWait bool DefaultInterval time.Duration DefaultTimeout time.Duration - WaitByDefault bool } func (f *WaitFlags) Set(cmd *cobra.Command, flagsFactory FlagsFactory, opts *WaitFlagsOpts) { - if opts.AllowDisableWait || !opts.WaitByDefault { - cmd.Flags().BoolVar(&f.Enabled, "wait", opts.WaitByDefault, "Wait for reconciliation to complete") + if opts.AllowDisableWait { + cmd.Flags().BoolVar(&f.Enabled, "wait", true, "Wait for reconciliation to complete") } - f.Enabled = opts.WaitByDefault + f.Enabled = true cmd.Flags().DurationVar(&f.CheckInterval, "wait-check-interval", opts.DefaultInterval, "Amount of time to sleep between checks while waiting") cmd.Flags().DurationVar(&f.Timeout, "wait-timeout", opts.DefaultTimeout, "Maximum amount of time to wait in wait phase") } diff --git a/cli/pkg/kctrl/cmd/kctrl.go b/cli/pkg/kctrl/cmd/kctrl.go index bab14fcbf..f89e98b03 100644 --- a/cli/pkg/kctrl/cmd/kctrl.go +++ b/cli/pkg/kctrl/cmd/kctrl.go @@ -76,7 +76,7 @@ func NewKctrlCmd(o *KctrlOptions, flagsFactory cmdcore.FlagsFactory) *cobra.Comm cmdcore.RestOfCommandsHelpGroup, })) - pkgOpts := cmdcore.PackageCommandTreeOpts{BinaryName: "kctrl", Color: true, JSON: true, WaitByDefault: true} + pkgOpts := cmdcore.PackageCommandTreeOpts{BinaryName: "kctrl", Color: true, JSON: true} setGlobalFlags(o, cmd, flagsFactory, pkgOpts) @@ -227,7 +227,6 @@ func AttachGlobalFlags(o *KctrlOptions, cmd *cobra.Command, flagsFactory cmdcore func AttachKctrlPackageCommandTree(cmd *cobra.Command, confUI *ui.ConfUI, opts cmdcore.PackageCommandTreeOpts) { configFactory := cmdcore.NewConfigFactoryImpl() - configFactory.ConfigureKubeconfigOverrides(opts.DefaultKubeconfigOverridePath, opts.DefaultKubeconfigOverrideContext) depsFactory := cmdcore.NewDepsFactoryImpl(configFactory, confUI) options := NewKctrlOptions(confUI, configFactory, depsFactory) flagsFactory := cmdcore.NewFlagsFactory(configFactory, depsFactory) diff --git a/cli/pkg/kctrl/cmd/package/installed/create_or_update.go b/cli/pkg/kctrl/cmd/package/installed/create_or_update.go index ebf075118..4eeabdf6b 100644 --- a/cli/pkg/kctrl/cmd/package/installed/create_or_update.go +++ b/cli/pkg/kctrl/cmd/package/installed/create_or_update.go @@ -88,7 +88,7 @@ func NewCreateCmd(o *CreateOrUpdateOptions, flagsFactory cmdcore.FlagsFactory) * cmdcore.PackageManagementCommandsHelpGroup.Key: cmdcore.PackageManagementCommandsHelpGroup.Value}, } o.NamespaceFlags.SetWithPackageCommandTreeOpts(cmd, flagsFactory, o.pkgCmdTreeOpts) - o.SecureNamespaceFlags.Set(cmd, o.pkgCmdTreeOpts.AllowSharedNamespaces) + o.SecureNamespaceFlags.Set(cmd) if !o.pkgCmdTreeOpts.PositionalArgs { cmd.Flags().StringVarP(&o.Name, "package-install", "i", "", "Set installed package name (required)") @@ -99,7 +99,7 @@ func NewCreateCmd(o *CreateOrUpdateOptions, flagsFactory cmdcore.FlagsFactory) * cmd.Flags().StringVarP(&o.packageName, "package", "p", "", "Set package name (required)") cmd.Flags().StringVarP(&o.version, "version", "v", "", "Set package version (required)") - cmd.Flags().StringVar(&o.serviceAccountName, "service-account-name", o.pkgCmdTreeOpts.DefaultServiceAcccountName, "Name of an existing service account used to install underlying package contents, optional") + cmd.Flags().StringVar(&o.serviceAccountName, "service-account-name", "", "Name of an existing service account used to install underlying package contents, optional") cmd.Flags().StringVar(&o.valuesFile, "values-file", "", "The path to the configuration values file, optional") cmd.Flags().BoolVar(&o.values, "values", true, "Add or keep values supplied to package install, optional") cmd.Flags().BoolVar(&o.DryRun, "dry-run", false, "Print YAML for resources being applied to the cluster without applying them, optional") @@ -108,7 +108,6 @@ func NewCreateCmd(o *CreateOrUpdateOptions, flagsFactory cmdcore.FlagsFactory) * AllowDisableWait: true, DefaultInterval: 1 * time.Second, DefaultTimeout: 30 * time.Minute, - WaitByDefault: o.pkgCmdTreeOpts.WaitByDefault, }) o.YttOverlayFlags.Set(cmd) @@ -135,7 +134,7 @@ func NewInstallCmd(o *CreateOrUpdateOptions, flagsFactory cmdcore.FlagsFactory) cmdcore.PackageManagementCommandsHelpGroup.Key: cmdcore.PackageManagementCommandsHelpGroup.Value}, } o.NamespaceFlags.SetWithPackageCommandTreeOpts(cmd, flagsFactory, o.pkgCmdTreeOpts) - o.SecureNamespaceFlags.Set(cmd, o.pkgCmdTreeOpts.AllowSharedNamespaces) + o.SecureNamespaceFlags.Set(cmd) if !o.pkgCmdTreeOpts.PositionalArgs { cmd.Flags().StringVarP(&o.Name, "package-install", "i", "", "Set installed package name (required)") @@ -146,7 +145,7 @@ func NewInstallCmd(o *CreateOrUpdateOptions, flagsFactory cmdcore.FlagsFactory) cmd.Flags().StringVarP(&o.packageName, "package", "p", "", "Set package name (required)") cmd.Flags().StringVarP(&o.version, "version", "v", "", "Set package version (required)") - cmd.Flags().StringVar(&o.serviceAccountName, "service-account-name", o.pkgCmdTreeOpts.DefaultServiceAcccountName, "Name of an existing service account used to install underlying package contents, optional") + cmd.Flags().StringVar(&o.serviceAccountName, "service-account-name", "", "Name of an existing service account used to install underlying package contents, optional") cmd.Flags().StringVar(&o.valuesFile, "values-file", "", "The path to the configuration values file, optional") cmd.Flags().BoolVar(&o.values, "values", true, "Add or keep values supplied to package install, optional") cmd.Flags().BoolVar(&o.DryRun, "dry-run", false, "Print YAML for resources being applied to the cluster without applying them, optional") @@ -155,7 +154,6 @@ func NewInstallCmd(o *CreateOrUpdateOptions, flagsFactory cmdcore.FlagsFactory) AllowDisableWait: true, DefaultInterval: 1 * time.Second, DefaultTimeout: 30 * time.Minute, - WaitByDefault: o.pkgCmdTreeOpts.WaitByDefault, }) o.YttOverlayFlags.Set(cmd) @@ -181,7 +179,7 @@ func NewUpdateCmd(o *CreateOrUpdateOptions, flagsFactory cmdcore.FlagsFactory) * cmdcore.PackageManagementCommandsHelpGroup.Key: cmdcore.PackageManagementCommandsHelpGroup.Value}, } o.NamespaceFlags.SetWithPackageCommandTreeOpts(cmd, flagsFactory, o.pkgCmdTreeOpts) - o.SecureNamespaceFlags.Set(cmd, o.pkgCmdTreeOpts.AllowSharedNamespaces) + o.SecureNamespaceFlags.Set(cmd) if !o.pkgCmdTreeOpts.PositionalArgs { cmd.Flags().StringVarP(&o.Name, "package-install", "i", "", "Set installed package name") @@ -199,7 +197,6 @@ func NewUpdateCmd(o *CreateOrUpdateOptions, flagsFactory cmdcore.FlagsFactory) * AllowDisableWait: true, DefaultInterval: 1 * time.Second, DefaultTimeout: 30 * time.Minute, - WaitByDefault: o.pkgCmdTreeOpts.WaitByDefault, }) o.YttOverlayFlags.Set(cmd) diff --git a/cli/pkg/kctrl/cmd/package/installed/delete.go b/cli/pkg/kctrl/cmd/package/installed/delete.go index 4a18a6097..80b54db48 100644 --- a/cli/pkg/kctrl/cmd/package/installed/delete.go +++ b/cli/pkg/kctrl/cmd/package/installed/delete.go @@ -72,10 +72,9 @@ func NewDeleteCmd(o *DeleteOptions, flagsFactory cmdcore.FlagsFactory) *cobra.Co } o.WaitFlags.Set(cmd, flagsFactory, &cmdcore.WaitFlagsOpts{ - AllowDisableWait: false, + AllowDisableWait: false || o.pkgCmdTreeOpts.AlwaysAllowTogglingWait, DefaultInterval: 1 * time.Second, DefaultTimeout: 5 * time.Minute, - WaitByDefault: o.pkgCmdTreeOpts.WaitByDefault, }) return cmd diff --git a/cli/pkg/kctrl/cmd/package/installed/pause_or_kick.go b/cli/pkg/kctrl/cmd/package/installed/pause_or_kick.go index 087ff5305..f42c83303 100644 --- a/cli/pkg/kctrl/cmd/package/installed/pause_or_kick.go +++ b/cli/pkg/kctrl/cmd/package/installed/pause_or_kick.go @@ -96,7 +96,6 @@ func NewKickCmd(o *PauseOrKickOptions, flagsFactory cmdcore.FlagsFactory) *cobra AllowDisableWait: true, DefaultInterval: 2 * time.Second, DefaultTimeout: 5 * time.Minute, - WaitByDefault: o.pkgCmdTreeOpts.WaitByDefault, }) return cmd diff --git a/cli/pkg/kctrl/cmd/package/repository/add_or_update.go b/cli/pkg/kctrl/cmd/package/repository/add_or_update.go index 3bb164f7b..1c778d4b3 100644 --- a/cli/pkg/kctrl/cmd/package/repository/add_or_update.go +++ b/cli/pkg/kctrl/cmd/package/repository/add_or_update.go @@ -65,7 +65,7 @@ func NewAddCmd(o *AddOrUpdateOptions, flagsFactory cmdcore.FlagsFactory) *cobra. } o.NamespaceFlags.SetWithPackageCommandTreeOpts(cmd, flagsFactory, o.pkgCmdTreeOpts) - o.SecureNamespaceFlags.Set(cmd, o.pkgCmdTreeOpts.AllowSharedNamespaces) + o.SecureNamespaceFlags.Set(cmd) if !o.pkgCmdTreeOpts.PositionalArgs { cmd.Flags().StringVarP(&o.Name, "repository", "r", "", "Set package repository name (required)") @@ -84,7 +84,6 @@ func NewAddCmd(o *AddOrUpdateOptions, flagsFactory cmdcore.FlagsFactory) *cobra. AllowDisableWait: true, DefaultInterval: 1 * time.Second, DefaultTimeout: 5 * time.Minute, - WaitByDefault: o.pkgCmdTreeOpts.WaitByDefault, }) o.CreateRepository = true @@ -107,7 +106,7 @@ func NewUpdateCmd(o *AddOrUpdateOptions, flagsFactory cmdcore.FlagsFactory) *cob } o.NamespaceFlags.SetWithPackageCommandTreeOpts(cmd, flagsFactory, o.pkgCmdTreeOpts) - o.SecureNamespaceFlags.Set(cmd, o.pkgCmdTreeOpts.AllowSharedNamespaces) + o.SecureNamespaceFlags.Set(cmd) if !o.pkgCmdTreeOpts.PositionalArgs { cmd.Flags().StringVarP(&o.Name, "repository", "r", "", "Set package repository name (required)") @@ -122,7 +121,6 @@ func NewUpdateCmd(o *AddOrUpdateOptions, flagsFactory cmdcore.FlagsFactory) *cob AllowDisableWait: true, DefaultInterval: 1 * time.Second, DefaultTimeout: 5 * time.Minute, - WaitByDefault: o.pkgCmdTreeOpts.WaitByDefault, }) return cmd diff --git a/cli/pkg/kctrl/cmd/package/repository/delete.go b/cli/pkg/kctrl/cmd/package/repository/delete.go index 3d5ffd011..6f06f67ac 100644 --- a/cli/pkg/kctrl/cmd/package/repository/delete.go +++ b/cli/pkg/kctrl/cmd/package/repository/delete.go @@ -62,7 +62,6 @@ func NewDeleteCmd(o *DeleteOptions, flagsFactory cmdcore.FlagsFactory) *cobra.Co AllowDisableWait: true, DefaultInterval: 1 * time.Second, DefaultTimeout: 5 * time.Minute, - WaitByDefault: o.pkgCmdTreeOpts.WaitByDefault, }) return cmd diff --git a/cli/pkg/kctrl/cmd/package/repository/kick.go b/cli/pkg/kctrl/cmd/package/repository/kick.go index 9b013a6e9..5d33030d2 100644 --- a/cli/pkg/kctrl/cmd/package/repository/kick.go +++ b/cli/pkg/kctrl/cmd/package/repository/kick.go @@ -65,7 +65,6 @@ func NewKickCmd(o *KickOptions, flagsFactory cmdcore.FlagsFactory) *cobra.Comman AllowDisableWait: true, DefaultInterval: 1 * time.Second, DefaultTimeout: 5 * time.Minute, - WaitByDefault: o.pkgCmdTreeOpts.WaitByDefault, }) return cmd