style: 4matting
This commit is contained in:
@ -234,7 +234,6 @@ beforehand. See "abra app backup" for more.`),
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if showReleaseNotes {
|
if showReleaseNotes {
|
||||||
fmt.Print(upgradeReleaseNotes)
|
fmt.Print(upgradeReleaseNotes)
|
||||||
return
|
return
|
||||||
|
@ -40,10 +40,10 @@ func RemoveConfigs(cl *client.Client, ctx context.Context, configNames []string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetConfigNameAndVersion(fullName string, stackName string) (string, string, error) {
|
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 {
|
if lastUnderscore := strings.LastIndex(name, "_"); lastUnderscore != -1 {
|
||||||
return name[0:lastUnderscore], name[lastUnderscore+1:], nil
|
return name[0:lastUnderscore], name[lastUnderscore+1:], nil
|
||||||
} else {
|
} 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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@ import (
|
|||||||
"coopcloud.tech/abra/pkg/log"
|
"coopcloud.tech/abra/pkg/log"
|
||||||
"coopcloud.tech/abra/pkg/secret"
|
"coopcloud.tech/abra/pkg/secret"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
|
||||||
composetypes "github.com/docker/cli/cli/compose/types"
|
composetypes "github.com/docker/cli/cli/compose/types"
|
||||||
|
"github.com/docker/docker/api/types/swarm"
|
||||||
dockerClient "github.com/docker/docker/client"
|
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) {
|
func GetImageNameAndTag(imageName string) (string, string, error) {
|
||||||
imageParts := regexp.MustCompile("^([^:]*):([^@]*)@?").FindSubmatch([]byte(imageName))
|
imageParts := regexp.MustCompile("^([^:]*):([^@]*)@?").FindSubmatch([]byte(imageName))
|
||||||
|
|
||||||
if len(imageParts) == 0 {
|
if len(imageParts) == 0 {
|
||||||
return "", "", errors.New("can't determine image version for image '%s'")
|
return "", "", errors.New("can't determine image version for image '%s'")
|
||||||
}
|
}
|
||||||
|
|
||||||
imageBaseName := string(imageParts[1])
|
imageBaseName := string(imageParts[1])
|
||||||
imageTag := string(imageParts[2])
|
imageTag := string(imageParts[2])
|
||||||
|
|
||||||
return imageBaseName, imageTag, nil
|
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) {
|
func GatherSecretsForDeploy(cl *dockerClient.Client, app appPkg.App) ([]string, error) {
|
||||||
|
|
||||||
secStats, err := secret.PollSecretsStatus(cl, app)
|
secStats, err := secret.PollSecretsStatus(cl, app)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var secretInfo []string
|
var secretInfo []string
|
||||||
|
|
||||||
// Sort secrets to ensure reproducible output
|
// Sort secrets to ensure reproducible output
|
||||||
sort.Slice(secStats, func(i, j int) bool {
|
sort.Slice(secStats, func(i, j int) bool {
|
||||||
return secStats[i].LocalName < secStats[j].LocalName
|
return secStats[i].LocalName < secStats[j].LocalName
|
||||||
})
|
})
|
||||||
for _, secStat := range secStats {
|
for _, secStat := range secStats {
|
||||||
secretInfo = append(secretInfo, fmt.Sprintf("%s: %s", secStat.LocalName, secStat.Version))
|
secretInfo = append(secretInfo, fmt.Sprintf("%s: %s", secStat.LocalName, secStat.Version))
|
||||||
}
|
}
|
||||||
return secretInfo, nil
|
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) ([]string, error) {
|
||||||
// Get current configs from existing deployment
|
// Get current configs from existing deployment
|
||||||
currentConfigs, err := GetConfigsForStack(cl, app)
|
currentConfigs, err := GetConfigsForStack(cl, app)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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)
|
if currentVersion, exists := currentConfigs[configName]; exists {
|
||||||
|
if currentVersion == newVersion {
|
||||||
// Get new configs from the compose specification
|
configInfo = append(configInfo, fmt.Sprintf("%s: %s (unchanged)", configName, newVersion))
|
||||||
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))
|
|
||||||
}
|
|
||||||
} else {
|
} 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
|
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
|
// Get current images from existing deployment
|
||||||
currentImages, err := GetImagesForStack(cl, app)
|
currentImages, err := GetImagesForStack(cl, app)
|
||||||
|
Reference in New Issue
Block a user