cli: add version validation and force flag

Version validation checks that the configured versions
are not more than one minor version below the CLI's version.
The validation can be disabled using --force.
This is necessary for now during development as the CLI
does not have a prerelease version, as our images do.
This commit is contained in:
Otto Bittner 2023-01-31 11:45:31 +01:00
parent 3a7b829107
commit f204c24174
29 changed files with 590 additions and 61 deletions

View file

@ -79,9 +79,9 @@ func (r *recoverCmd) recover(
}
r.log.Debugf("Loading configuration file from %q", flags.configPath)
conf, err := config.New(fileHandler, flags.configPath)
conf, err := config.New(fileHandler, flags.configPath, flags.force)
if err != nil {
return displayConfigValidationErrors(cmd.ErrOrStderr(), err)
return config.DisplayValidationErrors(cmd.ErrOrStderr(), err)
}
provider := conf.GetProvider()
r.log.Debugf("Got provider %s", provider.String())
@ -202,6 +202,7 @@ type recoverFlags struct {
endpoint string
secretPath string
configPath string
force bool
}
func (r *recoverCmd) parseRecoverFlags(cmd *cobra.Command, fileHandler file.Handler) (recoverFlags, error) {
@ -232,10 +233,16 @@ func (r *recoverCmd) parseRecoverFlags(cmd *cobra.Command, fileHandler file.Hand
}
r.log.Debugf("Configuration path flag is %s", configPath)
force, err := cmd.Flags().GetBool("force")
if err != nil {
return recoverFlags{}, fmt.Errorf("parsing force argument: %w", err)
}
return recoverFlags{
endpoint: endpoint,
secretPath: masterSecretPath,
configPath: configPath,
force: force,
}, nil
}