revertprovider: only accept the supported version

This commit is contained in:
Nicola Murino 2021-02-05 13:55:19 +01:00
parent d32b195a57
commit 8de7a81674
No known key found for this signature in database
GPG key ID: 2F1FB59433D5A8CB

View file

@ -26,11 +26,15 @@ Please take a look at the usage below to customize the options.`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
logger.DisableLogger() logger.DisableLogger()
logger.EnableConsoleLogger(zerolog.DebugLevel) logger.EnableConsoleLogger(zerolog.DebugLevel)
if revertProviderTargetVersion != 4 {
logger.WarnToConsole("Unsupported target version, 4 is the only supported one")
os.Exit(1)
}
configDir = utils.CleanDirInput(configDir) configDir = utils.CleanDirInput(configDir)
err := config.LoadConfig(configDir, configFile) err := config.LoadConfig(configDir, configFile)
if err != nil { if err != nil {
logger.WarnToConsole("Unable to initialize data provider, config load error: %v", err) logger.WarnToConsole("Unable to initialize data provider, config load error: %v", err)
return os.Exit(1)
} }
kmsConfig := config.GetKMSConfig() kmsConfig := config.GetKMSConfig()
err = kmsConfig.Initialize() err = kmsConfig.Initialize()
@ -54,6 +58,7 @@ Please take a look at the usage below to customize the options.`,
func init() { func init() {
addConfigFlags(revertProviderCmd) addConfigFlags(revertProviderCmd)
revertProviderCmd.Flags().IntVar(&revertProviderTargetVersion, "to-version", 0, `4 means the version supported in v1.0.0-v1.2.x`) revertProviderCmd.Flags().IntVar(&revertProviderTargetVersion, "to-version", 0, `4 means the version supported in v1.0.0-v1.2.x`)
revertProviderCmd.MarkFlagRequired("to-version") //nolint:errcheck
rootCmd.AddCommand(revertProviderCmd) rootCmd.AddCommand(revertProviderCmd)
} }