feat: add GetSecretNamesForStack, tidy up GetConfigNamesForStack

This commit is contained in:
3wc
2025-09-02 11:32:37 -04:00
parent f3edfea744
commit c2848cb3ec
3 changed files with 38 additions and 8 deletions

View File

@ -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