Skip to content

Commit

Permalink
handle default req label for dynamic group better
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuZad committed Dec 6, 2024
1 parent 813733a commit 9b61ec5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/resources/dynamic_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Dynamic Group resource manages Google Workspace Groups with Dynamic memberships.
### Optional

- `description` (String) An extended description to help users determine the purpose of a group.For example, you can include information about who should join the group,the types of messages to send to the group, links to FAQs about the group, or related groups.
- `labels` (Map of String) Defaults to `map[cloudidentity.googleapis.com/groups.discussion_forum:]`. One or more label entries that apply to the Group. Currently supported labels contain a key with an empty value.
- `labels` (Map of String) One or more label entries that apply to the Group. Currently supported labels contain a key with an empty value.
- `name` (String) The group's display name.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))

Expand Down
14 changes: 10 additions & 4 deletions internal/provider/resource_dynamic_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ func resourceDynamicGroup() *schema.Resource {
Type: schema.TypeMap,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Default: map[string]interface{}{"cloudidentity.googleapis.com/groups.discussion_forum": ""},
},
},
}
Expand All @@ -123,9 +122,16 @@ func resourceDynamicGroupCreate(ctx context.Context, d *schema.ResourceData, met
return diags
}

labels, err := convertInterfaceMapToStringMap(d.Get("labels").(map[string]interface{}))
if err != nil {
return diag.FromErr(err)
labelsRaw, ok := d.GetOk("labels")
var labels map[string]string
if !ok || len(labelsRaw.(map[string]interface{})) == 0 {
labels = map[string]string{"cloudidentity.googleapis.com/groups.discussion_forum": ""}
} else {
var err error
labels, err = convertInterfaceMapToStringMap(labelsRaw.(map[string]interface{}))
if err != nil {
return diag.FromErr(err)
}
}

groupObj := cloudidentity.Group{
Expand Down

0 comments on commit 9b61ec5

Please sign in to comment.