feat: support deploying with chaos mode
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@ -10,6 +10,7 @@ import (
|
||||
"coopcloud.tech/abra/pkg/client"
|
||||
stack "coopcloud.tech/abra/pkg/client/stack"
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
"coopcloud.tech/abra/pkg/git"
|
||||
"coopcloud.tech/abra/pkg/recipe"
|
||||
"github.com/AlecAivazis/survey/v2"
|
||||
"github.com/sirupsen/logrus"
|
||||
@ -22,6 +23,7 @@ var appDeployCommand = &cli.Command{
|
||||
Usage: "Deploy an app",
|
||||
Flags: []cli.Flag{
|
||||
internal.ForceFlag,
|
||||
internal.ChaosFlag,
|
||||
},
|
||||
Description: `
|
||||
This command deploys a new instance of an app. It does not support changing the
|
||||
@ -50,14 +52,16 @@ hacking.
|
||||
|
||||
if isDeployed {
|
||||
if internal.Force {
|
||||
logrus.Infof("continuing with deployment due to '--force/-f' being set")
|
||||
logrus.Warnf("'%s' already deployed but continuing (--force)", stackName)
|
||||
} else if internal.Chaos {
|
||||
logrus.Warnf("'%s' already deployed but continuing (--chaos)", stackName)
|
||||
} else {
|
||||
logrus.Fatalf("'%s' is already deployed", stackName)
|
||||
}
|
||||
}
|
||||
|
||||
version := deployedVersion
|
||||
if version == "" {
|
||||
if version == "" && !internal.Chaos {
|
||||
versions, err := catalogue.GetRecipeCatalogueVersions(app.Type)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
@ -70,13 +74,32 @@ hacking.
|
||||
}
|
||||
} else {
|
||||
version = "latest commit"
|
||||
logrus.Warning("no versions detected, using latest commit")
|
||||
logrus.Warn("no versions detected, using latest commit")
|
||||
if err := recipe.EnsureLatest(app.Type); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if internal.Chaos {
|
||||
logrus.Warnf("chaos mode engaged")
|
||||
head, err := git.GetRecipeHead(app.Type)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
version = head.String()[:8]
|
||||
|
||||
isClean, err := git.IsClean(app.Type)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if !isClean {
|
||||
version = fmt.Sprintf("%s + unstaged changes", version)
|
||||
}
|
||||
}
|
||||
|
||||
abraShPath := fmt.Sprintf("%s/%s/%s", config.APPS_DIR, app.Type, "abra.sh")
|
||||
abraShEnv, err := config.ReadAbraShEnvVars(abraShPath)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user