From 96ac1c594a81bb4e0c972bd36a32f7083b84c77d Mon Sep 17 00:00:00 2001 From: Christopher Fitzner Date: Tue, 12 Mar 2024 22:38:37 -0700 Subject: [PATCH] vendor: upgrade plugin-framework-validators --- go.mod | 2 +- go.sum | 4 +- .../helpers/validatordiag/diag.go | 3 + .../helpers/validatordiag/doc.go | 3 + .../configvalidator/at_least_one_of.go | 3 + .../internal/configvalidator/conflicting.go | 3 + .../internal/configvalidator/doc.go | 3 + .../configvalidator/exactly_one_of.go | 3 + .../configvalidator/required_together.go | 3 + .../resourcevalidator/all.go | 57 ++++++++++++++++ .../resourcevalidator/any.go | 65 ++++++++++++++++++ .../any_with_all_warnings.go | 67 +++++++++++++++++++ .../resourcevalidator/at_least_one_of.go | 3 + .../resourcevalidator/conflicting.go | 3 + .../resourcevalidator/doc.go | 3 + .../resourcevalidator/exactly_one_of.go | 3 + .../resourcevalidator/required_together.go | 3 + vendor/modules.txt | 4 +- 18 files changed, 230 insertions(+), 5 deletions(-) create mode 100644 vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/all.go create mode 100644 vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/any.go create mode 100644 vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/any_with_all_warnings.go diff --git a/go.mod b/go.mod index 97d42095..cff71c92 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/hashicorp/go-retryablehttp v0.7.4 github.com/hashicorp/terraform-plugin-docs v0.13.0 github.com/hashicorp/terraform-plugin-framework v1.6.1 - github.com/hashicorp/terraform-plugin-framework-validators v0.10.0 + github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 github.com/hashicorp/terraform-plugin-go v0.22.0 github.com/hashicorp/terraform-plugin-log v0.9.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 diff --git a/go.sum b/go.sum index 74305014..710901ec 100644 --- a/go.sum +++ b/go.sum @@ -106,8 +106,8 @@ github.com/hashicorp/terraform-plugin-docs v0.13.0 h1:6e+VIWsVGb6jYJewfzq2ok2smP github.com/hashicorp/terraform-plugin-docs v0.13.0/go.mod h1:W0oCmHAjIlTHBbvtppWHe8fLfZ2BznQbuv8+UD8OucQ= github.com/hashicorp/terraform-plugin-framework v1.6.1 h1:hw2XrmUu8d8jVL52ekxim2IqDc+2Kpekn21xZANARLU= github.com/hashicorp/terraform-plugin-framework v1.6.1/go.mod h1:aJI+n/hBPhz1J+77GdgNfk5svW12y7fmtxe/5L5IuwI= -github.com/hashicorp/terraform-plugin-framework-validators v0.10.0 h1:4L0tmy/8esP6OcvocVymw52lY0HyQ5OxB7VNl7k4bS0= -github.com/hashicorp/terraform-plugin-framework-validators v0.10.0/go.mod h1:qdQJCdimB9JeX2YwOpItEu+IrfoJjWQ5PhLpAOMDQAE= +github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 h1:HOjBuMbOEzl7snOdOoUfE2Jgeto6JOjLVQ39Ls2nksc= +github.com/hashicorp/terraform-plugin-framework-validators v0.12.0/go.mod h1:jfHGE/gzjxYz6XoUwi/aYiiKrJDeutQNUtGQXkaHklg= github.com/hashicorp/terraform-plugin-go v0.22.0 h1:1OS1Jk5mO0f5hrziWJGXXIxBrMe2j/B8E+DVGw43Xmc= github.com/hashicorp/terraform-plugin-go v0.22.0/go.mod h1:mPULV91VKss7sik6KFEcEu7HuTogMLLO/EvWCuFkRVE= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= diff --git a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/helpers/validatordiag/diag.go b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/helpers/validatordiag/diag.go index 60ca1e79..09a65e6b 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/helpers/validatordiag/diag.go +++ b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/helpers/validatordiag/diag.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package validatordiag import ( diff --git a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/helpers/validatordiag/doc.go b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/helpers/validatordiag/doc.go index c31457a0..c6f8dcff 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/helpers/validatordiag/doc.go +++ b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/helpers/validatordiag/doc.go @@ -1,2 +1,5 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + // Package validatordiag provides diagnostics helpers for validator implementations. package validatordiag diff --git a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/internal/configvalidator/at_least_one_of.go b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/internal/configvalidator/at_least_one_of.go index 32cee174..9d67ef4a 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/internal/configvalidator/at_least_one_of.go +++ b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/internal/configvalidator/at_least_one_of.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package configvalidator import ( diff --git a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/internal/configvalidator/conflicting.go b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/internal/configvalidator/conflicting.go index 85499cf2..edd2abd8 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/internal/configvalidator/conflicting.go +++ b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/internal/configvalidator/conflicting.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package configvalidator import ( diff --git a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/internal/configvalidator/doc.go b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/internal/configvalidator/doc.go index b1bed4ac..789b4159 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/internal/configvalidator/doc.go +++ b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/internal/configvalidator/doc.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + // Package configvalidator provides the generic configuration validator // implementations for the exported datasourcevalidator, providervalidator, and // resourcevalidator packages. diff --git a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/internal/configvalidator/exactly_one_of.go b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/internal/configvalidator/exactly_one_of.go index 477a8f24..b76786f8 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/internal/configvalidator/exactly_one_of.go +++ b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/internal/configvalidator/exactly_one_of.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package configvalidator import ( diff --git a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/internal/configvalidator/required_together.go b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/internal/configvalidator/required_together.go index c9186c87..69c46671 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/internal/configvalidator/required_together.go +++ b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/internal/configvalidator/required_together.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package configvalidator import ( diff --git a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/all.go b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/all.go new file mode 100644 index 00000000..db9197a3 --- /dev/null +++ b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/all.go @@ -0,0 +1,57 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package resourcevalidator + +import ( + "context" + "fmt" + "strings" + + "github.com/hashicorp/terraform-plugin-framework/resource" +) + +// All returns a validator which ensures that any configured attribute value +// validates against all the given validators. +// +// Use of All is only necessary when used in conjunction with Any or AnyWithAllWarnings +// as the Validators field automatically applies a logical AND. +func All(validators ...resource.ConfigValidator) resource.ConfigValidator { + return allValidator{ + validators: validators, + } +} + +var _ resource.ConfigValidator = allValidator{} + +// allValidator implements the validator. +type allValidator struct { + validators []resource.ConfigValidator +} + +// Description describes the validation in plain text formatting. +func (v allValidator) Description(ctx context.Context) string { + var descriptions []string + + for _, subValidator := range v.validators { + descriptions = append(descriptions, subValidator.Description(ctx)) + } + + return fmt.Sprintf("Value must satisfy all of the validations: %s", strings.Join(descriptions, " + ")) +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v allValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// ValidateResource performs the validation. +func (v allValidator) ValidateResource(ctx context.Context, req resource.ValidateConfigRequest, resp *resource.ValidateConfigResponse) { + for _, subValidator := range v.validators { + validateResp := &resource.ValidateConfigResponse{} + + subValidator.ValidateResource(ctx, req, validateResp) + + resp.Diagnostics.Append(validateResp.Diagnostics...) + } +} diff --git a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/any.go b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/any.go new file mode 100644 index 00000000..89cb678e --- /dev/null +++ b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/any.go @@ -0,0 +1,65 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package resourcevalidator + +import ( + "context" + "fmt" + "strings" + + "github.com/hashicorp/terraform-plugin-framework/resource" +) + +// Any returns a validator which ensures that any configured attribute value +// passes at least one of the given validators. +// +// To prevent practitioner confusion should non-passing validators have +// conflicting logic, only warnings from the passing validator are returned. +// Use AnyWithAllWarnings() to return warnings from non-passing validators +// as well. +func Any(validators ...resource.ConfigValidator) resource.ConfigValidator { + return anyValidator{ + validators: validators, + } +} + +var _ resource.ConfigValidator = anyValidator{} + +// anyValidator implements the validator. +type anyValidator struct { + validators []resource.ConfigValidator +} + +// Description describes the validation in plain text formatting. +func (v anyValidator) Description(ctx context.Context) string { + var descriptions []string + + for _, subValidator := range v.validators { + descriptions = append(descriptions, subValidator.Description(ctx)) + } + + return fmt.Sprintf("Value must satisfy at least one of the validations: %s", strings.Join(descriptions, " + ")) +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v anyValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// ValidateResource performs the validation. +func (v anyValidator) ValidateResource(ctx context.Context, req resource.ValidateConfigRequest, resp *resource.ValidateConfigResponse) { + for _, subValidator := range v.validators { + validateResp := &resource.ValidateConfigResponse{} + + subValidator.ValidateResource(ctx, req, validateResp) + + if !validateResp.Diagnostics.HasError() { + resp.Diagnostics = validateResp.Diagnostics + + return + } + + resp.Diagnostics.Append(validateResp.Diagnostics...) + } +} diff --git a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/any_with_all_warnings.go b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/any_with_all_warnings.go new file mode 100644 index 00000000..34b6a509 --- /dev/null +++ b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/any_with_all_warnings.go @@ -0,0 +1,67 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package resourcevalidator + +import ( + "context" + "fmt" + "strings" + + "github.com/hashicorp/terraform-plugin-framework/resource" +) + +// AnyWithAllWarnings returns a validator which ensures that any configured +// attribute value passes at least one of the given validators. This validator +// returns all warnings, including failed validators. +// +// Use Any() to return warnings only from the passing validator. +func AnyWithAllWarnings(validators ...resource.ConfigValidator) resource.ConfigValidator { + return anyWithAllWarningsValidator{ + validators: validators, + } +} + +var _ resource.ConfigValidator = anyWithAllWarningsValidator{} + +// anyWithAllWarningsValidator implements the validator. +type anyWithAllWarningsValidator struct { + validators []resource.ConfigValidator +} + +// Description describes the validation in plain text formatting. +func (v anyWithAllWarningsValidator) Description(ctx context.Context) string { + var descriptions []string + + for _, subValidator := range v.validators { + descriptions = append(descriptions, subValidator.Description(ctx)) + } + + return fmt.Sprintf("Value must satisfy at least one of the validations: %s", strings.Join(descriptions, " + ")) +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v anyWithAllWarningsValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// ValidateResource performs the validation. +func (v anyWithAllWarningsValidator) ValidateResource(ctx context.Context, req resource.ValidateConfigRequest, resp *resource.ValidateConfigResponse) { + anyValid := false + + for _, subValidator := range v.validators { + validateResp := &resource.ValidateConfigResponse{} + + subValidator.ValidateResource(ctx, req, validateResp) + + if !validateResp.Diagnostics.HasError() { + anyValid = true + } + + resp.Diagnostics.Append(validateResp.Diagnostics...) + } + + if anyValid { + resp.Diagnostics = resp.Diagnostics.Warnings() + } +} diff --git a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/at_least_one_of.go b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/at_least_one_of.go index 11cba7e8..c2de7d62 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/at_least_one_of.go +++ b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/at_least_one_of.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package resourcevalidator import ( diff --git a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/conflicting.go b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/conflicting.go index 25f88aee..01f1c4aa 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/conflicting.go +++ b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/conflicting.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package resourcevalidator import ( diff --git a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/doc.go b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/doc.go index ed6f16a1..c53097a9 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/doc.go +++ b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/doc.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + // Package resourcevalidator provides validators to express relationships // between multiple attributes of a resource. For example, checking that // multiple attributes are not configured at the same time. diff --git a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/exactly_one_of.go b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/exactly_one_of.go index a1fbdbee..4582cecf 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/exactly_one_of.go +++ b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/exactly_one_of.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package resourcevalidator import ( diff --git a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/required_together.go b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/required_together.go index 787a38be..449db6f7 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/required_together.go +++ b/vendor/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator/required_together.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package resourcevalidator import ( diff --git a/vendor/modules.txt b/vendor/modules.txt index ae28ac6d..30de9948 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -208,8 +208,8 @@ github.com/hashicorp/terraform-plugin-framework/schema/validator github.com/hashicorp/terraform-plugin-framework/tfsdk github.com/hashicorp/terraform-plugin-framework/types github.com/hashicorp/terraform-plugin-framework/types/basetypes -# github.com/hashicorp/terraform-plugin-framework-validators v0.10.0 -## explicit; go 1.18 +# github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 +## explicit; go 1.19 github.com/hashicorp/terraform-plugin-framework-validators/helpers/validatordiag github.com/hashicorp/terraform-plugin-framework-validators/internal/configvalidator github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator