Files
docker-cli/cli/command/stack/swarm/ps.go
Sebastiaan van Stijn 19b7dfa1cf deprecate cli/command/stack/swarm
Functions and types in this package were exported as part of the "compose
on kubernetes" feature, which was deprecated and removed. These functions
are meant for internal use, and will be removed in the next release.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 036d3a6bab)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-28 12:07:52 +02:00

37 lines
1.0 KiB
Go

package swarm
import (
"context"
"fmt"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/idresolver"
"github.com/docker/cli/cli/command/stack/options"
"github.com/docker/cli/cli/command/task"
"github.com/docker/docker/api/types/swarm"
)
// RunPS is the swarm implementation of docker stack ps
//
// Deprecated: this function was for internal use and will be removed in the next release.
func RunPS(ctx context.Context, dockerCLI command.Cli, opts options.PS) error {
filter := getStackFilterFromOpt(opts.Namespace, opts.Filter)
apiClient := dockerCLI.Client()
tasks, err := apiClient.TaskList(ctx, swarm.TaskListOptions{Filters: filter})
if err != nil {
return err
}
if len(tasks) == 0 {
return fmt.Errorf("nothing found in stack: %s", opts.Namespace)
}
format := opts.Format
if len(format) == 0 {
format = task.DefaultFormat(dockerCLI.ConfigFile(), opts.Quiet)
}
return task.Print(ctx, dockerCLI, tasks, idresolver.New(apiClient, opts.NoResolve), !opts.NoTrunc, opts.Quiet, format)
}