feat: support deploying with chaos mode
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2021-10-18 08:14:06 +02:00
parent 6d42e72f16
commit 2f9b11f389
3 changed files with 86 additions and 3 deletions

View File

@ -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 {