Skip to content

Commit

Permalink
refactor: remove silent flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmad-ibra committed Aug 3, 2024
1 parent 19cfc4a commit 30707e7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
12 changes: 3 additions & 9 deletions cmd/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,11 @@ For more information about validator, see: https://github.com/validator-labs/val
flags.BoolVarP(&tc.Reconfigure, "reconfigure", "r", false, "Re-configure validator and plugin(s) prior to installation. The --config-file flag must be provided. Default: false.")

flags.BoolVar(&tc.Check, "check", false, "Configure rules for validator plugin(s). Default: false")
flags.BoolVarP(&tc.Silent, "silent", "s", false, "Skip all plugin prompts and apply configuration file directly. Only applies when --check is set. Default: false.")
flags.BoolVar(&tc.Wait, "wait", false, "Wait for validation to succeed and describe results. Only applies when --check is set. Default: false")

cmd.MarkFlagsMutuallyExclusive("config-only", "silent")
cmd.MarkFlagsMutuallyExclusive("config-only", "wait")
cmd.MarkFlagsMutuallyExclusive("update-passwords", "silent")
cmd.MarkFlagsMutuallyExclusive("update-passwords", "wait")
cmd.MarkFlagsMutuallyExclusive("update-passwords", "reconfigure")
cmd.MarkFlagsMutuallyExclusive("reconfigure", "silent")

return cmd
}
Expand All @@ -68,8 +64,7 @@ For more information about validator, see: https://github.com/validator-labs/val
func NewConfigureValidatorCmd() *cobra.Command {
c := cfgmanager.Config()
var tc = &cfg.TaskConfig{
CliVersion: Version,
Reconfigure: true,
CliVersion: Version,
}

cmd := &cobra.Command{
Expand Down Expand Up @@ -100,15 +95,14 @@ For more information about validator, see: https://github.com/validator-labs/val
flags.StringVarP(&tc.ConfigFile, "config-file", "f", "", "Validator installation configuration file.")
flags.BoolVarP(&tc.CreateConfigOnly, "config-only", "o", false, "Update configuration file only. Do not proceed with checks. Default: false.")
flags.BoolVarP(&tc.UpdatePasswords, "update-passwords", "p", false, "Update passwords only. Do not proceed with checks. Default: false.")
flags.BoolVarP(&tc.Silent, "silent", "s", false, "Skip all prompts and apply configuration file directly. Default: false.")
flags.BoolVarP(&tc.Reconfigure, "reconfigure", "r", false, "Re-configure plugin rules prior to running checks. Default: false.")
flags.BoolVar(&tc.Wait, "wait", false, "Wait for validation to succeed and describe results. Default: false")

cmdutils.MarkFlagRequired(cmd, "config-file")

cmd.MarkFlagsMutuallyExclusive("config-only", "silent")
cmd.MarkFlagsMutuallyExclusive("config-only", "wait")
cmd.MarkFlagsMutuallyExclusive("update-passwords", "silent")
cmd.MarkFlagsMutuallyExclusive("update-passwords", "wait")
cmd.MarkFlagsMutuallyExclusive("update-passwords", "reconfigure")

return cmd
}
Expand Down
8 changes: 7 additions & 1 deletion pkg/cmd/validator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ func InstallValidatorCommand(c *cfg.Config, tc *cfg.TaskConfig) error {
log.FatalCLI("Cannot reconfigure validator without providing a configuration file.")
}

configProvided := tc.ConfigFile != ""

if tc.ConfigFile != "" && !tc.Reconfigure {
// Silent Mode
vc, err = components.NewValidatorFromConfig(tc)
Expand Down Expand Up @@ -118,6 +120,10 @@ func InstallValidatorCommand(c *cfg.Config, tc *cfg.TaskConfig) error {
return err
}
if tc.Check {
if !configProvided {
tc.Reconfigure = true
}

return ConfigureValidatorCommand(c, tc)
}
return nil
Expand All @@ -130,7 +136,7 @@ func ConfigureValidatorCommand(c *cfg.Config, tc *cfg.TaskConfig) error {
var err error
var saveConfig bool

if tc.Silent {
if !tc.Reconfigure {
// Silent Mode
vc, err = components.NewValidatorFromConfig(tc)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ type TaskConfig struct {
CreateConfigOnly bool
DeleteCluster bool
Reconfigure bool
Silent bool
UpdatePasswords bool
Wait bool
}
Expand Down

0 comments on commit 30707e7

Please sign in to comment.