Skip to content

Commit

Permalink
Add other attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
1riatsila1 committed Sep 13, 2024
1 parent 323ac6d commit 17f3320
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions pkg/config-api-provider/provider/data-sources/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
)

// Ensure the implementation satisfies the expected interfaces.
var (
_ datasource.DataSource = &groupDataSource{}
_ datasource.DataSourceWithConfigure = &groupDataSource{}
Expand All @@ -24,8 +23,11 @@ type groupDataSource struct {
}

type groupDataSourceModel struct {
ID types.String `tfsdk:"id"`
Filter struct {
ID types.String `tfsdk:"id"`
Path types.String `tfsdk:"path"`
ParentGroupID types.String `tfsdk:"parent_group_id"`
Name types.String `tfsdk:"name"`
Filter struct {
GroupID *string `tfsdk:"group_id"`
IsRoot *bool `tfsdk:"is_root"`
} `tfsdk:"filter"`
Expand All @@ -41,6 +43,16 @@ func (d *groupDataSource) Schema(_ context.Context, _ datasource.SchemaRequest,
"id": schema.StringAttribute{
Computed: true,
},
"path": schema.StringAttribute{
Computed: true,
Optional: true,
},
"parent_group_id": schema.StringAttribute{
Computed: true,
},
"name": schema.StringAttribute{
Computed: true,
},
"filter": schema.SingleNestedAttribute{
Required: true,
Attributes: map[string]schema.Attribute{
Expand Down Expand Up @@ -91,6 +103,11 @@ func (d *groupDataSource) Read(ctx context.Context, req datasource.ReadRequest,

group := groupResponse.Groups[0]
state.ID = types.StringValue(group.Uid)
state.Name = types.StringValue(group.Name)
state.Path = types.StringValue(group.Path)
if group.ParentUid.IsSet() {
state.ParentGroupID = types.StringValue(*group.ParentUid.Get())
}

// Set state
diags = resp.State.Set(ctx, &state)
Expand Down

0 comments on commit 17f3320

Please sign in to comment.