Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore diff to start on downtime resource #597

Merged
merged 4 commits into from
Jul 27, 2020
Merged

Conversation

therve
Copy link
Contributor

@therve therve commented Jul 24, 2020

If the start attributes generates a diff from a value to nothing, it
means that the attribute was never set to being with. Let's ignore the
diff in that case.

Closes #507

@@ -46,7 +46,7 @@ func resourceDatadogDowntime() *schema.Resource {
Optional: true,
DiffSuppressFunc: func(k, oldVal, newVal string, d *schema.ResourceData) bool {
_, startDatePresent := d.GetOk("start_date")
return startDatePresent
return startDatePresent || (newVal == "0" && oldVal != "0")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@therve can you add examples when the diff should (not) be supressed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return startDatePresent || (newVal == "0" && oldVal != "0")
// "start_date" is set or was previously set (oldVal != "0") and it is being removed (newVal == "0")
return startDatePresent || (oldVal != "0" && newVal == "0")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment, let me know if it makes sense.

@jirikuncar
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

therve added 2 commits July 24, 2020 14:27
If the start attributes generates a diff from a value to nothing, it
means that the attribute was never set to being with. Let's ignore the
diff in that case.

Closes #507
@therve therve force-pushed the therve/diff-downtime-start branch from 1210ae1 to 08160f3 Compare July 24, 2020 12:27
jirikuncar
jirikuncar previously approved these changes Jul 27, 2020
Copy link
Contributor

@jirikuncar jirikuncar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works well for previously created downtimes 👍

@therve therve merged commit 0c3ffaf into master Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

start is marked as optional in docs but it seems to be required? (datadog_downtime)
2 participants