Skip to content

Commit dd659ae

Browse files
committed
replace routed flag with non-routed to align with api values
1 parent 756aac2 commit dd659ae

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

docs/stackit_beta_network_create.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ stackit beta network create [flags]
1616
Create a network with name "network-1"
1717
$ stackit beta network create --name network-1
1818
19-
Create a routed network with name "network-1"
20-
$ stackit beta network create --name network-1 --routed
19+
Create a non-routed network with name "network-1"
20+
$ stackit beta network create --name network-1 --non-routed
2121
2222
Create a network with name "network-1" and no gateway
2323
$ stackit beta network create --name network-1 --no-ipv4-gateway
@@ -44,7 +44,7 @@ stackit beta network create [flags]
4444
-n, --name string Network name
4545
--no-ipv4-gateway If set to true, the network doesn't have an IPv4 gateway
4646
--no-ipv6-gateway If set to true, the network doesn't have an IPv6 gateway
47-
--routed If set to true, the network is routed and therefore accessible from other networks
47+
--non-routed If set to true, the network is not routed and therefore not accessible from other networks
4848
```
4949

5050
### Options inherited from parent commands

internal/cmd/beta/network/create/create.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const (
3131
ipv6PrefixLengthFlag = "ipv6-prefix-length"
3232
ipv6PrefixFlag = "ipv6-prefix"
3333
ipv6GatewayFlag = "ipv6-gateway"
34-
routedFlag = "routed"
34+
nonRoutedFlag = "non-routed"
3535
noIpv4GatewayFlag = "no-ipv4-gateway"
3636
noIpv6GatewayFlag = "no-ipv6-gateway"
3737
)
@@ -47,7 +47,7 @@ type inputModel struct {
4747
IPv6PrefixLength *int64
4848
IPv6Prefix *string
4949
IPv6Gateway *string
50-
Routed bool
50+
NonRouted bool
5151
NoIPv4Gateway bool
5252
NoIPv6Gateway bool
5353
}
@@ -64,8 +64,8 @@ func NewCmd(p *print.Printer) *cobra.Command {
6464
`$ stackit beta network create --name network-1`,
6565
),
6666
examples.NewExample(
67-
`Create a routed network with name "network-1"`,
68-
`$ stackit beta network create --name network-1 --routed`,
67+
`Create a non-routed network with name "network-1"`,
68+
`$ stackit beta network create --name network-1 --non-routed`,
6969
),
7070
examples.NewExample(
7171
`Create a network with name "network-1" and no gateway`,
@@ -143,12 +143,10 @@ func configureFlags(cmd *cobra.Command) {
143143
cmd.Flags().Int64(ipv6PrefixLengthFlag, 0, "The prefix length of the IPv6 network")
144144
cmd.Flags().String(ipv6PrefixFlag, "", "The IPv6 prefix of the network (CIDR)")
145145
cmd.Flags().String(ipv6GatewayFlag, "", "The IPv6 gateway of a network. If not specified, the first IP of the network will be assigned as the gateway")
146-
cmd.Flags().Bool(routedFlag, false, "If set to true, the network is routed and therefore accessible from other networks")
146+
cmd.Flags().Bool(nonRoutedFlag, false, "If set to true, the network is not routed and therefore not accessible from other networks")
147147
cmd.Flags().Bool(noIpv4GatewayFlag, false, "If set to true, the network doesn't have an IPv4 gateway")
148148
cmd.Flags().Bool(noIpv6GatewayFlag, false, "If set to true, the network doesn't have an IPv6 gateway")
149149

150-
cmd.MarkFlagsMutuallyExclusive(routedFlag, ipv4DnsNameServersFlag)
151-
cmd.MarkFlagsMutuallyExclusive(routedFlag, ipv6DnsNameServersFlag)
152150
err := flags.MarkFlagsRequired(cmd, nameFlag)
153151
cobra.CheckErr(err)
154152
}
@@ -170,7 +168,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
170168
IPv6PrefixLength: flags.FlagToInt64Pointer(p, cmd, ipv6PrefixLengthFlag),
171169
IPv6Prefix: flags.FlagToStringPointer(p, cmd, ipv6PrefixFlag),
172170
IPv6Gateway: flags.FlagToStringPointer(p, cmd, ipv6GatewayFlag),
173-
Routed: flags.FlagToBoolValue(p, cmd, routedFlag),
171+
NonRouted: flags.FlagToBoolValue(p, cmd, nonRoutedFlag),
174172
NoIPv4Gateway: flags.FlagToBoolValue(p, cmd, noIpv4GatewayFlag),
175173
NoIPv6Gateway: flags.FlagToBoolValue(p, cmd, noIpv6GatewayFlag),
176174
}
@@ -219,9 +217,14 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli
219217
}
220218
}
221219

220+
routed := true
221+
if model.NonRouted {
222+
routed = false
223+
}
224+
222225
payload := iaas.CreateNetworkPayload{
223226
Name: model.Name,
224-
Routed: &model.Routed,
227+
Routed: &routed,
225228
}
226229

227230
if addressFamily.Ipv4 != nil || addressFamily.Ipv6 != nil {

internal/cmd/beta/network/create/create_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st
3535
ipv6PrefixLengthFlag: "24",
3636
ipv6PrefixFlag: "2001:4860:4860::8888",
3737
ipv6GatewayFlag: "2001:4860:4860::8888",
38-
routedFlag: "true",
38+
nonRoutedFlag: "false",
3939
}
4040
for _, mod := range mods {
4141
mod(flagValues)
@@ -58,7 +58,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
5858
IPv6PrefixLength: utils.Ptr(int64(24)),
5959
IPv6Prefix: utils.Ptr("2001:4860:4860::8888"),
6060
IPv6Gateway: utils.Ptr("2001:4860:4860::8888"),
61-
Routed: true,
61+
NonRouted: false,
6262
}
6363
for _, mod := range mods {
6464
mod(model)
@@ -79,7 +79,7 @@ func fixtureRequiredRequest(mods ...func(request *iaas.ApiCreateNetworkRequest))
7979
request := testClient.CreateNetwork(testCtx, testProjectId)
8080
request = request.CreateNetworkPayload(iaas.CreateNetworkPayload{
8181
Name: utils.Ptr("example-network-name"),
82-
Routed: utils.Ptr(false),
82+
Routed: utils.Ptr(true),
8383
})
8484
for _, mod := range mods {
8585
mod(&request)
@@ -229,11 +229,11 @@ func TestParseInput(t *testing.T) {
229229
{
230230
description: "use routed true",
231231
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
232-
flagValues[routedFlag] = "true"
232+
flagValues[nonRoutedFlag] = "false"
233233
}),
234234
isValid: true,
235235
expectedModel: fixtureInputModel(func(model *inputModel) {
236-
model.Routed = true
236+
model.NonRouted = false
237237
}),
238238
},
239239
}

0 commit comments

Comments
 (0)