Skip to content

Commit 581cb2b

Browse files
committed
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 <[email protected]>
1 parent 6b86aac commit 581cb2b

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

cli/command/stack/formatter/formatter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type Stack struct {
4343
// StackWrite writes formatted stacks using the Context
4444
//
4545
// Deprecated: this function was for internal use and will be removed in the next release.
46-
func StackWrite(ctx formatter.Context, stacks []*Stack) error {
46+
func StackWrite(ctx formatter.Context, stacks []Stack) error {
4747
fmtCtx := &stackContext{
4848
HeaderContext: formatter.HeaderContext{
4949
Header: formatter.SubHeaderContext{
@@ -64,7 +64,7 @@ func StackWrite(ctx formatter.Context, stacks []*Stack) error {
6464

6565
type stackContext struct {
6666
formatter.HeaderContext
67-
s *Stack
67+
s Stack
6868
}
6969

7070
func (s *stackContext) MarshalJSON() ([]byte, error) {

cli/command/stack/formatter/formatter_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ bar
5656
Format: tc.format,
5757
Output: &out,
5858
}
59-
if err := StackWrite(fmtCtx, []*Stack{
59+
if err := StackWrite(fmtCtx, []Stack{
6060
{Name: "baz", Services: 2},
6161
{Name: "bar", Services: 1},
6262
}); err != nil {

cli/command/stack/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func runList(ctx context.Context, dockerCLI command.Cli, opts listOptions) error
5353
return format(dockerCLI.Out(), opts, stacks)
5454
}
5555

56-
func format(out io.Writer, opts listOptions, stacks []*formatter.Stack) error {
56+
func format(out io.Writer, opts listOptions, stacks []formatter.Stack) error {
5757
fmt := formatter.Format(opts.Format)
5858
if fmt == "" || fmt == formatter.TableFormatKey {
5959
fmt = formatter.SwarmStackTableFormat

cli/command/stack/swarm/list.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
// GetStacks lists the swarm stacks with the number of services they contain.
1313
//
1414
// Deprecated: this function was for internal use and will be removed in the next release.
15-
func GetStacks(ctx context.Context, apiClient client.ServiceAPIClient) ([]*formatter.Stack, error) {
15+
func GetStacks(ctx context.Context, apiClient client.ServiceAPIClient) ([]formatter.Stack, error) {
1616
services, err := apiClient.ServiceList(ctx, client.ServiceListOptions{
1717
Filters: getAllStacksFilter(),
1818
})
@@ -21,7 +21,7 @@ func GetStacks(ctx context.Context, apiClient client.ServiceAPIClient) ([]*forma
2121
}
2222

2323
idx := make(map[string]int, len(services))
24-
out := make([]*formatter.Stack, 0, len(services))
24+
out := make([]formatter.Stack, 0, len(services))
2525

2626
for _, svc := range services {
2727
name, ok := svc.Spec.Labels[convert.LabelNamespace]
@@ -33,7 +33,7 @@ func GetStacks(ctx context.Context, apiClient client.ServiceAPIClient) ([]*forma
3333
continue
3434
}
3535
idx[name] = len(out)
36-
out = append(out, &formatter.Stack{Name: name, Services: 1})
36+
out = append(out, formatter.Stack{Name: name, Services: 1})
3737
}
3838
return out, nil
3939
}

0 commit comments

Comments
 (0)