Skip to content

Commit

Permalink
Fixed custom destination creation failing without forward_tags_restri…
Browse files Browse the repository at this point in the history
…ction_list (#2565)
  • Loading branch information
Prepager authored Sep 6, 2024
1 parent 4e54cb8 commit 53c4c1a
Show file tree
Hide file tree
Showing 6 changed files with 500 additions and 350 deletions.
28 changes: 12 additions & 16 deletions datadog/fwprovider/resource_datadog_logs_custom_destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,29 +489,27 @@ func (r *logsCustomDestinationResource) buildLogsCustomDestinationCreateRequestB
attributes.SetForwarderDestination(*forwarderDestination)
}

if !state.Name.IsNull() {
attributes.SetName(state.Name.ValueString())
}
attributes.SetName(state.Name.ValueString())

if !state.Query.IsNull() {
if !state.Query.IsUnknown() {
attributes.SetQuery(state.Query.ValueString())
}

if !state.Enabled.IsNull() {
if !state.Enabled.IsUnknown() {
attributes.SetEnabled(state.Enabled.ValueBool())
}

if !state.ForwardTags.IsNull() {
if !state.ForwardTags.IsUnknown() {
attributes.SetForwardTags(state.ForwardTags.ValueBool())
}

if !state.ForwardTagsRestrictionList.IsNull() {
if !state.ForwardTagsRestrictionList.IsUnknown() {
var forwardTagsRestrictionList []string
diags.Append(state.ForwardTagsRestrictionList.ElementsAs(ctx, &forwardTagsRestrictionList, false)...)
attributes.SetForwardTagsRestrictionList(forwardTagsRestrictionList)
}

if !state.ForwardTagsRestrictionListType.IsNull() {
if !state.ForwardTagsRestrictionListType.IsUnknown() {
forwardTagsRestrictionListType, err := datadogV2.NewCustomDestinationAttributeTagsRestrictionListTypeFromValue(state.ForwardTagsRestrictionListType.ValueString())
if err == nil {
attributes.SetForwardTagsRestrictionListType(*forwardTagsRestrictionListType)
Expand All @@ -534,29 +532,27 @@ func (r *logsCustomDestinationResource) buildLogsCustomDestinationUpdateRequestB
attributes.SetForwarderDestination(*forwarderDestination)
}

if !state.Name.IsNull() {
attributes.SetName(state.Name.ValueString())
}
attributes.SetName(state.Name.ValueString())

if !state.Query.IsNull() {
if !state.Query.IsUnknown() {
attributes.SetQuery(state.Query.ValueString())
}

if !state.Enabled.IsNull() {
if !state.Enabled.IsUnknown() {
attributes.SetEnabled(state.Enabled.ValueBool())
}

if !state.ForwardTags.IsNull() {
if !state.ForwardTags.IsUnknown() {
attributes.SetForwardTags(state.ForwardTags.ValueBool())
}

if !state.ForwardTagsRestrictionList.IsNull() {
if !state.ForwardTagsRestrictionList.IsUnknown() {
var forwardTagsRestrictionList []string
diags.Append(state.ForwardTagsRestrictionList.ElementsAs(ctx, &forwardTagsRestrictionList, false)...)
attributes.SetForwardTagsRestrictionList(forwardTagsRestrictionList)
}

if !state.ForwardTagsRestrictionListType.IsNull() {
if !state.ForwardTagsRestrictionListType.IsUnknown() {
forwardTagsRestrictionListType, err := datadogV2.NewCustomDestinationAttributeTagsRestrictionListTypeFromValue(state.ForwardTagsRestrictionListType.ValueString())
if err == nil {
attributes.SetForwardTagsRestrictionListType(*forwardTagsRestrictionListType)
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-09-04T21:44:08.351625+02:00
2024-09-06T16:56:04.416023+02:00
Loading

0 comments on commit 53c4c1a

Please sign in to comment.