Skip to content

Commit 6809356

Browse files
authored
Merge pull request #1077 from PagerDuty/cjavier/device-type-validation
Skip validation for unknown push device type
2 parents d0aa4a9 + 87cf791 commit 6809356

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pagerdutyplugin/resource_pagerduty_user_contact_method.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ func (r *resourceUserContactMethod) ValidateConfig(ctx context.Context, req reso
8080
}
8181

8282
if cfg.Type.ValueString() == "push_notification_contact_method" {
83-
if allowed, got := []string{"android", "ios"}, cfg.DeviceType.ValueString(); !slices.Contains(allowed, got) {
84-
resp.Diagnostics.AddAttributeError(path.Root("device_type"), "Invalid value", fmt.Sprintf("Attribute device_type value must be one of %q, got %q", allowed, got))
85-
return
83+
if !cfg.DeviceType.IsNull() && !cfg.DeviceType.IsUnknown() {
84+
if allowed, got := []string{"android", "ios"}, cfg.DeviceType.ValueString(); !slices.Contains(allowed, got) {
85+
resp.Diagnostics.AddAttributeError(path.Root("device_type"), "Invalid value", fmt.Sprintf("Attribute device_type value must be one of %q, got %q", allowed, got))
86+
return
87+
}
8688
}
8789
}
8890

0 commit comments

Comments
 (0)