From 9f8288b8af1ead3342916cf3fc8fbfc009304a07 Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Thu, 1 Aug 2019 15:00:08 +0100 Subject: [PATCH] [TEMPORARY] Pin terraform to f-httpclient-ua --- go.mod | 4 +- go.sum | 14 +- .../terraform/helper/schema/resource.go | 7 +- .../terraform/helper/schema/schema.go | 3 - .../terraform/httpclient/useragent.go | 131 ++++++++++++++++++ .../terraform/terraform/user_agent.go | 3 +- .../hashicorp/terraform/terraform/version.go | 2 +- .../hashicorp/terraform/version/version.go | 2 +- vendor/modules.txt | 2 +- 9 files changed, 153 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index 74c84770f4..e714689209 100644 --- a/go.mod +++ b/go.mod @@ -3,12 +3,14 @@ module github.com/terraform-providers/terraform-provider-cloudflare go 1.12 require ( + github.com/aws/aws-sdk-go v1.21.7 // indirect github.com/cloudflare/cloudflare-go v0.9.4 github.com/hashicorp/go-cleanhttp v0.5.1 github.com/hashicorp/go-hclog v0.9.2 // indirect github.com/hashicorp/hcl2 v0.0.0-20190729005642-0c3fe388e450 // indirect - github.com/hashicorp/terraform v0.12.6 + github.com/hashicorp/terraform v0.12.6-0.20190731153428-29e24795f1b2 github.com/pkg/errors v0.8.1 + github.com/zclconf/go-cty-yaml v1.0.1 // indirect golang.org/x/net v0.0.0-20190628185345-da137c7871d7 google.golang.org/genproto v0.0.0-20190716165318-c506a9f90610 // indirect ) diff --git a/go.sum b/go.sum index 72b57adc00..06e76bc859 100644 --- a/go.sum +++ b/go.sum @@ -27,8 +27,11 @@ github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXva github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agl/ed25519 v0.0.0-20150830182803-278e1ec8e8a6 h1:LoeFxdq5zUCBQPhbQKE6zvoGwHMxCBlqwbH9+9kHoHA= github.com/agl/ed25519 v0.0.0-20150830182803-278e1ec8e8a6/go.mod h1:WPjqKcmVOxf0XSf3YxCJs6N6AOSrOx3obionmG7T0y0= +github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190329064014-6e358769c32a h1:APorzFpCcv6wtD5vmRWYqNm4N55kbepL7c7kTq9XI6A= github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190329064014-6e358769c32a/go.mod h1:T9M45xf79ahXVelWoOBmH0y4aC1t5kXO5BxwyakgIGA= +github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190103054945-8205d1f41e70 h1:FrF4uxA24DF3ARNXVbUin3wa5fDLaB1Cy8mKks/LRz4= github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190103054945-8205d1f41e70/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= +github.com/aliyun/aliyun-tablestore-go-sdk v4.1.2+incompatible h1:ABQ7FF+IxSFHDMOTtjCfmMDMHiCq6EsAoCV/9sFinaM= github.com/aliyun/aliyun-tablestore-go-sdk v4.1.2+incompatible/go.mod h1:LDQHRZylxvcg8H7wBIDfvO5g/cy4/sz1iucBlc2l3Jw= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/antchfx/xpath v0.0.0-20190129040759-c8489ed3251e/go.mod h1:Yee4kTMuNiPYJ7nSNorELQMr1J33uOpXDMByNYhvtNk= @@ -50,6 +53,7 @@ github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgI github.com/aws/aws-sdk-go v1.15.78 h1:LaXy6lWR0YK7LKyuU0QWy2ws/LWTPfYV/UgfiBu4tvY= github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM= github.com/aws/aws-sdk-go v1.16.36/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go v1.20.19/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.21.7 h1:ml+k7szyVaq4YD+3LhqOGl9tgMTqgMbpnuUSkB6UJvQ= github.com/aws/aws-sdk-go v1.21.7/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc= @@ -205,8 +209,8 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO github.com/hashicorp/memberlist v0.1.0/go.mod h1:ncdBp14cuox2iFOq3kDiquKU6fqsTBc3W6JvZwjxxsE= github.com/hashicorp/serf v0.0.0-20160124182025-e4ec8cc423bb h1:ZbgmOQt8DOg796figP87/EFCVx2v2h9yRvwHF/zceX4= github.com/hashicorp/serf v0.0.0-20160124182025-e4ec8cc423bb/go.mod h1:h/Ru6tmZazX7WO/GDmwdpS975F019L4t5ng5IgwbNrE= -github.com/hashicorp/terraform v0.12.6 h1:mWItQdLZQ7f3kBYBu2Kgdg+E5iZb1KtCq73V10Hmu48= -github.com/hashicorp/terraform v0.12.6/go.mod h1:udmq5rU8CO9pEIh/A/Xrs3zb3yYU/W9ce1pp8K1ysHA= +github.com/hashicorp/terraform v0.12.6-0.20190731153428-29e24795f1b2 h1:uQhkc+TjkBh3DisLjBfnV0As2MOYN5nEpfAJqms/bpA= +github.com/hashicorp/terraform v0.12.6-0.20190731153428-29e24795f1b2/go.mod h1:9k1Dfe/qxpci2K7832vhgXj1uqnRELMiTD4SlG1+0II= github.com/hashicorp/terraform-config-inspect v0.0.0-20190327195015-8022a2663a70 h1:oZm5nE11yhzsTRz/YrUyDMSvixePqjoZihwn8ipuOYI= github.com/hashicorp/terraform-config-inspect v0.0.0-20190327195015-8022a2663a70/go.mod h1:ItvqtvbC3K23FFET62ZwnkwtpbKZm8t8eMcWjmVVjD8= github.com/hashicorp/vault v0.10.4/go.mod h1:KfSyffbKxoVyspOdlaGVjIuwLobi07qD1bAbosPMpP0= @@ -221,6 +225,7 @@ github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/joyent/triton-go v0.0.0-20180313100802-d8f9c0314926 h1:kie3qOosvRKqwij2HGzXWffwpXvcqfPPXRUw8I4F/mg= github.com/joyent/triton-go v0.0.0-20180313100802-d8f9c0314926/go.mod h1:U+RSyWxWd04xTqnuOQxnai7XGS2PrPY2cfGoDKtMHjA= +github.com/json-iterator/go v1.1.5 h1:gL2yXlmiIo4+t+y32d4WGwOjKGYcGOuyrg46vadswDE= github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/jtolds/gls v4.2.1+incompatible h1:fSuqC+Gmlu6l/ZYAoZzx2pyucC8Xza35fpRVWLVmUEE= github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= @@ -291,7 +296,9 @@ github.com/mitchellh/prefixedio v0.0.0-20190213213902-5733675afd51 h1:eD92Am0Qf3 github.com/mitchellh/prefixedio v0.0.0-20190213213902-5733675afd51/go.mod h1:kB1naBgV9ORnkiTVeyJOI1DavaJkG4oNIq0Af6ZVKUo= github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= @@ -381,10 +388,12 @@ github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18/go.mod h1:UETIi67q github.com/xlab/treeprint v0.0.0-20161029104018-1d6e34225557 h1:Jpn2j6wHkC9wJv5iMfJhKqrZJx3TahFx+7sbZ7zQdxs= github.com/xlab/treeprint v0.0.0-20161029104018-1d6e34225557/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg= github.com/zclconf/go-cty v0.0.0-20181129180422-88fbe721e0f8/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= +github.com/zclconf/go-cty v0.0.0-20190516203816-4fecf87372ec/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.0.0 h1:EWtv3gKe2wPLIB9hQRQJa7k/059oIfAqcEkCNnaVckk= github.com/zclconf/go-cty v1.0.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.0.1-0.20190708163926-19588f92a98f h1:sq2p8SN6ji66CFEQFIWLlD/gFmGtr5hBrOzv5nLlGfA= github.com/zclconf/go-cty v1.0.1-0.20190708163926-19588f92a98f/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= +github.com/zclconf/go-cty-yaml v0.1.0/go.mod h1:Lk26EcRlO3XbaQ8U2fxIJbEtbgEteSZFUpEr3XFTtsU= github.com/zclconf/go-cty-yaml v1.0.1 h1:up11wlgAaDvlAGENcFDnZgkn0qUJurso7k6EpURKNF8= github.com/zclconf/go-cty-yaml v1.0.1/go.mod h1:IP3Ylp0wQpYm50IHK8OZWKMu6sPJIUgKa8XhiVHura0= go.opencensus.io v0.18.0 h1:Mk5rgZcggtbvtAun5aJzAtjKKN/t0R3jJPlWILlv938= @@ -505,6 +514,7 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/ini.v1 v1.42.0 h1:7N3gPTt50s8GuLortA00n8AqRTk75qOP98+mTPpgzRk= gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= diff --git a/vendor/github.com/hashicorp/terraform/helper/schema/resource.go b/vendor/github.com/hashicorp/terraform/helper/schema/resource.go index b59e4e82e7..bcfe5666fc 100644 --- a/vendor/github.com/hashicorp/terraform/helper/schema/resource.go +++ b/vendor/github.com/hashicorp/terraform/helper/schema/resource.go @@ -95,10 +95,9 @@ type Resource struct { // // Exists is a function that is called to check if a resource still // exists. If this returns false, then this will affect the diff - // accordingly. If this function isn't set, it will not be called. You - // can also signal existence in the Read method by calling d.SetId("") - // if the Resource is no longer present and should be removed from state. - // The *ResourceData passed to Exists should _not_ be modified. + // accordingly. If this function isn't set, it will not be called. It + // is highly recommended to set it. The *ResourceData passed to Exists + // should _not_ be modified. Create CreateFunc Read ReadFunc Update UpdateFunc diff --git a/vendor/github.com/hashicorp/terraform/helper/schema/schema.go b/vendor/github.com/hashicorp/terraform/helper/schema/schema.go index bcc8e4ba34..3e5f5da1b7 100644 --- a/vendor/github.com/hashicorp/terraform/helper/schema/schema.go +++ b/vendor/github.com/hashicorp/terraform/helper/schema/schema.go @@ -1371,9 +1371,6 @@ func (m schemaMap) validate( // The SDK has to allow the unknown value through initially, so that // Required fields set via an interpolated value are accepted. if !isWhollyKnown(raw) { - if schema.Deprecated != "" { - return []string{fmt.Sprintf("%q: [DEPRECATED] %s", k, schema.Deprecated)}, nil - } return nil, nil } diff --git a/vendor/github.com/hashicorp/terraform/httpclient/useragent.go b/vendor/github.com/hashicorp/terraform/httpclient/useragent.go index 5e28017688..4fe8ba07b0 100644 --- a/vendor/github.com/hashicorp/terraform/httpclient/useragent.go +++ b/vendor/github.com/hashicorp/terraform/httpclient/useragent.go @@ -5,6 +5,7 @@ import ( "log" "net/http" "os" + "regexp" "strings" "github.com/hashicorp/terraform/version" @@ -13,6 +14,7 @@ import ( const userAgentFormat = "Terraform/%s" const uaEnvVar = "TF_APPEND_USER_AGENT" +// Deprecated: Use UserAgent(version) instead func UserAgentString() string { ua := fmt.Sprintf(userAgentFormat, version.Version) @@ -38,3 +40,132 @@ func (rt *userAgentRoundTripper) RoundTrip(req *http.Request) (*http.Response, e } return rt.inner.RoundTrip(req) } + +func UserAgent(version string) *userAgent { + return newUserAgent([]*UserAgentProduct{ + {"HashiCorp", "1.0", ""}, + {"Terraform", version, "+https://www.terraform.io"}, + }) +} + +type UserAgentProduct struct { + Name string + Version string + Comment string +} + +func (uap *UserAgentProduct) String() string { + var b strings.Builder + b.WriteString(uap.Name) + if uap.Version != "" { + b.WriteString(fmt.Sprintf("/%s", uap.Version)) + } + if uap.Comment != "" { + b.WriteString(fmt.Sprintf(" (%s)", uap.Comment)) + } + return b.String() +} + +func (uap *UserAgentProduct) Equal(p *UserAgentProduct) bool { + if uap.Name == p.Name && + uap.Version == p.Version && + uap.Comment == p.Comment { + return true + } + return false +} + +type userAgent struct { + products []*UserAgentProduct +} + +func (ua *userAgent) Products() []*UserAgentProduct { + return ua.products +} + +func (ua *userAgent) String() string { + var b strings.Builder + for i, p := range ua.products { + if i > 0 { + b.WriteString(" ") + } + b.WriteString(p.String()) + } + + return b.String() +} + +func (ua *userAgent) Append(uap ...*UserAgentProduct) *userAgent { + ua.products = append(ua.products, uap...) + return ua +} + +func (ua *userAgent) AppendString(uap ...string) *userAgent { + for _, uaString := range uap { + products, err := ParseUserAgentString(uaString) + if err != nil { + log.Printf("[WARN] Unable to append User-Agent string %q: %s", + uaString, err) + continue + } + + ua.products = append(ua.products, products...) + } + return ua +} + +func (ua *userAgent) Equal(userAgent *userAgent) bool { + if len(ua.products) != len(userAgent.products) { + return false + } + + for i, p := range ua.products { + if !p.Equal(userAgent.products[i]) { + return false + } + } + + return true +} + +func newUserAgent(products []*UserAgentProduct) *userAgent { + ua := &userAgent{products} + + if add := os.Getenv(uaEnvVar); add != "" { + add = strings.TrimSpace(add) + if len(add) > 0 { + parsedUAs, err := ParseUserAgentString(add) + if err != nil { + log.Printf("[WARN] Unable to parse User-Agent string %q: %s", + add, err) + return ua + } + ua = ua.Append(parsedUAs...) + log.Printf("[DEBUG] Using modified User-Agent: %s", ua) + } + } + + return ua +} + +func ParseUserAgentString(uaString string) ([]*UserAgentProduct, error) { + products := make([]*UserAgentProduct, 0) + + // Parse "Product/version (comment)" + re := regexp.MustCompile(`([^/]+)/([^\s]+)(\s\([^\)]+\))?`) + matches := re.FindAllStringSubmatch(uaString, -1) + + if len(matches) == 0 { + return nil, fmt.Errorf("Invalid User-Agent format: %q", uaString) + } + + for _, match := range matches { + products = append(products, &UserAgentProduct{ + Name: strings.TrimSpace(match[1]), + Version: match[2], + Comment: strings.Trim(strings.TrimSpace(match[3]), "()"), + }) + } + + return products, nil +} diff --git a/vendor/github.com/hashicorp/terraform/terraform/user_agent.go b/vendor/github.com/hashicorp/terraform/terraform/user_agent.go index a42613e858..97f1ec1f6d 100644 --- a/vendor/github.com/hashicorp/terraform/terraform/user_agent.go +++ b/vendor/github.com/hashicorp/terraform/terraform/user_agent.go @@ -6,8 +6,7 @@ import ( // Generate a UserAgent string // -// Deprecated: Use httpclient.UserAgentString if you are setting your -// own User-Agent header. +// Deprecated: Use httpclient.UserAgent(version) instead func UserAgentString() string { return httpclient.UserAgentString() } diff --git a/vendor/github.com/hashicorp/terraform/terraform/version.go b/vendor/github.com/hashicorp/terraform/terraform/version.go index ac730154f5..0caeca0ad9 100644 --- a/vendor/github.com/hashicorp/terraform/terraform/version.go +++ b/vendor/github.com/hashicorp/terraform/terraform/version.go @@ -4,7 +4,7 @@ import ( "github.com/hashicorp/terraform/version" ) -// TODO: update providers to use the version package directly +// Deprecated: Providers should use schema.Provider.TerraformVersion instead func VersionString() string { return version.String() } diff --git a/vendor/github.com/hashicorp/terraform/version/version.go b/vendor/github.com/hashicorp/terraform/version/version.go index c30595c5cd..f10fc3724d 100644 --- a/vendor/github.com/hashicorp/terraform/version/version.go +++ b/vendor/github.com/hashicorp/terraform/version/version.go @@ -16,7 +16,7 @@ var Version = "0.12.6" // A pre-release marker for the version. If this is "" (empty string) // then it means that it is a final release. Otherwise, this is a pre-release // such as "dev" (in development), "beta", "rc1", etc. -var Prerelease = "" +var Prerelease = "dev" // SemVer is an instance of version.Version. This has the secondary // benefit of verifying during tests and init time that our version is a diff --git a/vendor/modules.txt b/vendor/modules.txt index 83f4750593..4a44d2b2fa 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -126,7 +126,7 @@ github.com/hashicorp/hil/parser github.com/hashicorp/hil/scanner # github.com/hashicorp/logutils v1.0.0 github.com/hashicorp/logutils -# github.com/hashicorp/terraform v0.12.6 +# github.com/hashicorp/terraform v0.12.6-0.20190731153428-29e24795f1b2 github.com/hashicorp/terraform/plugin github.com/hashicorp/terraform/helper/hashcode github.com/hashicorp/terraform/helper/logging