-
Notifications
You must be signed in to change notification settings - Fork 89
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
Make auth0_branding_theme
fields optional
#499
Conversation
Hey @sergiught I might be running into a similar issue with the HTTP test recordings! When I try to recreate the recording using
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @nialdaly thanks for picking this one up! 💪🏻
The issue with the tests is that the old interactions weren't deleted before regenerating them. It's the first warning in the contribution section here https://github.com/auth0/terraform-provider-auth0/blob/main/CONTRIBUTING.md#adding-new-http-test-recordings. Unfortunately the make test-acc-record
command doesn't do that yet (we were discussing internally whether we wanted to add that capability or not but decided to skip it for now as the FILTER is pretty much a regex and we could delete more files than desired).
After doing that would you mind adding a couple of new tests to ensure we can create a branding theme only with required properties? 🙏🏻
Don't hesitate to ping again if I can clarify further or help.
Thanks for getting back to me! @sergiught
I was also wondering, now that all of the required fields are actually optional, what would be your recommended way to test that? |
Codecov ReportBase: 87.15% // Head: 86.96% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #499 +/- ##
==========================================
- Coverage 87.15% 86.96% -0.20%
==========================================
Files 62 64 +2
Lines 9631 9679 +48
==========================================
+ Hits 8394 8417 +23
- Misses 946 973 +27
+ Partials 291 289 -2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
docs/index.md
Outdated
@@ -33,17 +33,14 @@ better alternative. | |||
<!-- schema generated by tfplugindocs --> | |||
## Schema | |||
|
|||
### Required |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be part of this PR. You probably just ran "make docs" and it did this automatically. The CI step that runs make docs keeps the domain in the required section but if you have a specific version of terraform and go locally it will move it to the optional block. I plan to fix this in the upcoming days, but for now let's discard this change please 🙏🏻
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"buttons_style": { | ||
Type: schema.TypeString, | ||
ValidateFunc: validation.StringInSlice([]string{"pill", "rounded", "sharp"}, false), | ||
Required: true, | ||
Optional: true, | ||
Default: "rounded", | ||
Description: "Buttons style. Available options: `pill`, `rounded`, `sharp`.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we please update as well all the descriptions to mention what the default value will be 🙏🏻 ? e.g.
Description: "Buttons style. Available options: `pill`, `rounded`, `sharp`.", | |
Description: "Buttons style. Available options: `pill`, `rounded`, `sharp`. Defaults to `rounded`. ", |
status: 204 No Content | ||
code: 204 | ||
duration: 1ms | ||
- id: 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding your testing question, we could probably have another step that doesn't set any of the options and then checks that the defaults get applied. e.g.
const testAccBrandingThemeCreate = `
resource auth0_branding_theme my_theme {
}
`
// ... and then add another test step to check defaults in the actual test func
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! @sergiught I've made the changes as requested and tried to get it to a point where none of the options are set and the defaults are applied. There may be a neater way of doing it, more than happy for you to push changes on this branch. Thanks!
Hey @nialdaly 👋🏻 I can make some time today to help with the changes requested if needed and push on top of your branch. Just let me know:) |
Heads up @nialdaly I'll make some time to take a look at this again and push some changes today. |
borders {} | ||
colors {} | ||
fonts { | ||
title {} | ||
subtitle {} | ||
links {} | ||
input_labels {} | ||
buttons_text {} | ||
body_text {} | ||
} | ||
page_background {} | ||
widget {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a couple of problems and challenges to allow setting the minimal configuration for this resource to:
resource "auth0_branding_theme" "my_theme" { }
- If we set all the
TypeList
elements toOptional
we can't ensure that theMinItems
count is 1 because that is ignored whenOptional
is true. - We can't use the
Default
property onTypeList
orTypeSets
. From the docs:
// Default cannot be used if the Schema is directly an
// implementation of an Elem field of another Schema, such as trying to
// set a default value for a TypeList or TypeSet.
To work around this I've noticed that your attempt @nialdaly was to handle this within the expandBrandingTheme
func, however that opens us up for serious drifts between the default values we set on the schema and potential erroneous changes of the default values within the expand func.
So to keep just the defaults on the schema as the only sources of truth we're requiring all the TypeList
blocks to be set within the config at least as empty. The example highlighted here in the code above.
I'm not sure if you're an active user of this resource @nialdaly but what do you think of this? Tagging as well @TiltUp-Rad as the reporter of the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sergiught my initial approach was to require all of the blocks and then I went down the rabbit hole of trying to achieve the minimal configuration. I'm not an active user but I think the approach you suggest makes sense as the API does actually require the values!
Awesome contribution @nialdaly 🥳 thanks again! |
Summary
This PR aims to close this issue.