Skip to content

Commit 61b3378

Browse files
feat(edgecloud): add minEdgeHosts attribute to plans data source
1 parent 3b2e92d commit 61b3378

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

docs/data-sources/edgecloud_plans.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ Read-Only:
4343
- `description` (String) Description of the plan.
4444
- `id` (String) The ID of the plan.
4545
- `max_edge_hosts` (Number) Maximum number of Edge Cloud hosts that can be used.
46+
- `min_edge_hosts` (Number) Minimum number of Edge Cloud hosts charged.
4647
- `name` (String) The name of the plan.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/stackitcloud/stackit-sdk-go/services/alb v0.9.3
1616
github.com/stackitcloud/stackit-sdk-go/services/cdn v1.13.0
1717
github.com/stackitcloud/stackit-sdk-go/services/dns v0.19.1
18-
github.com/stackitcloud/stackit-sdk-go/services/edge v0.4.3
18+
github.com/stackitcloud/stackit-sdk-go/services/edge v0.7.0
1919
github.com/stackitcloud/stackit-sdk-go/services/git v0.10.3
2020
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.5
2121
github.com/stackitcloud/stackit-sdk-go/services/kms v1.3.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ github.com/stackitcloud/stackit-sdk-go/services/cdn v1.13.0 h1:iRJK2d3I2QqWp8hqh
161161
github.com/stackitcloud/stackit-sdk-go/services/cdn v1.13.0/go.mod h1:URWWMIbvq4YgWdGYCbccr3eat4Y+0qRpufZsEAsvoLM=
162162
github.com/stackitcloud/stackit-sdk-go/services/dns v0.19.1 h1:VfszhFq/Snsd0LnflS8PbM0d9cG98hOFpamfjlcTnDQ=
163163
github.com/stackitcloud/stackit-sdk-go/services/dns v0.19.1/go.mod h1:gBv6YkB3Xf3c0ZXg2GwtWY8zExwGPF/Ag114XiiERxg=
164-
github.com/stackitcloud/stackit-sdk-go/services/edge v0.4.3 h1:TxChb2qbO82JiQEBYClSSD5HZxqKeKJ6dIvkEUCJmbs=
165-
github.com/stackitcloud/stackit-sdk-go/services/edge v0.4.3/go.mod h1:KVWvQHb7CQLD9DzA4Np3WmakiCCsrHaCXvFEnOQ7nPk=
164+
github.com/stackitcloud/stackit-sdk-go/services/edge v0.7.0 h1:DNBiHWQEWXHSbaZBmnXb+CaPXX1uVsSfp4FTHoH4wrM=
165+
github.com/stackitcloud/stackit-sdk-go/services/edge v0.7.0/go.mod h1:CfqSEGCW0b5JlijCwtUT1kfjThmQ5jXX47TWrdD5rTU=
166166
github.com/stackitcloud/stackit-sdk-go/services/git v0.10.3 h1:VIjkSofZz9utOOkBdNZCIb07P/JdKc1kHV1P8Rq9dLc=
167167
github.com/stackitcloud/stackit-sdk-go/services/git v0.10.3/go.mod h1:EJk1Ss9GTel2NPIu/w3+x9XcQcEd2k3ibea5aQDzVhQ=
168168
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.5 h1:W57+XRa8wTLsi5CV9Tqa7mGgt/PvlRM//RurXSmvII8=

stackit/internal/services/edgecloud/edge_acc_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ func TestAccEdgeCloudMax(t *testing.T) {
174174
// check plans data source
175175
resource.TestCheckResourceAttr("data.stackit_edgecloud_plans.this", "id", testutil.ProjectId),
176176
resource.TestCheckResourceAttr("data.stackit_edgecloud_plans.this", "project_id", testutil.ProjectId),
177+
resource.TestCheckResourceAttrSet("data.stackit_edgecloud_plans.this", "plans.0.min_edge_hosts"),
178+
resource.TestCheckResourceAttrSet("data.stackit_edgecloud_plans.this", "plans.0.max_edge_hosts"),
177179
),
178180
},
179181
// Kubeconfig

stackit/internal/services/edgecloud/plans/datasource.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ var planTypes = map[string]attr.Type{
3737
"id": types.StringType,
3838
"name": types.StringType,
3939
"description": types.StringType,
40+
"min_edge_hosts": types.Int64Type,
4041
"max_edge_hosts": types.Int64Type,
4142
}
4243

@@ -108,6 +109,10 @@ func (d *plansDataSource) Schema(_ context.Context, _ datasource.SchemaRequest,
108109
Description: "Description of the plan.",
109110
Computed: true,
110111
},
112+
"min_edge_hosts": schema.Int64Attribute{
113+
Description: "Minimum number of Edge Cloud hosts charged.",
114+
Computed: true,
115+
},
111116
"max_edge_hosts": schema.Int64Attribute{
112117
Description: "Maximum number of Edge Cloud hosts that can be used.",
113118
Computed: true,
@@ -190,14 +195,15 @@ func (d *plansDataSource) Read(ctx context.Context, req datasource.ReadRequest,
190195

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

197202
attrs := map[string]attr.Value{
198203
"id": types.StringValue(plan.GetId()),
199204
"name": types.StringValue(plan.GetName()),
200205
"description": types.StringValue(plan.GetDescription()),
206+
"min_edge_hosts": types.Int64Value(plan.GetMinEdgeHosts()),
201207
"max_edge_hosts": types.Int64Value(plan.GetMaxEdgeHosts()),
202208
}
203209

0 commit comments

Comments
 (0)