forked from toolshed/abra
refactor: PR feedback
This commit is contained in:
@ -208,7 +208,6 @@ checkout as-is. Recipe commit hashes are also supported as values for
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Show deploy overview
|
// Show deploy overview
|
||||||
|
|
||||||
if err := internal.DeployOverview(
|
if err := internal.DeployOverview(
|
||||||
app,
|
app,
|
||||||
deployedVersion,
|
deployedVersion,
|
||||||
|
@ -39,11 +39,11 @@ func RemoveConfigs(cl *client.Client, ctx context.Context, configNames []string,
|
|||||||
return nil
|
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) {
|
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 {
|
|
||||||
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))
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"coopcloud.tech/abra/pkg/client"
|
"coopcloud.tech/abra/pkg/client"
|
||||||
"coopcloud.tech/abra/pkg/envfile"
|
"coopcloud.tech/abra/pkg/envfile"
|
||||||
"coopcloud.tech/abra/pkg/formatter"
|
"coopcloud.tech/abra/pkg/formatter"
|
||||||
|
"coopcloud.tech/abra/pkg/i18n"
|
||||||
"coopcloud.tech/abra/pkg/log"
|
"coopcloud.tech/abra/pkg/log"
|
||||||
"coopcloud.tech/abra/pkg/recipe"
|
"coopcloud.tech/abra/pkg/recipe"
|
||||||
"coopcloud.tech/abra/pkg/secret"
|
"coopcloud.tech/abra/pkg/secret"
|
||||||
@ -72,7 +73,7 @@ func GetConfigsForStack(cl *dockerClient.Client, app appPkg.App) (map[string]str
|
|||||||
} else {
|
} else {
|
||||||
// Just make sure the versions are the same..
|
// Just make sure the versions are the same..
|
||||||
if existingConfigVersion != configVersion {
|
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 {
|
} else {
|
||||||
// Just make sure the versions are the same..
|
// Just make sure the versions are the same..
|
||||||
if existingImageVersion != imageTag {
|
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) {
|
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
|
||||||
@ -154,32 +154,32 @@ func GatherConfigsForDeploy(cl *dockerClient.Client, app appPkg.App, compose *co
|
|||||||
return nil, err
|
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
|
// Get new configs from the compose specification
|
||||||
newConfigs := compose.Configs
|
newConfigs := compose.Configs
|
||||||
|
|
||||||
var configInfo []string
|
var configInfo []string
|
||||||
for configName := range newConfigs {
|
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"
|
versionKey := strings.ToUpper(configName) + "_VERSION"
|
||||||
newVersion, exists := abraShEnv[versionKey]
|
newVersion, exists := abraShEnv[versionKey]
|
||||||
if !exists {
|
if !exists {
|
||||||
log.Warnf("No version found for config %s", configName)
|
log.Warnf(i18n.G("no version found for config %s", configName))
|
||||||
configInfo = append(configInfo, fmt.Sprintf("%s: ? (missing version)", configName))
|
configInfo = append(configInfo, i18n.G("%s: ? (missing version)", configName))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if currentVersion, exists := currentConfigs[configName]; exists {
|
if currentVersion, exists := currentConfigs[configName]; exists {
|
||||||
if currentVersion == newVersion {
|
if currentVersion == newVersion {
|
||||||
if showUnchanged {
|
if showUnchanged {
|
||||||
configInfo = append(configInfo, fmt.Sprintf("%s: %s (unchanged)", configName, newVersion))
|
configInfo = append(configInfo, i18n.G("%s: %s (unchanged)", configName, newVersion))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
configInfo = append(configInfo, fmt.Sprintf("%s: %s → %s", configName, currentVersion, newVersion))
|
configInfo = append(configInfo, i18n.G("%s: %s → %s", configName, currentVersion, newVersion))
|
||||||
}
|
}
|
||||||
} else {
|
} 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) {
|
func GatherImagesForDeploy(cl *dockerClient.Client, app appPkg.App, compose *composetypes.Config, showUnchanged bool) ([]string, error) {
|
||||||
|
|
||||||
// Get current images from existing deployment
|
// Get current images from existing deployment
|
||||||
currentImages, err := GetImagesForStack(cl, app)
|
currentImages, err := GetImagesForStack(cl, app)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("Deployed images: %v", currentImages)
|
log.Debugf(i18n.G("deployed images: %v", currentImages))
|
||||||
|
|
||||||
// Proposed new images from the compose files
|
// Proposed new images from the compose files
|
||||||
newImages := make(map[string]string)
|
newImages := make(map[string]string)
|
||||||
@ -215,24 +214,24 @@ func GatherImagesForDeploy(cl *dockerClient.Client, app appPkg.App, compose *com
|
|||||||
} else {
|
} else {
|
||||||
// Just make sure the versions are the same..
|
// Just make sure the versions are the same..
|
||||||
if existingImageVersion != imageTag {
|
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
|
var imageInfo []string
|
||||||
for newImageName, newImageVersion := range newImages {
|
for newImageName, newImageVersion := range newImages {
|
||||||
if currentVersion, exists := currentImages[newImageName]; exists {
|
if currentVersion, exists := currentImages[newImageName]; exists {
|
||||||
if currentVersion == newImageVersion {
|
if currentVersion == newImageVersion {
|
||||||
if showUnchanged {
|
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 {
|
} 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 {
|
} 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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user