Skip to content

Commit a3da9dc

Browse files
committed
removed utils.getSliceFromPointer(&var) pattern
1 parent e2748e4 commit a3da9dc

8 files changed

Lines changed: 12 additions & 14 deletions

File tree

internal/cmd/beta/sfs/export-policy/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
7676
}
7777

7878
// Truncate output
79-
items := utils.GetSliceFromPointer(&resp.ShareExportPolicies)
79+
items := resp.ShareExportPolicies
8080
if model.Limit != nil && len(items) > int(*model.Limit) {
8181
items = items[:*model.Limit]
8282
}

internal/cmd/beta/sfs/performance-class/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
6363
projectLabel = model.ProjectId
6464
}
6565

66-
performanceClasses := utils.GetSliceFromPointer(&resp.PerformanceClasses)
66+
performanceClasses := resp.PerformanceClasses
6767

6868
return outputResult(params.Printer, model.OutputFormat, projectLabel, performanceClasses)
6969
},

internal/cmd/beta/sfs/resource-pool/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
6666
return fmt.Errorf("list SFS resource pools: %w", err)
6767
}
6868

69-
resourcePools := utils.GetSliceFromPointer(&resp.ResourcePools)
69+
resourcePools := resp.ResourcePools
7070

7171
// Truncate output
7272
if model.Limit != nil && len(resourcePools) > int(*model.Limit) {

internal/cmd/beta/sfs/share/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
7676
}
7777

7878
// Truncate output
79-
items := utils.GetSliceFromPointer(&resp.Shares)
79+
items := resp.Shares
8080
if model.Limit != nil && len(items) > int(*model.Limit) {
8181
items = items[:*model.Limit]
8282
}

internal/cmd/beta/sfs/snapshot-policy/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
9393
}
9494

9595
// Truncate output
96-
items := utils.GetSliceFromPointer(&resp.SnapshotPolicies)
96+
items := resp.SnapshotPolicies
9797
if model.Limit != nil && len(items) > int(*model.Limit) {
9898
items = items[:*model.Limit]
9999
}

internal/cmd/beta/sfs/snapshot/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
6363
}
6464

6565
// Truncate output
66-
items := utils.GetSliceFromPointer(&resp.ResourcePoolSnapshots)
66+
items := resp.ResourcePoolSnapshots
6767
if model.Limit != nil && len(items) > int(*model.Limit) {
6868
items = items[:*model.Limit]
6969
}

internal/cmd/beta/vpn/gateway/list/list.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,16 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
6767
}
6868

6969
// Truncate output
70-
items := utils.GetSliceFromPointer(&resp.Gateways)
71-
if model.Limit != nil && len(items) > int(*model.Limit) {
72-
items = items[:*model.Limit]
70+
if model.Limit != nil && len(resp.Gateways) > int(*model.Limit) {
71+
resp.Gateways = resp.Gateways[:*model.Limit]
7372
}
7473

7574
projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd)
7675
if err != nil || projectLabel == "" {
7776
projectLabel = model.ProjectId
7877
}
7978

80-
return outputResult(params.Printer, model.OutputFormat, items, projectLabel)
79+
return outputResult(params.Printer, model.OutputFormat, resp.Gateways, projectLabel)
8180
},
8281
}
8382
configureFlags(cmd)

internal/cmd/beta/vpn/plans/plans.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,11 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
6262
}
6363

6464
// Truncate output
65-
items := utils.GetSliceFromPointer(&resp.Plans)
66-
if model.Limit != nil && len(items) > int(*model.Limit) {
67-
items = items[:*model.Limit]
65+
if model.Limit != nil && len(resp.Plans) > int(*model.Limit) {
66+
resp.Plans = resp.Plans[:*model.Limit]
6867
}
6968

70-
return outputResult(params.Printer, model.OutputFormat, items, model.Region)
69+
return outputResult(params.Printer, model.OutputFormat, resp.Plans, model.Region)
7170
},
7271
}
7372
configureFlags(cmd)

0 commit comments

Comments
 (0)