Skip to content

Commit caca0a5

Browse files
committed
review changes
1 parent c382cf8 commit caca0a5

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

internal/cmd/public-ip/public-ip.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"github.com/stackitcloud/stackit-cli/internal/cmd/public-ip/delete"
88
"github.com/stackitcloud/stackit-cli/internal/cmd/public-ip/describe"
99
"github.com/stackitcloud/stackit-cli/internal/cmd/public-ip/disassociate"
10-
ipranges "github.com/stackitcloud/stackit-cli/internal/cmd/public-ip/ip-ranges"
1110
"github.com/stackitcloud/stackit-cli/internal/cmd/public-ip/list"
11+
"github.com/stackitcloud/stackit-cli/internal/cmd/public-ip/ranges"
1212
"github.com/stackitcloud/stackit-cli/internal/cmd/public-ip/update"
1313
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
1414
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
@@ -36,5 +36,5 @@ func addSubcommands(cmd *cobra.Command, params *params.CmdParams) {
3636
cmd.AddCommand(update.NewCmd(params))
3737
cmd.AddCommand(associate.NewCmd(params))
3838
cmd.AddCommand(disassociate.NewCmd(params))
39-
cmd.AddCommand(ipranges.NewCmd(params))
39+
cmd.AddCommand(ranges.NewCmd(params))
4040
}

internal/cmd/public-ip/ip-ranges/ip-ranges.go renamed to internal/cmd/public-ip/ranges/ip-ranges.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package ipranges
1+
package ranges
22

33
import (
44
"github.com/stackitcloud/stackit-cli/internal/cmd/params"
5-
"github.com/stackitcloud/stackit-cli/internal/cmd/public-ip/ip-ranges/list"
5+
"github.com/stackitcloud/stackit-cli/internal/cmd/public-ip/ranges/list"
66
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
77
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
88

@@ -11,7 +11,7 @@ import (
1111

1212
func NewCmd(params *params.CmdParams) *cobra.Command {
1313
cmd := &cobra.Command{
14-
Use: "ip-ranges",
14+
Use: "ranges",
1515
Short: "Provides functionality for STACKIT Cloud public ip-ranges",
1616
Long: "Provides functionality for STACKIT Cloud public ip-ranges",
1717
Args: args.NoArgs,

internal/cmd/public-ip/ip-ranges/list/list.go renamed to internal/cmd/public-ip/ranges/list/list.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/spf13/cobra"
1111
"github.com/stackitcloud/stackit-cli/internal/cmd/params"
1212
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
13-
"github.com/stackitcloud/stackit-cli/internal/pkg/errors"
1413
"github.com/stackitcloud/stackit-cli/internal/pkg/examples"
1514
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
1615
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
@@ -25,17 +24,17 @@ type inputModel struct {
2524
func NewCmd(params *params.CmdParams) *cobra.Command {
2625
cmd := &cobra.Command{
2726
Use: "list",
28-
Short: "Lists all STACKIT cloud public IP ranges.",
29-
Long: "Lists all STACKIT cloud public IP ranges.",
27+
Short: "Lists all STACKIT public-ip ranges",
28+
Long: "Lists all STACKIT public-ip ranges.",
3029
Args: args.NoArgs,
3130
Example: examples.Build(
3231
examples.NewExample(
33-
`Lists all STACKIT cloud public IP ranges`,
32+
`Lists all STACKIT public-ip ranges`,
3433
"$ stackit public-ip ranges list",
3534
),
3635
examples.NewExample(
37-
`Lists all STACKIT cloud public IP ranges, piping to a tool like fzf for interactive selection`,
38-
"$ stackit public-ip ip-ranges list -o pretty | fzf",
36+
`Lists all STACKIT public-ip ranges, piping to a tool like fzf for interactive selection`,
37+
"$ stackit public-ip ranges list -o pretty | fzf",
3938
),
4039
),
4140
RunE: func(cmd *cobra.Command, _ []string) error {
@@ -72,9 +71,6 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
7271

7372
func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
7473
globalFlags := globalflags.Parse(p, cmd)
75-
if globalFlags.ProjectId == "" {
76-
return nil, &errors.ProjectIdError{}
77-
}
7874

7975
model := inputModel{GlobalFlagModel: globalFlags}
8076

@@ -111,7 +107,7 @@ func outputResult(p *print.Printer, outputFormat string, networkListResponse iaa
111107
default:
112108
var publicIps []string
113109
for _, item := range *networkListResponse.Items {
114-
if item.Cidr != nil || *item.Cidr != "" {
110+
if item.Cidr != nil && *item.Cidr != "" {
115111
publicIps = append(publicIps, *item.Cidr)
116112
}
117113
}

internal/cmd/public-ip/ip-ranges/list/list_test.go renamed to internal/cmd/public-ip/ranges/list/list_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,14 @@ func TestParseInput(t *testing.T) {
3434
isValid: true,
3535
},
3636
{
37-
description: "missing project id",
38-
globalFlags: map[string]string{},
39-
expectedModel: nil,
40-
isValid: false,
37+
description: "missing project id does not lead into error",
38+
globalFlags: map[string]string{},
39+
expectedModel: &inputModel{
40+
GlobalFlagModel: &globalflags.GlobalFlagModel{
41+
Verbosity: globalflags.InfoVerbosity,
42+
},
43+
},
44+
isValid: true,
4145
},
4246
}
4347

0 commit comments

Comments
 (0)