style: 4matting

This commit is contained in:
3wc
2025-09-02 13:59:30 -04:00
parent 40b5c5cd63
commit bf68ec56a3
3 changed files with 53 additions and 54 deletions

View File

@ -234,7 +234,6 @@ beforehand. See "abra app backup" for more.`),
log.Fatal(err)
}
if showReleaseNotes {
fmt.Print(upgradeReleaseNotes)
return

View File

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

View File

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