Working config version comparison
This commit is contained in:
@ -208,15 +208,44 @@ checkout as-is. Recipe commit hashes are also supported as values for
|
||||
secretInfo = append(secretInfo, fmt.Sprintf("%s: %s", secStat.LocalName, secStat.Version))
|
||||
}
|
||||
|
||||
configNames, err := client.GetConfigNamesForStack(cl, context.Background(), app.StackName())
|
||||
// Get current configs from existing deployment
|
||||
currentConfigNames, err := client.GetConfigNamesForStack(cl, context.Background(), app.StackName())
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
log.Infof("Config names: %v", currentConfigNames)
|
||||
|
||||
// Create map of current config base names to versions
|
||||
currentConfigs := make(map[string]string)
|
||||
for _, configName := range currentConfigNames {
|
||||
baseName, version := client.GetConfigNameAndVersion(configName, app.StackName())
|
||||
currentConfigs[baseName] = version
|
||||
}
|
||||
|
||||
log.Infof("Configs: %v", currentConfigs)
|
||||
|
||||
// Get new configs from the compose specification
|
||||
newConfigs := compose.Configs
|
||||
|
||||
var configInfo []string
|
||||
for _, config := range configNames {
|
||||
name, version := client.GetConfigNameAndVersion(config, app.StackName())
|
||||
configInfo = append(configInfo, fmt.Sprintf("%s: %s", name, version))
|
||||
for configName := range newConfigs {
|
||||
log.Debugf("Searching for abra.sh version for %s", configName)
|
||||
versionKey := strings.ToUpper(configName) + "_VERSION"
|
||||
newVersion, exists := abraShEnv[versionKey]
|
||||
if !exists {
|
||||
log.Fatalf("No version found for config %s", configName)
|
||||
}
|
||||
|
||||
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 {
|
||||
configInfo = append(configInfo, fmt.Sprintf("%s: %s (new)", configName, newVersion))
|
||||
}
|
||||
}
|
||||
|
||||
var imageInfo []string
|
||||
|
Reference in New Issue
Block a user