Merge pull request 'app ls --status
shows more detailles about the deployment state' (!280) from detailed_app_list into main
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: coop-cloud/abra#280
This commit is contained in:
commit
0ce8b3a5c2
@ -39,13 +39,16 @@ var listAppServerFlag = &cli.StringFlag{
|
||||
}
|
||||
|
||||
type appStatus struct {
|
||||
Server string `json:"server"`
|
||||
Recipe string `json:"recipe"`
|
||||
AppName string `json:"appName"`
|
||||
Domain string `json:"domain"`
|
||||
Status string `json:"status"`
|
||||
Version string `json:"version"`
|
||||
Upgrade string `json:"upgrade"`
|
||||
Server string `json:"server"`
|
||||
Recipe string `json:"recipe"`
|
||||
AppName string `json:"appName"`
|
||||
Domain string `json:"domain"`
|
||||
Status string `json:"status"`
|
||||
Chaos string `json:"chaos"`
|
||||
ChaosVersion string `json:"chaosVersion"`
|
||||
AutoUpdate string `json:"autoUpdate"`
|
||||
Version string `json:"version"`
|
||||
Upgrade string `json:"upgrade"`
|
||||
}
|
||||
|
||||
type serverStatus struct {
|
||||
@ -138,12 +141,24 @@ can take some time.
|
||||
if status {
|
||||
status := "unknown"
|
||||
version := "unknown"
|
||||
chaos := "unknown"
|
||||
chaosVersion := "unknown"
|
||||
autoUpdate := "unknown"
|
||||
if statusMeta, ok := statuses[app.StackName()]; ok {
|
||||
if currentVersion, exists := statusMeta["version"]; exists {
|
||||
if currentVersion != "" {
|
||||
version = currentVersion
|
||||
}
|
||||
}
|
||||
if chaosDeploy, exists := statusMeta["chaos"]; exists {
|
||||
chaos = chaosDeploy
|
||||
}
|
||||
if chaosDeployVersion, exists := statusMeta["chaosVersion"]; exists {
|
||||
chaosVersion = chaosDeployVersion
|
||||
}
|
||||
if autoUpdateState, exists := statusMeta["autoUpdate"]; exists {
|
||||
autoUpdate = autoUpdateState
|
||||
}
|
||||
if statusMeta["status"] != "" {
|
||||
status = statusMeta["status"]
|
||||
}
|
||||
@ -153,7 +168,10 @@ can take some time.
|
||||
}
|
||||
|
||||
appStats.Status = status
|
||||
appStats.Chaos = chaos
|
||||
appStats.ChaosVersion = chaosVersion
|
||||
appStats.Version = version
|
||||
appStats.AutoUpdate = autoUpdate
|
||||
|
||||
var newUpdates []string
|
||||
if version != "unknown" {
|
||||
@ -223,7 +241,7 @@ can take some time.
|
||||
|
||||
tableCol := []string{"recipe", "domain"}
|
||||
if status {
|
||||
tableCol = append(tableCol, []string{"status", "version", "upgrade"}...)
|
||||
tableCol = append(tableCol, []string{"status", "chaos", "version", "upgrade", "autoupdate"}...)
|
||||
}
|
||||
|
||||
table := formatter.CreateTable(tableCol)
|
||||
@ -231,7 +249,13 @@ can take some time.
|
||||
for _, appStat := range serverStat.Apps {
|
||||
tableRow := []string{appStat.Recipe, appStat.Domain}
|
||||
if status {
|
||||
tableRow = append(tableRow, []string{appStat.Status, appStat.Version, appStat.Upgrade}...)
|
||||
chaosStatus := "unknown"
|
||||
if appStat.ChaosVersion != "unknown" {
|
||||
chaosStatus = appStat.Chaos + appStat.ChaosVersion
|
||||
} else {
|
||||
chaosStatus = appStat.Chaos
|
||||
}
|
||||
tableRow = append(tableRow, []string{appStat.Status, chaosStatus, appStat.Version, appStat.Upgrade, appStat.AutoUpdate}...)
|
||||
}
|
||||
table.Append(tableRow)
|
||||
}
|
||||
|
@ -183,6 +183,7 @@ recipes.
|
||||
config.ExposeAllEnv(stackName, compose, app.Env)
|
||||
config.SetRecipeLabel(compose, stackName, app.Recipe)
|
||||
config.SetChaosLabel(compose, stackName, internal.Chaos)
|
||||
config.SetChaosVersionLabel(compose, stackName, chosenDowngrade)
|
||||
config.SetUpdateLabel(compose, stackName, app.Env)
|
||||
|
||||
if !internal.Force {
|
||||
@ -191,7 +192,7 @@ recipes.
|
||||
}
|
||||
}
|
||||
|
||||
if err := stack.RunDeploy(cl, deployOpts, compose, app.StackName(), internal.DontWaitConverge); err != nil {
|
||||
if err := stack.RunDeploy(cl, deployOpts, compose, stackName, internal.DontWaitConverge); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -194,13 +194,14 @@ recipes.
|
||||
config.ExposeAllEnv(stackName, compose, app.Env)
|
||||
config.SetRecipeLabel(compose, stackName, app.Recipe)
|
||||
config.SetChaosLabel(compose, stackName, internal.Chaos)
|
||||
config.SetChaosVersionLabel(compose, stackName, chosenUpgrade)
|
||||
config.SetUpdateLabel(compose, stackName, app.Env)
|
||||
|
||||
if err := internal.NewVersionOverview(app, deployedVersion, chosenUpgrade, releaseNotes); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if err := stack.RunDeploy(cl, deployOpts, compose, app.StackName(), internal.DontWaitConverge); err != nil {
|
||||
if err := stack.RunDeploy(cl, deployOpts, compose, stackName, internal.DontWaitConverge); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ import (
|
||||
// DeployAction is the main command-line action for this package
|
||||
func DeployAction(c *cli.Context) error {
|
||||
app := ValidateApp(c)
|
||||
stackName := app.StackName()
|
||||
conf := runtime.New()
|
||||
|
||||
cl, err := client.New(app.Server)
|
||||
@ -47,9 +48,9 @@ func DeployAction(c *cli.Context) error {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
logrus.Debugf("checking whether %s is already deployed", app.StackName())
|
||||
logrus.Debugf("checking whether %s is already deployed", stackName)
|
||||
|
||||
isDeployed, deployedVersion, err := stack.IsDeployed(context.Background(), cl, app.StackName())
|
||||
isDeployed, deployedVersion, err := stack.IsDeployed(context.Background(), cl, stackName)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
@ -128,7 +129,7 @@ func DeployAction(c *cli.Context) error {
|
||||
}
|
||||
deployOpts := stack.Deploy{
|
||||
Composefiles: composeFiles,
|
||||
Namespace: app.StackName(),
|
||||
Namespace: stackName,
|
||||
Prune: false,
|
||||
ResolveImage: stack.ResolveImageAlways,
|
||||
}
|
||||
@ -136,10 +137,11 @@ func DeployAction(c *cli.Context) error {
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
config.ExposeAllEnv(app.StackName(), compose, app.Env)
|
||||
config.SetRecipeLabel(compose, app.StackName(), app.Recipe)
|
||||
config.SetChaosLabel(compose, app.StackName(), Chaos)
|
||||
config.SetUpdateLabel(compose, app.StackName(), app.Env)
|
||||
config.ExposeAllEnv(stackName, compose, app.Env)
|
||||
config.SetRecipeLabel(compose, stackName, app.Recipe)
|
||||
config.SetChaosLabel(compose, stackName, Chaos)
|
||||
config.SetChaosVersionLabel(compose, stackName, version)
|
||||
config.SetUpdateLabel(compose, stackName, app.Env)
|
||||
|
||||
if err := DeployOverview(app, version, "continue with deployment?"); err != nil {
|
||||
logrus.Fatal(err)
|
||||
|
@ -403,7 +403,25 @@ func GetAppStatuses(apps []App, MachineReadable bool) (map[string]map[string]str
|
||||
result["status"] = "deployed"
|
||||
}
|
||||
|
||||
labelKey := fmt.Sprintf("coop-cloud.%s.version", name)
|
||||
labelKey := fmt.Sprintf("coop-cloud.%s.chaos", name)
|
||||
chaos, ok := service.Spec.Labels[labelKey]
|
||||
if ok {
|
||||
result["chaos"] = chaos
|
||||
}
|
||||
|
||||
labelKey = fmt.Sprintf("coop-cloud.%s.chaos-version", name)
|
||||
if chaosVersion, ok := service.Spec.Labels[labelKey]; ok {
|
||||
result["chaosVersion"] = chaosVersion
|
||||
}
|
||||
|
||||
labelKey = fmt.Sprintf("coop-cloud.%s.autoupdate", name)
|
||||
if autoUpdate, ok := service.Spec.Labels[labelKey]; ok {
|
||||
result["autoUpdate"] = autoUpdate
|
||||
} else {
|
||||
result["autoUpdate"] = "false"
|
||||
}
|
||||
|
||||
labelKey = fmt.Sprintf("coop-cloud.%s.version", name)
|
||||
if version, ok := service.Spec.Labels[labelKey]; ok {
|
||||
result["version"] = version
|
||||
} else {
|
||||
@ -499,6 +517,17 @@ func SetChaosLabel(compose *composetypes.Config, stackName string, chaos bool) {
|
||||
}
|
||||
}
|
||||
|
||||
// SetChaosVersionLabel adds the label 'coop-cloud.${STACK_NAME}.chaos-version=$(GIT_COMMIT)' to the app container
|
||||
func SetChaosVersionLabel(compose *composetypes.Config, stackName string, chaosVersion string) {
|
||||
for _, service := range compose.Services {
|
||||
if service.Name == "app" {
|
||||
logrus.Debugf("set label 'coop-cloud.%s.chaos-version' to %v for %s", stackName, chaosVersion, stackName)
|
||||
labelKey := fmt.Sprintf("coop-cloud.%s.chaos-version", stackName)
|
||||
service.Deploy.Labels[labelKey] = chaosVersion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SetUpdateLabel adds env ENABLE_AUTO_UPDATE as label to enable/disable the
|
||||
// auto update process for this app. The default if this variable is not set is to disable
|
||||
// the auto update process.
|
||||
|
Loading…
Reference in New Issue
Block a user