From 076d522b1a86cf579ecfbb7f5d670133788f4dd2 Mon Sep 17 00:00:00 2001 From: 3wc <3wc@doesthisthing.work> Date: Tue, 9 Sep 2025 13:18:26 -0400 Subject: [PATCH] refactor: PR feedback --- cli/app/deploy.go | 1 - pkg/client/configs.go | 4 ++-- pkg/deploy/utils.go | 33 ++++++++++++++++----------------- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/cli/app/deploy.go b/cli/app/deploy.go index ff5e25ab5..fa0c14be1 100644 --- a/cli/app/deploy.go +++ b/cli/app/deploy.go @@ -208,7 +208,6 @@ checkout as-is. Recipe commit hashes are also supported as values for } // Show deploy overview - if err := internal.DeployOverview( app, deployedVersion, diff --git a/pkg/client/configs.go b/pkg/client/configs.go index f102467f5..406a32ad1 100644 --- a/pkg/client/configs.go +++ b/pkg/client/configs.go @@ -39,11 +39,11 @@ func RemoveConfigs(cl *client.Client, ctx context.Context, configNames []string, return nil } +// GetConfigNameAndVersion parses a full config name like `app_example_com_someconf_v1` to extract name and version, ("someconf", "v1") func GetConfigNameAndVersion(fullName string, stackName string) (string, string, error) { name := strings.TrimPrefix(fullName, stackName+"_") if lastUnderscore := strings.LastIndex(name, "_"); lastUnderscore != -1 { return name[0:lastUnderscore], name[lastUnderscore+1:], nil - } else { - return "", "", errors.New(i18n.G("can't parse version from config '%s'", fullName)) } + return "", "", errors.New(i18n.G("can't parse version from config '%s'", fullName)) } diff --git a/pkg/deploy/utils.go b/pkg/deploy/utils.go index 917dfdc22..0cb692140 100644 --- a/pkg/deploy/utils.go +++ b/pkg/deploy/utils.go @@ -10,6 +10,7 @@ import ( "coopcloud.tech/abra/pkg/client" "coopcloud.tech/abra/pkg/envfile" "coopcloud.tech/abra/pkg/formatter" + "coopcloud.tech/abra/pkg/i18n" "coopcloud.tech/abra/pkg/log" "coopcloud.tech/abra/pkg/recipe" "coopcloud.tech/abra/pkg/secret" @@ -72,7 +73,7 @@ func GetConfigsForStack(cl *dockerClient.Client, app appPkg.App) (map[string]str } else { // Just make sure the versions are the same.. if existingConfigVersion != configVersion { - log.Warnf("different versions for config '%s', '%s' and %s'", configBaseName, existingConfigVersion, configVersion) + log.Warnf(i18n.G( "different versions for config '%s', '%s' and %s'", configBaseName, existingConfigVersion, configVersion)) } } } @@ -119,7 +120,7 @@ func GetImagesForStack(cl *dockerClient.Client, app appPkg.App) (map[string]stri } else { // Just make sure the versions are the same.. if existingImageVersion != imageTag { - log.Warnf("different versions for image '%s', '%s' and %s'", imageBaseName, existingImageVersion, imageTag) + log.Warnf(i18n.G("different versions for image '%s', '%s' and %s'", imageBaseName, existingImageVersion, imageTag)) } } } @@ -129,7 +130,6 @@ func GetImagesForStack(cl *dockerClient.Client, app appPkg.App) (map[string]stri } func GatherSecretsForDeploy(cl *dockerClient.Client, app appPkg.App) ([]string, error) { - secStats, err := secret.PollSecretsStatus(cl, app) if err != nil { return nil, err @@ -154,32 +154,32 @@ func GatherConfigsForDeploy(cl *dockerClient.Client, app appPkg.App, compose *co return nil, err } - log.Debugf("Deployed config names: %v", currentConfigs) + log.Debugf(i18n.G("deployed config names: %v", currentConfigs)) // Get new configs from the compose specification newConfigs := compose.Configs var configInfo []string for configName := range newConfigs { - log.Debugf("Searching abra.sh for version for %s", configName) + log.Debugf(i18n.G("searching abra.sh for version for %s", configName)) versionKey := strings.ToUpper(configName) + "_VERSION" newVersion, exists := abraShEnv[versionKey] if !exists { - log.Warnf("No version found for config %s", configName) - configInfo = append(configInfo, fmt.Sprintf("%s: ? (missing version)", configName)) + log.Warnf(i18n.G("no version found for config %s", configName)) + configInfo = append(configInfo, i18n.G("%s: ? (missing version)", configName)) continue } if currentVersion, exists := currentConfigs[configName]; exists { if currentVersion == newVersion { if showUnchanged { - configInfo = append(configInfo, fmt.Sprintf("%s: %s (unchanged)", configName, newVersion)) + configInfo = append(configInfo, i18n.G("%s: %s (unchanged)", configName, newVersion)) } } else { - configInfo = append(configInfo, fmt.Sprintf("%s: %s → %s", configName, currentVersion, newVersion)) + configInfo = append(configInfo, i18n.G("%s: %s → %s", configName, currentVersion, newVersion)) } } else { - configInfo = append(configInfo, fmt.Sprintf("%s: %s (new)", configName, newVersion)) + configInfo = append(configInfo, i18n.G("%s: %s (new)", configName, newVersion)) } } @@ -187,14 +187,13 @@ func GatherConfigsForDeploy(cl *dockerClient.Client, app appPkg.App, compose *co } 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) if err != nil { return nil, err } - log.Debugf("Deployed images: %v", currentImages) + log.Debugf(i18n.G("deployed images: %v", currentImages)) // Proposed new images from the compose files newImages := make(map[string]string) @@ -215,24 +214,24 @@ func GatherImagesForDeploy(cl *dockerClient.Client, app appPkg.App, compose *com } else { // Just make sure the versions are the same.. if existingImageVersion != imageTag { - log.Warnf("different versions for image '%s', '%s' and %s'", imageBaseName, existingImageVersion, imageTag) + log.Warnf(i18n.G("different versions for image '%s', '%s' and %s'", imageBaseName, existingImageVersion, imageTag)) } } } - log.Debugf("Proposed images: %v", newImages) + log.Debugf(i18n.G("proposed images: %v", newImages)) var imageInfo []string for newImageName, newImageVersion := range newImages { if currentVersion, exists := currentImages[newImageName]; exists { if currentVersion == newImageVersion { if showUnchanged { - imageInfo = append(imageInfo, fmt.Sprintf("%s: %s (unchanged)", formatter.StripTagMeta(newImageName), newImageVersion)) + imageInfo = append(imageInfo, i18n.G("%s: %s (unchanged)", formatter.StripTagMeta(newImageName), newImageVersion)) } } else { - imageInfo = append(imageInfo, fmt.Sprintf("%s: %s → %s", formatter.StripTagMeta(newImageName), currentVersion, newImageVersion)) + imageInfo = append(imageInfo, i18n.G("%s: %s → %s", formatter.StripTagMeta(newImageName), currentVersion, newImageVersion)) } } else { - imageInfo = append(imageInfo, fmt.Sprintf("%s: %s (new)", formatter.StripTagMeta(newImageName), newImageVersion)) + imageInfo = append(imageInfo, i18n.G("%s: %s (new)", formatter.StripTagMeta(newImageName), newImageVersion)) } }