From 33aca421815f7edc43dbd11f9cc8b957f52a2bc4 Mon Sep 17 00:00:00 2001 From: 3wc <3wc@doesthisthing.work> Date: Mon, 8 Sep 2025 11:21:44 -0400 Subject: [PATCH] feat: add --show-unchanged/-U option --- cli/app/deploy.go | 12 ++++++++++-- cli/app/rollback.go | 12 ++++++++++-- cli/app/upgrade.go | 12 ++++++++++-- cli/internal/cli.go | 1 + pkg/deploy/utils.go | 12 ++++++++---- 5 files changed, 39 insertions(+), 10 deletions(-) diff --git a/cli/app/deploy.go b/cli/app/deploy.go index b01faba3..5b9f76aa 100644 --- a/cli/app/deploy.go +++ b/cli/app/deploy.go @@ -196,13 +196,13 @@ checkout as-is. Recipe commit hashes are also supported as values for } // Gather configs - configInfo, err := deploy.GatherConfigsForDeploy(cl, app, compose, app.Env) + configInfo, err := deploy.GatherConfigsForDeploy(cl, app, compose, app.Env, internal.ShowUnchanged) if err != nil { log.Fatal(err) } // Gather images - imageInfo, err := deploy.GatherImagesForDeploy(cl, app, compose) + imageInfo, err := deploy.GatherImagesForDeploy(cl, app, compose, internal.ShowUnchanged) if err != nil { log.Fatal(err) } @@ -393,4 +393,12 @@ func init() { false, i18n.G("deploy latest recipe version"), ) + + AppDeployCommand.Flags().BoolVarP( + &internal.ShowUnchanged, + i18n.G("show-unchanged"), + i18n.G("U"), + false, + i18n.G("show all configs & images, including unchanged ones"), + ) } diff --git a/cli/app/rollback.go b/cli/app/rollback.go index 1c4b46f8..9b58003f 100644 --- a/cli/app/rollback.go +++ b/cli/app/rollback.go @@ -192,13 +192,13 @@ beforehand. See "abra app backup" for more.`), } // Gather configs - configInfo, err := deploy.GatherConfigsForDeploy(cl, app, compose, app.Env) + configInfo, err := deploy.GatherConfigsForDeploy(cl, app, compose, app.Env, internal.ShowUnchanged) if err != nil { log.Fatal(err) } // Gather images - imageInfo, err := deploy.GatherImagesForDeploy(cl, app, compose) + imageInfo, err := deploy.GatherImagesForDeploy(cl, app, compose, internal.ShowUnchanged) if err != nil { log.Fatal(err) } @@ -362,4 +362,12 @@ func init() { false, i18n.G("disable converge logic checks"), ) + + AppRollbackCommand.Flags().BoolVarP( + &internal.ShowUnchanged, + i18n.G("show-unchanged"), + i18n.G("U"), + false, + i18n.G("show all configs & images, including unchanged ones"), + ) } diff --git a/cli/app/upgrade.go b/cli/app/upgrade.go index d04504fb..35064524 100644 --- a/cli/app/upgrade.go +++ b/cli/app/upgrade.go @@ -218,13 +218,13 @@ beforehand. See "abra app backup" for more.`), } // Gather configs - configInfo, err := deploy.GatherConfigsForDeploy(cl, app, compose, app.Env) + configInfo, err := deploy.GatherConfigsForDeploy(cl, app, compose, app.Env, internal.ShowUnchanged) if err != nil { log.Fatal(err) } // Gather images - imageInfo, err := deploy.GatherImagesForDeploy(cl, app, compose) + imageInfo, err := deploy.GatherImagesForDeploy(cl, app, compose, internal.ShowUnchanged) if err != nil { log.Fatal(err) } @@ -480,4 +480,12 @@ func init() { false, i18n.G("only show release notes"), ) + + AppUpgradeCommand.Flags().BoolVarP( + &internal.ShowUnchanged, + i18n.G("show-unchanged"), + i18n.G("U"), + false, + i18n.G("show all configs & images, including unchanged ones"), + ) } diff --git a/cli/internal/cli.go b/cli/internal/cli.go index 3e8844d2..86b73233 100644 --- a/cli/internal/cli.go +++ b/cli/internal/cli.go @@ -19,4 +19,5 @@ var ( Minor bool NoDomainChecks bool Patch bool + ShowUnchanged bool ) diff --git a/pkg/deploy/utils.go b/pkg/deploy/utils.go index 30ce4c77..2e67c325 100644 --- a/pkg/deploy/utils.go +++ b/pkg/deploy/utils.go @@ -157,7 +157,7 @@ func GatherSecretsForDeploy(cl *dockerClient.Client, app appPkg.App) ([]string, return secretInfo, nil } -func GatherConfigsForDeploy(cl *dockerClient.Client, app appPkg.App, compose *composetypes.Config, abraShEnv map[string]string) ([]string, error) { +func GatherConfigsForDeploy(cl *dockerClient.Client, app appPkg.App, compose *composetypes.Config, abraShEnv map[string]string, showUnchanged bool) ([]string, error) { // Get current configs from existing deployment currentConfigs, err := GetConfigsForStack(cl, app) if err != nil { @@ -182,7 +182,9 @@ func GatherConfigsForDeploy(cl *dockerClient.Client, app appPkg.App, compose *co if currentVersion, exists := currentConfigs[configName]; exists { if currentVersion == newVersion { - configInfo = append(configInfo, fmt.Sprintf("%s: %s (unchanged)", configName, newVersion)) + if (showUnchanged) { + configInfo = append(configInfo, fmt.Sprintf("%s: %s (unchanged)", configName, newVersion)) + } } else { configInfo = append(configInfo, fmt.Sprintf("%s: %s → %s", configName, currentVersion, newVersion)) } @@ -194,7 +196,7 @@ func GatherConfigsForDeploy(cl *dockerClient.Client, app appPkg.App, compose *co return configInfo, nil } -func GatherImagesForDeploy(cl *dockerClient.Client, app appPkg.App, compose *composetypes.Config) ([]string, error) { +func GatherImagesForDeploy(cl *dockerClient.Client, app appPkg.App, compose *composetypes.Config, showUnchanged bool) ([]string, error) { // Get current images from existing deployment currentImages, err := GetImagesForStack(cl, app) @@ -230,7 +232,9 @@ func GatherImagesForDeploy(cl *dockerClient.Client, app appPkg.App, compose *com for newImageName, newImageVersion := range newImages { if currentVersion, exists := currentImages[newImageName]; exists { if currentVersion == newImageVersion { - imageInfo = append(imageInfo, fmt.Sprintf("%s: %s (unchanged)", newImageName, newImageVersion)) + if showUnchanged { + imageInfo = append(imageInfo, fmt.Sprintf("%s: %s (unchanged)", newImageName, newImageVersion)) + } } else { imageInfo = append(imageInfo, fmt.Sprintf("%s: %s → %s", newImageName, currentVersion, newImageVersion)) }