Skip to content

Commit

Permalink
custom ipv4 and nameservers in network create. (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
uzaxirr authored Mar 25, 2024
1 parent b227728 commit 5eddd8d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cmd/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ func init() {
NetworkCmd.AddCommand(networkCreateCmd)
NetworkCmd.AddCommand(networkUpdateCmd)
NetworkCmd.AddCommand(networkRemoveCmd)

networkCreateCmd.Flags().StringVarP(&cidrV4, "cidr-v4", "", "", "Custom IPv4 CIDR")
networkCreateCmd.Flags().StringSliceVarP(&nameserversV4, "nameservers-v4", "", nil, "Custom list of IPv4 nameservers (up to three, comma-separated)")
}
14 changes: 13 additions & 1 deletion cmd/network/network_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package network

import (
"fmt"
"github.com/civo/civogo"
"os"

"github.com/civo/cli/common"
Expand All @@ -10,6 +11,11 @@ import (
"github.com/spf13/cobra"
)

var (
cidrV4 string
nameserversV4 []string
)

var networkCreateCmd = &cobra.Command{
Use: "create",
Aliases: []string{"new", "add"},
Expand All @@ -28,7 +34,13 @@ var networkCreateCmd = &cobra.Command{
os.Exit(1)
}

network, err := client.NewNetwork(args[0])
networkConfig := civogo.NetworkConfig{
Label: args[0],
CIDRv4: cidrV4,
NameserversV4: nameserversV4,
}

network, err := client.CreateNetwork(networkConfig)
if err != nil {
utility.Error("%s", err)
os.Exit(1)
Expand Down

0 comments on commit 5eddd8d

Please sign in to comment.