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

@ -69,9 +69,9 @@ func upgradeExecute(cmd *cobra.Command, imageFetcher imageFetcher, upgrader clou
if err != nil {
return fmt.Errorf("parsing flags: %w", err)
}
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)
}
if flags.helmFlag {
@ -130,7 +130,13 @@ func parseUpgradeExecuteFlags(cmd *cobra.Command) (upgradeExecuteFlags, error) {
if err != nil {
return upgradeExecuteFlags{}, err
}
return upgradeExecuteFlags{configPath: configPath, helmFlag: helmFlag, yes: yes, upgradeTimeout: timeout}, nil
force, err := cmd.Flags().GetBool("force")
if err != nil {
return upgradeExecuteFlags{}, fmt.Errorf("parsing force argument: %w", err)
}
return upgradeExecuteFlags{configPath: configPath, helmFlag: helmFlag, yes: yes, upgradeTimeout: timeout, force: force}, nil
}
type upgradeExecuteFlags struct {
@ -138,6 +144,7 @@ type upgradeExecuteFlags struct {
helmFlag bool
yes bool
upgradeTimeout time.Duration
force bool
}
type cloudUpgrader interface {