Skip to content

Commit

Permalink
errcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
phm07 committed Aug 12, 2024
1 parent d2b6433 commit c070580
Show file tree
Hide file tree
Showing 47 changed files with 116 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ linters:
enable:
- bodyclose
# - dupl
# - errcheck
- errcheck
- exhaustive
- gocritic
- golint
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/base/set_rdns.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (rc *SetRdnsCmd) CobraCommand(s state.State) *cobra.Command {
},
}
cmd.Flags().StringP("hostname", "r", "", "Hostname to set as a reverse DNS PTR entry (required)")
cmd.MarkFlagRequired("hostname")
_ = cmd.MarkFlagRequired("hostname")

cmd.Flags().IPP("ip", "i", net.IP{}, "IP address for which the reverse DNS entry should be set")
if rc.AdditionalFlags != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/certificate/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ var CreateCmd = base.CreateCmd{
}

cmd.Flags().String("name", "", "Certificate name (required)")
cmd.MarkFlagRequired("name")
_ = cmd.MarkFlagRequired("name")

cmd.Flags().StringP("type", "t", string(hcloud.CertificateTypeUploaded),
fmt.Sprintf("Type of certificate to create. Valid choices: %v, %v",
hcloud.CertificateTypeUploaded, hcloud.CertificateTypeManaged))
cmd.RegisterFlagCompletionFunc(
_ = cmd.RegisterFlagCompletionFunc(
"type",
cmpl.SuggestCandidates(string(hcloud.CertificateTypeUploaded), string(hcloud.CertificateTypeManaged)),
)
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/firewall/add_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ var AddRuleCmd = base.Cmd{
DisableFlagsInUseLine: true,
}
cmd.Flags().String("direction", "", "Direction (in, out) (required)")
cmd.RegisterFlagCompletionFunc("direction", cmpl.SuggestCandidates("in", "out"))
cmd.MarkFlagRequired("direction")
_ = cmd.RegisterFlagCompletionFunc("direction", cmpl.SuggestCandidates("in", "out"))
_ = cmd.MarkFlagRequired("direction")

cmd.Flags().String("protocol", "", "Protocol (icmp, esp, gre, udp or tcp) (required)")
cmd.RegisterFlagCompletionFunc("protocol", cmpl.SuggestCandidates("icmp", "udp", "tcp", "esp", "gre"))
cmd.MarkFlagRequired("protocol")
_ = cmd.RegisterFlagCompletionFunc("protocol", cmpl.SuggestCandidates("icmp", "udp", "tcp", "esp", "gre"))
_ = cmd.MarkFlagRequired("protocol")

cmd.Flags().StringArray("source-ips", []string{}, "Source IPs (CIDR Notation) (required when direction is in)")

Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/firewall/apply_to_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ var ApplyToResourceCmd = base.Cmd{
DisableFlagsInUseLine: true,
}
cmd.Flags().String("type", "", "Resource Type (server, label_selector) (required)")
cmd.RegisterFlagCompletionFunc("type", cmpl.SuggestCandidates("server", "label_selector"))
cmd.MarkFlagRequired("type")
_ = cmd.RegisterFlagCompletionFunc("type", cmpl.SuggestCandidates("server", "label_selector"))
_ = cmd.MarkFlagRequired("type")

cmd.Flags().String("server", "", "Server name of ID (required when type is server)")
cmd.RegisterFlagCompletionFunc("server", cmpl.SuggestCandidatesF(client.Server().Names))
_ = cmd.RegisterFlagCompletionFunc("server", cmpl.SuggestCandidatesF(client.Server().Names))

cmd.Flags().StringP("label-selector", "l", "", "Label Selector")
return cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/firewall/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var CreateCmd = base.CreateCmd{
Short: "Create a Firewall",
}
cmd.Flags().String("name", "", "Name")
cmd.MarkFlagRequired("name")
_ = cmd.MarkFlagRequired("name")

cmd.Flags().StringToString("label", nil, "User-defined labels ('key=value') (can be specified multiple times)")

Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/firewall/delete_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ var DeleteRuleCmd = base.Cmd{
DisableFlagsInUseLine: true,
}
cmd.Flags().String("direction", "", "Direction (in, out) (required)")
cmd.RegisterFlagCompletionFunc("direction", cmpl.SuggestCandidates("in", "out"))
cmd.MarkFlagRequired("direction")
_ = cmd.RegisterFlagCompletionFunc("direction", cmpl.SuggestCandidates("in", "out"))
_ = cmd.MarkFlagRequired("direction")

cmd.Flags().String("protocol", "", "Protocol (icmp, esp, gre, udp or tcp) (required)")
cmd.RegisterFlagCompletionFunc("protocol", cmpl.SuggestCandidates("icmp", "udp", "tcp", "esp", "gre"))
cmd.MarkFlagRequired("protocol")
_ = cmd.RegisterFlagCompletionFunc("protocol", cmpl.SuggestCandidates("icmp", "udp", "tcp", "esp", "gre"))
_ = cmd.MarkFlagRequired("protocol")

cmd.Flags().StringArray("source-ips", []string{}, "Source IPs (CIDR Notation) (required when direction is in)")

Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/firewall/remove_from_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ var RemoveFromResourceCmd = base.Cmd{
DisableFlagsInUseLine: true,
}
cmd.Flags().String("type", "", "Resource Type (server) (required)")
cmd.RegisterFlagCompletionFunc("type", cmpl.SuggestCandidates("server", "label_selector"))
cmd.MarkFlagRequired("type")
_ = cmd.RegisterFlagCompletionFunc("type", cmpl.SuggestCandidates("server", "label_selector"))
_ = cmd.MarkFlagRequired("type")

cmd.Flags().String("server", "", "Server name of ID (required when type is server)")
cmd.RegisterFlagCompletionFunc("server", cmpl.SuggestCandidatesF(client.Server().Names))
_ = cmd.RegisterFlagCompletionFunc("server", cmpl.SuggestCandidatesF(client.Server().Names))

cmd.Flags().StringP("label-selector", "l", "", "Label Selector")
return cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/firewall/replace_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var ReplaceRulesCmd = base.Cmd{
DisableFlagsInUseLine: true,
}
cmd.Flags().String("rules-file", "", "JSON file containing your routes (use - to read from stdin). The structure of the file needs to be the same as within the API: https://docs.hetzner.cloud/#firewalls-get-a-firewall")
cmd.MarkFlagRequired("rules-file")
_ = cmd.MarkFlagRequired("rules-file")
return cmd
},
Run: func(s state.State, cmd *cobra.Command, args []string) error {
Expand Down
10 changes: 5 additions & 5 deletions internal/cmd/floatingip/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ var CreateCmd = base.CreateCmd{
DisableFlagsInUseLine: true,
}
cmd.Flags().String("type", "", "Type (ipv4 or ipv6) (required)")
cmd.RegisterFlagCompletionFunc("type", cmpl.SuggestCandidates("ipv4", "ipv6"))
cmd.MarkFlagRequired("type")
_ = cmd.RegisterFlagCompletionFunc("type", cmpl.SuggestCandidates("ipv4", "ipv6"))
_ = cmd.MarkFlagRequired("type")

cmd.Flags().String("description", "", "Description")

cmd.Flags().String("name", "", "Name")

cmd.Flags().String("home-location", "", "Home location")
cmd.RegisterFlagCompletionFunc("home-location", cmpl.SuggestCandidatesF(client.Location().Names))
_ = cmd.RegisterFlagCompletionFunc("home-location", cmpl.SuggestCandidatesF(client.Location().Names))

cmd.Flags().String("server", "", "Server to assign Floating IP to")
cmd.RegisterFlagCompletionFunc("server", cmpl.SuggestCandidatesF(client.Server().Names))
_ = cmd.RegisterFlagCompletionFunc("server", cmpl.SuggestCandidatesF(client.Server().Names))

cmd.Flags().StringToString("label", nil, "User-defined labels ('key=value') (can be specified multiple times)")

cmd.Flags().StringSlice("enable-protection", []string{}, "Enable protection (delete) (default: none)")
cmd.RegisterFlagCompletionFunc("enable-protection", cmpl.SuggestCandidates("delete"))
_ = cmd.RegisterFlagCompletionFunc("enable-protection", cmpl.SuggestCandidates("delete"))

return cmd
},
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/image/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ var DescribeCmd = base.DescribeCmd{
JSONKeyGetByName: "images",
AdditionalFlags: func(cmd *cobra.Command) {
cmd.Flags().StringP("architecture", "a", string(hcloud.ArchitectureX86), "architecture of the image, default is x86")
cmd.RegisterFlagCompletionFunc("architecture", cmpl.SuggestCandidates(string(hcloud.ArchitectureX86), string(hcloud.ArchitectureARM)))

_ = cmd.RegisterFlagCompletionFunc("architecture", cmpl.SuggestCandidates(string(hcloud.ArchitectureX86), string(hcloud.ArchitectureARM)))
},
NameSuggestions: func(c hcapi2.Client) func() []string { return c.Image().Names },
Fetch: func(s state.State, cmd *cobra.Command, idOrName string) (interface{}, interface{}, error) {
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/image/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ var ListCmd = base.ListCmd{

AdditionalFlags: func(cmd *cobra.Command) {
cmd.Flags().StringSliceP("type", "t", []string{}, "Only show images of given type: system|app|snapshot|backup")
cmd.RegisterFlagCompletionFunc("type", cmpl.SuggestCandidates("backup", "snapshot", "system", "app"))
_ = cmd.RegisterFlagCompletionFunc("type", cmpl.SuggestCandidates("backup", "snapshot", "system", "app"))

cmd.Flags().StringSliceP("architecture", "a", []string{}, "Only show images of given architecture: x86|arm")
cmd.RegisterFlagCompletionFunc("architecture", cmpl.SuggestCandidates(string(hcloud.ArchitectureX86), string(hcloud.ArchitectureARM)))
_ = cmd.RegisterFlagCompletionFunc("architecture", cmpl.SuggestCandidates(string(hcloud.ArchitectureX86), string(hcloud.ArchitectureARM)))
},
Fetch: func(s state.State, flags *pflag.FlagSet, listOpts hcloud.ListOpts, sorts []string) ([]interface{}, error) {
opts := hcloud.ImageListOpts{ListOpts: listOpts, IncludeDeprecated: true}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/image/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var UpdateCmd = base.UpdateCmd{
DefineFlags: func(cmd *cobra.Command) {
cmd.Flags().String("description", "", "Image description")
cmd.Flags().String("type", "", "Image type")
cmd.RegisterFlagCompletionFunc("type", cmpl.SuggestCandidates("snapshot"))
_ = cmd.RegisterFlagCompletionFunc("type", cmpl.SuggestCandidates("snapshot"))
},
Update: func(s state.State, cmd *cobra.Command, resource interface{}, flags map[string]pflag.Value) error {
image := resource.(*hcloud.Image)
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/iso/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ var ListCmd = base.ListCmd{

AdditionalFlags: func(cmd *cobra.Command) {
cmd.Flags().StringSlice("architecture", []string{}, "Only show images of given architecture: x86|arm")
cmd.RegisterFlagCompletionFunc("architecture", cmpl.SuggestCandidates(string(hcloud.ArchitectureX86), string(hcloud.ArchitectureARM)))
_ = cmd.RegisterFlagCompletionFunc("architecture", cmpl.SuggestCandidates(string(hcloud.ArchitectureX86), string(hcloud.ArchitectureARM)))

cmd.Flags().Bool("include-architecture-wildcard", false, "Include ISOs with unknown architecture, only required if you want so show custom ISOs and still filter for architecture.")

cmd.Flags().StringSlice("type", []string{"public", "private"}, "Types to include (public, private)")
cmd.RegisterFlagCompletionFunc("type", cmpl.SuggestCandidates("public", "private"))
_ = cmd.RegisterFlagCompletionFunc("type", cmpl.SuggestCandidates("public", "private"))
},

Fetch: func(s state.State, flags *pflag.FlagSet, listOpts hcloud.ListOpts, sorts []string) ([]interface{}, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/loadbalancer/add_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var AddServiceCmd = base.Cmd{
DisableFlagsInUseLine: true,
}
cmd.Flags().String("protocol", "", "Protocol of the service (required)")
cmd.MarkFlagRequired("protocol")
_ = cmd.MarkFlagRequired("protocol")

cmd.Flags().Int("listen-port", 0, "Listen port of the service")
cmd.Flags().Int("destination-port", 0, "Destination port of the service on the targets")
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/loadbalancer/add_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var AddTargetCmd = base.Cmd{
}

cmd.Flags().String("server", "", "Name or ID of the server")
cmd.RegisterFlagCompletionFunc("server", cmpl.SuggestCandidatesF(client.Server().Names))
_ = cmd.RegisterFlagCompletionFunc("server", cmpl.SuggestCandidatesF(client.Server().Names))

cmd.Flags().String("label-selector", "", "Label Selector")

Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/loadbalancer/attach_to_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ var AttachToNetworkCmd = base.Cmd{
}

cmd.Flags().StringP("network", "n", "", "Network (ID or name) (required)")
cmd.RegisterFlagCompletionFunc("network", cmpl.SuggestCandidatesF(client.Network().Names))
cmd.MarkFlagRequired("network")
_ = cmd.RegisterFlagCompletionFunc("network", cmpl.SuggestCandidatesF(client.Network().Names))
_ = cmd.MarkFlagRequired("network")

cmd.Flags().IP("ip", nil, "IP address to assign to the Load Balancer (auto-assigned if omitted)")

Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/loadbalancer/change_algorithm.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ var ChangeAlgorithmCmd = base.Cmd{
}

cmd.Flags().String("algorithm-type", "", "New Load Balancer algorithm (round_robin, least_connections) (required)")
cmd.RegisterFlagCompletionFunc("algorithm-type", cmpl.SuggestCandidates(
_ = cmd.RegisterFlagCompletionFunc("algorithm-type", cmpl.SuggestCandidates(
string(hcloud.LoadBalancerAlgorithmTypeRoundRobin),
string(hcloud.LoadBalancerAlgorithmTypeLeastConnections),
))
cmd.MarkFlagRequired("algorithm-type")
_ = cmd.MarkFlagRequired("algorithm-type")

return cmd
},
Expand Down
14 changes: 7 additions & 7 deletions internal/cmd/loadbalancer/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,27 @@ var CreateCmd = base.CreateCmd{
}

cmd.Flags().String("name", "", "Load Balancer name (required)")
cmd.MarkFlagRequired("name")
_ = cmd.MarkFlagRequired("name")

cmd.Flags().String("type", "", "Load Balancer type (ID or name) (required)")
cmd.RegisterFlagCompletionFunc("type", cmpl.SuggestCandidatesF(client.LoadBalancerType().Names))
cmd.MarkFlagRequired("type")
_ = cmd.RegisterFlagCompletionFunc("type", cmpl.SuggestCandidatesF(client.LoadBalancerType().Names))
_ = cmd.MarkFlagRequired("type")

cmd.Flags().String("algorithm-type", "", "Algorithm Type name (round_robin or least_connections)")
cmd.RegisterFlagCompletionFunc("algorithm-type", cmpl.SuggestCandidates(
_ = cmd.RegisterFlagCompletionFunc("algorithm-type", cmpl.SuggestCandidates(
string(hcloud.LoadBalancerAlgorithmTypeLeastConnections),
string(hcloud.LoadBalancerAlgorithmTypeRoundRobin),
))
cmd.Flags().String("location", "", "Location (ID or name)")
cmd.RegisterFlagCompletionFunc("location", cmpl.SuggestCandidatesF(client.Location().Names))
_ = cmd.RegisterFlagCompletionFunc("location", cmpl.SuggestCandidatesF(client.Location().Names))

cmd.Flags().String("network-zone", "", "Network Zone")
cmd.RegisterFlagCompletionFunc("network-zone", cmpl.SuggestCandidatesF(client.Location().NetworkZones))
_ = cmd.RegisterFlagCompletionFunc("network-zone", cmpl.SuggestCandidatesF(client.Location().NetworkZones))

cmd.Flags().StringToString("label", nil, "User-defined labels ('key=value') (can be specified multiple times)")

cmd.Flags().StringSlice("enable-protection", []string{}, "Enable protection (delete) (default: none)")
cmd.RegisterFlagCompletionFunc("enable-protection", cmpl.SuggestCandidates("delete"))
_ = cmd.RegisterFlagCompletionFunc("enable-protection", cmpl.SuggestCandidates("delete"))

return cmd
},
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/loadbalancer/delete_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var DeleteServiceCmd = base.Cmd{
}

cmd.Flags().Int("listen-port", 0, "The listen port of the service you want to delete (required)")
cmd.MarkFlagRequired("listen-port")
_ = cmd.MarkFlagRequired("listen-port")
return cmd
},
Run: func(s state.State, cmd *cobra.Command, args []string) error {
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/loadbalancer/detach_from_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ var DetachFromNetworkCmd = base.Cmd{
DisableFlagsInUseLine: true,
}
cmd.Flags().StringP("network", "n", "", "Network (ID or name) (required)")
cmd.RegisterFlagCompletionFunc("network", cmpl.SuggestCandidatesF(client.Network().Names))
cmd.MarkFlagRequired("network")
_ = cmd.RegisterFlagCompletionFunc("network", cmpl.SuggestCandidatesF(client.Network().Names))
_ = cmd.MarkFlagRequired("network")
return cmd
},
Run: func(s state.State, cmd *cobra.Command, args []string) error {
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/loadbalancer/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ var MetricsCmd = base.Cmd{
}

cmd.Flags().StringSlice("type", nil, "Types of metrics you want to show")
cmd.MarkFlagRequired("type")
cmd.RegisterFlagCompletionFunc("type", cmpl.SuggestCandidates(metricTypeStrings...))
_ = cmd.MarkFlagRequired("type")
_ = cmd.RegisterFlagCompletionFunc("type", cmpl.SuggestCandidates(metricTypeStrings...))

cmd.Flags().String("start", "", "ISO 8601 timestamp")
cmd.Flags().String("end", "", "ISO 8601 timestamp")
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/loadbalancer/remove_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var RemoveTargetCmd = base.Cmd{
}

cmd.Flags().String("server", "", "Name or ID of the server")
cmd.RegisterFlagCompletionFunc("server", cmpl.SuggestCandidatesF(client.Server().Names))
_ = cmd.RegisterFlagCompletionFunc("server", cmpl.SuggestCandidatesF(client.Server().Names))

cmd.Flags().String("label-selector", "", "Label Selector")

Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/loadbalancer/update_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var UpdateServiceCmd = base.Cmd{
}

cmd.Flags().Int("listen-port", 0, "The listen port of the service that you want to update (required)")
cmd.MarkFlagRequired("listen-port")
_ = cmd.MarkFlagRequired("listen-port")

cmd.Flags().Int("destination-port", 0, "Destination port of the service on the targets")

Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/network/add_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ var AddRouteCmd = base.Cmd{
}

cmd.Flags().IPNet("destination", net.IPNet{}, "Destination network or host (required)")
cmd.MarkFlagRequired("destination")
_ = cmd.MarkFlagRequired("destination")

cmd.Flags().IP("gateway", net.IP{}, "Gateway IP address (required)")
cmd.MarkFlagRequired("gateway")
_ = cmd.MarkFlagRequired("gateway")

return cmd
},
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/network/add_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ var AddSubnetCmd = base.Cmd{
}

cmd.Flags().String("type", "", "Type of subnet (required)")
cmd.RegisterFlagCompletionFunc("type", cmpl.SuggestCandidates("cloud", "server", "vswitch"))
cmd.MarkFlagRequired("type")
_ = cmd.RegisterFlagCompletionFunc("type", cmpl.SuggestCandidates("cloud", "server", "vswitch"))
_ = cmd.MarkFlagRequired("type")

cmd.Flags().String("network-zone", "", "Name of network zone (required)")
cmd.RegisterFlagCompletionFunc("network-zone", cmpl.SuggestCandidatesF(client.Location().NetworkZones))
cmd.MarkFlagRequired("network-zone")
_ = cmd.RegisterFlagCompletionFunc("network-zone", cmpl.SuggestCandidatesF(client.Location().NetworkZones))
_ = cmd.MarkFlagRequired("network-zone")

cmd.Flags().IPNet("ip-range", net.IPNet{}, "Range to allocate IPs from")

Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/network/change_ip_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var ChangeIPRangeCmd = base.Cmd{
}

cmd.Flags().IPNet("ip-range", net.IPNet{}, "New IP range (required)")
cmd.MarkFlagRequired("ip-range")
_ = cmd.MarkFlagRequired("ip-range")

return cmd
},
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/network/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ var CreateCmd = base.CreateCmd{
}

cmd.Flags().String("name", "", "Network name (required)")
cmd.MarkFlagRequired("name")
_ = cmd.MarkFlagRequired("name")

cmd.Flags().IPNet("ip-range", net.IPNet{}, "Network IP range (required)")
cmd.MarkFlagRequired("ip-range")
_ = cmd.MarkFlagRequired("ip-range")

cmd.Flags().Bool("expose-routes-to-vswitch", false, "Expose routes from this network to the vSwitch connection. It only takes effect if a vSwitch connection is active.")

cmd.Flags().StringToString("label", nil, "User-defined labels ('key=value') (can be specified multiple times)")

cmd.Flags().StringSlice("enable-protection", []string{}, "Enable protection (delete) (default: none)")
cmd.RegisterFlagCompletionFunc("enable-protection", cmpl.SuggestCandidates("delete"))
_ = cmd.RegisterFlagCompletionFunc("enable-protection", cmpl.SuggestCandidates("delete"))
return cmd
},
Run: func(s state.State, cmd *cobra.Command, args []string) (any, any, error) {
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/network/remove_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ var RemoveRouteCmd = base.Cmd{
}

cmd.Flags().IPNet("destination", net.IPNet{}, "Destination network or host (required)")
cmd.MarkFlagRequired("destination")
_ = cmd.MarkFlagRequired("destination")

cmd.Flags().IP("gateway", net.IP{}, "Gateway IP address (required)")
cmd.MarkFlagRequired("gateway")
_ = cmd.MarkFlagRequired("gateway")

return cmd
},
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/network/remove_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var RemoveSubnetCmd = base.Cmd{
DisableFlagsInUseLine: true,
}
cmd.Flags().IPNet("ip-range", net.IPNet{}, "Subnet IP range (required)")
cmd.MarkFlagRequired("ip-range")
_ = cmd.MarkFlagRequired("ip-range")
return cmd
},
Run: func(s state.State, cmd *cobra.Command, args []string) error {
Expand Down
Loading

0 comments on commit c070580

Please sign in to comment.