From f2b5fb122f1716641257b031d20c1e0c020c5a5f Mon Sep 17 00:00:00 2001 From: Conor Mongey Date: Mon, 15 Jan 2018 00:17:35 +0000 Subject: [PATCH] Update terraform dep to 0.11.2 --- Gopkg.lock | 7 +- Gopkg.toml | 2 +- .../hashicorp/terraform/CHANGELOG.md | 34 ++ .../hashicorp/terraform/commands.go | 13 +- .../hashicorp/terraform/config/config.go | 18 +- .../hashicorp/terraform/config/config_test.go | 2 +- .../config/configschema/nestingmode_string.go | 4 +- .../terraform/config/interpolate_funcs.go | 70 +++- .../config/interpolate_funcs_test.go | 180 ++++++++++ .../terraform/config/module/get_test.go | 335 ------------------ .../terraform/config/module/inode.go | 2 +- .../terraform/config/module/module_test.go | 18 - .../terraform/config/module/storage.go | 30 +- .../terraform/config/module/storage_test.go | 146 +++++++- .../terraform/config/resource_mode_string.go | 4 +- .../hashicorp/terraform/config_unix.go | 1 - .../helper/schema/getsource_string.go | 6 +- .../terraform/helper/schema/resource.go | 1 - .../terraform/helper/schema/resource_data.go | 4 +- .../terraform/helper/schema/resource_diff.go | 15 +- .../terraform/helper/schema/schema.go | 106 +++--- .../terraform/helper/schema/schema_test.go | 32 ++ .../helper/schema/valuetype_string.go | 4 +- .../module/registry.go => registry/client.go} | 107 +++--- .../client_test.go} | 53 ++- .../hashicorp/terraform/terraform/context.go | 9 +- .../terraform/terraform/context_apply_test.go | 1 - .../terraform/terraform/context_plan_test.go | 26 ++ .../hashicorp/terraform/terraform/diff.go | 5 + .../terraform/terraform/eval_diff.go | 6 +- .../terraform/terraform/eval_diff_test.go | 68 ++++ .../terraform/terraform/eval_provider_test.go | 5 +- .../terraform/terraform/eval_validate.go | 1 + .../terraform/terraform/graphtype_string.go | 4 +- .../terraform/instancetype_string.go | 4 +- .../terraform/terraform/interpolate.go | 3 - .../terraform/module_dependencies.go | 1 - .../hashicorp/terraform/terraform/resource.go | 2 +- .../terraform/resource_provider_mock.go | 1 + .../terraform/terraform/resource_test.go | 8 + .../hashicorp/terraform/terraform/state.go | 21 ++ .../terraform/terraform/terraform_test.go | 3 - .../terraform/terraform/transform_provider.go | 8 +- .../terraform/walkoperation_string.go | 4 +- .../terraform/tfdiags/severity_string.go | 9 +- .../hashicorp/terraform/version/version.go | 2 +- 46 files changed, 816 insertions(+), 569 deletions(-) delete mode 100644 vendor/github.com/hashicorp/terraform/config/module/get_test.go rename vendor/github.com/hashicorp/terraform/{config/module/registry.go => registry/client.go} (67%) rename vendor/github.com/hashicorp/terraform/{config/module/registry_test.go => registry/client_test.go} (73%) diff --git a/Gopkg.lock b/Gopkg.lock index 4f2de120..fdb1d43a 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -236,6 +236,7 @@ "moduledeps", "plugin", "plugin/discovery", + "registry", "registry/regsrc", "registry/response", "svchost", @@ -245,8 +246,8 @@ "tfdiags", "version" ] - revision = "a42fdb08a43c7fabb8898fe8c286b793bbaa4835" - version = "v0.11.1" + revision = "a6008b8a48a749c7c167453b9cf55ffd572b9a5d" + version = "v0.11.2" [[projects]] branch = "master" @@ -472,6 +473,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "b6552a3c83989fe1859d0d19ed99d92e299768f79269d7f5157b0db27996e17b" + inputs-digest = "dcfc8f489c5394ec548dd7ab320bec8e84beda42e5c17bd4c7652c1249a492b2" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 58a94692..f03e4780 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -8,4 +8,4 @@ [[constraint]] name = "github.com/hashicorp/terraform" - version = "0.11.1" + version = "0.11.2" diff --git a/vendor/github.com/hashicorp/terraform/CHANGELOG.md b/vendor/github.com/hashicorp/terraform/CHANGELOG.md index ab045657..dc680299 100644 --- a/vendor/github.com/hashicorp/terraform/CHANGELOG.md +++ b/vendor/github.com/hashicorp/terraform/CHANGELOG.md @@ -1,3 +1,37 @@ +## 0.11.2 (January 9, 2018) + +BACKWARDS INCOMPATIBILITIES / NOTES: + +* backend/gcs: The gcs remote state backend was erroneously creating the state bucket if it didn't exist. This is not the intended behavior of backends, as Terraform cannot track or manage that resource. The target bucket must now be created separately, before using it with Terraform. ([#16865](https://github.com/hashicorp/terraform/issues/16865)) + +NEW FEATURES: + +* **[Habitat](https://www.habitat.sh/) Provisioner** allowing automatic installation of the Habitat agent ([#16280](https://github.com/hashicorp/terraform/issues/16280)) + +IMPROVEMENTS: + +* core: removed duplicate prompts and clarified working when migration backend configurations ([#16939](https://github.com/hashicorp/terraform/issues/16939)) +* config: new `rsadecrypt` interpolation function allows decrypting a base64-encoded ciphertext using a given private key. This is particularly useful for decrypting the password for a Windows instance on AWS EC2, but is generic and may find other uses too. ([#16647](https://github.com/hashicorp/terraform/issues/16647)) +* config: new `timeadd` interpolation function allows calculating a new timestamp relative to an existing known timestamp. ([#16644](https://github.com/hashicorp/terraform/issues/16644)) +* cli: Passing an empty string to `-plugin-dir` during init will remove previously saved paths ([#16969](https://github.com/hashicorp/terraform/issues/16969)) +* cli: Module and provider installation (and some other Terraform features) now implement [RFC6555](https://tools.ietf.org/html/rfc6555) when making outgoing HTTP requests, which should improve installation reliability for dual-stack (both IPv4 and IPv6) hosts running on networks that have non-performant or broken IPv6 Internet connectivity by trying both IPv4 and IPv6 connections. ([#16805](https://github.com/hashicorp/terraform/issues/16805)) +* backend/s3: it is now possible to disable the region check, for improved compatibility with third-party services that attempt to mimic the S3 API. ([#16757](https://github.com/hashicorp/terraform/issues/16757)) +* backend/s3: it is now possible to for the path-based S3 API form, for improved compatibility with third-party services that attempt to mimic the S3 API. ([#17001](https://github.com/hashicorp/terraform/issues/17001)) +* backend/s3: it is now possible to use named credentials from the `~/.aws/credentials` file, similarly to the AWS plugin ([#16661](https://github.com/hashicorp/terraform/issues/16661)) +* backend/manta: support for Triton RBAC ([#17003](https://github.com/hashicorp/terraform/issues/17003)) +* backend/gcs: support for customer-supplied encryption keys for remote state buckets ([#16936](https://github.com/hashicorp/terraform/issues/16936)) +* provider/terraform: in `terraform_remote_state`, the argument `environment` is now deprecated in favor of `workspace`. The `environment` argument will be removed in a later Terraform release. ([#16558](https://github.com/hashicorp/terraform/issues/16558)) + +BUG FIXES: + +* config: fixed crash in `substr` interpolation function with invalid offset ([#17043](https://github.com/hashicorp/terraform/issues/17043)) +* config: Referencing a count attribute in an output no longer generates a warning ([#16866](https://github.com/hashicorp/terraform/issues/16866)) +* cli: Terraform will no longer crash when `terraform plan`, `terraform apply`, and some other commands encounter an invalid provider version constraint in configuration, generating a proper error message instead. ([#16867](https://github.com/hashicorp/terraform/issues/16867)) +* backend/gcs: The usage of the GOOGLE_CREDENTIALS environment variable now matches that of the google provider ([#16865](https://github.com/hashicorp/terraform/issues/16865)) +* backend/gcs: fixed the locking methodology to avoid "double-locking" issues when used with the `terraform_remote_state` data source ([#16852](https://github.com/hashicorp/terraform/issues/16852)) +* backend/s3: the `workspace_key_prefix` can now be an empty string or contain slashes ([#16932](https://github.com/hashicorp/terraform/issues/16932)) +* provisioner/salt-masterless: now waits for all of the remote operations to complete before returning ([#16704](https://github.com/hashicorp/terraform/issues/16704)) + ## 0.11.1 (November 30, 2017) IMPROVEMENTS: diff --git a/vendor/github.com/hashicorp/terraform/commands.go b/vendor/github.com/hashicorp/terraform/commands.go index d65437f6..3335d2cd 100644 --- a/vendor/github.com/hashicorp/terraform/commands.go +++ b/vendor/github.com/hashicorp/terraform/commands.go @@ -63,6 +63,8 @@ func initCommands(config *Config) { RunningInAutomation: inAutomation, PluginCacheDir: config.PluginCacheDir, OverrideDataDir: dataDir, + + ShutdownCh: makeShutdownCh(), } // The command list is included in the terraform -help @@ -80,23 +82,20 @@ func initCommands(config *Config) { Commands = map[string]cli.CommandFactory{ "apply": func() (cli.Command, error) { return &command.ApplyCommand{ - Meta: meta, - ShutdownCh: makeShutdownCh(), + Meta: meta, }, nil }, "console": func() (cli.Command, error) { return &command.ConsoleCommand{ - Meta: meta, - ShutdownCh: makeShutdownCh(), + Meta: meta, }, nil }, "destroy": func() (cli.Command, error) { return &command.ApplyCommand{ - Meta: meta, - Destroy: true, - ShutdownCh: makeShutdownCh(), + Meta: meta, + Destroy: true, }, nil }, diff --git a/vendor/github.com/hashicorp/terraform/config/config.go b/vendor/github.com/hashicorp/terraform/config/config.go index c89f2ed7..055a7f33 100644 --- a/vendor/github.com/hashicorp/terraform/config/config.go +++ b/vendor/github.com/hashicorp/terraform/config/config.go @@ -8,6 +8,7 @@ import ( "strconv" "strings" + hcl2 "github.com/hashicorp/hcl2/hcl" "github.com/hashicorp/hil/ast" "github.com/hashicorp/terraform/helper/hilmapstructure" "github.com/hashicorp/terraform/plugin/discovery" @@ -415,10 +416,17 @@ func (c *Config) Validate() tfdiags.Diagnostics { if p.Version != "" { _, err := discovery.ConstraintStr(p.Version).Parse() if err != nil { - diags = diags.Append(fmt.Errorf( - "provider.%s: invalid version constraint %q: %s", - name, p.Version, err, - )) + diags = diags.Append(&hcl2.Diagnostic{ + Severity: hcl2.DiagError, + Summary: "Invalid provider version constraint", + Detail: fmt.Sprintf( + "The value %q given for provider.%s is not a valid version constraint.", + p.Version, name, + ), + // TODO: include a "Subject" source reference in here, + // once the config loader is able to retain source + // location information. + }) } } @@ -849,7 +857,7 @@ func (c *Config) Validate() tfdiags.Diagnostics { // a count might dynamically be set to something // other than 1 and thus splat syntax is still needed // to be safe. - if r.RawCount != nil && r.RawCount.Raw != nil && r.RawCount.Raw["count"] != "1" { + if r.RawCount != nil && r.RawCount.Raw != nil && r.RawCount.Raw["count"] != "1" && rv.Field != "count" { diags = diags.Append(tfdiags.SimpleWarning(fmt.Sprintf( "output %q: must use splat syntax to access %s attribute %q, because it has \"count\" set; use %s.*.%s to obtain a list of the attributes across all instances", o.Name, diff --git a/vendor/github.com/hashicorp/terraform/config/config_test.go b/vendor/github.com/hashicorp/terraform/config/config_test.go index 18bab3f1..6f6e7a46 100644 --- a/vendor/github.com/hashicorp/terraform/config/config_test.go +++ b/vendor/github.com/hashicorp/terraform/config/config_test.go @@ -217,7 +217,7 @@ func TestConfigValidate_table(t *testing.T) { "provider with invalid version constraint", "provider-version-invalid", true, - "invalid version constraint", + "not a valid version constraint", }, { "invalid provider name in module block", diff --git a/vendor/github.com/hashicorp/terraform/config/configschema/nestingmode_string.go b/vendor/github.com/hashicorp/terraform/config/configschema/nestingmode_string.go index d9253a20..6cb9313e 100644 --- a/vendor/github.com/hashicorp/terraform/config/configschema/nestingmode_string.go +++ b/vendor/github.com/hashicorp/terraform/config/configschema/nestingmode_string.go @@ -2,7 +2,7 @@ package configschema -import "fmt" +import "strconv" const _NestingMode_name = "nestingModeInvalidNestingSingleNestingListNestingSetNestingMap" @@ -10,7 +10,7 @@ var _NestingMode_index = [...]uint8{0, 18, 31, 42, 52, 62} func (i NestingMode) String() string { if i < 0 || i >= NestingMode(len(_NestingMode_index)-1) { - return fmt.Sprintf("NestingMode(%d)", i) + return "NestingMode(" + strconv.FormatInt(int64(i), 10) + ")" } return _NestingMode_name[_NestingMode_index[i]:_NestingMode_index[i+1]] } diff --git a/vendor/github.com/hashicorp/terraform/config/interpolate_funcs.go b/vendor/github.com/hashicorp/terraform/config/interpolate_funcs.go index 94894ffe..72be817a 100644 --- a/vendor/github.com/hashicorp/terraform/config/interpolate_funcs.go +++ b/vendor/github.com/hashicorp/terraform/config/interpolate_funcs.go @@ -4,12 +4,15 @@ import ( "bytes" "compress/gzip" "crypto/md5" + "crypto/rsa" "crypto/sha1" "crypto/sha256" "crypto/sha512" + "crypto/x509" "encoding/base64" "encoding/hex" "encoding/json" + "encoding/pem" "fmt" "io/ioutil" "math" @@ -103,6 +106,7 @@ func Funcs() map[string]ast.Function { "pow": interpolationFuncPow(), "uuid": interpolationFuncUUID(), "replace": interpolationFuncReplace(), + "rsadecrypt": interpolationFuncRsaDecrypt(), "sha1": interpolationFuncSha1(), "sha256": interpolationFuncSha256(), "sha512": interpolationFuncSha512(), @@ -112,6 +116,7 @@ func Funcs() map[string]ast.Function { "split": interpolationFuncSplit(), "substr": interpolationFuncSubstr(), "timestamp": interpolationFuncTimestamp(), + "timeadd": interpolationFuncTimeAdd(), "title": interpolationFuncTitle(), "transpose": interpolationFuncTranspose(), "trimspace": interpolationFuncTrimSpace(), @@ -1504,6 +1509,29 @@ func interpolationFuncTimestamp() ast.Function { } } +func interpolationFuncTimeAdd() ast.Function { + return ast.Function{ + ArgTypes: []ast.Type{ + ast.TypeString, // input timestamp string in RFC3339 format + ast.TypeString, // duration to add to input timestamp that should be parsable by time.ParseDuration + }, + ReturnType: ast.TypeString, + Callback: func(args []interface{}) (interface{}, error) { + + ts, err := time.Parse(time.RFC3339, args[0].(string)) + if err != nil { + return nil, err + } + duration, err := time.ParseDuration(args[1].(string)) + if err != nil { + return nil, err + } + + return ts.Add(duration).Format(time.RFC3339), nil + }, + } +} + // interpolationFuncTitle implements the "title" function that returns a copy of the // string in which first characters of all the words are capitalized. func interpolationFuncTitle() ast.Function { @@ -1549,7 +1577,7 @@ func interpolationFuncSubstr() ast.Function { return nil, fmt.Errorf("length should be a non-negative integer") } - if offset > len(str) { + if offset > len(str) || offset < 0 { return nil, fmt.Errorf("offset cannot be larger than the length of the string") } @@ -1657,3 +1685,43 @@ func interpolationFuncAbs() ast.Function { }, } } + +// interpolationFuncRsaDecrypt implements the "rsadecrypt" function that does +// RSA decryption. +func interpolationFuncRsaDecrypt() ast.Function { + return ast.Function{ + ArgTypes: []ast.Type{ast.TypeString, ast.TypeString}, + ReturnType: ast.TypeString, + Callback: func(args []interface{}) (interface{}, error) { + s := args[0].(string) + key := args[1].(string) + + b, err := base64.StdEncoding.DecodeString(s) + if err != nil { + return "", fmt.Errorf("Failed to decode input %q: cipher text must be base64-encoded", key) + } + + block, _ := pem.Decode([]byte(key)) + if block == nil { + return "", fmt.Errorf("Failed to read key %q: no key found", key) + } + if block.Headers["Proc-Type"] == "4,ENCRYPTED" { + return "", fmt.Errorf( + "Failed to read key %q: password protected keys are\n"+ + "not supported. Please decrypt the key prior to use.", key) + } + + x509Key, err := x509.ParsePKCS1PrivateKey(block.Bytes) + if err != nil { + return "", err + } + + out, err := rsa.DecryptPKCS1v15(nil, x509Key, b) + if err != nil { + return "", err + } + + return string(out), nil + }, + } +} diff --git a/vendor/github.com/hashicorp/terraform/config/interpolate_funcs_test.go b/vendor/github.com/hashicorp/terraform/config/interpolate_funcs_test.go index fc7540e8..f63d81c3 100644 --- a/vendor/github.com/hashicorp/terraform/config/interpolate_funcs_test.go +++ b/vendor/github.com/hashicorp/terraform/config/interpolate_funcs_test.go @@ -2426,6 +2426,38 @@ func TestInterpolateFuncTimestamp(t *testing.T) { } } +func TestInterpolateFuncTimeAdd(t *testing.T) { + testFunction(t, testFunctionConfig{ + Cases: []testFunctionCase{ + { + `${timeadd("2017-11-22T00:00:00Z", "1s")}`, + "2017-11-22T00:00:01Z", + false, + }, + { + `${timeadd("2017-11-22T00:00:00Z", "10m1s")}`, + "2017-11-22T00:10:01Z", + false, + }, + { // also support subtraction + `${timeadd("2017-11-22T00:00:00Z", "-1h")}`, + "2017-11-21T23:00:00Z", + false, + }, + { // Invalid format timestamp + `${timeadd("2017-11-22", "-1h")}`, + nil, + true, + }, + { // Invalid format duration (day is not supported by ParseDuration) + `${timeadd("2017-11-22T00:00:00Z", "1d")}`, + nil, + true, + }, + }, + }) +} + type testFunctionConfig struct { Cases []testFunctionCase Vars map[string]ast.Variable @@ -2536,6 +2568,11 @@ func TestInterpolateFuncSubstr(t *testing.T) { nil, true, }, + { + `${substr("foo", -4, -1)}`, + nil, + true, + }, // invalid length { @@ -2780,3 +2817,146 @@ func TestInterpolateFuncAbs(t *testing.T) { }, }) } + +func TestInterpolateFuncRsaDecrypt(t *testing.T) { + testFunction(t, testFunctionConfig{ + Vars: map[string]ast.Variable{ + "var.cipher_base64": ast.Variable{ + Type: ast.TypeString, + Value: "eczGaDhXDbOFRZGhjx2etVzWbRqWDlmq0bvNt284JHVbwCgObiuyX9uV0LSAMY707IEgMkExJqXmsB4OWKxvB7epRB9G/3+F+pcrQpODlDuL9oDUAsa65zEpYF0Wbn7Oh7nrMQncyUPpyr9WUlALl0gRWytOA23S+y5joa4M34KFpawFgoqTu/2EEH4Xl1zo+0fy73fEto+nfkUY+meuyGZ1nUx/+DljP7ZqxHBFSlLODmtuTMdswUbHbXbWneW51D7Jm7xB8nSdiA2JQNK5+Sg5x8aNfgvFTt/m2w2+qpsyFa5Wjeu6fZmXSl840CA07aXbk9vN4I81WmJyblD/ZA==", + }, + "var.private_key": ast.Variable{ + Type: ast.TypeString, + Value: ` +-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEAgUElV5mwqkloIrM8ZNZ72gSCcnSJt7+/Usa5G+D15YQUAdf9 +c1zEekTfHgDP+04nw/uFNFaE5v1RbHaPxhZYVg5ZErNCa/hzn+x10xzcepeS3KPV +Xcxae4MR0BEegvqZqJzN9loXsNL/c3H/B+2Gle3hTxjlWFb3F5qLgR+4Mf4ruhER +1v6eHQa/nchi03MBpT4UeJ7MrL92hTJYLdpSyCqmr8yjxkKJDVC2uRrr+sTSxfh7 +r6v24u/vp/QTmBIAlNPgadVAZw17iNNb7vjV7Gwl/5gHXonCUKURaV++dBNLrHIZ +pqcAM8wHRph8mD1EfL9hsz77pHewxolBATV+7QIDAQABAoIBAC1rK+kFW3vrAYm3 ++8/fQnQQw5nec4o6+crng6JVQXLeH32qXShNf8kLLG/Jj0vaYcTPPDZw9JCKkTMQ +0mKj9XR/5DLbBMsV6eNXXuvJJ3x4iKW5eD9WkLD4FKlNarBRyO7j8sfPTqXW7uat +NxWdFH7YsSRvNh/9pyQHLWA5OituidMrYbc3EUx8B1GPNyJ9W8Q8znNYLfwYOjU4 +Wv1SLE6qGQQH9Q0WzA2WUf8jklCYyMYTIywAjGb8kbAJlKhmj2t2Igjmqtwt1PYc +pGlqbtQBDUiWXt5S4YX/1maIQ/49yeNUajjpbJiH3DbhJbHwFTzP3pZ9P9GHOzlG +kYR+wSECgYEAw/Xida8kSv8n86V3qSY/I+fYQ5V+jDtXIE+JhRnS8xzbOzz3v0WS +Oo5H+o4nJx5eL3Ghb3Gcm0Jn46dHrxinHbm+3RjXv/X6tlbxIYjRSQfHOTSMCTvd +qcliF5vC6RCLXuc7R+IWR1Ky6eDEZGtrvt3DyeYABsp9fRUFR/6NluUCgYEAqNsw +1aSl7WJa27F0DoJdlU9LWerpXcazlJcIdOz/S9QDmSK3RDQTdqfTxRmrxiYI9LEs +mkOkvzlnnOBMpnZ3ZOU5qIRfprecRIi37KDAOHWGnlC0EWGgl46YLb7/jXiWf0AG +Y+DfJJNd9i6TbIDWu8254/erAS6bKMhW/3q7f2kCgYAZ7Id/BiKJAWRpqTRBXlvw +BhXoKvjI2HjYP21z/EyZ+PFPzur/lNaZhIUlMnUfibbwE9pFggQzzf8scM7c7Sf+ +mLoVSdoQ/Rujz7CqvQzi2nKSsM7t0curUIb3lJWee5/UeEaxZcmIufoNUrzohAWH +BJOIPDM4ssUTLRq7wYM9uQKBgHCBau5OP8gE6mjKuXsZXWUoahpFLKwwwmJUp2vQ +pOFPJ/6WZOlqkTVT6QPAcPUbTohKrF80hsZqZyDdSfT3peFx4ZLocBrS56m6NmHR +UYHMvJ8rQm76T1fryHVidz85g3zRmfBeWg8yqT5oFg4LYgfLsPm1gRjOhs8LfPvI +OLlRAoGBAIZ5Uv4Z3s8O7WKXXUe/lq6j7vfiVkR1NW/Z/WLKXZpnmvJ7FgxN4e56 +RXT7GwNQHIY8eDjDnsHxzrxd+raOxOZeKcMHj3XyjCX3NHfTscnsBPAGYpY/Wxzh +T8UYnFu6RzkixElTf2rseEav7rkdKkI3LAeIZy7B0HulKKsmqVQ7 +-----END RSA PRIVATE KEY----- +`, + }, + "var.wrong_private_key": ast.Variable{ + Type: ast.TypeString, + Value: ` +-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEAlrCgnEVgmNKCq7KPc+zUU5IrxPu1ClMNJS7RTsTPEkbwe5SB +p+6V6WtCbD/X/lDRRGbOENChh1Phulb7lViqgrdpHydgsrKoS5ah3DfSIxLFLE00 +9Yo4TCYwgw6+s59j16ZAFVinaQ9l6Kmrb2ll136hMrz8QKh+qw+onOLd38WFgm+W +ZtUqSXf2LANzfzzy4OWFNyFqKaCAolSkPdTS9Nz+svtScvp002DQp8OdP1AgPO+l +o5N3M38Fftapwg0pCtJ5Zq0NRWIXEonXiTEMA6zy3gEZVOmDxoIFUWnmrqlMJLFy +5S6LDrHSdqJhCxDK6WRZj43X9j8spktk3eGhMwIDAQABAoIBAAem8ID/BOi9x+Tw +LFi2rhGQWqimH4tmrEQ3HGnjlKBY+d1MrUjZ1MMFr1nP5CgF8pqGnfA8p/c3Sz8r +K5tp5T6+EZiDZ2WrrOApxg5ox0MAsQKO6SGO40z6o3wEQ6rbbTaGOrraxaWQIpyu +AQanU4Sd6ZGqByVBaS1GnklZO+shCHqw73b7g1cpLEmFzcYnKHYHlUUIsstMe8E1 +BaCY0CH7JbWBjcbiTnBVwIRZuu+EjGiQuhTilYL2OWqoMVg1WU0L2IFpR8lkf/2W +SBx5J6xhwbBGASOpM+qidiN580GdPzGhWYSqKGroHEzBm6xPSmV1tadNA26WFG4p +pthLiAECgYEA5BsPRpNYJAQLu5B0N7mj9eEp0HABVEgL/MpwiImjaKdAwp78HM64 +IuPvJxs7r+xESiIz4JyjR8zrQjYOCKJsARYkmNlEuAz0SkHabCw1BdEBwUhjUGVB +efoERK6GxfAoNqmSDwsOvHFOtsmDIlbHmg7G2rUxNVpeou415BSB0B8CgYEAqR4J +YHKk2Ibr9rU+rBU33TcdTGw0aAkFNAVeqM9j0haWuFXmV3RArgoy09lH+2Ha6z/g +fTX2xSDAWV7QUlLOlBRIhurPAo2jO2yCrGHPZcWiugstrR2hTTInigaSnCmK3i7F +6sYmL3S7K01IcVNxSlWvGijtClT92Cl2WUCTfG0CgYAiEjyk4QtQTd5mxLvnOu5X +oqs5PBGmwiAwQRiv/EcRMbJFn7Oupd3xMDSflbzDmTnWDOfMy/jDl8MoH6TW+1PA +kcsjnYhbKWwvz0hN0giVdtOZSDO1ZXpzOrn6fEsbM7T9/TQY1SD9WrtUKCNTNL0Z +sM1ZC6lu+7GZCpW4HKwLJwKBgQCRT0yxQXBg1/UxwuO5ynV4rx2Oh76z0WRWIXMH +S0MyxdP1SWGkrS/SGtM3cg/GcHtA/V6vV0nUcWK0p6IJyjrTw2XZ/zGluPuTWJYi +9dvVT26Vunshrz7kbH7KuwEICy3V4IyQQHeY+QzFlR70uMS0IVFWAepCoWqHbIDT +CYhwNQKBgGPcLXmjpGtkZvggl0aZr9LsvCTckllSCFSI861kivL/rijdNoCHGxZv +dfDkLTLcz9Gk41rD9Gxn/3sqodnTAc3Z2PxFnzg1Q/u3+x6YAgBwI/g/jE2xutGW +H7CurtMwALQ/n/6LUKFmjRZjqbKX9SO2QSaC3grd6sY9Tu+bZjLe +-----END RSA PRIVATE KEY----- +`, + }, + }, + Cases: []testFunctionCase{ + // Base-64 encoded cipher decrypts correctly + { + `${rsadecrypt(var.cipher_base64, var.private_key)}`, + "message", + false, + }, + // Raw cipher + { + `${rsadecrypt(base64decode(var.cipher_base64), var.private_key)}`, + nil, + true, + }, + // Wrong key + { + `${rsadecrypt(var.cipher_base64, var.wrong_private_key)}`, + nil, + true, + }, + // Bad key + { + `${rsadecrypt(var.cipher_base64, "bad key")}`, + nil, + true, + }, + // Empty key + { + `${rsadecrypt(var.cipher_base64, "")}`, + nil, + true, + }, + // Bad cipher + { + `${rsadecrypt("bad cipher", var.private_key)}`, + nil, + true, + }, + // Bad base64-encoded cipher + { + `${rsadecrypt(base64encode("bad cipher"), var.private_key)}`, + nil, + true, + }, + // Empty cipher + { + `${rsadecrypt("", var.private_key)}`, + nil, + true, + }, + // Too many arguments + { + `${rsadecrypt("", "", "")}`, + nil, + true, + }, + // One argument + { + `${rsadecrypt("")}`, + nil, + true, + }, + // No arguments + { + `${rsadecrypt()}`, + nil, + true, + }, + }, + }) +} diff --git a/vendor/github.com/hashicorp/terraform/config/module/get_test.go b/vendor/github.com/hashicorp/terraform/config/module/get_test.go deleted file mode 100644 index 0c6ff020..00000000 --- a/vendor/github.com/hashicorp/terraform/config/module/get_test.go +++ /dev/null @@ -1,335 +0,0 @@ -package module - -import ( - "encoding/json" - "fmt" - "io" - "net/http" - "net/http/httptest" - "net/url" - "os" - "regexp" - "sort" - "strings" - "testing" - - version "github.com/hashicorp/go-version" - "github.com/hashicorp/terraform/registry/regsrc" - "github.com/hashicorp/terraform/registry/response" -) - -// Map of module names and location of test modules. -// Only one version for now, as we only lookup latest from the registry. -type testMod struct { - location string - version string -} - -const ( - testCredentials = "test-auth-token" -) - -// All the locationes from the mockRegistry start with a file:// scheme. If -// the the location string here doesn't have a scheme, the mockRegistry will -// find the absolute path and return a complete URL. -var testMods = map[string][]testMod{ - "registry/foo/bar": {{ - location: "file:///download/registry/foo/bar/0.2.3//*?archive=tar.gz", - version: "0.2.3", - }}, - "registry/foo/baz": {{ - location: "file:///download/registry/foo/baz/1.10.0//*?archive=tar.gz", - version: "1.10.0", - }}, - "registry/local/sub": {{ - location: "test-fixtures/registry-tar-subdir/foo.tgz//*?archive=tar.gz", - version: "0.1.2", - }}, - "exists-in-registry/identifier/provider": {{ - location: "file:///registry/exists", - version: "0.2.0", - }}, - "relative/foo/bar": {{ // There is an exception for the "relative/" prefix in the test registry server - location: "/relative-path", - version: "0.2.0", - }}, - "test-versions/name/provider": { - {version: "2.2.0"}, - {version: "2.1.1"}, - {version: "1.2.2"}, - {version: "1.2.1"}, - }, - "private/name/provider": { - {version: "1.0.0"}, - }, -} - -func latestVersion(versions []string) string { - var col version.Collection - for _, v := range versions { - ver, err := version.NewVersion(v) - if err != nil { - panic(err) - } - col = append(col, ver) - } - - sort.Sort(col) - return col[len(col)-1].String() -} - -func mockRegHandler() http.Handler { - mux := http.NewServeMux() - - download := func(w http.ResponseWriter, r *http.Request) { - p := strings.TrimLeft(r.URL.Path, "/") - // handle download request - re := regexp.MustCompile(`^([-a-z]+/\w+/\w+).*/download$`) - // download lookup - matches := re.FindStringSubmatch(p) - if len(matches) != 2 { - w.WriteHeader(http.StatusBadRequest) - return - } - - // check for auth - if strings.Contains(matches[0], "private/") { - if !strings.Contains(r.Header.Get("Authorization"), testCredentials) { - http.Error(w, "", http.StatusForbidden) - } - } - - versions, ok := testMods[matches[1]] - if !ok { - http.NotFound(w, r) - return - } - mod := versions[0] - - location := mod.location - if !strings.HasPrefix(matches[0], "relative/") && !strings.HasPrefix(location, "file:///") { - // we can't use filepath.Abs because it will clean `//` - wd, _ := os.Getwd() - location = fmt.Sprintf("file://%s/%s", wd, location) - } - - w.Header().Set("X-Terraform-Get", location) - w.WriteHeader(http.StatusNoContent) - // no body - return - } - - versions := func(w http.ResponseWriter, r *http.Request) { - p := strings.TrimLeft(r.URL.Path, "/") - re := regexp.MustCompile(`^([-a-z]+/\w+/\w+)/versions$`) - matches := re.FindStringSubmatch(p) - if len(matches) != 2 { - w.WriteHeader(http.StatusBadRequest) - return - } - - // check for auth - if strings.Contains(matches[1], "private/") { - if !strings.Contains(r.Header.Get("Authorization"), testCredentials) { - http.Error(w, "", http.StatusForbidden) - } - } - - name := matches[1] - versions, ok := testMods[name] - if !ok { - http.NotFound(w, r) - return - } - - // only adding the single requested module for now - // this is the minimal that any regisry is epected to support - mpvs := &response.ModuleProviderVersions{ - Source: name, - } - - for _, v := range versions { - mv := &response.ModuleVersion{ - Version: v.version, - } - mpvs.Versions = append(mpvs.Versions, mv) - } - - resp := response.ModuleVersions{ - Modules: []*response.ModuleProviderVersions{mpvs}, - } - - js, err := json.Marshal(resp) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - w.Header().Set("Content-Type", "application/json") - w.Write(js) - } - - mux.Handle("/v1/modules/", - http.StripPrefix("/v1/modules/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if strings.HasSuffix(r.URL.Path, "/download") { - download(w, r) - return - } - - if strings.HasSuffix(r.URL.Path, "/versions") { - versions(w, r) - return - } - - http.NotFound(w, r) - })), - ) - - mux.HandleFunc("/.well-known/terraform.json", func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - io.WriteString(w, `{"modules.v1":"http://localhost/v1/modules/"}`) - }) - return mux -} - -// Just enough like a registry to exercise our code. -// Returns the location of the latest version -func mockRegistry() *httptest.Server { - server := httptest.NewServer(mockRegHandler()) - return server -} - -// GitHub archives always contain the module source in a single subdirectory, -// so the registry will return a path with with a `//*` suffix. We need to make -// sure this doesn't intefere with our internal handling of `//` subdir. -func TestRegistryGitHubArchive(t *testing.T) { - server := mockRegistry() - defer server.Close() - - disco := testDisco(server) - storage := testStorage(t, disco) - - tree := NewTree("", testConfig(t, "registry-tar-subdir")) - - storage.Mode = GetModeGet - if err := tree.Load(storage); err != nil { - t.Fatalf("err: %s", err) - } - - if !tree.Loaded() { - t.Fatal("should be loaded") - } - - storage.Mode = GetModeNone - if err := tree.Load(storage); err != nil { - t.Fatalf("err: %s", err) - } - - // stop the registry server, and make sure that we don't need to call out again - server.Close() - tree = NewTree("", testConfig(t, "registry-tar-subdir")) - - storage.Mode = GetModeGet - if err := tree.Load(storage); err != nil { - t.Fatalf("err: %s", err) - } - - if !tree.Loaded() { - t.Fatal("should be loaded") - } - - actual := strings.TrimSpace(tree.String()) - expected := strings.TrimSpace(treeLoadSubdirStr) - if actual != expected { - t.Fatalf("got: \n\n%s\nexpected: \n\n%s", actual, expected) - } -} - -// Test that the //subdir notation can be used with registry modules -func TestRegisryModuleSubdir(t *testing.T) { - server := mockRegistry() - defer server.Close() - - disco := testDisco(server) - storage := testStorage(t, disco) - tree := NewTree("", testConfig(t, "registry-subdir")) - - storage.Mode = GetModeGet - if err := tree.Load(storage); err != nil { - t.Fatalf("err: %s", err) - } - - if !tree.Loaded() { - t.Fatal("should be loaded") - } - - storage.Mode = GetModeNone - if err := tree.Load(storage); err != nil { - t.Fatalf("err: %s", err) - } - - actual := strings.TrimSpace(tree.String()) - expected := strings.TrimSpace(treeLoadRegistrySubdirStr) - if actual != expected { - t.Fatalf("got: \n\n%s\nexpected: \n\n%s", actual, expected) - } -} - -func TestAccRegistryDiscover(t *testing.T) { - if os.Getenv("TF_ACC") == "" { - t.Skip("skipping ACC test") - } - - // simply check that we get a valid github URL for this from the registry - module, err := regsrc.ParseModuleSource("hashicorp/consul/aws") - if err != nil { - t.Fatal(err) - } - - s := NewStorage("/tmp", nil, nil) - loc, err := s.lookupModuleLocation(module, "") - if err != nil { - t.Fatal(err) - } - - u, err := url.Parse(loc) - if err != nil { - t.Fatal(err) - } - - if !strings.HasSuffix(u.Host, "github.com") { - t.Fatalf("expected host 'github.com', got: %q", u.Host) - } - - if !strings.Contains(u.String(), "consul") { - t.Fatalf("url doesn't contain 'consul': %s", u.String()) - } -} - -func TestAccRegistryLoad(t *testing.T) { - if os.Getenv("TF_ACC") == "" { - t.Skip("skipping ACC test") - } - - storage := testStorage(t, nil) - tree := NewTree("", testConfig(t, "registry-load")) - - storage.Mode = GetModeGet - if err := tree.Load(storage); err != nil { - t.Fatalf("err: %s", err) - } - - if !tree.Loaded() { - t.Fatal("should be loaded") - } - - storage.Mode = GetModeNone - if err := tree.Load(storage); err != nil { - t.Fatalf("err: %s", err) - } - - // TODO expand this further by fetching some metadata from the registry - actual := strings.TrimSpace(tree.String()) - if !strings.Contains(actual, "(path: vault)") { - t.Fatal("missing vault module, got:\n", actual) - } -} diff --git a/vendor/github.com/hashicorp/terraform/config/module/inode.go b/vendor/github.com/hashicorp/terraform/config/module/inode.go index 8603ee26..da520abc 100644 --- a/vendor/github.com/hashicorp/terraform/config/module/inode.go +++ b/vendor/github.com/hashicorp/terraform/config/module/inode.go @@ -1,4 +1,4 @@ -// +build linux darwin openbsd netbsd solaris +// +build linux darwin openbsd netbsd solaris dragonfly package module diff --git a/vendor/github.com/hashicorp/terraform/config/module/module_test.go b/vendor/github.com/hashicorp/terraform/config/module/module_test.go index 9685f7fe..62e7ed2a 100644 --- a/vendor/github.com/hashicorp/terraform/config/module/module_test.go +++ b/vendor/github.com/hashicorp/terraform/config/module/module_test.go @@ -1,16 +1,13 @@ package module import ( - "fmt" "io/ioutil" "log" - "net/http/httptest" "os" "path/filepath" "testing" "github.com/hashicorp/terraform/config" - "github.com/hashicorp/terraform/svchost" "github.com/hashicorp/terraform/svchost/disco" ) @@ -49,18 +46,3 @@ func testStorage(t *testing.T, d *disco.Disco) *Storage { t.Helper() return NewStorage(tempDir(t), d, nil) } - -// test discovery maps registry.terraform.io, localhost, localhost.localdomain, -// and example.com to the test server. -func testDisco(s *httptest.Server) *disco.Disco { - services := map[string]interface{}{ - "modules.v1": fmt.Sprintf("%s/v1/modules/", s.URL), - } - d := disco.NewDisco() - - d.ForceHostServices(svchost.Hostname("registry.terraform.io"), services) - d.ForceHostServices(svchost.Hostname("localhost"), services) - d.ForceHostServices(svchost.Hostname("localhost.localdomain"), services) - d.ForceHostServices(svchost.Hostname("example.com"), services) - return d -} diff --git a/vendor/github.com/hashicorp/terraform/config/module/storage.go b/vendor/github.com/hashicorp/terraform/config/module/storage.go index 12171976..c1588d68 100644 --- a/vendor/github.com/hashicorp/terraform/config/module/storage.go +++ b/vendor/github.com/hashicorp/terraform/config/module/storage.go @@ -9,6 +9,7 @@ import ( "path/filepath" getter "github.com/hashicorp/go-getter" + "github.com/hashicorp/terraform/registry" "github.com/hashicorp/terraform/registry/regsrc" "github.com/hashicorp/terraform/svchost/auth" "github.com/hashicorp/terraform/svchost/disco" @@ -73,20 +74,17 @@ type Storage struct { Ui cli.Ui // Mode is the GetMode that will be used for various operations. Mode GetMode + + registry *registry.Client } func NewStorage(dir string, services *disco.Disco, creds auth.CredentialsSource) *Storage { - s := &Storage{ - StorageDir: dir, - Services: services, - Creds: creds, - } + regClient := registry.NewClient(services, creds, nil) - // make sure this isn't nil - if s.Services == nil { - s.Services = disco.NewDisco() + return &Storage{ + StorageDir: dir, + registry: regClient, } - return s } // loadManifest returns the moduleManifest file from the parent directory. @@ -297,17 +295,17 @@ func (s Storage) findRegistryModule(mSource, constraint string) (moduleRecord, e } rec.registry = true - log.Printf("[TRACE] %q is a registry module", mod.Module()) + log.Printf("[TRACE] %q is a registry module", mod.Display()) versions, err := s.moduleVersions(mod.String()) if err != nil { - log.Printf("[ERROR] error looking up versions for %q: %s", mod.Module(), err) + log.Printf("[ERROR] error looking up versions for %q: %s", mod.Display(), err) return rec, err } match, err := newestRecord(versions, constraint) if err != nil { - log.Printf("[INFO] no matching version for %q<%s>, %s", mod.Module(), constraint, err) + log.Printf("[INFO] no matching version for %q<%s>, %s", mod.Display(), constraint, err) } log.Printf("[DEBUG] matched %q version %s for %s", mod, match.Version, constraint) @@ -318,13 +316,13 @@ func (s Storage) findRegistryModule(mSource, constraint string) (moduleRecord, e // we need to lookup available versions // Only on Get if it's not found, on unconditionally on Update if (s.Mode == GetModeGet && !found) || (s.Mode == GetModeUpdate) { - resp, err := s.lookupModuleVersions(mod) + resp, err := s.registry.Versions(mod) if err != nil { return rec, err } if len(resp.Modules) == 0 { - return rec, fmt.Errorf("module %q not found in registry", mod.Module()) + return rec, fmt.Errorf("module %q not found in registry", mod.Display()) } match, err := newestVersion(resp.Modules[0].Versions, constraint) @@ -333,12 +331,12 @@ func (s Storage) findRegistryModule(mSource, constraint string) (moduleRecord, e } if match == nil { - return rec, fmt.Errorf("no versions for %q found matching %q", mod.Module(), constraint) + return rec, fmt.Errorf("no versions for %q found matching %q", mod.Display(), constraint) } rec.Version = match.Version - rec.url, err = s.lookupModuleLocation(mod, rec.Version) + rec.url, err = s.registry.Location(mod, rec.Version) if err != nil { return rec, err } diff --git a/vendor/github.com/hashicorp/terraform/config/module/storage_test.go b/vendor/github.com/hashicorp/terraform/config/module/storage_test.go index 6fa1212f..10811190 100644 --- a/vendor/github.com/hashicorp/terraform/config/module/storage_test.go +++ b/vendor/github.com/hashicorp/terraform/config/module/storage_test.go @@ -2,15 +2,20 @@ package module import ( "io/ioutil" + "net/url" "os" "path/filepath" + "strings" "testing" + + "github.com/hashicorp/terraform/registry/regsrc" + "github.com/hashicorp/terraform/registry/test" ) func TestGetModule(t *testing.T) { - server := mockRegistry() + server := test.Registry() defer server.Close() - disco := testDisco(server) + disco := test.Disco(server) td, err := ioutil.TempDir("", "tf") if err != nil { @@ -19,7 +24,7 @@ func TestGetModule(t *testing.T) { defer os.RemoveAll(td) storage := NewStorage(td, disco, nil) - // this module exists in a test fixture, and is known by the mockRegistry + // this module exists in a test fixture, and is known by the test.Registry // relative to our cwd. err = storage.GetModule(filepath.Join(td, "foo"), "registry/local/sub") if err != nil { @@ -45,5 +50,140 @@ func TestGetModule(t *testing.T) { if err != nil { t.Fatal(err) } +} + +// GitHub archives always contain the module source in a single subdirectory, +// so the registry will return a path with with a `//*` suffix. We need to make +// sure this doesn't intefere with our internal handling of `//` subdir. +func TestRegistryGitHubArchive(t *testing.T) { + server := test.Registry() + defer server.Close() + + disco := test.Disco(server) + storage := testStorage(t, disco) + + tree := NewTree("", testConfig(t, "registry-tar-subdir")) + + storage.Mode = GetModeGet + if err := tree.Load(storage); err != nil { + t.Fatalf("err: %s", err) + } + if !tree.Loaded() { + t.Fatal("should be loaded") + } + + storage.Mode = GetModeNone + if err := tree.Load(storage); err != nil { + t.Fatalf("err: %s", err) + } + + // stop the registry server, and make sure that we don't need to call out again + server.Close() + tree = NewTree("", testConfig(t, "registry-tar-subdir")) + + storage.Mode = GetModeGet + if err := tree.Load(storage); err != nil { + t.Fatalf("err: %s", err) + } + + if !tree.Loaded() { + t.Fatal("should be loaded") + } + + actual := strings.TrimSpace(tree.String()) + expected := strings.TrimSpace(treeLoadSubdirStr) + if actual != expected { + t.Fatalf("got: \n\n%s\nexpected: \n\n%s", actual, expected) + } +} + +// Test that the //subdir notation can be used with registry modules +func TestRegisryModuleSubdir(t *testing.T) { + server := test.Registry() + defer server.Close() + + disco := test.Disco(server) + storage := testStorage(t, disco) + tree := NewTree("", testConfig(t, "registry-subdir")) + + storage.Mode = GetModeGet + if err := tree.Load(storage); err != nil { + t.Fatalf("err: %s", err) + } + + if !tree.Loaded() { + t.Fatal("should be loaded") + } + + storage.Mode = GetModeNone + if err := tree.Load(storage); err != nil { + t.Fatalf("err: %s", err) + } + + actual := strings.TrimSpace(tree.String()) + expected := strings.TrimSpace(treeLoadRegistrySubdirStr) + if actual != expected { + t.Fatalf("got: \n\n%s\nexpected: \n\n%s", actual, expected) + } +} + +func TestAccRegistryDiscover(t *testing.T) { + if os.Getenv("TF_ACC") == "" { + t.Skip("skipping ACC test") + } + + // simply check that we get a valid github URL for this from the registry + module, err := regsrc.ParseModuleSource("hashicorp/consul/aws") + if err != nil { + t.Fatal(err) + } + + s := NewStorage("/tmp", nil, nil) + loc, err := s.registry.Location(module, "") + if err != nil { + t.Fatal(err) + } + + u, err := url.Parse(loc) + if err != nil { + t.Fatal(err) + } + + if !strings.HasSuffix(u.Host, "github.com") { + t.Fatalf("expected host 'github.com', got: %q", u.Host) + } + + if !strings.Contains(u.String(), "consul") { + t.Fatalf("url doesn't contain 'consul': %s", u.String()) + } +} + +func TestAccRegistryLoad(t *testing.T) { + if os.Getenv("TF_ACC") == "" { + t.Skip("skipping ACC test") + } + + storage := testStorage(t, nil) + tree := NewTree("", testConfig(t, "registry-load")) + + storage.Mode = GetModeGet + if err := tree.Load(storage); err != nil { + t.Fatalf("err: %s", err) + } + + if !tree.Loaded() { + t.Fatal("should be loaded") + } + + storage.Mode = GetModeNone + if err := tree.Load(storage); err != nil { + t.Fatalf("err: %s", err) + } + + // TODO expand this further by fetching some metadata from the registry + actual := strings.TrimSpace(tree.String()) + if !strings.Contains(actual, "(path: vault)") { + t.Fatal("missing vault module, got:\n", actual) + } } diff --git a/vendor/github.com/hashicorp/terraform/config/resource_mode_string.go b/vendor/github.com/hashicorp/terraform/config/resource_mode_string.go index ea68b4fc..8a55e060 100644 --- a/vendor/github.com/hashicorp/terraform/config/resource_mode_string.go +++ b/vendor/github.com/hashicorp/terraform/config/resource_mode_string.go @@ -2,7 +2,7 @@ package config -import "fmt" +import "strconv" const _ResourceMode_name = "ManagedResourceModeDataResourceMode" @@ -10,7 +10,7 @@ var _ResourceMode_index = [...]uint8{0, 19, 35} func (i ResourceMode) String() string { if i < 0 || i >= ResourceMode(len(_ResourceMode_index)-1) { - return fmt.Sprintf("ResourceMode(%d)", i) + return "ResourceMode(" + strconv.FormatInt(int64(i), 10) + ")" } return _ResourceMode_name[_ResourceMode_index[i]:_ResourceMode_index[i+1]] } diff --git a/vendor/github.com/hashicorp/terraform/config_unix.go b/vendor/github.com/hashicorp/terraform/config_unix.go index d28d7492..85c313a0 100644 --- a/vendor/github.com/hashicorp/terraform/config_unix.go +++ b/vendor/github.com/hashicorp/terraform/config_unix.go @@ -32,7 +32,6 @@ func configDir() (string, error) { func homeDir() (string, error) { // First prefer the HOME environmental variable if home := os.Getenv("HOME"); home != "" { - // FIXME: homeDir gets called from globalPluginDirs during init, before // the logging is setup. We should move meta initializtion outside of // init, but in the meantime we just need to silence this output. diff --git a/vendor/github.com/hashicorp/terraform/helper/schema/getsource_string.go b/vendor/github.com/hashicorp/terraform/helper/schema/getsource_string.go index 3a976293..38cd8c70 100644 --- a/vendor/github.com/hashicorp/terraform/helper/schema/getsource_string.go +++ b/vendor/github.com/hashicorp/terraform/helper/schema/getsource_string.go @@ -2,7 +2,7 @@ package schema -import "fmt" +import "strconv" const ( _getSource_name_0 = "getSourceStategetSourceConfig" @@ -13,8 +13,6 @@ const ( var ( _getSource_index_0 = [...]uint8{0, 14, 29} - _getSource_index_1 = [...]uint8{0, 13} - _getSource_index_2 = [...]uint8{0, 12} _getSource_index_3 = [...]uint8{0, 18, 32} ) @@ -31,6 +29,6 @@ func (i getSource) String() string { i -= 15 return _getSource_name_3[_getSource_index_3[i]:_getSource_index_3[i+1]] default: - return fmt.Sprintf("getSource(%d)", i) + return "getSource(" + strconv.FormatInt(int64(i), 10) + ")" } } diff --git a/vendor/github.com/hashicorp/terraform/helper/schema/resource.go b/vendor/github.com/hashicorp/terraform/helper/schema/resource.go index 8290ba50..c8e99b94 100644 --- a/vendor/github.com/hashicorp/terraform/helper/schema/resource.go +++ b/vendor/github.com/hashicorp/terraform/helper/schema/resource.go @@ -282,7 +282,6 @@ func (r *Resource) ReadDataApply( d *terraform.InstanceDiff, meta interface{}, ) (*terraform.InstanceState, error) { - // Data sources are always built completely from scratch // on each read, so the source state is always nil. data, err := schemaMap(r.Schema).Data(nil, d) diff --git a/vendor/github.com/hashicorp/terraform/helper/schema/resource_data.go b/vendor/github.com/hashicorp/terraform/helper/schema/resource_data.go index 970dc7b9..9ab8bcca 100644 --- a/vendor/github.com/hashicorp/terraform/helper/schema/resource_data.go +++ b/vendor/github.com/hashicorp/terraform/helper/schema/resource_data.go @@ -445,7 +445,7 @@ func (d *ResourceData) init() { } func (d *ResourceData) diffChange( - k string) (interface{}, interface{}, bool, bool) { + k string) (interface{}, interface{}, bool, bool, bool) { // Get the change between the state and the config. o, n := d.getChange(k, getSourceState, getSourceConfig|getSourceExact) if !o.Exists { @@ -456,7 +456,7 @@ func (d *ResourceData) diffChange( } // Return the old, new, and whether there is a change - return o.Value, n.Value, !reflect.DeepEqual(o.Value, n.Value), n.Computed + return o.Value, n.Value, !reflect.DeepEqual(o.Value, n.Value), n.Computed, false } func (d *ResourceData) getChange( diff --git a/vendor/github.com/hashicorp/terraform/helper/schema/resource_diff.go b/vendor/github.com/hashicorp/terraform/helper/schema/resource_diff.go index 4fc1dbb6..822d0dc4 100644 --- a/vendor/github.com/hashicorp/terraform/helper/schema/resource_diff.go +++ b/vendor/github.com/hashicorp/terraform/helper/schema/resource_diff.go @@ -236,8 +236,8 @@ func (d *ResourceDiff) clear(key string) error { // diffChange helps to implement resourceDiffer and derives its change values // from ResourceDiff's own change data, in addition to existing diff, config, and state. -func (d *ResourceDiff) diffChange(key string) (interface{}, interface{}, bool, bool) { - old, new := d.getChange(key) +func (d *ResourceDiff) diffChange(key string) (interface{}, interface{}, bool, bool, bool) { + old, new, customized := d.getChange(key) if !old.Exists { old.Value = nil @@ -246,7 +246,7 @@ func (d *ResourceDiff) diffChange(key string) (interface{}, interface{}, bool, b new.Value = nil } - return old.Value, new.Value, !reflect.DeepEqual(old.Value, new.Value), new.Computed + return old.Value, new.Value, !reflect.DeepEqual(old.Value, new.Value), new.Computed, customized } // SetNew is used to set a new diff value for the mentioned key. The value must @@ -327,7 +327,7 @@ func (d *ResourceDiff) Get(key string) interface{} { // results from the exact levels for the new diff, then from state and diff as // per normal. func (d *ResourceDiff) GetChange(key string) (interface{}, interface{}) { - old, new := d.getChange(key) + old, new, _ := d.getChange(key) return old.Value, new.Value } @@ -387,18 +387,17 @@ func (d *ResourceDiff) Id() string { // This implementation differs from ResourceData's in the way that we first get // results from the exact levels for the new diff, then from state and diff as // per normal. -func (d *ResourceDiff) getChange(key string) (getResult, getResult) { +func (d *ResourceDiff) getChange(key string) (getResult, getResult, bool) { old := d.get(strings.Split(key, "."), "state") var new getResult for p := range d.updatedKeys { if childAddrOf(key, p) { new = d.getExact(strings.Split(key, "."), "newDiff") - goto done + return old, new, true } } new = d.get(strings.Split(key, "."), "newDiff") -done: - return old, new + return old, new, false } // get performs the appropriate multi-level reader logic for ResourceDiff, diff --git a/vendor/github.com/hashicorp/terraform/helper/schema/schema.go b/vendor/github.com/hashicorp/terraform/helper/schema/schema.go index 6cc71df5..6773fe58 100644 --- a/vendor/github.com/hashicorp/terraform/helper/schema/schema.go +++ b/vendor/github.com/hashicorp/terraform/helper/schema/schema.go @@ -296,8 +296,7 @@ func (s *Schema) ZeroValue() interface{} { } } -func (s *Schema) finalizeDiff( - d *terraform.ResourceAttrDiff) *terraform.ResourceAttrDiff { +func (s *Schema) finalizeDiff(d *terraform.ResourceAttrDiff, customized bool) *terraform.ResourceAttrDiff { if d == nil { return d } @@ -337,14 +336,21 @@ func (s *Schema) finalizeDiff( return d } - if s.Computed && !d.NewComputed { - if d.Old != "" && d.New == "" { - // This is a computed value with an old value set already, - // just let it go. - return nil + if s.Computed { + // FIXME: This is where the customized bool from getChange finally + // comes into play. It allows the previously incorrect behavior + // of an empty string being used as "unset" when the value is + // computed. This should be removed once we can properly + // represent an unset/nil value from the configuration. + if !customized { + if d.Old != "" && d.New == "" { + // This is a computed value with an old value set already, + // just let it go. + return nil + } } - if d.New == "" { + if d.New == "" && !d.NewComputed { // Computed attribute without a new value set d.NewComputed = true } @@ -744,7 +750,7 @@ func isValidFieldName(name string) bool { // This helps facilitate diff logic for both ResourceData and ResoureDiff with // minimal divergence in code. type resourceDiffer interface { - diffChange(string) (interface{}, interface{}, bool, bool) + diffChange(string) (interface{}, interface{}, bool, bool, bool) Get(string) interface{} GetChange(string) (interface{}, interface{}) GetOk(string) (interface{}, bool) @@ -797,7 +803,7 @@ func (m schemaMap) diffList( diff *terraform.InstanceDiff, d resourceDiffer, all bool) error { - o, n, _, computedList := d.diffChange(k) + o, n, _, computedList, customized := d.diffChange(k) if computedList { n = nil } @@ -864,10 +870,13 @@ func (m schemaMap) diffList( oldStr = "" } - diff.Attributes[k+".#"] = countSchema.finalizeDiff(&terraform.ResourceAttrDiff{ - Old: oldStr, - New: newStr, - }) + diff.Attributes[k+".#"] = countSchema.finalizeDiff( + &terraform.ResourceAttrDiff{ + Old: oldStr, + New: newStr, + }, + customized, + ) } // Figure out the maximum @@ -920,7 +929,7 @@ func (m schemaMap) diffMap( // First get all the values from the state var stateMap, configMap map[string]string - o, n, _, nComputed := d.diffChange(k) + o, n, _, nComputed, customized := d.diffChange(k) if err := mapstructure.WeakDecode(o, &stateMap); err != nil { return fmt.Errorf("%s: %s", k, err) } @@ -972,6 +981,7 @@ func (m schemaMap) diffMap( Old: oldStr, New: newStr, }, + customized, ) } @@ -989,16 +999,22 @@ func (m schemaMap) diffMap( continue } - diff.Attributes[prefix+k] = schema.finalizeDiff(&terraform.ResourceAttrDiff{ - Old: old, - New: v, - }) + diff.Attributes[prefix+k] = schema.finalizeDiff( + &terraform.ResourceAttrDiff{ + Old: old, + New: v, + }, + customized, + ) } for k, v := range stateMap { - diff.Attributes[prefix+k] = schema.finalizeDiff(&terraform.ResourceAttrDiff{ - Old: v, - NewRemoved: true, - }) + diff.Attributes[prefix+k] = schema.finalizeDiff( + &terraform.ResourceAttrDiff{ + Old: v, + NewRemoved: true, + }, + customized, + ) } return nil @@ -1011,7 +1027,7 @@ func (m schemaMap) diffSet( d resourceDiffer, all bool) error { - o, n, _, computedSet := d.diffChange(k) + o, n, _, computedSet, customized := d.diffChange(k) if computedSet { n = nil } @@ -1070,20 +1086,26 @@ func (m schemaMap) diffSet( countStr = "" } - diff.Attributes[k+".#"] = countSchema.finalizeDiff(&terraform.ResourceAttrDiff{ - Old: countStr, - NewComputed: true, - }) + diff.Attributes[k+".#"] = countSchema.finalizeDiff( + &terraform.ResourceAttrDiff{ + Old: countStr, + NewComputed: true, + }, + customized, + ) return nil } // If the counts are not the same, then record that diff changed := oldLen != newLen if changed || all { - diff.Attributes[k+".#"] = countSchema.finalizeDiff(&terraform.ResourceAttrDiff{ - Old: oldStr, - New: newStr, - }) + diff.Attributes[k+".#"] = countSchema.finalizeDiff( + &terraform.ResourceAttrDiff{ + Old: oldStr, + New: newStr, + }, + customized, + ) } // Build the list of codes that will make up our set. This is the @@ -1133,7 +1155,7 @@ func (m schemaMap) diffString( all bool) error { var originalN interface{} var os, ns string - o, n, _, computed := d.diffChange(k) + o, n, _, computed, customized := d.diffChange(k) if schema.StateFunc != nil && n != nil { originalN = n n = schema.StateFunc(n) @@ -1170,13 +1192,16 @@ func (m schemaMap) diffString( return nil } - diff.Attributes[k] = schema.finalizeDiff(&terraform.ResourceAttrDiff{ - Old: os, - New: ns, - NewExtra: originalN, - NewRemoved: removed, - NewComputed: computed, - }) + diff.Attributes[k] = schema.finalizeDiff( + &terraform.ResourceAttrDiff{ + Old: os, + New: ns, + NewExtra: originalN, + NewRemoved: removed, + NewComputed: computed, + }, + customized, + ) return nil } @@ -1503,7 +1528,6 @@ func (m schemaMap) validatePrimitive( raw interface{}, schema *Schema, c *terraform.ResourceConfig) ([]string, []error) { - // Catch if the user gave a complex type where a primitive was // expected, so we can return a friendly error message that // doesn't contain Go type system terminology. diff --git a/vendor/github.com/hashicorp/terraform/helper/schema/schema_test.go b/vendor/github.com/hashicorp/terraform/helper/schema/schema_test.go index 3698fe0f..bda54cce 100644 --- a/vendor/github.com/hashicorp/terraform/helper/schema/schema_test.go +++ b/vendor/github.com/hashicorp/terraform/helper/schema/schema_test.go @@ -3110,6 +3110,38 @@ func TestSchemaMap_Diff(t *testing.T) { Err: true, }, + + // A lot of resources currently depended on using the empty string as a + // nil/unset value. + // FIXME: We want this to eventually produce a diff, since there + // technically is a new value in the config. + { + Name: "optional, computed, empty string", + Schema: map[string]*Schema{ + "attr": &Schema{ + Type: TypeString, + Optional: true, + Computed: true, + }, + }, + + State: &terraform.InstanceState{ + Attributes: map[string]string{ + "attr": "bar", + }, + }, + + // this does necessarily depend on an interpolated value, but this + // is often how it comes about in a configuration, otherwise the + // value would be unset. + Config: map[string]interface{}{ + "attr": "${var.foo}", + }, + + ConfigVariables: map[string]ast.Variable{ + "var.foo": interfaceToVariableSwallowError(""), + }, + }, } for i, tc := range cases { diff --git a/vendor/github.com/hashicorp/terraform/helper/schema/valuetype_string.go b/vendor/github.com/hashicorp/terraform/helper/schema/valuetype_string.go index 1610cec2..3bc3ac45 100644 --- a/vendor/github.com/hashicorp/terraform/helper/schema/valuetype_string.go +++ b/vendor/github.com/hashicorp/terraform/helper/schema/valuetype_string.go @@ -2,7 +2,7 @@ package schema -import "fmt" +import "strconv" const _ValueType_name = "TypeInvalidTypeBoolTypeIntTypeFloatTypeStringTypeListTypeMapTypeSettypeObject" @@ -10,7 +10,7 @@ var _ValueType_index = [...]uint8{0, 11, 19, 26, 35, 45, 53, 60, 67, 77} func (i ValueType) String() string { if i < 0 || i >= ValueType(len(_ValueType_index)-1) { - return fmt.Sprintf("ValueType(%d)", i) + return "ValueType(" + strconv.FormatInt(int64(i), 10) + ")" } return _ValueType_name[_ValueType_index[i]:_ValueType_index[i+1]] } diff --git a/vendor/github.com/hashicorp/terraform/config/module/registry.go b/vendor/github.com/hashicorp/terraform/registry/client.go similarity index 67% rename from vendor/github.com/hashicorp/terraform/config/module/registry.go rename to vendor/github.com/hashicorp/terraform/registry/client.go index da67c5ab..b4cd7989 100644 --- a/vendor/github.com/hashicorp/terraform/config/module/registry.go +++ b/vendor/github.com/hashicorp/terraform/registry/client.go @@ -1,4 +1,4 @@ -package module +package registry import ( "encoding/json" @@ -12,75 +12,75 @@ import ( "time" cleanhttp "github.com/hashicorp/go-cleanhttp" - "github.com/hashicorp/terraform/registry/regsrc" "github.com/hashicorp/terraform/registry/response" "github.com/hashicorp/terraform/svchost" + "github.com/hashicorp/terraform/svchost/auth" + "github.com/hashicorp/terraform/svchost/disco" "github.com/hashicorp/terraform/version" ) const ( - defaultRegistry = "registry.terraform.io" - registryServiceID = "registry.v1" xTerraformGet = "X-Terraform-Get" xTerraformVersion = "X-Terraform-Version" requestTimeout = 10 * time.Second serviceID = "modules.v1" ) -var ( - httpClient *http.Client - tfVersion = version.String() -) +var tfVersion = version.String() -func init() { - httpClient = cleanhttp.DefaultPooledClient() - httpClient.Timeout = requestTimeout -} +// Client provides methods to query Terraform Registries. +type Client struct { + // this is the client to be used for all requests. + client *http.Client -type errModuleNotFound string + // services is a required *disco.Disco, which may have services and + // credentials pre-loaded. + services *disco.Disco -func (e errModuleNotFound) Error() string { - return `module "` + string(e) + `" not found` + // Creds optionally provides credentials for communicating with service + // providers. + creds auth.CredentialsSource } -func (s *Storage) discoverRegURL(host svchost.Hostname) *url.URL { - regURL := s.Services.DiscoverServiceURL(host, serviceID) - if regURL == nil { - return nil +func NewClient(services *disco.Disco, creds auth.CredentialsSource, client *http.Client) *Client { + if services == nil { + services = disco.NewDisco() } - if !strings.HasSuffix(regURL.Path, "/") { - regURL.Path += "/" - } + services.SetCredentialsSource(creds) - return regURL -} - -func (s *Storage) addRequestCreds(host svchost.Hostname, req *http.Request) { - if s.Creds == nil { - return + if client == nil { + client = cleanhttp.DefaultPooledClient() + client.Timeout = requestTimeout } - creds, err := s.Creds.ForHost(host) - if err != nil { - log.Printf("[WARNING] Failed to get credentials for %s: %s (ignoring)", host, err) - return + services.Transport = client.Transport.(*http.Transport) + + return &Client{ + client: client, + services: services, + creds: creds, } +} - if creds != nil { - creds.PrepareRequest(req) +// Discover qeuries the host, and returns the url for the registry. +func (c *Client) Discover(host svchost.Hostname) *url.URL { + service := c.services.DiscoverServiceURL(host, serviceID) + if !strings.HasSuffix(service.Path, "/") { + service.Path += "/" } + return service } -// Lookup module versions in the registry. -func (s *Storage) lookupModuleVersions(module *regsrc.Module) (*response.ModuleVersions, error) { +// Versions queries the registry for a module, and returns the available versions. +func (c *Client) Versions(module *regsrc.Module) (*response.ModuleVersions, error) { host, err := module.SvcHost() if err != nil { return nil, err } - service := s.discoverRegURL(host) + service := c.Discover(host) if service == nil { return nil, fmt.Errorf("host %s does not provide Terraform modules", host) } @@ -99,10 +99,10 @@ func (s *Storage) lookupModuleVersions(module *regsrc.Module) (*response.ModuleV return nil, err } - s.addRequestCreds(host, req) + c.addRequestCreds(host, req) req.Header.Set(xTerraformVersion, tfVersion) - resp, err := httpClient.Do(req) + resp, err := c.client.Do(req) if err != nil { return nil, err } @@ -112,7 +112,7 @@ func (s *Storage) lookupModuleVersions(module *regsrc.Module) (*response.ModuleV case http.StatusOK: // OK case http.StatusNotFound: - return nil, errModuleNotFound(module.String()) + return nil, fmt.Errorf("module %q not found", module.String()) default: return nil, fmt.Errorf("error looking up module versions: %s", resp.Status) } @@ -133,14 +133,31 @@ func (s *Storage) lookupModuleVersions(module *regsrc.Module) (*response.ModuleV return &versions, nil } -// lookup the location of a specific module version in the registry -func (s *Storage) lookupModuleLocation(module *regsrc.Module, version string) (string, error) { +func (c *Client) addRequestCreds(host svchost.Hostname, req *http.Request) { + if c.creds == nil { + return + } + + creds, err := c.creds.ForHost(host) + if err != nil { + log.Printf("[WARNING] Failed to get credentials for %s: %s (ignoring)", host, err) + return + } + + if creds != nil { + creds.PrepareRequest(req) + } +} + +// Location find the download location for a specific version module. +// This returns a string, because the final location may contain special go-getter syntax. +func (c *Client) Location(module *regsrc.Module, version string) (string, error) { host, err := module.SvcHost() if err != nil { return "", err } - service := s.discoverRegURL(host) + service := c.Discover(host) if service == nil { return "", fmt.Errorf("host %s does not provide Terraform modules", host.ForDisplay()) } @@ -163,10 +180,10 @@ func (s *Storage) lookupModuleLocation(module *regsrc.Module, version string) (s return "", err } - s.addRequestCreds(host, req) + c.addRequestCreds(host, req) req.Header.Set(xTerraformVersion, tfVersion) - resp, err := httpClient.Do(req) + resp, err := c.client.Do(req) if err != nil { return "", err } diff --git a/vendor/github.com/hashicorp/terraform/config/module/registry_test.go b/vendor/github.com/hashicorp/terraform/registry/client_test.go similarity index 73% rename from vendor/github.com/hashicorp/terraform/config/module/registry_test.go rename to vendor/github.com/hashicorp/terraform/registry/client_test.go index dab7444c..a4ef640e 100644 --- a/vendor/github.com/hashicorp/terraform/config/module/registry_test.go +++ b/vendor/github.com/hashicorp/terraform/registry/client_test.go @@ -1,4 +1,4 @@ -package module +package registry import ( "os" @@ -7,16 +7,15 @@ import ( version "github.com/hashicorp/go-version" "github.com/hashicorp/terraform/registry/regsrc" - "github.com/hashicorp/terraform/svchost" - "github.com/hashicorp/terraform/svchost/auth" + "github.com/hashicorp/terraform/registry/test" "github.com/hashicorp/terraform/svchost/disco" ) func TestLookupModuleVersions(t *testing.T) { - server := mockRegistry() + server := test.Registry() defer server.Close() - regDisco := testDisco(server) + client := NewClient(test.Disco(server), nil, nil) // test with and without a hostname for _, src := range []string{ @@ -28,8 +27,7 @@ func TestLookupModuleVersions(t *testing.T) { t.Fatal(err) } - s := &Storage{Services: regDisco} - resp, err := s.lookupModuleVersions(modsrc) + resp, err := client.Versions(modsrc) if err != nil { t.Fatal(err) } @@ -58,11 +56,10 @@ func TestLookupModuleVersions(t *testing.T) { } func TestRegistryAuth(t *testing.T) { - server := mockRegistry() + server := test.Registry() defer server.Close() - regDisco := testDisco(server) - storage := testStorage(t, regDisco) + client := NewClient(test.Disco(server), nil, nil) src := "private/name/provider" mod, err := regsrc.ParseModuleSource(src) @@ -71,36 +68,32 @@ func TestRegistryAuth(t *testing.T) { } // both should fail without auth - _, err = storage.lookupModuleVersions(mod) + _, err = client.Versions(mod) if err == nil { t.Fatal("expected error") } - _, err = storage.lookupModuleLocation(mod, "1.0.0") + _, err = client.Location(mod, "1.0.0") if err == nil { t.Fatal("expected error") } - storage.Creds = auth.StaticCredentialsSource(map[svchost.Hostname]map[string]interface{}{ - svchost.Hostname(defaultRegistry): {"token": testCredentials}, - }) + client = NewClient(test.Disco(server), test.Credentials, nil) - _, err = storage.lookupModuleVersions(mod) + _, err = client.Versions(mod) if err != nil { t.Fatal(err) } - _, err = storage.lookupModuleLocation(mod, "1.0.0") + _, err = client.Location(mod, "1.0.0") if err != nil { t.Fatal(err) } - } func TestLookupModuleLocationRelative(t *testing.T) { - server := mockRegistry() + server := test.Registry() defer server.Close() - regDisco := testDisco(server) - storage := testStorage(t, regDisco) + client := NewClient(test.Disco(server), nil, nil) src := "relative/foo/bar" mod, err := regsrc.ParseModuleSource(src) @@ -108,7 +101,7 @@ func TestLookupModuleLocationRelative(t *testing.T) { t.Fatal(err) } - got, err := storage.lookupModuleLocation(mod, "0.2.0") + got, err := client.Location(mod, "0.2.0") if err != nil { t.Fatal(err) } @@ -117,7 +110,6 @@ func TestLookupModuleLocationRelative(t *testing.T) { if got != want { t.Errorf("wrong location %s; want %s", got, want) } - } func TestAccLookupModuleVersions(t *testing.T) { @@ -129,17 +121,15 @@ func TestAccLookupModuleVersions(t *testing.T) { // test with and without a hostname for _, src := range []string{ "terraform-aws-modules/vpc/aws", - defaultRegistry + "/terraform-aws-modules/vpc/aws", + regsrc.PublicRegistryHost.String() + "/terraform-aws-modules/vpc/aws", } { modsrc, err := regsrc.ParseModuleSource(src) if err != nil { t.Fatal(err) } - s := &Storage{ - Services: regDisco, - } - resp, err := s.lookupModuleVersions(modsrc) + s := NewClient(regDisco, nil, nil) + resp, err := s.Versions(modsrc) if err != nil { t.Fatal(err) } @@ -169,11 +159,10 @@ func TestAccLookupModuleVersions(t *testing.T) { // the error should reference the config source exatly, not the discovered path. func TestLookupLookupModuleError(t *testing.T) { - server := mockRegistry() + server := test.Registry() defer server.Close() - regDisco := testDisco(server) - storage := testStorage(t, regDisco) + client := NewClient(test.Disco(server), nil, nil) // this should not be found in teh registry src := "bad/local/path" @@ -182,7 +171,7 @@ func TestLookupLookupModuleError(t *testing.T) { t.Fatal(err) } - _, err = storage.lookupModuleLocation(mod, "0.2.0") + _, err = client.Location(mod, "0.2.0") if err == nil { t.Fatal("expected error") } diff --git a/vendor/github.com/hashicorp/terraform/terraform/context.go b/vendor/github.com/hashicorp/terraform/terraform/context.go index cede4f81..53a12314 100644 --- a/vendor/github.com/hashicorp/terraform/terraform/context.go +++ b/vendor/github.com/hashicorp/terraform/terraform/context.go @@ -145,13 +145,8 @@ func NewContext(opts *ContextOpts) (*Context, error) { // If our state is from the future, then error. Callers can avoid // this error by explicitly setting `StateFutureAllowed`. - if !opts.StateFutureAllowed && state.FromFutureTerraform() { - return nil, fmt.Errorf( - "Terraform doesn't allow running any operations against a state\n"+ - "that was written by a future Terraform version. The state is\n"+ - "reporting it is written by Terraform '%s'.\n\n"+ - "Please run at least that version of Terraform to continue.", - state.TFVersion) + if err := CheckStateVersion(state); err != nil && !opts.StateFutureAllowed { + return nil, err } // Explicitly reset our state version to our current version so that diff --git a/vendor/github.com/hashicorp/terraform/terraform/context_apply_test.go b/vendor/github.com/hashicorp/terraform/terraform/context_apply_test.go index 7bc28f3b..ddaaae0b 100644 --- a/vendor/github.com/hashicorp/terraform/terraform/context_apply_test.go +++ b/vendor/github.com/hashicorp/terraform/terraform/context_apply_test.go @@ -3883,7 +3883,6 @@ func TestContext2Apply_outputDependsOn(t *testing.T) { info *InstanceInfo, is *InstanceState, id *InstanceDiff) (*InstanceState, error) { - // Sleep to allow parallel execution time.Sleep(50 * time.Millisecond) diff --git a/vendor/github.com/hashicorp/terraform/terraform/context_plan_test.go b/vendor/github.com/hashicorp/terraform/terraform/context_plan_test.go index 00d81590..8b680879 100644 --- a/vendor/github.com/hashicorp/terraform/terraform/context_plan_test.go +++ b/vendor/github.com/hashicorp/terraform/terraform/context_plan_test.go @@ -2401,6 +2401,32 @@ func TestContext2Plan_hook(t *testing.T) { } } +func TestContext2Plan_closeProvider(t *testing.T) { + // this fixture only has an aliased provider located in the module, to make + // sure that the provier name contains a path more complex than + // "provider.aws". + m := testModule(t, "plan-close-module-provider") + p := testProvider("aws") + p.DiffFn = testDiffFn + ctx := testContext2(t, &ContextOpts{ + Module: m, + ProviderResolver: ResourceProviderResolverFixed( + map[string]ResourceProviderFactory{ + "aws": testProviderFuncFixed(p), + }, + ), + }) + + _, err := ctx.Plan() + if err != nil { + t.Fatalf("err: %s", err) + } + + if !p.CloseCalled { + t.Fatal("provider not closed") + } +} + func TestContext2Plan_orphan(t *testing.T) { m := testModule(t, "plan-orphan") p := testProvider("aws") diff --git a/vendor/github.com/hashicorp/terraform/terraform/diff.go b/vendor/github.com/hashicorp/terraform/terraform/diff.go index d6dc5506..b6651c0a 100644 --- a/vendor/github.com/hashicorp/terraform/terraform/diff.go +++ b/vendor/github.com/hashicorp/terraform/terraform/diff.go @@ -396,6 +396,11 @@ type ResourceAttrDiff struct { Type DiffAttrType } +// Modified returns the inequality of Old and New for this attr +func (d *ResourceAttrDiff) Modified() bool { + return d.Old != d.New +} + // Empty returns true if the diff for this attr is neutral func (d *ResourceAttrDiff) Empty() bool { return d.Old == d.New && !d.NewComputed && !d.NewRemoved diff --git a/vendor/github.com/hashicorp/terraform/terraform/eval_diff.go b/vendor/github.com/hashicorp/terraform/terraform/eval_diff.go index bbc2b366..c1def916 100644 --- a/vendor/github.com/hashicorp/terraform/terraform/eval_diff.go +++ b/vendor/github.com/hashicorp/terraform/terraform/eval_diff.go @@ -258,9 +258,11 @@ func (n *EvalDiff) processIgnoreChanges(diff *InstanceDiff) error { for _, v := range containers { if v.keepDiff() { // At least one key has changes, so list all the sibling keys - // to keep in the diff. + // to keep in the diff if any values have changed for k := range v { - keep[k] = true + if v[k].Modified() { + keep[k] = true + } } } } diff --git a/vendor/github.com/hashicorp/terraform/terraform/eval_diff_test.go b/vendor/github.com/hashicorp/terraform/terraform/eval_diff_test.go index 1291e699..0da3b0ee 100644 --- a/vendor/github.com/hashicorp/terraform/terraform/eval_diff_test.go +++ b/vendor/github.com/hashicorp/terraform/terraform/eval_diff_test.go @@ -3,6 +3,8 @@ package terraform import ( "reflect" "testing" + + "github.com/hashicorp/terraform/config" ) func TestEvalFilterDiff(t *testing.T) { @@ -76,3 +78,69 @@ func TestEvalFilterDiff(t *testing.T) { } } } + +func TestProcessIgnoreChangesOnResourceIgnoredWithRequiresNew(t *testing.T) { + var evalDiff *EvalDiff + var instanceDiff *InstanceDiff + + var testDiffs = func(ignoreChanges []string, newAttribute string) (*EvalDiff, *InstanceDiff) { + return &EvalDiff{ + Resource: &config.Resource{ + Lifecycle: config.ResourceLifecycle{ + IgnoreChanges: ignoreChanges, + }, + }, + }, + &InstanceDiff{ + Destroy: true, + Attributes: map[string]*ResourceAttrDiff{ + "resource.changed": { + RequiresNew: true, + Type: DiffAttrInput, + Old: "old", + New: "new", + }, + "resource.unchanged": { + Old: "unchanged", + New: newAttribute, + }, + }, + } + } + + evalDiff, instanceDiff = testDiffs([]string{"resource.changed"}, "unchanged") + err := evalDiff.processIgnoreChanges(instanceDiff) + if err != nil { + t.Fatalf("err: %s", err) + } + if len(instanceDiff.Attributes) > 0 { + t.Fatalf("Expected all resources to be ignored, found %d", len(instanceDiff.Attributes)) + } + + evalDiff, instanceDiff = testDiffs([]string{}, "unchanged") + err = evalDiff.processIgnoreChanges(instanceDiff) + if err != nil { + t.Fatalf("err: %s", err) + } + if len(instanceDiff.Attributes) != 2 { + t.Fatalf("Expected 2 resources to be found, found %d", len(instanceDiff.Attributes)) + } + + evalDiff, instanceDiff = testDiffs([]string{"resource.changed"}, "changed") + err = evalDiff.processIgnoreChanges(instanceDiff) + if err != nil { + t.Fatalf("err: %s", err) + } + if len(instanceDiff.Attributes) != 1 { + t.Fatalf("Expected 1 resource to be found, found %d", len(instanceDiff.Attributes)) + } + + evalDiff, instanceDiff = testDiffs([]string{}, "changed") + err = evalDiff.processIgnoreChanges(instanceDiff) + if err != nil { + t.Fatalf("err: %s", err) + } + if len(instanceDiff.Attributes) != 2 { + t.Fatalf("Expected 2 resource to be found, found %d", len(instanceDiff.Attributes)) + } +} diff --git a/vendor/github.com/hashicorp/terraform/terraform/eval_provider_test.go b/vendor/github.com/hashicorp/terraform/terraform/eval_provider_test.go index cca02a76..8722b3e5 100644 --- a/vendor/github.com/hashicorp/terraform/terraform/eval_provider_test.go +++ b/vendor/github.com/hashicorp/terraform/terraform/eval_provider_test.go @@ -90,7 +90,8 @@ func TestEvalInitProvider(t *testing.T) { } func TestEvalCloseProvider(t *testing.T) { - n := &EvalCloseProvider{Name: "foo"} + providerName := ResolveProviderName("foo", nil) + n := &EvalCloseProvider{Name: providerName} provider := &MockResourceProvider{} ctx := &MockEvalContext{CloseProviderProvider: provider} if _, err := n.Eval(ctx); err != nil { @@ -100,7 +101,7 @@ func TestEvalCloseProvider(t *testing.T) { if !ctx.CloseProviderCalled { t.Fatal("should be called") } - if ctx.CloseProviderName != "foo" { + if ctx.CloseProviderName != providerName { t.Fatalf("bad: %#v", ctx.CloseProviderName) } } diff --git a/vendor/github.com/hashicorp/terraform/terraform/eval_validate.go b/vendor/github.com/hashicorp/terraform/terraform/eval_validate.go index 478aa640..e48af84a 100644 --- a/vendor/github.com/hashicorp/terraform/terraform/eval_validate.go +++ b/vendor/github.com/hashicorp/terraform/terraform/eval_validate.go @@ -150,6 +150,7 @@ func (n *EvalValidateProvisioner) validateConnConfig(connConfig *ResourceConfig) BastionUser interface{} `mapstructure:"bastion_user"` BastionPassword interface{} `mapstructure:"bastion_password"` BastionPrivateKey interface{} `mapstructure:"bastion_private_key"` + AgentIdentity interface{} `mapstructure:"agent_identity"` // For type=winrm only (enforced in winrm communicator) HTTPS interface{} `mapstructure:"https"` diff --git a/vendor/github.com/hashicorp/terraform/terraform/graphtype_string.go b/vendor/github.com/hashicorp/terraform/terraform/graphtype_string.go index e97b4855..95ef4e94 100644 --- a/vendor/github.com/hashicorp/terraform/terraform/graphtype_string.go +++ b/vendor/github.com/hashicorp/terraform/terraform/graphtype_string.go @@ -2,7 +2,7 @@ package terraform -import "fmt" +import "strconv" const _GraphType_name = "GraphTypeInvalidGraphTypeLegacyGraphTypeRefreshGraphTypePlanGraphTypePlanDestroyGraphTypeApplyGraphTypeInputGraphTypeValidate" @@ -10,7 +10,7 @@ var _GraphType_index = [...]uint8{0, 16, 31, 47, 60, 80, 94, 108, 125} func (i GraphType) String() string { if i >= GraphType(len(_GraphType_index)-1) { - return fmt.Sprintf("GraphType(%d)", i) + return "GraphType(" + strconv.FormatInt(int64(i), 10) + ")" } return _GraphType_name[_GraphType_index[i]:_GraphType_index[i+1]] } diff --git a/vendor/github.com/hashicorp/terraform/terraform/instancetype_string.go b/vendor/github.com/hashicorp/terraform/terraform/instancetype_string.go index f69267cd..b8e7d1fb 100644 --- a/vendor/github.com/hashicorp/terraform/terraform/instancetype_string.go +++ b/vendor/github.com/hashicorp/terraform/terraform/instancetype_string.go @@ -2,7 +2,7 @@ package terraform -import "fmt" +import "strconv" const _InstanceType_name = "TypeInvalidTypePrimaryTypeTaintedTypeDeposed" @@ -10,7 +10,7 @@ var _InstanceType_index = [...]uint8{0, 11, 22, 33, 44} func (i InstanceType) String() string { if i < 0 || i >= InstanceType(len(_InstanceType_index)-1) { - return fmt.Sprintf("InstanceType(%d)", i) + return "InstanceType(" + strconv.FormatInt(int64(i), 10) + ")" } return _InstanceType_name[_InstanceType_index[i]:_InstanceType_index[i+1]] } diff --git a/vendor/github.com/hashicorp/terraform/terraform/interpolate.go b/vendor/github.com/hashicorp/terraform/terraform/interpolate.go index 52ce1e88..456e7e3a 100644 --- a/vendor/github.com/hashicorp/terraform/terraform/interpolate.go +++ b/vendor/github.com/hashicorp/terraform/terraform/interpolate.go @@ -142,7 +142,6 @@ func (i *Interpolater) valueModuleVar( n string, v *config.ModuleVariable, result map[string]ast.Variable) error { - // Build the path to the child module we want path := make([]string, len(scope.Path), len(scope.Path)+1) copy(path, scope.Path) @@ -319,7 +318,6 @@ func (i *Interpolater) valueTerraformVar( n string, v *config.TerraformVariable, result map[string]ast.Variable) error { - // "env" is supported for backward compatibility, but it's deprecated and // so we won't advertise it as being allowed in the error message. It will // be removed in a future version of Terraform. @@ -701,7 +699,6 @@ func (i *Interpolater) computeResourceMultiVariable( func (i *Interpolater) interpolateComplexTypeAttribute( resourceID string, attributes map[string]string) (ast.Variable, error) { - // We can now distinguish between lists and maps in state by the count field: // - lists (and by extension, sets) use the traditional .# notation // - maps use the newer .% notation diff --git a/vendor/github.com/hashicorp/terraform/terraform/module_dependencies.go b/vendor/github.com/hashicorp/terraform/terraform/module_dependencies.go index b9f44a0e..4594cb60 100644 --- a/vendor/github.com/hashicorp/terraform/terraform/module_dependencies.go +++ b/vendor/github.com/hashicorp/terraform/terraform/module_dependencies.go @@ -17,7 +17,6 @@ import ( // present in the configuration. This is guaranteed not to happen for any // configuration that has passed a call to Config.Validate(). func ModuleTreeDependencies(root *module.Tree, state *State) *moduledeps.Module { - // First we walk the configuration tree to build the overall structure // and capture the explicit/implicit/inherited provider dependencies. deps := moduleTreeConfigDependencies(root, nil) diff --git a/vendor/github.com/hashicorp/terraform/terraform/resource.go b/vendor/github.com/hashicorp/terraform/terraform/resource.go index a8cd8dd9..2f5ebb5e 100644 --- a/vendor/github.com/hashicorp/terraform/terraform/resource.go +++ b/vendor/github.com/hashicorp/terraform/terraform/resource.go @@ -346,7 +346,7 @@ func (c *ResourceConfig) get( if err != nil { return nil, false } - if i >= int64(cv.Len()) { + if int(i) < 0 || int(i) >= cv.Len() { return nil, false } current = cv.Index(int(i)).Interface() diff --git a/vendor/github.com/hashicorp/terraform/terraform/resource_provider_mock.go b/vendor/github.com/hashicorp/terraform/terraform/resource_provider_mock.go index 73cde0cc..4000e3d2 100644 --- a/vendor/github.com/hashicorp/terraform/terraform/resource_provider_mock.go +++ b/vendor/github.com/hashicorp/terraform/terraform/resource_provider_mock.go @@ -203,6 +203,7 @@ func (p *MockResourceProvider) Diff( p.DiffInfo = info p.DiffState = state p.DiffDesired = desired + if p.DiffFn != nil { return p.DiffFn(info, state, desired) } diff --git a/vendor/github.com/hashicorp/terraform/terraform/resource_test.go b/vendor/github.com/hashicorp/terraform/terraform/resource_test.go index 31d511e5..4566492d 100644 --- a/vendor/github.com/hashicorp/terraform/terraform/resource_test.go +++ b/vendor/github.com/hashicorp/terraform/terraform/resource_test.go @@ -158,6 +158,14 @@ func TestResourceConfigGet(t *testing.T) { Value: nil, }, + { + Config: map[string]interface{}{ + "foo": []interface{}{1, 2, 5}, + }, + Key: "foo.-1", + Value: nil, + }, + // get from map { Config: map[string]interface{}{ diff --git a/vendor/github.com/hashicorp/terraform/terraform/state.go b/vendor/github.com/hashicorp/terraform/terraform/state.go index 5bc2f8a0..6a363485 100644 --- a/vendor/github.com/hashicorp/terraform/terraform/state.go +++ b/vendor/github.com/hashicorp/terraform/terraform/state.go @@ -2174,6 +2174,19 @@ func (s moduleStateSort) Swap(i, j int) { s[i], s[j] = s[j], s[i] } +// StateCompatible returns an error if the state is not compatible with the +// current version of terraform. +func CheckStateVersion(state *State) error { + if state == nil { + return nil + } + + if state.FromFutureTerraform() { + return fmt.Errorf(stateInvalidTerraformVersionErr, state.TFVersion) + } + return nil +} + const stateValidateErrMultiModule = ` Multiple modules with the same path: %s @@ -2182,3 +2195,11 @@ in your state file that point to the same module. This will cause Terraform to behave in unexpected and error prone ways and is invalid. Please back up and modify your state file manually to resolve this. ` + +const stateInvalidTerraformVersionErr = ` +Terraform doesn't allow running any operations against a state +that was written by a future Terraform version. The state is +reporting it is written by Terraform '%s' + +Please run at least that version of Terraform to continue. +` diff --git a/vendor/github.com/hashicorp/terraform/terraform/terraform_test.go b/vendor/github.com/hashicorp/terraform/terraform/terraform_test.go index 2deb4415..640741e4 100644 --- a/vendor/github.com/hashicorp/terraform/terraform/terraform_test.go +++ b/vendor/github.com/hashicorp/terraform/terraform/terraform_test.go @@ -1675,10 +1675,7 @@ aws_instance.foo: const testTFPlanDiffIgnoreChangesWithFlatmaps = ` UPDATE: aws_instance.foo lst.#: "1" => "2" - lst.0: "j" => "j" lst.1: "" => "k" - set.#: "1" => "1" - set.0.a: "1" => "1" set.0.b: "" => "2" type: "" => "aws_instance" ` diff --git a/vendor/github.com/hashicorp/terraform/terraform/transform_provider.go b/vendor/github.com/hashicorp/terraform/terraform/transform_provider.go index f8386efe..c4772b40 100644 --- a/vendor/github.com/hashicorp/terraform/terraform/transform_provider.go +++ b/vendor/github.com/hashicorp/terraform/terraform/transform_provider.go @@ -138,13 +138,13 @@ func (t *CloseProviderTransformer) Transform(g *Graph) error { p := v.(GraphNodeProvider) // get the close provider of this type if we alread created it - closer := cpm[p.ProviderName()] + closer := cpm[p.Name()] if closer == nil { // create a closer for this provider type - closer = &graphNodeCloseProvider{ProviderNameValue: p.ProviderName()} + closer = &graphNodeCloseProvider{ProviderNameValue: p.Name()} g.Add(closer) - cpm[p.ProviderName()] = closer + cpm[p.Name()] = closer } // Close node depends on the provider itself @@ -336,7 +336,7 @@ type graphNodeCloseProvider struct { } func (n *graphNodeCloseProvider) Name() string { - return fmt.Sprintf("provider.%s (close)", n.ProviderNameValue) + return n.ProviderNameValue + " (close)" } // GraphNodeEvalable impl. diff --git a/vendor/github.com/hashicorp/terraform/terraform/walkoperation_string.go b/vendor/github.com/hashicorp/terraform/terraform/walkoperation_string.go index cbd78dd9..4cfc528e 100644 --- a/vendor/github.com/hashicorp/terraform/terraform/walkoperation_string.go +++ b/vendor/github.com/hashicorp/terraform/terraform/walkoperation_string.go @@ -2,7 +2,7 @@ package terraform -import "fmt" +import "strconv" const _walkOperation_name = "walkInvalidwalkInputwalkApplywalkPlanwalkPlanDestroywalkRefreshwalkValidatewalkDestroywalkImport" @@ -10,7 +10,7 @@ var _walkOperation_index = [...]uint8{0, 11, 20, 29, 37, 52, 63, 75, 86, 96} func (i walkOperation) String() string { if i >= walkOperation(len(_walkOperation_index)-1) { - return fmt.Sprintf("walkOperation(%d)", i) + return "walkOperation(" + strconv.FormatInt(int64(i), 10) + ")" } return _walkOperation_name[_walkOperation_index[i]:_walkOperation_index[i+1]] } diff --git a/vendor/github.com/hashicorp/terraform/tfdiags/severity_string.go b/vendor/github.com/hashicorp/terraform/tfdiags/severity_string.go index edf9e639..0b1249bb 100644 --- a/vendor/github.com/hashicorp/terraform/tfdiags/severity_string.go +++ b/vendor/github.com/hashicorp/terraform/tfdiags/severity_string.go @@ -2,18 +2,13 @@ package tfdiags -import "fmt" +import "strconv" const ( _Severity_name_0 = "Error" _Severity_name_1 = "Warning" ) -var ( - _Severity_index_0 = [...]uint8{0, 5} - _Severity_index_1 = [...]uint8{0, 7} -) - func (i Severity) String() string { switch { case i == 69: @@ -21,6 +16,6 @@ func (i Severity) String() string { case i == 87: return _Severity_name_1 default: - return fmt.Sprintf("Severity(%d)", i) + return "Severity(" + strconv.FormatInt(int64(i), 10) + ")" } } diff --git a/vendor/github.com/hashicorp/terraform/version/version.go b/vendor/github.com/hashicorp/terraform/version/version.go index 551fe5e6..699ccf7a 100644 --- a/vendor/github.com/hashicorp/terraform/version/version.go +++ b/vendor/github.com/hashicorp/terraform/version/version.go @@ -11,7 +11,7 @@ import ( ) // The main version number that is being run at the moment. -const Version = "0.11.1" +const Version = "0.11.2" // 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