refactor!: --ignore-env-version is --latest *only* on deploy
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
See #617
This commit is contained in:
@ -262,6 +262,14 @@ func validateArgsAndFlags(args []string) error {
|
||||
return errors.New(i18n.G("cannot use [version] and --chaos together"))
|
||||
}
|
||||
|
||||
if len(args) == 2 && args[1] != "" && internal.DeployLatest {
|
||||
return errors.New(i18n.G("cannot use [version] and --latest together"))
|
||||
}
|
||||
|
||||
if internal.DeployLatest && internal.Chaos {
|
||||
return errors.New(i18n.G("cannot use --chaos and --latest together"))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -298,7 +306,7 @@ func getDeployVersion(cliArgs []string, deployMeta stack.DeployMeta, app app.App
|
||||
}
|
||||
|
||||
// Check if the recipe has a version in the .env file
|
||||
if app.Recipe.EnvVersion != "" && !internal.IgnoreEnvVersion {
|
||||
if app.Recipe.EnvVersion != "" && !internal.DeployLatest {
|
||||
if strings.HasSuffix(app.Recipe.EnvVersionRaw, "+U") {
|
||||
return "", errors.New(i18n.G("version: can not redeploy chaos version %s", app.Recipe.EnvVersionRaw))
|
||||
}
|
||||
@ -307,7 +315,7 @@ func getDeployVersion(cliArgs []string, deployMeta stack.DeployMeta, app app.App
|
||||
}
|
||||
|
||||
// Take deployed version
|
||||
if deployMeta.IsDeployed {
|
||||
if deployMeta.IsDeployed && !internal.DeployLatest {
|
||||
log.Debug(i18n.G("version: taking deployed version: %s", deployMeta.Version))
|
||||
return deployMeta.Version, nil
|
||||
}
|
||||
@ -352,4 +360,12 @@ func init() {
|
||||
false,
|
||||
i18n.G("disable converge logic checks"),
|
||||
)
|
||||
|
||||
AppDeployCommand.PersistentFlags().BoolVarP(
|
||||
&internal.DeployLatest,
|
||||
"latest",
|
||||
"l",
|
||||
false,
|
||||
i18n.G("deploy latest recipe version"),
|
||||
)
|
||||
}
|
||||
|
@ -2,13 +2,13 @@ package internal
|
||||
|
||||
var (
|
||||
// NOTE(d1): global
|
||||
Debug bool
|
||||
NoInput bool
|
||||
Offline bool
|
||||
IgnoreEnvVersion bool
|
||||
Debug bool
|
||||
NoInput bool
|
||||
Offline bool
|
||||
|
||||
// NOTE(d1): sub-command specific
|
||||
Chaos bool
|
||||
DeployLatest bool
|
||||
DontWaitConverge bool
|
||||
Dry bool
|
||||
Force bool
|
||||
|
@ -6,6 +6,6 @@ func GetEnsureContext() recipe.EnsureContext {
|
||||
return recipe.EnsureContext{
|
||||
Chaos,
|
||||
Offline,
|
||||
IgnoreEnvVersion,
|
||||
DeployLatest,
|
||||
}
|
||||
}
|
||||
|
@ -137,14 +137,6 @@ func Run(version, commit string) {
|
||||
i18n.G("prefer offline & filesystem access"),
|
||||
)
|
||||
|
||||
rootCmd.PersistentFlags().BoolVarP(
|
||||
&internal.IgnoreEnvVersion,
|
||||
"ignore-env-version",
|
||||
"i",
|
||||
false,
|
||||
i18n.G("ignore .env version checkout"),
|
||||
)
|
||||
|
||||
catalogue.CatalogueCommand.AddCommand(
|
||||
catalogue.CatalogueGenerateCommand,
|
||||
catalogue.CatalogueSyncCommand,
|
||||
|
Reference in New Issue
Block a user