diff --git a/cli/app/deploy.go b/cli/app/deploy.go index 7378a4a4..d8f71119 100644 --- a/cli/app/deploy.go +++ b/cli/app/deploy.go @@ -216,7 +216,7 @@ checkout as-is. Recipe commit hashes are also supported as values for // Gather configs // Get current configs from existing deployment - currentConfigNames, err := client.GetConfigNamesForStack(cl, context.Background(), app.StackName()) + currentConfigNames, err := client.GetConfigNamesForStack(cl, app) if err != nil { log.Fatal(err) } @@ -237,7 +237,7 @@ checkout as-is. Recipe commit hashes are also supported as values for var configInfo []string for configName := range newConfigs { - log.Debugf("Searching for abra.sh version for %s", configName) + log.Debugf("Searching abra.sh for version for %s", configName) versionKey := strings.ToUpper(configName) + "_VERSION" newVersion, exists := abraShEnv[versionKey] if !exists { @@ -257,11 +257,15 @@ checkout as-is. Recipe commit hashes are also supported as values for } } + // Gather images + var imageInfo []string for _, service := range compose.Services { imageInfo = append(imageInfo, fmt.Sprintf("%s: %s", service.Name, service.Image)) } + // Show deploy overview + if err := internal.DeployOverview( app, deployedVersion, diff --git a/pkg/client/configs.go b/pkg/client/configs.go index 0c8ac187..1b8732c0 100644 --- a/pkg/client/configs.go +++ b/pkg/client/configs.go @@ -6,6 +6,7 @@ import ( "strings" "coopcloud.tech/abra/pkg/i18n" + appPkg "coopcloud.tech/abra/pkg/app" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/swarm" @@ -49,14 +50,15 @@ func GetConfigNameAndVersion(fullName string, stackName string) (string, string) } // GetConfigNamesForStack retrieves all Docker configs attached to services in a given stack. -func GetConfigNamesForStack(cl *client.Client, ctx context.Context, stackName string) ([]string, error) { - // Create filter to get services for the specific stack - filter := filters.NewArgs() - filter.Add("label", "com.docker.stack.namespace="+stackName) +func GetConfigNamesForStack(cl *client.Client, app appPkg.App) ([]string, error) { + filters, err := app.Filters(false, false) + if err != nil { + return nil, err + } // List all services in the stack - services, err := cl.ServiceList(ctx, types.ServiceListOptions{ - Filters: filter, + services, err := cl.ServiceList(context.Background(), types.ServiceListOptions{ + Filters: filters, }) if err != nil { return nil, err diff --git a/pkg/client/secret.go b/pkg/client/secret.go index 1d095467..e2c82298 100644 --- a/pkg/client/secret.go +++ b/pkg/client/secret.go @@ -3,6 +3,8 @@ package client import ( "context" + appPkg "coopcloud.tech/abra/pkg/app" + "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/client" ) @@ -17,3 +19,25 @@ func StoreSecret(cl *client.Client, secretName, secretValue string) error { return nil } + +func GetSecretNamesForStack(cl *client.Client, app appPkg.App) ([]string, error) { + filters, err := app.Filters(false, false) + if err != nil { + return nil, err + } + + secretList, err := cl.SecretList(context.Background(), swarm.SecretListOptions{Filters: filters}) + if err != nil { + return nil, err + } + + return GetSecretNames(secretList), nil +} + +func GetSecretNames(secrets []swarm.Secret) []string { + var secretNames []string + for _, secret := range secrets { + secretNames = append(secretNames, secret.Spec.Name) + } + return secretNames +}