Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

Add debug property to provider #36

Merged
merged 2 commits into from
Aug 23, 2018

Conversation

hypnoglow
Copy link
Contributor

Cannot check if this actually works right now, because we need to have updated vendored go-auth0 with this go-auth0/auth0#11.

So this is a WIP until vendors are updated.

@@ -44,6 +49,7 @@ func configure(data *schema.ResourceData) (interface{}, error) {
domain := data.Get("domain").(string)
id := data.Get("client_id").(string)
secret := data.Get("client_secret").(string)
debug := data.Get("debug").(bool)
Copy link
Owner

Choose a reason for hiding this comment

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

I believe this is why the build fails, its defined as a string?

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 know, sorry, this is just a draft yet ;)

Copy link
Owner

Choose a reason for hiding this comment

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

No worries :)

Copy link
Owner

@alexkappa alexkappa left a comment

Choose a reason for hiding this comment

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

I've went ahead and pushed a new tag with your changes in yieldr/go-auth, so please feel free to update vendors.

You can do that with dep ensure -update github.com/yieldr/go-auth0

@hypnoglow hypnoglow changed the title WIP: Add debug property to provider Add debug property to provider Aug 20, 2018
"debug": {
Type: schema.TypeBool,
Optional: true,
DefaultFunc: func() (interface{}, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can't just use schema.EnvDefaultFunc here because it returns the variable value as a string, but we need bool.

Copy link
Owner

@alexkappa alexkappa Aug 21, 2018

Choose a reason for hiding this comment

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

Perhaps we don't need to use env vars for this, and allow defining it only via the provider config (tf). For example to enable debug we could do:

provider "auth0" {
    debug = "true"
}

I took this example from the aws provider, which only looks for certain env vars (that are usually defined in the host system) and for others you must configure it yourself. Example: https://github.com/terraform-providers/terraform-provider-aws/blob/master/aws/provider.go#L60-L76

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For aws, I think the core reason is that the provider just supports "well-known" environment variables, and no specific "provider" environment variables..

Personally, I think "debug" is more like a dynamic property than a static one. It would be convenient for me just using export TF_LOG=debug and export AUTH0_DEBUG=true if I want to debug auth0 requests temporary. If I would have to change tf file, I could end up accidentally committing this or something.

Still, if you don't think that it can be convenient, I can remove the support for environment variable.

Copy link
Owner

Choose a reason for hiding this comment

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

Yes, I see your point in that it would be a nuisance to change it in the file. Lets keep it then with env vars and see how it goes ;)

@hypnoglow
Copy link
Contributor Author

Updated vendors, added code for processing "debug" property.

@alexkappa alexkappa merged commit 123b9ba into alexkappa:master Aug 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants