From 7017fa66b335cb2776a64eb1d2959caa6ad98c5d Mon Sep 17 00:00:00 2001 From: Uzair Ali <72073401+uzaxirr@users.noreply.github.com> Date: Mon, 6 May 2024 23:41:44 +0530 Subject: [PATCH] Support Private IPS in create Instance --- cmd/instance/instance.go | 1 + cmd/instance/instance_create.go | 9 +++++++-- go.mod | 2 +- go.sum | 2 ++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cmd/instance/instance.go b/cmd/instance/instance.go index 79e49df8..7c26d31a 100644 --- a/cmd/instance/instance.go +++ b/cmd/instance/instance.go @@ -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") diff --git a/cmd/instance/instance_create.go b/cmd/instance/instance_create.go index 1442ce92..632961d0 100644 --- a/cmd/instance/instance_create.go +++ b/cmd/instance/instance_create.go @@ -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 @@ -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 @@ -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 } diff --git a/go.mod b/go.mod index 1f76d3ba..c1cd4911 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index cf4d4274..84b919d4 100644 --- a/go.sum +++ b/go.sum @@ -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=