Roll out pre-deploy changes to rollback and upgrade
This commit is contained in:
		@ -227,8 +227,6 @@ checkout as-is. Recipe commit hashes are also supported as values for
 | 
			
		||||
		); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
		// FIXME: just for debugging
 | 
			
		||||
		return
 | 
			
		||||
 | 
			
		||||
		stack.WaitTimeout, err = appPkg.GetTimeoutFromLabel(compose, stackName)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -7,11 +7,11 @@ import (
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/app"
 | 
			
		||||
	appPkg "coopcloud.tech/abra/pkg/app"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/client"
 | 
			
		||||
	"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"
 | 
			
		||||
@ -21,7 +21,6 @@ import (
 | 
			
		||||
	stack "coopcloud.tech/abra/pkg/upstream/stack"
 | 
			
		||||
	"coopcloud.tech/tagcmp"
 | 
			
		||||
	"github.com/AlecAivazis/survey/v2"
 | 
			
		||||
	"github.com/docker/docker/api/types"
 | 
			
		||||
	dockerClient "github.com/docker/docker/client"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
@ -217,35 +216,24 @@ beforehand. See "abra app backup" for more.`),
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		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)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if showReleaseNotes {
 | 
			
		||||
			fmt.Print(upgradeReleaseNotes)
 | 
			
		||||
@ -265,9 +253,9 @@ beforehand. See "abra app backup" for more.`),
 | 
			
		||||
			chosenUpgrade,
 | 
			
		||||
			upgradeReleaseNotes,
 | 
			
		||||
			upgradeWarnMessages,
 | 
			
		||||
			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)
 | 
			
		||||
		}
 | 
			
		||||
@ -345,7 +333,7 @@ func chooseUpgrade(
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func getReleaseNotes(
 | 
			
		||||
	app app.App,
 | 
			
		||||
	app appPkg.App,
 | 
			
		||||
	versions []string,
 | 
			
		||||
	chosenUpgrade string,
 | 
			
		||||
	deployMeta stack.DeployMeta,
 | 
			
		||||
@ -390,7 +378,7 @@ func getReleaseNotes(
 | 
			
		||||
 | 
			
		||||
// ensureUpgradesAvailable ensures that there are available upgrades.
 | 
			
		||||
func ensureUpgradesAvailable(
 | 
			
		||||
	app app.App,
 | 
			
		||||
	app appPkg.App,
 | 
			
		||||
	versions []string,
 | 
			
		||||
	availableUpgrades *[]string,
 | 
			
		||||
	deployMeta stack.DeployMeta,
 | 
			
		||||
@ -422,7 +410,7 @@ func ensureUpgradesAvailable(
 | 
			
		||||
// validateUpgradeVersionArg validates the specific version.
 | 
			
		||||
func validateUpgradeVersionArg(
 | 
			
		||||
	specificVersion string,
 | 
			
		||||
	app app.App,
 | 
			
		||||
	app appPkg.App,
 | 
			
		||||
	deployMeta stack.DeployMeta,
 | 
			
		||||
) error {
 | 
			
		||||
	parsedSpecificVersion, err := tagcmp.Parse(specificVersion)
 | 
			
		||||
@ -449,7 +437,7 @@ func validateUpgradeVersionArg(
 | 
			
		||||
 | 
			
		||||
// ensureDeployed ensures the app is deployed and if so, returns deployment
 | 
			
		||||
// meta info.
 | 
			
		||||
func ensureDeployed(cl *dockerClient.Client, app app.App) (stack.DeployMeta, error) {
 | 
			
		||||
func ensureDeployed(cl *dockerClient.Client, app appPkg.App) (stack.DeployMeta, error) {
 | 
			
		||||
	log.Debug(i18n.G("checking whether %s is already deployed", app.StackName()))
 | 
			
		||||
 | 
			
		||||
	deployMeta, err := stack.IsDeployed(context.Background(), cl, app.StackName())
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user