Skip to content
Merged
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
1 change: 1 addition & 0 deletions docs/data-sources/edgecloud_plans.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ Read-Only:
- `description` (String) Description of the plan.
- `id` (String) The ID of the plan.
- `max_edge_hosts` (Number) Maximum number of Edge Cloud hosts that can be used.
- `min_edge_hosts` (Number) Minimum number of Edge Cloud hosts charged.
- `name` (String) The name of the plan.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/stackitcloud/stackit-sdk-go/services/alb v0.9.3
github.com/stackitcloud/stackit-sdk-go/services/cdn v1.13.0
github.com/stackitcloud/stackit-sdk-go/services/dns v0.19.1
github.com/stackitcloud/stackit-sdk-go/services/edge v0.4.3
github.com/stackitcloud/stackit-sdk-go/services/edge v0.7.0
github.com/stackitcloud/stackit-sdk-go/services/git v0.10.3
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.5
github.com/stackitcloud/stackit-sdk-go/services/kms v1.3.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ github.com/stackitcloud/stackit-sdk-go/services/cdn v1.13.0 h1:iRJK2d3I2QqWp8hqh
github.com/stackitcloud/stackit-sdk-go/services/cdn v1.13.0/go.mod h1:URWWMIbvq4YgWdGYCbccr3eat4Y+0qRpufZsEAsvoLM=
github.com/stackitcloud/stackit-sdk-go/services/dns v0.19.1 h1:VfszhFq/Snsd0LnflS8PbM0d9cG98hOFpamfjlcTnDQ=
github.com/stackitcloud/stackit-sdk-go/services/dns v0.19.1/go.mod h1:gBv6YkB3Xf3c0ZXg2GwtWY8zExwGPF/Ag114XiiERxg=
github.com/stackitcloud/stackit-sdk-go/services/edge v0.4.3 h1:TxChb2qbO82JiQEBYClSSD5HZxqKeKJ6dIvkEUCJmbs=
github.com/stackitcloud/stackit-sdk-go/services/edge v0.4.3/go.mod h1:KVWvQHb7CQLD9DzA4Np3WmakiCCsrHaCXvFEnOQ7nPk=
github.com/stackitcloud/stackit-sdk-go/services/edge v0.7.0 h1:DNBiHWQEWXHSbaZBmnXb+CaPXX1uVsSfp4FTHoH4wrM=
github.com/stackitcloud/stackit-sdk-go/services/edge v0.7.0/go.mod h1:CfqSEGCW0b5JlijCwtUT1kfjThmQ5jXX47TWrdD5rTU=
github.com/stackitcloud/stackit-sdk-go/services/git v0.10.3 h1:VIjkSofZz9utOOkBdNZCIb07P/JdKc1kHV1P8Rq9dLc=
github.com/stackitcloud/stackit-sdk-go/services/git v0.10.3/go.mod h1:EJk1Ss9GTel2NPIu/w3+x9XcQcEd2k3ibea5aQDzVhQ=
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.5 h1:W57+XRa8wTLsi5CV9Tqa7mGgt/PvlRM//RurXSmvII8=
Expand Down
2 changes: 2 additions & 0 deletions stackit/internal/services/edgecloud/edge_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ func TestAccEdgeCloudMax(t *testing.T) {
// check plans data source
resource.TestCheckResourceAttr("data.stackit_edgecloud_plans.this", "id", testutil.ProjectId),
resource.TestCheckResourceAttr("data.stackit_edgecloud_plans.this", "project_id", testutil.ProjectId),
resource.TestCheckResourceAttrSet("data.stackit_edgecloud_plans.this", "plans.0.min_edge_hosts"),
resource.TestCheckResourceAttrSet("data.stackit_edgecloud_plans.this", "plans.0.max_edge_hosts"),
),
},
// Kubeconfig
Expand Down
8 changes: 7 additions & 1 deletion stackit/internal/services/edgecloud/plans/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var planTypes = map[string]attr.Type{
"id": types.StringType,
"name": types.StringType,
"description": types.StringType,
"min_edge_hosts": types.Int64Type,
"max_edge_hosts": types.Int64Type,
}

Expand Down Expand Up @@ -108,6 +109,10 @@ func (d *plansDataSource) Schema(_ context.Context, _ datasource.SchemaRequest,
Description: "Description of the plan.",
Computed: true,
},
"min_edge_hosts": schema.Int64Attribute{
Description: "Minimum number of Edge Cloud hosts charged.",
Computed: true,
},
"max_edge_hosts": schema.Int64Attribute{
Description: "Maximum number of Edge Cloud hosts that can be used.",
Computed: true,
Expand Down Expand Up @@ -190,14 +195,15 @@ func (d *plansDataSource) Read(ctx context.Context, req datasource.ReadRequest,

// mapPlanToAttrs maps a single edge.Plan to a map of Terraform attributes.
func mapPlanToAttrs(plan *edge.Plan) (map[string]attr.Value, error) {
if plan == nil || plan.Id == nil || plan.Name == nil || plan.MaxEdgeHosts == nil {
if plan == nil || plan.Id == nil || plan.Name == nil || plan.MaxEdgeHosts == nil || plan.MinEdgeHosts == nil {
return nil, fmt.Errorf("received nil or incomplete plan from API")
}

attrs := map[string]attr.Value{
"id": types.StringValue(plan.GetId()),
"name": types.StringValue(plan.GetName()),
"description": types.StringValue(plan.GetDescription()),
"min_edge_hosts": types.Int64Value(plan.GetMinEdgeHosts()),
"max_edge_hosts": types.Int64Value(plan.GetMaxEdgeHosts()),
}

Expand Down
Loading