mirror of https://github.com/docker/cli.git
cli/command/stack/swarm: GetStacks: don't use pointers for values
These are very small structs, so using pointers doesn't bring much advantage and makes it slightly more cumbersome to use. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
6b86aac02e
commit
581cb2b70a
|
@ -43,7 +43,7 @@ type Stack struct {
|
|||
// StackWrite writes formatted stacks using the Context
|
||||
//
|
||||
// Deprecated: this function was for internal use and will be removed in the next release.
|
||||
func StackWrite(ctx formatter.Context, stacks []*Stack) error {
|
||||
func StackWrite(ctx formatter.Context, stacks []Stack) error {
|
||||
fmtCtx := &stackContext{
|
||||
HeaderContext: formatter.HeaderContext{
|
||||
Header: formatter.SubHeaderContext{
|
||||
|
@ -64,7 +64,7 @@ func StackWrite(ctx formatter.Context, stacks []*Stack) error {
|
|||
|
||||
type stackContext struct {
|
||||
formatter.HeaderContext
|
||||
s *Stack
|
||||
s Stack
|
||||
}
|
||||
|
||||
func (s *stackContext) MarshalJSON() ([]byte, error) {
|
||||
|
|
|
@ -56,7 +56,7 @@ bar
|
|||
Format: tc.format,
|
||||
Output: &out,
|
||||
}
|
||||
if err := StackWrite(fmtCtx, []*Stack{
|
||||
if err := StackWrite(fmtCtx, []Stack{
|
||||
{Name: "baz", Services: 2},
|
||||
{Name: "bar", Services: 1},
|
||||
}); err != nil {
|
||||
|
|
|
@ -53,7 +53,7 @@ func runList(ctx context.Context, dockerCLI command.Cli, opts listOptions) error
|
|||
return format(dockerCLI.Out(), opts, stacks)
|
||||
}
|
||||
|
||||
func format(out io.Writer, opts listOptions, stacks []*formatter.Stack) error {
|
||||
func format(out io.Writer, opts listOptions, stacks []formatter.Stack) error {
|
||||
fmt := formatter.Format(opts.Format)
|
||||
if fmt == "" || fmt == formatter.TableFormatKey {
|
||||
fmt = formatter.SwarmStackTableFormat
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
// GetStacks lists the swarm stacks with the number of services they contain.
|
||||
//
|
||||
// Deprecated: this function was for internal use and will be removed in the next release.
|
||||
func GetStacks(ctx context.Context, apiClient client.ServiceAPIClient) ([]*formatter.Stack, error) {
|
||||
func GetStacks(ctx context.Context, apiClient client.ServiceAPIClient) ([]formatter.Stack, error) {
|
||||
services, err := apiClient.ServiceList(ctx, client.ServiceListOptions{
|
||||
Filters: getAllStacksFilter(),
|
||||
})
|
||||
|
@ -21,7 +21,7 @@ func GetStacks(ctx context.Context, apiClient client.ServiceAPIClient) ([]*forma
|
|||
}
|
||||
|
||||
idx := make(map[string]int, len(services))
|
||||
out := make([]*formatter.Stack, 0, len(services))
|
||||
out := make([]formatter.Stack, 0, len(services))
|
||||
|
||||
for _, svc := range services {
|
||||
name, ok := svc.Spec.Labels[convert.LabelNamespace]
|
||||
|
@ -33,7 +33,7 @@ func GetStacks(ctx context.Context, apiClient client.ServiceAPIClient) ([]*forma
|
|||
continue
|
||||
}
|
||||
idx[name] = len(out)
|
||||
out = append(out, &formatter.Stack{Name: name, Services: 1})
|
||||
out = append(out, formatter.Stack{Name: name, Services: 1})
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue