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

netbox_webhook: add additional attributes #505

Merged
merged 3 commits into from
Nov 30, 2023

Conversation

Ikke
Copy link
Contributor

@Ikke Ikke commented Nov 29, 2023

This adds support for 2 additional attributes for the netbox_webhook resource:

  • additional_headers
  • conditions

This also fixes an issue with the body_template attribute, where terraform may keep showing changes to this field due to differences in json encoding:

~ body_template     = jsonencode( # whitespace changes
      {
          text = "This is a sample json"
      }
  )

Ikke added 3 commits November 29, 2023 14:54
Conditions are expected to returned as a json structure (not json
encoded string). In the provider schema, it's possible to model a map
with arbitrary typed values, so we have to provide this as a json
encoded string.

To prevent differently encoded json resulting in terraform showing
whitespace differences, we implement a DiffSuppresFunc that checks if
the old and new value are semantically equal. This mostly happens
because by default `json.Marshal()` in go omits whitespace, while
handcrafted json usually includes whitespace.
HCL is a superset of json. When providing json data through a heredoc,
terraform interprets it as an actual datastructure (maps / lists, etc)
and jsonencodes it itself.

Providing data like that will result in terraform always showing
whitespace changes like this:

```
~ body_template     = jsonencode( # whitespace changes
      {
          text = "This is a sample json"
      }
  )
```

Use a DiffSuppressFunc to only show changes when there are semantic
differences.
@fbreckle fbreckle merged commit 3f6ce8f into e-breuninger:master Nov 30, 2023
11 checks passed
@fbreckle
Copy link
Collaborator

I usually just merge when everything looks fine and no further chatting is required, so I want to take the extra time and say thank your for you contributions! :D

@Ikke
Copy link
Contributor Author

Ikke commented Nov 30, 2023

I usually just merge when everything looks fine and no further chatting is required, so I want to take the extra time and say thank your for you contributions! :D

Thanks, appreciate it, and you're welcome

@arjenvri
Copy link
Contributor

@fbreckle would it be possible to release a new version that includes this change? Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants