forked from toolshed/abra
fix: undeploy handles chaos/unstaged in overview
Follows 3a71dc47f8afa8e64adb86868a17650ea98bb842
This commit is contained in:
parent
3a71dc47f8
commit
0a63f9ce27
@ -59,10 +59,16 @@ Passing "--prune/-p" does not remove those volumes.`,
|
|||||||
chaosVersion = deployMeta.ChaosVersion
|
chaosVersion = deployMeta.ChaosVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toWriteVersion := deployMeta.Version
|
||||||
|
if deployMeta.IsChaos {
|
||||||
|
toWriteVersion = chaosVersion
|
||||||
|
}
|
||||||
|
|
||||||
if err := internal.UndeployOverview(
|
if err := internal.UndeployOverview(
|
||||||
app,
|
app,
|
||||||
deployMeta.Version,
|
deployMeta.Version,
|
||||||
chaosVersion,
|
chaosVersion,
|
||||||
|
toWriteVersion,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -81,11 +87,6 @@ Passing "--prune/-p" does not remove those volumes.`,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toWriteVersion := deployMeta.Version
|
|
||||||
if deployMeta.IsChaos {
|
|
||||||
toWriteVersion = chaosVersion
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := app.WriteRecipeVersion(toWriteVersion, false); err != nil {
|
if err := app.WriteRecipeVersion(toWriteVersion, false); err != nil {
|
||||||
log.Fatalf("writing recipe version failed: %s", err)
|
log.Fatalf("writing recipe version failed: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -210,8 +210,10 @@ func DeployOverview(
|
|||||||
// UndeployOverview shows an undeployment overview
|
// UndeployOverview shows an undeployment overview
|
||||||
func UndeployOverview(
|
func UndeployOverview(
|
||||||
app appPkg.App,
|
app appPkg.App,
|
||||||
version,
|
deployedVersion,
|
||||||
chaosVersion string) error {
|
deployedChaosVersion,
|
||||||
|
toWriteVersion string,
|
||||||
|
) error {
|
||||||
deployConfig := "compose.yml"
|
deployConfig := "compose.yml"
|
||||||
if composeFiles, ok := app.Env["COMPOSE_FILE"]; ok {
|
if composeFiles, ok := app.Env["COMPOSE_FILE"]; ok {
|
||||||
deployConfig = composeFiles
|
deployConfig = composeFiles
|
||||||
@ -227,6 +229,20 @@ func UndeployOverview(
|
|||||||
domain = config.NO_DOMAIN_DEFAULT
|
domain = config.NO_DOMAIN_DEFAULT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recipeName, exists := app.Env["RECIPE"]
|
||||||
|
if !exists {
|
||||||
|
recipeName = app.Env["TYPE"]
|
||||||
|
}
|
||||||
|
|
||||||
|
envVersion, err := recipe.GetEnvVersionRaw(recipeName)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if envVersion == "" {
|
||||||
|
envVersion = config.NO_VERSION_DEFAULT
|
||||||
|
}
|
||||||
|
|
||||||
rows := [][]string{
|
rows := [][]string{
|
||||||
{"APP", domain},
|
{"APP", domain},
|
||||||
{"RECIPE", app.Recipe.Name},
|
{"RECIPE", app.Recipe.Name},
|
||||||
@ -234,12 +250,12 @@ func UndeployOverview(
|
|||||||
{"CONFIG", deployConfig},
|
{"CONFIG", deployConfig},
|
||||||
|
|
||||||
{"CURRENT DEPLOYMENT", "---"},
|
{"CURRENT DEPLOYMENT", "---"},
|
||||||
{"VERSION", formatter.BoldDirtyDefault(version)},
|
{"VERSION", formatter.BoldDirtyDefault(deployedVersion)},
|
||||||
{"CHAOS", formatter.BoldDirtyDefault(chaosVersion)},
|
{"CHAOS", formatter.BoldDirtyDefault(deployedChaosVersion)},
|
||||||
|
|
||||||
{fmt.Sprintf("%s.ENV", strings.ToUpper(app.Name)), "---"},
|
{fmt.Sprintf("%s.ENV", strings.ToUpper(app.Name)), "---"},
|
||||||
{"CURRENT VERSION", formatter.BoldDirtyDefault(app.Recipe.EnvVersion)},
|
{"CURRENT VERSION", formatter.BoldDirtyDefault(envVersion)},
|
||||||
{"NEW VERSION", formatter.BoldDirtyDefault(version)},
|
{"NEW VERSION", formatter.BoldDirtyDefault(toWriteVersion)},
|
||||||
}
|
}
|
||||||
|
|
||||||
overview := formatter.CreateOverview("UNDEPLOY OVERVIEW", rows)
|
overview := formatter.CreateOverview("UNDEPLOY OVERVIEW", rows)
|
||||||
|
@ -107,6 +107,15 @@ type DeployMeta struct {
|
|||||||
ChaosVersion string // the --chaos deployment version
|
ChaosVersion string // the --chaos deployment version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d DeployMeta) String() string {
|
||||||
|
var out string
|
||||||
|
out += fmt.Sprintf("{isDeployed: %v, ", d.IsDeployed)
|
||||||
|
out += fmt.Sprintf("version: %s, ", d.Version)
|
||||||
|
out += fmt.Sprintf("isChaos: %v, ", d.IsChaos)
|
||||||
|
out += fmt.Sprintf("chaosVersion: %s}", d.ChaosVersion)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
// IsDeployed gathers metadata about an app deployment.
|
// IsDeployed gathers metadata about an app deployment.
|
||||||
func IsDeployed(ctx context.Context, cl *dockerClient.Client, stackName string) (DeployMeta, error) {
|
func IsDeployed(ctx context.Context, cl *dockerClient.Client, stackName string) (DeployMeta, error) {
|
||||||
deployMeta := DeployMeta{
|
deployMeta := DeployMeta{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user