Skip to content

Commit 598979e

Browse files
committed
log drains validations
1 parent 24b16ae commit 598979e

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

internal/provider/log_drain_resource.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
1919
"github.com/hashicorp/terraform-plugin-framework/types"
2020
"github.com/netlify/terraform-provider-netlify/internal/netlifyapi"
21+
"github.com/netlify/terraform-provider-netlify/internal/provider/netlify_validators"
2122
)
2223

2324
var (
@@ -112,6 +113,26 @@ func (r *logDrainResource) Schema(_ context.Context, _ resource.SchemaRequest, r
112113
"axiom",
113114
"azure",
114115
),
116+
// TODO: These are partial validations, need to be completed
117+
netlify_validators.RequiredIfEquals("datadog", path.MatchRoot("service_config").AtName("url")),
118+
netlify_validators.ForbiddenIfEquals( // Must be part of the URL
119+
"datadog",
120+
path.MatchRoot("service_config").AtName("tags"),
121+
path.MatchRoot("service_config").AtName("authorization_header"),
122+
),
123+
netlify_validators.RequiredIfEquals(
124+
"newrelic",
125+
path.MatchRoot("service_config").AtName("url"),
126+
path.MatchRoot("service_config").AtName("tags"),
127+
),
128+
netlify_validators.RequiredIfEquals("http", path.MatchRoot("service_config").AtName("url")),
129+
netlify_validators.RequiredIfEquals(
130+
"s3",
131+
path.MatchRoot("service_config").AtName("bucket_name"),
132+
path.MatchRoot("service_config").AtName("bucket_region"),
133+
path.MatchRoot("service_config").AtName("path"),
134+
path.MatchRoot("service_config").AtName("verification_filename"),
135+
),
115136
},
116137
},
117138
"format": schema.StringAttribute{
@@ -133,7 +154,6 @@ func (r *logDrainResource) Schema(_ context.Context, _ resource.SchemaRequest, r
133154
},
134155
"service_config": schema.SingleNestedAttribute{
135156
Required: true,
136-
// TODO: add validations based on the destination type
137157
Attributes: map[string]schema.Attribute{
138158
"url": schema.StringAttribute{
139159
Optional: true,

0 commit comments

Comments
 (0)