Skip to content

Commit

Permalink
Support HiddenValueDomainWhitelist (#35)
Browse files Browse the repository at this point in the history
* Support HiddenValueDomainWhitelist

* Run make docs

Co-authored-by: hirosassa <[email protected]>
  • Loading branch information
marcoquerque and hirosassa authored Sep 7, 2022
1 parent 373c1fd commit 9ebec06
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
1 change: 1 addition & 0 deletions docs/resources/user_attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ resource "looker_user_attribute" "my_user_attribute" {
### Optional

- `default_value` (String)
- `hidden_value_domain_whitelist` (String)
- `id` (String) The ID of this resource.
- `user_can_edit` (Boolean)
- `user_can_view` (Boolean)
Expand Down
40 changes: 26 additions & 14 deletions pkg/looker/resource_user_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ func resourceUserAttribute() *schema.Resource {
Type: schema.TypeBool,
Optional: true,
},
"hidden_value_domain_whitelist": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
},
}
}
Expand All @@ -61,15 +66,17 @@ func resourceUserAttributeCreate(ctx context.Context, d *schema.ResourceData, m
userAttributeValueIsHidden := d.Get("value_is_hidden").(bool)
userAttributeUserCanView := d.Get("user_can_view").(bool)
userAttributeUserCanEdit := d.Get("user_can_edit").(bool)
userAttributeHiddenValueDomainWhitelist := d.Get("hidden_value_domain_whitelist").(string)

writeUserAttribute := apiclient.WriteUserAttribute{
Name: userAttributeName,
Label: userAttributeLabel,
Type: userAttributeType,
DefaultValue: &userAttributeDefaultValue,
ValueIsHidden: &userAttributeValueIsHidden,
UserCanView: &userAttributeUserCanView,
UserCanEdit: &userAttributeUserCanEdit,
Name: userAttributeName,
Label: userAttributeLabel,
Type: userAttributeType,
DefaultValue: &userAttributeDefaultValue,
ValueIsHidden: &userAttributeValueIsHidden,
UserCanView: &userAttributeUserCanView,
UserCanEdit: &userAttributeUserCanEdit,
HiddenValueDomainWhitelist: &userAttributeHiddenValueDomainWhitelist,
}

log.Printf("[DEBUG] Create user attribute %s", userAttributeName)
Expand Down Expand Up @@ -116,6 +123,9 @@ func resourceUserAttributeRead(ctx context.Context, d *schema.ResourceData, m in
if err = d.Set("user_can_edit", userAttribute.UserCanEdit); err != nil {
return diag.FromErr(err)
}
if err = d.Set("hidden_value_domain_whitelist", userAttribute.HiddenValueDomainWhitelist); err != nil {
return diag.FromErr(err)
}

return nil
}
Expand All @@ -132,15 +142,17 @@ func resourceUserAttributeUpdate(ctx context.Context, d *schema.ResourceData, m
userAttributeValueIsHidden := d.Get("value_is_hidden").(bool)
userAttributeUserCanView := d.Get("user_can_view").(bool)
userAttributeUserCanEdit := d.Get("user_can_edit").(bool)
userAttributeHiddenValueDomainWhitelist := d.Get("hidden_value_domain_whitelist").(string)

writeUserAttribute := apiclient.WriteUserAttribute{
Name: userAttributeName,
Label: userAttributeLabel,
Type: userAttributeType,
DefaultValue: &userAttributeDefaultValue,
ValueIsHidden: &userAttributeValueIsHidden,
UserCanView: &userAttributeUserCanView,
UserCanEdit: &userAttributeUserCanEdit,
Name: userAttributeName,
Label: userAttributeLabel,
Type: userAttributeType,
DefaultValue: &userAttributeDefaultValue,
ValueIsHidden: &userAttributeValueIsHidden,
UserCanView: &userAttributeUserCanView,
UserCanEdit: &userAttributeUserCanEdit,
HiddenValueDomainWhitelist: &userAttributeHiddenValueDomainWhitelist,
}

log.Printf("[DEBUG] Update user attribute %s", userAttributeID)
Expand Down

0 comments on commit 9ebec06

Please sign in to comment.