feat: add --show-unchanged/-U option

This commit is contained in:
3wc
2025-09-08 11:21:44 -04:00
parent 5c659bae5f
commit 33aca42181
5 changed files with 39 additions and 10 deletions

View File

@ -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))
}