From 9dbcbf4651db23614a0a5f366cc82d8897ad2fb4 Mon Sep 17 00:00:00 2001 From: App Platform Runtime Working Group CI Bot Date: Wed, 22 May 2024 00:01:16 +0000 Subject: [PATCH] Bump code.cloudfoundry.org/dockerdriver from v0.0.0-20240425154110-a68c794c8bb0 to v0.0.0-20240521135308-9fa280d26502 --- go.mod | 3 +- go.sum | 8 +- .../code.cloudfoundry.org/cfhttp/.gitignore | 1 - vendor/code.cloudfoundry.org/cfhttp/README.md | 5 - .../code.cloudfoundry.org/cfhttp/cf_http.go | 105 --------- .../code.cloudfoundry.org/cfhttp/package.go | 1 - .../cfhttp/unix_transport/package.go | 1 - .../cfhttp/unix_transport/unix_transport.go | 113 ---------- .../code.cloudfoundry.org/cfhttp/v2/LICENSE | 201 ++++++++++++++++++ .../code.cloudfoundry.org/cfhttp/v2/client.go | 129 +++++++++++ .../cfhttp/v2/package.go | 1 + .../cfhttp/v2/staticcheck.conf | 1 + .../dockerdriver/driverhttp/remote_client.go | 34 +-- vendor/modules.txt | 7 +- 14 files changed, 353 insertions(+), 257 deletions(-) delete mode 100644 vendor/code.cloudfoundry.org/cfhttp/.gitignore delete mode 100644 vendor/code.cloudfoundry.org/cfhttp/README.md delete mode 100644 vendor/code.cloudfoundry.org/cfhttp/cf_http.go delete mode 100644 vendor/code.cloudfoundry.org/cfhttp/package.go delete mode 100644 vendor/code.cloudfoundry.org/cfhttp/unix_transport/package.go delete mode 100644 vendor/code.cloudfoundry.org/cfhttp/unix_transport/unix_transport.go create mode 100644 vendor/code.cloudfoundry.org/cfhttp/v2/LICENSE create mode 100644 vendor/code.cloudfoundry.org/cfhttp/v2/client.go create mode 100644 vendor/code.cloudfoundry.org/cfhttp/v2/package.go create mode 100644 vendor/code.cloudfoundry.org/cfhttp/v2/staticcheck.conf diff --git a/go.mod b/go.mod index ca9fec7b..057097e1 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module code.cloudfoundry.org/volumedriver go 1.22.3 require ( - code.cloudfoundry.org/dockerdriver v0.0.0-20240425154110-a68c794c8bb0 + code.cloudfoundry.org/dockerdriver v0.0.0-20240521135308-9fa280d26502 code.cloudfoundry.org/goshims v0.35.0 code.cloudfoundry.org/lager/v3 v3.0.3 github.com/maxbrunsfeld/counterfeiter/v6 v6.8.1 @@ -13,6 +13,7 @@ require ( require ( code.cloudfoundry.org/cfhttp v2.0.0+incompatible // indirect + code.cloudfoundry.org/cfhttp/v2 v2.0.1 // indirect code.cloudfoundry.org/clock v1.1.0 // indirect code.cloudfoundry.org/tlsconfig v0.0.0-20230320190829-8f91c367795b // indirect github.com/bmizerany/pat v0.0.0-20210406213842-e4b6760bdd6f // indirect diff --git a/go.sum b/go.sum index 4bba4e67..0f4ce043 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,11 @@ code.cloudfoundry.org/cfhttp v2.0.0+incompatible h1:Gk1oNYalXmkebrG9kgUtZ9+FPjQGnqZtS457RP2gWhc= code.cloudfoundry.org/cfhttp v2.0.0+incompatible/go.mod h1:kwYQ8kChWl4AuUJG3vKtp1po2B91S7XoUWhoKElabmA= +code.cloudfoundry.org/cfhttp/v2 v2.0.1 h1:xCbkvDVUDuFCquDo66QnvM9hG6vxM2cvTMjj/A8BcNA= +code.cloudfoundry.org/cfhttp/v2 v2.0.1/go.mod h1:yD0n22D4KP4xamgTxbz82KsWzK5kcfUrmJNrrmd4YBg= code.cloudfoundry.org/clock v1.1.0 h1:XLzC6W3Ah/Y7ht1rmZ6+QfPdt1iGWEAAtIZXgiaj57c= code.cloudfoundry.org/clock v1.1.0/go.mod h1:yA3fxddT9RINQL2XHS7PS+OXxKCGhfrZmlNUCIM6AKo= -code.cloudfoundry.org/dockerdriver v0.0.0-20240425154110-a68c794c8bb0 h1:LtXPi3kfkRv1v9r4Z1vrx8C4MrzTQOAD5UikJ2LnTBI= -code.cloudfoundry.org/dockerdriver v0.0.0-20240425154110-a68c794c8bb0/go.mod h1:MMEvnCuQXFE3x52RigbEEp8CGpqVWdSzEvnUseIPv/I= +code.cloudfoundry.org/dockerdriver v0.0.0-20240521135308-9fa280d26502 h1:uBEdHs0pWHYPonBqJBXY5lVyR925IahaM8Lcou1+SJg= +code.cloudfoundry.org/dockerdriver v0.0.0-20240521135308-9fa280d26502/go.mod h1:q5inx1+qNb+GvIp+S/R7gD4k3D/the2pUiRWGeumP5E= code.cloudfoundry.org/goshims v0.35.0 h1:2QJem6S/YfW7lHDalUsWyH80zoAF1gV89tir8b/myVQ= code.cloudfoundry.org/goshims v0.35.0/go.mod h1:ED2Cq4h2VftZlduIo/PJLP0rPGGwgwpY8T+kyy54KJo= code.cloudfoundry.org/lager/v3 v3.0.3 h1:/UTmadZfIaKuT/whEinSxK1mzRfNu1uPfvjFfGqiwzM= @@ -32,8 +34,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/maxbrunsfeld/counterfeiter/v6 v6.8.1 h1:NicmruxkeqHjDv03SfSxqmaLuisddudfP3h5wdXFbhM= github.com/maxbrunsfeld/counterfeiter/v6 v6.8.1/go.mod h1:eyp4DdUJAKkr9tvxR3jWhw2mDK7CWABMG5r9uyaKC7I= -github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ= -github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U= github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY= github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= diff --git a/vendor/code.cloudfoundry.org/cfhttp/.gitignore b/vendor/code.cloudfoundry.org/cfhttp/.gitignore deleted file mode 100644 index 9ed3b07c..00000000 --- a/vendor/code.cloudfoundry.org/cfhttp/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.test diff --git a/vendor/code.cloudfoundry.org/cfhttp/README.md b/vendor/code.cloudfoundry.org/cfhttp/README.md deleted file mode 100644 index f4b8a36e..00000000 --- a/vendor/code.cloudfoundry.org/cfhttp/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# cfhttp - -**Note**: This repository should be imported as `code.cloudfoundry.org/cfhttp`. - -Wrapper for official go http package diff --git a/vendor/code.cloudfoundry.org/cfhttp/cf_http.go b/vendor/code.cloudfoundry.org/cfhttp/cf_http.go deleted file mode 100644 index 286ce4ab..00000000 --- a/vendor/code.cloudfoundry.org/cfhttp/cf_http.go +++ /dev/null @@ -1,105 +0,0 @@ -package cfhttp - -import ( - "crypto/tls" - "crypto/x509" - "errors" - "fmt" - "io/ioutil" - "net" - "net/http" - "sync/atomic" - "time" - - "code.cloudfoundry.org/cfhttp/unix_transport" -) - -var SUPPORTED_CIPHER_SUITES = []uint16{ - tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, - tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, -} - -var config Config - -type Config struct { - Timeout time.Duration -} - -func Initialize(timeout time.Duration) { - atomic.StoreInt64((*int64)(&config.Timeout), int64(timeout)) -} - -func NewClient() *http.Client { - return newClient(5*time.Second, 0*time.Second, 90*time.Second, time.Duration(atomic.LoadInt64((*int64)(&config.Timeout)))) -} - -func NewUnixClient(socketPath string) *http.Client { - return &http.Client{ - Transport: unix_transport.NewWithDial(socketPath, - (&net.Dialer{ - Timeout: 5 * time.Second, - KeepAlive: 0 * time.Second, - }).Dial), - Timeout: time.Duration(atomic.LoadInt64((*int64)(&config.Timeout))), - } -} - -func NewCustomTimeoutClient(customTimeout time.Duration) *http.Client { - return newClient(5*time.Second, 0*time.Second, 90*time.Second, customTimeout) -} - -func NewStreamingClient() *http.Client { - return newClient(5*time.Second, 30*time.Second, 90*time.Second, 0*time.Second) -} - -func newClient(dialTimeout, keepAliveTimeout, idleConnTimeout, timeout time.Duration) *http.Client { - return &http.Client{ - Transport: &http.Transport{ - DialContext: (&net.Dialer{ - Timeout: dialTimeout, - KeepAlive: keepAliveTimeout, - }).DialContext, - IdleConnTimeout: idleConnTimeout, - }, - Timeout: timeout, - } -} - -func NewTLSConfig(certFile, keyFile, caCertFile string) (*tls.Config, error) { - caCertPool := x509.NewCertPool() - if caCertFile != "" { - certBytes, err := ioutil.ReadFile(caCertFile) - if err != nil { - return nil, fmt.Errorf("failed read ca cert file: %s", err.Error()) - } - - if ok := caCertPool.AppendCertsFromPEM(certBytes); !ok { - return nil, errors.New("Unable to load caCert") - } - } - return NewTLSConfigWithCertPool(certFile, keyFile, caCertPool) -} - -func NewTLSConfigWithCertPool(certFile, keyFile string, caCertPool *x509.CertPool) (*tls.Config, error) { - tlsCert, err := tls.LoadX509KeyPair(certFile, keyFile) - if err != nil { - return nil, fmt.Errorf("failed to load keypair: %s", err.Error()) - } - - tlsConfig := &tls.Config{ - Certificates: []tls.Certificate{tlsCert}, - InsecureSkipVerify: false, - ClientAuth: tls.RequireAndVerifyClientCert, - CipherSuites: SUPPORTED_CIPHER_SUITES, - MinVersion: tls.VersionTLS12, - } - - if caCertPool == nil { - return nil, fmt.Errorf("CaCertPool is nil") - } - - tlsConfig.RootCAs = caCertPool - tlsConfig.ClientCAs = caCertPool - - return tlsConfig, nil -} diff --git a/vendor/code.cloudfoundry.org/cfhttp/package.go b/vendor/code.cloudfoundry.org/cfhttp/package.go deleted file mode 100644 index 8b4535c6..00000000 --- a/vendor/code.cloudfoundry.org/cfhttp/package.go +++ /dev/null @@ -1 +0,0 @@ -package cfhttp // import "code.cloudfoundry.org/cfhttp" diff --git a/vendor/code.cloudfoundry.org/cfhttp/unix_transport/package.go b/vendor/code.cloudfoundry.org/cfhttp/unix_transport/package.go deleted file mode 100644 index c46d44b6..00000000 --- a/vendor/code.cloudfoundry.org/cfhttp/unix_transport/package.go +++ /dev/null @@ -1 +0,0 @@ -package unix_transport // import "code.cloudfoundry.org/cfhttp/unix_transport" diff --git a/vendor/code.cloudfoundry.org/cfhttp/unix_transport/unix_transport.go b/vendor/code.cloudfoundry.org/cfhttp/unix_transport/unix_transport.go deleted file mode 100644 index ef1de2cc..00000000 --- a/vendor/code.cloudfoundry.org/cfhttp/unix_transport/unix_transport.go +++ /dev/null @@ -1,113 +0,0 @@ -package unix_transport - -import ( - "crypto/tls" - "errors" - "fmt" - "net" - "net/http" - "net/http/httputil" - "net/url" - "strings" -) - -func NewWithTLS(socketPath string, tlsConfig *tls.Config) *http.Transport { - unixTransport := &http.Transport{TLSClientConfig: tlsConfig} - - unixTransport.RegisterProtocol("unix", NewUnixRoundTripperTls(socketPath, tlsConfig)) - return unixTransport -} - -func New(socketPath string) *http.Transport { - unixTransport := &http.Transport{} - unixTransport.RegisterProtocol("unix", NewUnixRoundTripper(socketPath)) - return unixTransport -} - -type DialFunc func(network, addr string) (net.Conn, error) - -func NewWithDial(socketPath string, dial DialFunc) *http.Transport { - unixTransport := &http.Transport{Dial: dial} - unixTransport.RegisterProtocol("unix", NewUnixRoundTripper(socketPath)) - return unixTransport -} - -type UnixRoundTripper struct { - path string - conn httputil.ClientConn - useTls bool - tlsConfig *tls.Config -} - -func NewUnixRoundTripper(path string) *UnixRoundTripper { - return &UnixRoundTripper{path: path} -} - -func NewUnixRoundTripperTls(path string, tlsConfig *tls.Config) *UnixRoundTripper { - return &UnixRoundTripper{ - path: path, - useTls: true, - tlsConfig: tlsConfig, - } -} - -// The RoundTripper (http://golang.org/pkg/net/http/#RoundTripper) for the socket transport dials the socket -// each time a request is made. -func (roundTripper UnixRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { - var conn net.Conn - var err error - if roundTripper.useTls { - - conn, err = tls.Dial("unix", roundTripper.path, roundTripper.tlsConfig) - if err != nil { - return nil, err - } - if conn == nil { - return nil, errors.New("net/http: Transport.DialTLS returned (nil, nil)") - } - if tc, ok := conn.(*tls.Conn); ok { - // Handshake here, in case DialTLS didn't. TLSNextProto below - // depends on it for knowing the connection state. - if err := tc.Handshake(); err != nil { - go conn.Close() - return nil, err - } - } - } else { - conn, err = net.Dial("unix", roundTripper.path) - if err != nil { - return nil, err - } - } - - socketClientConn := httputil.NewClientConn(conn, nil) - defer socketClientConn.Close() - - newReq, err := roundTripper.rewriteRequest(req) - if err != nil { - return nil, err - } - - return socketClientConn.Do(newReq) -} - -func (roundTripper *UnixRoundTripper) rewriteRequest(req *http.Request) (*http.Request, error) { - requestPath := req.URL.Path - if !strings.HasPrefix(requestPath, roundTripper.path) { - return nil, fmt.Errorf("Wrong unix socket [unix://%s]. Expected unix socket is [%s]", requestPath, roundTripper.path) - } - - reqPath := strings.TrimPrefix(requestPath, roundTripper.path) - newReqUrl := fmt.Sprintf("unix://%s", reqPath) - - var err error - newURL, err := url.Parse(newReqUrl) - if err != nil { - return nil, err - } - - req.URL.Path = newURL.Path - req.URL.Host = roundTripper.path - return req, nil - -} diff --git a/vendor/code.cloudfoundry.org/cfhttp/v2/LICENSE b/vendor/code.cloudfoundry.org/cfhttp/v2/LICENSE new file mode 100644 index 00000000..f49a4e16 --- /dev/null +++ b/vendor/code.cloudfoundry.org/cfhttp/v2/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/vendor/code.cloudfoundry.org/cfhttp/v2/client.go b/vendor/code.cloudfoundry.org/cfhttp/v2/client.go new file mode 100644 index 00000000..22e6d2c5 --- /dev/null +++ b/vendor/code.cloudfoundry.org/cfhttp/v2/client.go @@ -0,0 +1,129 @@ +// Package cfhttp provides defaults and helpers for building http clients. +// It serves to help maintain the same HTTP configuration across multiple +// CloudFoundry components. +package cfhttp + +import ( + "crypto/tls" + "net" + "net/http" + "time" +) + +type config struct { + requestTimeout time.Duration + dialTimeout time.Duration + tcpKeepAliveTimeout time.Duration + idleConnTimeout time.Duration + disableKeepAlives bool + maxIdleConnsPerHost int + tlsConfig *tls.Config +} + +// Option can be used to configure different parts of the HTTP client, including +// its internal transport or the connection dialer. +type Option func(*config) + +// WithStreamingDefaults modifies the HTTP client with defaults that are more +// suitable for consuming server-sent events on persistent connections. +func WithStreamingDefaults() Option { + return func(c *config) { + c.tcpKeepAliveTimeout = 30 * time.Second + c.disableKeepAlives = false + c.requestTimeout = 0 + } +} + +// WithRequestTimeout sets the total time limit for requests made by this Client. +// +// A setting of 0 means no timeout. +func WithRequestTimeout(t time.Duration) Option { + return func(c *config) { + c.requestTimeout = t + } +} + +// WithDialTimeout sets the time limit for connecting to the remote address. This +// includes DNS resolution and retries on multiple IP addresses. +// +// A setting of 0 means no timeout. +func WithDialTimeout(t time.Duration) Option { + return func(c *config) { + c.dialTimeout = t + } +} + +// WithTCPKeepAliveTimeout sets the keep-alive period for an active TCP +// connection. +// +// A setting of 0 disables TCP keep-alives. +func WithTCPKeepAliveTimeout(t time.Duration) Option { + return func(c *config) { + c.tcpKeepAliveTimeout = t + } +} + +// WithIdleConnTimeout sets the maximum amount of time a keep-alive +// connection can be idle before it closes itself. +// +// A setting of 0 means no timeout. +func WithIdleConnTimeout(t time.Duration) Option { + return func(c *config) { + c.idleConnTimeout = t + } +} + +// WithDisableKeepAlives disables keep-alive on every HTTP connection so that +// every connection is closed as soon as its request is done. +func WithDisableKeepAlives() Option { + return func(c *config) { + c.disableKeepAlives = true + } +} + +// WithMaxIdleConnsPerHost sets the maximum number of keep-alive connections that +// can be active at a time per remote host. +// +// A setting of 0 sets means the MaxIdleConnsPerHost is +// http.DefaultMaxIdleConnsPerHost (2 at the time of writing). +func WithMaxIdleConnsPerHost(max int) Option { + return func(c *config) { + c.maxIdleConnsPerHost = max + } +} + +// WithTLSConfig sets the TLS configuration on the HTTP client. +func WithTLSConfig(t *tls.Config) Option { + return func(c *config) { + c.tlsConfig = t + } +} + +// NewClient builds a HTTP client with suitable defaults. +// The Options can optionally set configuration options on the +// HTTP client, transport, or net dialer. Options are applied +// in the order that they are passed in, so it is possible for +// later Options previous ones. +func NewClient(options ...Option) *http.Client { + cfg := config{ + dialTimeout: 5 * time.Second, + tcpKeepAliveTimeout: 0, + idleConnTimeout: 90 * time.Second, + } + for _, v := range options { + v(&cfg) + } + return &http.Client{ + Transport: &http.Transport{ + DialContext: (&net.Dialer{ + Timeout: cfg.dialTimeout, + KeepAlive: cfg.tcpKeepAliveTimeout, + }).DialContext, + IdleConnTimeout: cfg.idleConnTimeout, + DisableKeepAlives: cfg.disableKeepAlives, + MaxIdleConnsPerHost: cfg.maxIdleConnsPerHost, + TLSClientConfig: cfg.tlsConfig, + }, + Timeout: cfg.requestTimeout, + } +} diff --git a/vendor/code.cloudfoundry.org/cfhttp/v2/package.go b/vendor/code.cloudfoundry.org/cfhttp/v2/package.go new file mode 100644 index 00000000..13638153 --- /dev/null +++ b/vendor/code.cloudfoundry.org/cfhttp/v2/package.go @@ -0,0 +1 @@ +package cfhttp // import "code.cloudfoundry.org/cfhttp/v2" diff --git a/vendor/code.cloudfoundry.org/cfhttp/v2/staticcheck.conf b/vendor/code.cloudfoundry.org/cfhttp/v2/staticcheck.conf new file mode 100644 index 00000000..eba7af74 --- /dev/null +++ b/vendor/code.cloudfoundry.org/cfhttp/v2/staticcheck.conf @@ -0,0 +1 @@ +checks = ["all", "-ST1008","-ST1005","-ST1001","-ST1012","-ST1000","-ST1003","-ST1016","-ST1020","-ST1021","-ST1022"] diff --git a/vendor/code.cloudfoundry.org/dockerdriver/driverhttp/remote_client.go b/vendor/code.cloudfoundry.org/dockerdriver/driverhttp/remote_client.go index 1e40875c..08e796f2 100644 --- a/vendor/code.cloudfoundry.org/dockerdriver/driverhttp/remote_client.go +++ b/vendor/code.cloudfoundry.org/dockerdriver/driverhttp/remote_client.go @@ -5,12 +5,10 @@ import ( "context" "encoding/json" "errors" - "fmt" "io" "net/http" - "strings" - "code.cloudfoundry.org/cfhttp" + "code.cloudfoundry.org/cfhttp/v2" "code.cloudfoundry.org/clock" "code.cloudfoundry.org/dockerdriver" "code.cloudfoundry.org/goshims/http_wrap" @@ -49,28 +47,18 @@ func NewRemoteClient(url string, tls *dockerdriver.TLSConfig) (*remoteClient, er client := cfhttp.NewClient() input_url := url - if strings.Contains(url, ".sock") { - client = cfhttp.NewUnixClient(url) - url = fmt.Sprintf("unix://%s", url) - } else { - if tls != nil { - tlsConfig, err := tlsconfig.Build( - tlsconfig.WithInternalServiceDefaults(), - tlsconfig.WithIdentityFromFile(tls.CertFile, tls.KeyFile), - ).Client(tlsconfig.WithAuthorityFromFile(tls.CAFile)) - if err != nil { - return nil, err - } - - tlsConfig.InsecureSkipVerify = tls.InsecureSkipVerify - - if tr, ok := client.Transport.(*http.Transport); ok { - tr.TLSClientConfig = tlsConfig - } else { - return nil, errors.New("Invalid transport") - } + if tls != nil { + tlsConfig, err := tlsconfig.Build( + tlsconfig.WithInternalServiceDefaults(), + tlsconfig.WithIdentityFromFile(tls.CertFile, tls.KeyFile), + ).Client(tlsconfig.WithAuthorityFromFile(tls.CAFile)) + if err != nil { + return nil, err } + tlsConfig.InsecureSkipVerify = tls.InsecureSkipVerify + + client = cfhttp.NewClient(cfhttp.WithTLSConfig(tlsConfig)) } driver := NewRemoteClientWithClient(url, tls, client, clock.NewClock()) diff --git a/vendor/modules.txt b/vendor/modules.txt index 047913bc..c3201e55 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,12 +1,13 @@ # code.cloudfoundry.org/cfhttp v2.0.0+incompatible ## explicit -code.cloudfoundry.org/cfhttp code.cloudfoundry.org/cfhttp/handlers -code.cloudfoundry.org/cfhttp/unix_transport +# code.cloudfoundry.org/cfhttp/v2 v2.0.1 +## explicit; go 1.19 +code.cloudfoundry.org/cfhttp/v2 # code.cloudfoundry.org/clock v1.1.0 ## explicit; go 1.20 code.cloudfoundry.org/clock -# code.cloudfoundry.org/dockerdriver v0.0.0-20240425154110-a68c794c8bb0 +# code.cloudfoundry.org/dockerdriver v0.0.0-20240521135308-9fa280d26502 ## explicit; go 1.19 code.cloudfoundry.org/dockerdriver code.cloudfoundry.org/dockerdriver/driverhttp