diff --git a/go.mod b/go.mod index 9a33ce37..de7d4f46 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21 toolchain go1.22.0 require ( - github.com/go-chef/chef v0.29.0 + github.com/go-chef/chef v0.30.1 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/terraform-plugin-docs v0.19.4 github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 diff --git a/go.sum b/go.sum index 26bae80e..cfbe2c91 100644 --- a/go.sum +++ b/go.sum @@ -44,8 +44,8 @@ github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= -github.com/go-chef/chef v0.29.0 h1:7U9P8op5jqaDXo6wANjopiirSENtemTVfoXFEgG8hso= -github.com/go-chef/chef v0.29.0/go.mod h1:7RU1oCrRErTrkmIszkhJ9vHw7Bv2hZ1Vv1C1qKj01fc= +github.com/go-chef/chef v0.30.1 h1:yvOSijEBWAQtRbBPj9hz1atEJUU6HckPc7AaEyZXnLg= +github.com/go-chef/chef v0.30.1/go.mod h1:7RU1oCrRErTrkmIszkhJ9vHw7Bv2hZ1Vv1C1qKj01fc= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= diff --git a/vendor/github.com/go-chef/chef/http.go b/vendor/github.com/go-chef/chef/http.go index 8b9390bd..543730d8 100644 --- a/vendor/github.com/go-chef/chef/http.go +++ b/vendor/github.com/go-chef/chef/http.go @@ -50,7 +50,7 @@ type AuthConfig struct { type Client struct { Auth *AuthConfig BaseURL *url.URL - client *http.Client + Client *http.Client IsWebuiKey bool ACLs *ACLService @@ -114,6 +114,10 @@ type Config struct { // Pointer to an HTTP Client to use instead of the default Client *http.Client + + // A function which wraps an existing RoundTripper. + // Cannot be used if Client is set. + RoundTripper func(http.RoundTripper) http.RoundTripper } /* @@ -266,10 +270,36 @@ func NewClient(cfg *Config) (*Client, error) { } if cfg.Client != nil { - c.client = cfg.Client + if cfg.RoundTripper != nil { + return nil, errors.New("NewClient: cannot set both Client and RoundTripper") + } + c.Client = cfg.Client } else { - c.client = &http.Client{ - Transport: tr, + tlsConfig := &tls.Config{InsecureSkipVerify: cfg.SkipSSL} + if cfg.RootCAs != nil { + tlsConfig.RootCAs = cfg.RootCAs + } + tr := &http.Transport{ + Proxy: http.ProxyFromEnvironment, + Dial: (&net.Dialer{ + Timeout: 30 * time.Second, + KeepAlive: 30 * time.Second, + }).Dial, + TLSClientConfig: tlsConfig, + TLSHandshakeTimeout: 10 * time.Second, + } + + if cfg.Proxy != nil { + tr.Proxy = cfg.Proxy + } + + var transport http.RoundTripper = tr + if cfg.RoundTripper != nil { + transport = cfg.RoundTripper(tr) + } + + c.Client = &http.Client{ + Transport: transport, Timeout: time.Duration(cfg.Timeout) * time.Second, } } @@ -315,7 +345,7 @@ func NewClientWithOutConfig(baseurl string) (*Client, error) { } c := &Client{ - client: &http.Client{ + Client: &http.Client{ Transport: tr, Timeout: 60 * time.Second, }, @@ -511,7 +541,7 @@ func ChefError(err error) (cerr *ErrorResponse, nerr error) { // Do is used either internally via our magic request shite or a user may use it func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error) { - res, err := c.client.Do(req) + res, err := c.Client.Do(req) if err != nil { return nil, err } diff --git a/vendor/github.com/posener/complete/readme.md b/vendor/github.com/posener/complete/README.md similarity index 100% rename from vendor/github.com/posener/complete/readme.md rename to vendor/github.com/posener/complete/README.md diff --git a/vendor/modules.txt b/vendor/modules.txt index 44407fba..91efd1cc 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -70,7 +70,7 @@ github.com/cloudflare/circl/sign/ed448 # github.com/fatih/color v1.17.0 ## explicit; go 1.17 github.com/fatih/color -# github.com/go-chef/chef v0.29.0 +# github.com/go-chef/chef v0.30.1 ## explicit; go 1.20 github.com/go-chef/chef # github.com/golang/protobuf v1.5.4