From e6140fce6136f9dce20d9322f05b3085ce1ddec2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 May 2022 08:48:13 -0400 Subject: [PATCH] Bump github.com/vultr/govultr/v2 from 2.15.1 to 2.16.0 (#260) Bumps [github.com/vultr/govultr/v2](https://github.com/vultr/govultr) from 2.15.1 to 2.16.0. - [Release notes](https://github.com/vultr/govultr/releases) - [Changelog](https://github.com/vultr/govultr/blob/master/CHANGELOG.md) - [Commits](https://github.com/vultr/govultr/compare/v2.15.1...v2.16.0) --- updated-dependencies: - dependency-name: github.com/vultr/govultr/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 +- go.sum | 8 +- .../hashicorp/go-retryablehttp/README.md | 19 ++++ .../hashicorp/go-retryablehttp/client.go | 85 ++++++++++---- .../github.com/vultr/govultr/v2/CHANGELOG.md | 17 +++ .../vultr/govultr/v2/bare_metal_server.go | 60 +++++----- .../vultr/govultr/v2/firewall_rule.go | 6 +- vendor/github.com/vultr/govultr/v2/govultr.go | 2 +- .../github.com/vultr/govultr/v2/instance.go | 106 +++++++++--------- .../github.com/vultr/govultr/v2/kubernetes.go | 48 ++++++++ vendor/modules.txt | 4 +- 11 files changed, 249 insertions(+), 110 deletions(-) diff --git a/go.mod b/go.mod index 461fe2a6..fc13fde3 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.17 require ( github.com/spf13/cobra v1.4.0 github.com/spf13/viper v1.11.0 - github.com/vultr/govultr/v2 v2.15.1 + github.com/vultr/govultr/v2 v2.16.0 golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 ) @@ -14,7 +14,7 @@ require ( github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-retryablehttp v0.7.0 // indirect + github.com/hashicorp/go-retryablehttp v0.7.1 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/kr/pretty v0.2.0 // indirect diff --git a/go.sum b/go.sum index 984359b8..10e36909 100644 --- a/go.sum +++ b/go.sum @@ -218,8 +218,8 @@ github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iP github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-retryablehttp v0.7.0 h1:eu1EI/mbirUgP5C8hVsTNaGZreBDlYiwC1FZWkvQPQ4= -github.com/hashicorp/go-retryablehttp v0.7.0/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= +github.com/hashicorp/go-retryablehttp v0.7.1 h1:sUiuQAnLlbvmExtFQs72iFW/HXeUn8Z1aJLQ4LJJbTQ= +github.com/hashicorp/go-retryablehttp v0.7.1/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= @@ -348,8 +348,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= -github.com/vultr/govultr/v2 v2.15.1 h1:UooxPwrkNg8zeBYL+WUrlYFrm5ap1P/jlwtDlxvRJ9U= -github.com/vultr/govultr/v2 v2.15.1/go.mod h1:jbiv34j+vv4fVD1+qnSCqYlV95U2xLHxOtU+F+k/l2M= +github.com/vultr/govultr/v2 v2.16.0 h1:2Wa8znp9FrKLBCA5mp1XOk65k2g60uKnmaqO4z3ERtU= +github.com/vultr/govultr/v2 v2.16.0/go.mod h1:ZFOKGWmgjytfyjeyAdhQlSWwTjh2ig+X49cAp50dzXI= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/vendor/github.com/hashicorp/go-retryablehttp/README.md b/vendor/github.com/hashicorp/go-retryablehttp/README.md index 8943becf..09f5eaf2 100644 --- a/vendor/github.com/hashicorp/go-retryablehttp/README.md +++ b/vendor/github.com/hashicorp/go-retryablehttp/README.md @@ -45,6 +45,25 @@ The returned response object is an `*http.Response`, the same thing you would usually get from `net/http`. Had the request failed one or more times, the above call would block and retry with exponential backoff. +## Retrying cases that fail after a seeming success + +It's possible for a request to succeed in the sense that the expected response headers are received, but then to encounter network-level errors while reading the response body. In go-retryablehttp's most basic usage, this error would not be retryable, due to the out-of-band handling of the response body. In some cases it may be desirable to handle the response body as part of the retryable operation. + +A toy example (which will retry the full request and succeed on the second attempt) is shown below: + +```go +c := retryablehttp.NewClient() +r := retryablehttp.NewRequest("GET", "://foo", nil) +handlerShouldRetry := true +r.SetResponseHandler(func(*http.Response) error { + if !handlerShouldRetry { + return nil + } + handlerShouldRetry = false + return errors.New("retryable error") +}) +``` + ## Getting a stdlib `*http.Client` with retries It's possible to convert a `*retryablehttp.Client` directly to a `*http.Client`. diff --git a/vendor/github.com/hashicorp/go-retryablehttp/client.go b/vendor/github.com/hashicorp/go-retryablehttp/client.go index adbdd92e..57116e96 100644 --- a/vendor/github.com/hashicorp/go-retryablehttp/client.go +++ b/vendor/github.com/hashicorp/go-retryablehttp/client.go @@ -69,11 +69,21 @@ var ( // scheme specified in the URL is invalid. This error isn't typed // specifically so we resort to matching on the error string. schemeErrorRe = regexp.MustCompile(`unsupported protocol scheme`) + + // A regular expression to match the error returned by net/http when the + // TLS certificate is not trusted. This error isn't typed + // specifically so we resort to matching on the error string. + notTrustedErrorRe = regexp.MustCompile(`certificate is not trusted`) ) // ReaderFunc is the type of function that can be given natively to NewRequest type ReaderFunc func() (io.Reader, error) +// ResponseHandlerFunc is a type of function that takes in a Response, and does something with it. +// It only runs if the initial part of the request was successful. +// If an error is returned, the client's retry policy will be used to determine whether to retry the whole request. +type ResponseHandlerFunc func(*http.Response) error + // LenReader is an interface implemented by many in-memory io.Reader's. Used // for automatically sending the right Content-Length header when possible. type LenReader interface { @@ -86,6 +96,8 @@ type Request struct { // used to rewind the request data in between retries. body ReaderFunc + responseHandler ResponseHandlerFunc + // Embed an HTTP request directly. This makes a *Request act exactly // like an *http.Request so that all meta methods are supported. *http.Request @@ -94,8 +106,16 @@ type Request struct { // WithContext returns wrapped Request with a shallow copy of underlying *http.Request // with its context changed to ctx. The provided ctx must be non-nil. func (r *Request) WithContext(ctx context.Context) *Request { - r.Request = r.Request.WithContext(ctx) - return r + return &Request{ + body: r.body, + responseHandler: r.responseHandler, + Request: r.Request.WithContext(ctx), + } +} + +// SetResponseHandler allows setting the response handler. +func (r *Request) SetResponseHandler(fn ResponseHandlerFunc) { + r.responseHandler = fn } // BodyBytes allows accessing the request body. It is an analogue to @@ -252,23 +272,31 @@ func FromRequest(r *http.Request) (*Request, error) { return nil, err } // Could assert contentLength == r.ContentLength - return &Request{bodyReader, r}, nil + return &Request{body: bodyReader, Request: r}, nil } // NewRequest creates a new wrapped request. func NewRequest(method, url string, rawBody interface{}) (*Request, error) { + return NewRequestWithContext(context.Background(), method, url, rawBody) +} + +// NewRequestWithContext creates a new wrapped request with the provided context. +// +// The context controls the entire lifetime of a request and its response: +// obtaining a connection, sending the request, and reading the response headers and body. +func NewRequestWithContext(ctx context.Context, method, url string, rawBody interface{}) (*Request, error) { bodyReader, contentLength, err := getBodyReaderAndContentLength(rawBody) if err != nil { return nil, err } - httpReq, err := http.NewRequest(method, url, nil) + httpReq, err := http.NewRequestWithContext(ctx, method, url, nil) if err != nil { return nil, err } httpReq.ContentLength = contentLength - return &Request{bodyReader, httpReq}, nil + return &Request{body: bodyReader, Request: httpReq}, nil } // Logger interface allows to use other loggers than @@ -435,6 +463,9 @@ func baseRetryPolicy(resp *http.Response, err error) (bool, error) { } // Don't retry if the error was due to TLS cert verification failure. + if notTrustedErrorRe.MatchString(v.Error()) { + return false, v + } if _, ok := v.Err.(x509.UnknownAuthorityError); ok { return false, v } @@ -455,7 +486,7 @@ func baseRetryPolicy(resp *http.Response, err error) (bool, error) { // the server time to recover, as 500's are typically not permanent // errors and may relate to outages on the server side. This will catch // invalid response codes as well, like 0 and 999. - if resp.StatusCode == 0 || (resp.StatusCode >= 500 && resp.StatusCode != 501) { + if resp.StatusCode == 0 || (resp.StatusCode >= 500 && resp.StatusCode != http.StatusNotImplemented) { return true, fmt.Errorf("unexpected HTTP status %s", resp.Status) } @@ -555,13 +586,12 @@ func (c *Client) Do(req *Request) (*http.Response, error) { var resp *http.Response var attempt int var shouldRetry bool - var doErr, checkErr error + var doErr, respErr, checkErr error for i := 0; ; i++ { + doErr, respErr = nil, nil attempt++ - var code int // HTTP response code - // Always rewind the request body when non-nil. if req.body != nil { body, err := req.body() @@ -589,19 +619,24 @@ func (c *Client) Do(req *Request) (*http.Response, error) { // Attempt the request resp, doErr = c.HTTPClient.Do(req.Request) - if resp != nil { - code = resp.StatusCode - } // Check if we should continue with retries. shouldRetry, checkErr = c.CheckRetry(req.Context(), resp, doErr) + if !shouldRetry && doErr == nil && req.responseHandler != nil { + respErr = req.responseHandler(resp) + shouldRetry, checkErr = c.CheckRetry(req.Context(), resp, respErr) + } - if doErr != nil { + err := doErr + if respErr != nil { + err = respErr + } + if err != nil { switch v := logger.(type) { case LeveledLogger: - v.Error("request failed", "error", doErr, "method", req.Method, "url", req.URL) + v.Error("request failed", "error", err, "method", req.Method, "url", req.URL) case Logger: - v.Printf("[ERR] %s %s request failed: %v", req.Method, req.URL, doErr) + v.Printf("[ERR] %s %s request failed: %v", req.Method, req.URL, err) } } else { // Call this here to maintain the behavior of logging all requests, @@ -636,11 +671,11 @@ func (c *Client) Do(req *Request) (*http.Response, error) { } wait := c.Backoff(c.RetryWaitMin, c.RetryWaitMax, i, resp) - desc := fmt.Sprintf("%s %s", req.Method, req.URL) - if code > 0 { - desc = fmt.Sprintf("%s (status: %d)", desc, code) - } if logger != nil { + desc := fmt.Sprintf("%s %s", req.Method, req.URL) + if resp != nil { + desc = fmt.Sprintf("%s (status: %d)", desc, resp.StatusCode) + } switch v := logger.(type) { case LeveledLogger: v.Debug("retrying request", "request", desc, "timeout", wait, "remaining", remain) @@ -648,11 +683,13 @@ func (c *Client) Do(req *Request) (*http.Response, error) { v.Printf("[DEBUG] %s: retrying in %s (%d left)", desc, wait, remain) } } + timer := time.NewTimer(wait) select { case <-req.Context().Done(): + timer.Stop() c.HTTPClient.CloseIdleConnections() return nil, req.Context().Err() - case <-time.After(wait): + case <-timer.C: } // Make shallow copy of http Request so that we can modify its body @@ -662,15 +699,19 @@ func (c *Client) Do(req *Request) (*http.Response, error) { } // this is the closest we have to success criteria - if doErr == nil && checkErr == nil && !shouldRetry { + if doErr == nil && respErr == nil && checkErr == nil && !shouldRetry { return resp, nil } defer c.HTTPClient.CloseIdleConnections() - err := doErr + var err error if checkErr != nil { err = checkErr + } else if respErr != nil { + err = respErr + } else { + err = doErr } if c.ErrorHandler != nil { diff --git a/vendor/github.com/vultr/govultr/v2/CHANGELOG.md b/vendor/github.com/vultr/govultr/v2/CHANGELOG.md index a9bd95ed..8efbc78e 100644 --- a/vendor/github.com/vultr/govultr/v2/CHANGELOG.md +++ b/vendor/github.com/vultr/govultr/v2/CHANGELOG.md @@ -2,6 +2,23 @@ ## GoVultr v1 changelog is located [here](https://github.com/vultr/govultr/blob/v1/CHANGELOG.md) +## [v2.16.0](https://github.com/vultr/govultr/compare/v2.15.1..v2.16.0) (2022-05-04) + +### Enhancement +* Kubernetes: added auto scaler options to node pools [215](https://github.com/vultr/govultr/pull/215) +* Firewall rules: added new field `ip_type` in get/list responses to be consistent with the create calls [216](https://github.com/vultr/govultr/pull/216) +* Kubernetes: Upgrade support [217](https://github.com/vultr/govultr/pull/217) +* Baremetal: Added support for new `tags` field. This field allows multiple string tags to be associated with an instance [218](https://github.com/vultr/govultr/pull/218) +* Instance: Added support for new `tags` field. This field allows multiple string tags to be associated with an instance [218](https://github.com/vultr/govultr/pull/218) + +### Deprecations +* Instance: The `tag` field has been deprecated in favor for `tags` [218](https://github.com/vultr/govultr/pull/218) +* Baremetal: The `tag` field has been deprecated in favor for `tags` [218](https://github.com/vultr/govultr/pull/218) +* Firewall rules: The `type` field has been deprecated in favor for `ip_type` [216](https://github.com/vultr/govultr/pull/216) + +### Dependency Update +* Bump github.com/hashicorp/go-retryablehttp from 0.7.0 to 0.7.1 [214](https://github.com/vultr/govultr/pull/214) + ## [v2.15.1](https://github.com/vultr/govultr/compare/v2.15.0..v2.15.1) (2022-04-12) ### Bug fixes * Block : add `omityempty` to `block_type` to prevent deploy issues [212](https://github.com/vultr/govultr/pull/212) diff --git a/vendor/github.com/vultr/govultr/v2/bare_metal_server.go b/vendor/github.com/vultr/govultr/v2/bare_metal_server.go index 5de564e4..c155681c 100644 --- a/vendor/github.com/vultr/govultr/v2/bare_metal_server.go +++ b/vendor/github.com/vultr/govultr/v2/bare_metal_server.go @@ -45,29 +45,31 @@ type BareMetalServerServiceHandler struct { // BareMetalServer represents a Bare Metal server on Vultr type BareMetalServer struct { - ID string `json:"id"` - Os string `json:"os"` - RAM string `json:"ram"` - Disk string `json:"disk"` - MainIP string `json:"main_ip"` - CPUCount int `json:"cpu_count"` - Region string `json:"region"` - DefaultPassword string `json:"default_password"` - DateCreated string `json:"date_created"` - Status string `json:"status"` - NetmaskV4 string `json:"netmask_v4"` - GatewayV4 string `json:"gateway_v4"` - Plan string `json:"plan"` - V6Network string `json:"v6_network"` - V6MainIP string `json:"v6_main_ip"` - V6NetworkSize int `json:"v6_network_size"` - MacAddress int `json:"mac_address"` - Label string `json:"label"` - Tag string `json:"tag"` - OsID int `json:"os_id"` - AppID int `json:"app_id"` - ImageID string `json:"image_id"` - Features []string `json:"features"` + ID string `json:"id"` + Os string `json:"os"` + RAM string `json:"ram"` + Disk string `json:"disk"` + MainIP string `json:"main_ip"` + CPUCount int `json:"cpu_count"` + Region string `json:"region"` + DefaultPassword string `json:"default_password"` + DateCreated string `json:"date_created"` + Status string `json:"status"` + NetmaskV4 string `json:"netmask_v4"` + GatewayV4 string `json:"gateway_v4"` + Plan string `json:"plan"` + V6Network string `json:"v6_network"` + V6MainIP string `json:"v6_main_ip"` + V6NetworkSize int `json:"v6_network_size"` + MacAddress int `json:"mac_address"` + Label string `json:"label"` + // Deprecated: Tag should no longer be used. Instead, use Tags. + Tag string `json:"tag"` + OsID int `json:"os_id"` + AppID int `json:"app_id"` + ImageID string `json:"image_id"` + Features []string `json:"features"` + Tags []string `json:"tags"` } // BareMetalCreate represents the optional parameters that can be set when creating a Bare Metal server @@ -85,9 +87,11 @@ type BareMetalCreate struct { UserData string `json:"user_data,omitempty"` ActivationEmail *bool `json:"activation_email,omitempty"` Hostname string `json:"hostname,omitempty"` - Tag string `json:"tag,omitempty"` - ReservedIPv4 string `json:"reserved_ipv4,omitempty"` - PersistentPxe *bool `json:"persistent_pxe,omitempty"` + // Deprecated: Tag should no longer be used. Instead, use Tags. + Tag string `json:"tag,omitempty"` + ReservedIPv4 string `json:"reserved_ipv4,omitempty"` + PersistentPxe *bool `json:"persistent_pxe,omitempty"` + Tags []string `json:"tags"` } // BareMetalUpdate represents the optional parameters that can be set when updating a Bare Metal server @@ -98,7 +102,9 @@ type BareMetalUpdate struct { AppID int `json:"app_id,omitempty"` ImageID string `json:"image_id,omitempty"` UserData string `json:"user_data,omitempty"` - Tag string `json:"tag,omitempty"` + // Deprecated: Tag should no longer be used. Instead, use Tags. + Tag string `json:"tag,omitempty"` + Tags []string `json:"tags"` } // BareMetalServerBandwidth represents bandwidth information for a Bare Metal server diff --git a/vendor/github.com/vultr/govultr/v2/firewall_rule.go b/vendor/github.com/vultr/govultr/v2/firewall_rule.go index 73cd54a3..d2f5f961 100644 --- a/vendor/github.com/vultr/govultr/v2/firewall_rule.go +++ b/vendor/github.com/vultr/govultr/v2/firewall_rule.go @@ -24,9 +24,11 @@ type FireWallRuleServiceHandler struct { // FirewallRule represents a Vultr firewall rule type FirewallRule struct { - ID int `json:"id"` - Action string `json:"action"` + ID int `json:"id"` + Action string `json:"action"` + // Deprecated: Type should no longer be used. Instead, use IPType. Type string `json:"type"` + IPType string `json:"ip_type"` Protocol string `json:"protocol"` Port string `json:"port"` Subnet string `json:"subnet"` diff --git a/vendor/github.com/vultr/govultr/v2/govultr.go b/vendor/github.com/vultr/govultr/v2/govultr.go index c02a9b6e..12f9059a 100644 --- a/vendor/github.com/vultr/govultr/v2/govultr.go +++ b/vendor/github.com/vultr/govultr/v2/govultr.go @@ -16,7 +16,7 @@ import ( ) const ( - version = "2.15.1" + version = "2.16.0" defaultBase = "https://api.vultr.com" userAgent = "govultr/" + version rateLimit = 500 * time.Millisecond diff --git a/vendor/github.com/vultr/govultr/v2/instance.go b/vendor/github.com/vultr/govultr/v2/instance.go index 8ccc58a1..c9f73ab3 100644 --- a/vendor/github.com/vultr/govultr/v2/instance.go +++ b/vendor/github.com/vultr/govultr/v2/instance.go @@ -75,35 +75,37 @@ type InstanceServiceHandler struct { // Instance represents a VPS type Instance struct { - ID string `json:"id"` - Os string `json:"os"` - RAM int `json:"ram"` - Disk int `json:"disk"` - Plan string `json:"plan"` - MainIP string `json:"main_ip"` - VCPUCount int `json:"vcpu_count"` - Region string `json:"region"` - DefaultPassword string `json:"default_password,omitempty"` - DateCreated string `json:"date_created"` - Status string `json:"status"` - AllowedBandwidth int `json:"allowed_bandwidth"` - NetmaskV4 string `json:"netmask_v4"` - GatewayV4 string `json:"gateway_v4"` - PowerStatus string `json:"power_status"` - ServerStatus string `json:"server_status"` - V6Network string `json:"v6_network"` - V6MainIP string `json:"v6_main_ip"` - V6NetworkSize int `json:"v6_network_size"` - Label string `json:"label"` - InternalIP string `json:"internal_ip"` - KVM string `json:"kvm"` - Tag string `json:"tag"` - OsID int `json:"os_id"` - AppID int `json:"app_id"` - ImageID string `json:"image_id"` - FirewallGroupID string `json:"firewall_group_id"` - Features []string `json:"features"` - Hostname string `json:"hostname"` + ID string `json:"id"` + Os string `json:"os"` + RAM int `json:"ram"` + Disk int `json:"disk"` + Plan string `json:"plan"` + MainIP string `json:"main_ip"` + VCPUCount int `json:"vcpu_count"` + Region string `json:"region"` + DefaultPassword string `json:"default_password,omitempty"` + DateCreated string `json:"date_created"` + Status string `json:"status"` + AllowedBandwidth int `json:"allowed_bandwidth"` + NetmaskV4 string `json:"netmask_v4"` + GatewayV4 string `json:"gateway_v4"` + PowerStatus string `json:"power_status"` + ServerStatus string `json:"server_status"` + V6Network string `json:"v6_network"` + V6MainIP string `json:"v6_main_ip"` + V6NetworkSize int `json:"v6_network_size"` + Label string `json:"label"` + InternalIP string `json:"internal_ip"` + KVM string `json:"kvm"` + // Deprecated: Tag should no longer be used. Instead, use Tags. + Tag string `json:"tag"` + OsID int `json:"os_id"` + AppID int `json:"app_id"` + ImageID string `json:"image_id"` + FirewallGroupID string `json:"firewall_group_id"` + Features []string `json:"features"` + Hostname string `json:"hostname"` + Tags []string `json:"tags"` } type instanceBase struct { @@ -229,20 +231,22 @@ type Upgrades struct { // InstanceCreateReq struct used to create an instance. type InstanceCreateReq struct { - Region string `json:"region,omitempty"` - Plan string `json:"plan,omitempty"` - Label string `json:"label,omitempty"` - Tag string `json:"tag,omitempty"` - OsID int `json:"os_id,omitempty"` - ISOID string `json:"iso_id,omitempty"` - AppID int `json:"app_id,omitempty"` - ImageID string `json:"image_id,omitempty"` - FirewallGroupID string `json:"firewall_group_id,omitempty"` - Hostname string `json:"hostname,omitempty"` - IPXEChainURL string `json:"ipxe_chain_url,omitempty"` - ScriptID string `json:"script_id,omitempty"` - SnapshotID string `json:"snapshot_id,omitempty"` - EnableIPv6 *bool `json:"enable_ipv6,omitempty"` + Region string `json:"region,omitempty"` + Plan string `json:"plan,omitempty"` + Label string `json:"label,omitempty"` + // Deprecated: Tag should no longer be used. Instead, use Tags. + Tag string `json:"tag,omitempty"` + Tags []string `json:"tags"` + OsID int `json:"os_id,omitempty"` + ISOID string `json:"iso_id,omitempty"` + AppID int `json:"app_id,omitempty"` + ImageID string `json:"image_id,omitempty"` + FirewallGroupID string `json:"firewall_group_id,omitempty"` + Hostname string `json:"hostname,omitempty"` + IPXEChainURL string `json:"ipxe_chain_url,omitempty"` + ScriptID string `json:"script_id,omitempty"` + SnapshotID string `json:"snapshot_id,omitempty"` + EnableIPv6 *bool `json:"enable_ipv6,omitempty"` // Deprecated: EnablePrivateNetwork should no longer be used. Instead, use EnableVPC. EnablePrivateNetwork *bool `json:"enable_private_network,omitempty"` // Deprecated: AttachPrivateNetwork should no longer be used. Instead, use AttachVPC. @@ -259,13 +263,15 @@ type InstanceCreateReq struct { // InstanceUpdateReq struct used to update an instance. type InstanceUpdateReq struct { - Plan string `json:"plan,omitempty"` - Label string `json:"label,omitempty"` - Tag string `json:"tag,omitempty"` - OsID int `json:"os_id,omitempty"` - AppID int `json:"app_id,omitempty"` - ImageID string `json:"image_id,omitempty"` - EnableIPv6 *bool `json:"enable_ipv6,omitempty"` + Plan string `json:"plan,omitempty"` + Label string `json:"label,omitempty"` + // Deprecated: Tag should no longer be used. Instead, use Tags. + Tag string `json:"tag,omitempty"` + Tags []string `json:"tags"` + OsID int `json:"os_id,omitempty"` + AppID int `json:"app_id,omitempty"` + ImageID string `json:"image_id,omitempty"` + EnableIPv6 *bool `json:"enable_ipv6,omitempty"` // Deprecated: EnablePrivateNetwork should no longer be used. Instead, use EnableVPC. EnablePrivateNetwork *bool `json:"enable_private_network,omitempty"` // Deprecated: AttachPrivateNetwork should no longer be used. Instead, use AttachVPC. diff --git a/vendor/github.com/vultr/govultr/v2/kubernetes.go b/vendor/github.com/vultr/govultr/v2/kubernetes.go index 9fdc800d..37aadea4 100644 --- a/vendor/github.com/vultr/govultr/v2/kubernetes.go +++ b/vendor/github.com/vultr/govultr/v2/kubernetes.go @@ -31,6 +31,9 @@ type KubernetesService interface { GetKubeConfig(ctx context.Context, vkeID string) (*KubeConfig, error) GetVersions(ctx context.Context) (*Versions, error) + + GetUpgrades(ctx context.Context, vkeID string) ([]string, error) + Upgrade(ctx context.Context, vkeID string, body *ClusterUpgradeReq) error } // KubernetesHandler handles interaction with the kubernetes methods for the Vultr API @@ -62,6 +65,9 @@ type NodePool struct { Plan string `json:"plan"` Status string `json:"status"` NodeQuantity int `json:"node_quantity"` + MinNodes int `json:"min_nodes"` + MaxNodes int `json:"max_nodes"` + AutoScaler bool `json:"auto_scaler"` Tag string `json:"tag"` Nodes []Node `json:"nodes"` } @@ -98,12 +104,18 @@ type NodePoolReq struct { Label string `json:"label"` Plan string `json:"plan"` Tag string `json:"tag"` + MinNodes int `json:"min_nodes,omitempty"` + MaxNodes int `json:"max_nodes,omitempty"` + AutoScaler *bool `json:"auto_scaler"` } // NodePoolReqUpdate struct used to update a node pool type NodePoolReqUpdate struct { NodeQuantity int `json:"node_quantity,omitempty"` Tag string `json:"tag,omitempty"` + MinNodes int `json:"min_nodes,omitempty"` + MaxNodes int `json:"max_nodes,omitempty"` + AutoScaler *bool `json:"auto_scaler"` } type vkeClustersBase struct { @@ -129,6 +141,16 @@ type Versions struct { Versions []string `json:"versions"` } +// AvailableUpgrades for a given VKE cluster +type availableUpgrades struct { + AvailableUpgrades []string `json:"available_upgrades"` +} + +// ClusterUpgradeReq struct for vke upgradse +type ClusterUpgradeReq struct { + UpgradeVersion string `json:"upgrade_version,omitempty"` +} + // CreateCluster will create a Kubernetes cluster. func (k *KubernetesHandler) CreateCluster(ctx context.Context, createReq *ClusterReq) (*Cluster, error) { req, err := k.client.NewRequest(ctx, http.MethodPost, vkePath, createReq) @@ -339,3 +361,29 @@ func (k *KubernetesHandler) GetVersions(ctx context.Context) (*Versions, error) return versions, nil } + +// GetUpgrades returns all version a VKE cluster can upgrade to +func (k *KubernetesHandler) GetUpgrades(ctx context.Context, vkeID string) ([]string, error) { + req, err := k.client.NewRequest(ctx, http.MethodGet, fmt.Sprintf("%s/%s/available-upgrades", vkePath, vkeID), nil) + if err != nil { + return nil, err + } + + upgrades := new(availableUpgrades) + if err = k.client.DoWithContext(ctx, req, &upgrades); err != nil { + return nil, err + } + + return upgrades.AvailableUpgrades, nil +} + +// Upgrade beings a VKE cluster upgrade +func (k *KubernetesHandler) Upgrade(ctx context.Context, vkeID string, body *ClusterUpgradeReq) error { + + req, err := k.client.NewRequest(ctx, http.MethodPost, fmt.Sprintf("%s/%s/upgrades", vkePath, vkeID), body) + if err != nil { + return err + } + + return k.client.DoWithContext(ctx, req, nil) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 62f8b32d..14d9fc0f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -10,7 +10,7 @@ github.com/google/go-querystring/query # github.com/hashicorp/go-cleanhttp v0.5.2 ## explicit; go 1.13 github.com/hashicorp/go-cleanhttp -# github.com/hashicorp/go-retryablehttp v0.7.0 +# github.com/hashicorp/go-retryablehttp v0.7.1 ## explicit; go 1.13 github.com/hashicorp/go-retryablehttp # github.com/hashicorp/hcl v1.0.0 @@ -75,7 +75,7 @@ github.com/spf13/viper/internal/encoding/yaml # github.com/subosito/gotenv v1.2.0 ## explicit github.com/subosito/gotenv -# github.com/vultr/govultr/v2 v2.15.1 +# github.com/vultr/govultr/v2 v2.16.0 ## explicit; go 1.17 github.com/vultr/govultr/v2 # golang.org/x/net v0.0.0-20220412020605-290c469a71a5