refactor: make IsChaos an actual bool
This commit is contained in:
parent
00d60f7114
commit
b82ac3bd63
@ -129,7 +129,7 @@ EXAMPLE:
|
||||
}
|
||||
|
||||
if deployMeta.Version != "unknown" && specificVersion == "" {
|
||||
if deployMeta.IsChaos == "true" {
|
||||
if deployMeta.IsChaos {
|
||||
log.Warn("attempting to rollback a chaos deployment")
|
||||
}
|
||||
|
||||
@ -162,7 +162,7 @@ EXAMPLE:
|
||||
log.Debugf("choosing %s as version to downgrade to (--force/--no-input)", chosenDowngrade)
|
||||
} else {
|
||||
msg := fmt.Sprintf("please select a downgrade (version: %s):", deployMeta.Version)
|
||||
if deployMeta.IsChaos == "true" {
|
||||
if deployMeta.IsChaos {
|
||||
msg = fmt.Sprintf("please select a downgrade (version: %s, chaosVersion: %s):", deployMeta.Version, deployMeta.ChaosVersion)
|
||||
}
|
||||
|
||||
@ -214,8 +214,8 @@ EXAMPLE:
|
||||
appPkg.SetChaosVersionLabel(compose, stackName, chosenDowngrade)
|
||||
appPkg.SetUpdateLabel(compose, stackName, app.Env)
|
||||
|
||||
chaosVersion := deployMeta.IsChaos
|
||||
if deployMeta.IsChaos == "true" {
|
||||
chaosVersion := "false"
|
||||
if deployMeta.IsChaos {
|
||||
chaosVersion = deployMeta.ChaosVersion
|
||||
}
|
||||
|
||||
|
@ -99,8 +99,8 @@ Passing "-p/--prune" does not remove those volumes.`,
|
||||
log.Fatalf("%s is not deployed?", app.Name)
|
||||
}
|
||||
|
||||
chaosVersion := deployMeta.IsChaos
|
||||
if deployMeta.IsChaos == "true" {
|
||||
chaosVersion := "false"
|
||||
if deployMeta.IsChaos {
|
||||
chaosVersion = deployMeta.ChaosVersion
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ EXAMPLE:
|
||||
}
|
||||
|
||||
if deployMeta.Version != "unknown" && specificVersion == "" {
|
||||
if deployMeta.IsChaos == "true" {
|
||||
if deployMeta.IsChaos {
|
||||
log.Warn("attempting to upgrade a chaos deployment")
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ EXAMPLE:
|
||||
log.Debugf("choosing %s as version to upgrade to", chosenUpgrade)
|
||||
} else {
|
||||
msg := fmt.Sprintf("please select an upgrade (version: %s):", deployMeta.Version)
|
||||
if deployMeta.IsChaos == "true" {
|
||||
if deployMeta.IsChaos {
|
||||
msg = fmt.Sprintf("please select an upgrade (version: %s, chaosVersion: %s):", deployMeta.Version, deployMeta.ChaosVersion)
|
||||
}
|
||||
|
||||
@ -259,8 +259,8 @@ EXAMPLE:
|
||||
return nil
|
||||
}
|
||||
|
||||
chaosVersion := deployMeta.IsChaos
|
||||
if deployMeta.IsChaos == "true" {
|
||||
chaosVersion := "false"
|
||||
if deployMeta.IsChaos {
|
||||
chaosVersion = deployMeta.ChaosVersion
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -101,7 +102,7 @@ func GetDeployedServicesByName(ctx context.Context, cl *dockerClient.Client, sta
|
||||
type DeployMeta struct {
|
||||
IsDeployed bool // whether the app is deployed or not
|
||||
Version string // the deployed version
|
||||
IsChaos string // whether or not the deployment is --chaos
|
||||
IsChaos bool // whether or not the deployment is --chaos
|
||||
ChaosVersion string // the --chaos deployment version
|
||||
}
|
||||
|
||||
@ -110,7 +111,7 @@ func IsDeployed(ctx context.Context, cl *dockerClient.Client, stackName string)
|
||||
deployMeta := DeployMeta{
|
||||
IsDeployed: false,
|
||||
Version: "unknown",
|
||||
IsChaos: "false", // NOTE(d1): match string type used on label
|
||||
IsChaos: false,
|
||||
ChaosVersion: "false", // NOTE(d1): match string type used on label
|
||||
}
|
||||
|
||||
@ -137,7 +138,11 @@ func IsDeployed(ctx context.Context, cl *dockerClient.Client, stackName string)
|
||||
|
||||
labelKey = fmt.Sprintf("coop-cloud.%s.chaos", stackName)
|
||||
if isChaos, ok := service.Spec.Labels[labelKey]; ok {
|
||||
deployMeta.IsChaos = isChaos
|
||||
boolVal, err := strconv.ParseBool(isChaos)
|
||||
if err != nil {
|
||||
return deployMeta, fmt.Errorf("unable to parse '%s' value as bool: %s", labelKey, err)
|
||||
}
|
||||
deployMeta.IsChaos = boolVal
|
||||
}
|
||||
|
||||
labelKey = fmt.Sprintf("coop-cloud.%s.chaos-version", stackName)
|
||||
|
Loading…
Reference in New Issue
Block a user