feat: roll out pre-deploy changes to rollback and upgrade

This commit is contained in:
3wc
2025-09-02 13:58:45 -04:00
parent 14d3f1f669
commit 40b5c5cd63
3 changed files with 24 additions and 51 deletions

View File

@ -1,7 +1,6 @@
package app
import (
"context"
"errors"
"strings"
@ -9,6 +8,7 @@ import (
appPkg "coopcloud.tech/abra/pkg/app"
"coopcloud.tech/abra/pkg/autocomplete"
"coopcloud.tech/abra/pkg/config"
"coopcloud.tech/abra/pkg/deploy"
"coopcloud.tech/abra/pkg/envfile"
"coopcloud.tech/abra/pkg/formatter"
"coopcloud.tech/abra/pkg/i18n"
@ -20,7 +20,6 @@ import (
"coopcloud.tech/abra/pkg/client"
"coopcloud.tech/abra/pkg/log"
"github.com/AlecAivazis/survey/v2"
"github.com/docker/docker/api/types"
"github.com/spf13/cobra"
)
@ -192,36 +191,24 @@ beforehand. See "abra app backup" for more.`),
}
appPkg.SetUpdateLabel(compose, stackName, app.Env)
filters, err := app.Filters(false, false)
// Gather secrets
secretInfo, err := deploy.GatherSecretsForDeploy(cl, app)
if err != nil {
log.Fatal(err)
}
secretList, err := cl.SecretList(context.Background(), types.SecretListOptions{Filters: filters})
// Gather configs
configInfo, err := deploy.GatherConfigsForDeploy(cl, app, compose, abraShEnv)
if err != nil {
log.Fatal(err)
}
var secretStrings []string
for _, cont := range secretList {
secretStrings = append(secretStrings, cont.Spec.Name)
}
configList, err := cl.ConfigList(context.Background(), types.ConfigListOptions{Filters: filters})
// Gather images
imageInfo, err := deploy.GatherImagesForDeploy(cl, app, compose)
if err != nil {
log.Fatal(err)
}
var configStrings []string
for _, config := range configList {
configStrings = append(configStrings, config.Spec.Name)
}
var imageStrings []string
for _, service := range compose.Services {
imageStrings = append(imageStrings, service.Image)
}
// NOTE(d1): no release notes implemeneted for rolling back
if err := internal.DeployOverview(
app,
@ -229,9 +216,9 @@ beforehand. See "abra app backup" for more.`),
chosenDowngrade,
"",
downgradeWarnMessages,
strings.Join(secretStrings, "\n"),
strings.Join(configStrings, "\n"),
strings.Join(imageStrings, "\n"),
strings.Join(secretInfo, "\n"),
strings.Join(configInfo, "\n"),
strings.Join(imageInfo, "\n"),
); err != nil {
log.Fatal(err)
}