Skip to content

Commit

Permalink
use validator to mark object as required
Browse files Browse the repository at this point in the history
  • Loading branch information
skarimo committed Aug 9, 2023
1 parent dc1060c commit 7dc58f0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 36 deletions.
4 changes: 2 additions & 2 deletions datadog/fwprovider/resource_datadog_downtime_schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ func (r *DowntimeScheduleResource) Schema(_ context.Context, _ resource.SchemaRe
ElementType: types.StringType,
},
},
PlanModifiers: []planmodifier.Object{
planmodifiers.ObjectRequired(),
Validators: []validator.Object{
objectvalidator.IsRequired(),
},
},
"one_time_schedule": schema.SingleNestedBlock{
Expand Down
11 changes: 6 additions & 5 deletions datadog/fwprovider/resource_datadog_spans_metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ import (
"context"

"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
"github.com/hashicorp/terraform-plugin-framework-validators/objectvalidator"
"github.com/hashicorp/terraform-plugin-framework/diag"
frameworkPath "github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"

"github.com/terraform-providers/terraform-provider-datadog/datadog/internal/planmodifiers"
"github.com/terraform-providers/terraform-provider-datadog/datadog/internal/utils"
)

Expand Down Expand Up @@ -114,8 +115,8 @@ func (r *spansMetricResource) Schema(_ context.Context, _ resource.SchemaRequest
// This attritbute is treated as required by the framework sdk.
// See: https://github.com/hashicorp/terraform-plugin-framework/issues/740
// In case this will be allowed in the future, explicitly add validation to the object.
PlanModifiers: []planmodifier.Object{
planmodifiers.ObjectRequired(),
Validators: []validator.Object{
objectvalidator.IsRequired(),
},
},
"filter": schema.SingleNestedBlock{
Expand All @@ -129,8 +130,8 @@ func (r *spansMetricResource) Schema(_ context.Context, _ resource.SchemaRequest
},
// This field is marked as required for now since the framework does not allow
// blocks with default values.
PlanModifiers: []planmodifier.Object{
planmodifiers.ObjectRequired(),
Validators: []validator.Object{
objectvalidator.IsRequired(),
},
},
},
Expand Down
29 changes: 0 additions & 29 deletions datadog/internal/planmodifiers/types_object_required.go

This file was deleted.

0 comments on commit 7dc58f0

Please sign in to comment.