style: 4matting
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user