diff --git a/cli/app/rollback.go b/cli/app/rollback.go index 6ffff04b..91a4e6dd 100644 --- a/cli/app/rollback.go +++ b/cli/app/rollback.go @@ -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 } diff --git a/cli/app/undeploy.go b/cli/app/undeploy.go index c242f9c5..342532a3 100644 --- a/cli/app/undeploy.go +++ b/cli/app/undeploy.go @@ -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 } diff --git a/cli/app/upgrade.go b/cli/app/upgrade.go index 74ffef28..54b79730 100644 --- a/cli/app/upgrade.go +++ b/cli/app/upgrade.go @@ -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 } diff --git a/pkg/upstream/stack/stack.go b/pkg/upstream/stack/stack.go index a7c0fb5f..8576f61f 100644 --- a/pkg/upstream/stack/stack.go +++ b/pkg/upstream/stack/stack.go @@ -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)