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

Add sub_groups to group resource #1010

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
16 changes: 16 additions & 0 deletions provider/data_source_keycloak_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ func dataSourceKeycloakGroup() *schema.Resource {
Type: schema.TypeMap,
Computed: true,
},
"sub_groups": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Computed: true,
},
"id": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
},
}
}
Expand Down
25 changes: 25 additions & 0 deletions provider/resource_keycloak_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ func resourceKeycloakGroup() *schema.Resource {
Type: schema.TypeMap,
Optional: true,
},
"sub_groups": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Computed: true,
},
"id": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
},
}
}
Expand Down Expand Up @@ -77,6 +93,15 @@ func mapFromGroupToData(data *schema.ResourceData, group *keycloak.Group) {
data.Set("name", group.Name)
data.Set("path", group.Path)
data.Set("attributes", attributes)
var subgroups []map[string]interface{}
for _, sg := range group.SubGroups {
subgroup := map[string]interface{}{
"id": sg.Id,
"name": sg.Name,
}
subgroups = append(subgroups, subgroup)
}
data.Set("sub_groups", subgroups)
if group.ParentId != "" {
data.Set("parent_id", group.ParentId)
}
Expand Down
Loading