Skip to content

Commit

Permalink
Bump egoscale and improve find elastic ip
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre-Emmanuel Jacquier <[email protected]>
  • Loading branch information
pierre-emmanuelJ committed Sep 11, 2024
1 parent cb69129 commit f8df71e
Show file tree
Hide file tree
Showing 23 changed files with 2,421 additions and 526 deletions.
19 changes: 13 additions & 6 deletions cmd/instance_pool_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"fmt"
"os"
"strings"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -110,17 +111,23 @@ func (c *instancePoolCreateCmd) cmdRun(_ *cobra.Command, _ []string) error {
}

if l := len(c.ElasticIPs); l > 0 {
instancePoolReq.ElasticIPS = make([]v3.ElasticIP, l)
eIP, err := client.ListElasticIPS(ctx)
result := []v3.ElasticIP{}
eipList, err := client.ListElasticIPS(ctx)
if err != nil {
return fmt.Errorf("error listing Elastic IP: %w", err)
}
for i := range c.ElasticIPs {
elasticIP, err := eIP.FindElasticIP(c.ElasticIPs[i])
for _, input := range c.ElasticIPs {
eip, err := eipList.FindElasticIP(input)
if err != nil {
return fmt.Errorf("error retrieving Elastic IP: %w", err)
fmt.Fprintf(os.Stderr, "warning: Elastic IP %s not found.\n", input)
continue
}
instancePoolReq.ElasticIPS[i] = elasticIP

result = append(result, v3.ElasticIP{ID: eip.ID})
}

if len(result) != 0 {
instancePoolReq.ElasticIPS = result
}
}

Expand Down
25 changes: 12 additions & 13 deletions cmd/instance_pool_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,26 +119,25 @@ func (c *instancePoolUpdateCmd) cmdRun(cmd *cobra.Command, _ []string) error { /
}

if cmd.Flags().Changed(mustCLICommandFlagName(c, &c.ElasticIPs)) {
updateReq.ElasticIPS = make([]v3.ElasticIP, len(c.ElasticIPs))
result := []v3.ElasticIP{}
eipList, err := client.ListElasticIPS(ctx)
if err != nil {
return fmt.Errorf("error listing Elastic IP: %w", err)
}
for i, input := range c.ElasticIPs {
found := false
for _, eip := range eipList.ElasticIPS {
if input == eip.IP || input == string(eip.ID) {
updateReq.ElasticIPS[i] = v3.ElasticIP{ID: eip.ID}
found = true
break
}
}
if !found {
fmt.Fprintf(os.Stderr, "warning: %s not found.\n", input)
for _, input := range c.ElasticIPs {
eip, err := eipList.FindElasticIP(input)
if err != nil {
fmt.Fprintf(os.Stderr, "warning: Elastic IP %s not found.\n", input)
continue
}

result = append(result, v3.ElasticIP{ID: eip.ID})
}

updated = true
if len(result) != 0 {
updateReq.ElasticIPS = result
updated = true
}
}

if cmd.Flags().Changed(mustCLICommandFlagName(c, &c.InstancePrefix)) {
Expand Down
10 changes: 6 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/aws/smithy-go v1.1.0
github.com/dustin/go-humanize v1.0.1
github.com/exoscale/egoscale v0.102.4
github.com/exoscale/egoscale/v3 v3.1.1
github.com/exoscale/egoscale/v3 v3.1.3-0.20240911131558-1388ae1762b4
github.com/exoscale/openapi-cli-generator v1.1.0
github.com/fatih/camelcase v1.0.0
github.com/google/uuid v1.4.0
Expand All @@ -27,7 +27,7 @@ require (
github.com/spf13/cobra v1.3.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.18.2
github.com/stretchr/testify v1.8.4
github.com/stretchr/testify v1.9.0
github.com/vbauerster/mpb/v4 v4.12.2
github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1
github.com/xeipuuv/gojsonschema v1.2.0
Expand Down Expand Up @@ -132,7 +132,7 @@ require (
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/stretchr/objx v0.5.1 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tdewolff/minify/v2 v2.12.8 // indirect
github.com/tdewolff/parse/v2 v2.6.7 // indirect
Expand Down Expand Up @@ -161,4 +161,6 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

go 1.22
go 1.23.0

toolchain go1.23.1
11 changes: 6 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
github.com/envoyproxy/protoc-gen-validate v0.6.2/go.mod h1:2t7qjJNvHPx8IjnBOzl9E9/baC+qXE/TeeyBRzgJDws=
github.com/exoscale/egoscale v0.102.4 h1:GBKsZMIOzwBfSu+4ZmWka3Ejf2JLiaBDHp4CQUgvp2E=
github.com/exoscale/egoscale v0.102.4/go.mod h1:ROSmPtle0wvf91iLZb09++N/9BH2Jo9XxIpAEumvocA=
github.com/exoscale/egoscale/v3 v3.1.1 h1:NwTlXE2sKe2kBWm+c3bsHV+aWDFiEJ9JQpS6X3j4wbc=
github.com/exoscale/egoscale/v3 v3.1.1/go.mod h1:lPsza7G+giSxdzvzaHSEcjEAYz/YTiu2bEEha9KVAc4=
github.com/exoscale/egoscale/v3 v3.1.3-0.20240911131558-1388ae1762b4 h1:cpCmQ0JQsvzWNsBe5zbYR+QQ2hCLyKshQI1ZB+BGkxs=
github.com/exoscale/egoscale/v3 v3.1.3-0.20240911131558-1388ae1762b4/go.mod h1:6jaXkxVuV18K6CMd4O2jSE7xL+viOy3xZc2a4TBpfJ8=
github.com/exoscale/openapi-cli-generator v1.1.0 h1:fYjmPqHR5vxlOBrbvde7eo7bISNQIFxsGn4A5/acwKA=
github.com/exoscale/openapi-cli-generator v1.1.0/go.mod h1:TZBnbT7f3hJ5ImyUphJwRM+X5xF/zCQZ6o8a42gQeTs=
github.com/fatih/camelcase v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8=
Expand Down Expand Up @@ -612,8 +612,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.1 h1:4VhoImhV/Bm0ToFkXFi8hXNXwpDRZ/ynw3amt82mzq0=
github.com/stretchr/objx v0.5.1/go.mod h1:/iHQpkQwBD6DLUmQ4pE+s1TXdob1mORJ4/UFdrifcy0=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
Expand All @@ -624,8 +624,9 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
Expand Down
67 changes: 67 additions & 0 deletions vendor/github.com/exoscale/egoscale/v3/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vendor/github.com/exoscale/egoscale/v3/api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions vendor/github.com/exoscale/egoscale/v3/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f8df71e

Please sign in to comment.