diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index eff6b8f..cb4e8a5 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -4,16 +4,16 @@ management: docChecksum: 8ecc10127cd4d51cceddbc01756b40f4 docVersion: 0.0.1 speakeasyVersion: internal - generationVersion: 2.228.1 - releaseVersion: 0.10.0 - configChecksum: ae6aa247f4cac41bb380d4ba72d51037 + generationVersion: 2.230.1 + releaseVersion: 0.10.1 + configChecksum: a6920bc98759320d71d4dc35f7d80c54 repoURL: https://github.com/speakeasy-sdks/terraform-provider-vercel.git repoSubDirectory: . published: true features: terraform: constsAndDefaults: 0.1.2 - core: 3.8.0 + core: 3.8.1 deprecations: 2.81.1 globalSecurity: 2.81.2 globalServerURLs: 2.82.1 @@ -84,6 +84,15 @@ generatedFiles: - internal/validators/ExactlyOneChild.go - internal/validators/JSONParseValidator.go - internal/validators/RFC3339Validator.go + - internal/validators/boolvalidators/not_null.go + - internal/validators/float64validators/not_null.go + - internal/validators/int64validators/not_null.go + - internal/validators/listvalidators/not_null.go + - internal/validators/mapvalidators/not_null.go + - internal/validators/numbervalidators/not_null.go + - internal/validators/objectvalidators/not_null.go + - internal/validators/setvalidators/not_null.go + - internal/validators/stringvalidators/not_null.go - main.go - terraform-registry-manifest.json - tools/tools.go diff --git a/README.md b/README.md index 402c775..1f40f7e 100755 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ terraform { required_providers { vercel = { source = "zchee/vercel" - version = "0.10.0" + version = "0.10.1" } } } diff --git a/RELEASES.md b/RELEASES.md index d474c25..7434a36 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -150,4 +150,12 @@ Based on: - OpenAPI Doc 0.0.1 - Speakeasy CLI 1.133.1 (2.228.1) https://github.com/speakeasy-api/speakeasy ### Generated -- [terraform v0.10.0] . \ No newline at end of file +- [terraform v0.10.0] . + +## 2024-01-09 00:25:49 +### Changes +Based on: +- OpenAPI Doc 0.0.1 +- Speakeasy CLI 1.134.0 (2.230.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v0.10.1] . \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index c64de4d..d5ba721 100644 --- a/docs/index.md +++ b/docs/index.md @@ -17,7 +17,7 @@ terraform { required_providers { vercel = { source = "zchee/vercel" - version = "0.10.0" + version = "0.10.1" } } } diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index 300999f..d1fc061 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { vercel = { source = "zchee/vercel" - version = "0.10.0" + version = "0.10.1" } } } diff --git a/gen.yaml b/gen.yaml index a480c66..2efafcc 100644 --- a/gen.yaml +++ b/gen.yaml @@ -6,7 +6,7 @@ generation: fixes: nameResolutionDec2023: false terraform: - version: 0.10.0 + version: 0.10.1 author: zchee imports: option: openapi diff --git a/internal/planmodifiers/boolplanmodifier/suppress_diff.go b/internal/planmodifiers/boolplanmodifier/suppress_diff.go index 781f661..de53b9e 100644 --- a/internal/planmodifiers/boolplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/boolplanmodifier/suppress_diff.go @@ -10,8 +10,6 @@ import ( ) const ( - // Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions] - Standard = iota // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation ExplicitSuppress = iota ) @@ -53,9 +51,6 @@ func (m suppressDiff) PlanModifyBool(ctx context.Context, req planmodifier.BoolR if utils.IsAllStateUnknown(ctx, req.State) { return } - if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) { - return - } resp.PlanValue = req.StateValue } diff --git a/internal/planmodifiers/float64planmodifier/suppress_diff.go b/internal/planmodifiers/float64planmodifier/suppress_diff.go index 9434e2e..c01d2da 100644 --- a/internal/planmodifiers/float64planmodifier/suppress_diff.go +++ b/internal/planmodifiers/float64planmodifier/suppress_diff.go @@ -10,8 +10,6 @@ import ( ) const ( - // Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions] - Standard = iota // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation ExplicitSuppress = iota ) @@ -53,9 +51,6 @@ func (m suppressDiff) PlanModifyFloat64(ctx context.Context, req planmodifier.Fl if utils.IsAllStateUnknown(ctx, req.State) { return } - if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) { - return - } resp.PlanValue = req.StateValue } diff --git a/internal/planmodifiers/int64planmodifier/suppress_diff.go b/internal/planmodifiers/int64planmodifier/suppress_diff.go index 1f446f2..ba2de4e 100644 --- a/internal/planmodifiers/int64planmodifier/suppress_diff.go +++ b/internal/planmodifiers/int64planmodifier/suppress_diff.go @@ -10,8 +10,6 @@ import ( ) const ( - // Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions] - Standard = iota // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation ExplicitSuppress = iota ) @@ -53,9 +51,6 @@ func (m suppressDiff) PlanModifyInt64(ctx context.Context, req planmodifier.Int6 if utils.IsAllStateUnknown(ctx, req.State) { return } - if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) { - return - } resp.PlanValue = req.StateValue } diff --git a/internal/planmodifiers/listplanmodifier/suppress_diff.go b/internal/planmodifiers/listplanmodifier/suppress_diff.go index 7da51fd..fdf1ddd 100644 --- a/internal/planmodifiers/listplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/listplanmodifier/suppress_diff.go @@ -10,8 +10,6 @@ import ( ) const ( - // Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions] - Standard = iota // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation ExplicitSuppress = iota ) @@ -53,9 +51,6 @@ func (m suppressDiff) PlanModifyList(ctx context.Context, req planmodifier.ListR if utils.IsAllStateUnknown(ctx, req.State) { return } - if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) { - return - } resp.PlanValue = req.StateValue } diff --git a/internal/planmodifiers/mapplanmodifier/suppress_diff.go b/internal/planmodifiers/mapplanmodifier/suppress_diff.go index 3dab26a..c2f3f06 100644 --- a/internal/planmodifiers/mapplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/mapplanmodifier/suppress_diff.go @@ -10,8 +10,6 @@ import ( ) const ( - // Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions] - Standard = iota // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation ExplicitSuppress = iota ) @@ -53,9 +51,6 @@ func (m suppressDiff) PlanModifyMap(ctx context.Context, req planmodifier.MapReq if utils.IsAllStateUnknown(ctx, req.State) { return } - if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) { - return - } resp.PlanValue = req.StateValue } diff --git a/internal/planmodifiers/numberplanmodifier/suppress_diff.go b/internal/planmodifiers/numberplanmodifier/suppress_diff.go index 1b19e91..d19ab7e 100644 --- a/internal/planmodifiers/numberplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/numberplanmodifier/suppress_diff.go @@ -10,8 +10,6 @@ import ( ) const ( - // Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions] - Standard = iota // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation ExplicitSuppress = iota ) @@ -53,9 +51,6 @@ func (m suppressDiff) PlanModifyNumber(ctx context.Context, req planmodifier.Num if utils.IsAllStateUnknown(ctx, req.State) { return } - if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) { - return - } resp.PlanValue = req.StateValue } diff --git a/internal/planmodifiers/objectplanmodifier/suppress_diff.go b/internal/planmodifiers/objectplanmodifier/suppress_diff.go index 5d93953..b07e652 100644 --- a/internal/planmodifiers/objectplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/objectplanmodifier/suppress_diff.go @@ -10,8 +10,6 @@ import ( ) const ( - // Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions] - Standard = iota // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation ExplicitSuppress = iota ) @@ -53,9 +51,6 @@ func (m suppressDiff) PlanModifyObject(ctx context.Context, req planmodifier.Obj if utils.IsAllStateUnknown(ctx, req.State) { return } - if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) { - return - } resp.PlanValue = req.StateValue } diff --git a/internal/planmodifiers/setplanmodifier/suppress_diff.go b/internal/planmodifiers/setplanmodifier/suppress_diff.go index ce51637..d1d77ee 100644 --- a/internal/planmodifiers/setplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/setplanmodifier/suppress_diff.go @@ -10,8 +10,6 @@ import ( ) const ( - // Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions] - Standard = iota // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation ExplicitSuppress = iota ) @@ -53,9 +51,6 @@ func (m suppressDiff) PlanModifySet(ctx context.Context, req planmodifier.SetReq if utils.IsAllStateUnknown(ctx, req.State) { return } - if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) { - return - } resp.PlanValue = req.StateValue } diff --git a/internal/planmodifiers/stringplanmodifier/suppress_diff.go b/internal/planmodifiers/stringplanmodifier/suppress_diff.go index e8e6d0b..c7e5980 100644 --- a/internal/planmodifiers/stringplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/stringplanmodifier/suppress_diff.go @@ -10,8 +10,6 @@ import ( ) const ( - // Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions] - Standard = iota // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation ExplicitSuppress = iota ) @@ -53,9 +51,6 @@ func (m suppressDiff) PlanModifyString(ctx context.Context, req planmodifier.Str if utils.IsAllStateUnknown(ctx, req.State) { return } - if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) { - return - } resp.PlanValue = req.StateValue } diff --git a/internal/planmodifiers/utils/state_check.go b/internal/planmodifiers/utils/state_check.go index 9b087eb..66d9150 100644 --- a/internal/planmodifiers/utils/state_check.go +++ b/internal/planmodifiers/utils/state_check.go @@ -23,91 +23,3 @@ func IsAllStateUnknown(ctx context.Context, state tfsdk.State) bool { return !anyFound } - -func IsAnyKnownChange(ctx context.Context, plan tfsdk.Plan, state tfsdk.State) bool { - attrs := state.Schema.GetAttributes() - anyFound := false - for k, _ := range attrs { - stateValue := new(attr.Value) - planValue := new(attr.Value) - state.GetAttribute(ctx, path.Root(k), stateValue) - plan.GetAttribute(ctx, path.Root(k), planValue) - anyFound = !isKnownEqual(ctx, stateValue, planValue) - if anyFound { - break - } - } - - return anyFound -} - -type HasElements interface { - Elements() []attr.Value - IsUnknown() bool - IsNull() bool -} -type HasAttributes interface { - Attributes() map[string]attr.Value - IsUnknown() bool - IsNull() bool -} - -func isKnownEqual(ctx context.Context, a *attr.Value, b *attr.Value) bool { - if (*a).IsUnknown() || (*b).IsUnknown() { - return true - } - aType := (*a).Type(ctx) - bType := (*b).Type(ctx) - if !aType.Equal(bType) { - return false - } - attributeTypes, ok := aType.(attr.TypeWithAttributeTypes) - if ok { - check := true - for k, _ := range attributeTypes.AttributeTypes() { - objValA, isObjA := (*a).(HasAttributes) - objValB, isObjB := (*b).(HasAttributes) - if isObjA && isObjB { - if objValA.IsUnknown() || objValB.IsUnknown() { - continue - } - attrA, foundA := objValA.Attributes()[k] - attrB, foundB := objValB.Attributes()[k] - if foundA != foundB { - return false - } - if foundA { - check = isKnownEqual(ctx, &attrA, &attrB) - } - } - if !check { - break - } - } - return check - } - _, ok = aType.(attr.TypeWithElementType) - if ok { - aVal, aValList := (*a).(HasElements) - bVal, bValList := (*b).(HasElements) - if aValList && bValList { - if ((aVal).IsUnknown() || (aVal).IsNull()) && ((bVal).IsUnknown() || (bVal).IsNull()) { - return true - } - if len(aVal.Elements()) != len(bVal.Elements()) { - return false - } else { - for i, _ := range aVal.Elements() { - if !isKnownEqual(ctx, &aVal.Elements()[i], &bVal.Elements()[i]) { - return false - } - } - } - return true - } - return false - } - - isEqual := (*a).Equal(*b) - return isEqual -} diff --git a/internal/sdk/sdk.go b/internal/sdk/sdk.go index 80b9913..15f24e0 100644 --- a/internal/sdk/sdk.go +++ b/internal/sdk/sdk.go @@ -161,9 +161,9 @@ func New(opts ...SDKOption) *Vercel { sdkConfiguration: sdkConfiguration{ Language: "go", OpenAPIDocVersion: "0.0.1", - SDKVersion: "0.10.0", - GenVersion: "2.228.1", - UserAgent: "speakeasy-sdk/go 0.10.0 2.228.1 0.0.1 vercel", + SDKVersion: "0.10.1", + GenVersion: "2.230.1", + UserAgent: "speakeasy-sdk/go 0.10.1 2.230.1 0.0.1 vercel", }, } for _, opt := range opts { diff --git a/internal/validators/boolvalidators/not_null.go b/internal/validators/boolvalidators/not_null.go new file mode 100644 index 0000000..45e2e97 --- /dev/null +++ b/internal/validators/boolvalidators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package boolvalidators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Bool = BoolNotNullValidator{} + +// BoolNotNullValidator validates that an attribute is not null. Most +// attributes should set Required: true instead, however in certain scenarios, +// such as a computed nested attribute, all underlying attributes must also be +// computed for planning to not show unexpected differences. +type BoolNotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v BoolNotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v BoolNotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v BoolNotNullValidator) ValidateBool(ctx context.Context, req validator.BoolRequest, resp *validator.BoolResponse) { + if !req.ConfigValue.IsNull() { + return + } + + resp.Diagnostics.AddAttributeError( + req.Path, + "Missing Attribute Value", + req.Path.String()+": "+v.Description(ctx), + ) +} + +// NotNull returns an validator which ensures that the attribute is +// configured. Most attributes should set Required: true instead, however in +// certain scenarios, such as a computed nested attribute, all underlying +// attributes must also be computed for planning to not show unexpected +// differences. +func NotNull() validator.Bool { + return BoolNotNullValidator{} +} diff --git a/internal/validators/float64validators/not_null.go b/internal/validators/float64validators/not_null.go new file mode 100644 index 0000000..75099c2 --- /dev/null +++ b/internal/validators/float64validators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package float64validators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Float64 = Float64NotNullValidator{} + +// Float64NotNullValidator validates that an attribute is not null. Most +// attributes should set Required: true instead, however in certain scenarios, +// such as a computed nested attribute, all underlying attributes must also be +// computed for planning to not show unexpected differences. +type Float64NotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v Float64NotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v Float64NotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v Float64NotNullValidator) ValidateFloat64(ctx context.Context, req validator.Float64Request, resp *validator.Float64Response) { + if !req.ConfigValue.IsNull() { + return + } + + resp.Diagnostics.AddAttributeError( + req.Path, + "Missing Attribute Value", + req.Path.String()+": "+v.Description(ctx), + ) +} + +// NotNull returns an validator which ensures that the attribute is +// configured. Most attributes should set Required: true instead, however in +// certain scenarios, such as a computed nested attribute, all underlying +// attributes must also be computed for planning to not show unexpected +// differences. +func NotNull() validator.Float64 { + return Float64NotNullValidator{} +} diff --git a/internal/validators/int64validators/not_null.go b/internal/validators/int64validators/not_null.go new file mode 100644 index 0000000..32192d8 --- /dev/null +++ b/internal/validators/int64validators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package int64validators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Int64 = Int64NotNullValidator{} + +// Int64NotNullValidator validates that an attribute is not null. Most +// attributes should set Required: true instead, however in certain scenarios, +// such as a computed nested attribute, all underlying attributes must also be +// computed for planning to not show unexpected differences. +type Int64NotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v Int64NotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v Int64NotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v Int64NotNullValidator) ValidateInt64(ctx context.Context, req validator.Int64Request, resp *validator.Int64Response) { + if !req.ConfigValue.IsNull() { + return + } + + resp.Diagnostics.AddAttributeError( + req.Path, + "Missing Attribute Value", + req.Path.String()+": "+v.Description(ctx), + ) +} + +// NotNull returns an validator which ensures that the attribute is +// configured. Most attributes should set Required: true instead, however in +// certain scenarios, such as a computed nested attribute, all underlying +// attributes must also be computed for planning to not show unexpected +// differences. +func NotNull() validator.Int64 { + return Int64NotNullValidator{} +} diff --git a/internal/validators/listvalidators/not_null.go b/internal/validators/listvalidators/not_null.go new file mode 100644 index 0000000..c7bfa6e --- /dev/null +++ b/internal/validators/listvalidators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package listvalidators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.List = ListNotNullValidator{} + +// ListNotNullValidator validates that an attribute is not null. Most +// attributes should set Required: true instead, however in certain scenarios, +// such as a computed nested attribute, all underlying attributes must also be +// computed for planning to not show unexpected differences. +type ListNotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v ListNotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v ListNotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v ListNotNullValidator) ValidateList(ctx context.Context, req validator.ListRequest, resp *validator.ListResponse) { + if !req.ConfigValue.IsNull() { + return + } + + resp.Diagnostics.AddAttributeError( + req.Path, + "Missing Attribute Value", + req.Path.String()+": "+v.Description(ctx), + ) +} + +// NotNull returns an validator which ensures that the attribute is +// configured. Most attributes should set Required: true instead, however in +// certain scenarios, such as a computed nested attribute, all underlying +// attributes must also be computed for planning to not show unexpected +// differences. +func NotNull() validator.List { + return ListNotNullValidator{} +} diff --git a/internal/validators/mapvalidators/not_null.go b/internal/validators/mapvalidators/not_null.go new file mode 100644 index 0000000..7d22172 --- /dev/null +++ b/internal/validators/mapvalidators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package mapvalidators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Map = MapNotNullValidator{} + +// MapNotNullValidator validates that an attribute is not null. Most +// attributes should set Required: true instead, however in certain scenarios, +// such as a computed nested attribute, all underlying attributes must also be +// computed for planning to not show unexpected differences. +type MapNotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v MapNotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v MapNotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v MapNotNullValidator) ValidateMap(ctx context.Context, req validator.MapRequest, resp *validator.MapResponse) { + if !req.ConfigValue.IsNull() { + return + } + + resp.Diagnostics.AddAttributeError( + req.Path, + "Missing Attribute Value", + req.Path.String()+": "+v.Description(ctx), + ) +} + +// NotNull returns an validator which ensures that the attribute is +// configured. Most attributes should set Required: true instead, however in +// certain scenarios, such as a computed nested attribute, all underlying +// attributes must also be computed for planning to not show unexpected +// differences. +func NotNull() validator.Map { + return MapNotNullValidator{} +} diff --git a/internal/validators/numbervalidators/not_null.go b/internal/validators/numbervalidators/not_null.go new file mode 100644 index 0000000..b085170 --- /dev/null +++ b/internal/validators/numbervalidators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package numbervalidators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Number = NumberNotNullValidator{} + +// NumberNotNullValidator validates that an attribute is not null. Most +// attributes should set Required: true instead, however in certain scenarios, +// such as a computed nested attribute, all underlying attributes must also be +// computed for planning to not show unexpected differences. +type NumberNotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v NumberNotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v NumberNotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v NumberNotNullValidator) ValidateNumber(ctx context.Context, req validator.NumberRequest, resp *validator.NumberResponse) { + if !req.ConfigValue.IsNull() { + return + } + + resp.Diagnostics.AddAttributeError( + req.Path, + "Missing Attribute Value", + req.Path.String()+": "+v.Description(ctx), + ) +} + +// NotNull returns an validator which ensures that the attribute is +// configured. Most attributes should set Required: true instead, however in +// certain scenarios, such as a computed nested attribute, all underlying +// attributes must also be computed for planning to not show unexpected +// differences. +func NotNull() validator.Number { + return NumberNotNullValidator{} +} diff --git a/internal/validators/objectvalidators/not_null.go b/internal/validators/objectvalidators/not_null.go new file mode 100644 index 0000000..c45ca8d --- /dev/null +++ b/internal/validators/objectvalidators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package objectvalidators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Object = ObjectNotNullValidator{} + +// ObjectNotNullValidator validates that an attribute is not null. Most +// attributes should set Required: true instead, however in certain scenarios, +// such as a computed nested attribute, all underlying attributes must also be +// computed for planning to not show unexpected differences. +type ObjectNotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v ObjectNotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v ObjectNotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v ObjectNotNullValidator) ValidateObject(ctx context.Context, req validator.ObjectRequest, resp *validator.ObjectResponse) { + if !req.ConfigValue.IsNull() { + return + } + + resp.Diagnostics.AddAttributeError( + req.Path, + "Missing Attribute Value", + req.Path.String()+": "+v.Description(ctx), + ) +} + +// NotNull returns an validator which ensures that the attribute is +// configured. Most attributes should set Required: true instead, however in +// certain scenarios, such as a computed nested attribute, all underlying +// attributes must also be computed for planning to not show unexpected +// differences. +func NotNull() validator.Object { + return ObjectNotNullValidator{} +} diff --git a/internal/validators/setvalidators/not_null.go b/internal/validators/setvalidators/not_null.go new file mode 100644 index 0000000..23d6c16 --- /dev/null +++ b/internal/validators/setvalidators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package setvalidators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Set = SetNotNullValidator{} + +// SetNotNullValidator validates that an attribute is not null. Most +// attributes should set Required: true instead, however in certain scenarios, +// such as a computed nested attribute, all underlying attributes must also be +// computed for planning to not show unexpected differences. +type SetNotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v SetNotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v SetNotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v SetNotNullValidator) ValidateSet(ctx context.Context, req validator.SetRequest, resp *validator.SetResponse) { + if !req.ConfigValue.IsNull() { + return + } + + resp.Diagnostics.AddAttributeError( + req.Path, + "Missing Attribute Value", + req.Path.String()+": "+v.Description(ctx), + ) +} + +// NotNull returns an validator which ensures that the attribute is +// configured. Most attributes should set Required: true instead, however in +// certain scenarios, such as a computed nested attribute, all underlying +// attributes must also be computed for planning to not show unexpected +// differences. +func NotNull() validator.Set { + return SetNotNullValidator{} +} diff --git a/internal/validators/stringvalidators/not_null.go b/internal/validators/stringvalidators/not_null.go new file mode 100644 index 0000000..f15f8ae --- /dev/null +++ b/internal/validators/stringvalidators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package stringvalidators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.String = StringNotNullValidator{} + +// StringNotNullValidator validates that an attribute is not null. Most +// attributes should set Required: true instead, however in certain scenarios, +// such as a computed nested attribute, all underlying attributes must also be +// computed for planning to not show unexpected differences. +type StringNotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v StringNotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v StringNotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v StringNotNullValidator) ValidateString(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse) { + if !req.ConfigValue.IsNull() { + return + } + + resp.Diagnostics.AddAttributeError( + req.Path, + "Missing Attribute Value", + req.Path.String()+": "+v.Description(ctx), + ) +} + +// NotNull returns an validator which ensures that the attribute is +// configured. Most attributes should set Required: true instead, however in +// certain scenarios, such as a computed nested attribute, all underlying +// attributes must also be computed for planning to not show unexpected +// differences. +func NotNull() validator.String { + return StringNotNullValidator{} +}