From 1d978f96236ff9bf68808b6e432e5a4720ce90e9 Mon Sep 17 00:00:00 2001 From: "Inter, Sven" Date: Mon, 30 Mar 2026 09:18:06 +0200 Subject: [PATCH 1/4] chore(edgecloud): Update to new SDK structure --- go.mod | 2 +- go.sum | 4 +- .../services/edgecloud/edge_acc_test.go | 10 +- .../services/edgecloud/instance/resource.go | 40 +++--- .../edgecloud/instance/resource_test.go | 34 +++--- .../edgecloud/instances/datasource.go | 57 ++------- .../edgecloud/instances/datasource_test.go | 115 +++++++----------- .../services/edgecloud/kubeconfig/resource.go | 10 +- .../services/edgecloud/plans/datasource.go | 10 +- .../services/edgecloud/token/resource.go | 14 +-- .../internal/services/edgecloud/utils/util.go | 2 +- .../services/edgecloud/utils/util_test.go | 8 +- 12 files changed, 125 insertions(+), 181 deletions(-) diff --git a/go.mod b/go.mod index e7f626846..fed9029af 100644 --- a/go.mod +++ b/go.mod @@ -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.7.0 + github.com/stackitcloud/stackit-sdk-go/services/edge v0.8.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 diff --git a/go.sum b/go.sum index 976240e19..d9e375147 100644 --- a/go.sum +++ b/go.sum @@ -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.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/edge v0.8.0 h1:lsOTEvItzrUerCzUodyyOy6pZ4QiSzwID7U20ZvZvHw= +github.com/stackitcloud/stackit-sdk-go/services/edge v0.8.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= diff --git a/stackit/internal/services/edgecloud/edge_acc_test.go b/stackit/internal/services/edgecloud/edge_acc_test.go index 430912ccb..e8e87e7c2 100644 --- a/stackit/internal/services/edgecloud/edge_acc_test.go +++ b/stackit/internal/services/edgecloud/edge_acc_test.go @@ -17,8 +17,8 @@ import ( "github.com/hashicorp/terraform-plugin-testing/terraform" coreConfig "github.com/stackitcloud/stackit-sdk-go/core/config" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" - "github.com/stackitcloud/stackit-sdk-go/services/edge" - "github.com/stackitcloud/stackit-sdk-go/services/edge/wait" + edge "github.com/stackitcloud/stackit-sdk-go/services/edge/v1beta1api" + "github.com/stackitcloud/stackit-sdk-go/services/edge/v1beta1api/wait" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/testutil" ) @@ -357,7 +357,7 @@ func testAccCheckEdgeCloudInstanceDestroy(s *terraform.State) error { } projectId, region, instanceId := idParts[0], idParts[1], idParts[2] - _, err := client.GetInstance(ctx, projectId, region, instanceId).Execute() + _, err := client.DefaultAPI.GetInstance(ctx, projectId, region, instanceId).Execute() if err == nil { return fmt.Errorf("edge instance %q still exists", instanceId) } @@ -366,11 +366,11 @@ func testAccCheckEdgeCloudInstanceDestroy(s *terraform.State) error { var oapiErr *oapierror.GenericOpenAPIError ok := errors.As(err, &oapiErr) if !ok || oapiErr.StatusCode != http.StatusNotFound { - err := client.DeleteInstance(ctx, projectId, region, instanceId).Execute() + err := client.DefaultAPI.DeleteInstance(ctx, projectId, region, instanceId).Execute() if err != nil { return fmt.Errorf("deleting instance %s during CheckDestroy: %w", instanceId, err) } - _, err = wait.DeleteInstanceWaitHandler(ctx, client, projectId, region, instanceId).WaitWithContext(ctx) + _, err = wait.DeleteInstanceWaitHandler(ctx, client.DefaultAPI, projectId, region, instanceId).WaitWithContext(ctx) if err != nil { return fmt.Errorf("waiting for instance deletion %s during CheckDestroy: %w", instanceId, err) } diff --git a/stackit/internal/services/edgecloud/instance/resource.go b/stackit/internal/services/edgecloud/instance/resource.go index 10420606e..288e6c031 100644 --- a/stackit/internal/services/edgecloud/instance/resource.go +++ b/stackit/internal/services/edgecloud/instance/resource.go @@ -18,8 +18,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" - "github.com/stackitcloud/stackit-sdk-go/services/edge" - edgewait "github.com/stackitcloud/stackit-sdk-go/services/edge/wait" + edge "github.com/stackitcloud/stackit-sdk-go/services/edge/v1beta1api" + edgewait "github.com/stackitcloud/stackit-sdk-go/services/edge/v1beta1api/wait" "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement" enablementWait "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement/wait" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion" @@ -264,7 +264,7 @@ func (i *instanceResource) Create(ctx context.Context, req resource.CreateReques tflog.Info(ctx, "Creating new Edge Cloud instance") payload := toCreatePayload(&model) - createResp, err := i.client.CreateInstance(ctx, projectId, region).CreateInstancePayload(payload).Execute() + createResp, err := i.client.DefaultAPI.CreateInstance(ctx, projectId, region).CreateInstancePayload(payload).Execute() if err != nil { core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Calling API: %v", err)) return @@ -276,12 +276,12 @@ func (i *instanceResource) Create(ctx context.Context, req resource.CreateReques core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", "API returned nil response") return } - if createResp.Id == nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", "API returned nil Instance ID") + if createResp.Id == "" { + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", "API returned empty Instance ID") return } - edgeCloudInstanceId := *createResp.Id + edgeCloudInstanceId := createResp.Id // Write id attributes to state before polling via the wait handler - just in case anything goes wrong during the wait handler ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{ "project_id": projectId, @@ -292,7 +292,7 @@ func (i *instanceResource) Create(ctx context.Context, req resource.CreateReques return } - waitResp, err := edgewait.CreateOrUpdateInstanceWaitHandler(ctx, i.client, projectId, region, edgeCloudInstanceId).WaitWithContext(ctx) + waitResp, err := edgewait.CreateOrUpdateInstanceWaitHandler(ctx, i.client.DefaultAPI, projectId, region, edgeCloudInstanceId).WaitWithContext(ctx) if err != nil { core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Instance waiting: %v", err)) return @@ -329,7 +329,7 @@ func (i *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r ctx = tflog.SetField(ctx, "instance_id", instanceId) ctx = tflog.SetField(ctx, "region", region) - edgeCloudInstanceResp, err := i.client.GetInstance(ctx, projectId, region, instanceId).Execute() + edgeCloudInstanceResp, err := i.client.DefaultAPI.GetInstance(ctx, projectId, region, instanceId).Execute() if err != nil { var oapiErr *oapierror.GenericOpenAPIError ok := errors.As(err, &oapiErr) @@ -372,7 +372,7 @@ func (i *instanceResource) Update(ctx context.Context, req resource.UpdateReques tflog.Info(ctx, "Updating Edge Cloud instance", map[string]any{"instance_id": instanceId}) payload := toUpdatePayload(&model) - err := i.client.UpdateInstance(ctx, projectId, region, instanceId).UpdateInstancePayload(payload).Execute() + err := i.client.DefaultAPI.UpdateInstance(ctx, projectId, region, instanceId).UpdateInstancePayload(payload).Execute() if err != nil { core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Calling API: %v", err)) return @@ -380,7 +380,7 @@ func (i *instanceResource) Update(ctx context.Context, req resource.UpdateReques ctx = core.LogResponse(ctx) - waitResp, err := edgewait.CreateOrUpdateInstanceWaitHandler(ctx, i.client, projectId, region, instanceId).WaitWithContext(ctx) + waitResp, err := edgewait.CreateOrUpdateInstanceWaitHandler(ctx, i.client.DefaultAPI, projectId, region, instanceId).WaitWithContext(ctx) if err != nil { core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Instance waiting: %v", err)) return @@ -414,7 +414,7 @@ func (i *instanceResource) Delete(ctx context.Context, req resource.DeleteReques ctx = tflog.SetField(ctx, "instance_id", instanceId) ctx = tflog.SetField(ctx, "region", region) - err := i.client.DeleteInstance(ctx, projectId, region, instanceId).Execute() + err := i.client.DefaultAPI.DeleteInstance(ctx, projectId, region, instanceId).Execute() if err != nil { core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting instance", fmt.Sprintf("Calling API: %v", err)) return @@ -422,7 +422,7 @@ func (i *instanceResource) Delete(ctx context.Context, req resource.DeleteReques ctx = core.LogResponse(ctx) - _, err = edgewait.DeleteInstanceWaitHandler(ctx, i.client, projectId, region, instanceId).WaitWithContext(ctx) + _, err = edgewait.DeleteInstanceWaitHandler(ctx, i.client.DefaultAPI, projectId, region, instanceId).WaitWithContext(ctx) if err != nil { core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting instance", fmt.Sprintf("Instance deletion waiting: %v", err)) return @@ -461,8 +461,8 @@ func mapFields(resp *edge.Instance, model *Model) error { var instanceId string if model.InstanceId.ValueString() != "" { instanceId = model.InstanceId.ValueString() - } else if resp.Id != nil { - instanceId = *resp.Id + } else if resp.Id != "" { + instanceId = resp.Id } model.Id = utils.BuildInternalTerraformId(model.ProjectId.ValueString(), model.Region.ValueString(), instanceId) model.InstanceId = types.StringValue(instanceId) @@ -471,10 +471,10 @@ func mapFields(resp *edge.Instance, model *Model) error { } else { model.Created = types.StringNull() } - model.FrontendUrl = types.StringPointerValue(resp.FrontendUrl) - model.DisplayName = types.StringPointerValue(resp.DisplayName) - model.PlanID = types.StringPointerValue(resp.PlanId) - model.Status = types.StringValue(string(*resp.Status)) + model.FrontendUrl = types.StringValue(resp.FrontendUrl) + model.DisplayName = types.StringValue(resp.DisplayName) + model.PlanID = types.StringValue(resp.PlanId) + model.Status = types.StringValue(resp.Status) if resp.Description != nil { model.Description = types.StringValue(*resp.Description) @@ -488,9 +488,9 @@ func mapFields(resp *edge.Instance, model *Model) error { // toCreatePayload creates the payload for creating an Edge Cloud instance. func toCreatePayload(model *Model) edge.CreateInstancePayload { return edge.CreateInstancePayload{ - DisplayName: model.DisplayName.ValueStringPointer(), + DisplayName: model.DisplayName.ValueString(), Description: model.Description.ValueStringPointer(), - PlanId: model.PlanID.ValueStringPointer(), + PlanId: model.PlanID.ValueString(), } } diff --git a/stackit/internal/services/edgecloud/instance/resource_test.go b/stackit/internal/services/edgecloud/instance/resource_test.go index 02b58f4ed..d42dd30af 100644 --- a/stackit/internal/services/edgecloud/instance/resource_test.go +++ b/stackit/internal/services/edgecloud/instance/resource_test.go @@ -9,7 +9,7 @@ import ( "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stackitcloud/stackit-sdk-go/core/utils" - "github.com/stackitcloud/stackit-sdk-go/services/edge" + edge "github.com/stackitcloud/stackit-sdk-go/services/edge/v1beta1api" ) func TestMapFields(t *testing.T) { @@ -25,13 +25,13 @@ func TestMapFields(t *testing.T) { { "all_parameter_set", &edge.Instance{ - Id: utils.Ptr("iid-123"), - Created: &testTime, - DisplayName: utils.Ptr("test-instance"), + Id: "iid-123", + Created: testTime, + DisplayName: "test-instance", Description: utils.Ptr("Test description"), - PlanId: utils.Ptr(uuidString), - Status: utils.Ptr(edge.InstanceStatus("CREATING")), - FrontendUrl: utils.Ptr("https://iid-123.example.com"), + PlanId: uuidString, + Status: "CREATING", + FrontendUrl: "https://iid-123.example.com", }, &Model{ ProjectId: types.StringValue(uuidString), @@ -54,13 +54,13 @@ func TestMapFields(t *testing.T) { { "empty_description", &edge.Instance{ - Id: utils.Ptr("iid-123"), - Created: &testTime, - DisplayName: utils.Ptr("test-instance"), + Id: "iid-123", + Created: testTime, + DisplayName: "test-instance", Description: utils.Ptr(""), - PlanId: utils.Ptr(uuidString), - Status: utils.Ptr(edge.InstanceStatus("ACTIVE")), - FrontendUrl: utils.Ptr("https://iid-123.example.com"), + PlanId: uuidString, + Status: "ACTIVE", + FrontendUrl: "https://iid-123.example.com", }, &Model{ ProjectId: types.StringValue(uuidString), @@ -132,9 +132,9 @@ func TestToCreatePayload(t *testing.T) { PlanID: types.StringValue(uuidString), }, edge.CreateInstancePayload{ - DisplayName: utils.Ptr("new-instance"), + DisplayName: "new-instance", Description: utils.Ptr("A new test instance"), - PlanId: utils.Ptr(uuidString), + PlanId: uuidString, }, true, }, @@ -146,9 +146,9 @@ func TestToCreatePayload(t *testing.T) { PlanID: types.StringValue(uuidString), }, edge.CreateInstancePayload{ - DisplayName: utils.Ptr("new-instance"), + DisplayName: "new-instance", Description: nil, - PlanId: utils.Ptr(uuidString), + PlanId: uuidString, }, true, }, diff --git a/stackit/internal/services/edgecloud/instances/datasource.go b/stackit/internal/services/edgecloud/instances/datasource.go index 011a8c530..97fcf9c41 100644 --- a/stackit/internal/services/edgecloud/instances/datasource.go +++ b/stackit/internal/services/edgecloud/instances/datasource.go @@ -12,7 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/stackitcloud/stackit-sdk-go/services/edge" + edge "github.com/stackitcloud/stackit-sdk-go/services/edge/v1beta1api" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/features" @@ -166,7 +166,7 @@ func (d *instancesDataSource) Read(ctx context.Context, req datasource.ReadReque ctx = tflog.SetField(ctx, "region", region) // Fetch all instances for the project and region - instancesResp, err := d.client.ListInstances(ctx, projectId, region).Execute() + instancesResp, err := d.client.DefaultAPI.ListInstances(ctx, projectId, region).Execute() if err != nil { utils.LogError( ctx, @@ -216,20 +216,11 @@ func (d *instancesDataSource) Read(ctx context.Context, req datasource.ReadReque } // buildInstancesList constructs a list of instance attributes -func buildInstancesList(ctx context.Context, instances edge.InstanceListGetInstancesAttributeType, region string, diags *diag.Diagnostics) []attr.Value { +func buildInstancesList(_ context.Context, instances []edge.Instance, region string, diags *diag.Diagnostics) []attr.Value { var instancesList []attr.Value - for _, instance := range *instances { - instanceAttrs, err := mapInstanceToAttrs(instance, region) - if err != nil { - // Keep going in case there are more errors - instanceId := "without id" - if instance.Id != nil { - instanceId = *instance.Id - } - core.LogAndAddError(ctx, diags, "Error reading instances", fmt.Sprintf("Could not process instance %q: %v", instanceId, err)) - continue - } + for _, instance := range instances { + instanceAttrs := mapInstanceToAttrs(&instance, region) instanceObjectValue, objDiags := types.ObjectValue(instanceTypes, instanceAttrs) diags.Append(objDiags...) @@ -242,38 +233,16 @@ func buildInstancesList(ctx context.Context, instances edge.InstanceListGetInsta return instancesList } -func mapInstanceToAttrs(instance edge.Instance, region string) (map[string]attr.Value, error) { - if instance.Id == nil { - return nil, fmt.Errorf("instance is missing an 'id'") - } - if instance.DisplayName == nil || *instance.DisplayName == "" { - return nil, fmt.Errorf("instance %q is missing a 'displayName'", *instance.Id) - } - if instance.PlanId == nil { - return nil, fmt.Errorf("instance %q is missing a 'planId'", *instance.Id) - } - if instance.FrontendUrl == nil { - return nil, fmt.Errorf("instance %q is missing a 'frontendUrl'", *instance.Id) - } - if instance.Status == nil { - return nil, fmt.Errorf("instance %q is missing a 'status'", *instance.Id) - } - if instance.Created == nil { - return nil, fmt.Errorf("instance %q is missing a 'created' timestamp", *instance.Id) - } - if instance.Description == nil { - return nil, fmt.Errorf("instance %q is missing a 'description'", *instance.Id) - } - +func mapInstanceToAttrs(instance *edge.Instance, region string) map[string]attr.Value { attrs := map[string]attr.Value{ - "instance_id": types.StringValue(*instance.Id), - "display_name": types.StringValue(*instance.DisplayName), + "instance_id": types.StringValue(instance.Id), + "display_name": types.StringValue(instance.DisplayName), "region": types.StringValue(region), - "plan_id": types.StringValue(*instance.PlanId), - "frontend_url": types.StringValue(*instance.FrontendUrl), - "status": types.StringValue(string(instance.GetStatus())), + "plan_id": types.StringValue(instance.PlanId), + "frontend_url": types.StringValue(instance.FrontendUrl), + "status": types.StringValue(instance.Status), "created": types.StringValue(instance.Created.String()), - "description": types.StringValue(*instance.Description), + "description": types.StringPointerValue(instance.Description), } - return attrs, nil + return attrs } diff --git a/stackit/internal/services/edgecloud/instances/datasource_test.go b/stackit/internal/services/edgecloud/instances/datasource_test.go index 741db3d37..c0de2b717 100644 --- a/stackit/internal/services/edgecloud/instances/datasource_test.go +++ b/stackit/internal/services/edgecloud/instances/datasource_test.go @@ -16,7 +16,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stackitcloud/stackit-sdk-go/core/utils" - "github.com/stackitcloud/stackit-sdk-go/services/edge" + edge "github.com/stackitcloud/stackit-sdk-go/services/edge/v1beta1api" ) // testTime is a shared helper for generating consistent timestamps @@ -32,12 +32,12 @@ func fixtureInstance(mods ...func(instance *edge.Instance)) edge.Instance { description := "some-description" instance := &edge.Instance{ - Id: utils.Ptr(id), - DisplayName: utils.Ptr(displayName), - PlanId: &defaultPlanId, - FrontendUrl: utils.Ptr(fmt.Sprintf("https://%s.example.com", id)), - Status: utils.Ptr(edge.InstanceStatus("ACTIVE")), - Created: &testTime, + Id: id, + DisplayName: displayName, + PlanId: defaultPlanId, + FrontendUrl: fmt.Sprintf("https://%s.example.com", id), + Status: "ACTIVE", + Created: testTime, Description: utils.Ptr(description), } @@ -61,14 +61,14 @@ func TestMapInstanceToAttrs(t *testing.T) { validInstance := fixtureInstance() validInstanceAttrs := map[string]attr.Value{ - "instance_id": types.StringValue(*validInstance.Id), - "display_name": types.StringValue(*validInstance.DisplayName), + "instance_id": types.StringValue(validInstance.Id), + "display_name": types.StringValue(validInstance.DisplayName), "region": types.StringValue(region), - "plan_id": types.StringValue(*validInstance.PlanId), - "frontend_url": types.StringValue(*validInstance.FrontendUrl), - "status": types.StringValue(string(*validInstance.Status)), + "plan_id": types.StringValue(validInstance.PlanId), + "frontend_url": types.StringValue(validInstance.FrontendUrl), + "status": types.StringValue(validInstance.Status), "created": types.StringValue(testTime.String()), - "description": types.StringValue(*validInstance.Description), + "description": types.StringPointerValue(validInstance.Description), } tests := []struct { @@ -90,73 +90,59 @@ func TestMapInstanceToAttrs(t *testing.T) { i.Description = utils.Ptr("") }), expected: fixtureAttrs(validInstanceAttrs, func(m map[string]attr.Value) { - m["description"] = types.StringValue("") + m["description"] = types.StringPointerValue(utils.Ptr("")) }), expectError: false, }, - { - description: "error, nil display name", - instance: fixtureInstance(func(i *edge.Instance) { - i.DisplayName = nil - }), - expectError: true, - errorMsg: "missing a 'displayName'", - }, { description: "error, empty display name", instance: fixtureInstance(func(i *edge.Instance) { - i.DisplayName = utils.Ptr("") + i.DisplayName = "" }), expectError: true, errorMsg: "missing a 'displayName'", }, { - description: "error, nil id", + description: "error, empty id", instance: fixtureInstance(func(i *edge.Instance) { - i.Id = nil + i.Id = "" }), expectError: true, errorMsg: "missing an 'id'", }, { - description: "error, nil planId", + description: "error, empty planId", instance: fixtureInstance(func(i *edge.Instance) { - i.PlanId = nil + i.PlanId = "" }), expectError: true, errorMsg: "missing a 'planId'", }, { - description: "error, nil frontendUrl", + description: "error, empty frontendUrl", instance: fixtureInstance(func(i *edge.Instance) { - i.FrontendUrl = nil + i.FrontendUrl = "" }), expectError: true, errorMsg: "missing a 'frontendUrl'", }, { - description: "error, nil status", + description: "error, empty status", instance: fixtureInstance(func(i *edge.Instance) { - i.Status = nil + i.Status = "" }), expectError: true, errorMsg: "missing a 'status'", }, - { - description: "error, nil created", - instance: fixtureInstance(func(i *edge.Instance) { - i.Created = nil - }), - expectError: true, - errorMsg: "missing a 'created' timestamp", - }, { description: "error, nil description", instance: fixtureInstance(func(i *edge.Instance) { i.Description = nil }), - expectError: true, - errorMsg: "missing a 'description'", + expectError: false, + expected: fixtureAttrs(validInstanceAttrs, func(m map[string]attr.Value) { + m["description"] = types.StringPointerValue(nil) + }), }, } @@ -191,33 +177,28 @@ func TestBuildInstancesList(t *testing.T) { ctx := context.Background() instance1 := fixtureInstance(func(i *edge.Instance) { - i.Id = utils.Ptr("first-ab75568") - i.DisplayName = utils.Ptr("first") + i.Id = "first-ab75568" + i.DisplayName = "first" }) instance2 := fixtureInstance(func(i *edge.Instance) { - i.Id = utils.Ptr("second-ab75568") - i.DisplayName = utils.Ptr("second") + i.Id = "second-ab75568" + i.DisplayName = "second" }) instanceInvalidPlan := fixtureInstance(func(i *edge.Instance) { - i.PlanId = nil - }) - - // Invalid: Nil Display Name - instanceNilName := fixtureInstance(func(i *edge.Instance) { - i.DisplayName = nil + i.PlanId = "" }) // Invalid: Empty Display Name instanceEmptyName := fixtureInstance(func(i *edge.Instance) { - i.DisplayName = utils.Ptr("") + i.DisplayName = "" }) - // Invalid: Nil ID and Nil Display Name - instanceNilIdAndName := fixtureInstance(func(i *edge.Instance) { - i.Id = nil - i.DisplayName = nil + // Invalid: Empty ID and Empty Display Name + instanceEmptyIdAndName := fixtureInstance(func(i *edge.Instance) { + i.Id = "" + i.DisplayName = "" }) // Pre-calculate expected mapped objects for the valid instances @@ -229,43 +210,37 @@ func TestBuildInstancesList(t *testing.T) { tests := []struct { description string - instances edge.InstanceListGetInstancesAttributeType + instances []edge.Instance expectedList []attr.Value expectedDiagCount int }{ { description: "empty instance list", - instances: &[]edge.Instance{}, // No test case for nil, since this is checked before buildInstancesList is called + instances: []edge.Instance{}, // No test case for nil, since this is checked before buildInstancesList is called expectedList: []attr.Value{}, expectedDiagCount: 0, }, { description: "two valid instances", - instances: &[]edge.Instance{instance1, instance2}, + instances: []edge.Instance{instance1, instance2}, expectedList: []attr.Value{obj1, obj2}, expectedDiagCount: 0, }, { - description: "one valid, one invalid (nil planId)", - instances: &[]edge.Instance{instance1, instanceInvalidPlan}, - expectedList: []attr.Value{obj1}, - expectedDiagCount: 1, - }, - { - description: "one valid, one invalid (nil display name)", - instances: &[]edge.Instance{instance1, instanceNilName}, + description: "one valid, one invalid (empty planId)", + instances: []edge.Instance{instance1, instanceInvalidPlan}, expectedList: []attr.Value{obj1}, expectedDiagCount: 1, }, { description: "one valid, one invalid (empty display name)", - instances: &[]edge.Instance{instance1, instanceEmptyName}, + instances: []edge.Instance{instance1, instanceEmptyName}, expectedList: []attr.Value{obj1}, expectedDiagCount: 1, }, { - description: "one valid, one invalid (nil id and nil display name)", - instances: &[]edge.Instance{instance1, instanceNilIdAndName}, + description: "one valid, one invalid (empty id and empty display name)", + instances: []edge.Instance{instance1, instanceEmptyIdAndName}, expectedList: []attr.Value{obj1}, expectedDiagCount: 1, }, diff --git a/stackit/internal/services/edgecloud/kubeconfig/resource.go b/stackit/internal/services/edgecloud/kubeconfig/resource.go index 1e60bb861..ce73b47a0 100644 --- a/stackit/internal/services/edgecloud/kubeconfig/resource.go +++ b/stackit/internal/services/edgecloud/kubeconfig/resource.go @@ -8,8 +8,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework-validators/int64validator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" - edgeCloud "github.com/stackitcloud/stackit-sdk-go/services/edge" - edgeCloudWait "github.com/stackitcloud/stackit-sdk-go/services/edge/wait" + edgeCloud "github.com/stackitcloud/stackit-sdk-go/services/edge/v1beta1api" + edgeCloudWait "github.com/stackitcloud/stackit-sdk-go/services/edge/v1beta1api/wait" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/features" edgeCloudUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/edgecloud/utils" @@ -305,7 +305,7 @@ func (r *kubeconfigResource) Create(ctx context.Context, req resource.CreateRequ if !model.InstanceId.IsNull() { instanceId := model.InstanceId.ValueString() ctx = tflog.SetField(ctx, "instance_id", model.InstanceId) - kubeconfigResp, err = edgeCloudWait.KubeconfigWaitHandler(ctx, r.client, projectId, region, instanceId, &expirationSeconds).WaitWithContext(ctx) + kubeconfigResp, err = edgeCloudWait.KubeconfigWaitHandler(ctx, r.client.DefaultAPI, projectId, region, instanceId, &expirationSeconds).WaitWithContext(ctx) if err != nil { core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating kubeconfig", fmt.Sprintf("Kubeconfig creation waiting: %v", err)) return @@ -314,7 +314,7 @@ func (r *kubeconfigResource) Create(ctx context.Context, req resource.CreateRequ } else if !model.InstanceName.IsNull() { instanceName := model.InstanceName.ValueString() ctx = tflog.SetField(ctx, "instance_name", model.InstanceName) - kubeconfigResp, err = edgeCloudWait.KubeconfigByInstanceNameWaitHandler(ctx, r.client, projectId, region, instanceName, &expirationSeconds).WaitWithContext(ctx) + kubeconfigResp, err = edgeCloudWait.KubeconfigByInstanceNameWaitHandler(ctx, r.client.DefaultAPI, projectId, region, instanceName, &expirationSeconds).WaitWithContext(ctx) if err != nil { core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating kubeconfig", fmt.Sprintf("Kubeconfig creation waiting: %v", err)) return @@ -340,7 +340,7 @@ func (r *kubeconfigResource) Create(ctx context.Context, req resource.CreateRequ return } - kubeconfig, err := marshalKubeconfig(*kubeconfigResp.Kubeconfig) + kubeconfig, err := marshalKubeconfig(kubeconfigResp.Kubeconfig) if err != nil { core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating kubeconfig", fmt.Sprintf("Processing API payload: %v", err)) return diff --git a/stackit/internal/services/edgecloud/plans/datasource.go b/stackit/internal/services/edgecloud/plans/datasource.go index 34ca59019..4b80f1bfe 100644 --- a/stackit/internal/services/edgecloud/plans/datasource.go +++ b/stackit/internal/services/edgecloud/plans/datasource.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/stackitcloud/stackit-sdk-go/services/edge" + edge "github.com/stackitcloud/stackit-sdk-go/services/edge/v1beta1api" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/features" @@ -140,7 +140,7 @@ func (d *plansDataSource) Read(ctx context.Context, req datasource.ReadRequest, ctx = tflog.SetField(ctx, "project_id", projectId) // Fetch all Plans for the project - plansResp, err := d.client.ListPlansProject(ctx, projectId).Execute() + plansResp, err := d.client.DefaultAPI.ListPlansProject(ctx, projectId).Execute() if err != nil { utils.LogError( ctx, @@ -160,7 +160,7 @@ func (d *plansDataSource) Read(ctx context.Context, req datasource.ReadRequest, // Process the API response and build the list var plansList []attr.Value if plansResp.ValidPlans != nil { - for _, plan := range *plansResp.ValidPlans { + for _, plan := range plansResp.ValidPlans { planAttrs, err := mapPlanToAttrs(&plan) if err != nil { core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading Edge Cloud plans", fmt.Sprintf("Could not process plans: %v", err)) @@ -203,8 +203,8 @@ func mapPlanToAttrs(plan *edge.Plan) (map[string]attr.Value, error) { "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()), + "min_edge_hosts": types.Int32Value(plan.GetMinEdgeHosts()), + "max_edge_hosts": types.Int32Value(plan.GetMaxEdgeHosts()), } return attrs, nil diff --git a/stackit/internal/services/edgecloud/token/resource.go b/stackit/internal/services/edgecloud/token/resource.go index 7fc625a37..9481aac28 100644 --- a/stackit/internal/services/edgecloud/token/resource.go +++ b/stackit/internal/services/edgecloud/token/resource.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework-validators/int64validator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" - edgeCloud "github.com/stackitcloud/stackit-sdk-go/services/edge" - edgeCloudWait "github.com/stackitcloud/stackit-sdk-go/services/edge/wait" + edgeCloud "github.com/stackitcloud/stackit-sdk-go/services/edge/v1beta1api" + edgeCloudWait "github.com/stackitcloud/stackit-sdk-go/services/edge/v1beta1api/wait" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/features" edgeCloudUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/edgecloud/utils" @@ -303,7 +303,7 @@ func (r *tokenResource) Create(ctx context.Context, req resource.CreateRequest, if !model.InstanceId.IsNull() { instanceId := model.InstanceId.ValueString() ctx = tflog.SetField(ctx, "instance_id", model.InstanceId) - tokenResp, err = edgeCloudWait.TokenWaitHandler(ctx, r.client, projectId, region, instanceId, &expirationSeconds).WaitWithContext(ctx) + tokenResp, err = edgeCloudWait.TokenWaitHandler(ctx, r.client.DefaultAPI, projectId, region, instanceId, &expirationSeconds).WaitWithContext(ctx) if err != nil { core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating token", fmt.Sprintf("token waiting: %v", err)) return @@ -312,7 +312,7 @@ func (r *tokenResource) Create(ctx context.Context, req resource.CreateRequest, } else if !model.InstanceName.IsNull() { instanceName := model.InstanceName.ValueString() ctx = tflog.SetField(ctx, "instance_name", model.InstanceName) - tokenResp, err = edgeCloudWait.TokenByInstanceNameWaitHandler(ctx, r.client, projectId, region, instanceName, &expirationSeconds).WaitWithContext(ctx) + tokenResp, err = edgeCloudWait.TokenByInstanceNameWaitHandler(ctx, r.client.DefaultAPI, projectId, region, instanceName, &expirationSeconds).WaitWithContext(ctx) if err != nil { core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating token", fmt.Sprintf("token waiting: %v", err)) return @@ -332,11 +332,11 @@ func (r *tokenResource) Create(ctx context.Context, req resource.CreateRequest, core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating token", "API response is nil") return } - if tokenResp.Token == nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating token", "token field in the API response is nil") + if tokenResp.Token == "" { + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating token", "token field in the API response is empty") return } - model.Token = types.StringPointerValue(tokenResp.Token) + model.Token = types.StringValue(tokenResp.Token) diags = resp.State.Set(ctx, model) resp.Diagnostics.Append(diags...) diff --git a/stackit/internal/services/edgecloud/utils/util.go b/stackit/internal/services/edgecloud/utils/util.go index 6939c9437..8867849b6 100644 --- a/stackit/internal/services/edgecloud/utils/util.go +++ b/stackit/internal/services/edgecloud/utils/util.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stackitcloud/stackit-sdk-go/core/config" - "github.com/stackitcloud/stackit-sdk-go/services/edge" + edge "github.com/stackitcloud/stackit-sdk-go/services/edge/v1beta1api" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils" ) diff --git a/stackit/internal/services/edgecloud/utils/util_test.go b/stackit/internal/services/edgecloud/utils/util_test.go index b86c9b0c1..31bdf1a36 100644 --- a/stackit/internal/services/edgecloud/utils/util_test.go +++ b/stackit/internal/services/edgecloud/utils/util_test.go @@ -3,7 +3,6 @@ package utils import ( "context" "os" - "reflect" "testing" "time" @@ -11,7 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" sdkClients "github.com/stackitcloud/stackit-sdk-go/core/clients" "github.com/stackitcloud/stackit-sdk-go/core/config" - "github.com/stackitcloud/stackit-sdk-go/services/edge" + edge "github.com/stackitcloud/stackit-sdk-go/services/edge/v1beta1api" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils" ) @@ -86,8 +85,9 @@ func TestConfigureClient(t *testing.T) { t.Errorf("ConfigureClient() error = %v, want %v", diags.HasError(), tt.wantErr) } - if !reflect.DeepEqual(actual, tt.expected) { - t.Errorf("ConfigureClient() = %v, want %v", actual, tt.expected) + // Verify that a client was successfully created + if actual == nil && !tt.wantErr { + t.Errorf("ConfigureClient() returned nil client, expected non-nil") } }) } From a923afd747d0236d011706554e584e62be104272 Mon Sep 17 00:00:00 2001 From: "Inter, Sven" Date: Mon, 30 Mar 2026 16:18:24 +0200 Subject: [PATCH 2/4] chore(edgecloud): directly use API response ID --- stackit/internal/services/edgecloud/instance/resource.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/stackit/internal/services/edgecloud/instance/resource.go b/stackit/internal/services/edgecloud/instance/resource.go index 288e6c031..4d482ea28 100644 --- a/stackit/internal/services/edgecloud/instance/resource.go +++ b/stackit/internal/services/edgecloud/instance/resource.go @@ -276,23 +276,18 @@ func (i *instanceResource) Create(ctx context.Context, req resource.CreateReques core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", "API returned nil response") return } - if createResp.Id == "" { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", "API returned empty Instance ID") - return - } - edgeCloudInstanceId := createResp.Id // Write id attributes to state before polling via the wait handler - just in case anything goes wrong during the wait handler ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{ "project_id": projectId, - "instance_id": edgeCloudInstanceId, + "instance_id": createResp.Id, "region": region, }) if resp.Diagnostics.HasError() { return } - waitResp, err := edgewait.CreateOrUpdateInstanceWaitHandler(ctx, i.client.DefaultAPI, projectId, region, edgeCloudInstanceId).WaitWithContext(ctx) + waitResp, err := edgewait.CreateOrUpdateInstanceWaitHandler(ctx, i.client.DefaultAPI, projectId, region, createResp.Id).WaitWithContext(ctx) if err != nil { core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Instance waiting: %v", err)) return From ed025238a9ce3aa31d9023927c1a88a4c2d7aed0 Mon Sep 17 00:00:00 2001 From: "Inter, Sven" Date: Wed, 1 Apr 2026 09:57:38 +0200 Subject: [PATCH 3/4] chore(edgecloud): fix datasource tests --- .../edgecloud/instances/datasource_test.go | 136 ++---------------- 1 file changed, 14 insertions(+), 122 deletions(-) diff --git a/stackit/internal/services/edgecloud/instances/datasource_test.go b/stackit/internal/services/edgecloud/instances/datasource_test.go index c0de2b717..df64a7f82 100644 --- a/stackit/internal/services/edgecloud/instances/datasource_test.go +++ b/stackit/internal/services/edgecloud/instances/datasource_test.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "maps" - "strings" "testing" "time" @@ -75,14 +74,11 @@ func TestMapInstanceToAttrs(t *testing.T) { description string instance edge.Instance expected map[string]attr.Value - expectError bool - errorMsg string }{ { description: "valid instance", instance: validInstance, expected: validInstanceAttrs, - expectError: false, }, { description: "valid instance, empty description", @@ -92,54 +88,12 @@ func TestMapInstanceToAttrs(t *testing.T) { expected: fixtureAttrs(validInstanceAttrs, func(m map[string]attr.Value) { m["description"] = types.StringPointerValue(utils.Ptr("")) }), - expectError: false, }, { - description: "error, empty display name", - instance: fixtureInstance(func(i *edge.Instance) { - i.DisplayName = "" - }), - expectError: true, - errorMsg: "missing a 'displayName'", - }, - { - description: "error, empty id", - instance: fixtureInstance(func(i *edge.Instance) { - i.Id = "" - }), - expectError: true, - errorMsg: "missing an 'id'", - }, - { - description: "error, empty planId", - instance: fixtureInstance(func(i *edge.Instance) { - i.PlanId = "" - }), - expectError: true, - errorMsg: "missing a 'planId'", - }, - { - description: "error, empty frontendUrl", - instance: fixtureInstance(func(i *edge.Instance) { - i.FrontendUrl = "" - }), - expectError: true, - errorMsg: "missing a 'frontendUrl'", - }, - { - description: "error, empty status", - instance: fixtureInstance(func(i *edge.Instance) { - i.Status = "" - }), - expectError: true, - errorMsg: "missing a 'status'", - }, - { - description: "error, nil description", + description: "nil description", instance: fixtureInstance(func(i *edge.Instance) { i.Description = nil }), - expectError: false, expected: fixtureAttrs(validInstanceAttrs, func(m map[string]attr.Value) { m["description"] = types.StringPointerValue(nil) }), @@ -148,21 +102,7 @@ func TestMapInstanceToAttrs(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - attrs, err := mapInstanceToAttrs(tt.instance, region) - - if tt.expectError { - if err == nil { - t.Fatalf("Expected an error, but got nil") - } - if tt.errorMsg != "" && !strings.Contains(err.Error(), tt.errorMsg) { - t.Errorf("Expected error message to contain %q, but got: %v", tt.errorMsg, err) - } - return - } - - if err != nil { - t.Fatalf("Expected no error, but got: %v", err) - } + attrs := mapInstanceToAttrs(&tt.instance, region) diff := cmp.Diff(tt.expected, attrs, cmpopts.EquateEmpty()) if diff != "" { @@ -186,63 +126,27 @@ func TestBuildInstancesList(t *testing.T) { i.DisplayName = "second" }) - instanceInvalidPlan := fixtureInstance(func(i *edge.Instance) { - i.PlanId = "" - }) - - // Invalid: Empty Display Name - instanceEmptyName := fixtureInstance(func(i *edge.Instance) { - i.DisplayName = "" - }) - - // Invalid: Empty ID and Empty Display Name - instanceEmptyIdAndName := fixtureInstance(func(i *edge.Instance) { - i.Id = "" - i.DisplayName = "" - }) - // Pre-calculate expected mapped objects for the valid instances - attrs1, _ := mapInstanceToAttrs(instance1, region) + attrs1 := mapInstanceToAttrs(&instance1, region) obj1, _ := types.ObjectValue(instanceTypes, attrs1) - attrs2, _ := mapInstanceToAttrs(instance2, region) + attrs2 := mapInstanceToAttrs(&instance2, region) obj2, _ := types.ObjectValue(instanceTypes, attrs2) tests := []struct { - description string - instances []edge.Instance - expectedList []attr.Value - expectedDiagCount int + description string + instances []edge.Instance + expectedList []attr.Value }{ { - description: "empty instance list", - instances: []edge.Instance{}, // No test case for nil, since this is checked before buildInstancesList is called - expectedList: []attr.Value{}, - expectedDiagCount: 0, - }, - { - description: "two valid instances", - instances: []edge.Instance{instance1, instance2}, - expectedList: []attr.Value{obj1, obj2}, - expectedDiagCount: 0, - }, - { - description: "one valid, one invalid (empty planId)", - instances: []edge.Instance{instance1, instanceInvalidPlan}, - expectedList: []attr.Value{obj1}, - expectedDiagCount: 1, - }, - { - description: "one valid, one invalid (empty display name)", - instances: []edge.Instance{instance1, instanceEmptyName}, - expectedList: []attr.Value{obj1}, - expectedDiagCount: 1, + description: "empty instance list", + instances: []edge.Instance{}, // No test case for nil, since this is checked before buildInstancesList is called + expectedList: []attr.Value{}, }, { - description: "one valid, one invalid (empty id and empty display name)", - instances: []edge.Instance{instance1, instanceEmptyIdAndName}, - expectedList: []attr.Value{obj1}, - expectedDiagCount: 1, + description: "two valid instances", + instances: []edge.Instance{instance1, instance2}, + expectedList: []attr.Value{obj1, obj2}, }, } @@ -252,19 +156,7 @@ func TestBuildInstancesList(t *testing.T) { resultList := buildInstancesList(ctx, tt.instances, region, &diags) - if tt.expectedDiagCount > 0 { - if !diags.HasError() { - t.Errorf("Expected diagnostics to have errors, but it didn't") - } - if len(diags) != tt.expectedDiagCount { - t.Errorf("Expected %d diagnostic(s), but got %d", tt.expectedDiagCount, len(diags)) - } - for _, d := range diags { - if d.Severity() != diag.SeverityError { - t.Errorf("Expected diagnostic to be an Error, but got %v", d.Severity()) - } - } - } else if diags.HasError() { + if diags.HasError() { t.Errorf("Expected no errors, but got diagnostics: %v", diags) } From d1d711d761995622cb36ba2e03ff15ce653a134d Mon Sep 17 00:00:00 2001 From: "Inter, Sven" Date: Wed, 1 Apr 2026 13:02:46 +0200 Subject: [PATCH 4/4] chore(edgecloud): upgrade sdk and set types to int32 --- go.sum | 2 -- stackit/internal/services/edgecloud/plans/datasource.go | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/go.sum b/go.sum index c85f26dd8..cb57c2f92 100644 --- a/go.sum +++ b/go.sum @@ -153,8 +153,6 @@ github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= github.com/skeema/knownhosts v1.3.1 h1:X2osQ+RAjK76shCbvhHHHVl3ZlgDm8apHEHFqRjnBY8= github.com/skeema/knownhosts v1.3.1/go.mod h1:r7KTdC8l4uxWRyK2TpQZ/1o5HaSzh06ePQNxPwTcfiY= -github.com/stackitcloud/stackit-sdk-go/core v0.23.0 h1:zPrOhf3Xe47rKRs1fg/AqKYUiJJRYjdcv+3qsS50mEs= -github.com/stackitcloud/stackit-sdk-go/core v0.23.0/go.mod h1:osMglDby4csGZ5sIfhNyYq1bS1TxIdPY88+skE/kkmI= github.com/stackitcloud/stackit-sdk-go/core v0.24.0 h1:kHCcezCJ5OGSP7RRuGOxD5rF2wejpkEiRr/OdvNcuPQ= github.com/stackitcloud/stackit-sdk-go/core v0.24.0/go.mod h1:osMglDby4csGZ5sIfhNyYq1bS1TxIdPY88+skE/kkmI= github.com/stackitcloud/stackit-sdk-go/services/alb v0.12.1 h1:RKaxAymxlyxxE0Gta3yRuQWf07LnlcX+mfGnVB96NHA= diff --git a/stackit/internal/services/edgecloud/plans/datasource.go b/stackit/internal/services/edgecloud/plans/datasource.go index 4b80f1bfe..be753c282 100644 --- a/stackit/internal/services/edgecloud/plans/datasource.go +++ b/stackit/internal/services/edgecloud/plans/datasource.go @@ -37,8 +37,8 @@ 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, + "min_edge_hosts": types.Int32Type, + "max_edge_hosts": types.Int32Type, } // NewPlansDataSource creates a new plan data source. @@ -109,11 +109,11 @@ func (d *plansDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, Description: "Description of the plan.", Computed: true, }, - "min_edge_hosts": schema.Int64Attribute{ + "min_edge_hosts": schema.Int32Attribute{ Description: "Minimum number of Edge Cloud hosts charged.", Computed: true, }, - "max_edge_hosts": schema.Int64Attribute{ + "max_edge_hosts": schema.Int32Attribute{ Description: "Maximum number of Edge Cloud hosts that can be used.", Computed: true, },