diff --git a/cli/app/upgrade.go b/cli/app/upgrade.go index 9b1a05f3..9cf5cfdd 100644 --- a/cli/app/upgrade.go +++ b/cli/app/upgrade.go @@ -234,7 +234,6 @@ beforehand. See "abra app backup" for more.`), log.Fatal(err) } - if showReleaseNotes { fmt.Print(upgradeReleaseNotes) return diff --git a/pkg/client/configs.go b/pkg/client/configs.go index 22c693c8..f102467f 100644 --- a/pkg/client/configs.go +++ b/pkg/client/configs.go @@ -40,10 +40,10 @@ func RemoveConfigs(cl *client.Client, ctx context.Context, configNames []string, } func GetConfigNameAndVersion(fullName string, stackName string) (string, string, error) { - name := strings.TrimPrefix(fullName, stackName + "_") + 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 f447e4ec..bd7a803a 100644 --- a/pkg/deploy/utils.go +++ b/pkg/deploy/utils.go @@ -13,8 +13,8 @@ import ( "coopcloud.tech/abra/pkg/log" "coopcloud.tech/abra/pkg/secret" - "github.com/docker/docker/api/types/swarm" composetypes "github.com/docker/cli/cli/compose/types" + "github.com/docker/docker/api/types/swarm" dockerClient "github.com/docker/docker/client" ) @@ -56,7 +56,7 @@ func GetConfigsForStack(cl *dockerClient.Client, app appPkg.App) (map[string]str // Just make sure the versions are the same.. if existingConfigVersion != configVersion { log.Warnf("different versions for config '%s', '%s' and %s'", configBaseName, existingConfigVersion, configVersion) - } + } } } } @@ -66,14 +66,14 @@ func GetConfigsForStack(cl *dockerClient.Client, app appPkg.App) (map[string]str } func GetImageNameAndTag(imageName string) (string, string, error) { - imageParts := regexp.MustCompile("^([^:]*):([^@]*)@?").FindSubmatch([]byte(imageName)) + imageParts := regexp.MustCompile("^([^:]*):([^@]*)@?").FindSubmatch([]byte(imageName)) - if len(imageParts) == 0 { - return "", "", errors.New("can't determine image version for image '%s'") - } + if len(imageParts) == 0 { + return "", "", errors.New("can't determine image version for image '%s'") + } - imageBaseName := string(imageParts[1]) - imageTag := string(imageParts[2]) + imageBaseName := string(imageParts[1]) + imageTag := string(imageParts[2]) return imageBaseName, imageTag, nil } @@ -113,7 +113,7 @@ func GetImagesForStack(cl *dockerClient.Client, app appPkg.App) (map[string]stri // Just make sure the versions are the same.. if existingImageVersion != imageTag { log.Warnf("different versions for image '%s', '%s' and %s'", imageBaseName, existingImageVersion, imageTag) - } + } } } } @@ -123,61 +123,61 @@ 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 - } + secStats, err := secret.PollSecretsStatus(cl, app) + if err != nil { + return nil, err + } - var secretInfo []string + var secretInfo []string - // Sort secrets to ensure reproducible output - sort.Slice(secStats, func(i, j int) bool { - return secStats[i].LocalName < secStats[j].LocalName - }) - for _, secStat := range secStats { - secretInfo = append(secretInfo, fmt.Sprintf("%s: %s", secStat.LocalName, secStat.Version)) - } + // Sort secrets to ensure reproducible output + sort.Slice(secStats, func(i, j int) bool { + return secStats[i].LocalName < secStats[j].LocalName + }) + for _, secStat := range secStats { + secretInfo = append(secretInfo, fmt.Sprintf("%s: %s", secStat.LocalName, secStat.Version)) + } return secretInfo, nil } func GatherConfigsForDeploy(cl *dockerClient.Client, app appPkg.App, compose *composetypes.Config, abraShEnv map[string]string) ([]string, error) { - // Get current configs from existing deployment - currentConfigs, err := GetConfigsForStack(cl, app) - if err != nil { - return nil, err + // Get current configs from existing deployment + currentConfigs, err := GetConfigsForStack(cl, app) + if err != nil { + return nil, err + } + + log.Debugf("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) + 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)) + continue } - log.Debugf("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) - 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)) - continue - } - - if currentVersion, exists := currentConfigs[configName]; exists { - if currentVersion == newVersion { - configInfo = append(configInfo, fmt.Sprintf("%s: %s (unchanged)", configName, newVersion)) - } else { - configInfo = append(configInfo, fmt.Sprintf("%s: %s → %s", configName, currentVersion, newVersion)) - } + if currentVersion, exists := currentConfigs[configName]; exists { + if currentVersion == newVersion { + configInfo = append(configInfo, fmt.Sprintf("%s: %s (unchanged)", configName, newVersion)) } else { - configInfo = append(configInfo, fmt.Sprintf("%s: %s (new)", configName, newVersion)) + configInfo = append(configInfo, fmt.Sprintf("%s: %s → %s", configName, currentVersion, newVersion)) } - } + } else { + configInfo = append(configInfo, fmt.Sprintf("%s: %s (new)", configName, newVersion)) + } + } 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) ([]string, error) { // Get current images from existing deployment currentImages, err := GetImagesForStack(cl, app) @@ -204,7 +204,7 @@ func GatherImagesForDeploy(cl *dockerClient.Client, app appPkg.App, compose *com // 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.Infof("Proposed images: %v", newImages)