[fix] chaos mode always fails deploy
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing

This commit is contained in:
Ammar Hussein
2024-11-30 20:10:04 -08:00
parent bba1640913
commit f664599836
2 changed files with 116 additions and 6 deletions

View File

@ -2,6 +2,7 @@ package app
import (
"context"
"errors"
"fmt"
"coopcloud.tech/abra/cli/internal"
@ -46,14 +47,12 @@ operations.`,
app := internal.ValidateApp(cmd)
stackName := app.StackName()
specificVersion := cmd.Args().Get(1)
if specificVersion == "" {
specificVersion = app.Recipe.Version
ok, err := validateChaosXORVersion(cmd.Args())
if !ok {
log.Fatalf(err.Error())
}
if specificVersion != "" && internal.Chaos {
log.Fatal("cannot use <version> and --chaos together")
}
specificVersion := getSpecifiedVersion(cmd.Args())
if specificVersion != "" {
log.Debugf("overriding env file version (%s) with %s", app.Recipe.Version, specificVersion)
@ -261,3 +260,17 @@ operations.`,
return nil
},
}
// This is not really xor since both can be absent
//
// but, I say we let it slide this time!
func validateChaosXORVersion(args cli.Args) (bool, error) {
if getSpecifiedVersion(args) != "" && internal.Chaos {
return false, errors.New("cannot use <version> and --chaos together")
}
return true, nil
}
func getSpecifiedVersion(args cli.Args) string {
return args.Get(1)
}