From 3670f33d46ee89c743d2c682d800fc885935c814 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Wed, 15 Jan 2025 05:48:58 +0000
Subject: [PATCH] Update module github.com/go-resty/resty/v2 to v2.16.3
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
go.mod | 2 +-
go.sum | 2 +
vendor/github.com/go-resty/resty/v2/README.md | 10 +--
vendor/github.com/go-resty/resty/v2/client.go | 26 ++++++--
.../go-resty/resty/v2/middleware.go | 29 ++++++---
.../github.com/go-resty/resty/v2/request.go | 14 +++++
.../github.com/go-resty/resty/v2/response.go | 3 +
vendor/github.com/go-resty/resty/v2/resty.go | 2 +-
vendor/github.com/go-resty/resty/v2/util.go | 63 +++++++++++--------
.../github.com/go-resty/resty/v2/util_curl.go | 6 +-
vendor/modules.txt | 2 +-
11 files changed, 104 insertions(+), 55 deletions(-)
diff --git a/go.mod b/go.mod
index 27406460..53b5089c 100644
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,7 @@ module github.com/redhat-ai-dev/rhdh-ai-catalog-cli
go 1.23.2
require (
- github.com/go-resty/resty/v2 v2.15.0
+ github.com/go-resty/resty/v2 v2.16.3
github.com/kserve/kserve v0.13.1
github.com/kubeflow/model-registry v0.2.5-alpha
github.com/spf13/cobra v1.8.1
diff --git a/go.sum b/go.sum
index be3b47ed..d2a594ca 100644
--- a/go.sum
+++ b/go.sum
@@ -87,6 +87,8 @@ github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogB
github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
github.com/go-resty/resty/v2 v2.15.0 h1:clPQLZ2x9h4yGY81IzpMPnty+xoGyFaDg0XMkCsHf90=
github.com/go-resty/resty/v2 v2.15.0/go.mod h1:0fHAoK7JoBy/Ch36N8VFeMsK7xQOHhvWaC3iOktwmIU=
+github.com/go-resty/resty/v2 v2.16.3 h1:zacNT7lt4b8M/io2Ahj6yPypL7bqx9n1iprfQuodV+E=
+github.com/go-resty/resty/v2 v2.16.3/go.mod h1:hkJtXbA2iKHzJheXYvQ8snQES5ZLGKMwQ07xAwp/fiA=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
diff --git a/vendor/github.com/go-resty/resty/v2/README.md b/vendor/github.com/go-resty/resty/v2/README.md
index 0469afc7..35974127 100644
--- a/vendor/github.com/go-resty/resty/v2/README.md
+++ b/vendor/github.com/go-resty/resty/v2/README.md
@@ -4,16 +4,12 @@
Features section describes in detail about Resty capabilities
-

-
-
-
Resty Communication Channels
-

+

## News
- * v2.15.0 [released](https://github.com/go-resty/resty/releases/tag/v2.15.0) and tagged on Sep 14, 2024.
+ * v2.16.3 [released](https://github.com/go-resty/resty/releases/tag/v2.16.3) and tagged on Jan 08, 2025.
* v2.0.0 [released](https://github.com/go-resty/resty/releases/tag/v2.0.0) and tagged on Jul 16, 2019.
* v1.12.0 [released](https://github.com/go-resty/resty/releases/tag/v1.12.0) and tagged on Feb 27, 2019.
* v1.0 released and tagged on Sep 25, 2017. - Resty's first version was released on Sep 15, 2015 then it grew gradually as a very handy and helpful library. Its been a two years since first release. I'm very thankful to Resty users and its [contributors](https://github.com/go-resty/resty/graphs/contributors).
@@ -109,7 +105,7 @@ Resty author also published following projects for Go Community.
```bash
# Go Modules
-require github.com/go-resty/resty/v2 v2.15.0
+require github.com/go-resty/resty/v2 v2.16.3
```
## Usage
diff --git a/vendor/github.com/go-resty/resty/v2/client.go b/vendor/github.com/go-resty/resty/v2/client.go
index a40bbe4b..7ab33ae8 100644
--- a/vendor/github.com/go-resty/resty/v2/client.go
+++ b/vendor/github.com/go-resty/resty/v2/client.go
@@ -155,6 +155,7 @@ type Client struct {
panicHooks []ErrorHook
rateLimiter RateLimiter
generateCurlOnDebug bool
+ unescapeQueryParams bool
}
// User type is to hold an username and password information
@@ -325,6 +326,17 @@ func (c *Client) SetQueryParams(params map[string]string) *Client {
return c
}
+// SetUnescapeQueryParams method sets the unescape query parameters choice for request URL.
+// To prevent broken URL, resty replaces space (" ") with "+" in the query parameters.
+//
+// See [Request.SetUnescapeQueryParams]
+//
+// NOTE: Request failure is possible due to non-standard usage of Unescaped Query Parameters.
+func (c *Client) SetUnescapeQueryParams(unescape bool) *Client {
+ c.unescapeQueryParams = unescape
+ return c
+}
+
// SetFormData method sets Form parameters and their values in the client instance.
// It applies only to HTTP methods `POST` and `PUT`, and the request content type would be set as
// `application/x-www-form-urlencoded`. These form data will be added to all the requests raised from
@@ -446,6 +458,7 @@ func (c *Client) R() *Request {
log: c.log,
responseBodyLimit: c.ResponseBodyLimit,
generateCurlOnDebug: c.generateCurlOnDebug,
+ unescapeQueryParams: c.unescapeQueryParams,
}
return r
}
@@ -1223,7 +1236,6 @@ func (c *Client) executeBefore(req *Request) error {
return wrapNoRetryErr(err)
}
- req.RawRequest.Body = newRequestBodyReleaser(req.RawRequest.Body, req.bodyBuf)
return nil
}
@@ -1243,12 +1255,14 @@ func (c *Client) execute(req *Request) (*Response, error) {
}
if err != nil || req.notParseResponse || c.notParseResponse {
- logErr := responseLogger(c, response)
response.setReceivedAt()
+ if logErr := responseLogger(c, response); logErr != nil {
+ return response, wrapErrors(logErr, err)
+ }
if err != nil {
- return response, errors.Join(err, logErr)
+ return response, err
}
- return response, wrapNoRetryErr(logErr)
+ return response, nil
}
if !req.isSaveResponse {
@@ -1260,7 +1274,7 @@ func (c *Client) execute(req *Request) (*Response, error) {
if _, ok := body.(*gzip.Reader); !ok {
body, err = gzip.NewReader(body)
if err != nil {
- err = errors.Join(err, responseLogger(c, response))
+ err = wrapErrors(responseLogger(c, response), err)
response.setReceivedAt()
return response, err
}
@@ -1269,7 +1283,7 @@ func (c *Client) execute(req *Request) (*Response, error) {
}
if response.body, err = readAllWithLimit(body, req.responseBodyLimit); err != nil {
- err = errors.Join(err, responseLogger(c, response))
+ err = wrapErrors(responseLogger(c, response), err)
response.setReceivedAt()
return response, err
}
diff --git a/vendor/github.com/go-resty/resty/v2/middleware.go b/vendor/github.com/go-resty/resty/v2/middleware.go
index 84f0fdea..91eed9b2 100644
--- a/vendor/github.com/go-resty/resty/v2/middleware.go
+++ b/vendor/github.com/go-resty/resty/v2/middleware.go
@@ -154,6 +154,15 @@ func parseRequestURL(c *Client, r *Request) error {
}
}
+ // GH#797 Unescape query parameters
+ if r.unescapeQueryParams && len(reqURL.RawQuery) > 0 {
+ // at this point, all errors caught up in the above operations
+ // so ignore the return error on query unescape; I realized
+ // while writing the unit test
+ unescapedQuery, _ := url.QueryUnescape(reqURL.RawQuery)
+ reqURL.RawQuery = strings.ReplaceAll(unescapedQuery, " ", "+") // otherwise request becomes bad request
+ }
+
r.URL = reqURL.String()
return nil
@@ -254,17 +263,19 @@ func createHTTPRequest(c *Client, r *Request) (err error) {
r.RawRequest = r.RawRequest.WithContext(r.ctx)
}
- bodyCopy, err := getBodyCopy(r)
- if err != nil {
- return err
- }
-
// assign get body func for the underlying raw request instance
- r.RawRequest.GetBody = func() (io.ReadCloser, error) {
+ if r.RawRequest.GetBody == nil {
+ bodyCopy, err := getBodyCopy(r)
+ if err != nil {
+ return err
+ }
if bodyCopy != nil {
- return io.NopCloser(bytes.NewReader(bodyCopy.Bytes())), nil
+ buf := bodyCopy.Bytes()
+ r.RawRequest.GetBody = func() (io.ReadCloser, error) {
+ b := bytes.NewReader(buf)
+ return io.NopCloser(b), nil
+ }
}
- return nil, nil
}
return
@@ -375,7 +386,7 @@ func responseLogger(c *Client, res *Response) error {
debugLog := res.Request.values[debugRequestLogKey].(string)
debugLog += "~~~ RESPONSE ~~~\n" +
fmt.Sprintf("STATUS : %s\n", res.Status()) +
- fmt.Sprintf("PROTO : %s\n", res.RawResponse.Proto) +
+ fmt.Sprintf("PROTO : %s\n", res.Proto()) +
fmt.Sprintf("RECEIVED AT : %v\n", res.ReceivedAt().Format(time.RFC3339Nano)) +
fmt.Sprintf("TIME DURATION: %v\n", res.Time()) +
"HEADERS :\n" +
diff --git a/vendor/github.com/go-resty/resty/v2/request.go b/vendor/github.com/go-resty/resty/v2/request.go
index 18340715..6c6f9259 100644
--- a/vendor/github.com/go-resty/resty/v2/request.go
+++ b/vendor/github.com/go-resty/resty/v2/request.go
@@ -73,6 +73,7 @@ type Request struct {
retryConditions []RetryConditionFunc
responseBodyLimit int
generateCurlOnDebug bool
+ unescapeQueryParams bool
}
// GenerateCurlCommand method generates the CURL command for the request.
@@ -210,6 +211,17 @@ func (r *Request) SetQueryParams(params map[string]string) *Request {
return r
}
+// SetUnescapeQueryParams method sets the unescape query parameters choice for request URL.
+// To prevent broken URL, resty replaces space (" ") with "+" in the query parameters.
+//
+// This method overrides the value set by [Client.SetUnescapeQueryParams]
+//
+// NOTE: Request failure is possible due to non-standard usage of Unescaped Query Parameters.
+func (r *Request) SetUnescapeQueryParams(unescape bool) *Request {
+ r.unescapeQueryParams = unescape
+ return r
+}
+
// SetQueryParamsFromValues method appends multiple parameters with multi-value
// ([url.Values]) at one go in the current request. It will be formed as
// query string for the request.
@@ -1018,6 +1030,7 @@ func (r *Request) Execute(method, url string) (*Response, error) {
r.Attempt = 1
resp, err = r.client.execute(r)
r.client.onErrorHooks(r, resp, unwrapNoRetryErr(err))
+ backToBufPool(r.bodyBuf)
return resp, unwrapNoRetryErr(err)
}
@@ -1047,6 +1060,7 @@ func (r *Request) Execute(method, url string) (*Response, error) {
}
r.client.onErrorHooks(r, resp, unwrapNoRetryErr(err))
+ backToBufPool(r.bodyBuf)
return resp, unwrapNoRetryErr(err)
}
diff --git a/vendor/github.com/go-resty/resty/v2/response.go b/vendor/github.com/go-resty/resty/v2/response.go
index c3e4611b..f52b5c61 100644
--- a/vendor/github.com/go-resty/resty/v2/response.go
+++ b/vendor/github.com/go-resty/resty/v2/response.go
@@ -171,6 +171,9 @@ func (r *Response) setReceivedAt() {
}
func (r *Response) fmtBodyString(sl int64) string {
+ if r.Request.client.notParseResponse || r.Request.notParseResponse {
+ return "***** DO NOT PARSE RESPONSE - Enabled *****"
+ }
if len(r.body) > 0 {
if int64(len(r.body)) > sl {
return fmt.Sprintf("***** RESPONSE TOO LARGE (size - %d) *****", len(r.body))
diff --git a/vendor/github.com/go-resty/resty/v2/resty.go b/vendor/github.com/go-resty/resty/v2/resty.go
index 1e4dadf4..6f82fb2b 100644
--- a/vendor/github.com/go-resty/resty/v2/resty.go
+++ b/vendor/github.com/go-resty/resty/v2/resty.go
@@ -14,7 +14,7 @@ import (
)
// Version # of resty
-const Version = "2.15.0"
+const Version = "2.16.3"
// New method creates a new Resty client.
func New() *Client {
diff --git a/vendor/github.com/go-resty/resty/v2/util.go b/vendor/github.com/go-resty/resty/v2/util.go
index 812dce3d..0ac470e4 100644
--- a/vendor/github.com/go-resty/resty/v2/util.go
+++ b/vendor/github.com/go-resty/resty/v2/util.go
@@ -19,7 +19,6 @@ import (
"runtime"
"sort"
"strings"
- "sync"
)
//‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
@@ -286,7 +285,13 @@ func functionName(i interface{}) string {
}
func acquireBuffer() *bytes.Buffer {
- return bufPool.Get().(*bytes.Buffer)
+ buf := bufPool.Get().(*bytes.Buffer)
+ if buf.Len() == 0 {
+ buf.Reset()
+ return buf
+ }
+ bufPool.Put(buf)
+ return new(bytes.Buffer)
}
func releaseBuffer(buf *bytes.Buffer) {
@@ -296,34 +301,12 @@ func releaseBuffer(buf *bytes.Buffer) {
}
}
-// requestBodyReleaser wraps requests's body and implements custom Close for it.
-// The Close method closes original body and releases request body back to sync.Pool.
-type requestBodyReleaser struct {
- releaseOnce sync.Once
- reqBuf *bytes.Buffer
- io.ReadCloser
-}
-
-func newRequestBodyReleaser(respBody io.ReadCloser, reqBuf *bytes.Buffer) io.ReadCloser {
- if reqBuf == nil {
- return respBody
- }
-
- return &requestBodyReleaser{
- reqBuf: reqBuf,
- ReadCloser: respBody,
+func backToBufPool(buf *bytes.Buffer) {
+ if buf != nil {
+ bufPool.Put(buf)
}
}
-func (rr *requestBodyReleaser) Close() error {
- err := rr.ReadCloser.Close()
- rr.releaseOnce.Do(func() {
- releaseBuffer(rr.reqBuf)
- })
-
- return err
-}
-
func closeq(v interface{}) {
if c, ok := v.(io.Closer); ok {
silently(c.Close())
@@ -357,6 +340,32 @@ func copyHeaders(hdrs http.Header) http.Header {
return nh
}
+func wrapErrors(n error, inner error) error {
+ if inner == nil {
+ return n
+ }
+ if n == nil {
+ return inner
+ }
+ return &restyError{
+ err: n,
+ inner: inner,
+ }
+}
+
+type restyError struct {
+ err error
+ inner error
+}
+
+func (e *restyError) Error() string {
+ return e.err.Error()
+}
+
+func (e *restyError) Unwrap() error {
+ return e.inner
+}
+
type noRetryErr struct {
err error
}
diff --git a/vendor/github.com/go-resty/resty/v2/util_curl.go b/vendor/github.com/go-resty/resty/v2/util_curl.go
index 2bd91270..073d0492 100644
--- a/vendor/github.com/go-resty/resty/v2/util_curl.go
+++ b/vendor/github.com/go-resty/resty/v2/util_curl.go
@@ -27,7 +27,7 @@ func buildCurlRequest(req *http.Request, httpCookiejar http.CookieJar) (curl str
if cookieJar, ok := httpCookiejar.(*cookiejar.Jar); ok {
cookies := cookieJar.Cookies(req.URL)
if len(cookies) > 0 {
- curl += ` -H ` + shellescape.Quote(dumpCurlCookies(cookies)) + " "
+ curl += `-H ` + shellescape.Quote(dumpCurlCookies(cookies)) + " "
}
}
@@ -35,14 +35,14 @@ func buildCurlRequest(req *http.Request, httpCookiejar http.CookieJar) (curl str
if req.Body != nil {
buf, _ := io.ReadAll(req.Body)
req.Body = io.NopCloser(bytes.NewBuffer(buf)) // important!!
- curl += `-d ` + shellescape.Quote(string(buf))
+ curl += `-d ` + shellescape.Quote(string(buf)) + " "
}
urlString := shellescape.Quote(req.URL.String())
if urlString == "''" {
urlString = "'http://unexecuted-request'"
}
- curl += " " + urlString
+ curl += urlString
return curl
}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index de5dfcc4..0f9fb26f 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -131,7 +131,7 @@ github.com/go-openapi/jsonreference/internal
# github.com/go-openapi/swag v0.22.4
## explicit; go 1.18
github.com/go-openapi/swag
-# github.com/go-resty/resty/v2 v2.15.0
+# github.com/go-resty/resty/v2 v2.16.3
## explicit; go 1.20
github.com/go-resty/resty/v2
github.com/go-resty/resty/v2/shellescape