Skip to content

Commit

Permalink
adjust node allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
Luiggi33 committed Aug 19, 2024
1 parent 5de7142 commit a97df26
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions internal/provider/node_allocations_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ func (d *nodeAllocationsDataSource) Schema(ctx context.Context, req datasource.S
resp.Schema = schema.Schema{
Description: "The Pterodactyl IP Allocations for servers.",
Attributes: map[string]schema.Attribute{
"nodeid": schema.Int32Attribute{
Description: "The ID of the node to get allocations from.",
Required: true,
},
"allocations": schema.ListNestedAttribute{
Description: "The list of allocations to a node.",
Computed: true,
Expand Down Expand Up @@ -104,15 +108,15 @@ func (d *nodeAllocationsDataSource) Read(ctx context.Context, req datasource.Rea
state.NodeAllocations = make([]Allocation, len(nodes))

// Map response body to model
for _, allocation := range nodes {
state.NodeAllocations = append(state.NodeAllocations, Allocation{
for i, allocation := range nodes {
state.NodeAllocations[i] = Allocation{
ID: types.Int32Value(allocation.ID),
IP: types.StringValue(allocation.IP),
Alias: types.StringValue(allocation.Alias),
Port: types.Int32Value(allocation.Port),
Notes: types.StringValue(allocation.Notes),
Assigned: types.BoolValue(allocation.Assigned),
})
}
}

// Set state
Expand Down

0 comments on commit a97df26

Please sign in to comment.