From ece44151d64e755c6000495963998946f8c13ac2 Mon Sep 17 00:00:00 2001 From: David MICHENEAU Date: Tue, 21 Nov 2023 16:09:10 +0100 Subject: [PATCH] feat: Add publicip feature --- .changelog/{000.txt => 0.txt} | 0 .changelog/3.txt | 7 +++++ cmd/publicip.go | 51 ++++++++++------------------------- go.mod | 2 +- go.sum | 4 +-- 5 files changed, 24 insertions(+), 40 deletions(-) rename .changelog/{000.txt => 0.txt} (100%) create mode 100644 .changelog/3.txt diff --git a/.changelog/000.txt b/.changelog/0.txt similarity index 100% rename from .changelog/000.txt rename to .changelog/0.txt diff --git a/.changelog/3.txt b/.changelog/3.txt new file mode 100644 index 0000000..5394949 --- /dev/null +++ b/.changelog/3.txt @@ -0,0 +1,7 @@ +```release-note:feature +`New publicip` - Add List, Create, Delete operations for publicip. +``` + +```release-note:dependency +deps: bumps cloudavenue-sdk-go from 1.5.5 to 1.5.6 +``` \ No newline at end of file diff --git a/cmd/publicip.go b/cmd/publicip.go index ec9fafb..f4ded4c 100644 --- a/cmd/publicip.go +++ b/cmd/publicip.go @@ -31,7 +31,7 @@ func init() { // ? Create command publicipCmd.AddCommand(publicipCreateCmd) - publicipCreateCmd.PersistentFlags().String("name", "", "vdc name") + publicipCreateCmd.PersistentFlags().String("name", "", "edge gateway name") if err := publicipCreateCmd.MarkPersistentFlagRequired("name"); err != nil { log.Default().Println("Error from Flag name, is require.", err) return @@ -80,7 +80,7 @@ var publicipListCmd = &cobra.Command{ // deleteCmd represents the delete command var publicipDelCmd = &cobra.Command{ Use: "delete", - Example: "publicip delete [] [] ...", + Example: "publicip delete [] [] ...", Short: "Delete publicip resource(s)", Run: func(cmd *cobra.Command, args []string) { @@ -89,12 +89,12 @@ var publicipDelCmd = &cobra.Command{ fmt.Println("delete publicip resource " + arg) ip, err := c.V1.PublicIP.GetIP(arg) if err != nil { - log.Default().Println("Error from ip", err) + log.Default().Println("Error from ip: ", err) return } job, err := ip.Delete() if err != nil { - log.Default().Println("Unable to delete ip", err) + log.Default().Println("Unable to delete ip: ", err) return } err = job.Wait(15, 300) @@ -125,45 +125,22 @@ var publicipCreateCmd = &cobra.Command{ return } - // // Get EdgeGateway from name - // gw, err := c.V1.EdgeGateway.GetByName(gwName) - // if err != nil { - // log.Default().Println("EdgeGateway not found", err) - // return - // } - - // Create the vdc + // Create a public ip fmt.Println("create public ip resource") fmt.Println("for EdgeGateway name: " + gwName) - // c.V1.EdgeGateway. - - // _, err = c.V1.VDC.New(&v1.CAVVirtualDataCenter{Vdc: v1.CAVVirtualDataCenterVDC{ - // Name: vdcName, - // ServiceClass: "STD", - // BillingModel: "PAYG", - // CPUAllocated: 22000, - // VcpuInMhz2: 2200, - // Description: "vdc created by cloudavenue-cli", - // MemoryAllocated: 30, - // DisponibilityClass: "ONE-ROOM", - // StorageBillingModel: "PAYG", - // StorageProfiles: []v1.VDCStrorageProfile{ - // v1.VDCStrorageProfile{ //nolint - // Class: "gold", - // Limit: 500, - // Default: true, - // }, - // }, - // }}) - + job, err := c.V1.PublicIP.New(gwName) if err != nil { - log.Default().Println("Error from vdc", err) + log.Default().Println("Unable to create public ip", err) return } - - fmt.Println("vdc resource created successfully !") - fmt.Println("\nvdc resource list after creation:") + err = job.Wait(5, 300) + if err != nil { + log.Default().Println("Error during public ip creation !!", err) + return + } + fmt.Println("public ip resource created successfully !") + fmt.Println("\npublic ip resource list after creation:") publicipListCmd.Run(cmd, []string{}) }, diff --git a/go.mod b/go.mod index 770abb9..0a0a0f6 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21.3 require ( github.com/aws/aws-sdk-go v1.47.9 github.com/fbiville/markdown-table-formatter v0.3.0 - github.com/orange-cloudavenue/cloudavenue-sdk-go v0.5.4-0.20231120154256-3c8c8c214b94 + github.com/orange-cloudavenue/cloudavenue-sdk-go v0.5.6 github.com/spf13/cobra v1.8.0 ) diff --git a/go.sum b/go.sum index 740c234..23ab43b 100644 --- a/go.sum +++ b/go.sum @@ -16,8 +16,8 @@ github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9Y github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= -github.com/orange-cloudavenue/cloudavenue-sdk-go v0.5.4-0.20231120154256-3c8c8c214b94 h1:6eVvqWBkrAT+7cPQImyACBdNPrEkYkm0A5FuUCQsTfw= -github.com/orange-cloudavenue/cloudavenue-sdk-go v0.5.4-0.20231120154256-3c8c8c214b94/go.mod h1:cWQdAHu+UlpulY0Vv4i+yPG17PUp8ZhK06VOR5Oq8iM= +github.com/orange-cloudavenue/cloudavenue-sdk-go v0.5.6 h1:S2miIutUXVRB4UTY0zOXa3xZujKLtOqLUCAOYzweoDw= +github.com/orange-cloudavenue/cloudavenue-sdk-go v0.5.6/go.mod h1:cWQdAHu+UlpulY0Vv4i+yPG17PUp8ZhK06VOR5Oq8iM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=