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

provider: add "validate" option that can disable validation #474

Merged
merged 8 commits into from
Apr 30, 2020

Conversation

bendrucker
Copy link
Contributor

@bendrucker bendrucker commented Apr 18, 2020

This allows users to disable credential validation by setting validate = false in the provider configuration.

Use Case

I recently wrote some tests for a set of complex modules that abstract details of Datadog resources, e.g. monitors and synthetic tests. While I might E2E test these configurations in a dedicated sandbox account, initially I wanted to write tests that assert some of the contents of:

terraform plan -out ./plan.out
terraform show -json ./plan.out

The resulting JSON document has planned_resources and changed_resources. There's no existing state so I only care about the planned_resources. Currently these tests require valid credentials but they would pass just the same with mock credentials if validation could be disabled.

Closes #368

@enieuw
Copy link

enieuw commented Apr 20, 2020

+1 on this, we have a use case where we conditionally create DD resources. Right now even when no DD resources are created we need to provide the provider with valid credentials so this would help us improve that!

@bendrucker
Copy link
Contributor Author

Fixing the build, forgot to close a { 🤦‍♂️

Copy link
Contributor

@nmuesch nmuesch left a comment

Choose a reason for hiding this comment

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

Thanks @bendrucker for working on this! The code looks good. I left just one inline comment. Looks like there are also some conflicts based on some recent changes. Would you be able to address those?

datadog/provider.go Show resolved Hide resolved
@ghost ghost added size/S and removed size/XS labels Apr 30, 2020
@bendrucker
Copy link
Contributor Author

Changes:

  • Keys are now optional and validation is performed by the ConfigureFunc
  • Keys must not be set if validate is false, and must be set if validate = true
  • The docs explain this

Notes:

  • I opted not to use ConflictsWith since that expresses that entire attributes conflict regardless of values. If a user ends up setting validate = true and providing valid keys I don't want to treat that as an error.

@bendrucker bendrucker requested a review from nmuesch April 30, 2020 02:42
Copy link
Contributor

@nmuesch nmuesch left a comment

Choose a reason for hiding this comment

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

Left a couple last comments. (They're all really small)
Thanks again for the work here, and the docs 🙇!

datadog/provider.go Show resolved Hide resolved
datadog/provider.go Outdated Show resolved Hide resolved
website/docs/index.html.markdown Outdated Show resolved Hide resolved
website/docs/index.html.markdown Show resolved Hide resolved
@bendrucker
Copy link
Contributor Author

Changes made!

@bendrucker bendrucker requested a review from nmuesch April 30, 2020 19:53
Copy link
Contributor

@nmuesch nmuesch left a comment

Choose a reason for hiding this comment

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

Thanks for all the work here! Merging!

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

Successfully merging this pull request may close these issues.

Allow to use data source for Datadog IP anonymously (no api key requirement)
3 participants