diff --git a/go.mod b/go.mod index 7dc7283..ac13665 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/dirien/devpod-provider-scaleway -go 1.23.0 +go 1.24.0 toolchain go1.24.1 @@ -8,7 +8,7 @@ require ( github.com/loft-sh/devpod v0.6.15 github.com/loft-sh/log v0.0.0-20240219160058-26d83ffb46ac github.com/pkg/errors v0.9.1 - github.com/scaleway/scaleway-sdk-go v1.0.0-beta.34 + github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35 github.com/spf13/cobra v1.9.1 golang.org/x/crypto v0.38.0 ) @@ -41,10 +41,10 @@ require ( github.com/sirupsen/logrus v1.9.3 // indirect github.com/spf13/pflag v1.0.6 // indirect github.com/tidwall/jsonc v0.3.2 // indirect - golang.org/x/sync v0.15.0 // indirect + golang.org/x/sync v0.17.0 // indirect golang.org/x/sys v0.33.0 // indirect golang.org/x/term v0.32.0 // indirect - golang.org/x/text v0.26.0 // indirect + golang.org/x/text v0.29.0 // indirect google.golang.org/protobuf v1.35.1 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect diff --git a/go.sum b/go.sum index 9a93974..24e7f68 100644 --- a/go.sum +++ b/go.sum @@ -85,8 +85,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.34 h1:48+VFHsyVcAHIN2v1Ao9v1/RkjJS5AwctFucBrfYNIA= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.34/go.mod h1:zFWiHphneiey3s8HOtAEnGrRlWivNaxW5T6d5Xfco7g= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35 h1:8xfn1RzeI9yoCUuEwDy08F+No6PcKZGEDOQ6hrRyLts= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35/go.mod h1:47B1d/YXmSAxlJxUJxClzHR6b3T4M1WyCvwENPQNBWc= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo= @@ -122,8 +122,8 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8= -golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug= +golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -146,8 +146,8 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M= -golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= +golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= +golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= diff --git a/vendor/github.com/scaleway/scaleway-sdk-go/api/instance/v1/instance_metadata_sdk.go b/vendor/github.com/scaleway/scaleway-sdk-go/api/instance/v1/instance_metadata_sdk.go index 9d6da40..d5ed413 100644 --- a/vendor/github.com/scaleway/scaleway-sdk-go/api/instance/v1/instance_metadata_sdk.go +++ b/vendor/github.com/scaleway/scaleway-sdk-go/api/instance/v1/instance_metadata_sdk.go @@ -96,6 +96,7 @@ type Metadata struct { Organization string `json:"organization,omitempty"` Project string `json:"project,omitempty"` CommercialType string `json:"commercial_type,omitempty"` + Image Image `json:"image,omitempty"` // PublicIP IPv4 only PublicIP struct { ID string `json:"id"` diff --git a/vendor/github.com/scaleway/scaleway-sdk-go/api/instance/v1/instance_sdk.go b/vendor/github.com/scaleway/scaleway-sdk-go/api/instance/v1/instance_sdk.go index aba7a54..6feab35 100644 --- a/vendor/github.com/scaleway/scaleway-sdk-go/api/instance/v1/instance_sdk.go +++ b/vendor/github.com/scaleway/scaleway-sdk-go/api/instance/v1/instance_sdk.go @@ -1059,10 +1059,11 @@ type VolumeServerState string const ( VolumeServerStateAvailable = VolumeServerState("available") VolumeServerStateSnapshotting = VolumeServerState("snapshotting") - VolumeServerStateFetching = VolumeServerState("fetching") VolumeServerStateResizing = VolumeServerState("resizing") + VolumeServerStateFetching = VolumeServerState("fetching") VolumeServerStateSaving = VolumeServerState("saving") VolumeServerStateHotsyncing = VolumeServerState("hotsyncing") + VolumeServerStateAttaching = VolumeServerState("attaching") VolumeServerStateError = VolumeServerState("error") ) @@ -1078,10 +1079,11 @@ func (enum VolumeServerState) Values() []VolumeServerState { return []VolumeServerState{ "available", "snapshotting", - "fetching", "resizing", + "fetching", "saving", "hotsyncing", + "attaching", "error", } } @@ -1148,8 +1150,8 @@ const ( VolumeStateAvailable = VolumeState("available") VolumeStateSnapshotting = VolumeState("snapshotting") VolumeStateFetching = VolumeState("fetching") - VolumeStateResizing = VolumeState("resizing") VolumeStateSaving = VolumeState("saving") + VolumeStateResizing = VolumeState("resizing") VolumeStateHotsyncing = VolumeState("hotsyncing") VolumeStateError = VolumeState("error") ) @@ -1167,8 +1169,8 @@ func (enum VolumeState) Values() []VolumeState { "available", "snapshotting", "fetching", - "resizing", "saving", + "resizing", "hotsyncing", "error", } @@ -2424,7 +2426,7 @@ type CreateServerRequest struct { // Name: instance name. Name string `json:"name,omitempty"` - // DynamicIPRequired: define if a dynamic IPv4 is required for the Instance. + // DynamicIPRequired: by default, `dynamic_ip_required` is true, a dynamic ip is attached to the instance (if no flexible ip is already attached). DynamicIPRequired *bool `json:"dynamic_ip_required,omitempty"` // Deprecated: RoutedIPEnabled: if true, configure the Instance so it uses the new routed IP mode. @@ -3560,6 +3562,15 @@ type PlanBlockMigrationRequest struct { SnapshotID *string `json:"snapshot_id,omitempty"` } +// ReleaseIPToIpamRequest: release ip to ipam request. +type ReleaseIPToIpamRequest struct { + // Zone: zone to target. If none is passed will use default zone from the config. + Zone scw.Zone `json:"-"` + + // IPID: ID of the IP you want to release from the Instance but retain in IPAM. + IPID string `json:"-"` +} + // ServerActionRequest: server action request. type ServerActionRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. @@ -4771,7 +4782,7 @@ func (s *API) GetServerCompatibleTypes(req *GetServerCompatibleTypesRequest, opt return &resp, nil } -// AttachServerVolume: +// AttachServerVolume: Attach a volume to an Instance. func (s *API) AttachServerVolume(req *AttachServerVolumeRequest, opts ...scw.RequestOption) (*AttachServerVolumeResponse, error) { var err error @@ -4807,7 +4818,7 @@ func (s *API) AttachServerVolume(req *AttachServerVolumeRequest, opts ...scw.Req return &resp, nil } -// DetachServerVolume: +// DetachServerVolume: Detach a volume from an Instance. func (s *API) DetachServerVolume(req *DetachServerVolumeRequest, opts ...scw.RequestOption) (*DetachServerVolumeResponse, error) { var err error @@ -4879,7 +4890,7 @@ func (s *API) AttachServerFileSystem(req *AttachServerFileSystemRequest, opts .. return &resp, nil } -// DetachServerFileSystem: Detach a filesystem volume to an Instance. +// DetachServerFileSystem: Detach a filesystem volume from an Instance. func (s *API) DetachServerFileSystem(req *DetachServerFileSystemRequest, opts ...scw.RequestOption) (*DetachServerFileSystemResponse, error) { var err error @@ -6914,3 +6925,37 @@ func (s *API) CheckBlockMigrationOrganizationQuotas(req *CheckBlockMigrationOrga } return nil } + +// ReleaseIPToIpam: **The IP remains available in IPAM**, which means that it is still reserved by the Organization, and can be reattached to another resource (Instance or other product). +func (s *API) ReleaseIPToIpam(req *ReleaseIPToIpamRequest, opts ...scw.RequestOption) error { + var err error + + if req.Zone == "" { + defaultZone, _ := s.client.GetDefaultZone() + req.Zone = defaultZone + } + + if fmt.Sprint(req.Zone) == "" { + return errors.New("field Zone cannot be empty in request") + } + + if fmt.Sprint(req.IPID) == "" { + return errors.New("field IPID cannot be empty in request") + } + + scwReq := &scw.ScalewayRequest{ + Method: "POST", + Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/ips/" + fmt.Sprint(req.IPID) + "/release-to-ipam", + } + + err = scwReq.SetBody(req) + if err != nil { + return err + } + + err = s.client.Do(scwReq, nil, opts...) + if err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/scaleway/scaleway-sdk-go/api/marketplace/v2/marketplace_sdk.go b/vendor/github.com/scaleway/scaleway-sdk-go/api/marketplace/v2/marketplace_sdk.go index 5f0fb65..465a869 100644 --- a/vendor/github.com/scaleway/scaleway-sdk-go/api/marketplace/v2/marketplace_sdk.go +++ b/vendor/github.com/scaleway/scaleway-sdk-go/api/marketplace/v2/marketplace_sdk.go @@ -401,6 +401,9 @@ type ListLocalImagesRequest struct { // Zone: filter local images available on this Availability Zone. Zone *scw.Zone `json:"-"` + // Arch: filter local images available for this machine architecture. + Arch *string `json:"-"` + // ImageID: filter by image id. // Precisely one of ImageID, VersionID, ImageLabel must be set. ImageID *string `json:"image_id,omitempty"` @@ -619,6 +622,7 @@ func (s *API) ListLocalImages(req *ListLocalImagesRequest, opts ...scw.RequestOp parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "zone", req.Zone) + parameter.AddToQuery(query, "arch", req.Arch) parameter.AddToQuery(query, "type", req.Type) parameter.AddToQuery(query, "image_id", req.ImageID) parameter.AddToQuery(query, "version_id", req.VersionID) diff --git a/vendor/github.com/scaleway/scaleway-sdk-go/api/std/std_sdk.go b/vendor/github.com/scaleway/scaleway-sdk-go/api/std/std_sdk.go index 0584f7a..3cec3ea 100644 --- a/vendor/github.com/scaleway/scaleway-sdk-go/api/std/std_sdk.go +++ b/vendor/github.com/scaleway/scaleway-sdk-go/api/std/std_sdk.go @@ -38,6 +38,539 @@ var ( _ = namegenerator.GetRandomName ) +type CountryCode string + +const ( + CountryCodeUnknownCountryCode = CountryCode("unknown_country_code") + CountryCodeAF = CountryCode("AF") + CountryCodeAX = CountryCode("AX") + CountryCodeAL = CountryCode("AL") + CountryCodeDZ = CountryCode("DZ") + CountryCodeAS = CountryCode("AS") + CountryCodeAD = CountryCode("AD") + CountryCodeAO = CountryCode("AO") + CountryCodeAI = CountryCode("AI") + CountryCodeAQ = CountryCode("AQ") + CountryCodeAG = CountryCode("AG") + CountryCodeAR = CountryCode("AR") + CountryCodeAM = CountryCode("AM") + CountryCodeAW = CountryCode("AW") + CountryCodeAU = CountryCode("AU") + CountryCodeAT = CountryCode("AT") + CountryCodeAZ = CountryCode("AZ") + CountryCodeBS = CountryCode("BS") + CountryCodeBH = CountryCode("BH") + CountryCodeBD = CountryCode("BD") + CountryCodeBB = CountryCode("BB") + CountryCodeBY = CountryCode("BY") + CountryCodeBE = CountryCode("BE") + CountryCodeBZ = CountryCode("BZ") + CountryCodeBJ = CountryCode("BJ") + CountryCodeBM = CountryCode("BM") + CountryCodeBT = CountryCode("BT") + CountryCodeBO = CountryCode("BO") + CountryCodeBQ = CountryCode("BQ") + CountryCodeBA = CountryCode("BA") + CountryCodeBW = CountryCode("BW") + CountryCodeBV = CountryCode("BV") + CountryCodeBR = CountryCode("BR") + CountryCodeIO = CountryCode("IO") + CountryCodeBN = CountryCode("BN") + CountryCodeBG = CountryCode("BG") + CountryCodeBF = CountryCode("BF") + CountryCodeBI = CountryCode("BI") + CountryCodeKH = CountryCode("KH") + CountryCodeCM = CountryCode("CM") + CountryCodeCA = CountryCode("CA") + CountryCodeCV = CountryCode("CV") + CountryCodeKY = CountryCode("KY") + CountryCodeCF = CountryCode("CF") + CountryCodeTD = CountryCode("TD") + CountryCodeCL = CountryCode("CL") + CountryCodeCN = CountryCode("CN") + CountryCodeCX = CountryCode("CX") + CountryCodeCC = CountryCode("CC") + CountryCodeCO = CountryCode("CO") + CountryCodeKM = CountryCode("KM") + CountryCodeCG = CountryCode("CG") + CountryCodeCD = CountryCode("CD") + CountryCodeCK = CountryCode("CK") + CountryCodeCR = CountryCode("CR") + CountryCodeCI = CountryCode("CI") + CountryCodeHR = CountryCode("HR") + CountryCodeCU = CountryCode("CU") + CountryCodeCW = CountryCode("CW") + CountryCodeCY = CountryCode("CY") + CountryCodeCZ = CountryCode("CZ") + CountryCodeDK = CountryCode("DK") + CountryCodeDJ = CountryCode("DJ") + CountryCodeDM = CountryCode("DM") + CountryCodeDO = CountryCode("DO") + CountryCodeEC = CountryCode("EC") + CountryCodeEG = CountryCode("EG") + CountryCodeSV = CountryCode("SV") + CountryCodeGQ = CountryCode("GQ") + CountryCodeER = CountryCode("ER") + CountryCodeEE = CountryCode("EE") + CountryCodeET = CountryCode("ET") + CountryCodeFK = CountryCode("FK") + CountryCodeFO = CountryCode("FO") + CountryCodeFJ = CountryCode("FJ") + CountryCodeFI = CountryCode("FI") + CountryCodeFR = CountryCode("FR") + CountryCodeGF = CountryCode("GF") + CountryCodePF = CountryCode("PF") + CountryCodeTF = CountryCode("TF") + CountryCodeGA = CountryCode("GA") + CountryCodeGM = CountryCode("GM") + CountryCodeGE = CountryCode("GE") + CountryCodeDE = CountryCode("DE") + CountryCodeGH = CountryCode("GH") + CountryCodeGI = CountryCode("GI") + CountryCodeGR = CountryCode("GR") + CountryCodeGL = CountryCode("GL") + CountryCodeGD = CountryCode("GD") + CountryCodeGP = CountryCode("GP") + CountryCodeGU = CountryCode("GU") + CountryCodeGT = CountryCode("GT") + CountryCodeGG = CountryCode("GG") + CountryCodeGN = CountryCode("GN") + CountryCodeGW = CountryCode("GW") + CountryCodeGY = CountryCode("GY") + CountryCodeHT = CountryCode("HT") + CountryCodeHM = CountryCode("HM") + CountryCodeVA = CountryCode("VA") + CountryCodeHN = CountryCode("HN") + CountryCodeHK = CountryCode("HK") + CountryCodeHU = CountryCode("HU") + CountryCodeIS = CountryCode("IS") + CountryCodeIN = CountryCode("IN") + CountryCodeID = CountryCode("ID") + CountryCodeIR = CountryCode("IR") + CountryCodeIQ = CountryCode("IQ") + CountryCodeIE = CountryCode("IE") + CountryCodeIM = CountryCode("IM") + CountryCodeIL = CountryCode("IL") + CountryCodeIT = CountryCode("IT") + CountryCodeJM = CountryCode("JM") + CountryCodeJP = CountryCode("JP") + CountryCodeJE = CountryCode("JE") + CountryCodeJO = CountryCode("JO") + CountryCodeKZ = CountryCode("KZ") + CountryCodeKE = CountryCode("KE") + CountryCodeKI = CountryCode("KI") + CountryCodeKP = CountryCode("KP") + CountryCodeKR = CountryCode("KR") + CountryCodeKW = CountryCode("KW") + CountryCodeKG = CountryCode("KG") + CountryCodeLA = CountryCode("LA") + CountryCodeLV = CountryCode("LV") + CountryCodeLB = CountryCode("LB") + CountryCodeLS = CountryCode("LS") + CountryCodeLR = CountryCode("LR") + CountryCodeLY = CountryCode("LY") + CountryCodeLI = CountryCode("LI") + CountryCodeLT = CountryCode("LT") + CountryCodeLU = CountryCode("LU") + CountryCodeMO = CountryCode("MO") + CountryCodeMK = CountryCode("MK") + CountryCodeMG = CountryCode("MG") + CountryCodeMW = CountryCode("MW") + CountryCodeMY = CountryCode("MY") + CountryCodeMV = CountryCode("MV") + CountryCodeML = CountryCode("ML") + CountryCodeMT = CountryCode("MT") + CountryCodeMH = CountryCode("MH") + CountryCodeMQ = CountryCode("MQ") + CountryCodeMR = CountryCode("MR") + CountryCodeMU = CountryCode("MU") + CountryCodeYT = CountryCode("YT") + CountryCodeMX = CountryCode("MX") + CountryCodeFM = CountryCode("FM") + CountryCodeMD = CountryCode("MD") + CountryCodeMC = CountryCode("MC") + CountryCodeMN = CountryCode("MN") + CountryCodeME = CountryCode("ME") + CountryCodeMS = CountryCode("MS") + CountryCodeMA = CountryCode("MA") + CountryCodeMZ = CountryCode("MZ") + CountryCodeMM = CountryCode("MM") + CountryCodeNA = CountryCode("NA") + CountryCodeNR = CountryCode("NR") + CountryCodeNP = CountryCode("NP") + CountryCodeNL = CountryCode("NL") + CountryCodeNC = CountryCode("NC") + CountryCodeNZ = CountryCode("NZ") + CountryCodeNI = CountryCode("NI") + CountryCodeNE = CountryCode("NE") + CountryCodeNG = CountryCode("NG") + CountryCodeNU = CountryCode("NU") + CountryCodeNF = CountryCode("NF") + CountryCodeMP = CountryCode("MP") + CountryCodeNO = CountryCode("NO") + CountryCodeOM = CountryCode("OM") + CountryCodePK = CountryCode("PK") + CountryCodePW = CountryCode("PW") + CountryCodePS = CountryCode("PS") + CountryCodePA = CountryCode("PA") + CountryCodePG = CountryCode("PG") + CountryCodePY = CountryCode("PY") + CountryCodePE = CountryCode("PE") + CountryCodePH = CountryCode("PH") + CountryCodePN = CountryCode("PN") + CountryCodePL = CountryCode("PL") + CountryCodePT = CountryCode("PT") + CountryCodePR = CountryCode("PR") + CountryCodeQA = CountryCode("QA") + CountryCodeRE = CountryCode("RE") + CountryCodeRO = CountryCode("RO") + CountryCodeRU = CountryCode("RU") + CountryCodeRW = CountryCode("RW") + CountryCodeBL = CountryCode("BL") + CountryCodeSH = CountryCode("SH") + CountryCodeKN = CountryCode("KN") + CountryCodeLC = CountryCode("LC") + CountryCodeMF = CountryCode("MF") + CountryCodePM = CountryCode("PM") + CountryCodeVC = CountryCode("VC") + CountryCodeWS = CountryCode("WS") + CountryCodeSM = CountryCode("SM") + CountryCodeST = CountryCode("ST") + CountryCodeSA = CountryCode("SA") + CountryCodeSN = CountryCode("SN") + CountryCodeRS = CountryCode("RS") + CountryCodeSC = CountryCode("SC") + CountryCodeSL = CountryCode("SL") + CountryCodeSG = CountryCode("SG") + CountryCodeSX = CountryCode("SX") + CountryCodeSK = CountryCode("SK") + CountryCodeSI = CountryCode("SI") + CountryCodeSB = CountryCode("SB") + CountryCodeSO = CountryCode("SO") + CountryCodeZA = CountryCode("ZA") + CountryCodeGS = CountryCode("GS") + CountryCodeSS = CountryCode("SS") + CountryCodeES = CountryCode("ES") + CountryCodeLK = CountryCode("LK") + CountryCodeSD = CountryCode("SD") + CountryCodeSR = CountryCode("SR") + CountryCodeSJ = CountryCode("SJ") + CountryCodeSZ = CountryCode("SZ") + CountryCodeSE = CountryCode("SE") + CountryCodeCH = CountryCode("CH") + CountryCodeSY = CountryCode("SY") + CountryCodeTW = CountryCode("TW") + CountryCodeTJ = CountryCode("TJ") + CountryCodeTZ = CountryCode("TZ") + CountryCodeTH = CountryCode("TH") + CountryCodeTL = CountryCode("TL") + CountryCodeTG = CountryCode("TG") + CountryCodeTK = CountryCode("TK") + CountryCodeTO = CountryCode("TO") + CountryCodeTT = CountryCode("TT") + CountryCodeTN = CountryCode("TN") + CountryCodeTR = CountryCode("TR") + CountryCodeTM = CountryCode("TM") + CountryCodeTC = CountryCode("TC") + CountryCodeTV = CountryCode("TV") + CountryCodeUG = CountryCode("UG") + CountryCodeUA = CountryCode("UA") + CountryCodeAE = CountryCode("AE") + CountryCodeGB = CountryCode("GB") + CountryCodeUS = CountryCode("US") + CountryCodeUM = CountryCode("UM") + CountryCodeUY = CountryCode("UY") + CountryCodeUZ = CountryCode("UZ") + CountryCodeVU = CountryCode("VU") + CountryCodeVE = CountryCode("VE") + CountryCodeVN = CountryCode("VN") + CountryCodeVG = CountryCode("VG") + CountryCodeVI = CountryCode("VI") + CountryCodeWF = CountryCode("WF") + CountryCodeEH = CountryCode("EH") + CountryCodeYE = CountryCode("YE") + CountryCodeZM = CountryCode("ZM") + CountryCodeZW = CountryCode("ZW") +) + +func (enum CountryCode) String() string { + if enum == "" { + // return default value if empty + return string(CountryCodeUnknownCountryCode) + } + return string(enum) +} + +func (enum CountryCode) Values() []CountryCode { + return []CountryCode{ + "unknown_country_code", + "AF", + "AX", + "AL", + "DZ", + "AS", + "AD", + "AO", + "AI", + "AQ", + "AG", + "AR", + "AM", + "AW", + "AU", + "AT", + "AZ", + "BS", + "BH", + "BD", + "BB", + "BY", + "BE", + "BZ", + "BJ", + "BM", + "BT", + "BO", + "BQ", + "BA", + "BW", + "BV", + "BR", + "IO", + "BN", + "BG", + "BF", + "BI", + "KH", + "CM", + "CA", + "CV", + "KY", + "CF", + "TD", + "CL", + "CN", + "CX", + "CC", + "CO", + "KM", + "CG", + "CD", + "CK", + "CR", + "CI", + "HR", + "CU", + "CW", + "CY", + "CZ", + "DK", + "DJ", + "DM", + "DO", + "EC", + "EG", + "SV", + "GQ", + "ER", + "EE", + "ET", + "FK", + "FO", + "FJ", + "FI", + "FR", + "GF", + "PF", + "TF", + "GA", + "GM", + "GE", + "DE", + "GH", + "GI", + "GR", + "GL", + "GD", + "GP", + "GU", + "GT", + "GG", + "GN", + "GW", + "GY", + "HT", + "HM", + "VA", + "HN", + "HK", + "HU", + "IS", + "IN", + "ID", + "IR", + "IQ", + "IE", + "IM", + "IL", + "IT", + "JM", + "JP", + "JE", + "JO", + "KZ", + "KE", + "KI", + "KP", + "KR", + "KW", + "KG", + "LA", + "LV", + "LB", + "LS", + "LR", + "LY", + "LI", + "LT", + "LU", + "MO", + "MK", + "MG", + "MW", + "MY", + "MV", + "ML", + "MT", + "MH", + "MQ", + "MR", + "MU", + "YT", + "MX", + "FM", + "MD", + "MC", + "MN", + "ME", + "MS", + "MA", + "MZ", + "MM", + "NA", + "NR", + "NP", + "NL", + "NC", + "NZ", + "NI", + "NE", + "NG", + "NU", + "NF", + "MP", + "NO", + "OM", + "PK", + "PW", + "PS", + "PA", + "PG", + "PY", + "PE", + "PH", + "PN", + "PL", + "PT", + "PR", + "QA", + "RE", + "RO", + "RU", + "RW", + "BL", + "SH", + "KN", + "LC", + "MF", + "PM", + "VC", + "WS", + "SM", + "ST", + "SA", + "SN", + "RS", + "SC", + "SL", + "SG", + "SX", + "SK", + "SI", + "SB", + "SO", + "ZA", + "GS", + "SS", + "ES", + "LK", + "SD", + "SR", + "SJ", + "SZ", + "SE", + "CH", + "SY", + "TW", + "TJ", + "TZ", + "TH", + "TL", + "TG", + "TK", + "TO", + "TT", + "TN", + "TR", + "TM", + "TC", + "TV", + "UG", + "UA", + "AE", + "GB", + "US", + "UM", + "UY", + "UZ", + "VU", + "VE", + "VN", + "VG", + "VI", + "WF", + "EH", + "YE", + "ZM", + "ZW", + } +} + +func (enum CountryCode) MarshalJSON() ([]byte, error) { + return []byte(fmt.Sprintf(`"%s"`, enum)), nil +} + +func (enum *CountryCode) UnmarshalJSON(data []byte) error { + tmp := "" + + if err := json.Unmarshal(data, &tmp); err != nil { + return err + } + + *enum = CountryCode(CountryCode(tmp).String()) + return nil +} + type LanguageCode string const ( diff --git a/vendor/github.com/scaleway/scaleway-sdk-go/scw/client.go b/vendor/github.com/scaleway/scaleway-sdk-go/scw/client.go index 0f9a8a2..c509084 100644 --- a/vendor/github.com/scaleway/scaleway-sdk-go/scw/client.go +++ b/vendor/github.com/scaleway/scaleway-sdk-go/scw/client.go @@ -395,7 +395,7 @@ L: // We gather potential errors and return them all together for { select { case newErr := <-errChan: - err = errors.Wrap(err, newErr.Error()) + err = errors.Wrap(err, "%s", newErr.Error()) default: break L } @@ -556,6 +556,15 @@ func setInsecureMode(c httpClient) { logger.Warningf("client: cannot use insecure mode with HTTP client of type %T", c) return } + + altTransport, ok := standardHTTPClient.Transport.(interface { + SetInsecureTransport() + }) + if ok { + altTransport.SetInsecureTransport() + return + } + transportClient, ok := standardHTTPClient.Transport.(*http.Transport) if !ok { logger.Warningf("client: cannot use insecure mode with Transport client of type %T", standardHTTPClient.Transport) diff --git a/vendor/golang.org/x/sync/errgroup/errgroup.go b/vendor/golang.org/x/sync/errgroup/errgroup.go index cb6bb9a..1d8cffa 100644 --- a/vendor/golang.org/x/sync/errgroup/errgroup.go +++ b/vendor/golang.org/x/sync/errgroup/errgroup.go @@ -12,8 +12,6 @@ package errgroup import ( "context" "fmt" - "runtime" - "runtime/debug" "sync" ) @@ -33,10 +31,6 @@ type Group struct { errOnce sync.Once err error - - mu sync.Mutex - panicValue any // = PanicError | PanicValue; non-nil if some Group.Go goroutine panicked. - abnormal bool // some Group.Go goroutine terminated abnormally (panic or goexit). } func (g *Group) done() { @@ -56,22 +50,13 @@ func WithContext(ctx context.Context) (*Group, context.Context) { return &Group{cancel: cancel}, ctx } -// Wait blocks until all function calls from the Go method have returned -// normally, then returns the first non-nil error (if any) from them. -// -// If any of the calls panics, Wait panics with a [PanicValue]; -// and if any of them calls [runtime.Goexit], Wait calls runtime.Goexit. +// Wait blocks until all function calls from the Go method have returned, then +// returns the first non-nil error (if any) from them. func (g *Group) Wait() error { g.wg.Wait() if g.cancel != nil { g.cancel(g.err) } - if g.panicValue != nil { - panic(g.panicValue) - } - if g.abnormal { - runtime.Goexit() - } return g.err } @@ -81,53 +66,31 @@ func (g *Group) Wait() error { // It blocks until the new goroutine can be added without the number of // goroutines in the group exceeding the configured limit. // -// The first goroutine in the group that returns a non-nil error, panics, or -// invokes [runtime.Goexit] will cancel the associated Context, if any. +// The first goroutine in the group that returns a non-nil error will +// cancel the associated Context, if any. The error will be returned +// by Wait. func (g *Group) Go(f func() error) { if g.sem != nil { g.sem <- token{} } - g.add(f) -} - -func (g *Group) add(f func() error) { g.wg.Add(1) go func() { defer g.done() - normalReturn := false - defer func() { - if normalReturn { - return - } - v := recover() - g.mu.Lock() - defer g.mu.Unlock() - if !g.abnormal { - if g.cancel != nil { - g.cancel(g.err) - } - g.abnormal = true - } - if v != nil && g.panicValue == nil { - switch v := v.(type) { - case error: - g.panicValue = PanicError{ - Recovered: v, - Stack: debug.Stack(), - } - default: - g.panicValue = PanicValue{ - Recovered: v, - Stack: debug.Stack(), - } - } - } - }() - err := f() - normalReturn = true - if err != nil { + // It is tempting to propagate panics from f() + // up to the goroutine that calls Wait, but + // it creates more problems than it solves: + // - it delays panics arbitrarily, + // making bugs harder to detect; + // - it turns f's panic stack into a mere value, + // hiding it from crash-monitoring tools; + // - it risks deadlocks that hide the panic entirely, + // if f's panic leaves the program in a state + // that prevents the Wait call from being reached. + // See #53757, #74275, #74304, #74306. + + if err := f(); err != nil { g.errOnce.Do(func() { g.err = err if g.cancel != nil { @@ -152,7 +115,19 @@ func (g *Group) TryGo(f func() error) bool { } } - g.add(f) + g.wg.Add(1) + go func() { + defer g.done() + + if err := f(); err != nil { + g.errOnce.Do(func() { + g.err = err + if g.cancel != nil { + g.cancel(g.err) + } + }) + } + }() return true } @@ -174,34 +149,3 @@ func (g *Group) SetLimit(n int) { } g.sem = make(chan token, n) } - -// PanicError wraps an error recovered from an unhandled panic -// when calling a function passed to Go or TryGo. -type PanicError struct { - Recovered error - Stack []byte // result of call to [debug.Stack] -} - -func (p PanicError) Error() string { - if len(p.Stack) > 0 { - return fmt.Sprintf("recovered from errgroup.Group: %v\n%s", p.Recovered, p.Stack) - } - return fmt.Sprintf("recovered from errgroup.Group: %v", p.Recovered) -} - -func (p PanicError) Unwrap() error { return p.Recovered } - -// PanicValue wraps a value that does not implement the error interface, -// recovered from an unhandled panic when calling a function passed to Go or -// TryGo. -type PanicValue struct { - Recovered any - Stack []byte // result of call to [debug.Stack] -} - -func (p PanicValue) String() string { - if len(p.Stack) > 0 { - return fmt.Sprintf("recovered from errgroup.Group: %v\n%s", p.Recovered, p.Stack) - } - return fmt.Sprintf("recovered from errgroup.Group: %v", p.Recovered) -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 2f5ad75..55e6a5a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -105,8 +105,8 @@ github.com/pkg/errors github.com/planetscale/vtprotobuf/protohelpers # github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 ## explicit -# github.com/scaleway/scaleway-sdk-go v1.0.0-beta.34 -## explicit; go 1.23.0 +# github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35 +## explicit; go 1.24.0 github.com/scaleway/scaleway-sdk-go/api/account/v3 github.com/scaleway/scaleway-sdk-go/api/block/v1alpha1 github.com/scaleway/scaleway-sdk-go/api/instance/v1 @@ -144,8 +144,8 @@ golang.org/x/crypto/internal/poly1305 golang.org/x/crypto/ssh golang.org/x/crypto/ssh/agent golang.org/x/crypto/ssh/internal/bcrypt_pbkdf -# golang.org/x/sync v0.15.0 -## explicit; go 1.23.0 +# golang.org/x/sync v0.17.0 +## explicit; go 1.24.0 golang.org/x/sync/errgroup # golang.org/x/sys v0.33.0 ## explicit; go 1.23.0 @@ -156,8 +156,8 @@ golang.org/x/sys/windows # golang.org/x/term v0.32.0 ## explicit; go 1.23.0 golang.org/x/term -# golang.org/x/text v0.26.0 -## explicit; go 1.23.0 +# golang.org/x/text v0.29.0 +## explicit; go 1.24.0 golang.org/x/text/cases golang.org/x/text/internal golang.org/x/text/internal/language