Skip to content

Commit

Permalink
Merge pull request #415 from civo/private-ipv4
Browse files Browse the repository at this point in the history
Support Private IP in create Instance
  • Loading branch information
uzaxirr authored May 7, 2024
2 parents bbff382 + 7017fa6 commit 302ba9f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions cmd/instance/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func init() {
instanceCreateCmd.Flags().StringVarP(&network, "network", "r", "", "the instance's network you can use the Name or the ID")
instanceCreateCmd.Flags().StringVarP(&firewall, "firewall", "l", "", "the instance's firewall you can use the Name or the ID")
instanceCreateCmd.Flags().StringVarP(&tags, "tags", "g", "", "the instance's tags")
instanceCreateCmd.Flags().StringVarP(&privateIPv4, "private_ipv4", "", "", "Private IPv4 address")
instanceCreateCmd.Flags().StringVarP(&tags, "region", "e", "", "the region code identifier to have your instance built in")
instanceCreateCmd.Flags().StringVar(&script, "script", "", "path to a script that will be uploaded to /usr/local/bin/civo-user-init-script on your instance, read/write/executable only by root and then will be executed at the end of the cloud initialization")
instanceCreateCmd.Flags().BoolVar(&skipShebangCheck, "skip-shebang-check", false, "skip the shebang line check when passing a user init script")
Expand Down
9 changes: 7 additions & 2 deletions cmd/instance/instance_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

var wait bool
var hostnameCreate, size, diskimage, publicip, initialuser, sshkey, tags, network, firewall string
var hostnameCreate, size, diskimage, publicip, initialuser, sshkey, tags, network, privateIPv4, firewall string
var script string
var skipShebangCheck bool

Expand All @@ -27,7 +27,7 @@ var instanceCreateCmd = &cobra.Command{
Aliases: []string{"new", "add"},
Short: "Create a new instance",
Example: "civo instance create HOSTNAME [flags]",
Long: `You can create an instance with a hostname argument, as well as any other options you provide.
Long: `You can create an instance with a hostname argument, as well as any other options you provide.
If you don't provide a hostname, it will be automatically generated.
If you wish to use a custom format, the available fields are:
* id
Expand Down Expand Up @@ -143,6 +143,11 @@ If you wish to use a custom format, the available fields are:
config.PublicIPRequired = publicip
}

// Set private_ipv4 if provided
if privateIPv4 != "" {
config.PrivateIPv4 = privateIPv4
}

if initialuser != "" {
config.InitialUser = initialuser
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 // indirect
github.com/briandowns/spinner v1.11.1
github.com/c4milo/unpackit v0.0.0-20170704181138-4ed373e9ef1c // indirect
github.com/civo/civogo v0.3.67
github.com/civo/civogo v0.3.69
github.com/dsnet/compress v0.0.1 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/google/go-github v17.0.0+incompatible // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ github.com/c4milo/unpackit v0.0.0-20170704181138-4ed373e9ef1c/go.mod h1:Ie6SubJv
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/civo/civogo v0.3.67 h1:R6MepF20Od7KQdcEKpr3GD8zKy1Jly0SuBDubZkEU2s=
github.com/civo/civogo v0.3.67/go.mod h1:S/iYmGvQOraxdRtcXeq/2mVX01/ia2qfpQUp2SsTLKA=
github.com/civo/civogo v0.3.69 h1:Not+F3Z1mxtXjMvDhUD5Nwi/1ql3uBT0ioRfhKXYhOA=
github.com/civo/civogo v0.3.69/go.mod h1:7UCYX+qeeJbrG55E1huv+0ySxcHTqq/26FcHLVelQJM=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
Expand Down

0 comments on commit 302ba9f

Please sign in to comment.