From 7df15ad98afe9ba134516f9a1804e600437c59dd Mon Sep 17 00:00:00 2001 From: craigatgoogle Date: Mon, 6 Aug 2018 16:17:30 -0700 Subject: [PATCH 001/226] Added FloatBetween validation func Added lower bound inclusion test for FloatBetween --- helper/validation/validation.go | 19 ++++++++++++ helper/validation/validation_test.go | 43 ++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/helper/validation/validation.go b/helper/validation/validation.go index e9edcd333..1c441fc82 100644 --- a/helper/validation/validation.go +++ b/helper/validation/validation.go @@ -266,3 +266,22 @@ func ValidateRFC3339TimeString(v interface{}, k string) (ws []string, errors []e } return } + +// FloatBetween returns a SchemaValidateFunc which tests if the provided value +// is of type float64 and is between min and max (inclusive). +func FloatBetween(min, max float64) schema.SchemaValidateFunc { + return func(i interface{}, k string) (s []string, es []error) { + v, ok := i.(float64) + if !ok { + es = append(es, fmt.Errorf("expected type of %s to be float64", k)) + return + } + + if v < min || v > max { + es = append(es, fmt.Errorf("expected %s to be in the range (%f - %f), got %f", k, min, max, v)) + return + } + + return + } +} diff --git a/helper/validation/validation_test.go b/helper/validation/validation_test.go index ea3b703bc..905e473b8 100644 --- a/helper/validation/validation_test.go +++ b/helper/validation/validation_test.go @@ -373,3 +373,46 @@ func runTestCases(t *testing.T, cases []testCase) { } } } + +func TestFloatBetween(t *testing.T) { + cases := map[string]struct { + Value interface{} + ValidateFunc schema.SchemaValidateFunc + ExpectValidationErrors bool + }{ + "accept valid value": { + Value: 1.5, + ValidateFunc: FloatBetween(1.0, 2.0), + ExpectValidationErrors: false, + }, + "accept valid value inclusive upper bound": { + Value: 1.0, + ValidateFunc: FloatBetween(0.0, 1.0), + ExpectValidationErrors: false, + }, + "accept valid value inclusive lower bound": { + Value: 0.0, + ValidateFunc: FloatBetween(0.0, 1.0), + ExpectValidationErrors: false, + }, + "reject out of range value": { + Value: -1.0, + ValidateFunc: FloatBetween(0.0, 1.0), + ExpectValidationErrors: true, + }, + "reject incorrectly typed value": { + Value: 1, + ValidateFunc: FloatBetween(0.0, 1.0), + ExpectValidationErrors: true, + }, + } + + for tn, tc := range cases { + _, errors := tc.ValidateFunc(tc.Value, tn) + if len(errors) > 0 && !tc.ExpectValidationErrors { + t.Errorf("%s: unexpected errors %s", tn, errors) + } else if len(errors) == 0 && tc.ExpectValidationErrors { + t.Errorf("%s: expected errors but got none", tn) + } + } +} From adebc65d95d3fcc4f9060d0f478410c2f9b67594 Mon Sep 17 00:00:00 2001 From: Alex Somesan Date: Wed, 27 Mar 2019 20:10:46 +0100 Subject: [PATCH 002/226] Document that ValidateFunc works on maps. --- helper/schema/schema.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helper/schema/schema.go b/helper/schema/schema.go index 15a82e7f7..041ee8fd1 100644 --- a/helper/schema/schema.go +++ b/helper/schema/schema.go @@ -279,7 +279,7 @@ type Schema struct { // guaranteed to be of the proper Schema type, and it can yield warnings or // errors based on inspection of that value. // - // ValidateFunc currently only works for primitive types. + // ValidateFunc currently only works for primitive types and maps. ValidateFunc SchemaValidateFunc // Sensitive ensures that the attribute's value does not get displayed in From ef681e527d27e215c3d4dde74f0d3ab860be6345 Mon Sep 17 00:00:00 2001 From: Alex Somesan Date: Fri, 29 Mar 2019 16:53:13 +0100 Subject: [PATCH 003/226] Rephrase for clarity --- helper/schema/schema.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/helper/schema/schema.go b/helper/schema/schema.go index 041ee8fd1..7ae381c63 100644 --- a/helper/schema/schema.go +++ b/helper/schema/schema.go @@ -279,7 +279,8 @@ type Schema struct { // guaranteed to be of the proper Schema type, and it can yield warnings or // errors based on inspection of that value. // - // ValidateFunc currently only works for primitive types and maps. + // ValidateFunc currently only works for primitive types and TypeList / TypeSet + // of primitive type elements. ValidateFunc SchemaValidateFunc // Sensitive ensures that the attribute's value does not get displayed in From a674d3fb7b6446492ee42430c59981bf7df58ae4 Mon Sep 17 00:00:00 2001 From: cgriggs01 Date: Wed, 10 Apr 2019 11:00:15 -0700 Subject: [PATCH 004/226] [Website] new community providers --- website/docs/providers/type/community-index.html.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/website/docs/providers/type/community-index.html.markdown b/website/docs/providers/type/community-index.html.markdown index 6a63c9009..3099de681 100644 --- a/website/docs/providers/type/community-index.html.markdown +++ b/website/docs/providers/type/community-index.html.markdown @@ -29,6 +29,7 @@ please fill out this [community providers form](https://docs.google.com/forms/d/ - [Aviatrix](https://github.com/AviatrixSystems/terraform-provider-aviatrix) - [AWX](https://github.com/mauromedda/terraform-provider-awx) - [Azure Devops](https://github.com/agarciamiravet/terraform-provider-azuredevops) +- [Cherry Servers](https://github.com/cherryservers/terraform-provider-cherryservers) - [CloudAMQP](https://github.com/cloudamqp/terraform-provider) - [CloudKarafka](https://github.com/cloudkarafka/terraform-provider) - [CloudMQTT](https://github.com/cloudmqtt/terraform-provider) @@ -52,6 +53,7 @@ please fill out this [community providers form](https://docs.google.com/forms/d/ - [Gandi](https://github.com/tiramiseb/terraform-provider-gandi) - [Generic Rest API](https://github.com/Mastercard/terraform-provider-restapi) - [Git](https://github.com/fourplusone/terraform-provider-git) +- [GitHub Code Owners](https://github.com/form3tech-oss/terraform-provider-codeowners) - [Glue](https://github.com/MikeSouza/terraform-provider-glue) - [GoCD](https://github.com/drewsonne/terraform-provider-gocd) - [Google Calendar](https://github.com/sethvargo/terraform-provider-googlecalendar) @@ -107,6 +109,7 @@ please fill out this [community providers form](https://docs.google.com/forms/d/ - [Spinnaker](https://github.com/armory-io/terraform-provider-spinnaker) - [SQL](https://github.com/odedniv/terraform-provider-sql) - [Stateful](https://github.com/Ashald/terraform-provider-stateful) +- [Statuspage](https://github.com/yannh/terraform-provider-statuspage) - [Stripe](https://github.com/franckverrot/terraform-provider-stripe) - [Sumo Logic](https://github.com/SumoLogic/sumologic-terraform-provider) - [TeamCity](https://github.com/cvbarros/terraform-provider-teamcity) @@ -118,6 +121,7 @@ please fill out this [community providers form](https://docs.google.com/forms/d/ - [Vultr](https://github.com/squat/terraform-provider-vultr) - [Win DNS](https://github.com/PortOfPortland/terraform-provider-windns) - [YAML](https://github.com/Ashald/terraform-provider-yaml) +- [Zendesk](https://github.com/nukosuke/terraform-provider-zendesk) - [ZeroTier](https://github.com/cormacrelf/terraform-provider-zerotier) - [Zipper](https://github.com/ArthurHlt/terraform-provider-zipper) From 90bc237b7baac432070fd479b70b88e3fc3a7fc7 Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Thu, 11 Apr 2019 14:34:14 +0200 Subject: [PATCH 005/226] Prevent a panic caused by writing to a nil map --- backend/remote/backend_context.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/remote/backend_context.go b/backend/remote/backend_context.go index dfc5783d4..d548a4eec 100644 --- a/backend/remote/backend_context.go +++ b/backend/remote/backend_context.go @@ -89,6 +89,9 @@ func (b *Remote) Context(op *backend.Operation) (*terraform.Context, statemgr.Fu } if tfeVariables != nil { + if op.Variables == nil { + op.Variables = make(map[string]backend.UnparsedVariableValue) + } for _, v := range tfeVariables.Items { if v.Sensitive { v.Value = "" @@ -100,12 +103,12 @@ func (b *Remote) Context(op *backend.Operation) (*terraform.Context, statemgr.Fu } } - variables, varDiags := backend.ParseVariableValues(op.Variables, config.Module.Variables) - diags = diags.Append(varDiags) - if diags.HasErrors() { - return nil, nil, diags - } if op.Variables != nil { + variables, varDiags := backend.ParseVariableValues(op.Variables, config.Module.Variables) + diags = diags.Append(varDiags) + if diags.HasErrors() { + return nil, nil, diags + } opts.Variables = variables } From 88982fdbc3cce02e67fe241d62a9e691e2ab7d30 Mon Sep 17 00:00:00 2001 From: Nick Fagerlund Date: Thu, 11 Apr 2019 16:54:18 -0700 Subject: [PATCH 006/226] website: in functions sidebar, default lists to collapsed (#20945) Find-in-page is still supported with the 'expand/collapse all' control. --- website/layouts/functions.erb | 795 +++++++++++++++++----------------- 1 file changed, 397 insertions(+), 398 deletions(-) diff --git a/website/layouts/functions.erb b/website/layouts/functions.erb index 4e539fa92..50f65c61b 100644 --- a/website/layouts/functions.erb +++ b/website/layouts/functions.erb @@ -2,427 +2,426 @@ <% content_for :sidebar do %>

Terraform CLI

+ (Expand/collapse all) +