forked from toolshed/abra
		
	WIP: Initial stab at secrets/configs/images
This commit is contained in:
		@ -22,6 +22,7 @@ import (
 | 
				
			|||||||
	"coopcloud.tech/abra/pkg/upstream/stack"
 | 
						"coopcloud.tech/abra/pkg/upstream/stack"
 | 
				
			||||||
	dockerClient "github.com/docker/docker/client"
 | 
						dockerClient "github.com/docker/docker/client"
 | 
				
			||||||
	"github.com/spf13/cobra"
 | 
						"github.com/spf13/cobra"
 | 
				
			||||||
 | 
						"github.com/docker/docker/api/types"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// translators: `abra app deploy` aliases. use a comma separated list of aliases with
 | 
					// translators: `abra app deploy` aliases. use a comma separated list of aliases with
 | 
				
			||||||
@ -194,15 +195,49 @@ checkout as-is. Recipe commit hashes are also supported as values for
 | 
				
			|||||||
			deployedVersion = deployMeta.Version
 | 
								deployedVersion = deployMeta.Version
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							filters, err := app.Filters(false, false)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								log.Fatal(err)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							secretList, err := cl.SecretList(context.Background(), types.SecretListOptions{Filters: filters})
 | 
				
			||||||
 | 
							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})
 | 
				
			||||||
 | 
							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 err := internal.DeployOverview(
 | 
							if err := internal.DeployOverview(
 | 
				
			||||||
			app,
 | 
								app,
 | 
				
			||||||
			deployedVersion,
 | 
								deployedVersion,
 | 
				
			||||||
			toDeployVersion,
 | 
								toDeployVersion,
 | 
				
			||||||
			"",
 | 
								"",
 | 
				
			||||||
			deployWarnMessages,
 | 
								deployWarnMessages,
 | 
				
			||||||
 | 
								strings.Join(secretStrings, "\n"),
 | 
				
			||||||
 | 
								strings.Join(configStrings, "\n"),
 | 
				
			||||||
 | 
								strings.Join(imageStrings, "\n"),
 | 
				
			||||||
		); err != nil {
 | 
							); err != nil {
 | 
				
			||||||
			log.Fatal(err)
 | 
								log.Fatal(err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		stack.WaitTimeout, err = appPkg.GetTimeoutFromLabel(compose, stackName)
 | 
							stack.WaitTimeout, err = appPkg.GetTimeoutFromLabel(compose, stackName)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,7 @@
 | 
				
			|||||||
package app
 | 
					package app
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"context"
 | 
				
			||||||
	"errors"
 | 
						"errors"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -19,6 +20,7 @@ import (
 | 
				
			|||||||
	"coopcloud.tech/abra/pkg/client"
 | 
						"coopcloud.tech/abra/pkg/client"
 | 
				
			||||||
	"coopcloud.tech/abra/pkg/log"
 | 
						"coopcloud.tech/abra/pkg/log"
 | 
				
			||||||
	"github.com/AlecAivazis/survey/v2"
 | 
						"github.com/AlecAivazis/survey/v2"
 | 
				
			||||||
 | 
						"github.com/docker/docker/api/types"
 | 
				
			||||||
	"github.com/spf13/cobra"
 | 
						"github.com/spf13/cobra"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -190,6 +192,36 @@ beforehand. See "abra app backup" for more.`),
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		appPkg.SetUpdateLabel(compose, stackName, app.Env)
 | 
							appPkg.SetUpdateLabel(compose, stackName, app.Env)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							filters, err := app.Filters(false, false)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								log.Fatal(err)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							secretList, err := cl.SecretList(context.Background(), types.SecretListOptions{Filters: filters})
 | 
				
			||||||
 | 
							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})
 | 
				
			||||||
 | 
							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
 | 
							// NOTE(d1): no release notes implemeneted for rolling back
 | 
				
			||||||
		if err := internal.DeployOverview(
 | 
							if err := internal.DeployOverview(
 | 
				
			||||||
			app,
 | 
								app,
 | 
				
			||||||
@ -197,6 +229,9 @@ beforehand. See "abra app backup" for more.`),
 | 
				
			|||||||
			chosenDowngrade,
 | 
								chosenDowngrade,
 | 
				
			||||||
			"",
 | 
								"",
 | 
				
			||||||
			downgradeWarnMessages,
 | 
								downgradeWarnMessages,
 | 
				
			||||||
 | 
								strings.Join(secretStrings, "\n"),
 | 
				
			||||||
 | 
								strings.Join(configStrings, "\n"),
 | 
				
			||||||
 | 
								strings.Join(imageStrings, "\n"),
 | 
				
			||||||
		); err != nil {
 | 
							); err != nil {
 | 
				
			||||||
			log.Fatal(err)
 | 
								log.Fatal(err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
				
			|||||||
@ -71,6 +71,9 @@ Passing "--prune/-p" does not remove those volumes.`),
 | 
				
			|||||||
			config.NO_DOMAIN_DEFAULT,
 | 
								config.NO_DOMAIN_DEFAULT,
 | 
				
			||||||
			"",
 | 
								"",
 | 
				
			||||||
			nil,
 | 
								nil,
 | 
				
			||||||
 | 
								"",
 | 
				
			||||||
 | 
								"",
 | 
				
			||||||
 | 
								"",
 | 
				
			||||||
		); err != nil {
 | 
							); err != nil {
 | 
				
			||||||
			log.Fatal(err)
 | 
								log.Fatal(err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
				
			|||||||
@ -21,6 +21,7 @@ import (
 | 
				
			|||||||
	stack "coopcloud.tech/abra/pkg/upstream/stack"
 | 
						stack "coopcloud.tech/abra/pkg/upstream/stack"
 | 
				
			||||||
	"coopcloud.tech/tagcmp"
 | 
						"coopcloud.tech/tagcmp"
 | 
				
			||||||
	"github.com/AlecAivazis/survey/v2"
 | 
						"github.com/AlecAivazis/survey/v2"
 | 
				
			||||||
 | 
						"github.com/docker/docker/api/types"
 | 
				
			||||||
	dockerClient "github.com/docker/docker/client"
 | 
						dockerClient "github.com/docker/docker/client"
 | 
				
			||||||
	"github.com/spf13/cobra"
 | 
						"github.com/spf13/cobra"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@ -216,6 +217,36 @@ beforehand. See "abra app backup" for more.`),
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							filters, err := app.Filters(false, false)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								log.Fatal(err)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							secretList, err := cl.SecretList(context.Background(), types.SecretListOptions{Filters: filters})
 | 
				
			||||||
 | 
							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})
 | 
				
			||||||
 | 
							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 {
 | 
							if showReleaseNotes {
 | 
				
			||||||
			fmt.Print(upgradeReleaseNotes)
 | 
								fmt.Print(upgradeReleaseNotes)
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
@ -234,6 +265,9 @@ beforehand. See "abra app backup" for more.`),
 | 
				
			|||||||
			chosenUpgrade,
 | 
								chosenUpgrade,
 | 
				
			||||||
			upgradeReleaseNotes,
 | 
								upgradeReleaseNotes,
 | 
				
			||||||
			upgradeWarnMessages,
 | 
								upgradeWarnMessages,
 | 
				
			||||||
 | 
								strings.Join(secretStrings, "\n"),
 | 
				
			||||||
 | 
								strings.Join(configStrings, "\n"),
 | 
				
			||||||
 | 
								strings.Join(imageStrings, "\n"),
 | 
				
			||||||
		); err != nil {
 | 
							); err != nil {
 | 
				
			||||||
			log.Fatal(err)
 | 
								log.Fatal(err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
				
			|||||||
@ -50,6 +50,9 @@ func DeployOverview(
 | 
				
			|||||||
	toDeployVersion string,
 | 
						toDeployVersion string,
 | 
				
			||||||
	releaseNotes string,
 | 
						releaseNotes string,
 | 
				
			||||||
	warnMessages []string,
 | 
						warnMessages []string,
 | 
				
			||||||
 | 
						secrets string,
 | 
				
			||||||
 | 
						configs string,
 | 
				
			||||||
 | 
						images string,
 | 
				
			||||||
) error {
 | 
					) error {
 | 
				
			||||||
	deployConfig := "compose.yml"
 | 
						deployConfig := "compose.yml"
 | 
				
			||||||
	if composeFiles, ok := app.Env["COMPOSE_FILE"]; ok {
 | 
						if composeFiles, ok := app.Env["COMPOSE_FILE"]; ok {
 | 
				
			||||||
@ -80,6 +83,10 @@ func DeployOverview(
 | 
				
			|||||||
		{i18n.G("CURRENT DEPLOYMENT"), formatter.BoldDirtyDefault(deployedVersion)},
 | 
							{i18n.G("CURRENT DEPLOYMENT"), formatter.BoldDirtyDefault(deployedVersion)},
 | 
				
			||||||
		{i18n.G("ENV VERSION"), formatter.BoldDirtyDefault(envVersion)},
 | 
							{i18n.G("ENV VERSION"), formatter.BoldDirtyDefault(envVersion)},
 | 
				
			||||||
		{i18n.G("NEW DEPLOYMENT"), formatter.BoldDirtyDefault(toDeployVersion)},
 | 
							{i18n.G("NEW DEPLOYMENT"), formatter.BoldDirtyDefault(toDeployVersion)},
 | 
				
			||||||
 | 
							{"", ""},
 | 
				
			||||||
 | 
							{i18n.G("SECRETS"), secrets},
 | 
				
			||||||
 | 
							{i18n.G("CONFIGS"), configs},
 | 
				
			||||||
 | 
							{i18n.G("IMAGES"), images},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	deployType := getDeployType(deployedVersion, toDeployVersion)
 | 
						deployType := getDeployType(deployedVersion, toDeployVersion)
 | 
				
			||||||
 | 
				
			|||||||
@ -280,7 +280,7 @@ type secretStatus struct {
 | 
				
			|||||||
type secretStatuses []secretStatus
 | 
					type secretStatuses []secretStatus
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// PollSecretsStatus checks status of secrets by comparing the local recipe
 | 
					// PollSecretsStatus checks status of secrets by comparing the local recipe
 | 
				
			||||||
// config and deploymend server state.
 | 
					// config and deployed server state.
 | 
				
			||||||
func PollSecretsStatus(cl *dockerClient.Client, app appPkg.App) (secretStatuses, error) {
 | 
					func PollSecretsStatus(cl *dockerClient.Client, app appPkg.App) (secretStatuses, error) {
 | 
				
			||||||
	var secStats secretStatuses
 | 
						var secStats secretStatuses
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -306,7 +306,7 @@ func PollSecretsStatus(cl *dockerClient.Client, app appPkg.App) (secretStatuses,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	remoteSecretNames := make(map[string]bool)
 | 
						remoteSecretNames := make(map[string]bool)
 | 
				
			||||||
	for _, cont := range secretList {
 | 
						for _, cont := range secretList {
 | 
				
			||||||
		remoteSecretNames[cont.Spec.Annotations.Name] = true
 | 
							remoteSecretNames[cont.Spec.Name] = true
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for secretName, val := range secretsConfig {
 | 
						for secretName, val := range secretsConfig {
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user