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

Make auth0_branding_theme fields optional #499

Merged
merged 4 commits into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 79 additions & 62 deletions docs/resources/branding_theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@ This resource allows you to manage branding themes for your Universal Login page
## Example Usage

```terraform
# An example of the auth0_branding_theme using defaults for all the attributes.
resource "auth0_branding_theme" "my_theme" {
borders {}
colors {}
fonts {
title {}
subtitle {}
links {}
input_labels {}
buttons_text {}
body_text {}
}
page_background {}
widget {}
Comment on lines +16 to +27
Copy link
Contributor

@sergiught sergiught Feb 24, 2023

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" { }
  1. If we set all the TypeList elements to Optional we can't ensure that the MinItems count is 1 because that is ignored when Optional is true.
  2. We can't use the Default property on TypeList or TypeSets. 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.

Copy link
Contributor Author

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!

}

# An example of a fully configured auth0_branding_theme.
resource "auth0_branding_theme" "my_theme" {
borders {
button_border_radius = 1
Expand Down Expand Up @@ -117,45 +134,42 @@ resource "auth0_branding_theme" "my_theme" {
<a id="nestedblock--borders"></a>
### Nested Schema for `borders`

Required:
Optional:

- `button_border_radius` (Number) Button border radius. Value needs to be between `1` and `10`.
- `button_border_weight` (Number) Button border weight. Value needs to be between `0` and `10`.
- `buttons_style` (String) Buttons style. Available options: `pill`, `rounded`, `sharp`.
- `input_border_radius` (Number) Input border radius. Value needs to be between `0` and `10`.
- `input_border_weight` (Number) Input border weight. Value needs to be between `0` and `3`.
- `inputs_style` (String) Inputs style. Available options: `pill`, `rounded`, `sharp`.
- `show_widget_shadow` (Boolean) Show widget shadow.
- `widget_border_weight` (Number) Widget border weight. Value needs to be between `0` and `10`.
- `widget_corner_radius` (Number) Widget corner radius. Value needs to be between `0` and `50`.
- `button_border_radius` (Number) Button border radius. Value needs to be between `1` and `10`. Defaults to `3.0`.
- `button_border_weight` (Number) Button border weight. Value needs to be between `0` and `10`. Defaults to `1.0`.
- `buttons_style` (String) Buttons style. Available options: `pill`, `rounded`, `sharp`. Defaults to `rounded`.
- `input_border_radius` (Number) Input border radius. Value needs to be between `0` and `10`. Defaults to `3.0`.
- `input_border_weight` (Number) Input border weight. Value needs to be between `0` and `3`. Defaults to `1.0`.
- `inputs_style` (String) Inputs style. Available options: `pill`, `rounded`, `sharp`. Defaults to `rounded`.
- `show_widget_shadow` (Boolean) Show widget shadow. Defaults to `true`.
- `widget_border_weight` (Number) Widget border weight. Value needs to be between `0` and `10`. Defaults to `0.0`.
- `widget_corner_radius` (Number) Widget corner radius. Value needs to be between `0` and `50`. Defaults to `5.0`.


<a id="nestedblock--colors"></a>
### Nested Schema for `colors`

Required:

- `body_text` (String) Body text.
- `error` (String) Error.
- `header` (String) Header.
- `icons` (String) Icons.
- `input_background` (String) Input background.
- `input_border` (String) Input border.
- `input_filled_text` (String) Input filled text.
- `input_labels_placeholders` (String) Input labels & placeholders.
- `links_focused_components` (String) Links & focused components.
- `primary_button` (String) Primary button.
- `primary_button_label` (String) Primary button label.
- `secondary_button_border` (String) Secondary button border.
- `secondary_button_label` (String) Secondary button label.
- `success` (String) Success.
- `widget_background` (String) Widget background.
- `widget_border` (String) Widget border.

Optional:

- `base_focus_color` (String) Base focus color.
- `base_hover_color` (String) Base hover color.
- `base_focus_color` (String) Base focus color. Defaults to `#635dff`.
- `base_hover_color` (String) Base hover color. Defaults to `#000000`.
- `body_text` (String) Body text. Defaults to `#1e212a`.
- `error` (String) Error. Defaults to `#d03c38`.
- `header` (String) Header. Defaults to `#1e212a`.
- `icons` (String) Icons. Defaults to `#65676e`.
- `input_background` (String) Input background. Defaults to `#ffffff`.
- `input_border` (String) Input border. Defaults to `#c9cace`.
- `input_filled_text` (String) Input filled text. Defaults to `#000000`.
- `input_labels_placeholders` (String) Input labels & placeholders. Defaults to `#65676e`.
- `links_focused_components` (String) Links & focused components. Defaults to `#635dff`.
- `primary_button` (String) Primary button. Defaults to `#635dff`.
- `primary_button_label` (String) Primary button label. Defaults to `#ffffff`.
- `secondary_button_border` (String) Secondary button border. Defaults to `#c9cace`.
- `secondary_button_label` (String) Secondary button label. Defaults to `#1e212a`.
- `success` (String) Success. Defaults to `#13a688`.
- `widget_background` (String) Widget background. Defaults to `#ffffff`.
- `widget_border` (String) Widget border. Defaults to `#c9cace`.


<a id="nestedblock--fonts"></a>
Expand All @@ -165,89 +179,92 @@ Required:

- `body_text` (Block List, Min: 1, Max: 1) Body text. (see [below for nested schema](#nestedblock--fonts--body_text))
- `buttons_text` (Block List, Min: 1, Max: 1) Buttons text. (see [below for nested schema](#nestedblock--fonts--buttons_text))
- `font_url` (String) Font URL.
- `input_labels` (Block List, Min: 1, Max: 1) Input labels. (see [below for nested schema](#nestedblock--fonts--input_labels))
- `links` (Block List, Min: 1, Max: 1) Links. (see [below for nested schema](#nestedblock--fonts--links))
- `links_style` (String) Links style.
- `reference_text_size` (Number) Reference text size. Value needs to be between `12` and `24`.
- `subtitle` (Block List, Min: 1, Max: 1) Subtitle. (see [below for nested schema](#nestedblock--fonts--subtitle))
- `title` (Block List, Min: 1, Max: 1) Title. (see [below for nested schema](#nestedblock--fonts--title))

Optional:

- `font_url` (String) Font URL. Defaults to an empty string.
- `links_style` (String) Links style. Defaults to `normal`.
- `reference_text_size` (Number) Reference text size. Value needs to be between `12` and `24`. Defaults to `16.0`.

<a id="nestedblock--fonts--body_text"></a>
### Nested Schema for `fonts.body_text`

Required:
Optional:

- `bold` (Boolean) Body text bold.
- `size` (Number) Body text size. Value needs to be between `0` and `150`.
- `bold` (Boolean) Body text bold. Defaults to `false`.
- `size` (Number) Body text size. Value needs to be between `0` and `150`. Defaults to `87.5`.


<a id="nestedblock--fonts--buttons_text"></a>
### Nested Schema for `fonts.buttons_text`

Required:
Optional:

- `bold` (Boolean) Buttons text bold.
- `size` (Number) Buttons text size. Value needs to be between `0` and `150`.
- `bold` (Boolean) Buttons text bold. Defaults to `false`.
- `size` (Number) Buttons text size. Value needs to be between `0` and `150`. Defaults to `100.0`.


<a id="nestedblock--fonts--input_labels"></a>
### Nested Schema for `fonts.input_labels`

Required:
Optional:

- `bold` (Boolean) Input labels bold.
- `size` (Number) Input labels size. Value needs to be between `0` and `150`.
- `bold` (Boolean) Input labels bold. Defaults to `false`.
- `size` (Number) Input labels size. Value needs to be between `0` and `150`. Defaults to `100.0`.


<a id="nestedblock--fonts--links"></a>
### Nested Schema for `fonts.links`

Required:
Optional:

- `bold` (Boolean) Links bold.
- `size` (Number) Links size. Value needs to be between `0` and `150`.
- `bold` (Boolean) Links bold. Defaults to `true`.
- `size` (Number) Links size. Value needs to be between `0` and `150`. Defaults to `87.5`.


<a id="nestedblock--fonts--subtitle"></a>
### Nested Schema for `fonts.subtitle`

Required:
Optional:

- `bold` (Boolean) Subtitle bold.
- `size` (Number) Subtitle size. Value needs to be between `0` and `150`.
- `bold` (Boolean) Subtitle bold. Defaults to `false`.
- `size` (Number) Subtitle size. Value needs to be between `0` and `150`. Defaults to `87.5`.


<a id="nestedblock--fonts--title"></a>
### Nested Schema for `fonts.title`

Required:
Optional:

- `bold` (Boolean) Title bold.
- `size` (Number) Title size. Value needs to be between `75` and `150`.
- `bold` (Boolean) Title bold. Defaults to `false`.
- `size` (Number) Title size. Value needs to be between `75` and `150`. Defaults to `150.0`.



<a id="nestedblock--page_background"></a>
### Nested Schema for `page_background`

Required:
Optional:

- `background_color` (String) Background color.
- `background_image_url` (String) Background image url.
- `page_layout` (String) Page layout. Available options: `center`, `left`, `right`.
- `background_color` (String) Background color. Defaults to `#000000`.
- `background_image_url` (String) Background image url. Defaults to an empty string.
- `page_layout` (String) Page layout. Available options: `center`, `left`, `right`. Defaults to `center`.


<a id="nestedblock--widget"></a>
### Nested Schema for `widget`

Required:
Optional:

- `header_text_alignment` (String) Header text alignment. Available options: `center`, `left`, `right`.
- `logo_height` (Number) Logo height. Value needs to be between `1` and `100`.
- `logo_position` (String) Logo position. Available options: `center`, `left`, `right`, `none`.
- `logo_url` (String) Logo url.
- `social_buttons_layout` (String) Social buttons layout. Available options: `bottom`, `top`.
- `header_text_alignment` (String) Header text alignment. Available options: `center`, `left`, `right`. Defaults to `center`.
- `logo_height` (Number) Logo height. Value needs to be between `1` and `100`. Defaults to `52.0`.
- `logo_position` (String) Logo position. Available options: `center`, `left`, `right`, `none`. Defaults to `center`.
- `logo_url` (String) Logo url. Defaults to an empty string.
- `social_buttons_layout` (String) Social buttons layout. Available options: `bottom`, `top`. Defaults to `bottom`.

## Import

Expand Down
17 changes: 17 additions & 0 deletions examples/resources/auth0_branding_theme/resource.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# An example of the auth0_branding_theme using defaults for all the attributes.
resource "auth0_branding_theme" "my_theme" {
borders {}
colors {}
fonts {
title {}
subtitle {}
links {}
input_labels {}
buttons_text {}
body_text {}
}
page_background {}
widget {}
}

# An example of a fully configured auth0_branding_theme.
resource "auth0_branding_theme" "my_theme" {
borders {
button_border_radius = 1
Expand Down
4 changes: 4 additions & 0 deletions internal/auth0/branding/data_source_theme_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ resource "auth0_branding_theme" "my_theme" {
}

colors {
base_focus_color = "#635dff"
base_hover_color = "#000000"
body_text = "#FF00CC"
error = "#FF00CC"
header = "#FF00CC"
Expand Down Expand Up @@ -114,6 +116,8 @@ func TestAccDataSourceBrandingTheme(t *testing.T) {
resource.TestCheckResourceAttr("data.auth0_branding_theme.test", "borders.0.widget_border_weight", "1.11"),
resource.TestCheckResourceAttr("data.auth0_branding_theme.test", "borders.0.widget_corner_radius", "3.57"),
resource.TestCheckResourceAttr("data.auth0_branding_theme.test", "colors.#", "1"),
resource.TestCheckResourceAttr("data.auth0_branding_theme.test", "colors.0.base_focus_color", "#635dff"),
resource.TestCheckResourceAttr("data.auth0_branding_theme.test", "colors.0.base_hover_color", "#000000"),
resource.TestCheckResourceAttr("data.auth0_branding_theme.test", "colors.0.body_text", "#FF00CC"),
resource.TestCheckResourceAttr("data.auth0_branding_theme.test", "colors.0.error", "#FF00CC"),
resource.TestCheckResourceAttr("data.auth0_branding_theme.test", "colors.0.header", "#FF00CC"),
Expand Down
Loading