From 564a8adb45c091cb2eab7f0f810cfdd4257e8c2b Mon Sep 17 00:00:00 2001 From: Carlo Goetz Date: Fri, 27 Mar 2026 14:42:36 +0100 Subject: [PATCH 1/7] chore(go) update to go 1.26 --- .github/workflows/ci.yaml | 2 +- CONTRIBUTION.md | 2 +- go.mod | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5e27952af..d8048908d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,7 +8,7 @@ on: - main env: - GO_VERSION: "1.24" + GO_VERSION: "1.26" CODE_COVERAGE_FILE_NAME: "coverage.out" # must be the same as in Makefile CODE_COVERAGE_ARTIFACT_NAME: "code-coverage" diff --git a/CONTRIBUTION.md b/CONTRIBUTION.md index c7312031c..18af52002 100644 --- a/CONTRIBUTION.md +++ b/CONTRIBUTION.md @@ -103,7 +103,7 @@ If you want to onboard resources of a STACKIT service `foo` that was not yet in ### Local development -To test your changes locally, you have to compile the provider (requires Go 1.24) and configure the Terraform CLI to use the local version. +To test your changes locally, you have to compile the provider (requires Go 1.26) and configure the Terraform CLI to use the local version. 1. Clone the repository. 1. Run `$ make build` to build the Terraform provider binary in `/bin/` diff --git a/go.mod b/go.mod index e7f626846..54261233d 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/stackitcloud/terraform-provider-stackit -go 1.24.0 +go 1.26.0 require ( github.com/google/go-cmp v0.7.0 From e809dc9833f5f623c50dab591d4def132398b818 Mon Sep 17 00:00:00 2001 From: Carlo Goetz Date: Fri, 27 Mar 2026 14:47:27 +0100 Subject: [PATCH 2/7] chore(go) run `go fix ./...` --- stackit/internal/conversion/conversion.go | 8 +- .../internal/conversion/conversion_test.go | 26 +- stackit/internal/core/core.go | 2 +- .../alb/applicationloadbalancer/resource.go | 2 +- .../applicationloadbalancer/resource_test.go | 232 ++--- .../authorization/authorization_acc_test.go | 12 +- .../authorization/customrole/resource_test.go | 51 +- .../roleassignments/resource_test.go | 17 +- .../services/authorization/utils/util_test.go | 29 +- stackit/internal/services/cdn/cdn_acc_test.go | 2 +- .../cdn/customdomain/datasource_test.go | 2 +- .../services/cdn/customdomain/resource.go | 6 +- .../cdn/customdomain/resource_test.go | 4 +- .../cdn/distribution/datasource_test.go | 22 +- .../services/cdn/distribution/resource.go | 23 +- .../cdn/distribution/resource_test.go | 54 +- .../services/dns/recordset/resource.go | 2 +- .../services/dns/recordset/resource_test.go | 29 +- .../internal/services/dns/zone/resource.go | 4 +- .../services/dns/zone/resource_test.go | 67 +- .../edgecloud/instance/resource_test.go | 36 +- .../edgecloud/instances/datasource_test.go | 22 +- .../services/git/instance/resource.go | 2 +- .../services/git/instance/resource_test.go | 31 +- .../iaas/affinitygroup/resource_test.go | 7 +- .../internal/services/iaas/iaas_acc_test.go | 64 +- .../services/iaas/image/datasource.go | 2 +- .../services/iaas/image/datasource_test.go | 51 +- .../internal/services/iaas/image/resource.go | 2 +- .../services/iaas/image/resource_test.go | 125 ++- .../services/iaas/imagev2/datasource.go | 2 +- .../services/iaas/imagev2/datasource_test.go | 111 ++- .../services/iaas/keypair/resource_test.go | 33 +- .../iaas/machinetype/datasource_test.go | 55 +- .../services/iaas/network/datasource_test.go | 29 +- .../services/iaas/network/resource_test.go | 189 ++-- .../services/iaas/networkarea/resource.go | 3 +- .../iaas/networkarea/resource_test.go | 93 +- .../iaas/networkarearegion/resource.go | 4 +- .../iaas/networkarearegion/resource_test.go | 79 +- .../iaas/networkarearoute/resource.go | 14 +- .../iaas/networkarearoute/resource_test.go | 64 +- .../iaas/networkinterface/resource.go | 4 +- .../iaas/networkinterface/resource_test.go | 49 +- .../iaas/networkinterfaceattach/resource.go | 2 +- .../services/iaas/project/datasource_test.go | 12 +- .../services/iaas/publicip/resource_test.go | 33 +- .../iaas/publicipassociate/resource_test.go | 13 +- .../iaas/publicipranges/datasource_test.go | 9 +- .../iaas/routingtable/route/resource.go | 13 +- .../iaas/routingtable/route/resource_test.go | 33 +- .../routingtable/routes/datasource_test.go | 17 +- .../iaas/routingtable/shared/route_test.go | 21 +- .../routingtable/table/datasource_test.go | 13 +- .../iaas/routingtable/table/resource_test.go | 33 +- .../routingtable/tables/datasource_test.go | 37 +- .../iaas/securitygroup/resource_test.go | 31 +- .../iaas/securitygrouprule/resource_test.go | 37 +- .../services/iaas/server/datasource_test.go | 31 +- .../services/iaas/server/resource_test.go | 92 +- stackit/internal/services/iaas/utils/util.go | 4 +- .../internal/services/iaas/utils/util_test.go | 6 +- .../services/iaas/volume/datasource_test.go | 33 +- .../internal/services/iaas/volume/resource.go | 5 +- .../services/iaas/volume/resource_test.go | 83 +- .../services/iaas/volumeattach/resource.go | 3 +- .../services/kms/key/resource_test.go | 16 +- .../services/kms/keyring/resource_test.go | 15 +- .../services/kms/wrapping-key/resource.go | 2 +- .../kms/wrapping-key/resource_test.go | 18 +- .../loadbalancer/loadbalancer/resource.go | 5 +- .../loadbalancer/resource_test.go | 265 +++--- .../observability-credential/resource_test.go | 25 +- .../services/logme/credential/resource.go | 2 +- .../logme/credential/resource_test.go | 27 +- .../services/logme/instance/resource.go | 8 +- .../services/logme/instance/resource_test.go | 79 +- .../services/logs/accesstoken/datasource.go | 2 +- .../logs/accesstoken/datasource_test.go | 7 +- .../services/logs/accesstoken/resource.go | 4 +- .../logs/accesstoken/resource_test.go | 15 +- .../services/logs/instance/datasource.go | 2 +- .../services/logs/instance/resource_test.go | 21 +- .../mariadb/credential/resource_test.go | 43 +- .../services/mariadb/instance/resource.go | 4 +- .../mariadb/instance/resource_test.go | 55 +- .../services/mariadb/mariadb_acc_test.go | 5 +- .../internal/services/mariadb/mariadb_test.go | 6 +- .../modelserving/token/resource_test.go | 45 +- .../mongodbflex/instance/resource_test.go | 149 ++- .../services/mongodbflex/mongodbflex_test.go | 13 +- .../mongodbflex/user/datasource_test.go | 13 +- .../mongodbflex/user/resource_test.go | 45 +- .../objectstorage/bucket/resource_test.go | 13 +- .../credential/datasource_test.go | 11 +- .../objectstorage/credential/resource_test.go | 81 +- .../credentialsgroup/resource.go | 3 +- .../credentialsgroup/resource_test.go | 39 +- .../objectstorage/objectstorage_test.go | 2 +- .../observability/alertgroup/resource_test.go | 69 +- .../observability/credential/resource_test.go | 5 +- .../observability/instance/resource.go | 21 +- .../observability/instance/resource_test.go | 361 ++++--- .../log-alertgroup/resource_test.go | 61 +- .../observability/observability_test.go | 10 +- .../observability/scrapeconfig/resource.go | 27 +- .../scrapeconfig/resource_test.go | 125 ++- .../opensearch/credential/resource_test.go | 43 +- .../services/opensearch/instance/resource.go | 6 +- .../opensearch/instance/resource_test.go | 59 +- .../opensearch/opensearch_acc_test.go | 11 +- .../services/opensearch/opensearch_test.go | 8 +- .../postgresflex/database/resource_test.go | 23 +- .../postgresflex/instance/resource_test.go | 117 ++- .../postgresflex/user/datasource_test.go | 11 +- .../postgresflex/user/resource_test.go | 37 +- .../rabbitmq/credential/resource_test.go | 47 +- .../services/rabbitmq/instance/resource.go | 6 +- .../rabbitmq/instance/resource_test.go | 57 +- .../services/rabbitmq/rabbitmq_acc_test.go | 11 +- .../services/rabbitmq/rabbitmq_test.go | 4 +- .../redis/credential/resource_test.go | 43 +- .../services/redis/instance/resource.go | 6 +- .../services/redis/instance/resource_test.go | 73 +- .../internal/services/redis/redis_acc_test.go | 11 +- .../resourcemanager/folder/resource_test.go | 5 +- .../resourcemanager/project/resource_test.go | 5 +- .../scf/organization/resource_test.go | 29 +- .../organizationmanager/datasource_test.go | 23 +- .../scf/organizationmanager/resource_test.go | 47 +- .../services/scf/platform/datasource_test.go | 19 +- stackit/internal/services/scf/scf_test.go | 3 +- .../secretsmanager/instance/resource.go | 3 +- .../secretsmanager/instance/resource_test.go | 63 +- .../secretsmanager/user/datasource_test.go | 11 +- .../secretsmanager/user/resource_test.go | 43 +- .../serverbackup/enable/datasource_test.go | 3 +- .../serverbackup/enable/resource_test.go | 3 +- .../serverbackup/schedule/resource_test.go | 35 +- .../schedule/schedules_datasource_test.go | 13 +- .../serverupdate/schedule/resource_test.go | 37 +- .../schedule/schedules_datasource_test.go | 11 +- .../serviceaccount/account/resource_test.go | 17 +- .../accounts/datasource_test.go | 27 +- .../serviceaccount/key/resource_test.go | 9 +- .../sfs/export-policy/resource_test.go | 73 +- .../sfs/resourcepool/datasource_test.go | 12 +- .../sfs/resourcepool/resource_test.go | 30 +- stackit/internal/services/sfs/sfs_test.go | 5 +- .../services/sfs/share/datasource_test.go | 6 +- .../services/sfs/share/resource_test.go | 16 +- .../services/sfs/snapshots/datasource_test.go | 21 +- .../internal/services/ske/cluster/resource.go | 4 +- .../services/ske/cluster/resource_test.go | 895 +++++++++--------- .../services/ske/kubeconfig/resource.go | 3 +- .../services/ske/kubeconfig/resource_test.go | 17 +- .../kubernetesversions/datasource_test.go | 41 +- .../machineimages/datasource_test.go | 38 +- stackit/internal/services/ske/ske_test.go | 18 +- .../sqlserverflex/instance/resource.go | 3 +- .../sqlserverflex/instance/resource_test.go | 113 ++- .../sqlserverflex/sqlserverflex_test.go | 4 +- .../sqlserverflex/user/datasource_test.go | 11 +- .../sqlserverflex/user/resource_test.go | 37 +- stackit/internal/utils/attributes.go | 2 +- stackit/internal/utils/attributes_test.go | 8 +- stackit/internal/utils/utils_test.go | 13 +- 167 files changed, 3074 insertions(+), 3220 deletions(-) diff --git a/stackit/internal/conversion/conversion.go b/stackit/internal/conversion/conversion.go index e6721ac17..8ad134ad5 100644 --- a/stackit/internal/conversion/conversion.go +++ b/stackit/internal/conversion/conversion.go @@ -63,14 +63,14 @@ func ToTerraformStringMap(ctx context.Context, m map[string]string) (basetypes.M } // ToStringInterfaceMap converts a basetypes.MapValue of Strings to a map[string]interface{}. -func ToStringInterfaceMap(ctx context.Context, m basetypes.MapValue) (map[string]interface{}, error) { +func ToStringInterfaceMap(ctx context.Context, m basetypes.MapValue) (map[string]any, error) { labels := map[string]string{} diags := m.ElementsAs(ctx, &labels, false) if diags.HasError() { return nil, fmt.Errorf("converting from MapValue: %w", core.DiagsToError(diags)) } - interfaceMap := make(map[string]interface{}, len(labels)) + interfaceMap := make(map[string]any, len(labels)) for k, v := range labels { interfaceMap[k] = v } @@ -177,7 +177,7 @@ func StringSetToPointer(set basetypes.SetValue) (*[]string, error) { // It takes a current map as it is in the terraform state and a desired map as it is in the user configuratiom // and builds a map which sets to null keys that should be removed, updates the values of existing keys and adds new keys // This method is needed because in partial updates, e.g. if the key is not provided it is ignored and not removed -func ToJSONMapPartialUpdatePayload(ctx context.Context, current, desired types.Map) (map[string]interface{}, error) { +func ToJSONMapPartialUpdatePayload(ctx context.Context, current, desired types.Map) (map[string]any, error) { currentMap, err := ToStringInterfaceMap(ctx, current) if err != nil { return nil, fmt.Errorf("converting to Go map: %w", err) @@ -188,7 +188,7 @@ func ToJSONMapPartialUpdatePayload(ctx context.Context, current, desired types.M return nil, fmt.Errorf("converting to Go map: %w", err) } - mapPayload := map[string]interface{}{} + mapPayload := map[string]any{} // Update and remove existing keys for k := range currentMap { if desiredValue, ok := desiredMap[k]; ok { diff --git a/stackit/internal/conversion/conversion_test.go b/stackit/internal/conversion/conversion_test.go index 3bfb042c5..1841f6b64 100644 --- a/stackit/internal/conversion/conversion_test.go +++ b/stackit/internal/conversion/conversion_test.go @@ -24,7 +24,7 @@ func TestFromTerraformStringMapToInterfaceMap(t *testing.T) { tests := []struct { name string args args - want map[string]interface{} + want map[string]any wantErr bool }{ { @@ -37,7 +37,7 @@ func TestFromTerraformStringMapToInterfaceMap(t *testing.T) { "key3": types.StringValue("value3"), }), }, - want: map[string]interface{}{ + want: map[string]any{ "key": "value", "key2": "value2", "key3": "value3", @@ -50,7 +50,7 @@ func TestFromTerraformStringMapToInterfaceMap(t *testing.T) { ctx: context.Background(), m: types.MapValueMust(types.StringType, map[string]attr.Value{}), }, - want: map[string]interface{}{}, + want: map[string]any{}, wantErr: false, }, { @@ -59,7 +59,7 @@ func TestFromTerraformStringMapToInterfaceMap(t *testing.T) { ctx: context.Background(), m: types.MapNull(types.StringType), }, - want: map[string]interface{}{}, + want: map[string]any{}, wantErr: false, }, { @@ -92,7 +92,7 @@ func TestToJSONMapUpdatePayload(t *testing.T) { description string currentLabels types.Map desiredLabels types.Map - expected map[string]interface{} + expected map[string]any isValid bool }{ { @@ -103,7 +103,7 @@ func TestToJSONMapUpdatePayload(t *testing.T) { types.MapValueMust(types.StringType, map[string]attr.Value{ "key": types.StringValue("value"), }), - map[string]interface{}{ + map[string]any{ "key": "value", }, true, @@ -116,7 +116,7 @@ func TestToJSONMapUpdatePayload(t *testing.T) { types.MapValueMust(types.StringType, map[string]attr.Value{ "key": types.StringValue("updated_value"), }), - map[string]interface{}{ + map[string]any{ "key": "updated_value", }, true, @@ -130,7 +130,7 @@ func TestToJSONMapUpdatePayload(t *testing.T) { types.MapValueMust(types.StringType, map[string]attr.Value{ "key": types.StringValue("value"), }), - map[string]interface{}{ + map[string]any{ "key": "value", "key2": nil, }, @@ -145,7 +145,7 @@ func TestToJSONMapUpdatePayload(t *testing.T) { "key": types.StringValue("value"), "key2": types.StringValue("value2"), }), - map[string]interface{}{ + map[string]any{ "key": "value", "key2": "value2", }, @@ -158,7 +158,7 @@ func TestToJSONMapUpdatePayload(t *testing.T) { "key2": types.StringValue("value2"), }), types.MapValueMust(types.StringType, map[string]attr.Value{}), - map[string]interface{}{ + map[string]any{ "key": nil, "key2": nil, }, @@ -171,7 +171,7 @@ func TestToJSONMapUpdatePayload(t *testing.T) { "key2": types.StringValue("value2"), }), types.MapNull(types.StringType), - map[string]interface{}{ + map[string]any{ "key": nil, "key2": nil, }, @@ -184,7 +184,7 @@ func TestToJSONMapUpdatePayload(t *testing.T) { "key": types.StringValue("value"), "key2": types.StringValue("value2"), }), - map[string]interface{}{ + map[string]any{ "key": "value", "key2": "value2", }, @@ -197,7 +197,7 @@ func TestToJSONMapUpdatePayload(t *testing.T) { "key": types.StringValue("value"), "key2": types.StringValue("value2"), }), - map[string]interface{}{ + map[string]any{ "key": "value", "key2": "value2", }, diff --git a/stackit/internal/core/core.go b/stackit/internal/core/core.go index 59a74d419..2c1d21feb 100644 --- a/stackit/internal/core/core.go +++ b/stackit/internal/core/core.go @@ -157,7 +157,7 @@ func LogResponse(ctx context.Context) context.Context { traceId := runtime.GetTraceId(ctx) ctx = tflog.SetField(ctx, "x-trace-id", traceId) - tflog.Info(ctx, "response data", map[string]interface{}{ + tflog.Info(ctx, "response data", map[string]any{ "x-trace-id": traceId, }) return ctx diff --git a/stackit/internal/services/alb/applicationloadbalancer/resource.go b/stackit/internal/services/alb/applicationloadbalancer/resource.go index eb9b647a0..136c7c2cd 100644 --- a/stackit/internal/services/alb/applicationloadbalancer/resource.go +++ b/stackit/internal/services/alb/applicationloadbalancer/resource.go @@ -1173,7 +1173,7 @@ func (r *applicationLoadBalancerResource) Create(ctx context.Context, req resour ctx = core.LogResponse(ctx) - ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]interface{}{ + ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{ "project_id": projectId, "region": region, "name": *createResp.Name, diff --git a/stackit/internal/services/alb/applicationloadbalancer/resource_test.go b/stackit/internal/services/alb/applicationloadbalancer/resource_test.go index ee33ce18e..8f62ababc 100644 --- a/stackit/internal/services/alb/applicationloadbalancer/resource_test.go +++ b/stackit/internal/services/alb/applicationloadbalancer/resource_test.go @@ -337,62 +337,62 @@ func fixtureUpdatePayload(lb *albSdk.LoadBalancer) *albSdk.UpdateLoadBalancerPay func fixtureApplicationLoadBalancer(explicitBool *bool, mods ...func(m *albSdk.LoadBalancer)) *albSdk.LoadBalancer { resp := &albSdk.LoadBalancer{ DisableTargetSecurityGroupAssignment: explicitBool, - ExternalAddress: utils.Ptr(externalAddress), - Errors: utils.Ptr([]albSdk.LoadBalancerError{ + ExternalAddress: new(externalAddress), + Errors: new([]albSdk.LoadBalancerError{ { - Description: utils.Ptr("quota test error"), + Description: new("quota test error"), Type: utils.Ptr(albSdk.LOADBALANCERERRORTYPE_QUOTA_SECGROUP_EXCEEDED), }, { - Description: utils.Ptr("fip test error"), + Description: new("fip test error"), Type: utils.Ptr(albSdk.LOADBALANCERERRORTYPE_FIP_NOT_CONFIGURED), }, }), - Name: utils.Ptr(lbName), - PlanId: utils.Ptr("p10"), - PrivateAddress: utils.Ptr("10.1.11.0"), - Region: utils.Ptr(region), + Name: new(lbName), + PlanId: new("p10"), + PrivateAddress: new("10.1.11.0"), + Region: new(region), Status: utils.Ptr(albSdk.LoadBalancerStatus("STATUS_READY")), - Version: utils.Ptr(lbVersion), + Version: new(lbVersion), Labels: &map[string]string{ "key": "value", "key2": "value2", }, Networks: &[]albSdk.Network{ { - NetworkId: utils.Ptr("c7c92cc1-a6bd-4e15-a129-b6e2b9899bbc"), + NetworkId: new("c7c92cc1-a6bd-4e15-a129-b6e2b9899bbc"), Role: utils.Ptr(albSdk.NetworkRole("ROLE_LISTENERS")), }, { - NetworkId: utils.Ptr("ed3f1822-ca1c-4969-bea6-74c6b3e9aa40"), + NetworkId: new("ed3f1822-ca1c-4969-bea6-74c6b3e9aa40"), Role: utils.Ptr(albSdk.NetworkRole("ROLE_TARGETS")), }, }, Listeners: &[]albSdk.Listener{ { - Name: utils.Ptr("http-80"), - Port: utils.Ptr(int64(80)), + Name: new("http-80"), + Port: new(int64(80)), Protocol: utils.Ptr(albSdk.ListenerProtocol("PROTOCOL_HTTP")), Http: &albSdk.ProtocolOptionsHTTP{ Hosts: &[]albSdk.HostConfig{ { - Host: utils.Ptr("*"), + Host: new("*"), Rules: &[]albSdk.Rule{ { - TargetPool: utils.Ptr(targetPoolName), + TargetPool: new(targetPoolName), WebSocket: explicitBool, Path: &albSdk.Path{ - Prefix: utils.Ptr("/"), + Prefix: new("/"), }, Headers: &[]albSdk.HttpHeader{ - {Name: utils.Ptr("a-header"), ExactMatch: utils.Ptr("value")}, + {Name: new("a-header"), ExactMatch: new("value")}, }, QueryParameters: &[]albSdk.QueryParameter{ - {Name: utils.Ptr("a_query_parameter"), ExactMatch: utils.Ptr("value")}, + {Name: new("a_query_parameter"), ExactMatch: new("value")}, }, CookiePersistence: &albSdk.CookiePersistence{ - Name: utils.Ptr("cookie_name"), - Ttl: utils.Ptr("3s"), + Name: new("cookie_name"), + Ttl: new("3s"), }, }, }, @@ -400,54 +400,54 @@ func fixtureApplicationLoadBalancer(explicitBool *bool, mods ...func(m *albSdk.L }, }, Https: &albSdk.ProtocolOptionsHTTPS{ - CertificateConfig: utils.Ptr(albSdk.CertificateConfig{ + CertificateConfig: new(albSdk.CertificateConfig{ CertificateIds: &[]string{ credentialsRef, }, }), }, - WafConfigName: utils.Ptr("my-waf-config"), + WafConfigName: new("my-waf-config"), }, }, TargetPools: &[]albSdk.TargetPool{ { - Name: utils.Ptr(targetPoolName), - TargetPort: utils.Ptr(int64(80)), + Name: new(targetPoolName), + TargetPort: new(int64(80)), Targets: &[]albSdk.Target{ { - DisplayName: utils.Ptr("test-backend-server"), - Ip: utils.Ptr("192.168.0.218"), + DisplayName: new("test-backend-server"), + Ip: new("192.168.0.218"), }, }, TlsConfig: &albSdk.TargetPoolTlsConfig{ Enabled: explicitBool, SkipCertificateValidation: explicitBool, - CustomCa: utils.Ptr("LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURDekNDQWZPZ0F3SUJBZ0lVVHlQc1RXQzlseTdvK3dORlltMHV1MStQOElFd0RRWUpLb1pJaHZjTkFRRUwKQlFBd0ZURVRNQkVHQTFVRUF3d0tUWGxEZFhOMGIyMURRVEFlRncweU5UQXlNVGt4T1RJME1qQmFGdzB5TmpBeQpNVGt4T1RJME1qQmFNQlV4RXpBUkJnTlZCQU1NQ2sxNVEzVnpkRzl0UTBFd2dnRWlNQTBHQ1NxR1NJYjNEUUVCCkFRVUFBNElCRHdBd2dnRUtBb0lCQVFDUU1FWUtiaU54VTM3ZkV3Qk94a3ZDc2hCUiswTXd4d0xXOE1pMy9wdm8KbjNodXhqY203RWFLVzlyN2tJYW9IWGJUUzF0bk82ckhBSEtCRHh6dW9ZRDdDMlNNU2lMeGRkcXVOUnZwa0xhUAo4cUFYbmVRWTJWUDdMenNBZ3NDMDRQS0cwWUMxTmdGNXNKR3NpV0lSR0ltK2NzWUxuUE1ud2FBR3g0SXZZNm1ICkFtTTY0YjZRUkNnMzZMSytQNk45S1R2U1FMdnZtRmRrQTJzRFRvQ21OL0FtcDZ4TkRGcSthUUdMd2RRUXFIRFAKVGFVcVBtRXlpRkhLdkZVYUZNTlFWazhCMU9tOEFTbzY5bThVM0VhdDRaT1ZXMXRpdEUzOTNRa09kQTZaeXBNQwpySkpwZU5OTExKcTNtSU9XT2Q3R0V5QXZqVWZtSndHaHFFRlM3bE1HNjdobkFnTUJBQUdqVXpCUk1CMEdBMVVkCkRnUVdCQlNrL0lNNWphT0FKTDMvS255cTNjVnZhMDRZWkRBZkJnTlZIU01FR0RBV2dCU2svSU01amFPQUpMMy8KS255cTNjVnZhMDRZWkRBUEJnTlZIUk1CQWY4RUJUQURBUUgvTUEwR0NTcUdTSWIzRFFFQkN3VUFBNElCQVFCZQpaL21FOHJOSWJOYkhRZXAvVnBwc2hhWlV6Z2R5NG5zbWgwd3Z4TXVISVFQMEtIcnhMQ2toT243QTlmdTRtWS9QClErOFFxbG5qVHNNNGNxaXVGY2Q1VjFOazlWRi9lNVgzSFhDREhoL2pCRncrTzVUR1ZBUi83REJ3MzFsWXYvTHQKSGFra2pRQ2Rhd3V2SDNvc08vVWtFbE0vaTJLQytpWUJhdlRlbm05N0FSN1dHZ1cxNS9NSXF4TmFZRStuSnRoLwpkY1ZEMGI1cVN1WVFhRW1aM0N6TVVpMTg4UitnbzVvekNmMmNPYWErMy9MRVlBYUkzdktpU0U4S1Rzc2h5b0ttCk82WVpxclZ4UUNXQ0RUT3NkMjhrN2xIdDh3SitqelljakN1NjBEVXBnMVpwWStabm1yRTh2UFBEYi96WGhCbjYKL2xsWFRXT1VqbXVUS25Hc0lEUDUKLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQ=="), + CustomCa: new("LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURDekNDQWZPZ0F3SUJBZ0lVVHlQc1RXQzlseTdvK3dORlltMHV1MStQOElFd0RRWUpLb1pJaHZjTkFRRUwKQlFBd0ZURVRNQkVHQTFVRUF3d0tUWGxEZFhOMGIyMURRVEFlRncweU5UQXlNVGt4T1RJME1qQmFGdzB5TmpBeQpNVGt4T1RJME1qQmFNQlV4RXpBUkJnTlZCQU1NQ2sxNVEzVnpkRzl0UTBFd2dnRWlNQTBHQ1NxR1NJYjNEUUVCCkFRVUFBNElCRHdBd2dnRUtBb0lCQVFDUU1FWUtiaU54VTM3ZkV3Qk94a3ZDc2hCUiswTXd4d0xXOE1pMy9wdm8KbjNodXhqY203RWFLVzlyN2tJYW9IWGJUUzF0bk82ckhBSEtCRHh6dW9ZRDdDMlNNU2lMeGRkcXVOUnZwa0xhUAo4cUFYbmVRWTJWUDdMenNBZ3NDMDRQS0cwWUMxTmdGNXNKR3NpV0lSR0ltK2NzWUxuUE1ud2FBR3g0SXZZNm1ICkFtTTY0YjZRUkNnMzZMSytQNk45S1R2U1FMdnZtRmRrQTJzRFRvQ21OL0FtcDZ4TkRGcSthUUdMd2RRUXFIRFAKVGFVcVBtRXlpRkhLdkZVYUZNTlFWazhCMU9tOEFTbzY5bThVM0VhdDRaT1ZXMXRpdEUzOTNRa09kQTZaeXBNQwpySkpwZU5OTExKcTNtSU9XT2Q3R0V5QXZqVWZtSndHaHFFRlM3bE1HNjdobkFnTUJBQUdqVXpCUk1CMEdBMVVkCkRnUVdCQlNrL0lNNWphT0FKTDMvS255cTNjVnZhMDRZWkRBZkJnTlZIU01FR0RBV2dCU2svSU01amFPQUpMMy8KS255cTNjVnZhMDRZWkRBUEJnTlZIUk1CQWY4RUJUQURBUUgvTUEwR0NTcUdTSWIzRFFFQkN3VUFBNElCQVFCZQpaL21FOHJOSWJOYkhRZXAvVnBwc2hhWlV6Z2R5NG5zbWgwd3Z4TXVISVFQMEtIcnhMQ2toT243QTlmdTRtWS9QClErOFFxbG5qVHNNNGNxaXVGY2Q1VjFOazlWRi9lNVgzSFhDREhoL2pCRncrTzVUR1ZBUi83REJ3MzFsWXYvTHQKSGFra2pRQ2Rhd3V2SDNvc08vVWtFbE0vaTJLQytpWUJhdlRlbm05N0FSN1dHZ1cxNS9NSXF4TmFZRStuSnRoLwpkY1ZEMGI1cVN1WVFhRW1aM0N6TVVpMTg4UitnbzVvekNmMmNPYWErMy9MRVlBYUkzdktpU0U4S1Rzc2h5b0ttCk82WVpxclZ4UUNXQ0RUT3NkMjhrN2xIdDh3SitqelljakN1NjBEVXBnMVpwWStabm1yRTh2UFBEYi96WGhCbjYKL2xsWFRXT1VqbXVUS25Hc0lEUDUKLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQ=="), }, ActiveHealthCheck: &albSdk.ActiveHealthCheck{ - HealthyThreshold: utils.Ptr(int64(1)), - UnhealthyThreshold: utils.Ptr(int64(5)), - Interval: utils.Ptr("2s"), - IntervalJitter: utils.Ptr("3s"), - Timeout: utils.Ptr("4s"), + HealthyThreshold: new(int64(1)), + UnhealthyThreshold: new(int64(5)), + Interval: new("2s"), + IntervalJitter: new("3s"), + Timeout: new("4s"), HttpHealthChecks: &albSdk.HttpHealthChecks{ - Path: utils.Ptr("/health"), + Path: new("/health"), OkStatuses: &[]string{"200", "201"}, }, }, }, }, - Options: utils.Ptr(albSdk.LoadBalancerOptions{ + Options: new(albSdk.LoadBalancerOptions{ EphemeralAddress: explicitBool, PrivateNetworkOnly: explicitBool, Observability: &albSdk.LoadbalancerOptionObservability{ Logs: &albSdk.LoadbalancerOptionLogs{ - CredentialsRef: utils.Ptr(credentialsRef), - PushUrl: utils.Ptr("http://www.example.org/push"), + CredentialsRef: new(credentialsRef), + PushUrl: new("http://www.example.org/push"), }, Metrics: &albSdk.LoadbalancerOptionMetrics{ - CredentialsRef: utils.Ptr(credentialsRef), - PushUrl: utils.Ptr("http://www.example.org/pull"), + CredentialsRef: new(credentialsRef), + PushUrl: new("http://www.example.org/pull"), }, }, AccessControl: &albSdk.LoadbalancerOptionAccessControl{ @@ -455,12 +455,12 @@ func fixtureApplicationLoadBalancer(explicitBool *bool, mods ...func(m *albSdk.L }, }), LoadBalancerSecurityGroup: &albSdk.CreateLoadBalancerPayloadLoadBalancerSecurityGroup{ - Id: utils.Ptr(sgLBID), - Name: utils.Ptr("loadbalancer/" + lbName + "/backend-port"), + Id: new(sgLBID), + Name: new("loadbalancer/" + lbName + "/backend-port"), }, TargetSecurityGroup: &albSdk.CreateLoadBalancerPayloadTargetSecurityGroup{ - Id: utils.Ptr(sgTargetID), - Name: utils.Ptr("loadbalancer/" + lbName + "/backend"), + Id: new(sgTargetID), + Name: new("loadbalancer/" + lbName + "/backend"), }, } for _, mod := range mods { @@ -577,7 +577,7 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue(projectID), }, region: testRegion, - expected: fixtureModel(utils.Ptr(false)), + expected: fixtureModel(new(false)), isValid: true, }, { @@ -619,43 +619,43 @@ func TestMapFields(t *testing.T) { Name: types.StringValue(lbName), }, region: testRegion, - expected: fixtureModel(utils.Ptr(false)), + expected: fixtureModel(new(false)), isValid: true, }, { description: "false - explicitly set", - input: fixtureApplicationLoadBalancer(utils.Ptr(false)), + input: fixtureApplicationLoadBalancer(new(false)), output: &Model{ ProjectId: types.StringValue(projectID), }, region: testRegion, - expected: fixtureModel(utils.Ptr(false)), + expected: fixtureModel(new(false)), isValid: true, }, { description: "true - explicitly set", - input: fixtureApplicationLoadBalancer(utils.Ptr(true)), + input: fixtureApplicationLoadBalancer(new(true)), output: &Model{ ProjectId: types.StringValue(projectID), }, region: testRegion, - expected: fixtureModel(utils.Ptr(true)), + expected: fixtureModel(new(true)), isValid: true, }, { description: "false - only in model set", input: fixtureApplicationLoadBalancer(nil), - output: fixtureModel(utils.Ptr(false)), + output: fixtureModel(new(false)), region: testRegion, - expected: fixtureModel(utils.Ptr(false)), + expected: fixtureModel(new(false)), isValid: true, }, { description: "true - only in model set", input: fixtureApplicationLoadBalancer(nil), - output: fixtureModel(utils.Ptr(true)), + output: fixtureModel(new(true)), region: testRegion, - expected: fixtureModel(utils.Ptr(false)), + expected: fixtureModel(new(false)), isValid: true, }, { @@ -692,7 +692,7 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue(projectID), }, region: testRegion, - expected: fixtureModel(utils.Ptr(false), func(m *Model) { + expected: fixtureModel(new(false), func(m *Model) { m.TargetPools = types.ListValueMust( types.ObjectType{AttrTypes: targetPoolTypes}, []attr.Value{ @@ -716,20 +716,20 @@ func TestMapFields(t *testing.T) { input: fixtureApplicationLoadBalancer(nil, func(m *albSdk.LoadBalancer) { m.TargetPools = &[]albSdk.TargetPool{ { - Name: utils.Ptr(targetPoolName), - TargetPort: utils.Ptr(int64(80)), + Name: new(targetPoolName), + TargetPort: new(int64(80)), Targets: &[]albSdk.Target{ { - DisplayName: utils.Ptr("test-backend-server"), - Ip: utils.Ptr("192.168.0.218"), + DisplayName: new("test-backend-server"), + Ip: new("192.168.0.218"), }, }, ActiveHealthCheck: &albSdk.ActiveHealthCheck{ - HealthyThreshold: utils.Ptr(int64(1)), - UnhealthyThreshold: utils.Ptr(int64(5)), - Interval: utils.Ptr("2s"), - IntervalJitter: utils.Ptr("3s"), - Timeout: utils.Ptr("4s"), + HealthyThreshold: new(int64(1)), + UnhealthyThreshold: new(int64(5)), + Interval: new("2s"), + IntervalJitter: new("3s"), + Timeout: new("4s"), }, }, } @@ -738,7 +738,7 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue(projectID), }, region: testRegion, - expected: fixtureModel(utils.Ptr(false), func(m *Model) { + expected: fixtureModel(new(false), func(m *Model) { m.TargetPools = types.ListValueMust( types.ObjectType{AttrTypes: targetPoolTypes}, []attr.Value{ @@ -792,7 +792,7 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue(projectID), }, region: testRegion, - expected: fixtureModel(utils.Ptr(false), func(m *Model) { + expected: fixtureModel(new(false), func(m *Model) { m.Options = types.ObjectNull(optionsTypes) }), isValid: true, @@ -802,29 +802,29 @@ func TestMapFields(t *testing.T) { input: fixtureApplicationLoadBalancer(nil, func(m *albSdk.LoadBalancer) { m.Listeners = &[]albSdk.Listener{ { - Name: utils.Ptr("http-80"), - Port: utils.Ptr(int64(80)), + Name: new("http-80"), + Port: new(int64(80)), Protocol: utils.Ptr(albSdk.ListenerProtocol("PROTOCOL_HTTP")), Http: &albSdk.ProtocolOptionsHTTP{ Hosts: &[]albSdk.HostConfig{ { - Host: utils.Ptr("*"), + Host: new("*"), Rules: &[]albSdk.Rule{ { - TargetPool: utils.Ptr(targetPoolName), + TargetPool: new(targetPoolName), WebSocket: nil, Path: &albSdk.Path{ - Prefix: utils.Ptr("/"), + Prefix: new("/"), }, Headers: &[]albSdk.HttpHeader{ - {Name: utils.Ptr("a-header"), ExactMatch: utils.Ptr("value")}, + {Name: new("a-header"), ExactMatch: new("value")}, }, QueryParameters: &[]albSdk.QueryParameter{ - {Name: utils.Ptr("a_query_parameter"), ExactMatch: utils.Ptr("value")}, + {Name: new("a_query_parameter"), ExactMatch: new("value")}, }, CookiePersistence: &albSdk.CookiePersistence{ - Name: utils.Ptr("cookie_name"), - Ttl: utils.Ptr("3s"), + Name: new("cookie_name"), + Ttl: new("3s"), }, }, }, @@ -834,7 +834,7 @@ func TestMapFields(t *testing.T) { Https: &albSdk.ProtocolOptionsHTTPS{ CertificateConfig: nil, }, - WafConfigName: utils.Ptr("my-waf-config"), + WafConfigName: new("my-waf-config"), }, } }), @@ -842,7 +842,7 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue(projectID), }, region: testRegion, - expected: fixtureModel(utils.Ptr(false), func(m *Model) { + expected: fixtureModel(new(false), func(m *Model) { m.Listeners = types.ListValueMust( types.ObjectType{AttrTypes: listenerTypes}, []attr.Value{ @@ -928,29 +928,29 @@ func TestMapFields(t *testing.T) { input: fixtureApplicationLoadBalancer(nil, func(m *albSdk.LoadBalancer) { m.Listeners = &[]albSdk.Listener{ { - Name: utils.Ptr("http-80"), - Port: utils.Ptr(int64(80)), + Name: new("http-80"), + Port: new(int64(80)), Protocol: utils.Ptr(albSdk.ListenerProtocol("PROTOCOL_HTTP")), Http: &albSdk.ProtocolOptionsHTTP{ Hosts: &[]albSdk.HostConfig{ { - Host: utils.Ptr("*"), + Host: new("*"), Rules: &[]albSdk.Rule{ { - TargetPool: utils.Ptr(targetPoolName), + TargetPool: new(targetPoolName), WebSocket: nil, Path: &albSdk.Path{ - Prefix: utils.Ptr("/"), + Prefix: new("/"), }, Headers: &[]albSdk.HttpHeader{ - {Name: utils.Ptr("a-header"), ExactMatch: utils.Ptr("value")}, + {Name: new("a-header"), ExactMatch: new("value")}, }, QueryParameters: &[]albSdk.QueryParameter{ - {Name: utils.Ptr("a_query_parameter"), ExactMatch: utils.Ptr("value")}, + {Name: new("a_query_parameter"), ExactMatch: new("value")}, }, CookiePersistence: &albSdk.CookiePersistence{ - Name: utils.Ptr("cookie_name"), - Ttl: utils.Ptr("3s"), + Name: new("cookie_name"), + Ttl: new("3s"), }, }, }, @@ -958,7 +958,7 @@ func TestMapFields(t *testing.T) { }, }, Https: nil, - WafConfigName: utils.Ptr("my-waf-config"), + WafConfigName: new("my-waf-config"), }, } }), @@ -966,7 +966,7 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue(projectID), }, region: testRegion, - expected: fixtureModel(utils.Ptr(false), func(m *Model) { + expected: fixtureModel(new(false), func(m *Model) { m.Listeners = types.ListValueMust( types.ObjectType{AttrTypes: listenerTypes}, []attr.Value{ @@ -1047,16 +1047,16 @@ func TestMapFields(t *testing.T) { input: fixtureApplicationLoadBalancer(nil, func(m *albSdk.LoadBalancer) { m.Listeners = &[]albSdk.Listener{ { - Name: utils.Ptr("http-80"), - Port: utils.Ptr(int64(80)), + Name: new("http-80"), + Port: new(int64(80)), Protocol: utils.Ptr(albSdk.ListenerProtocol("PROTOCOL_HTTP")), Http: &albSdk.ProtocolOptionsHTTP{ Hosts: &[]albSdk.HostConfig{ { - Host: utils.Ptr("*"), + Host: new("*"), Rules: &[]albSdk.Rule{ { - TargetPool: utils.Ptr(targetPoolName), + TargetPool: new(targetPoolName), WebSocket: nil, Path: nil, Headers: nil, @@ -1068,13 +1068,13 @@ func TestMapFields(t *testing.T) { }, }, Https: &albSdk.ProtocolOptionsHTTPS{ - CertificateConfig: utils.Ptr(albSdk.CertificateConfig{ + CertificateConfig: new(albSdk.CertificateConfig{ CertificateIds: &[]string{ credentialsRef, }, }), }, - WafConfigName: utils.Ptr("my-waf-config"), + WafConfigName: new("my-waf-config"), }, } }), @@ -1082,7 +1082,7 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue(projectID), }, region: testRegion, - expected: fixtureModel(utils.Ptr(false), func(m *Model) { + expected: fixtureModel(new(false), func(m *Model) { m.Listeners = types.ListValueMust( types.ObjectType{AttrTypes: listenerTypes}, []attr.Value{ @@ -1149,25 +1149,25 @@ func TestMapFields(t *testing.T) { input: fixtureApplicationLoadBalancer(nil, func(m *albSdk.LoadBalancer) { m.Listeners = &[]albSdk.Listener{ { - Name: utils.Ptr("http-80"), - Port: utils.Ptr(int64(80)), + Name: new("http-80"), + Port: new(int64(80)), Protocol: utils.Ptr(albSdk.ListenerProtocol("PROTOCOL_HTTP")), Http: &albSdk.ProtocolOptionsHTTP{ Hosts: &[]albSdk.HostConfig{ { - Host: utils.Ptr("*"), + Host: new("*"), Rules: nil, }, }, }, Https: &albSdk.ProtocolOptionsHTTPS{ - CertificateConfig: utils.Ptr(albSdk.CertificateConfig{ + CertificateConfig: new(albSdk.CertificateConfig{ CertificateIds: &[]string{ credentialsRef, }, }), }, - WafConfigName: utils.Ptr("my-waf-config"), + WafConfigName: new("my-waf-config"), }, } }), @@ -1175,7 +1175,7 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue(projectID), }, region: testRegion, - expected: fixtureModel(utils.Ptr(false), func(m *Model) { + expected: fixtureModel(new(false), func(m *Model) { m.Listeners = types.ListValueMust( types.ObjectType{AttrTypes: listenerTypes}, []attr.Value{ @@ -1229,20 +1229,20 @@ func TestMapFields(t *testing.T) { input: fixtureApplicationLoadBalancer(nil, func(m *albSdk.LoadBalancer) { m.Listeners = &[]albSdk.Listener{ { - Name: utils.Ptr("http-80"), - Port: utils.Ptr(int64(80)), + Name: new("http-80"), + Port: new(int64(80)), Protocol: utils.Ptr(albSdk.ListenerProtocol("PROTOCOL_HTTP")), Http: &albSdk.ProtocolOptionsHTTP{ Hosts: nil, }, Https: &albSdk.ProtocolOptionsHTTPS{ - CertificateConfig: utils.Ptr(albSdk.CertificateConfig{ + CertificateConfig: new(albSdk.CertificateConfig{ CertificateIds: &[]string{ credentialsRef, }, }), }, - WafConfigName: utils.Ptr("my-waf-config"), + WafConfigName: new("my-waf-config"), }, } }), @@ -1250,7 +1250,7 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue(projectID), }, region: testRegion, - expected: fixtureModel(utils.Ptr(false), func(m *Model) { + expected: fixtureModel(new(false), func(m *Model) { m.Listeners = types.ListValueMust( types.ObjectType{AttrTypes: listenerTypes}, []attr.Value{ @@ -1295,18 +1295,18 @@ func TestMapFields(t *testing.T) { input: fixtureApplicationLoadBalancer(nil, func(m *albSdk.LoadBalancer) { m.Listeners = &[]albSdk.Listener{ { - Name: utils.Ptr("http-80"), - Port: utils.Ptr(int64(80)), + Name: new("http-80"), + Port: new(int64(80)), Protocol: utils.Ptr(albSdk.ListenerProtocol("PROTOCOL_HTTP")), Http: nil, Https: &albSdk.ProtocolOptionsHTTPS{ - CertificateConfig: utils.Ptr(albSdk.CertificateConfig{ + CertificateConfig: new(albSdk.CertificateConfig{ CertificateIds: &[]string{ credentialsRef, }, }), }, - WafConfigName: utils.Ptr("my-waf-config"), + WafConfigName: new("my-waf-config"), }, } }), @@ -1314,7 +1314,7 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue(projectID), }, region: testRegion, - expected: fixtureModel(utils.Ptr(false), func(m *Model) { + expected: fixtureModel(new(false), func(m *Model) { m.Listeners = types.ListValueMust( types.ObjectType{AttrTypes: listenerTypes}, []attr.Value{ @@ -1381,7 +1381,7 @@ func Test_toExternalAddress(t *testing.T) { input: &Model{ ExternalAddress: types.StringValue(externalAddress), }, - expected: utils.Ptr(externalAddress), + expected: new(externalAddress), isValid: true, }, { @@ -1396,7 +1396,7 @@ func Test_toExternalAddress(t *testing.T) { "ephemeral_address": types.BoolNull(), }), }, - expected: utils.Ptr(externalAddress), + expected: new(externalAddress), isValid: true, }, { @@ -1426,7 +1426,7 @@ func Test_toExternalAddress(t *testing.T) { "ephemeral_address": types.BoolValue(false), }), }, - expected: utils.Ptr(externalAddress), + expected: new(externalAddress), isValid: true, }, { @@ -1471,7 +1471,7 @@ func Test_toExternalAddress(t *testing.T) { "ephemeral_address": types.BoolValue(false), }), }, - expected: utils.Ptr(externalAddress), + expected: new(externalAddress), isValid: true, }, { @@ -1486,7 +1486,7 @@ func Test_toExternalAddress(t *testing.T) { "ephemeral_address": types.BoolNull(), }), }, - expected: utils.Ptr(externalAddress), + expected: new(externalAddress), isValid: true, }, } @@ -1527,7 +1527,7 @@ func Test_toPathPayload(t *testing.T) { }, expected: &albSdk.Path{ ExactMatch: nil, - Prefix: utils.Ptr("/"), + Prefix: new("/"), }, isValid: true, }, @@ -1541,7 +1541,7 @@ func Test_toPathPayload(t *testing.T) { }), }, expected: &albSdk.Path{ - ExactMatch: utils.Ptr("exact-match"), + ExactMatch: new("exact-match"), Prefix: nil, }, isValid: true, diff --git a/stackit/internal/services/authorization/authorization_acc_test.go b/stackit/internal/services/authorization/authorization_acc_test.go index 274d7f0d6..e1b0d6e17 100644 --- a/stackit/internal/services/authorization/authorization_acc_test.go +++ b/stackit/internal/services/authorization/authorization_acc_test.go @@ -682,8 +682,8 @@ func testAccCheckOrganizationRoleAssignmentDestroy(s *terraform.State) error { orgRoleAssignmentsToDestroy = append( orgRoleAssignmentsToDestroy, authorization.Member{ - Role: utils.Ptr(terraformId[1]), - Subject: utils.Ptr(terraformId[2]), + Role: new(terraformId[1]), + Subject: new(terraformId[2]), }, ) } @@ -694,7 +694,7 @@ func testAccCheckOrganizationRoleAssignmentDestroy(s *terraform.State) error { containerParentId := testutil.OrganizationId payload := authorization.RemoveMembersPayload{ - ResourceType: utils.Ptr("organization"), + ResourceType: new("organization"), Members: &orgRoleAssignmentsToDestroy, } @@ -730,11 +730,11 @@ func testAccCheckServiceAccountRoleAssignmentDestroy(s *terraform.State) error { resourceId := terraformId[0] payload := authorization.RemoveMembersPayload{ - ResourceType: utils.Ptr("service-account"), + ResourceType: new("service-account"), Members: &[]authorization.Member{ { - Role: utils.Ptr(terraformId[1]), - Subject: utils.Ptr(terraformId[2]), + Role: new(terraformId[1]), + Subject: new(terraformId[2]), }, }, } diff --git a/stackit/internal/services/authorization/customrole/resource_test.go b/stackit/internal/services/authorization/customrole/resource_test.go index b8c4f3cbd..8d2a0c82e 100644 --- a/stackit/internal/services/authorization/customrole/resource_test.go +++ b/stackit/internal/services/authorization/customrole/resource_test.go @@ -9,7 +9,6 @@ import ( "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/authorization" ) @@ -29,15 +28,15 @@ func TestMapFields(t *testing.T) { description: "full_input", input: &authorization.GetRoleResponse{ ResourceId: &testProjectId, - ResourceType: utils.Ptr("project"), - Role: utils.Ptr(authorization.Role{ + ResourceType: new("project"), + Role: new(authorization.Role{ Id: &testRoleId, - Name: utils.Ptr("role-name"), - Description: utils.Ptr("Some description"), - Permissions: utils.Ptr([]authorization.Permission{ + Name: new("role-name"), + Description: new("Some description"), + Permissions: new([]authorization.Permission{ { - Name: utils.Ptr("iam.subject.get"), - Description: utils.Ptr("Can read subjects."), + Name: new("iam.subject.get"), + Description: new("Can read subjects."), }, }), }), @@ -58,12 +57,12 @@ func TestMapFields(t *testing.T) { description: "partial_input", input: &authorization.GetRoleResponse{ ResourceId: &testProjectId, - ResourceType: utils.Ptr("project"), - Role: utils.Ptr(authorization.Role{ + ResourceType: new("project"), + Role: new(authorization.Role{ Id: &testRoleId, - Permissions: utils.Ptr([]authorization.Permission{ + Permissions: new([]authorization.Permission{ { - Name: utils.Ptr("iam.subject.get"), + Name: new("iam.subject.get"), }, }), }), @@ -82,10 +81,10 @@ func TestMapFields(t *testing.T) { description: "partial_input_without_permissions", input: &authorization.GetRoleResponse{ ResourceId: &testProjectId, - ResourceType: utils.Ptr("project"), - Role: utils.Ptr(authorization.Role{ + ResourceType: new("project"), + Role: new(authorization.Role{ Id: &testRoleId, - Permissions: utils.Ptr([]authorization.Permission{}), + Permissions: new([]authorization.Permission{}), }), }, expected: &Model{ @@ -112,7 +111,7 @@ func TestMapFields(t *testing.T) { description: "missing_role", input: &authorization.GetRoleResponse{ ResourceId: &testProjectId, - ResourceType: utils.Ptr("project"), + ResourceType: new("project"), }, expected: nil, isValid: false, @@ -121,8 +120,8 @@ func TestMapFields(t *testing.T) { description: "missing_permissions", input: &authorization.GetRoleResponse{ ResourceId: &testProjectId, - ResourceType: utils.Ptr("project"), - Role: utils.Ptr(authorization.Role{ + ResourceType: new("project"), + Role: new(authorization.Role{ Id: &testRoleId, }), }, @@ -133,9 +132,9 @@ func TestMapFields(t *testing.T) { description: "missing_role_id", input: &authorization.GetRoleResponse{ ResourceId: &testProjectId, - ResourceType: utils.Ptr("project"), - Role: utils.Ptr(authorization.Role{ - Permissions: utils.Ptr([]authorization.Permission{}), + ResourceType: new("project"), + Role: new(authorization.Role{ + Permissions: new([]authorization.Permission{}), }), }, expected: nil, @@ -182,11 +181,11 @@ func TestToCreatePayload(t *testing.T) { }), }, expected: authorization.AddRolePayload{ - Name: utils.Ptr("role-name"), - Description: utils.Ptr("Some description"), - Permissions: utils.Ptr([]authorization.PermissionRequest{ + Name: new("role-name"), + Description: new("Some description"), + Permissions: new([]authorization.PermissionRequest{ { - Name: utils.Ptr("iam.subject.get"), + Name: new("iam.subject.get"), }, }), }, @@ -195,7 +194,7 @@ func TestToCreatePayload(t *testing.T) { description: "empty values still valid", input: &Model{}, expected: authorization.AddRolePayload{ - Permissions: utils.Ptr([]authorization.PermissionRequest{}), + Permissions: new([]authorization.PermissionRequest{}), }, expectError: false, }, diff --git a/stackit/internal/services/authorization/roleassignments/resource_test.go b/stackit/internal/services/authorization/roleassignments/resource_test.go index e364a1442..ae878004c 100644 --- a/stackit/internal/services/authorization/roleassignments/resource_test.go +++ b/stackit/internal/services/authorization/roleassignments/resource_test.go @@ -6,7 +6,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/authorization" tfUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils" ) @@ -33,8 +32,8 @@ func TestToCreatePayload(t *testing.T) { ResourceType: &apiName, Members: &[]authorization.Member{ { - Role: utils.Ptr("editor"), - Subject: utils.Ptr("foo.bar@stackit.cloud"), + Role: new("editor"), + Subject: new("foo.bar@stackit.cloud"), }, }, }, @@ -196,8 +195,8 @@ func TestMapListMembersResponse(t *testing.T) { ResourceId: &resourceID, Members: &[]authorization.Member{ { - Role: utils.Ptr("reader"), - Subject: utils.Ptr("foo.bar@stackit.cloud"), + Role: new("reader"), + Subject: new("foo.bar@stackit.cloud"), }, }, }, @@ -260,12 +259,12 @@ func TestCheckDuplicate(t *testing.T) { ResourceId: &resourceID, Members: &[]authorization.Member{ { - Role: utils.Ptr("reader"), - Subject: utils.Ptr("foo.bar@stackit.cloud"), + Role: new("reader"), + Subject: new("foo.bar@stackit.cloud"), }, { - Role: utils.Ptr("editor"), - Subject: utils.Ptr("someoneelse@stackit.cloud"), + Role: new("editor"), + Subject: new("someoneelse@stackit.cloud"), }, }, }, diff --git a/stackit/internal/services/authorization/utils/util_test.go b/stackit/internal/services/authorization/utils/util_test.go index 7f011578a..70714b10d 100644 --- a/stackit/internal/services/authorization/utils/util_test.go +++ b/stackit/internal/services/authorization/utils/util_test.go @@ -11,7 +11,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" sdkClients "github.com/stackitcloud/stackit-sdk-go/core/clients" "github.com/stackitcloud/stackit-sdk-go/core/config" - testUtils "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/authorization" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils" @@ -107,22 +106,22 @@ func TestTypeConverter(t *testing.T) { input: authorization.MembersResponse{ Members: &[]authorization.Member{ { - Role: testUtils.Ptr("editor"), - Subject: testUtils.Ptr("foo.bar@stackit.cloud"), + Role: new("editor"), + Subject: new("foo.bar@stackit.cloud"), }, }, - ResourceId: testUtils.Ptr("project-123"), - ResourceType: testUtils.Ptr("project"), + ResourceId: new("project-123"), + ResourceType: new("project"), }, expected: &authorization.ListMembersResponse{ Members: &[]authorization.Member{ { - Role: testUtils.Ptr("editor"), - Subject: testUtils.Ptr("foo.bar@stackit.cloud"), + Role: new("editor"), + Subject: new("foo.bar@stackit.cloud"), }, }, - ResourceId: testUtils.Ptr("project-123"), - ResourceType: testUtils.Ptr("project"), + ResourceId: new("project-123"), + ResourceType: new("project"), }, expectError: false, }, @@ -158,9 +157,7 @@ func TestLockAssignment(t *testing.T) { var wg sync.WaitGroup // Goroutine 1 - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { unlock := LockAssignment(key) defer unlock() @@ -169,14 +166,12 @@ func TestLockAssignment(t *testing.T) { // Sleep to simulate API work and give G2 a chance to interrupt if the lock is broken time.Sleep(100 * time.Millisecond) criticalSectionActive = false - }() + }) // Goroutine 2 // Wait a tiny bit to ensure G1 has started and acquired the lock time.Sleep(10 * time.Millisecond) - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { // This should block until G1 releases the lock unlock := LockAssignment(key) @@ -186,7 +181,7 @@ func TestLockAssignment(t *testing.T) { if criticalSectionActive { t.Error("LockAssignment failed: entered critical section while another goroutine held the lock") } - }() + }) wg.Wait() }) diff --git a/stackit/internal/services/cdn/cdn_acc_test.go b/stackit/internal/services/cdn/cdn_acc_test.go index 499a9a24b..100329554 100644 --- a/stackit/internal/services/cdn/cdn_acc_test.go +++ b/stackit/internal/services/cdn/cdn_acc_test.go @@ -525,7 +525,7 @@ func blockUntilDomainResolves(domain string) (string, error) { func retry[T any](attempts int, sleep time.Duration, f func() (T, error)) (T, error) { var zero T var errOuter error - for i := 0; i < attempts; i++ { + for range attempts { dist, err := f() if err == nil { return dist, nil diff --git a/stackit/internal/services/cdn/customdomain/datasource_test.go b/stackit/internal/services/cdn/customdomain/datasource_test.go index 0a823b27e..dc4e60c6e 100644 --- a/stackit/internal/services/cdn/customdomain/datasource_test.go +++ b/stackit/internal/services/cdn/customdomain/datasource_test.go @@ -56,7 +56,7 @@ func TestMapDataSourceFields(t *testing.T) { customDomainFixture := func(mods ...func(*cdn.GetCustomDomainResponse)) *cdn.GetCustomDomainResponse { distribution := &cdn.CustomDomain{ Errors: &[]cdn.StatusError{}, - Name: cdn.PtrString("https://testdomain.com"), + Name: new("https://testdomain.com"), Status: cdn.DOMAINSTATUS_ACTIVE.Ptr(), } customDomainResponse := &cdn.GetCustomDomainResponse{ diff --git a/stackit/internal/services/cdn/customdomain/resource.go b/stackit/internal/services/cdn/customdomain/resource.go index 5544b686f..ed8de254e 100644 --- a/stackit/internal/services/cdn/customdomain/resource.go +++ b/stackit/internal/services/cdn/customdomain/resource.go @@ -201,7 +201,7 @@ func (r *customDomainResource) Create(ctx context.Context, req resource.CreateRe } payload := cdn.PutCustomDomainPayload{ - IntentId: cdn.PtrString(uuid.NewString()), + IntentId: new(uuid.NewString()), Certificate: certificate, } _, err = r.client.PutCustomDomain(ctx, projectId, distributionId, name).PutCustomDomainPayload(payload).Execute() @@ -317,7 +317,7 @@ func (r *customDomainResource) Update(ctx context.Context, req resource.UpdateRe } payload := cdn.PutCustomDomainPayload{ - IntentId: cdn.PtrString(uuid.NewString()), + IntentId: new(uuid.NewString()), Certificate: certificate, } _, err = r.client.PutCustomDomain(ctx, projectId, distributionId, name).PutCustomDomainPayload(payload).Execute() @@ -390,7 +390,7 @@ func (r *customDomainResource) ImportState(ctx context.Context, req resource.Imp if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" { core.LogAndAddError(ctx, &resp.Diagnostics, "Error importing CDN custom domain", fmt.Sprintf("Expected import identifier on the format: [project_id]%q[distribution_id]%q[custom_domain_name], got %q", core.Separator, core.Separator, req.ID)) } - ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]interface{}{ + ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{ "project_id": idParts[0], "distribution_id": idParts[1], "name": idParts[2], diff --git a/stackit/internal/services/cdn/customdomain/resource_test.go b/stackit/internal/services/cdn/customdomain/resource_test.go index 28aff2942..dd10dcee8 100644 --- a/stackit/internal/services/cdn/customdomain/resource_test.go +++ b/stackit/internal/services/cdn/customdomain/resource_test.go @@ -76,7 +76,7 @@ func TestMapFields(t *testing.T) { customDomainFixture := func(mods ...func(*cdn.GetCustomDomainResponse)) *cdn.GetCustomDomainResponse { distribution := &cdn.CustomDomain{ Errors: &[]cdn.StatusError{}, - Name: cdn.PtrString("https://testdomain.com"), + Name: new("https://testdomain.com"), Status: cdn.DOMAINSTATUS_ACTIVE.Ptr(), } customDomainResponse := &cdn.GetCustomDomainResponse{ @@ -92,7 +92,7 @@ func TestMapFields(t *testing.T) { tests := map[string]struct { Input *cdn.GetCustomDomainResponse - Certificate interface{} + Certificate any Expected *CustomDomainModel InitialModel *CustomDomainModel IsValid bool diff --git a/stackit/internal/services/cdn/distribution/datasource_test.go b/stackit/internal/services/cdn/distribution/datasource_test.go index 5bf117032..4157297be 100644 --- a/stackit/internal/services/cdn/distribution/datasource_test.go +++ b/stackit/internal/services/cdn/distribution/datasource_test.go @@ -80,8 +80,8 @@ func TestMapDataSourceFields(t *testing.T) { "testHeader0": "testHeaderValue0", "testHeader1": "testHeaderValue1", }, - OriginUrl: cdn.PtrString("https://www.mycoolapp.com"), - Type: cdn.PtrString("http"), + OriginUrl: new("https://www.mycoolapp.com"), + Type: new("http"), }, }, Regions: &[]cdn.Region{"EU", "US"}, @@ -91,13 +91,13 @@ func TestMapDataSourceFields(t *testing.T) { CreatedAt: &createdAt, Domains: &[]cdn.Domain{ { - Name: cdn.PtrString("test.stackit-cdn.com"), + Name: new("test.stackit-cdn.com"), Status: cdn.DOMAINSTATUS_ACTIVE.Ptr(), Type: cdn.DOMAINTYPE_MANAGED.Ptr(), }, }, - Id: cdn.PtrString("test-distribution-id"), - ProjectId: cdn.PtrString("test-project-id"), + Id: new("test-distribution-id"), + ProjectId: new("test-project-id"), Status: cdn.DISTRIBUTIONSTATUS_ACTIVE.Ptr(), UpdatedAt: &updatedAt, } @@ -136,7 +136,7 @@ func TestMapDataSourceFields(t *testing.T) { }), Input: distributionFixture(func(d *cdn.Distribution) { d.Config.Optimizer = &cdn.Optimizer{ - Enabled: cdn.PtrBool(true), + Enabled: new(true), } }), IsValid: true, @@ -145,9 +145,9 @@ func TestMapDataSourceFields(t *testing.T) { Input: distributionFixture(func(d *cdn.Distribution) { d.Config.Backend = &cdn.ConfigBackend{ BucketBackend: &cdn.BucketBackend{ - Type: cdn.PtrString("bucket"), - BucketUrl: cdn.PtrString("https://s3.example.com"), - Region: cdn.PtrString("eu01"), + Type: new("bucket"), + BucketUrl: new("https://s3.example.com"), + Region: new("eu01"), }, } }), @@ -212,12 +212,12 @@ func TestMapDataSourceFields(t *testing.T) { Input: distributionFixture(func(d *cdn.Distribution) { d.Domains = &[]cdn.Domain{ { - Name: cdn.PtrString("test.stackit-cdn.com"), + Name: new("test.stackit-cdn.com"), Status: cdn.DOMAINSTATUS_ACTIVE.Ptr(), Type: cdn.DOMAINTYPE_MANAGED.Ptr(), }, { - Name: cdn.PtrString("mycoolapp.info"), + Name: new("mycoolapp.info"), Status: cdn.DOMAINSTATUS_ACTIVE.Ptr(), Type: cdn.DOMAINTYPE_CUSTOM.Ptr(), }, diff --git a/stackit/internal/services/cdn/distribution/resource.go b/stackit/internal/services/cdn/distribution/resource.go index 47e36ffa4..e11c8a35a 100644 --- a/stackit/internal/services/cdn/distribution/resource.go +++ b/stackit/internal/services/cdn/distribution/resource.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "maps" "net/http" "strings" "time" @@ -590,12 +591,12 @@ func (r *distributionResource) Update(ctx context.Context, req resource.UpdateRe configPatchBackend.HttpBackendPatch = &cdn.HttpBackendPatch{ OriginRequestHeaders: configModel.Backend.OriginRequestHeaders, OriginUrl: configModel.Backend.OriginURL, - Type: cdn.PtrString("http"), + Type: new("http"), Geofencing: &geofencingPatch, } } else if configModel.Backend.Type == "bucket" { configPatchBackend.BucketBackendPatch = &cdn.BucketBackendPatch{ - Type: cdn.PtrString("bucket"), + Type: new("bucket"), BucketUrl: configModel.Backend.BucketURL, Region: configModel.Backend.Region, } @@ -631,7 +632,7 @@ func (r *distributionResource) Update(ctx context.Context, req resource.UpdateRe _, err := r.client.PatchDistribution(ctx, projectId, distributionId).PatchDistributionPayload(cdn.PatchDistributionPayload{ Config: configPatch, - IntentId: cdn.PtrString(uuid.NewString()), + IntentId: new(uuid.NewString()), }).Execute() if err != nil { core.LogAndAddError(ctx, &resp.Diagnostics, "Update CDN distribution", fmt.Sprintf("Patch distribution: %v", err)) @@ -696,7 +697,7 @@ func (r *distributionResource) ImportState(ctx context.Context, req resource.Imp if len(idParts) != 2 || idParts[0] == "" || idParts[1] == "" { core.LogAndAddError(ctx, &resp.Diagnostics, "Error importing CDN distribution", fmt.Sprintf("Expected import identifier on the format: [project_id]%q[distribution_id], got %q", core.Separator, req.ID)) } - ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]interface{}{ + ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{ "project_id": idParts[0], "distribution_id": idParts[1], }) @@ -976,7 +977,7 @@ func toCreatePayload(ctx context.Context, model *Model) (*cdn.CreateDistribution OriginUrl: cfg.Backend.HttpBackend.OriginUrl, OriginRequestHeaders: cfg.Backend.HttpBackend.OriginRequestHeaders, Geofencing: cfg.Backend.HttpBackend.Geofencing, - Type: cdn.PtrString("http"), + Type: new("http"), }, } } else if cfg.Backend.BucketBackend != nil { @@ -997,7 +998,7 @@ func toCreatePayload(ctx context.Context, model *Model) (*cdn.CreateDistribution } backend = &cdn.CreateDistributionPayloadBackend{ BucketBackendCreate: &cdn.BucketBackendCreate{ - Type: cdn.PtrString("bucket"), + Type: new("bucket"), BucketUrl: cfg.Backend.BucketBackend.BucketUrl, Region: cfg.Backend.BucketBackend.Region, Credentials: &cdn.BucketCredentials{ @@ -1009,7 +1010,7 @@ func toCreatePayload(ctx context.Context, model *Model) (*cdn.CreateDistribution } payload := &cdn.CreateDistributionPayload{ - IntentId: cdn.PtrString(uuid.NewString()), + IntentId: new(uuid.NewString()), Regions: cfg.Regions, Backend: backend, BlockedCountries: cfg.BlockedCountries, @@ -1085,19 +1086,17 @@ func convertConfig(ctx context.Context, model *Model) (*cdn.Config, error) { if configModel.Backend.Type == "http" { originRequestHeaders := map[string]string{} if configModel.Backend.OriginRequestHeaders != nil { - for k, v := range *configModel.Backend.OriginRequestHeaders { - originRequestHeaders[k] = v - } + maps.Copy(originRequestHeaders, *configModel.Backend.OriginRequestHeaders) } cdnConfig.Backend.HttpBackend = &cdn.HttpBackend{ OriginRequestHeaders: &originRequestHeaders, OriginUrl: configModel.Backend.OriginURL, - Type: cdn.PtrString("http"), + Type: new("http"), Geofencing: &geofencing, } } else if configModel.Backend.Type == "bucket" { cdnConfig.Backend.BucketBackend = &cdn.BucketBackend{ - Type: cdn.PtrString("bucket"), + Type: new("bucket"), BucketUrl: configModel.Backend.BucketURL, Region: configModel.Backend.Region, } diff --git a/stackit/internal/services/cdn/distribution/resource_test.go b/stackit/internal/services/cdn/distribution/resource_test.go index 9c4cda8c3..cc736f7c5 100644 --- a/stackit/internal/services/cdn/distribution/resource_test.go +++ b/stackit/internal/services/cdn/distribution/resource_test.go @@ -71,8 +71,8 @@ func TestToCreatePayload(t *testing.T) { HttpBackendCreate: &cdn.HttpBackendCreate{ Geofencing: &map[string][]string{"https://de.mycoolapp.com": {"DE", "FR"}}, OriginRequestHeaders: &map[string]string{"testHeader0": "testHeaderValue0", "testHeader1": "testHeaderValue1"}, - OriginUrl: cdn.PtrString("https://www.mycoolapp.com"), - Type: cdn.PtrString("http"), + OriginUrl: new("https://www.mycoolapp.com"), + Type: new("http"), }, }, }, @@ -95,8 +95,8 @@ func TestToCreatePayload(t *testing.T) { HttpBackendCreate: &cdn.HttpBackendCreate{ Geofencing: &map[string][]string{"https://de.mycoolapp.com": {"DE", "FR"}}, OriginRequestHeaders: &map[string]string{"testHeader0": "testHeaderValue0", "testHeader1": "testHeaderValue1"}, - OriginUrl: cdn.PtrString("https://www.mycoolapp.com"), - Type: cdn.PtrString("http"), + OriginUrl: new("https://www.mycoolapp.com"), + Type: new("http"), }, }, }, @@ -127,12 +127,12 @@ func TestToCreatePayload(t *testing.T) { Expected: &cdn.CreateDistributionPayload{ Backend: &cdn.CreateDistributionPayloadBackend{ BucketBackendCreate: &cdn.BucketBackendCreate{ - Type: cdn.PtrString("bucket"), - BucketUrl: cdn.PtrString("https://s3.example.com"), - Region: cdn.PtrString("eu01"), + Type: new("bucket"), + BucketUrl: new("https://s3.example.com"), + Region: new("eu01"), Credentials: &cdn.BucketCredentials{ - AccessKeyId: cdn.PtrString("my-access"), - SecretAccessKey: cdn.PtrString("my-secret"), + AccessKeyId: new("my-access"), + SecretAccessKey: new("my-secret"), }, }, }, @@ -234,8 +234,8 @@ func TestConvertConfig(t *testing.T) { "testHeader0": "testHeaderValue0", "testHeader1": "testHeaderValue1", }, - OriginUrl: cdn.PtrString("https://www.mycoolapp.com"), - Type: cdn.PtrString("http"), + OriginUrl: new("https://www.mycoolapp.com"), + Type: new("http"), Geofencing: &map[string][]string{ "https://de.mycoolapp.com": {"DE", "FR"}, }, @@ -262,8 +262,8 @@ func TestConvertConfig(t *testing.T) { "testHeader0": "testHeaderValue0", "testHeader1": "testHeaderValue1", }, - OriginUrl: cdn.PtrString("https://www.mycoolapp.com"), - Type: cdn.PtrString("http"), + OriginUrl: new("https://www.mycoolapp.com"), + Type: new("http"), Geofencing: &map[string][]string{ "https://de.mycoolapp.com": {"DE", "FR"}, }, @@ -300,9 +300,9 @@ func TestConvertConfig(t *testing.T) { Expected: &cdn.Config{ Backend: &cdn.ConfigBackend{ BucketBackend: &cdn.BucketBackend{ - Type: cdn.PtrString("bucket"), - BucketUrl: cdn.PtrString("https://s3.example.com"), - Region: cdn.PtrString("eu01"), + Type: new("bucket"), + BucketUrl: new("https://s3.example.com"), + Region: new("eu01"), // Note: config does not return credentials }, @@ -414,8 +414,8 @@ func TestMapFields(t *testing.T) { "testHeader0": "testHeaderValue0", "testHeader1": "testHeaderValue1", }, - OriginUrl: cdn.PtrString("https://www.mycoolapp.com"), - Type: cdn.PtrString("http"), + OriginUrl: new("https://www.mycoolapp.com"), + Type: new("http"), }, }, Regions: &[]cdn.Region{"EU", "US"}, @@ -425,13 +425,13 @@ func TestMapFields(t *testing.T) { CreatedAt: &createdAt, Domains: &[]cdn.Domain{ { - Name: cdn.PtrString("test.stackit-cdn.com"), + Name: new("test.stackit-cdn.com"), Status: cdn.DOMAINSTATUS_ACTIVE.Ptr(), Type: cdn.DOMAINTYPE_MANAGED.Ptr(), }, }, - Id: cdn.PtrString("test-distribution-id"), - ProjectId: cdn.PtrString("test-project-id"), + Id: new("test-distribution-id"), + ProjectId: new("test-project-id"), Status: cdn.DISTRIBUTIONSTATUS_ACTIVE.Ptr(), UpdatedAt: &updatedAt, } @@ -482,7 +482,7 @@ func TestMapFields(t *testing.T) { }), Input: distributionFixture(func(d *cdn.Distribution) { d.Config.Optimizer = &cdn.Optimizer{ - Enabled: cdn.PtrBool(true), + Enabled: new(true), } }), IsValid: true, @@ -539,12 +539,12 @@ func TestMapFields(t *testing.T) { Input: distributionFixture(func(d *cdn.Distribution) { d.Domains = &[]cdn.Domain{ { - Name: cdn.PtrString("test.stackit-cdn.com"), + Name: new("test.stackit-cdn.com"), Status: cdn.DOMAINSTATUS_ACTIVE.Ptr(), Type: cdn.DOMAINTYPE_MANAGED.Ptr(), }, { - Name: cdn.PtrString("mycoolapp.info"), + Name: new("mycoolapp.info"), Status: cdn.DOMAINSTATUS_ACTIVE.Ptr(), Type: cdn.DOMAINTYPE_CUSTOM.Ptr(), }, @@ -556,9 +556,9 @@ func TestMapFields(t *testing.T) { Input: distributionFixture(func(d *cdn.Distribution) { d.Config.Backend = &cdn.ConfigBackend{ BucketBackend: &cdn.BucketBackend{ - Type: cdn.PtrString("bucket"), - BucketUrl: cdn.PtrString("https://s3.example.com"), - Region: cdn.PtrString("eu01"), + Type: new("bucket"), + BucketUrl: new("https://s3.example.com"), + Region: new("eu01"), }, } }), diff --git a/stackit/internal/services/dns/recordset/resource.go b/stackit/internal/services/dns/recordset/resource.go index f863be137..ad665a3a7 100644 --- a/stackit/internal/services/dns/recordset/resource.go +++ b/stackit/internal/services/dns/recordset/resource.go @@ -399,7 +399,7 @@ func (r *recordSetResource) ImportState(ctx context.Context, req resource.Import return } - ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]interface{}{ + ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{ "project_id": idParts[0], "zone_id": idParts[1], "record_set_id": idParts[2], diff --git a/stackit/internal/services/dns/recordset/resource_test.go b/stackit/internal/services/dns/recordset/resource_test.go index 5bec846e8..372a20e4a 100644 --- a/stackit/internal/services/dns/recordset/resource_test.go +++ b/stackit/internal/services/dns/recordset/resource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api/wait" ) @@ -60,9 +59,9 @@ func TestMapFields(t *testing.T) { &dns.RecordSetResponse{ Rrset: dns.RecordSet{ Id: "rid", - Active: utils.Ptr(true), - Comment: utils.Ptr("comment"), - Error: utils.Ptr("error"), + Active: new(true), + Comment: new("comment"), + Error: new("error"), Name: "name", Records: []dns.Record{ {Content: "record_1"}, @@ -106,9 +105,9 @@ func TestMapFields(t *testing.T) { &dns.RecordSetResponse{ Rrset: dns.RecordSet{ Id: "rid", - Active: utils.Ptr(true), - Comment: utils.Ptr("comment"), - Error: utils.Ptr("error"), + Active: new(true), + Comment: new("comment"), + Error: new("error"), Name: "name", Records: []dns.Record{ {Content: "record_1"}, @@ -244,13 +243,13 @@ func TestToCreatePayload(t *testing.T) { Type: types.StringValue("A"), }, &dns.CreateRecordSetPayload{ - Comment: utils.Ptr("comment"), + Comment: new("comment"), Name: "name", Records: []dns.RecordPayload{ {Content: "record_1"}, {Content: "record_2"}, }, - Ttl: utils.Ptr(int32(1)), + Ttl: new(int32(1)), Type: "A", }, true, @@ -268,7 +267,7 @@ func TestToCreatePayload(t *testing.T) { Comment: nil, Name: "", Records: []dns.RecordPayload{}, - Ttl: utils.Ptr(int32(2123456789)), + Ttl: new(int32(2123456789)), Type: "A", }, true, @@ -326,13 +325,13 @@ func TestToUpdatePayload(t *testing.T) { TTL: types.Int32Value(1), }, &dns.PartialUpdateRecordSetPayload{ - Comment: utils.Ptr("comment"), - Name: utils.Ptr("name"), + Comment: new("comment"), + Name: new("name"), Records: []dns.RecordPayload{ {Content: "record_1"}, {Content: "record_2"}, }, - Ttl: utils.Ptr(int32(1)), + Ttl: new(int32(1)), }, true, }, @@ -346,9 +345,9 @@ func TestToUpdatePayload(t *testing.T) { }, &dns.PartialUpdateRecordSetPayload{ Comment: nil, - Name: utils.Ptr(""), + Name: new(""), Records: []dns.RecordPayload{}, - Ttl: utils.Ptr(int32(2123456789)), + Ttl: new(int32(2123456789)), }, true, }, diff --git a/stackit/internal/services/dns/zone/resource.go b/stackit/internal/services/dns/zone/resource.go index 745ac390a..fcd14c4d5 100644 --- a/stackit/internal/services/dns/zone/resource.go +++ b/stackit/internal/services/dns/zone/resource.go @@ -314,7 +314,7 @@ func (r *zoneResource) Create(ctx context.Context, req resource.CreateRequest, r // Write id attributes to state before polling via the wait handler - just in case anything goes wrong during the wait handler zoneId := createResp.Zone.Id - ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]interface{}{ + ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{ "project_id": projectId, "zone_id": zoneId, }) @@ -485,7 +485,7 @@ func (r *zoneResource) ImportState(ctx context.Context, req resource.ImportState return } - ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]interface{}{ + ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{ "project_id": idParts[0], "zone_id": idParts[1], }) diff --git a/stackit/internal/services/dns/zone/resource_test.go b/stackit/internal/services/dns/zone/resource_test.go index 4b5e7dc66..81799bb06 100644 --- a/stackit/internal/services/dns/zone/resource_test.go +++ b/stackit/internal/services/dns/zone/resource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api/wait" ) @@ -76,7 +75,7 @@ func TestMapFields(t *testing.T) { Name: "name", DnsName: "dnsname", Acl: "acl", - Active: utils.Ptr(false), + Active: new(false), CreationStarted: "bar", CreationFinished: "foo", DefaultTTL: 1, @@ -92,11 +91,11 @@ func TestMapFields(t *testing.T) { UpdateStarted: "ufoo", UpdateFinished: "ubar", Visibility: "public", - Error: utils.Ptr("error"), - ContactEmail: utils.Ptr("a@b.cd"), - Description: utils.Ptr("description"), - IsReverseZone: utils.Ptr(false), - RecordCount: utils.Ptr(int32(3)), + Error: new("error"), + ContactEmail: new("a@b.cd"), + Description: new("description"), + IsReverseZone: new(false), + RecordCount: new(int32(3)), }, }, Model{ @@ -143,7 +142,7 @@ func TestMapFields(t *testing.T) { Name: "name", DnsName: "dnsname", Acl: "acl", - Active: utils.Ptr(false), + Active: new(false), CreationStarted: "bar", CreationFinished: "foo", DefaultTTL: 1, @@ -162,11 +161,11 @@ func TestMapFields(t *testing.T) { UpdateStarted: "ufoo", UpdateFinished: "ubar", Visibility: "public", - Error: utils.Ptr("error"), - ContactEmail: utils.Ptr("a@b.cd"), - Description: utils.Ptr("description"), - IsReverseZone: utils.Ptr(false), - RecordCount: utils.Ptr(int32(3)), + Error: new("error"), + ContactEmail: new("a@b.cd"), + Description: new("description"), + IsReverseZone: new(false), + RecordCount: new(int32(3)), }, }, Model{ @@ -230,7 +229,7 @@ func TestMapFields(t *testing.T) { ContactEmail: nil, Description: nil, IsReverseZone: nil, - RecordCount: utils.Ptr(int32(-2123456789)), + RecordCount: new(int32(-2123456789)), }, }, Model{ @@ -338,17 +337,17 @@ func TestToCreatePayload(t *testing.T) { &dns.CreateZonePayload{ Name: "Name", DnsName: "DnsName", - Acl: utils.Ptr("Acl"), - Description: utils.Ptr("Description"), - Type: utils.Ptr("primary"), - ContactEmail: utils.Ptr("ContactEmail"), + Acl: new("Acl"), + Description: new("Description"), + Type: new("primary"), + ContactEmail: new("ContactEmail"), Primaries: []string{"primary"}, - RetryTime: utils.Ptr(int32(3)), - RefreshTime: utils.Ptr(int32(4)), - ExpireTime: utils.Ptr(int32(5)), - DefaultTTL: utils.Ptr(int32(4534534)), - NegativeCache: utils.Ptr(int32(-4534534)), - IsReverseZone: utils.Ptr(true), + RetryTime: new(int32(3)), + RefreshTime: new(int32(4)), + ExpireTime: new(int32(5)), + DefaultTTL: new(int32(4534534)), + NegativeCache: new(int32(-4534534)), + IsReverseZone: new(true), }, true, }, @@ -391,7 +390,7 @@ func TestToPayloadUpdate(t *testing.T) { Name: types.StringValue("Name"), }, &dns.PartialUpdateZonePayload{ - Name: utils.Ptr("Name"), + Name: new("Name"), }, true, }, @@ -417,15 +416,15 @@ func TestToPayloadUpdate(t *testing.T) { IsReverseZone: types.BoolValue(true), }, &dns.PartialUpdateZonePayload{ - Name: utils.Ptr("Name"), - Acl: utils.Ptr("Acl"), - Description: utils.Ptr("Description"), - ContactEmail: utils.Ptr("ContactEmail"), - RetryTime: utils.Ptr(int32(3)), - RefreshTime: utils.Ptr(int32(4)), - ExpireTime: utils.Ptr(int32(5)), - DefaultTTL: utils.Ptr(int32(4534534)), - NegativeCache: utils.Ptr(int32(-4534534)), + Name: new("Name"), + Acl: new("Acl"), + Description: new("Description"), + ContactEmail: new("ContactEmail"), + RetryTime: new(int32(3)), + RefreshTime: new(int32(4)), + ExpireTime: new(int32(5)), + DefaultTTL: new(int32(4534534)), + NegativeCache: new(int32(-4534534)), }, true, }, diff --git a/stackit/internal/services/edgecloud/instance/resource_test.go b/stackit/internal/services/edgecloud/instance/resource_test.go index 02b58f4ed..54c973628 100644 --- a/stackit/internal/services/edgecloud/instance/resource_test.go +++ b/stackit/internal/services/edgecloud/instance/resource_test.go @@ -25,13 +25,13 @@ func TestMapFields(t *testing.T) { { "all_parameter_set", &edge.Instance{ - Id: utils.Ptr("iid-123"), + Id: new("iid-123"), Created: &testTime, - DisplayName: utils.Ptr("test-instance"), - Description: utils.Ptr("Test description"), - PlanId: utils.Ptr(uuidString), + DisplayName: new("test-instance"), + Description: new("Test description"), + PlanId: new(uuidString), Status: utils.Ptr(edge.InstanceStatus("CREATING")), - FrontendUrl: utils.Ptr("https://iid-123.example.com"), + FrontendUrl: new("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"), + Id: new("iid-123"), Created: &testTime, - DisplayName: utils.Ptr("test-instance"), - Description: utils.Ptr(""), - PlanId: utils.Ptr(uuidString), + DisplayName: new("test-instance"), + Description: new(""), + PlanId: new(uuidString), Status: utils.Ptr(edge.InstanceStatus("ACTIVE")), - FrontendUrl: utils.Ptr("https://iid-123.example.com"), + FrontendUrl: new("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"), - Description: utils.Ptr("A new test instance"), - PlanId: utils.Ptr(uuidString), + DisplayName: new("new-instance"), + Description: new("A new test instance"), + PlanId: new(uuidString), }, true, }, @@ -146,9 +146,9 @@ func TestToCreatePayload(t *testing.T) { PlanID: types.StringValue(uuidString), }, edge.CreateInstancePayload{ - DisplayName: utils.Ptr("new-instance"), + DisplayName: new("new-instance"), Description: nil, - PlanId: utils.Ptr(uuidString), + PlanId: new(uuidString), }, true, }, @@ -181,8 +181,8 @@ func TestToUpdatePayload(t *testing.T) { PlanID: types.StringValue(uuidOne), }, edge.UpdateInstancePayload{ - Description: utils.Ptr("Updated description"), - PlanId: utils.Ptr(uuidOne), + Description: new("Updated description"), + PlanId: new(uuidOne), }, true, }, @@ -194,7 +194,7 @@ func TestToUpdatePayload(t *testing.T) { }, edge.UpdateInstancePayload{ Description: nil, - PlanId: utils.Ptr(uuidOne), + PlanId: new(uuidOne), }, true, }, diff --git a/stackit/internal/services/edgecloud/instances/datasource_test.go b/stackit/internal/services/edgecloud/instances/datasource_test.go index 741db3d37..392405886 100644 --- a/stackit/internal/services/edgecloud/instances/datasource_test.go +++ b/stackit/internal/services/edgecloud/instances/datasource_test.go @@ -32,13 +32,13 @@ func fixtureInstance(mods ...func(instance *edge.Instance)) edge.Instance { description := "some-description" instance := &edge.Instance{ - Id: utils.Ptr(id), - DisplayName: utils.Ptr(displayName), + Id: new(id), + DisplayName: new(displayName), PlanId: &defaultPlanId, - FrontendUrl: utils.Ptr(fmt.Sprintf("https://%s.example.com", id)), + FrontendUrl: new(fmt.Sprintf("https://%s.example.com", id)), Status: utils.Ptr(edge.InstanceStatus("ACTIVE")), Created: &testTime, - Description: utils.Ptr(description), + Description: new(description), } for _, mod := range mods { @@ -87,7 +87,7 @@ func TestMapInstanceToAttrs(t *testing.T) { { description: "valid instance, empty description", instance: fixtureInstance(func(i *edge.Instance) { - i.Description = utils.Ptr("") + i.Description = new("") }), expected: fixtureAttrs(validInstanceAttrs, func(m map[string]attr.Value) { m["description"] = types.StringValue("") @@ -105,7 +105,7 @@ func TestMapInstanceToAttrs(t *testing.T) { { description: "error, empty display name", instance: fixtureInstance(func(i *edge.Instance) { - i.DisplayName = utils.Ptr("") + i.DisplayName = new("") }), expectError: true, errorMsg: "missing a 'displayName'", @@ -191,13 +191,13 @@ 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 = new("first-ab75568") + i.DisplayName = new("first") }) instance2 := fixtureInstance(func(i *edge.Instance) { - i.Id = utils.Ptr("second-ab75568") - i.DisplayName = utils.Ptr("second") + i.Id = new("second-ab75568") + i.DisplayName = new("second") }) instanceInvalidPlan := fixtureInstance(func(i *edge.Instance) { @@ -211,7 +211,7 @@ func TestBuildInstancesList(t *testing.T) { // Invalid: Empty Display Name instanceEmptyName := fixtureInstance(func(i *edge.Instance) { - i.DisplayName = utils.Ptr("") + i.DisplayName = new("") }) // Invalid: Nil ID and Nil Display Name diff --git a/stackit/internal/services/git/instance/resource.go b/stackit/internal/services/git/instance/resource.go index eca38f669..f86272654 100644 --- a/stackit/internal/services/git/instance/resource.go +++ b/stackit/internal/services/git/instance/resource.go @@ -359,7 +359,7 @@ func (g *gitResource) ImportState(ctx context.Context, req resource.ImportStateR return } // Set the project ID and instance ID attributes in the state. - ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]interface{}{ + ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{ "project_id": idParts[0], "instance_id": idParts[1], }) diff --git a/stackit/internal/services/git/instance/resource_test.go b/stackit/internal/services/git/instance/resource_test.go index 93de087f1..1901cf404 100644 --- a/stackit/internal/services/git/instance/resource_test.go +++ b/stackit/internal/services/git/instance/resource_test.go @@ -10,7 +10,6 @@ import ( "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/git" ) @@ -34,8 +33,8 @@ func TestMapFields(t *testing.T) { { description: "minimal_input_name_only", input: &git.Instance{ - Id: utils.Ptr(testInstanceId), - Name: utils.Ptr("git-min-instance"), + Id: new(testInstanceId), + Name: new("git-min-instance"), }, expected: &Model{ Id: types.StringValue(fmt.Sprintf("%s,%s", testProjectId, testInstanceId)), @@ -56,14 +55,14 @@ func TestMapFields(t *testing.T) { description: "full_input_with_acl_and_flavor", input: &git.Instance{ Acl: &[]string{"192.168.0.0/24"}, - ConsumedDisk: utils.Ptr("1.00 GB"), - ConsumedObjectStorage: utils.Ptr("2.00 GB"), + ConsumedDisk: new("1.00 GB"), + ConsumedObjectStorage: new("2.00 GB"), Created: &createdTime, - Flavor: utils.Ptr("git-100"), - Id: utils.Ptr(testInstanceId), - Name: utils.Ptr("git-full-instance"), - Url: utils.Ptr("https://git-full-instance.git.onstackit.cloud"), - Version: utils.Ptr("v1.9.1"), + Flavor: new("git-100"), + Id: new(testInstanceId), + Name: new("git-full-instance"), + Url: new("https://git-full-instance.git.onstackit.cloud"), + Version: new("v1.9.1"), }, expected: &Model{ Id: types.StringValue(fmt.Sprintf("%s,%s", testProjectId, testInstanceId)), @@ -83,8 +82,8 @@ func TestMapFields(t *testing.T) { { description: "empty_acls", input: &git.Instance{ - Id: utils.Ptr(testInstanceId), - Name: utils.Ptr("git-empty-acl"), + Id: new(testInstanceId), + Name: new("git-empty-acl"), Acl: &[]string{}, }, expected: &Model{ @@ -117,7 +116,7 @@ func TestMapFields(t *testing.T) { { description: "missing_id", input: &git.Instance{ - Name: utils.Ptr("git-missing-id"), + Name: new("git-missing-id"), }, expected: nil, isValid: false, @@ -162,7 +161,7 @@ func TestToCreatePayload(t *testing.T) { ACL: types.ListNull(types.StringType), }, expected: git.CreateInstancePayload{ - Name: utils.Ptr("example-instance"), + Name: new("example-instance"), }, expectError: false, }, @@ -177,7 +176,7 @@ func TestToCreatePayload(t *testing.T) { }), }, expected: git.CreateInstancePayload{ - Name: utils.Ptr("my-instance"), + Name: new("my-instance"), Flavor: git.INSTANCEFLAVOR__100.Ptr(), Acl: &[]string{"10.0.0.1", "10.0.0.2"}, }, @@ -191,7 +190,7 @@ func TestToCreatePayload(t *testing.T) { ACL: types.ListValueMust(types.StringType, []attr.Value{}), }, expected: git.CreateInstancePayload{ - Name: utils.Ptr("my-instance"), + Name: new("my-instance"), Flavor: git.INSTANCEFLAVOR__100.Ptr(), Acl: &[]string{}, }, diff --git a/stackit/internal/services/iaas/affinitygroup/resource_test.go b/stackit/internal/services/iaas/affinitygroup/resource_test.go index 26f4bc055..d1822e242 100644 --- a/stackit/internal/services/iaas/affinitygroup/resource_test.go +++ b/stackit/internal/services/iaas/affinitygroup/resource_test.go @@ -6,7 +6,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/iaas" ) @@ -30,7 +29,7 @@ func TestMapFields(t *testing.T) { AffinityGroupId: types.StringValue("aid"), }, input: &iaas.AffinityGroup{ - Id: utils.Ptr("aid"), + Id: new("aid"), }, region: "eu01", }, @@ -92,8 +91,8 @@ func TestToCreatePayload(t *testing.T) { Policy: types.StringValue("policy"), }, &iaas.CreateAffinityGroupPayload{ - Name: utils.Ptr("name"), - Policy: utils.Ptr("policy"), + Name: new("name"), + Policy: new("policy"), }, true, }, diff --git a/stackit/internal/services/iaas/iaas_acc_test.go b/stackit/internal/services/iaas/iaas_acc_test.go index 8290ac5d1..f6ca7e016 100644 --- a/stackit/internal/services/iaas/iaas_acc_test.go +++ b/stackit/internal/services/iaas/iaas_acc_test.go @@ -127,9 +127,7 @@ var testConfigServerVarsMin = config.Variables{ var testConfigServerVarsMinUpdated = func() config.Variables { updatedConfig := config.Variables{} - for k, v := range testConfigServerVarsMin { - updatedConfig[k] = v - } + maps.Copy(updatedConfig, testConfigServerVarsMin) updatedConfig["name"] = config.StringVariable(testutil.ProjectId) updatedConfig["machine_type"] = config.StringVariable("t1.2") return updatedConfig @@ -155,9 +153,7 @@ var testConfigServerVarsMax = config.Variables{ var testConfigServerVarsMaxUpdated = func() config.Variables { updatedConfig := config.Variables{} - for k, v := range testConfigServerVarsMax { - updatedConfig[k] = v - } + maps.Copy(updatedConfig, testConfigServerVarsMax) updatedConfig["name"] = config.StringVariable(testutil.ProjectId) updatedConfig["machine_type"] = config.StringVariable("t1.2") updatedConfig["label"] = config.StringVariable("updated") @@ -167,9 +163,7 @@ var testConfigServerVarsMaxUpdated = func() config.Variables { var testConfigServerVarsMaxUpdatedDesiredStatus = func() config.Variables { updatedConfig := config.Variables{} - for k, v := range testConfigServerVarsMaxUpdated { - updatedConfig[k] = v - } + maps.Copy(updatedConfig, testConfigServerVarsMaxUpdated) updatedConfig["name"] = config.StringVariable(testutil.ProjectId) updatedConfig["machine_type"] = config.StringVariable("t1.2") updatedConfig["label"] = config.StringVariable("updated") @@ -207,9 +201,7 @@ var testConfigNetworkInterfaceVarsMax = config.Variables{ var testConfigNetworkInterfaceVarsMaxUpdated = func() config.Variables { updatedConfig := config.Variables{} - for k, v := range testConfigNetworkInterfaceVarsMax { - updatedConfig[k] = v - } + maps.Copy(updatedConfig, testConfigNetworkInterfaceVarsMax) updatedConfig["name"] = config.StringVariable(fmt.Sprintf("%s-updated", testutil.ConvertConfigVariable(testConfigNetworkInterfaceVarsMax["name"]))) updatedConfig["ipv4"] = config.StringVariable("10.2.10.21") updatedConfig["security"] = config.BoolVariable(false) @@ -227,9 +219,7 @@ var testConfigVolumeVarsMin = config.Variables{ var testConfigVolumeVarsMinUpdated = func() config.Variables { updatedConfig := config.Variables{} - for k, v := range testConfigVolumeVarsMin { - updatedConfig[k] = v - } + maps.Copy(updatedConfig, testConfigVolumeVarsMin) updatedConfig["size"] = config.IntegerVariable(20) return updatedConfig }() @@ -250,9 +240,7 @@ var testConfigVolumeVarsMax = config.Variables{ var testConfigVolumeVarsMaxUpdated = func() config.Variables { updatedConfig := config.Variables{} - for k, v := range testConfigVolumeVarsMax { - updatedConfig[k] = v - } + maps.Copy(updatedConfig, testConfigVolumeVarsMax) updatedConfig["size"] = config.IntegerVariable(20) updatedConfig["name"] = config.StringVariable(fmt.Sprintf("%s-updated", testutil.ConvertConfigVariable(testConfigVolumeVarsMax["name"]))) updatedConfig["description"] = config.StringVariable(fmt.Sprintf("%s-updated", testutil.ConvertConfigVariable(testConfigVolumeVarsMax["description"]))) @@ -310,9 +298,7 @@ var testConfigNetworkAreaVarsMin = config.Variables{ var testConfigNetworkAreaVarsMinUpdated = func() config.Variables { updatedConfig := config.Variables{} - for k, v := range testConfigNetworkAreaVarsMin { - updatedConfig[k] = v - } + maps.Copy(updatedConfig, testConfigNetworkAreaVarsMin) updatedConfig["name"] = config.StringVariable(fmt.Sprintf("%s-updated", testutil.ConvertConfigVariable(updatedConfig["name"]))) return updatedConfig }() @@ -337,9 +323,7 @@ var testConfigNetworkAreaVarsMax = config.Variables{ var testConfigNetworkAreaVarsMaxUpdated = func() config.Variables { updatedConfig := config.Variables{} - for k, v := range testConfigNetworkAreaVarsMax { - updatedConfig[k] = v - } + maps.Copy(updatedConfig, testConfigNetworkAreaVarsMax) updatedConfig["name"] = config.StringVariable(fmt.Sprintf("%s-updated", testutil.ConvertConfigVariable(updatedConfig["name"]))) updatedConfig["network_ranges_prefix"] = config.StringVariable("10.0.0.0/18") updatedConfig["default_nameservers"] = config.StringVariable("1.1.1.2") @@ -366,9 +350,7 @@ var testConfigNetworkAreaRegionVarsMin = config.Variables{ var testConfigNetworkAreaRegionVarsMinUpdated = func() config.Variables { updatedConfig := config.Variables{} - for k, v := range testConfigNetworkAreaRegionVarsMin { - updatedConfig[k] = v - } + maps.Copy(updatedConfig, testConfigNetworkAreaRegionVarsMin) updatedConfig["network_ranges_prefix"] = config.StringVariable("10.0.0.0/18") return updatedConfig }() @@ -388,9 +370,7 @@ var testConfigNetworkAreaRegionVarsMax = config.Variables{ var testConfigNetworkAreaRegionVarsMaxUpdated = func() config.Variables { updatedConfig := config.Variables{} - for k, v := range testConfigNetworkAreaRegionVarsMax { - updatedConfig[k] = v - } + maps.Copy(updatedConfig, testConfigNetworkAreaRegionVarsMax) updatedConfig["network_ranges_prefix"] = config.StringVariable("10.0.0.0/18") updatedConfig["default_nameservers"] = config.StringVariable("8.8.8.8") updatedConfig["default_prefix_length"] = config.IntegerVariable(27) @@ -409,9 +389,7 @@ var testConfigSecurityGroupsVarsMin = config.Variables{ func testConfigSecurityGroupsVarsMinUpdated() config.Variables { updatedConfig := config.Variables{} - for k, v := range testConfigSecurityGroupsVarsMin { - updatedConfig[k] = v - } + maps.Copy(updatedConfig, testConfigSecurityGroupsVarsMin) updatedConfig["name"] = config.StringVariable(fmt.Sprintf("%s-updated", testutil.ConvertConfigVariable(updatedConfig["name"]))) return updatedConfig } @@ -437,9 +415,7 @@ var testConfigSecurityGroupsVarsMax = config.Variables{ func testConfigSecurityGroupsVarsMaxUpdated() config.Variables { updatedConfig := config.Variables{} - for k, v := range testConfigSecurityGroupsVarsMax { - updatedConfig[k] = v - } + maps.Copy(updatedConfig, testConfigSecurityGroupsVarsMax) updatedConfig["name"] = config.StringVariable(fmt.Sprintf("%s-updated", testutil.ConvertConfigVariable(updatedConfig["name"]))) updatedConfig["name_remote"] = config.StringVariable(fmt.Sprintf("%s-updated", testutil.ConvertConfigVariable(updatedConfig["name_remote"]))) updatedConfig["description"] = config.StringVariable(fmt.Sprintf("%s-updated", testutil.ConvertConfigVariable(updatedConfig["description"]))) @@ -470,9 +446,7 @@ var testConfigImageVarsMin = func() config.Variables { var testConfigImageVarsMinUpdated = func() config.Variables { updatedConfig := config.Variables{} - for k, v := range testConfigImageVarsMin { - updatedConfig[k] = v - } + maps.Copy(updatedConfig, testConfigImageVarsMin) updatedConfig["name"] = config.StringVariable(fmt.Sprintf("%s-updated", testutil.ConvertConfigVariable(updatedConfig["name"]))) return updatedConfig }() @@ -515,9 +489,7 @@ var testConfigImageVarsMax = func() config.Variables { var testConfigImageVarsMaxUpdated = func() config.Variables { updatedConfig := config.Variables{} - for k, v := range testConfigImageVarsMax { - updatedConfig[k] = v - } + maps.Copy(updatedConfig, testConfigImageVarsMax) updatedConfig["name"] = config.StringVariable(fmt.Sprintf("%s-updated", testutil.ConvertConfigVariable(updatedConfig["name"]))) updatedConfig["min_disk_size"] = config.IntegerVariable(25) updatedConfig["min_ram"] = config.IntegerVariable(4096) @@ -555,9 +527,7 @@ var testConfigKeyPairMax = config.Variables{ var testConfigKeyPairMaxUpdated = func() config.Variables { updatedConfig := config.Variables{} - for k, v := range testConfigKeyPairMax { - updatedConfig[k] = v - } + maps.Copy(updatedConfig, testConfigKeyPairMax) updatedConfig["label"] = config.StringVariable("updated") return updatedConfig }() @@ -590,9 +560,7 @@ var testConfigRoutingTableMax = config.Variables{ var testConfigRoutingTableMaxUpdated = func() config.Variables { updatedConfig := config.Variables{} - for k, v := range testConfigRoutingTableMax { - updatedConfig[k] = v - } + maps.Copy(updatedConfig, testConfigRoutingTableMax) updatedConfig["name"] = config.StringVariable(fmt.Sprintf("acc-test-%s", acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum))) updatedConfig["description"] = config.StringVariable("This is the updated description of the routing table.") updatedConfig["label"] = config.StringVariable("routing-table-updated-label-01") diff --git a/stackit/internal/services/iaas/image/datasource.go b/stackit/internal/services/iaas/image/datasource.go index 0d3e1aa2a..8432a0b82 100644 --- a/stackit/internal/services/iaas/image/datasource.go +++ b/stackit/internal/services/iaas/image/datasource.go @@ -300,7 +300,7 @@ func mapDataSourceFields(ctx context.Context, imageResp *iaas.Image, model *Data configModel.SecureBoot = types.BoolPointerValue(imageResp.Config.SecureBoot) configModel.UEFI = types.BoolPointerValue(imageResp.Config.Uefi) configModel.VideoModel = types.StringPointerValue(imageResp.Config.GetVideoModel()) - configModel.VirtioScsi = types.BoolPointerValue(iaas.PtrBool(imageResp.Config.GetVirtioScsi())) + configModel.VirtioScsi = types.BoolPointerValue(new(imageResp.Config.GetVirtioScsi())) configObject, diags = types.ObjectValue(configTypes, map[string]attr.Value{ "boot_menu": configModel.BootMenu, diff --git a/stackit/internal/services/iaas/image/datasource_test.go b/stackit/internal/services/iaas/image/datasource_test.go index 37d812359..c11c65c93 100644 --- a/stackit/internal/services/iaas/image/datasource_test.go +++ b/stackit/internal/services/iaas/image/datasource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/iaas" ) @@ -31,7 +30,7 @@ func TestMapDataSourceFields(t *testing.T) { ImageId: types.StringValue("iid"), }, input: &iaas.Image{ - Id: utils.Ptr("iid"), + Id: new("iid"), }, region: "eu01", }, @@ -53,33 +52,33 @@ func TestMapDataSourceFields(t *testing.T) { Region: types.StringValue("eu01"), }, input: &iaas.Image{ - Id: utils.Ptr("iid"), - Name: utils.Ptr("name"), - DiskFormat: utils.Ptr("format"), - MinDiskSize: utils.Ptr(int64(1)), - MinRam: utils.Ptr(int64(1)), - Protected: utils.Ptr(true), - Scope: utils.Ptr("scope"), + Id: new("iid"), + Name: new("name"), + DiskFormat: new("format"), + MinDiskSize: new(int64(1)), + MinRam: new(int64(1)), + Protected: new(true), + Scope: new("scope"), Config: &iaas.ImageConfig{ - BootMenu: utils.Ptr(true), - CdromBus: iaas.NewNullableString(utils.Ptr("cdrom_bus")), - DiskBus: iaas.NewNullableString(utils.Ptr("disk_bus")), - NicModel: iaas.NewNullableString(utils.Ptr("model")), - OperatingSystem: utils.Ptr("os"), - OperatingSystemDistro: iaas.NewNullableString(utils.Ptr("os_distro")), - OperatingSystemVersion: iaas.NewNullableString(utils.Ptr("os_version")), - RescueBus: iaas.NewNullableString(utils.Ptr("rescue_bus")), - RescueDevice: iaas.NewNullableString(utils.Ptr("rescue_device")), - SecureBoot: utils.Ptr(true), - Uefi: utils.Ptr(true), - VideoModel: iaas.NewNullableString(utils.Ptr("model")), - VirtioScsi: utils.Ptr(true), + BootMenu: new(true), + CdromBus: iaas.NewNullableString(new("cdrom_bus")), + DiskBus: iaas.NewNullableString(new("disk_bus")), + NicModel: iaas.NewNullableString(new("model")), + OperatingSystem: new("os"), + OperatingSystemDistro: iaas.NewNullableString(new("os_distro")), + OperatingSystemVersion: iaas.NewNullableString(new("os_version")), + RescueBus: iaas.NewNullableString(new("rescue_bus")), + RescueDevice: iaas.NewNullableString(new("rescue_device")), + SecureBoot: new(true), + Uefi: new(true), + VideoModel: iaas.NewNullableString(new("model")), + VirtioScsi: new(true), }, Checksum: &iaas.ImageChecksum{ - Algorithm: utils.Ptr("algorithm"), - Digest: utils.Ptr("digest"), + Algorithm: new("algorithm"), + Digest: new("digest"), }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, }, @@ -130,7 +129,7 @@ func TestMapDataSourceFields(t *testing.T) { Labels: types.MapValueMust(types.StringType, map[string]attr.Value{}), }, input: &iaas.Image{ - Id: utils.Ptr("iid"), + Id: new("iid"), }, region: "eu01", }, diff --git a/stackit/internal/services/iaas/image/resource.go b/stackit/internal/services/iaas/image/resource.go index 7581bd383..89c6d620c 100644 --- a/stackit/internal/services/iaas/image/resource.go +++ b/stackit/internal/services/iaas/image/resource.go @@ -696,7 +696,7 @@ func mapFields(ctx context.Context, imageResp *iaas.Image, model *Model, region configModel.SecureBoot = types.BoolPointerValue(imageResp.Config.SecureBoot) configModel.UEFI = types.BoolPointerValue(imageResp.Config.Uefi) configModel.VideoModel = types.StringPointerValue(imageResp.Config.GetVideoModel()) - configModel.VirtioScsi = types.BoolPointerValue(iaas.PtrBool(imageResp.Config.GetVirtioScsi())) + configModel.VirtioScsi = types.BoolPointerValue(new(imageResp.Config.GetVirtioScsi())) configObject, diags = types.ObjectValue(configTypes, map[string]attr.Value{ "boot_menu": configModel.BootMenu, diff --git a/stackit/internal/services/iaas/image/resource_test.go b/stackit/internal/services/iaas/image/resource_test.go index 2040bdd69..665d7f86c 100644 --- a/stackit/internal/services/iaas/image/resource_test.go +++ b/stackit/internal/services/iaas/image/resource_test.go @@ -12,7 +12,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/iaas" ) @@ -36,7 +35,7 @@ func TestMapFields(t *testing.T) { ImageId: types.StringValue("iid"), }, input: &iaas.Image{ - Id: utils.Ptr("iid"), + Id: new("iid"), }, region: "eu01", }, @@ -58,33 +57,33 @@ func TestMapFields(t *testing.T) { Region: types.StringValue("eu01"), }, input: &iaas.Image{ - Id: utils.Ptr("iid"), - Name: utils.Ptr("name"), - DiskFormat: utils.Ptr("format"), - MinDiskSize: utils.Ptr(int64(1)), - MinRam: utils.Ptr(int64(1)), - Protected: utils.Ptr(true), - Scope: utils.Ptr("scope"), + Id: new("iid"), + Name: new("name"), + DiskFormat: new("format"), + MinDiskSize: new(int64(1)), + MinRam: new(int64(1)), + Protected: new(true), + Scope: new("scope"), Config: &iaas.ImageConfig{ - BootMenu: utils.Ptr(true), - CdromBus: iaas.NewNullableString(utils.Ptr("cdrom_bus")), - DiskBus: iaas.NewNullableString(utils.Ptr("disk_bus")), - NicModel: iaas.NewNullableString(utils.Ptr("model")), - OperatingSystem: utils.Ptr("os"), - OperatingSystemDistro: iaas.NewNullableString(utils.Ptr("os_distro")), - OperatingSystemVersion: iaas.NewNullableString(utils.Ptr("os_version")), - RescueBus: iaas.NewNullableString(utils.Ptr("rescue_bus")), - RescueDevice: iaas.NewNullableString(utils.Ptr("rescue_device")), - SecureBoot: utils.Ptr(true), - Uefi: utils.Ptr(true), - VideoModel: iaas.NewNullableString(utils.Ptr("model")), - VirtioScsi: utils.Ptr(true), + BootMenu: new(true), + CdromBus: iaas.NewNullableString(new("cdrom_bus")), + DiskBus: iaas.NewNullableString(new("disk_bus")), + NicModel: iaas.NewNullableString(new("model")), + OperatingSystem: new("os"), + OperatingSystemDistro: iaas.NewNullableString(new("os_distro")), + OperatingSystemVersion: iaas.NewNullableString(new("os_version")), + RescueBus: iaas.NewNullableString(new("rescue_bus")), + RescueDevice: iaas.NewNullableString(new("rescue_device")), + SecureBoot: new(true), + Uefi: new(true), + VideoModel: iaas.NewNullableString(new("model")), + VirtioScsi: new(true), }, Checksum: &iaas.ImageChecksum{ - Algorithm: utils.Ptr("algorithm"), - Digest: utils.Ptr("digest"), + Algorithm: new("algorithm"), + Digest: new("digest"), }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, }, @@ -135,7 +134,7 @@ func TestMapFields(t *testing.T) { Labels: types.MapValueMust(types.StringType, map[string]attr.Value{}), }, input: &iaas.Image{ - Id: utils.Ptr("iid"), + Id: new("iid"), }, region: "eu01", }, @@ -218,27 +217,27 @@ func TestToCreatePayload(t *testing.T) { }), }, &iaas.CreateImagePayload{ - Name: utils.Ptr("name"), - DiskFormat: utils.Ptr("format"), - MinDiskSize: utils.Ptr(int64(1)), - MinRam: utils.Ptr(int64(1)), - Protected: utils.Ptr(true), + Name: new("name"), + DiskFormat: new("format"), + MinDiskSize: new(int64(1)), + MinRam: new(int64(1)), + Protected: new(true), Config: &iaas.ImageConfig{ - BootMenu: utils.Ptr(true), - CdromBus: iaas.NewNullableString(utils.Ptr("cdrom_bus")), - DiskBus: iaas.NewNullableString(utils.Ptr("disk_bus")), - NicModel: iaas.NewNullableString(utils.Ptr("nic_model")), - OperatingSystem: utils.Ptr("os"), - OperatingSystemDistro: iaas.NewNullableString(utils.Ptr("os_distro")), - OperatingSystemVersion: iaas.NewNullableString(utils.Ptr("os_version")), - RescueBus: iaas.NewNullableString(utils.Ptr("rescue_bus")), - RescueDevice: iaas.NewNullableString(utils.Ptr("rescue_device")), - SecureBoot: utils.Ptr(true), - Uefi: utils.Ptr(true), - VideoModel: iaas.NewNullableString(utils.Ptr("video_model")), - VirtioScsi: utils.Ptr(true), + BootMenu: new(true), + CdromBus: iaas.NewNullableString(new("cdrom_bus")), + DiskBus: iaas.NewNullableString(new("disk_bus")), + NicModel: iaas.NewNullableString(new("nic_model")), + OperatingSystem: new("os"), + OperatingSystemDistro: iaas.NewNullableString(new("os_distro")), + OperatingSystemVersion: iaas.NewNullableString(new("os_version")), + RescueBus: iaas.NewNullableString(new("rescue_bus")), + RescueDevice: iaas.NewNullableString(new("rescue_device")), + SecureBoot: new(true), + Uefi: new(true), + VideoModel: iaas.NewNullableString(new("video_model")), + VirtioScsi: new(true), }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, }, @@ -302,26 +301,26 @@ func TestToUpdatePayload(t *testing.T) { }), }, &iaas.UpdateImagePayload{ - Name: utils.Ptr("name"), - MinDiskSize: utils.Ptr(int64(1)), - MinRam: utils.Ptr(int64(1)), - Protected: utils.Ptr(true), + Name: new("name"), + MinDiskSize: new(int64(1)), + MinRam: new(int64(1)), + Protected: new(true), Config: &iaas.ImageConfig{ - BootMenu: utils.Ptr(true), - CdromBus: iaas.NewNullableString(utils.Ptr("cdrom_bus")), - DiskBus: iaas.NewNullableString(utils.Ptr("disk_bus")), - NicModel: iaas.NewNullableString(utils.Ptr("nic_model")), - OperatingSystem: utils.Ptr("os"), - OperatingSystemDistro: iaas.NewNullableString(utils.Ptr("os_distro")), - OperatingSystemVersion: iaas.NewNullableString(utils.Ptr("os_version")), - RescueBus: iaas.NewNullableString(utils.Ptr("rescue_bus")), - RescueDevice: iaas.NewNullableString(utils.Ptr("rescue_device")), - SecureBoot: utils.Ptr(true), - Uefi: utils.Ptr(true), - VideoModel: iaas.NewNullableString(utils.Ptr("video_model")), - VirtioScsi: utils.Ptr(true), + BootMenu: new(true), + CdromBus: iaas.NewNullableString(new("cdrom_bus")), + DiskBus: iaas.NewNullableString(new("disk_bus")), + NicModel: iaas.NewNullableString(new("nic_model")), + OperatingSystem: new("os"), + OperatingSystemDistro: iaas.NewNullableString(new("os_distro")), + OperatingSystemVersion: iaas.NewNullableString(new("os_version")), + RescueBus: iaas.NewNullableString(new("rescue_bus")), + RescueDevice: iaas.NewNullableString(new("rescue_device")), + SecureBoot: new(true), + Uefi: new(true), + VideoModel: iaas.NewNullableString(new("video_model")), + VirtioScsi: new(true), }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, }, diff --git a/stackit/internal/services/iaas/imagev2/datasource.go b/stackit/internal/services/iaas/imagev2/datasource.go index 01f3b8a20..cad6d2cd7 100644 --- a/stackit/internal/services/iaas/imagev2/datasource.go +++ b/stackit/internal/services/iaas/imagev2/datasource.go @@ -520,7 +520,7 @@ func mapDataSourceFields(ctx context.Context, imageResp *iaas.Image, model *Data configModel.SecureBoot = types.BoolPointerValue(imageResp.Config.SecureBoot) configModel.UEFI = types.BoolPointerValue(imageResp.Config.Uefi) configModel.VideoModel = types.StringPointerValue(imageResp.Config.GetVideoModel()) - configModel.VirtioScsi = types.BoolPointerValue(iaas.PtrBool(imageResp.Config.GetVirtioScsi())) + configModel.VirtioScsi = types.BoolPointerValue(new(imageResp.Config.GetVirtioScsi())) configObject, diags = types.ObjectValue(configTypes, map[string]attr.Value{ "boot_menu": configModel.BootMenu, diff --git a/stackit/internal/services/iaas/imagev2/datasource_test.go b/stackit/internal/services/iaas/imagev2/datasource_test.go index 3d27ed4f9..0a8755773 100644 --- a/stackit/internal/services/iaas/imagev2/datasource_test.go +++ b/stackit/internal/services/iaas/imagev2/datasource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/iaas" ) @@ -31,7 +30,7 @@ func TestMapDataSourceFields(t *testing.T) { ImageId: types.StringValue("iid"), }, input: &iaas.Image{ - Id: utils.Ptr("iid"), + Id: new("iid"), }, region: "eu01", }, @@ -53,33 +52,33 @@ func TestMapDataSourceFields(t *testing.T) { Region: types.StringValue("eu01"), }, input: &iaas.Image{ - Id: utils.Ptr("iid"), - Name: utils.Ptr("name"), - DiskFormat: utils.Ptr("format"), - MinDiskSize: utils.Ptr(int64(1)), - MinRam: utils.Ptr(int64(1)), - Protected: utils.Ptr(true), - Scope: utils.Ptr("scope"), + Id: new("iid"), + Name: new("name"), + DiskFormat: new("format"), + MinDiskSize: new(int64(1)), + MinRam: new(int64(1)), + Protected: new(true), + Scope: new("scope"), Config: &iaas.ImageConfig{ - BootMenu: utils.Ptr(true), - CdromBus: iaas.NewNullableString(utils.Ptr("cdrom_bus")), - DiskBus: iaas.NewNullableString(utils.Ptr("disk_bus")), - NicModel: iaas.NewNullableString(utils.Ptr("model")), - OperatingSystem: utils.Ptr("os"), - OperatingSystemDistro: iaas.NewNullableString(utils.Ptr("os_distro")), - OperatingSystemVersion: iaas.NewNullableString(utils.Ptr("os_version")), - RescueBus: iaas.NewNullableString(utils.Ptr("rescue_bus")), - RescueDevice: iaas.NewNullableString(utils.Ptr("rescue_device")), - SecureBoot: utils.Ptr(true), - Uefi: utils.Ptr(true), - VideoModel: iaas.NewNullableString(utils.Ptr("model")), - VirtioScsi: utils.Ptr(true), + BootMenu: new(true), + CdromBus: iaas.NewNullableString(new("cdrom_bus")), + DiskBus: iaas.NewNullableString(new("disk_bus")), + NicModel: iaas.NewNullableString(new("model")), + OperatingSystem: new("os"), + OperatingSystemDistro: iaas.NewNullableString(new("os_distro")), + OperatingSystemVersion: iaas.NewNullableString(new("os_version")), + RescueBus: iaas.NewNullableString(new("rescue_bus")), + RescueDevice: iaas.NewNullableString(new("rescue_device")), + SecureBoot: new(true), + Uefi: new(true), + VideoModel: iaas.NewNullableString(new("model")), + VirtioScsi: new(true), }, Checksum: &iaas.ImageChecksum{ - Algorithm: utils.Ptr("algorithm"), - Digest: utils.Ptr("digest"), + Algorithm: new("algorithm"), + Digest: new("digest"), }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, }, @@ -130,7 +129,7 @@ func TestMapDataSourceFields(t *testing.T) { Labels: types.MapValueMust(types.StringType, map[string]attr.Value{}), }, input: &iaas.Image{ - Id: utils.Ptr("iid"), + Id: new("iid"), }, region: "eu01", }, @@ -198,11 +197,11 @@ func TestImageMatchesFilter(t *testing.T) { name: "all fields match", img: &iaas.Image{ Config: &iaas.ImageConfig{ - OperatingSystem: utils.Ptr("linux"), - OperatingSystemDistro: iaas.NewNullableString(utils.Ptr("ubuntu")), - OperatingSystemVersion: iaas.NewNullableString(utils.Ptr("22.04")), - Uefi: utils.Ptr(true), - SecureBoot: utils.Ptr(true), + OperatingSystem: new("linux"), + OperatingSystemDistro: iaas.NewNullableString(new("ubuntu")), + OperatingSystemVersion: iaas.NewNullableString(new("22.04")), + Uefi: new(true), + SecureBoot: new(true), }, }, filter: &Filter{ @@ -218,7 +217,7 @@ func TestImageMatchesFilter(t *testing.T) { name: "OS mismatch", img: &iaas.Image{ Config: &iaas.ImageConfig{ - OperatingSystem: utils.Ptr("windows"), + OperatingSystem: new("windows"), }, }, filter: &Filter{ @@ -230,7 +229,7 @@ func TestImageMatchesFilter(t *testing.T) { name: "Distro mismatch", img: &iaas.Image{ Config: &iaas.ImageConfig{ - OperatingSystemDistro: iaas.NewNullableString(utils.Ptr("debian")), + OperatingSystemDistro: iaas.NewNullableString(new("debian")), }, }, filter: &Filter{ @@ -242,7 +241,7 @@ func TestImageMatchesFilter(t *testing.T) { name: "Version mismatch", img: &iaas.Image{ Config: &iaas.ImageConfig{ - OperatingSystemVersion: iaas.NewNullableString(utils.Ptr("20.04")), + OperatingSystemVersion: iaas.NewNullableString(new("20.04")), }, }, filter: &Filter{ @@ -254,7 +253,7 @@ func TestImageMatchesFilter(t *testing.T) { name: "UEFI mismatch", img: &iaas.Image{ Config: &iaas.ImageConfig{ - Uefi: utils.Ptr(false), + Uefi: new(false), }, }, filter: &Filter{ @@ -266,7 +265,7 @@ func TestImageMatchesFilter(t *testing.T) { name: "SecureBoot mismatch", img: &iaas.Image{ Config: &iaas.ImageConfig{ - SecureBoot: utils.Ptr(false), + SecureBoot: new(false), }, }, filter: &Filter{ @@ -278,7 +277,7 @@ func TestImageMatchesFilter(t *testing.T) { name: "SecureBoot match - true", img: &iaas.Image{ Config: &iaas.ImageConfig{ - SecureBoot: utils.Ptr(true), + SecureBoot: new(true), }, }, filter: &Filter{ @@ -290,7 +289,7 @@ func TestImageMatchesFilter(t *testing.T) { name: "SecureBoot match - false", img: &iaas.Image{ Config: &iaas.ImageConfig{ - SecureBoot: utils.Ptr(false), + SecureBoot: new(false), }, }, filter: &Filter{ @@ -314,7 +313,7 @@ func TestImageMatchesFilter(t *testing.T) { name: "partial filter match - only distro set and match", img: &iaas.Image{ Config: &iaas.ImageConfig{ - OperatingSystemDistro: iaas.NewNullableString(utils.Ptr("ubuntu")), + OperatingSystemDistro: iaas.NewNullableString(new("ubuntu")), }, }, filter: &Filter{ @@ -326,7 +325,7 @@ func TestImageMatchesFilter(t *testing.T) { name: "partial filter match - distro mismatch", img: &iaas.Image{ Config: &iaas.ImageConfig{ - OperatingSystemDistro: iaas.NewNullableString(utils.Ptr("centos")), + OperatingSystemDistro: iaas.NewNullableString(new("centos")), }, }, filter: &Filter{ @@ -350,11 +349,11 @@ func TestImageMatchesFilter(t *testing.T) { name: "image has valid config, but filter has null values", img: &iaas.Image{ Config: &iaas.ImageConfig{ - OperatingSystem: utils.Ptr("linux"), - OperatingSystemDistro: iaas.NewNullableString(utils.Ptr("ubuntu")), - OperatingSystemVersion: iaas.NewNullableString(utils.Ptr("22.04")), - Uefi: utils.Ptr(false), - SecureBoot: utils.Ptr(false), + OperatingSystem: new("linux"), + OperatingSystemDistro: iaas.NewNullableString(new("ubuntu")), + OperatingSystemVersion: iaas.NewNullableString(new("22.04")), + Uefi: new(false), + SecureBoot: new(false), }, }, filter: &Filter{ @@ -409,9 +408,9 @@ func TestSortImagesByName(t *testing.T) { desc: "ascending by name", ascending: true, input: []*iaas.Image{ - {Name: utils.Ptr("Ubuntu 22.04")}, - {Name: utils.Ptr("Ubuntu 18.04")}, - {Name: utils.Ptr("Ubuntu 20.04")}, + {Name: new("Ubuntu 22.04")}, + {Name: new("Ubuntu 18.04")}, + {Name: new("Ubuntu 20.04")}, }, wantSorted: []string{"Ubuntu 18.04", "Ubuntu 20.04", "Ubuntu 22.04"}, }, @@ -419,9 +418,9 @@ func TestSortImagesByName(t *testing.T) { desc: "descending by name", ascending: false, input: []*iaas.Image{ - {Name: utils.Ptr("Ubuntu 22.04")}, - {Name: utils.Ptr("Ubuntu 18.04")}, - {Name: utils.Ptr("Ubuntu 20.04")}, + {Name: new("Ubuntu 22.04")}, + {Name: new("Ubuntu 18.04")}, + {Name: new("Ubuntu 20.04")}, }, wantSorted: []string{"Ubuntu 22.04", "Ubuntu 20.04", "Ubuntu 18.04"}, }, @@ -430,9 +429,9 @@ func TestSortImagesByName(t *testing.T) { ascending: true, input: []*iaas.Image{ {Name: nil}, - {Name: utils.Ptr("Ubuntu 18.04")}, + {Name: new("Ubuntu 18.04")}, {Name: nil}, - {Name: utils.Ptr("Ubuntu 20.04")}, + {Name: new("Ubuntu 20.04")}, }, wantSorted: []string{"Ubuntu 18.04", "Ubuntu 20.04", "", ""}, }, @@ -441,8 +440,8 @@ func TestSortImagesByName(t *testing.T) { ascending: false, input: []*iaas.Image{ {Name: nil}, - {Name: utils.Ptr("Ubuntu 18.04")}, - {Name: utils.Ptr("Ubuntu 20.04")}, + {Name: new("Ubuntu 18.04")}, + {Name: new("Ubuntu 20.04")}, {Name: nil}, }, wantSorted: []string{"Ubuntu 20.04", "Ubuntu 18.04", "", ""}, @@ -457,7 +456,7 @@ func TestSortImagesByName(t *testing.T) { desc: "single element slice", ascending: true, input: []*iaas.Image{ - {Name: utils.Ptr("Ubuntu 22.04")}, + {Name: new("Ubuntu 22.04")}, }, wantSorted: []string{"Ubuntu 22.04"}, }, diff --git a/stackit/internal/services/iaas/keypair/resource_test.go b/stackit/internal/services/iaas/keypair/resource_test.go index ed3af09ac..6326a5357 100644 --- a/stackit/internal/services/iaas/keypair/resource_test.go +++ b/stackit/internal/services/iaas/keypair/resource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/iaas" ) @@ -25,7 +24,7 @@ func TestMapFields(t *testing.T) { Name: types.StringValue("name"), }, &iaas.Keypair{ - Name: utils.Ptr("name"), + Name: new("name"), }, Model{ Id: types.StringValue("name"), @@ -42,10 +41,10 @@ func TestMapFields(t *testing.T) { Name: types.StringValue("name"), }, &iaas.Keypair{ - Name: utils.Ptr("name"), - PublicKey: utils.Ptr("public_key"), - Fingerprint: utils.Ptr("fingerprint"), - Labels: &map[string]interface{}{ + Name: new("name"), + PublicKey: new("public_key"), + Fingerprint: new("fingerprint"), + Labels: &map[string]any{ "key": "value", }, }, @@ -66,10 +65,10 @@ func TestMapFields(t *testing.T) { Name: types.StringValue("name"), }, &iaas.Keypair{ - Name: utils.Ptr("name"), - PublicKey: utils.Ptr("public_key"), - Fingerprint: utils.Ptr("fingerprint"), - Labels: &map[string]interface{}{}, + Name: new("name"), + PublicKey: new("public_key"), + Fingerprint: new("fingerprint"), + Labels: &map[string]any{}, }, Model{ Id: types.StringValue("name"), @@ -91,9 +90,9 @@ func TestMapFields(t *testing.T) { "no_resource_id", Model{}, &iaas.Keypair{ - PublicKey: utils.Ptr("public_key"), - Fingerprint: utils.Ptr("fingerprint"), - Labels: &map[string]interface{}{}, + PublicKey: new("public_key"), + Fingerprint: new("fingerprint"), + Labels: &map[string]any{}, }, Model{}, false, @@ -136,9 +135,9 @@ func TestToCreatePayload(t *testing.T) { }), }, &iaas.CreateKeyPairPayload{ - Name: utils.Ptr("name"), - PublicKey: utils.Ptr("public_key"), - Labels: &map[string]interface{}{ + Name: new("name"), + PublicKey: new("public_key"), + Labels: &map[string]any{ "key1": "value1", "key2": "value2", }, @@ -183,7 +182,7 @@ func TestToUpdatePayload(t *testing.T) { }), }, &iaas.UpdateKeyPairPayload{ - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key1": "value1", "key2": "value2", }, diff --git a/stackit/internal/services/iaas/machinetype/datasource_test.go b/stackit/internal/services/iaas/machinetype/datasource_test.go index 949188109..76310e061 100644 --- a/stackit/internal/services/iaas/machinetype/datasource_test.go +++ b/stackit/internal/services/iaas/machinetype/datasource_test.go @@ -8,7 +8,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/iaas" ) @@ -31,12 +30,12 @@ func TestMapDataSourceFields(t *testing.T) { ProjectId: types.StringValue("pid"), }, input: &iaas.MachineType{ - Name: utils.Ptr("s1.2"), - Description: utils.Ptr("general-purpose small"), - Disk: utils.Ptr(int64(20)), - Ram: utils.Ptr(int64(2048)), - Vcpus: utils.Ptr(int64(2)), - ExtraSpecs: &map[string]interface{}{ + Name: new("s1.2"), + Description: new("general-purpose small"), + Disk: new(int64(20)), + Ram: new(int64(2048)), + Vcpus: new(int64(2)), + ExtraSpecs: &map[string]any{ "cpu": "amd-epycrome-7702", "overcommit": "1", "environment": "general", @@ -68,7 +67,7 @@ func TestMapDataSourceFields(t *testing.T) { ProjectId: types.StringValue("pid-456"), }, input: &iaas.MachineType{ - Description: utils.Ptr("gp-medium"), + Description: new("gp-medium"), }, }, expected: DataSourceModel{}, @@ -90,12 +89,12 @@ func TestMapDataSourceFields(t *testing.T) { ProjectId: types.StringValue("pid-789"), }, input: &iaas.MachineType{ - Name: utils.Ptr("m1.noextras"), - Description: utils.Ptr("no extras"), - Disk: utils.Ptr(int64(10)), - Ram: utils.Ptr(int64(1024)), - Vcpus: utils.Ptr(int64(1)), - ExtraSpecs: &map[string]interface{}{}, + Name: new("m1.noextras"), + Description: new("no extras"), + Disk: new(int64(10)), + Ram: new(int64(1024)), + Vcpus: new(int64(1)), + ExtraSpecs: &map[string]any{}, }, region: "eu01", }, @@ -119,11 +118,11 @@ func TestMapDataSourceFields(t *testing.T) { ProjectId: types.StringValue("pid-987"), }, input: &iaas.MachineType{ - Name: utils.Ptr("g1.nil"), - Description: utils.Ptr("missing extras"), - Disk: utils.Ptr(int64(40)), - Ram: utils.Ptr(int64(8096)), - Vcpus: utils.Ptr(int64(4)), + Name: new("g1.nil"), + Description: new("missing extras"), + Disk: new(int64(40)), + Ram: new(int64(8096)), + Vcpus: new(int64(4)), ExtraSpecs: nil, }, region: "eu01", @@ -148,12 +147,12 @@ func TestMapDataSourceFields(t *testing.T) { ProjectId: types.StringValue("test-err"), }, input: &iaas.MachineType{ - Name: utils.Ptr("invalid"), - Description: utils.Ptr("bad map"), - Disk: utils.Ptr(int64(10)), - Ram: utils.Ptr(int64(4096)), - Vcpus: utils.Ptr(int64(2)), - ExtraSpecs: &map[string]interface{}{ + Name: new("invalid"), + Description: new("bad map"), + Disk: new(int64(10)), + Ram: new(int64(4096)), + Vcpus: new(int64(2)), + ExtraSpecs: &map[string]any{ "cpu": "intel", "burst": true, // not a string "gen": 8, // not a string @@ -202,19 +201,19 @@ func TestSortMachineTypeByName(t *testing.T) { }{ { name: "ascending order", - input: []*iaas.MachineType{{Name: utils.Ptr("zeta")}, {Name: utils.Ptr("alpha")}, {Name: utils.Ptr("gamma")}}, + input: []*iaas.MachineType{{Name: new("zeta")}, {Name: new("alpha")}, {Name: new("gamma")}}, ascending: true, expected: []string{"alpha", "gamma", "zeta"}, }, { name: "descending order", - input: []*iaas.MachineType{{Name: utils.Ptr("zeta")}, {Name: utils.Ptr("alpha")}, {Name: utils.Ptr("gamma")}}, + input: []*iaas.MachineType{{Name: new("zeta")}, {Name: new("alpha")}, {Name: new("gamma")}}, ascending: false, expected: []string{"zeta", "gamma", "alpha"}, }, { name: "handles nil names", - input: []*iaas.MachineType{{Name: utils.Ptr("beta")}, nil, {Name: nil}, {Name: utils.Ptr("alpha")}}, + input: []*iaas.MachineType{{Name: new("beta")}, nil, {Name: nil}, {Name: new("alpha")}}, ascending: true, expected: []string{"alpha", "beta"}, }, diff --git a/stackit/internal/services/iaas/network/datasource_test.go b/stackit/internal/services/iaas/network/datasource_test.go index cb905681c..d556b722a 100644 --- a/stackit/internal/services/iaas/network/datasource_test.go +++ b/stackit/internal/services/iaas/network/datasource_test.go @@ -9,7 +9,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" ) const ( @@ -32,7 +31,7 @@ func TestMapDataSourceFields(t *testing.T) { NetworkId: types.StringValue("nid"), }, &iaas.Network{ - Id: utils.Ptr("nid"), + Id: new("nid"), Ipv4: &iaas.NetworkIPv4{ Gateway: iaas.NewNullableString(nil), }, @@ -67,8 +66,8 @@ func TestMapDataSourceFields(t *testing.T) { NetworkId: types.StringValue("nid"), }, &iaas.Network{ - Id: utils.Ptr("nid"), - Name: utils.Ptr("name"), + Id: new("nid"), + Name: new("name"), Ipv4: &iaas.NetworkIPv4{ Nameservers: &[]string{ "ns1", @@ -78,8 +77,8 @@ func TestMapDataSourceFields(t *testing.T) { "192.168.42.0/24", "10.100.10.0/16", }, - PublicIp: utils.Ptr("publicIp"), - Gateway: iaas.NewNullableString(utils.Ptr("gateway")), + PublicIp: new("publicIp"), + Gateway: iaas.NewNullableString(new("gateway")), }, Ipv6: &iaas.NetworkIPv6{ Nameservers: &[]string{ @@ -90,13 +89,13 @@ func TestMapDataSourceFields(t *testing.T) { "fd12:3456:789a:1::/64", "fd12:3456:789a:2::/64", }, - Gateway: iaas.NewNullableString(utils.Ptr("gateway")), + Gateway: iaas.NewNullableString(new("gateway")), }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, - Routed: utils.Ptr(true), - Dhcp: utils.Ptr(true), + Routed: new(true), + Dhcp: new(true), }, testRegion, DataSourceModel{ @@ -147,7 +146,7 @@ func TestMapDataSourceFields(t *testing.T) { }), }, &iaas.Network{ - Id: utils.Ptr("nid"), + Id: new("nid"), Ipv4: &iaas.NetworkIPv4{ Nameservers: &[]string{ "ns2", @@ -184,7 +183,7 @@ func TestMapDataSourceFields(t *testing.T) { }), }, &iaas.Network{ - Id: utils.Ptr("nid"), + Id: new("nid"), Ipv6: &iaas.NetworkIPv6{ Nameservers: &[]string{ "ns2", @@ -217,7 +216,7 @@ func TestMapDataSourceFields(t *testing.T) { NetworkId: types.StringValue("nid"), }, &iaas.Network{ - Id: utils.Ptr("nid"), + Id: new("nid"), Ipv4: &iaas.NetworkIPv4{ Prefixes: &[]string{ "10.100.20.0/16", @@ -257,7 +256,7 @@ func TestMapDataSourceFields(t *testing.T) { }), }, &iaas.Network{ - Id: utils.Ptr("nid"), + Id: new("nid"), Ipv6: &iaas.NetworkIPv6{ Prefixes: &[]string{ "fd12:3456:789a:3::/64", @@ -293,7 +292,7 @@ func TestMapDataSourceFields(t *testing.T) { NetworkId: types.StringValue("nid"), }, &iaas.Network{ - Id: utils.Ptr("nid"), + Id: new("nid"), }, testRegion, DataSourceModel{ diff --git a/stackit/internal/services/iaas/network/resource_test.go b/stackit/internal/services/iaas/network/resource_test.go index 2c6aaa916..b774ce38a 100644 --- a/stackit/internal/services/iaas/network/resource_test.go +++ b/stackit/internal/services/iaas/network/resource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/iaas" ) @@ -28,7 +27,7 @@ func TestMapFields(t *testing.T) { NetworkId: types.StringValue("nid"), }, &iaas.Network{ - Id: utils.Ptr("nid"), + Id: new("nid"), Ipv4: &iaas.NetworkIPv4{ Gateway: iaas.NewNullableString(nil), }, @@ -63,32 +62,32 @@ func TestMapFields(t *testing.T) { NetworkId: types.StringValue("nid"), }, &iaas.Network{ - Id: utils.Ptr("nid"), - Name: utils.Ptr("name"), + Id: new("nid"), + Name: new("name"), Ipv4: &iaas.NetworkIPv4{ - Nameservers: utils.Ptr([]string{"ns1", "ns2"}), - Prefixes: utils.Ptr( + Nameservers: new([]string{"ns1", "ns2"}), + Prefixes: new( []string{ "192.168.42.0/24", "10.100.10.0/16", }, ), - PublicIp: utils.Ptr("publicIp"), - Gateway: iaas.NewNullableString(utils.Ptr("gateway")), + PublicIp: new("publicIp"), + Gateway: iaas.NewNullableString(new("gateway")), }, Ipv6: &iaas.NetworkIPv6{ - Nameservers: utils.Ptr([]string{"ns1", "ns2"}), - Prefixes: utils.Ptr([]string{ + Nameservers: new([]string{"ns1", "ns2"}), + Prefixes: new([]string{ "fd12:3456:789a:1::/64", "fd12:3456:789b:1::/64", }), - Gateway: iaas.NewNullableString(utils.Ptr("gateway")), + Gateway: iaas.NewNullableString(new("gateway")), }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, - Routed: utils.Ptr(true), - Dhcp: utils.Ptr(true), + Routed: new(true), + Dhcp: new(true), }, testRegion, Model{ @@ -139,9 +138,9 @@ func TestMapFields(t *testing.T) { }), }, &iaas.Network{ - Id: utils.Ptr("nid"), + Id: new("nid"), Ipv4: &iaas.NetworkIPv4{ - Nameservers: utils.Ptr([]string{ + Nameservers: new([]string{ "ns2", "ns3", }), @@ -176,9 +175,9 @@ func TestMapFields(t *testing.T) { }), }, &iaas.Network{ - Id: utils.Ptr("nid"), + Id: new("nid"), Ipv6: &iaas.NetworkIPv6{ - Nameservers: utils.Ptr([]string{ + Nameservers: new([]string{ "ns2", "ns3", }), @@ -209,9 +208,9 @@ func TestMapFields(t *testing.T) { NetworkId: types.StringValue("nid"), }, &iaas.Network{ - Id: utils.Ptr("nid"), + Id: new("nid"), Ipv4: &iaas.NetworkIPv4{ - Prefixes: utils.Ptr( + Prefixes: new( []string{ "192.168.54.0/24", "192.168.55.0/24", @@ -251,9 +250,9 @@ func TestMapFields(t *testing.T) { }), }, &iaas.Network{ - Id: utils.Ptr("nid"), + Id: new("nid"), Ipv6: &iaas.NetworkIPv6{ - Prefixes: utils.Ptr( + Prefixes: new( []string{ "fd12:3456:789a:1::/64", "fd12:3456:789a:2::/64", @@ -289,7 +288,7 @@ func TestMapFields(t *testing.T) { NetworkId: types.StringValue("nid"), }, &iaas.Network{ - Id: utils.Ptr("nid"), + Id: new("nid"), }, testRegion, Model{ @@ -374,22 +373,22 @@ func TestToCreatePayload(t *testing.T) { DHCP: types.BoolValue(true), }, &iaas.CreateNetworkPayload{ - Name: utils.Ptr("name"), + Name: new("name"), Ipv4: &iaas.CreateNetworkIPv4{ CreateNetworkIPv4WithPrefix: &iaas.CreateNetworkIPv4WithPrefix{ - Gateway: iaas.NewNullableString(utils.Ptr("gateway")), - Nameservers: utils.Ptr([]string{ + Gateway: iaas.NewNullableString(new("gateway")), + Nameservers: new([]string{ "ns1", "ns2", }), - Prefix: utils.Ptr("prefix"), + Prefix: new("prefix"), }, }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, - Routed: utils.Ptr(false), - Dhcp: utils.Ptr(true), + Routed: new(false), + Dhcp: new(true), }, true, }, @@ -409,21 +408,21 @@ func TestToCreatePayload(t *testing.T) { IPv4Prefix: types.StringValue("prefix"), }, &iaas.CreateNetworkPayload{ - Name: utils.Ptr("name"), + Name: new("name"), Ipv4: &iaas.CreateNetworkIPv4{ CreateNetworkIPv4WithPrefix: &iaas.CreateNetworkIPv4WithPrefix{ - Gateway: iaas.NewNullableString(utils.Ptr("gateway")), - Nameservers: utils.Ptr([]string{ + Gateway: iaas.NewNullableString(new("gateway")), + Nameservers: new([]string{ "ns1", "ns2", }), - Prefix: utils.Ptr("prefix"), + Prefix: new("prefix"), }, }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, - Routed: utils.Ptr(false), + Routed: new(false), }, true, }, @@ -440,18 +439,18 @@ func TestToCreatePayload(t *testing.T) { IPv4Prefix: types.StringValue("prefix"), }, &iaas.CreateNetworkPayload{ - Name: utils.Ptr("name"), + Name: new("name"), Ipv4: &iaas.CreateNetworkIPv4{ CreateNetworkIPv4WithPrefix: &iaas.CreateNetworkIPv4WithPrefix{ - Gateway: iaas.NewNullableString(utils.Ptr("gateway")), + Gateway: iaas.NewNullableString(new("gateway")), Nameservers: nil, - Prefix: utils.Ptr("prefix"), + Prefix: new("prefix"), }, }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, - Routed: utils.Ptr(false), + Routed: new(false), }, true, }, @@ -468,18 +467,18 @@ func TestToCreatePayload(t *testing.T) { IPv4Prefix: types.StringValue("prefix"), }, &iaas.CreateNetworkPayload{ - Name: utils.Ptr("name"), + Name: new("name"), Ipv4: &iaas.CreateNetworkIPv4{ CreateNetworkIPv4WithPrefix: &iaas.CreateNetworkIPv4WithPrefix{ - Gateway: iaas.NewNullableString(utils.Ptr("gateway")), - Nameservers: utils.Ptr([]string{}), - Prefix: utils.Ptr("prefix"), + Gateway: iaas.NewNullableString(new("gateway")), + Nameservers: new([]string{}), + Prefix: new("prefix"), }, }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, - Routed: utils.Ptr(false), + Routed: new(false), }, true, }, @@ -499,21 +498,21 @@ func TestToCreatePayload(t *testing.T) { IPv6Prefix: types.StringValue("prefix"), }, &iaas.CreateNetworkPayload{ - Name: utils.Ptr("name"), + Name: new("name"), Ipv6: &iaas.CreateNetworkIPv6{ CreateNetworkIPv6WithPrefix: &iaas.CreateNetworkIPv6WithPrefix{ - Gateway: iaas.NewNullableString(utils.Ptr("gateway")), - Nameservers: utils.Ptr([]string{ + Gateway: iaas.NewNullableString(new("gateway")), + Nameservers: new([]string{ "ns1", "ns2", }), - Prefix: utils.Ptr("prefix"), + Prefix: new("prefix"), }, }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, - Routed: utils.Ptr(false), + Routed: new(false), }, true, }, @@ -530,18 +529,18 @@ func TestToCreatePayload(t *testing.T) { IPv6Prefix: types.StringValue("prefix"), }, &iaas.CreateNetworkPayload{ - Name: utils.Ptr("name"), + Name: new("name"), Ipv6: &iaas.CreateNetworkIPv6{ CreateNetworkIPv6WithPrefix: &iaas.CreateNetworkIPv6WithPrefix{ Nameservers: nil, - Gateway: iaas.NewNullableString(utils.Ptr("gateway")), - Prefix: utils.Ptr("prefix"), + Gateway: iaas.NewNullableString(new("gateway")), + Prefix: new("prefix"), }, }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, - Routed: utils.Ptr(false), + Routed: new(false), }, true, }, @@ -558,18 +557,18 @@ func TestToCreatePayload(t *testing.T) { IPv6Prefix: types.StringValue("prefix"), }, &iaas.CreateNetworkPayload{ - Name: utils.Ptr("name"), + Name: new("name"), Ipv6: &iaas.CreateNetworkIPv6{ CreateNetworkIPv6WithPrefix: &iaas.CreateNetworkIPv6WithPrefix{ - Nameservers: utils.Ptr([]string{}), - Gateway: iaas.NewNullableString(utils.Ptr("gateway")), - Prefix: utils.Ptr("prefix"), + Nameservers: new([]string{}), + Gateway: iaas.NewNullableString(new("gateway")), + Prefix: new("prefix"), }, }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, - Routed: utils.Ptr(false), + Routed: new(false), }, true, }, @@ -622,18 +621,18 @@ func TestToUpdatePayload(t *testing.T) { Labels: types.MapNull(types.StringType), }, &iaas.PartialUpdateNetworkPayload{ - Name: utils.Ptr("name"), + Name: new("name"), Ipv4: &iaas.UpdateNetworkIPv4Body{ - Gateway: iaas.NewNullableString(utils.Ptr("gateway")), - Nameservers: utils.Ptr([]string{ + Gateway: iaas.NewNullableString(new("gateway")), + Nameservers: new([]string{ "ns1", "ns2", }), }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, - Dhcp: utils.Ptr(true), + Dhcp: new(true), }, true, }, @@ -657,15 +656,15 @@ func TestToUpdatePayload(t *testing.T) { Labels: types.MapNull(types.StringType), }, &iaas.PartialUpdateNetworkPayload{ - Name: utils.Ptr("name"), + Name: new("name"), Ipv4: &iaas.UpdateNetworkIPv4Body{ - Gateway: iaas.NewNullableString(utils.Ptr("gateway")), - Nameservers: utils.Ptr([]string{ + Gateway: iaas.NewNullableString(new("gateway")), + Nameservers: new([]string{ "ns1", "ns2", }), }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, }, @@ -690,14 +689,14 @@ func TestToUpdatePayload(t *testing.T) { Labels: types.MapNull(types.StringType), }, &iaas.PartialUpdateNetworkPayload{ - Name: utils.Ptr("name"), + Name: new("name"), Ipv4: &iaas.UpdateNetworkIPv4Body{ - Nameservers: utils.Ptr([]string{ + Nameservers: new([]string{ "ns1", "ns2", }), }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, }, @@ -719,9 +718,9 @@ func TestToUpdatePayload(t *testing.T) { Labels: types.MapNull(types.StringType), }, &iaas.PartialUpdateNetworkPayload{ - Name: utils.Ptr("name"), + Name: new("name"), Ipv4: nil, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, }, @@ -744,11 +743,11 @@ func TestToUpdatePayload(t *testing.T) { Labels: types.MapNull(types.StringType), }, &iaas.PartialUpdateNetworkPayload{ - Name: utils.Ptr("name"), + Name: new("name"), Ipv4: &iaas.UpdateNetworkIPv4Body{ - Gateway: iaas.NewNullableString(utils.Ptr("gateway")), + Gateway: iaas.NewNullableString(new("gateway")), }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, }, @@ -774,15 +773,15 @@ func TestToUpdatePayload(t *testing.T) { Labels: types.MapNull(types.StringType), }, &iaas.PartialUpdateNetworkPayload{ - Name: utils.Ptr("name"), + Name: new("name"), Ipv6: &iaas.UpdateNetworkIPv6Body{ - Gateway: iaas.NewNullableString(utils.Ptr("gateway")), - Nameservers: utils.Ptr([]string{ + Gateway: iaas.NewNullableString(new("gateway")), + Nameservers: new([]string{ "ns1", "ns2", }), }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, }, @@ -807,14 +806,14 @@ func TestToUpdatePayload(t *testing.T) { Labels: types.MapNull(types.StringType), }, &iaas.PartialUpdateNetworkPayload{ - Name: utils.Ptr("name"), + Name: new("name"), Ipv6: &iaas.UpdateNetworkIPv6Body{ - Nameservers: utils.Ptr([]string{ + Nameservers: new([]string{ "ns1", "ns2", }), }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, }, @@ -837,12 +836,12 @@ func TestToUpdatePayload(t *testing.T) { Labels: types.MapNull(types.StringType), }, &iaas.PartialUpdateNetworkPayload{ - Name: utils.Ptr("name"), + Name: new("name"), Ipv6: &iaas.UpdateNetworkIPv6Body{ Nameservers: nil, - Gateway: iaas.NewNullableString(utils.Ptr("gateway")), + Gateway: iaas.NewNullableString(new("gateway")), }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, }, @@ -865,12 +864,12 @@ func TestToUpdatePayload(t *testing.T) { Labels: types.MapNull(types.StringType), }, &iaas.PartialUpdateNetworkPayload{ - Name: utils.Ptr("name"), + Name: new("name"), Ipv6: &iaas.UpdateNetworkIPv6Body{ - Nameservers: utils.Ptr([]string{}), - Gateway: iaas.NewNullableString(utils.Ptr("gateway")), + Nameservers: new([]string{}), + Gateway: iaas.NewNullableString(new("gateway")), }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, }, diff --git a/stackit/internal/services/iaas/networkarea/resource.go b/stackit/internal/services/iaas/networkarea/resource.go index 228b75e78..6a3384c8b 100644 --- a/stackit/internal/services/iaas/networkarea/resource.go +++ b/stackit/internal/services/iaas/networkarea/resource.go @@ -26,7 +26,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" - sdkUtils "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/iaas" "github.com/stackitcloud/stackit-sdk-go/services/iaas/wait" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion" @@ -1033,7 +1032,7 @@ func updateNetworkRanges(ctx context.Context, organizationId, networkAreaId stri payload := iaas.CreateNetworkAreaRangePayload{ Ipv4: &[]iaas.NetworkRange{ { - Prefix: sdkUtils.Ptr(prefix), + Prefix: new(prefix), }, }, } diff --git a/stackit/internal/services/iaas/networkarea/resource_test.go b/stackit/internal/services/iaas/networkarea/resource_test.go index dbcdfbb5e..d2fd6d0af 100644 --- a/stackit/internal/services/iaas/networkarea/resource_test.go +++ b/stackit/internal/services/iaas/networkarea/resource_test.go @@ -13,7 +13,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stackitcloud/stackit-sdk-go/core/config" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/iaas" ) @@ -52,7 +51,7 @@ func TestMapFields(t *testing.T) { DefaultNameservers: types.ListNull(types.StringType), }, input: &iaas.NetworkArea{ - Id: utils.Ptr("naid"), + Id: new("naid"), }, expected: Model{ Id: types.StringValue("oid,naid"), @@ -92,9 +91,9 @@ func TestMapFields(t *testing.T) { DefaultNameservers: types.ListNull(types.StringType), }, input: &iaas.NetworkArea{ - Id: utils.Ptr("naid"), - Name: utils.Ptr("name"), - Labels: &map[string]interface{}{ + Id: new("naid"), + Name: new("name"), + Labels: &map[string]any{ "key": "value", }, }, @@ -138,7 +137,7 @@ func TestMapFields(t *testing.T) { DefaultNameservers: types.ListNull(types.StringType), }, input: &iaas.NetworkArea{ - Id: utils.Ptr("naid"), + Id: new("naid"), }, expected: Model{ Id: types.StringValue("oid,naid"), @@ -228,16 +227,16 @@ func Test_MapNetworkRanges(t *testing.T) { }, networkAreaRangesList: &[]iaas.NetworkRange{ { - Id: utils.Ptr(testRangeId2), - Prefix: utils.Ptr("prefix-2"), + Id: new(testRangeId2), + Prefix: new("prefix-2"), }, { - Id: utils.Ptr(testRangeId3), - Prefix: utils.Ptr("prefix-3"), + Id: new(testRangeId3), + Prefix: new("prefix-3"), }, { - Id: utils.Ptr(testRangeId1), - Prefix: utils.Ptr("prefix-1"), + Id: new(testRangeId1), + Prefix: new("prefix-1"), }, }, }, @@ -284,12 +283,12 @@ func Test_MapNetworkRanges(t *testing.T) { }, networkAreaRangesList: &[]iaas.NetworkRange{ { - Id: utils.Ptr(testRangeId2), - Prefix: utils.Ptr("prefix-2"), + Id: new(testRangeId2), + Prefix: new("prefix-2"), }, { - Id: utils.Ptr(testRangeId3), - Prefix: utils.Ptr("prefix-3"), + Id: new(testRangeId3), + Prefix: new("prefix-3"), }, }, }, @@ -350,18 +349,18 @@ func TestMapNetworkAreaRegionFields(t *testing.T) { "nameserver1", "nameserver2", }, - TransferNetwork: utils.Ptr("network"), - DefaultPrefixLen: utils.Ptr(int64(20)), - MaxPrefixLen: utils.Ptr(int64(22)), - MinPrefixLen: utils.Ptr(int64(18)), + TransferNetwork: new("network"), + DefaultPrefixLen: new(int64(20)), + MaxPrefixLen: new(int64(22)), + MinPrefixLen: new(int64(18)), NetworkRanges: &[]iaas.NetworkRange{ { - Id: utils.Ptr(testRangeId1), - Prefix: utils.Ptr("prefix-1"), + Id: new(testRangeId1), + Prefix: new("prefix-1"), }, { - Id: utils.Ptr(testRangeId2), - Prefix: utils.Ptr("prefix-2"), + Id: new(testRangeId2), + Prefix: new("prefix-2"), }, }, }, @@ -448,8 +447,8 @@ func TestToCreatePayload(t *testing.T) { }), }, &iaas.CreateNetworkAreaPayload{ - Name: utils.Ptr("name"), - Labels: &map[string]interface{}{ + Name: new("name"), + Labels: &map[string]any{ "key": "value", }, }, @@ -518,16 +517,16 @@ func TestToRegionCreatePayload(t *testing.T) { }, NetworkRanges: &[]iaas.NetworkRange{ { - Prefix: utils.Ptr("pr-1"), + Prefix: new("pr-1"), }, { - Prefix: utils.Ptr("pr-2"), + Prefix: new("pr-2"), }, }, - TransferNetwork: utils.Ptr("network"), - DefaultPrefixLen: utils.Ptr(int64(20)), - MaxPrefixLen: utils.Ptr(int64(22)), - MinPrefixLen: utils.Ptr(int64(18)), + TransferNetwork: new("network"), + DefaultPrefixLen: new(int64(20)), + MaxPrefixLen: new(int64(22)), + MinPrefixLen: new(int64(18)), }, }, }, @@ -571,8 +570,8 @@ func TestToUpdatePayload(t *testing.T) { }), }, &iaas.PartialUpdateNetworkAreaPayload{ - Name: utils.Ptr("name"), - Labels: &map[string]interface{}{ + Name: new("name"), + Labels: &map[string]any{ "key": "value", }, }, @@ -628,9 +627,9 @@ func TestToRegionUpdatePayload(t *testing.T) { "ns1", "ns2", }, - DefaultPrefixLen: utils.Ptr(int64(22)), - MaxPrefixLen: utils.Ptr(int64(24)), - MinPrefixLen: utils.Ptr(int64(20)), + DefaultPrefixLen: new(int64(22)), + MaxPrefixLen: new(int64(24)), + MinPrefixLen: new(int64(20)), }, }, }, @@ -662,20 +661,20 @@ func TestUpdateNetworkRanges(t *testing.T) { getAllNetworkRangesResp := iaas.NetworkRangeListResponse{ Items: &[]iaas.NetworkRange{ { - Prefix: utils.Ptr("pr-1"), - Id: utils.Ptr(testRangeId1), + Prefix: new("pr-1"), + Id: new(testRangeId1), }, { - Prefix: utils.Ptr("pr-2"), - Id: utils.Ptr(testRangeId2), + Prefix: new("pr-2"), + Id: new(testRangeId2), }, { - Prefix: utils.Ptr("pr-3"), - Id: utils.Ptr(testRangeId3), + Prefix: new("pr-3"), + Id: new(testRangeId3), }, { - Prefix: utils.Ptr("pr-2"), - Id: utils.Ptr(testRangeId2Repeated), + Prefix: new("pr-2"), + Id: new(testRangeId2Repeated), }, }, } @@ -1026,8 +1025,8 @@ func TestUpdateNetworkRanges(t *testing.T) { } resp := iaas.NetworkRange{ - Prefix: utils.Ptr("prefix"), - Id: utils.Ptr("id-range"), + Prefix: new("prefix"), + Id: new("id-range"), } respBytes, err := json.Marshal(resp) if err != nil { diff --git a/stackit/internal/services/iaas/networkarearegion/resource.go b/stackit/internal/services/iaas/networkarearegion/resource.go index 8171fadfc..b8055aee4 100644 --- a/stackit/internal/services/iaas/networkarearegion/resource.go +++ b/stackit/internal/services/iaas/networkarearegion/resource.go @@ -10,8 +10,6 @@ import ( "github.com/stackitcloud/stackit-sdk-go/services/resourcemanager" resourcemanagerUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/resourcemanager/utils" - sdkUtils "github.com/stackitcloud/stackit-sdk-go/core/utils" - "github.com/hashicorp/terraform-plugin-framework-validators/int64validator" "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator" "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64default" @@ -715,7 +713,7 @@ func updateIpv4NetworkRanges(ctx context.Context, organizationId, networkAreaId payload := iaas.CreateNetworkAreaRangePayload{ Ipv4: &[]iaas.NetworkRange{ { - Prefix: sdkUtils.Ptr(prefix), + Prefix: new(prefix), }, }, } diff --git a/stackit/internal/services/iaas/networkarearegion/resource_test.go b/stackit/internal/services/iaas/networkarearegion/resource_test.go index 34038a717..e7d669fd8 100644 --- a/stackit/internal/services/iaas/networkarearegion/resource_test.go +++ b/stackit/internal/services/iaas/networkarearegion/resource_test.go @@ -16,7 +16,6 @@ import ( "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/iaas" ) @@ -63,18 +62,18 @@ func Test_mapFields(t *testing.T) { "nameserver1", "nameserver2", }, - TransferNetwork: utils.Ptr("network"), - DefaultPrefixLen: utils.Ptr(int64(20)), - MaxPrefixLen: utils.Ptr(int64(22)), - MinPrefixLen: utils.Ptr(int64(18)), + TransferNetwork: new("network"), + DefaultPrefixLen: new(int64(20)), + MaxPrefixLen: new(int64(22)), + MinPrefixLen: new(int64(18)), NetworkRanges: &[]iaas.NetworkRange{ { - Id: utils.Ptr(networkRangeId1), - Prefix: utils.Ptr("prefix-1"), + Id: new(networkRangeId1), + Prefix: new("prefix-1"), }, { - Id: utils.Ptr(networkRangeId2), - Prefix: utils.Ptr("prefix-2"), + Id: new(networkRangeId2), + Prefix: new("prefix-2"), }, }, }, @@ -218,16 +217,16 @@ func Test_toCreatePayload(t *testing.T) { }, NetworkRanges: &[]iaas.NetworkRange{ { - Prefix: utils.Ptr("pr-1"), + Prefix: new("pr-1"), }, { - Prefix: utils.Ptr("pr-2"), + Prefix: new("pr-2"), }, }, - TransferNetwork: utils.Ptr("network"), - DefaultPrefixLen: utils.Ptr(int64(20)), - MaxPrefixLen: utils.Ptr(int64(22)), - MinPrefixLen: utils.Ptr(int64(18)), + TransferNetwork: new("network"), + DefaultPrefixLen: new(int64(20)), + MaxPrefixLen: new(int64(22)), + MinPrefixLen: new(int64(18)), }, }, }, @@ -286,9 +285,9 @@ func Test_toUpdatePayload(t *testing.T) { "ns1", "ns2", }, - DefaultPrefixLen: utils.Ptr(int64(22)), - MaxPrefixLen: utils.Ptr(int64(24)), - MinPrefixLen: utils.Ptr(int64(20)), + DefaultPrefixLen: new(int64(22)), + MaxPrefixLen: new(int64(24)), + MinPrefixLen: new(int64(20)), }, }, }, @@ -349,16 +348,16 @@ func Test_mapIpv4NetworkRanges(t *testing.T) { }, networkAreaRangesList: &[]iaas.NetworkRange{ { - Id: utils.Ptr(networkRangeId2), - Prefix: utils.Ptr("prefix-2"), + Id: new(networkRangeId2), + Prefix: new("prefix-2"), }, { - Id: utils.Ptr(networkRangeId3), - Prefix: utils.Ptr("prefix-3"), + Id: new(networkRangeId3), + Prefix: new("prefix-3"), }, { - Id: utils.Ptr(networkRangeId1), - Prefix: utils.Ptr("prefix-1"), + Id: new(networkRangeId1), + Prefix: new("prefix-1"), }, }, }, @@ -407,12 +406,12 @@ func Test_mapIpv4NetworkRanges(t *testing.T) { }, networkAreaRangesList: &[]iaas.NetworkRange{ { - Id: utils.Ptr(networkRangeId2), - Prefix: utils.Ptr("prefix-2"), + Id: new(networkRangeId2), + Prefix: new("prefix-2"), }, { - Id: utils.Ptr(networkRangeId3), - Prefix: utils.Ptr("prefix-3"), + Id: new(networkRangeId3), + Prefix: new("prefix-3"), }, }, }, @@ -453,20 +452,20 @@ func Test_updateIpv4NetworkRanges(t *testing.T) { getAllNetworkRangesResp := iaas.NetworkRangeListResponse{ Items: &[]iaas.NetworkRange{ { - Prefix: utils.Ptr("pr-1"), - Id: utils.Ptr(networkRangeId1), + Prefix: new("pr-1"), + Id: new(networkRangeId1), }, { - Prefix: utils.Ptr("pr-2"), - Id: utils.Ptr(networkRangeId2), + Prefix: new("pr-2"), + Id: new(networkRangeId2), }, { - Prefix: utils.Ptr("pr-3"), - Id: utils.Ptr(networkRangeId3), + Prefix: new("pr-3"), + Id: new(networkRangeId3), }, { - Prefix: utils.Ptr("pr-2"), - Id: utils.Ptr(networkRangeId2Repeated), + Prefix: new("pr-2"), + Id: new(networkRangeId2Repeated), }, }, } @@ -845,8 +844,8 @@ func Test_updateIpv4NetworkRanges(t *testing.T) { } resp := iaas.NetworkRange{ - Prefix: utils.Ptr("prefix"), - Id: utils.Ptr("id-range"), + Prefix: new("prefix"), + Id: new("id-range"), } respBytes, err := json.Marshal(resp) if err != nil { @@ -1020,10 +1019,10 @@ func Test_toNetworkRangesPayload(t *testing.T) { }, want: &[]iaas.NetworkRange{ { - Prefix: utils.Ptr("prefix-1"), + Prefix: new("prefix-1"), }, { - Prefix: utils.Ptr("prefix-2"), + Prefix: new("prefix-2"), }, }, }, diff --git a/stackit/internal/services/iaas/networkarearoute/resource.go b/stackit/internal/services/iaas/networkarearoute/resource.go index 3694312ec..41d0b9d7e 100644 --- a/stackit/internal/services/iaas/networkarearoute/resource.go +++ b/stackit/internal/services/iaas/networkarearoute/resource.go @@ -6,8 +6,6 @@ import ( "net/http" "strings" - sdkUtils "github.com/stackitcloud/stackit-sdk-go/core/utils" - "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils" iaasUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/iaas/utils" @@ -653,13 +651,13 @@ func toNextHopPayload(model *ModelV1) (*iaas.RouteNexthop, error) { switch model.NextHop.Type.ValueString() { case "blackhole": - return sdkUtils.Ptr(iaas.NexthopBlackholeAsRouteNexthop(iaas.NewNexthopBlackhole("blackhole"))), nil + return new(iaas.NexthopBlackholeAsRouteNexthop(iaas.NewNexthopBlackhole("blackhole"))), nil case "internet": - return sdkUtils.Ptr(iaas.NexthopInternetAsRouteNexthop(iaas.NewNexthopInternet("internet"))), nil + return new(iaas.NexthopInternetAsRouteNexthop(iaas.NewNexthopInternet("internet"))), nil case "ipv4": - return sdkUtils.Ptr(iaas.NexthopIPv4AsRouteNexthop(iaas.NewNexthopIPv4("ipv4", model.NextHop.Value.ValueString()))), nil + return new(iaas.NexthopIPv4AsRouteNexthop(iaas.NewNexthopIPv4("ipv4", model.NextHop.Value.ValueString()))), nil case "ipv6": - return sdkUtils.Ptr(iaas.NexthopIPv6AsRouteNexthop(iaas.NewNexthopIPv6("ipv6", model.NextHop.Value.ValueString()))), nil + return new(iaas.NexthopIPv6AsRouteNexthop(iaas.NewNexthopIPv6("ipv6", model.NextHop.Value.ValueString()))), nil } return nil, fmt.Errorf("unknown nexthop type: %s", model.NextHop.Type.ValueString()) } @@ -673,9 +671,9 @@ func toDestinationPayload(model *ModelV1) (*iaas.RouteDestination, error) { switch model.Destination.Type.ValueString() { case "cidrv4": - return sdkUtils.Ptr(iaas.DestinationCIDRv4AsRouteDestination(iaas.NewDestinationCIDRv4("cidrv4", model.Destination.Value.ValueString()))), nil + return new(iaas.DestinationCIDRv4AsRouteDestination(iaas.NewDestinationCIDRv4("cidrv4", model.Destination.Value.ValueString()))), nil case "cidrv6": - return sdkUtils.Ptr(iaas.DestinationCIDRv6AsRouteDestination(iaas.NewDestinationCIDRv6("cidrv6", model.Destination.Value.ValueString()))), nil + return new(iaas.DestinationCIDRv6AsRouteDestination(iaas.NewDestinationCIDRv6("cidrv6", model.Destination.Value.ValueString()))), nil } return nil, fmt.Errorf("unknown destination type: %s", model.Destination.Type.ValueString()) } diff --git a/stackit/internal/services/iaas/networkarearoute/resource_test.go b/stackit/internal/services/iaas/networkarearoute/resource_test.go index a0295cf3c..b28ba8814 100644 --- a/stackit/internal/services/iaas/networkarearoute/resource_test.go +++ b/stackit/internal/services/iaas/networkarearoute/resource_test.go @@ -5,8 +5,6 @@ import ( "reflect" "testing" - "github.com/stackitcloud/stackit-sdk-go/core/utils" - "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" @@ -66,18 +64,18 @@ func TestMapFields(t *testing.T) { input: &iaas.Route{ Destination: &iaas.RouteDestination{ DestinationCIDRv4: &iaas.DestinationCIDRv4{ - Type: utils.Ptr("cidrv4"), - Value: utils.Ptr("prefix"), + Type: new("cidrv4"), + Value: new("prefix"), }, DestinationCIDRv6: nil, }, Nexthop: &iaas.RouteNexthop{ NexthopIPv4: &iaas.NexthopIPv4{ - Type: utils.Ptr("ipv4"), - Value: utils.Ptr("hop"), + Type: new("ipv4"), + Value: new("hop"), }, }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, }, @@ -172,18 +170,18 @@ func TestToCreatePayload(t *testing.T) { { Destination: &iaas.RouteDestination{ DestinationCIDRv4: &iaas.DestinationCIDRv4{ - Type: utils.Ptr("cidrv4"), - Value: utils.Ptr("prefix"), + Type: new("cidrv4"), + Value: new("prefix"), }, DestinationCIDRv6: nil, }, Nexthop: &iaas.RouteNexthop{ NexthopIPv4: &iaas.NexthopIPv4{ - Type: utils.Ptr("ipv4"), - Value: utils.Ptr("hop"), + Type: new("ipv4"), + Value: new("hop"), }, }, - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, }, @@ -227,7 +225,7 @@ func TestToUpdatePayload(t *testing.T) { }), }, &iaas.UpdateNetworkAreaRoutePayload{ - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key1": "value1", "key2": "value2", }, @@ -276,8 +274,8 @@ func TestToNextHopPayload(t *testing.T) { }, want: &iaas.RouteNexthop{ NexthopIPv4: &iaas.NexthopIPv4{ - Type: utils.Ptr("ipv4"), - Value: utils.Ptr("10.20.30.40"), + Type: new("ipv4"), + Value: new("10.20.30.40"), }, }, wantErr: false, @@ -294,8 +292,8 @@ func TestToNextHopPayload(t *testing.T) { }, want: &iaas.RouteNexthop{ NexthopIPv6: &iaas.NexthopIPv6{ - Type: utils.Ptr("ipv6"), - Value: utils.Ptr("2001:db8:85a3:0:0:8a2e:370:7334"), + Type: new("ipv6"), + Value: new("2001:db8:85a3:0:0:8a2e:370:7334"), }, }, wantErr: false, @@ -311,7 +309,7 @@ func TestToNextHopPayload(t *testing.T) { }, want: &iaas.RouteNexthop{ NexthopInternet: &iaas.NexthopInternet{ - Type: utils.Ptr("internet"), + Type: new("internet"), }, }, wantErr: false, @@ -327,7 +325,7 @@ func TestToNextHopPayload(t *testing.T) { }, want: &iaas.RouteNexthop{ NexthopBlackhole: &iaas.NexthopBlackhole{ - Type: utils.Ptr("blackhole"), + Type: new("blackhole"), }, }, wantErr: false, @@ -396,8 +394,8 @@ func TestToDestinationPayload(t *testing.T) { }, want: &iaas.RouteDestination{ DestinationCIDRv4: &iaas.DestinationCIDRv4{ - Type: utils.Ptr("cidrv4"), - Value: utils.Ptr("192.168.1.0/24"), + Type: new("cidrv4"), + Value: new("192.168.1.0/24"), }, }, wantErr: false, @@ -414,8 +412,8 @@ func TestToDestinationPayload(t *testing.T) { }, want: &iaas.RouteDestination{ DestinationCIDRv6: &iaas.DestinationCIDRv6{ - Type: utils.Ptr("cidrv6"), - Value: utils.Ptr("2001:db8:1234::/48"), + Type: new("cidrv6"), + Value: new("2001:db8:1234::/48"), }, }, wantErr: false, @@ -478,8 +476,8 @@ func TestMapRouteNextHop(t *testing.T) { routeResp: &iaas.Route{ Nexthop: &iaas.RouteNexthop{ NexthopIPv4: &iaas.NexthopIPv4{ - Type: utils.Ptr("ipv4"), - Value: utils.Ptr("192.168.1.0/24"), + Type: new("ipv4"), + Value: new("192.168.1.0/24"), }, }, }, @@ -495,8 +493,8 @@ func TestMapRouteNextHop(t *testing.T) { routeResp: &iaas.Route{ Nexthop: &iaas.RouteNexthop{ NexthopIPv4: &iaas.NexthopIPv4{ - Type: utils.Ptr("ipv6"), - Value: utils.Ptr("2001:db8:85a3:0:0:8a2e:370:7334"), + Type: new("ipv6"), + Value: new("2001:db8:85a3:0:0:8a2e:370:7334"), }, }, }, @@ -512,7 +510,7 @@ func TestMapRouteNextHop(t *testing.T) { routeResp: &iaas.Route{ Nexthop: &iaas.RouteNexthop{ NexthopBlackhole: &iaas.NexthopBlackhole{ - Type: utils.Ptr("blackhole"), + Type: new("blackhole"), }, }, }, @@ -527,7 +525,7 @@ func TestMapRouteNextHop(t *testing.T) { routeResp: &iaas.Route{ Nexthop: &iaas.RouteNexthop{ NexthopInternet: &iaas.NexthopInternet{ - Type: utils.Ptr("internet"), + Type: new("internet"), }, }, }, @@ -567,8 +565,8 @@ func TestMapRouteDestination(t *testing.T) { routeResp: &iaas.Route{ Destination: &iaas.RouteDestination{ DestinationCIDRv4: &iaas.DestinationCIDRv4{ - Type: utils.Ptr("cidrv4"), - Value: utils.Ptr("192.168.1.0/24"), + Type: new("cidrv4"), + Value: new("192.168.1.0/24"), }, }, }, @@ -584,8 +582,8 @@ func TestMapRouteDestination(t *testing.T) { routeResp: &iaas.Route{ Destination: &iaas.RouteDestination{ DestinationCIDRv4: &iaas.DestinationCIDRv4{ - Type: utils.Ptr("cidrv6"), - Value: utils.Ptr("2001:db8:1234::/48"), + Type: new("cidrv6"), + Value: new("2001:db8:1234::/48"), }, }, }, diff --git a/stackit/internal/services/iaas/networkinterface/resource.go b/stackit/internal/services/iaas/networkinterface/resource.go index 007e17f0c..a050174e4 100644 --- a/stackit/internal/services/iaas/networkinterface/resource.go +++ b/stackit/internal/services/iaas/networkinterface/resource.go @@ -585,7 +585,7 @@ func toCreatePayload(ctx context.Context, model *Model) (*iaas.CreateNicPayload, return nil, fmt.Errorf("nil model") } - var labelPayload *map[string]interface{} + var labelPayload *map[string]any modelSecurityGroups := []string{} if !(model.SecurityGroupIds.IsNull() || model.SecurityGroupIds.IsUnknown()) { @@ -640,7 +640,7 @@ func toUpdatePayload(ctx context.Context, model *Model, currentLabels types.Map) return nil, fmt.Errorf("nil model") } - var labelPayload *map[string]interface{} + var labelPayload *map[string]any modelSecurityGroups := []string{} for _, ns := range model.SecurityGroupIds.Elements() { diff --git a/stackit/internal/services/iaas/networkinterface/resource_test.go b/stackit/internal/services/iaas/networkinterface/resource_test.go index e549f7d3a..ffa01b210 100644 --- a/stackit/internal/services/iaas/networkinterface/resource_test.go +++ b/stackit/internal/services/iaas/networkinterface/resource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/iaas" ) @@ -32,7 +31,7 @@ func TestMapFields(t *testing.T) { NetworkInterfaceId: types.StringValue("nicid"), }, input: &iaas.NIC{ - Id: utils.Ptr("nicid"), + Id: new("nicid"), }, region: "eu01", }, @@ -64,25 +63,25 @@ func TestMapFields(t *testing.T) { Region: types.StringValue("eu01"), }, input: &iaas.NIC{ - Id: utils.Ptr("nicid"), - Name: utils.Ptr("name"), + Id: new("nicid"), + Name: new("name"), AllowedAddresses: &[]iaas.AllowedAddressesInner{ { - String: utils.Ptr("aa1"), + String: new("aa1"), }, }, SecurityGroups: &[]string{ "prefix1", "prefix2", }, - Ipv4: utils.Ptr("ipv4"), - Ipv6: utils.Ptr("ipv6"), - NicSecurity: utils.Ptr(true), - Device: utils.Ptr("device"), - Mac: utils.Ptr("mac"), - Status: utils.Ptr("status"), - Type: utils.Ptr("type"), - Labels: &map[string]interface{}{ + Ipv4: new("ipv4"), + Ipv6: new("ipv6"), + NicSecurity: new(true), + Device: new("device"), + Mac: new("mac"), + Status: new("status"), + Type: new("type"), + Labels: &map[string]any{ "label1": "ref1", }, }, @@ -123,10 +122,10 @@ func TestMapFields(t *testing.T) { }), }, input: &iaas.NIC{ - Id: utils.Ptr("nicid"), + Id: new("nicid"), AllowedAddresses: &[]iaas.AllowedAddressesInner{ { - String: utils.Ptr("aa2"), + String: new("aa2"), }, }, }, @@ -157,7 +156,7 @@ func TestMapFields(t *testing.T) { AllowedAddresses: types.ListValueMust(types.StringType, []attr.Value{}), }, input: &iaas.NIC{ - Id: utils.Ptr("nicid"), + Id: new("nicid"), AllowedAddresses: nil, }, region: "eu01", @@ -236,17 +235,17 @@ func TestToCreatePayload(t *testing.T) { Security: types.BoolValue(true), }, &iaas.CreateNicPayload{ - Name: utils.Ptr("name"), + Name: new("name"), SecurityGroups: &[]string{ "sg1", "sg2", }, AllowedAddresses: &[]iaas.AllowedAddressesInner{ { - String: utils.Ptr("aa1"), + String: new("aa1"), }, }, - NicSecurity: utils.Ptr(true), + NicSecurity: new(true), }, true, }, @@ -262,7 +261,7 @@ func TestToCreatePayload(t *testing.T) { AllowedAddresses: types.ListNull(types.StringType), }, &iaas.CreateNicPayload{ - Name: utils.Ptr("name"), + Name: new("name"), SecurityGroups: &[]string{ "sg1", "sg2", @@ -312,17 +311,17 @@ func TestToUpdatePayload(t *testing.T) { Security: types.BoolValue(true), }, &iaas.UpdateNicPayload{ - Name: utils.Ptr("name"), + Name: new("name"), SecurityGroups: &[]string{ "sg1", "sg2", }, AllowedAddresses: &[]iaas.AllowedAddressesInner{ { - String: utils.Ptr("aa1"), + String: new("aa1"), }, }, - NicSecurity: utils.Ptr(true), + NicSecurity: new(true), }, true, }, @@ -338,12 +337,12 @@ func TestToUpdatePayload(t *testing.T) { AllowedAddresses: types.ListNull(types.StringType), }, &iaas.UpdateNicPayload{ - Name: utils.Ptr("name"), + Name: new("name"), SecurityGroups: &[]string{ "sg1", "sg2", }, - AllowedAddresses: utils.Ptr([]iaas.AllowedAddressesInner{}), + AllowedAddresses: new([]iaas.AllowedAddressesInner{}), }, true, }, diff --git a/stackit/internal/services/iaas/networkinterfaceattach/resource.go b/stackit/internal/services/iaas/networkinterfaceattach/resource.go index 7c7f8c04b..aa06b50a5 100644 --- a/stackit/internal/services/iaas/networkinterfaceattach/resource.go +++ b/stackit/internal/services/iaas/networkinterfaceattach/resource.go @@ -317,7 +317,7 @@ func (r *networkInterfaceAttachResource) ImportState(ctx context.Context, req re return } - ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]interface{}{ + ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{ "project_id": idParts[0], "region": idParts[1], "server_id": idParts[2], diff --git a/stackit/internal/services/iaas/project/datasource_test.go b/stackit/internal/services/iaas/project/datasource_test.go index d2e574893..cfaec9a61 100644 --- a/stackit/internal/services/iaas/project/datasource_test.go +++ b/stackit/internal/services/iaas/project/datasource_test.go @@ -48,12 +48,12 @@ func TestMapDataSourceFields(t *testing.T) { ProjectId: types.StringValue(projectId), }, input: &iaas.Project{ - AreaId: utils.Ptr(iaas.AreaId{String: utils.Ptr("aid")}), - CreatedAt: utils.Ptr(testTimestamp()), - InternetAccess: utils.Ptr(true), + AreaId: new(iaas.AreaId{String: new("aid")}), + CreatedAt: new(testTimestamp()), + InternetAccess: new(true), Id: utils.Ptr(projectId), - Status: utils.Ptr("CREATED"), - UpdatedAt: utils.Ptr(testTimestamp()), + Status: new("CREATED"), + UpdatedAt: new(testTimestamp()), }, expected: &DatasourceModel{ Id: types.StringValue(projectId), @@ -73,7 +73,7 @@ func TestMapDataSourceFields(t *testing.T) { ProjectId: types.StringValue(projectId), }, input: &iaas.Project{ - AreaId: utils.Ptr(iaas.AreaId{ + AreaId: new(iaas.AreaId{ StaticAreaID: iaas.STATICAREAID_PUBLIC.Ptr(), }), Id: utils.Ptr(projectId), diff --git a/stackit/internal/services/iaas/publicip/resource_test.go b/stackit/internal/services/iaas/publicip/resource_test.go index d1797897d..18fbd6b4d 100644 --- a/stackit/internal/services/iaas/publicip/resource_test.go +++ b/stackit/internal/services/iaas/publicip/resource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/iaas" ) @@ -31,7 +30,7 @@ func TestMapFields(t *testing.T) { PublicIpId: types.StringValue("pipid"), }, input: &iaas.PublicIp{ - Id: utils.Ptr("pipid"), + Id: new("pipid"), NetworkInterface: iaas.NewNullableString(nil), }, region: "eu01", @@ -56,12 +55,12 @@ func TestMapFields(t *testing.T) { Region: types.StringValue("eu01"), }, input: &iaas.PublicIp{ - Id: utils.Ptr("pipid"), - Ip: utils.Ptr("ip"), - Labels: &map[string]interface{}{ + Id: new("pipid"), + Ip: new("ip"), + Labels: &map[string]any{ "key": "value", }, - NetworkInterface: iaas.NewNullableString(utils.Ptr("interface")), + NetworkInterface: iaas.NewNullableString(new("interface")), }, region: "eu02", }, @@ -87,8 +86,8 @@ func TestMapFields(t *testing.T) { Labels: types.MapValueMust(types.StringType, map[string]attr.Value{}), }, input: &iaas.PublicIp{ - Id: utils.Ptr("pipid"), - NetworkInterface: iaas.NewNullableString(utils.Ptr("interface")), + Id: new("pipid"), + NetworkInterface: iaas.NewNullableString(new("interface")), }, region: "eu01", }, @@ -111,7 +110,7 @@ func TestMapFields(t *testing.T) { PublicIpId: types.StringValue("pipid"), }, input: &iaas.PublicIp{ - Id: utils.Ptr("pipid"), + Id: new("pipid"), }, region: "eu01", }, @@ -175,11 +174,11 @@ func TestToCreatePayload(t *testing.T) { NetworkInterfaceId: types.StringValue("interface"), }, &iaas.CreatePublicIPPayload{ - Ip: utils.Ptr("ip"), - Labels: &map[string]interface{}{ + Ip: new("ip"), + Labels: &map[string]any{ "key": "value", }, - NetworkInterface: iaas.NewNullableString(utils.Ptr("interface")), + NetworkInterface: iaas.NewNullableString(new("interface")), }, true, }, @@ -192,8 +191,8 @@ func TestToCreatePayload(t *testing.T) { }), }, &iaas.CreatePublicIPPayload{ - Ip: utils.Ptr("ip"), - Labels: &map[string]interface{}{ + Ip: new("ip"), + Labels: &map[string]any{ "key": "value", }, NetworkInterface: iaas.NewNullableString(nil), @@ -237,10 +236,10 @@ func TestToUpdatePayload(t *testing.T) { NetworkInterfaceId: types.StringValue("interface"), }, &iaas.UpdatePublicIPPayload{ - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, - NetworkInterface: iaas.NewNullableString(utils.Ptr("interface")), + NetworkInterface: iaas.NewNullableString(new("interface")), }, true, }, @@ -253,7 +252,7 @@ func TestToUpdatePayload(t *testing.T) { }), }, &iaas.UpdatePublicIPPayload{ - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, NetworkInterface: iaas.NewNullableString(nil), diff --git a/stackit/internal/services/iaas/publicipassociate/resource_test.go b/stackit/internal/services/iaas/publicipassociate/resource_test.go index f1c09f5a9..d1ef0cce3 100644 --- a/stackit/internal/services/iaas/publicipassociate/resource_test.go +++ b/stackit/internal/services/iaas/publicipassociate/resource_test.go @@ -5,7 +5,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/iaas" ) @@ -30,8 +29,8 @@ func TestMapFields(t *testing.T) { NetworkInterfaceId: types.StringValue("nicid"), }, input: &iaas.PublicIp{ - Id: utils.Ptr("pipid"), - NetworkInterface: iaas.NewNullableString(utils.Ptr("nicid")), + Id: new("pipid"), + NetworkInterface: iaas.NewNullableString(new("nicid")), }, region: "eu01", }, @@ -54,9 +53,9 @@ func TestMapFields(t *testing.T) { NetworkInterfaceId: types.StringValue("nicid"), }, input: &iaas.PublicIp{ - Id: utils.Ptr("pipid"), - Ip: utils.Ptr("ip"), - NetworkInterface: iaas.NewNullableString(utils.Ptr("nicid")), + Id: new("pipid"), + Ip: new("ip"), + NetworkInterface: iaas.NewNullableString(new("nicid")), }, region: "eu02", }, @@ -115,7 +114,7 @@ func TestToCreatePayload(t *testing.T) { NetworkInterfaceId: types.StringValue("interface"), }, &iaas.UpdatePublicIPPayload{ - NetworkInterface: iaas.NewNullableString(utils.Ptr("interface")), + NetworkInterface: iaas.NewNullableString(new("interface")), }, true, }, diff --git a/stackit/internal/services/iaas/publicipranges/datasource_test.go b/stackit/internal/services/iaas/publicipranges/datasource_test.go index 535df5f74..3dd21e8a8 100644 --- a/stackit/internal/services/iaas/publicipranges/datasource_test.go +++ b/stackit/internal/services/iaas/publicipranges/datasource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - coreUtils "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/iaas" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils" ) @@ -38,8 +37,8 @@ func TestMapPublicIpRanges(t *testing.T) { { name: "valid cidr entries", input: &[]iaas.PublicNetwork{ - {Cidr: coreUtils.Ptr("192.168.0.0/24")}, - {Cidr: coreUtils.Ptr("192.168.1.0/24")}, + {Cidr: new("192.168.0.0/24")}, + {Cidr: new("192.168.1.0/24")}, }, expected: func() Model { cidrs := []string{"192.168.0.0/24", "192.168.1.0/24"} @@ -64,9 +63,9 @@ func TestMapPublicIpRanges(t *testing.T) { { name: "filter out empty CIDRs", input: &[]iaas.PublicNetwork{ - {Cidr: coreUtils.Ptr("")}, + {Cidr: new("")}, {Cidr: nil}, - {Cidr: coreUtils.Ptr("10.0.0.0/8")}, + {Cidr: new("10.0.0.0/8")}, }, expected: func() Model { cidrs := []string{"10.0.0.0/8"} diff --git a/stackit/internal/services/iaas/routingtable/route/resource.go b/stackit/internal/services/iaas/routingtable/route/resource.go index 6324b1bce..3f5026d48 100644 --- a/stackit/internal/services/iaas/routingtable/route/resource.go +++ b/stackit/internal/services/iaas/routingtable/route/resource.go @@ -18,7 +18,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/hashicorp/terraform-plugin-log/tflog" - sdkUtils "github.com/stackitcloud/stackit-sdk-go/core/utils" "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" @@ -535,13 +534,13 @@ func toNextHopPayload(ctx context.Context, model *shared.RouteReadModel) (*iaas. switch nexthopModel.Type.ValueString() { case "blackhole": - return sdkUtils.Ptr(iaas.NexthopBlackholeAsRouteNexthop(iaas.NewNexthopBlackhole("blackhole"))), nil + return new(iaas.NexthopBlackholeAsRouteNexthop(iaas.NewNexthopBlackhole("blackhole"))), nil case "internet": - return sdkUtils.Ptr(iaas.NexthopInternetAsRouteNexthop(iaas.NewNexthopInternet("internet"))), nil + return new(iaas.NexthopInternetAsRouteNexthop(iaas.NewNexthopInternet("internet"))), nil case "ipv4": - return sdkUtils.Ptr(iaas.NexthopIPv4AsRouteNexthop(iaas.NewNexthopIPv4("ipv4", nexthopModel.Value.ValueString()))), nil + return new(iaas.NexthopIPv4AsRouteNexthop(iaas.NewNexthopIPv4("ipv4", nexthopModel.Value.ValueString()))), nil case "ipv6": - return sdkUtils.Ptr(iaas.NexthopIPv6AsRouteNexthop(iaas.NewNexthopIPv6("ipv6", nexthopModel.Value.ValueString()))), nil + return new(iaas.NexthopIPv6AsRouteNexthop(iaas.NewNexthopIPv6("ipv6", nexthopModel.Value.ValueString()))), nil } return nil, fmt.Errorf("unknown nexthop type: %s", nexthopModel.Type.ValueString()) } @@ -562,9 +561,9 @@ func toDestinationPayload(ctx context.Context, model *shared.RouteReadModel) (*i switch destinationModel.Type.ValueString() { case "cidrv4": - return sdkUtils.Ptr(iaas.DestinationCIDRv4AsRouteDestination(iaas.NewDestinationCIDRv4("cidrv4", destinationModel.Value.ValueString()))), nil + return new(iaas.DestinationCIDRv4AsRouteDestination(iaas.NewDestinationCIDRv4("cidrv4", destinationModel.Value.ValueString()))), nil case "cidrv6": - return sdkUtils.Ptr(iaas.DestinationCIDRv6AsRouteDestination(iaas.NewDestinationCIDRv6("cidrv6", destinationModel.Value.ValueString()))), nil + return new(iaas.DestinationCIDRv6AsRouteDestination(iaas.NewDestinationCIDRv6("cidrv6", destinationModel.Value.ValueString()))), nil } return nil, fmt.Errorf("unknown destination type: %s", destinationModel.Type.ValueString()) } diff --git a/stackit/internal/services/iaas/routingtable/route/resource_test.go b/stackit/internal/services/iaas/routingtable/route/resource_test.go index fa0948198..2ef931fb1 100644 --- a/stackit/internal/services/iaas/routingtable/route/resource_test.go +++ b/stackit/internal/services/iaas/routingtable/route/resource_test.go @@ -13,7 +13,6 @@ import ( "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" ) const ( @@ -84,10 +83,10 @@ func Test_mapFieldsFromList(t *testing.T) { routeResp: &iaas.RouteListResponse{ Items: &[]iaas.Route{ { - Id: utils.Ptr(uuid.NewString()), + Id: new(uuid.NewString()), }, { - Id: utils.Ptr(uuid.NewString()), + Id: new(uuid.NewString()), }, }, }, @@ -108,14 +107,14 @@ func Test_mapFieldsFromList(t *testing.T) { routeResp: &iaas.RouteListResponse{ Items: &[]iaas.Route{ { - Id: utils.Ptr(routeId.String()), - Destination: utils.Ptr(iaas.DestinationCIDRv4AsRouteDestination( + Id: new(routeId.String()), + Destination: new(iaas.DestinationCIDRv4AsRouteDestination( iaas.NewDestinationCIDRv4("cidrv4", "58.251.236.138/32"), )), - Nexthop: utils.Ptr(iaas.NexthopIPv4AsRouteNexthop( + Nexthop: new(iaas.NexthopIPv4AsRouteNexthop( iaas.NewNexthopIPv4("ipv4", "10.20.42.2"), )), - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "foo": "bar", }, CreatedAt: nil, @@ -202,7 +201,7 @@ func Test_toUpdatePayload(t *testing.T) { }), }, want: &iaas.UpdateRouteOfRoutingTablePayload{ - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "foo1": "bar1", "foo2": "bar2", "foo3": nil, @@ -254,7 +253,7 @@ func Test_toNextHopPayload(t *testing.T) { }, }, wantErr: false, - want: utils.Ptr(iaas.NexthopIPv4AsRouteNexthop( + want: new(iaas.NexthopIPv4AsRouteNexthop( iaas.NewNexthopIPv4("ipv4", "10.20.42.2"), )), }, @@ -269,7 +268,7 @@ func Test_toNextHopPayload(t *testing.T) { }, }, wantErr: false, - want: utils.Ptr(iaas.NexthopIPv6AsRouteNexthop( + want: new(iaas.NexthopIPv6AsRouteNexthop( iaas.NewNexthopIPv6("ipv6", "172b:f881:46fe:d89a:9332:90f7:3485:236d"), )), }, @@ -284,7 +283,7 @@ func Test_toNextHopPayload(t *testing.T) { }, }, wantErr: false, - want: utils.Ptr(iaas.NexthopInternetAsRouteNexthop( + want: new(iaas.NexthopInternetAsRouteNexthop( iaas.NewNexthopInternet("internet"), )), }, @@ -299,7 +298,7 @@ func Test_toNextHopPayload(t *testing.T) { }, }, wantErr: false, - want: utils.Ptr(iaas.NexthopBlackholeAsRouteNexthop( + want: new(iaas.NexthopBlackholeAsRouteNexthop( iaas.NewNexthopBlackhole("blackhole"), )), }, @@ -347,7 +346,7 @@ func Test_toDestinationPayload(t *testing.T) { }, }, wantErr: false, - want: utils.Ptr(iaas.DestinationCIDRv4AsRouteDestination( + want: new(iaas.DestinationCIDRv4AsRouteDestination( iaas.NewDestinationCIDRv4("cidrv4", "58.251.236.138/32"), )), }, @@ -362,7 +361,7 @@ func Test_toDestinationPayload(t *testing.T) { }, }, wantErr: false, - want: utils.Ptr(iaas.DestinationCIDRv6AsRouteDestination( + want: new(iaas.DestinationCIDRv6AsRouteDestination( iaas.NewDestinationCIDRv6("cidrv6", "2001:0db8:3c4d:1a2b::/64"), )), }, @@ -420,14 +419,14 @@ func Test_toCreatePayload(t *testing.T) { want: &iaas.AddRoutesToRoutingTablePayload{ Items: &[]iaas.Route{ { - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "foo1": "bar1", "foo2": "bar2", }, - Nexthop: utils.Ptr(iaas.NexthopIPv4AsRouteNexthop( + Nexthop: new(iaas.NexthopIPv4AsRouteNexthop( iaas.NewNexthopIPv4("ipv4", "10.20.42.2"), )), - Destination: utils.Ptr(iaas.DestinationCIDRv4AsRouteDestination( + Destination: new(iaas.DestinationCIDRv4AsRouteDestination( iaas.NewDestinationCIDRv4("cidrv4", "58.251.236.138/32"), )), }, diff --git a/stackit/internal/services/iaas/routingtable/routes/datasource_test.go b/stackit/internal/services/iaas/routingtable/routes/datasource_test.go index df752972a..f61051cf1 100644 --- a/stackit/internal/services/iaas/routingtable/routes/datasource_test.go +++ b/stackit/internal/services/iaas/routingtable/routes/datasource_test.go @@ -12,7 +12,6 @@ import ( "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" ) const ( @@ -105,28 +104,28 @@ func Test_mapDataSourceRoutingTableRoutes(t *testing.T) { routes: &iaas.RouteListResponse{ Items: &[]iaas.Route{ { - Id: utils.Ptr(testRouteId1), - Destination: utils.Ptr(iaas.DestinationCIDRv4AsRouteDestination( + Id: new(testRouteId1), + Destination: new(iaas.DestinationCIDRv4AsRouteDestination( iaas.NewDestinationCIDRv4("cidrv4", "58.251.236.138/32"), )), - Nexthop: utils.Ptr(iaas.NexthopIPv4AsRouteNexthop( + Nexthop: new(iaas.NexthopIPv4AsRouteNexthop( iaas.NewNexthopIPv4("ipv4", "10.20.42.2"), )), - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "foo": "bar", }, CreatedAt: nil, UpdatedAt: nil, }, { - Id: utils.Ptr(testRouteId2), - Destination: utils.Ptr(iaas.DestinationCIDRv6AsRouteDestination( + Id: new(testRouteId2), + Destination: new(iaas.DestinationCIDRv6AsRouteDestination( iaas.NewDestinationCIDRv6("cidrv6", "2001:0db8:3c4d:1a2b::/64"), )), - Nexthop: utils.Ptr(iaas.NexthopIPv6AsRouteNexthop( + Nexthop: new(iaas.NexthopIPv6AsRouteNexthop( iaas.NewNexthopIPv6("ipv6", "172b:f881:46fe:d89a:9332:90f7:3485:236d"), )), - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "key": "value", }, CreatedAt: nil, diff --git a/stackit/internal/services/iaas/routingtable/shared/route_test.go b/stackit/internal/services/iaas/routingtable/shared/route_test.go index aafbe1c52..ac19925a9 100644 --- a/stackit/internal/services/iaas/routingtable/shared/route_test.go +++ b/stackit/internal/services/iaas/routingtable/shared/route_test.go @@ -10,7 +10,6 @@ import ( "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/iaas" ) @@ -58,7 +57,7 @@ func Test_MapRouteNextHop(t *testing.T) { name: "nexthop ipv4", args: args{ routeResp: &iaas.Route{ - Nexthop: utils.Ptr(iaas.NexthopIPv4AsRouteNexthop( + Nexthop: new(iaas.NexthopIPv4AsRouteNexthop( iaas.NewNexthopIPv4("ipv4", "10.20.42.2"), )), }, @@ -73,7 +72,7 @@ func Test_MapRouteNextHop(t *testing.T) { name: "nexthop ipv6", args: args{ routeResp: &iaas.Route{ - Nexthop: utils.Ptr(iaas.NexthopIPv6AsRouteNexthop( + Nexthop: new(iaas.NexthopIPv6AsRouteNexthop( iaas.NewNexthopIPv6("ipv6", "172b:f881:46fe:d89a:9332:90f7:3485:236d"), )), }, @@ -88,7 +87,7 @@ func Test_MapRouteNextHop(t *testing.T) { name: "nexthop internet", args: args{ routeResp: &iaas.Route{ - Nexthop: utils.Ptr(iaas.NexthopInternetAsRouteNexthop( + Nexthop: new(iaas.NexthopInternetAsRouteNexthop( iaas.NewNexthopInternet("internet"), )), }, @@ -103,7 +102,7 @@ func Test_MapRouteNextHop(t *testing.T) { name: "nexthop blackhole", args: args{ routeResp: &iaas.Route{ - Nexthop: utils.Ptr(iaas.NexthopBlackholeAsRouteNexthop( + Nexthop: new(iaas.NexthopBlackholeAsRouteNexthop( iaas.NewNexthopBlackhole("blackhole"), )), }, @@ -164,7 +163,7 @@ func Test_MapRouteDestination(t *testing.T) { name: "destination cidrv4", args: args{ routeResp: &iaas.Route{ - Destination: utils.Ptr(iaas.DestinationCIDRv4AsRouteDestination( + Destination: new(iaas.DestinationCIDRv4AsRouteDestination( iaas.NewDestinationCIDRv4("cidrv4", "58.251.236.138/32"), )), }, @@ -179,7 +178,7 @@ func Test_MapRouteDestination(t *testing.T) { name: "destination cidrv6", args: args{ routeResp: &iaas.Route{ - Destination: utils.Ptr(iaas.DestinationCIDRv6AsRouteDestination( + Destination: new(iaas.DestinationCIDRv6AsRouteDestination( iaas.NewDestinationCIDRv6("cidrv6", "2001:0db8:3c4d:1a2b::/64"), )), }, @@ -249,15 +248,15 @@ func TestMapRouteModel(t *testing.T) { RoutingTableId: types.StringValue(testRoutingTableId.String()), }, route: &iaas.Route{ - Id: utils.Ptr(testRouteId.String()), - Destination: utils.Ptr(iaas.DestinationCIDRv4AsRouteDestination( + Id: new(testRouteId.String()), + Destination: new(iaas.DestinationCIDRv4AsRouteDestination( iaas.NewDestinationCIDRv4("cidrv4", "58.251.236.138/32"), )), - Labels: &map[string]interface{}{ + Labels: &map[string]any{ "foo1": "bar1", "foo2": "bar2", }, - Nexthop: utils.Ptr( + Nexthop: new( iaas.NexthopIPv4AsRouteNexthop(iaas.NewNexthopIPv4("ipv4", "10.20.42.2")), ), CreatedAt: &createdAt, diff --git a/stackit/internal/services/iaas/routingtable/table/datasource_test.go b/stackit/internal/services/iaas/routingtable/table/datasource_test.go index 3979e6f12..13a42fe9b 100644 --- a/stackit/internal/services/iaas/routingtable/table/datasource_test.go +++ b/stackit/internal/services/iaas/routingtable/table/datasource_test.go @@ -12,7 +12,6 @@ import ( "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" ) const ( @@ -42,8 +41,8 @@ func Test_mapDatasourceFields(t *testing.T) { NetworkAreaId: types.StringValue(networkAreaId.String()), }, &iaas.RoutingTable{ - Id: utils.Ptr(routingTableId.String()), - Name: utils.Ptr("default_values"), + Id: new(routingTableId.String()), + Name: new("default_values"), }, shared.RoutingTableDataSourceModel{ Id: types.StringValue(id), @@ -66,10 +65,10 @@ func Test_mapDatasourceFields(t *testing.T) { RoutingTableReadModel: shared.RoutingTableReadModel{}, }, &iaas.RoutingTable{ - Id: utils.Ptr(routingTableId.String()), - Name: utils.Ptr("values_ok"), - Description: utils.Ptr("Description"), - Labels: &map[string]interface{}{ + Id: new(routingTableId.String()), + Name: new("values_ok"), + Description: new("Description"), + Labels: &map[string]any{ "key": "value", }, }, diff --git a/stackit/internal/services/iaas/routingtable/table/resource_test.go b/stackit/internal/services/iaas/routingtable/table/resource_test.go index 2da1d999f..8dd81edc4 100644 --- a/stackit/internal/services/iaas/routingtable/table/resource_test.go +++ b/stackit/internal/services/iaas/routingtable/table/resource_test.go @@ -8,7 +8,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/iaas" ) @@ -29,8 +28,8 @@ func TestMapFields(t *testing.T) { NetworkAreaId: types.StringValue("aid"), }, &iaas.RoutingTable{ - Id: utils.Ptr("rtid"), - Name: utils.Ptr("default_values"), + Id: new("rtid"), + Name: new("default_values"), }, Model{ Id: types.StringValue(id), @@ -50,10 +49,10 @@ func TestMapFields(t *testing.T) { NetworkAreaId: types.StringValue("aid"), }, &iaas.RoutingTable{ - Id: utils.Ptr("rtid"), - Name: utils.Ptr("values_ok"), - Description: utils.Ptr("Description"), - Labels: &map[string]interface{}{ + Id: new("rtid"), + Name: new("values_ok"), + Description: new("Description"), + Labels: &map[string]any{ "key": "value", }, }, @@ -136,13 +135,13 @@ func TestToCreatePayload(t *testing.T) { DynamicRoutes: types.BoolValue(true), }, expected: &iaas.AddRoutingTableToAreaPayload{ - Description: utils.Ptr("Description"), - Name: utils.Ptr("default_ok"), - Labels: &map[string]interface{}{ + Description: new("Description"), + Name: new("default_ok"), + Labels: &map[string]any{ "key": "value", }, - SystemRoutes: utils.Ptr(true), - DynamicRoutes: utils.Ptr(true), + SystemRoutes: new(true), + DynamicRoutes: new(true), }, isValid: true, }, @@ -186,14 +185,14 @@ func TestToUpdatePayload(t *testing.T) { SystemRoutes: types.BoolValue(false), }, &iaas.UpdateRoutingTableOfAreaPayload{ - Description: utils.Ptr("Description"), - Name: utils.Ptr("default_ok"), - Labels: &map[string]interface{}{ + Description: new("Description"), + Name: new("default_ok"), + Labels: &map[string]any{ "key1": "value1", "key2": "value2", }, - DynamicRoutes: utils.Ptr(false), - SystemRoutes: utils.Ptr(false), + DynamicRoutes: new(false), + SystemRoutes: new(false), }, true, }, diff --git a/stackit/internal/services/iaas/routingtable/tables/datasource_test.go b/stackit/internal/services/iaas/routingtable/tables/datasource_test.go index f89e2628d..c6929676e 100644 --- a/stackit/internal/services/iaas/routingtable/tables/datasource_test.go +++ b/stackit/internal/services/iaas/routingtable/tables/datasource_test.go @@ -13,7 +13,6 @@ import ( "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" ) const ( @@ -49,14 +48,14 @@ func TestMapDataFields(t *testing.T) { &iaas.RoutingTableListResponse{ Items: &[]iaas.RoutingTable{ { - Id: utils.Ptr(routingTableId.String()), - Name: utils.Ptr("test"), - Description: utils.Ptr("description"), - Default: utils.Ptr(true), + Id: new(routingTableId.String()), + Name: new("test"), + Description: new("description"), + Default: new(true), CreatedAt: &createdAt, UpdatedAt: &updatedAt, - SystemRoutes: utils.Ptr(false), - DynamicRoutes: utils.Ptr(false), + SystemRoutes: new(false), + DynamicRoutes: new(false), }, }, }, @@ -91,24 +90,24 @@ func TestMapDataFields(t *testing.T) { &iaas.RoutingTableListResponse{ Items: &[]iaas.RoutingTable{ { - Id: utils.Ptr(routingTableId.String()), - Name: utils.Ptr("test"), - Description: utils.Ptr("description"), - Default: utils.Ptr(true), + Id: new(routingTableId.String()), + Name: new("test"), + Description: new("description"), + Default: new(true), CreatedAt: &createdAt, UpdatedAt: &updatedAt, - SystemRoutes: utils.Ptr(false), - DynamicRoutes: utils.Ptr(false), + SystemRoutes: new(false), + DynamicRoutes: new(false), }, { - Id: utils.Ptr(secondRoutingTableId.String()), - Name: utils.Ptr("test2"), - Description: utils.Ptr("description2"), - Default: utils.Ptr(false), + Id: new(secondRoutingTableId.String()), + Name: new("test2"), + Description: new("description2"), + Default: new(false), CreatedAt: &createdAt, UpdatedAt: &updatedAt, - SystemRoutes: utils.Ptr(false), - DynamicRoutes: utils.Ptr(false), + SystemRoutes: new(false), + DynamicRoutes: new(false), }, }, }, diff --git a/stackit/internal/services/iaas/securitygroup/resource_test.go b/stackit/internal/services/iaas/securitygroup/resource_test.go index 374986564..4ca9183bd 100644 --- a/stackit/internal/services/iaas/securitygroup/resource_test.go +++ b/stackit/internal/services/iaas/securitygroup/resource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/iaas" ) @@ -31,7 +30,7 @@ func TestMapFields(t *testing.T) { SecurityGroupId: types.StringValue("sgid"), }, input: &iaas.SecurityGroup{ - Id: utils.Ptr("sgid"), + Id: new("sgid"), }, region: "eu01", }, @@ -56,13 +55,13 @@ func TestMapFields(t *testing.T) { Region: types.StringValue("eu01"), }, input: &iaas.SecurityGroup{ - Id: utils.Ptr("sgid"), - Name: utils.Ptr("name"), - Stateful: utils.Ptr(true), - Labels: &map[string]interface{}{ + Id: new("sgid"), + Name: new("name"), + Stateful: new(true), + Labels: &map[string]any{ "key": "value", }, - Description: utils.Ptr("desc"), + Description: new("desc"), }, region: "eu02", }, @@ -88,8 +87,8 @@ func TestMapFields(t *testing.T) { SecurityGroupId: types.StringValue("sgid"), }, input: &iaas.SecurityGroup{ - Id: utils.Ptr("sgid"), - Labels: &map[string]interface{}{}, + Id: new("sgid"), + Labels: &map[string]any{}, }, region: "eu01", }, @@ -155,12 +154,12 @@ func TestToCreatePayload(t *testing.T) { Description: types.StringValue("desc"), }, &iaas.CreateSecurityGroupPayload{ - Name: utils.Ptr("name"), - Stateful: utils.Ptr(true), - Labels: &map[string]interface{}{ + Name: new("name"), + Stateful: new(true), + Labels: &map[string]any{ "key": "value", }, - Description: utils.Ptr("desc"), + Description: new("desc"), }, true, }, @@ -201,11 +200,11 @@ func TestToUpdatePayload(t *testing.T) { Description: types.StringValue("desc"), }, &iaas.UpdateSecurityGroupPayload{ - Name: utils.Ptr("name"), - Labels: &map[string]interface{}{ + Name: new("name"), + Labels: &map[string]any{ "key": "value", }, - Description: utils.Ptr("desc"), + Description: new("desc"), }, true, }, diff --git a/stackit/internal/services/iaas/securitygrouprule/resource_test.go b/stackit/internal/services/iaas/securitygrouprule/resource_test.go index dbf46f59e..b8464e21d 100644 --- a/stackit/internal/services/iaas/securitygrouprule/resource_test.go +++ b/stackit/internal/services/iaas/securitygrouprule/resource_test.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/iaas" ) @@ -18,8 +17,8 @@ var fixtureModelIcmpParameters = types.ObjectValueMust(icmpParametersTypes, map[ }) var fixtureIcmpParameters = iaas.ICMPParameters{ - Code: utils.Ptr(int64(1)), - Type: utils.Ptr(int64(2)), + Code: new(int64(1)), + Type: new(int64(2)), } var fixtureModelPortRange = types.ObjectValueMust(portRangeTypes, map[string]attr.Value{ @@ -28,8 +27,8 @@ var fixtureModelPortRange = types.ObjectValueMust(portRangeTypes, map[string]att }) var fixturePortRange = iaas.PortRange{ - Max: utils.Ptr(int64(2)), - Min: utils.Ptr(int64(1)), + Max: new(int64(2)), + Min: new(int64(1)), } var fixtureModelProtocol = types.ObjectValueMust(protocolTypes, map[string]attr.Value{ @@ -38,8 +37,8 @@ var fixtureModelProtocol = types.ObjectValueMust(protocolTypes, map[string]attr. }) var fixtureProtocol = iaas.Protocol{ - Name: utils.Ptr("name"), - Number: utils.Ptr(int64(1)), + Name: new("name"), + Number: new(int64(1)), } var fixtureModelCreateProtocol = types.ObjectValueMust(protocolTypes, map[string]attr.Value{ @@ -48,7 +47,7 @@ var fixtureModelCreateProtocol = types.ObjectValueMust(protocolTypes, map[string }) var fixtureCreateProtocol = iaas.CreateProtocol{ - String: utils.Ptr("name"), + String: new("name"), } func TestMapFields(t *testing.T) { @@ -72,7 +71,7 @@ func TestMapFields(t *testing.T) { SecurityGroupRuleId: types.StringValue("sgrid"), }, input: &iaas.SecurityGroupRule{ - Id: utils.Ptr("sgrid"), + Id: new("sgrid"), }, region: "eu01", }, @@ -103,12 +102,12 @@ func TestMapFields(t *testing.T) { Region: types.StringValue("eu01"), }, input: &iaas.SecurityGroupRule{ - Id: utils.Ptr("sgrid"), - Description: utils.Ptr("desc"), - Direction: utils.Ptr("ingress"), - Ethertype: utils.Ptr("ether"), - IpRange: utils.Ptr("iprange"), - RemoteSecurityGroupId: utils.Ptr("remote"), + Id: new("sgrid"), + Description: new("desc"), + Direction: new("ingress"), + Ethertype: new("ether"), + IpRange: new("iprange"), + RemoteSecurityGroupId: new("remote"), IcmpParameters: &fixtureIcmpParameters, PortRange: &fixturePortRange, Protocol: &fixtureProtocol, @@ -145,7 +144,7 @@ func TestMapFields(t *testing.T) { }), }, input: &iaas.SecurityGroupRule{ - Id: utils.Ptr("sgrid"), + Id: new("sgrid"), Protocol: &fixtureProtocol, }, region: "eu01", @@ -180,7 +179,7 @@ func TestMapFields(t *testing.T) { }), }, input: &iaas.SecurityGroupRule{ - Id: utils.Ptr("sgrid"), + Id: new("sgrid"), Protocol: &fixtureProtocol, }, region: "eu01", @@ -258,8 +257,8 @@ func TestToCreatePayload(t *testing.T) { Protocol: fixtureModelCreateProtocol, }, &iaas.CreateSecurityGroupRulePayload{ - Description: utils.Ptr("desc"), - Direction: utils.Ptr("ingress"), + Description: new("desc"), + Direction: new("ingress"), IcmpParameters: &fixtureIcmpParameters, PortRange: &fixturePortRange, Protocol: &fixtureCreateProtocol, diff --git a/stackit/internal/services/iaas/server/datasource_test.go b/stackit/internal/services/iaas/server/datasource_test.go index 56c2be530..d6c8dca09 100644 --- a/stackit/internal/services/iaas/server/datasource_test.go +++ b/stackit/internal/services/iaas/server/datasource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/iaas" ) @@ -31,7 +30,7 @@ func TestMapDataSourceFields(t *testing.T) { ServerId: types.StringValue("sid"), }, input: &iaas.Server{ - Id: utils.Ptr("sid"), + Id: new("sid"), }, region: "eu01", }, @@ -63,27 +62,27 @@ func TestMapDataSourceFields(t *testing.T) { Region: types.StringValue("eu01"), }, input: &iaas.Server{ - Id: utils.Ptr("sid"), - Name: utils.Ptr("name"), - AvailabilityZone: utils.Ptr("zone"), - Labels: &map[string]interface{}{ + Id: new("sid"), + Name: new("name"), + AvailabilityZone: new("zone"), + Labels: &map[string]any{ "key": "value", }, - ImageId: utils.Ptr("image_id"), + ImageId: new("image_id"), Nics: &[]iaas.ServerNetwork{ { - NicId: utils.Ptr("nic1"), + NicId: new("nic1"), }, { - NicId: utils.Ptr("nic2"), + NicId: new("nic2"), }, }, - KeypairName: utils.Ptr("keypair_name"), - AffinityGroup: utils.Ptr("group_id"), - CreatedAt: utils.Ptr(testTimestamp()), - UpdatedAt: utils.Ptr(testTimestamp()), - LaunchedAt: utils.Ptr(testTimestamp()), - Status: utils.Ptr("active"), + KeypairName: new("keypair_name"), + AffinityGroup: new("group_id"), + CreatedAt: new(testTimestamp()), + UpdatedAt: new(testTimestamp()), + LaunchedAt: new(testTimestamp()), + Status: new("active"), }, region: "eu02", }, @@ -119,7 +118,7 @@ func TestMapDataSourceFields(t *testing.T) { Labels: types.MapValueMust(types.StringType, map[string]attr.Value{}), }, input: &iaas.Server{ - Id: utils.Ptr("sid"), + Id: new("sid"), }, region: "eu01", }, diff --git a/stackit/internal/services/iaas/server/resource_test.go b/stackit/internal/services/iaas/server/resource_test.go index ad1c70741..ff59cf37d 100644 --- a/stackit/internal/services/iaas/server/resource_test.go +++ b/stackit/internal/services/iaas/server/resource_test.go @@ -45,7 +45,7 @@ func TestMapFields(t *testing.T) { ServerId: types.StringValue("sid"), }, input: &iaas.Server{ - Id: utils.Ptr("sid"), + Id: new("sid"), }, region: "eu01", }, @@ -77,27 +77,27 @@ func TestMapFields(t *testing.T) { Region: types.StringValue("eu01"), }, input: &iaas.Server{ - Id: utils.Ptr("sid"), - Name: utils.Ptr("name"), - AvailabilityZone: utils.Ptr("zone"), - Labels: &map[string]interface{}{ + Id: new("sid"), + Name: new("name"), + AvailabilityZone: new("zone"), + Labels: &map[string]any{ "key": "value", }, - ImageId: utils.Ptr("image_id"), + ImageId: new("image_id"), Nics: &[]iaas.ServerNetwork{ { - NicId: utils.Ptr("nic1"), + NicId: new("nic1"), }, { - NicId: utils.Ptr("nic2"), + NicId: new("nic2"), }, }, - KeypairName: utils.Ptr("keypair_name"), - AffinityGroup: utils.Ptr("group_id"), - CreatedAt: utils.Ptr(testTimestamp()), - UpdatedAt: utils.Ptr(testTimestamp()), - LaunchedAt: utils.Ptr(testTimestamp()), - Status: utils.Ptr("active"), + KeypairName: new("keypair_name"), + AffinityGroup: new("group_id"), + CreatedAt: new(testTimestamp()), + UpdatedAt: new(testTimestamp()), + LaunchedAt: new(testTimestamp()), + Status: new("active"), }, region: "eu02", }, @@ -130,7 +130,7 @@ func TestMapFields(t *testing.T) { Labels: types.MapValueMust(types.StringType, map[string]attr.Value{}), }, input: &iaas.Server{ - Id: utils.Ptr("sid"), + Id: new("sid"), }, region: "eu01", }, @@ -218,23 +218,23 @@ func TestToCreatePayload(t *testing.T) { }), }, expected: &iaas.CreateServerPayload{ - Name: utils.Ptr("name"), - AvailabilityZone: utils.Ptr("zone"), - Labels: &map[string]interface{}{ + Name: new("name"), + AvailabilityZone: new("zone"), + Labels: &map[string]any{ "key": "value", }, BootVolume: &iaas.ServerBootVolume{ - PerformanceClass: utils.Ptr("class"), - Size: utils.Ptr(int64(1)), + PerformanceClass: new("class"), + Size: new(int64(1)), Source: &iaas.BootVolumeSource{ - Type: utils.Ptr("type"), - Id: utils.Ptr("id"), + Type: new("type"), + Id: new("id"), }, }, - ImageId: utils.Ptr("image"), - KeypairName: utils.Ptr("keypair"), - MachineType: utils.Ptr("machine_type"), - UserData: utils.Ptr([]byte(base64EncodedUserData)), + ImageId: new("image"), + KeypairName: new("keypair"), + MachineType: new("machine_type"), + UserData: new([]byte(base64EncodedUserData)), Networking: &iaas.CreateServerPayloadAllOfNetworking{ CreateServerNetworkingWithNics: &iaas.CreateServerNetworkingWithNics{ NicIds: &[]string{"nic1", "nic2"}, @@ -269,24 +269,24 @@ func TestToCreatePayload(t *testing.T) { }), }, expected: &iaas.CreateServerPayload{ - Name: utils.Ptr("name"), - AvailabilityZone: utils.Ptr("zone"), - Labels: &map[string]interface{}{ + Name: new("name"), + AvailabilityZone: new("zone"), + Labels: &map[string]any{ "key": "value", }, BootVolume: &iaas.ServerBootVolume{ - PerformanceClass: utils.Ptr("class"), - Size: utils.Ptr(int64(1)), + PerformanceClass: new("class"), + Size: new(int64(1)), Source: &iaas.BootVolumeSource{ - Type: utils.Ptr("image"), - Id: utils.Ptr("id"), + Type: new("image"), + Id: new("id"), }, - DeleteOnTermination: utils.Ptr(true), + DeleteOnTermination: new(true), }, - ImageId: utils.Ptr("image"), - KeypairName: utils.Ptr("keypair"), - MachineType: utils.Ptr("machine_type"), - UserData: utils.Ptr([]byte(base64EncodedUserData)), + ImageId: new("image"), + KeypairName: new("keypair"), + MachineType: new("machine_type"), + UserData: new([]byte(base64EncodedUserData)), Networking: &iaas.CreateServerPayloadAllOfNetworking{ CreateServerNetworkingWithNics: &iaas.CreateServerNetworkingWithNics{ NicIds: &[]string{"nic1", "nic2"}, @@ -331,8 +331,8 @@ func TestToUpdatePayload(t *testing.T) { }), }, &iaas.UpdateServerPayload{ - Name: utils.Ptr("name"), - Labels: &map[string]interface{}{ + Name: new("name"), + Labels: &map[string]any{ "key": "value", }, }, @@ -432,7 +432,7 @@ func Test_serverResource_updateServerStatus(t *testing.T) { client: &mockServerControlClient{ getServerExecute: func(_ int, _ context.Context, _, _, _ string) (*iaas.Server, error) { return &iaas.Server{ - Id: utils.Ptr(serverId.ValueString()), + Id: new(serverId.ValueString()), Status: utils.Ptr(wait.ServerActiveStatus), }, nil }, @@ -462,7 +462,7 @@ func Test_serverResource_updateServerStatus(t *testing.T) { state = wait.ServerInactiveStatus } return &iaas.Server{ - Id: utils.Ptr(serverId.ValueString()), + Id: new(serverId.ValueString()), Status: &state, }, nil }, @@ -498,7 +498,7 @@ func Test_serverResource_updateServerStatus(t *testing.T) { state = wait.ServerDeallocatedStatus } return &iaas.Server{ - Id: utils.Ptr(serverId.ValueString()), + Id: new(serverId.ValueString()), Status: &state, }, nil }, @@ -525,7 +525,7 @@ func Test_serverResource_updateServerStatus(t *testing.T) { client: &mockServerControlClient{ getServerExecute: func(_ int, _ context.Context, _, _, _ string) (*iaas.Server, error) { return &iaas.Server{ - Id: utils.Ptr(serverId.ValueString()), + Id: new(serverId.ValueString()), Status: utils.Ptr(wait.ServerActiveStatus), }, nil }, @@ -550,7 +550,7 @@ func Test_serverResource_updateServerStatus(t *testing.T) { client: &mockServerControlClient{ getServerExecute: func(_ int, _ context.Context, _, _, _ string) (*iaas.Server, error) { return &iaas.Server{ - Id: utils.Ptr(serverId.ValueString()), + Id: new(serverId.ValueString()), Status: utils.Ptr(wait.ServerInactiveStatus), }, nil }, @@ -575,7 +575,7 @@ func Test_serverResource_updateServerStatus(t *testing.T) { client: &mockServerControlClient{ getServerExecute: func(_ int, _ context.Context, _, _, _ string) (*iaas.Server, error) { return &iaas.Server{ - Id: utils.Ptr(serverId.ValueString()), + Id: new(serverId.ValueString()), Status: utils.Ptr(wait.ServerDeallocatedStatus), }, nil }, diff --git a/stackit/internal/services/iaas/utils/util.go b/stackit/internal/services/iaas/utils/util.go index 79368cf4c..19e6f1485 100644 --- a/stackit/internal/services/iaas/utils/util.go +++ b/stackit/internal/services/iaas/utils/util.go @@ -32,8 +32,8 @@ func ConfigureClient(ctx context.Context, providerData *core.ProviderData, diags return apiClient } -func MapLabels(ctx context.Context, responseLabels *map[string]interface{}, currentLabels types.Map) (basetypes.MapValue, error) { //nolint:gocritic // Linter wants to have a non-pointer type for the map, but this would mean a nil check has to be done before every usage of this func. - labelsTF, diags := types.MapValueFrom(ctx, types.StringType, map[string]interface{}{}) +func MapLabels(ctx context.Context, responseLabels *map[string]any, currentLabels types.Map) (basetypes.MapValue, error) { //nolint:gocritic // Linter wants to have a non-pointer type for the map, but this would mean a nil check has to be done before every usage of this func. + labelsTF, diags := types.MapValueFrom(ctx, types.StringType, map[string]any{}) if diags.HasError() { return labelsTF, fmt.Errorf("convert labels to StringValue map: %w", core.DiagsToError(diags)) } diff --git a/stackit/internal/services/iaas/utils/util_test.go b/stackit/internal/services/iaas/utils/util_test.go index 79af11748..3f99fdc9a 100644 --- a/stackit/internal/services/iaas/utils/util_test.go +++ b/stackit/internal/services/iaas/utils/util_test.go @@ -98,7 +98,7 @@ func TestConfigureClient(t *testing.T) { func TestMapLabels(t *testing.T) { type args struct { - responseLabels *map[string]interface{} + responseLabels *map[string]any currentLabels types.Map } tests := []struct { @@ -110,7 +110,7 @@ func TestMapLabels(t *testing.T) { { name: "response labels is set", args: args{ - responseLabels: &map[string]interface{}{ + responseLabels: &map[string]any{ "foo1": "bar1", "foo2": "bar2", }, @@ -125,7 +125,7 @@ func TestMapLabels(t *testing.T) { { name: "response labels is set but empty", args: args{ - responseLabels: &map[string]interface{}{}, + responseLabels: &map[string]any{}, currentLabels: types.MapUnknown(types.StringType), }, wantErr: false, diff --git a/stackit/internal/services/iaas/volume/datasource_test.go b/stackit/internal/services/iaas/volume/datasource_test.go index e5b505576..b52eb9d08 100644 --- a/stackit/internal/services/iaas/volume/datasource_test.go +++ b/stackit/internal/services/iaas/volume/datasource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/iaas" ) @@ -31,7 +30,7 @@ func TestMapDatasourceFields(t *testing.T) { VolumeId: types.StringValue("nid"), }, input: &iaas.Volume{ - Id: utils.Ptr("nid"), + Id: new("nid"), EncryptionParameters: nil, }, region: "eu01", @@ -61,25 +60,25 @@ func TestMapDatasourceFields(t *testing.T) { Region: types.StringValue("eu01"), }, input: &iaas.Volume{ - Id: utils.Ptr("nid"), - Name: utils.Ptr("name"), - AvailabilityZone: utils.Ptr("zone"), - Labels: &map[string]interface{}{ + Id: new("nid"), + Name: new("name"), + AvailabilityZone: new("zone"), + Labels: &map[string]any{ "key": "value", }, - Description: utils.Ptr("desc"), - PerformanceClass: utils.Ptr("class"), - ServerId: utils.Ptr("sid"), - Size: utils.Ptr(int64(1)), + Description: new("desc"), + PerformanceClass: new("class"), + ServerId: new("sid"), + Size: new(int64(1)), Source: &iaas.VolumeSource{}, - Encrypted: utils.Ptr(true), + Encrypted: new(true), EncryptionParameters: &iaas.VolumeEncryptionParameter{ - KekKeyId: utils.Ptr("kek-key-id"), - KekKeyVersion: utils.Ptr(int64(1)), - KekKeyringId: utils.Ptr("kek-keyring-id"), - KekProjectId: utils.Ptr("kek-project-id"), + KekKeyId: new("kek-key-id"), + KekKeyVersion: new(int64(1)), + KekKeyringId: new("kek-keyring-id"), + KekProjectId: new("kek-project-id"), KeyPayload: nil, - ServiceAccount: utils.Ptr("test-sa@sa.stackit.cloud"), + ServiceAccount: new("test-sa@sa.stackit.cloud"), }, }, region: "eu02", @@ -115,7 +114,7 @@ func TestMapDatasourceFields(t *testing.T) { Labels: types.MapValueMust(types.StringType, map[string]attr.Value{}), }, input: &iaas.Volume{ - Id: utils.Ptr("nid"), + Id: new("nid"), EncryptionParameters: &iaas.VolumeEncryptionParameter{}, }, region: "eu01", diff --git a/stackit/internal/services/iaas/volume/resource.go b/stackit/internal/services/iaas/volume/resource.go index f68590832..f0ec57a0c 100644 --- a/stackit/internal/services/iaas/volume/resource.go +++ b/stackit/internal/services/iaas/volume/resource.go @@ -8,7 +8,6 @@ import ( "strings" "github.com/hashicorp/terraform-plugin-framework-validators/int64validator" - sdkUtils "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier" @@ -774,9 +773,9 @@ func toCreatePayload(ctx context.Context, model *Model, source *sourceModel) (*i if model.EncryptionParameters != nil { var keyPayload *[]byte if !utils.IsUndefined(model.EncryptionParameters.KeyPayloadBase64WriteOnly) { - keyPayload = sdkUtils.Ptr([]byte(model.EncryptionParameters.KeyPayloadBase64WriteOnly.ValueString())) + keyPayload = new([]byte(model.EncryptionParameters.KeyPayloadBase64WriteOnly.ValueString())) } else if !utils.IsUndefined(model.EncryptionParameters.KeyPayloadBase64) { - keyPayload = sdkUtils.Ptr([]byte(model.EncryptionParameters.KeyPayloadBase64.ValueString())) + keyPayload = new([]byte(model.EncryptionParameters.KeyPayloadBase64.ValueString())) } payload.EncryptionParameters = &iaas.VolumeEncryptionParameter{ diff --git a/stackit/internal/services/iaas/volume/resource_test.go b/stackit/internal/services/iaas/volume/resource_test.go index b97b1dc6e..cf60b6e99 100644 --- a/stackit/internal/services/iaas/volume/resource_test.go +++ b/stackit/internal/services/iaas/volume/resource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/iaas" ) @@ -31,7 +30,7 @@ func TestMapFields(t *testing.T) { VolumeId: types.StringValue("nid"), }, input: &iaas.Volume{ - Id: utils.Ptr("nid"), + Id: new("nid"), EncryptionParameters: nil, }, region: "eu01", @@ -69,25 +68,25 @@ func TestMapFields(t *testing.T) { }, }, input: &iaas.Volume{ - Id: utils.Ptr("nid"), - Name: utils.Ptr("name"), - AvailabilityZone: utils.Ptr("zone"), - Labels: &map[string]interface{}{ + Id: new("nid"), + Name: new("name"), + AvailabilityZone: new("zone"), + Labels: &map[string]any{ "key": "value", }, - Description: utils.Ptr("desc"), - PerformanceClass: utils.Ptr("class"), - ServerId: utils.Ptr("sid"), - Size: utils.Ptr(int64(1)), + Description: new("desc"), + PerformanceClass: new("class"), + ServerId: new("sid"), + Size: new(int64(1)), Source: &iaas.VolumeSource{}, - Encrypted: utils.Ptr(true), + Encrypted: new(true), EncryptionParameters: &iaas.VolumeEncryptionParameter{ - KekKeyId: utils.Ptr("kek-key-id"), - KekKeyVersion: utils.Ptr(int64(1)), - KekKeyringId: utils.Ptr("kek-keyring-id"), - KekProjectId: utils.Ptr("kek-project-id"), + KekKeyId: new("kek-key-id"), + KekKeyVersion: new(int64(1)), + KekKeyringId: new("kek-keyring-id"), + KekProjectId: new("kek-project-id"), KeyPayload: nil, - ServiceAccount: utils.Ptr("test-sa@sa.stackit.cloud"), + ServiceAccount: new("test-sa@sa.stackit.cloud"), }, }, region: "eu02", @@ -130,7 +129,7 @@ func TestMapFields(t *testing.T) { Labels: types.MapValueMust(types.StringType, map[string]attr.Value{}), }, input: &iaas.Volume{ - Id: utils.Ptr("nid"), + Id: new("nid"), }, region: "eu01", }, @@ -213,17 +212,17 @@ func TestToCreatePayload(t *testing.T) { Id: types.StringValue("id"), }, expected: &iaas.CreateVolumePayload{ - Name: utils.Ptr("name"), - AvailabilityZone: utils.Ptr("zone"), - Labels: &map[string]interface{}{ + Name: new("name"), + AvailabilityZone: new("zone"), + Labels: &map[string]any{ "key": "value", }, - Description: utils.Ptr("desc"), - PerformanceClass: utils.Ptr("class"), - Size: utils.Ptr(int64(1)), + Description: new("desc"), + PerformanceClass: new("class"), + Size: new(int64(1)), Source: &iaas.VolumeSource{ - Type: utils.Ptr("volume"), - Id: utils.Ptr("id"), + Type: new("volume"), + Id: new("id"), }, }, isValid: true, @@ -246,17 +245,17 @@ func TestToCreatePayload(t *testing.T) { }, expected: &iaas.CreateVolumePayload{ Source: &iaas.VolumeSource{ - Type: utils.Ptr("volume"), - Id: utils.Ptr("id"), + Type: new("volume"), + Id: new("id"), }, - Labels: &map[string]interface{}{}, + Labels: &map[string]any{}, EncryptionParameters: &iaas.VolumeEncryptionParameter{ - KekKeyId: utils.Ptr("kek-key-id"), - KekKeyVersion: utils.Ptr(int64(1)), - KekKeyringId: utils.Ptr("kek-keyring-id"), + KekKeyId: new("kek-key-id"), + KekKeyVersion: new(int64(1)), + KekKeyringId: new("kek-keyring-id"), KekProjectId: nil, KeyPayload: nil, - ServiceAccount: utils.Ptr("test-sa@sa.stackit.cloud"), + ServiceAccount: new("test-sa@sa.stackit.cloud"), }, }, isValid: true, @@ -279,14 +278,14 @@ func TestToCreatePayload(t *testing.T) { }, expected: &iaas.CreateVolumePayload{ Source: &iaas.VolumeSource{ - Type: utils.Ptr("volume"), - Id: utils.Ptr("id"), + Type: new("volume"), + Id: new("id"), }, - Labels: &map[string]interface{}{}, + Labels: &map[string]any{}, EncryptionParameters: &iaas.VolumeEncryptionParameter{ - KekKeyId: utils.Ptr("kek-key-id"), - KekKeyVersion: utils.Ptr(int64(1)), - KekKeyringId: utils.Ptr("kek-keyring-id"), + KekKeyId: new("kek-key-id"), + KekKeyVersion: new(int64(1)), + KekKeyringId: new("kek-keyring-id"), KekProjectId: nil, KeyPayload: func() *[]byte { keyPayload := []byte{ @@ -297,7 +296,7 @@ func TestToCreatePayload(t *testing.T) { } return &keyPayload }(), - ServiceAccount: utils.Ptr("test-sa@sa.stackit.cloud"), + ServiceAccount: new("test-sa@sa.stackit.cloud"), }, }, isValid: true, @@ -339,11 +338,11 @@ func TestToUpdatePayload(t *testing.T) { Description: types.StringValue("desc"), }, &iaas.UpdateVolumePayload{ - Name: utils.Ptr("name"), - Labels: &map[string]interface{}{ + Name: new("name"), + Labels: &map[string]any{ "key": "value", }, - Description: utils.Ptr("desc"), + Description: new("desc"), }, true, }, diff --git a/stackit/internal/services/iaas/volumeattach/resource.go b/stackit/internal/services/iaas/volumeattach/resource.go index a726e5fac..484a0fec1 100644 --- a/stackit/internal/services/iaas/volumeattach/resource.go +++ b/stackit/internal/services/iaas/volumeattach/resource.go @@ -19,7 +19,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" - sdkUtils "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/iaas" "github.com/stackitcloud/stackit-sdk-go/services/iaas/wait" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core" @@ -188,7 +187,7 @@ func (r *volumeAttachResource) Create(ctx context.Context, req resource.CreateRe // Create new Volume attachment payload := iaas.AddVolumeToServerPayload{ - DeleteOnTermination: sdkUtils.Ptr(false), + DeleteOnTermination: new(false), } _, err := r.client.AddVolumeToServer(ctx, projectId, region, serverId, volumeId).AddVolumeToServerPayload(payload).Execute() if err != nil { diff --git a/stackit/internal/services/kms/key/resource_test.go b/stackit/internal/services/kms/key/resource_test.go index f4846eca2..1dc2423f6 100644 --- a/stackit/internal/services/kms/key/resource_test.go +++ b/stackit/internal/services/kms/key/resource_test.go @@ -39,7 +39,7 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue(projectId), }, input: &kms.Key{ - Id: utils.Ptr(keyId), + Id: new(keyId), Protection: utils.Ptr(kms.PROTECTION_SOFTWARE), Algorithm: utils.Ptr(kms.ALGORITHM_ECDSA_P256_SHA256), Purpose: utils.Ptr(kms.PURPOSE_ASYMMETRIC_SIGN_VERIFY), @@ -71,10 +71,10 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue(projectId), }, input: &kms.Key{ - Id: utils.Ptr(keyId), - Description: utils.Ptr("descr"), - DisplayName: utils.Ptr("name"), - ImportOnly: utils.Ptr(true), + Id: new(keyId), + Description: new("descr"), + DisplayName: new("name"), + ImportOnly: new(true), Protection: utils.Ptr(kms.PROTECTION_SOFTWARE), Algorithm: utils.Ptr(kms.ALGORITHM_AES_256_GCM), Purpose: utils.Ptr(kms.PURPOSE_MESSAGE_AUTHENTICATION_CODE), @@ -173,7 +173,7 @@ func TestToCreatePayload(t *testing.T) { DisplayName: types.StringValue("name"), }, expected: &kms.CreateKeyPayload{ - DisplayName: utils.Ptr("name"), + DisplayName: new("name"), }, isValid: true, }, @@ -184,8 +184,8 @@ func TestToCreatePayload(t *testing.T) { Description: types.StringValue(""), }, expected: &kms.CreateKeyPayload{ - DisplayName: utils.Ptr(""), - Description: utils.Ptr(""), + DisplayName: new(""), + Description: new(""), }, isValid: true, }, diff --git a/stackit/internal/services/kms/keyring/resource_test.go b/stackit/internal/services/kms/keyring/resource_test.go index 9645c5f0a..98c9baf9a 100644 --- a/stackit/internal/services/kms/keyring/resource_test.go +++ b/stackit/internal/services/kms/keyring/resource_test.go @@ -6,7 +6,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/kms" ) @@ -27,7 +26,7 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue("pid"), }, &kms.KeyRing{ - Id: utils.Ptr("krid"), + Id: new("krid"), }, Model{ Description: types.StringNull(), @@ -46,9 +45,9 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue("pid"), }, &kms.KeyRing{ - Description: utils.Ptr("descr"), - DisplayName: utils.Ptr("name"), - Id: utils.Ptr("krid"), + Description: new("descr"), + DisplayName: new("name"), + Id: new("krid"), }, Model{ Description: types.StringValue("descr"), @@ -130,7 +129,7 @@ func TestToCreatePayload(t *testing.T) { DisplayName: types.StringValue("name"), }, &kms.CreateKeyRingPayload{ - DisplayName: utils.Ptr("name"), + DisplayName: new("name"), }, true, }, @@ -141,8 +140,8 @@ func TestToCreatePayload(t *testing.T) { Description: types.StringValue(""), }, &kms.CreateKeyRingPayload{ - DisplayName: utils.Ptr(""), - Description: utils.Ptr(""), + DisplayName: new(""), + Description: new(""), }, true, }, diff --git a/stackit/internal/services/kms/wrapping-key/resource.go b/stackit/internal/services/kms/wrapping-key/resource.go index 3d2cfc62c..a1501c8ce 100644 --- a/stackit/internal/services/kms/wrapping-key/resource.go +++ b/stackit/internal/services/kms/wrapping-key/resource.go @@ -280,7 +280,7 @@ func (r *wrappingKeyResource) Create(ctx context.Context, req resource.CreateReq wrappingKeyId := *createWrappingKeyResp.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]interface{}{ + ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{ "project_id": projectId, "region": region, "keyring_id": keyRingId, diff --git a/stackit/internal/services/kms/wrapping-key/resource_test.go b/stackit/internal/services/kms/wrapping-key/resource_test.go index fcc189e03..bd37f67d3 100644 --- a/stackit/internal/services/kms/wrapping-key/resource_test.go +++ b/stackit/internal/services/kms/wrapping-key/resource_test.go @@ -39,7 +39,7 @@ func TestMapFields(t *testing.T) { WrappingKeyId: types.StringValue(wrappingKeyId), }, input: &kms.WrappingKey{ - Id: utils.Ptr("wid"), + Id: new("wid"), AccessScope: utils.Ptr(kms.ACCESSSCOPE_PUBLIC), Algorithm: utils.Ptr(kms.WRAPPINGALGORITHM__2048_OAEP_SHA256), Purpose: utils.Ptr(kms.WRAPPINGPURPOSE_ASYMMETRIC_KEY), @@ -71,9 +71,9 @@ func TestMapFields(t *testing.T) { WrappingKeyId: types.StringValue(wrappingKeyId), }, input: &kms.WrappingKey{ - Description: utils.Ptr("descr"), - DisplayName: utils.Ptr("name"), - Id: utils.Ptr(wrappingKeyId), + Description: new("descr"), + DisplayName: new("name"), + Id: new(wrappingKeyId), AccessScope: utils.Ptr(kms.ACCESSSCOPE_PUBLIC), Algorithm: utils.Ptr(kms.WRAPPINGALGORITHM__2048_OAEP_SHA256), Purpose: utils.Ptr(kms.WRAPPINGPURPOSE_ASYMMETRIC_KEY), @@ -138,8 +138,8 @@ func TestMapFields(t *testing.T) { WrappingKeyId: types.StringValue(wrappingKeyId), }, input: &kms.WrappingKey{ - Description: utils.Ptr(""), - Id: utils.Ptr(wrappingKeyId), + Description: new(""), + Id: new(wrappingKeyId), AccessScope: utils.Ptr(kms.ACCESSSCOPE_PUBLIC), Algorithm: utils.Ptr(kms.WRAPPINGALGORITHM__2048_OAEP_SHA256), Purpose: utils.Ptr(kms.WRAPPINGPURPOSE_ASYMMETRIC_KEY), @@ -201,7 +201,7 @@ func TestToCreatePayload(t *testing.T) { DisplayName: types.StringValue("name"), }, &kms.CreateWrappingKeyPayload{ - DisplayName: utils.Ptr("name"), + DisplayName: new("name"), }, true, }, @@ -212,8 +212,8 @@ func TestToCreatePayload(t *testing.T) { Description: types.StringValue(""), }, &kms.CreateWrappingKeyPayload{ - DisplayName: utils.Ptr(""), - Description: utils.Ptr(""), + DisplayName: new(""), + Description: new(""), }, true, }, diff --git a/stackit/internal/services/loadbalancer/loadbalancer/resource.go b/stackit/internal/services/loadbalancer/loadbalancer/resource.go index 2a0fe0401..7e6ad45c6 100644 --- a/stackit/internal/services/loadbalancer/loadbalancer/resource.go +++ b/stackit/internal/services/loadbalancer/loadbalancer/resource.go @@ -30,7 +30,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" - sdkUtils "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/wait" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion" @@ -889,7 +888,7 @@ func (r *loadBalancerResource) Update(ctx context.Context, req resource.UpdateRe ctx = tflog.SetField(ctx, "target_pool_name", targetPoolName) // Generate API request body from model - payload, err := toTargetPoolUpdatePayload(ctx, sdkUtils.Ptr(targetPoolModel)) + payload, err := toTargetPoolUpdatePayload(ctx, new(targetPoolModel)) if err != nil { core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating load balancer", fmt.Sprintf("Creating API payload for target pool: %v", err)) return @@ -979,7 +978,7 @@ func (r *loadBalancerResource) ImportState(ctx context.Context, req resource.Imp return } - ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]interface{}{ + ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{ "project_id": idParts[0], "region": idParts[1], "name": idParts[2], diff --git a/stackit/internal/services/loadbalancer/loadbalancer/resource_test.go b/stackit/internal/services/loadbalancer/loadbalancer/resource_test.go index 831ae1f47..0212712f8 100644 --- a/stackit/internal/services/loadbalancer/loadbalancer/resource_test.go +++ b/stackit/internal/services/loadbalancer/loadbalancer/resource_test.go @@ -9,7 +9,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" ) @@ -124,34 +123,34 @@ func TestToCreatePayload(t *testing.T) { }), }, &loadbalancer.CreateLoadBalancerPayload{ - ExternalAddress: utils.Ptr("external_address"), + ExternalAddress: new("external_address"), Listeners: &[]loadbalancer.Listener{ { - DisplayName: utils.Ptr("display_name"), - Port: utils.Ptr(int64(80)), + DisplayName: new("display_name"), + Port: new(int64(80)), Protocol: loadbalancer.LISTENERPROTOCOL_TCP.Ptr(), ServerNameIndicators: &[]loadbalancer.ServerNameIndicator{ { - Name: utils.Ptr("domain.com"), + Name: new("domain.com"), }, }, - TargetPool: utils.Ptr("target_pool"), + TargetPool: new("target_pool"), Tcp: &loadbalancer.OptionsTCP{ - IdleTimeout: utils.Ptr("50s"), + IdleTimeout: new("50s"), }, Udp: &loadbalancer.OptionsUDP{ - IdleTimeout: utils.Ptr("50s"), + IdleTimeout: new("50s"), }, }, }, - Name: utils.Ptr("name"), + Name: new("name"), Networks: &[]loadbalancer.Network{ { - NetworkId: utils.Ptr("network_id"), + NetworkId: new("network_id"), Role: loadbalancer.NETWORKROLE_LISTENERS_AND_TARGETS.Ptr(), }, { - NetworkId: utils.Ptr("network_id_2"), + NetworkId: new("network_id_2"), Role: loadbalancer.NETWORKROLE_LISTENERS_AND_TARGETS.Ptr(), }, }, @@ -159,37 +158,37 @@ func TestToCreatePayload(t *testing.T) { AccessControl: &loadbalancer.LoadbalancerOptionAccessControl{ AllowedSourceRanges: &[]string{"cidr"}, }, - PrivateNetworkOnly: utils.Ptr(true), + PrivateNetworkOnly: new(true), Observability: &loadbalancer.LoadbalancerOptionObservability{ Logs: &loadbalancer.LoadbalancerOptionLogs{ - CredentialsRef: utils.Ptr("logs-credentials_ref"), - PushUrl: utils.Ptr("logs-push_url"), + CredentialsRef: new("logs-credentials_ref"), + PushUrl: new("logs-push_url"), }, Metrics: &loadbalancer.LoadbalancerOptionMetrics{ - CredentialsRef: utils.Ptr("metrics-credentials_ref"), - PushUrl: utils.Ptr("metrics-push_url"), + CredentialsRef: new("metrics-credentials_ref"), + PushUrl: new("metrics-push_url"), }, }, }, TargetPools: &[]loadbalancer.TargetPool{ { ActiveHealthCheck: &loadbalancer.ActiveHealthCheck{ - HealthyThreshold: utils.Ptr(int64(1)), - Interval: utils.Ptr("2s"), - IntervalJitter: utils.Ptr("3s"), - Timeout: utils.Ptr("4s"), - UnhealthyThreshold: utils.Ptr(int64(5)), + HealthyThreshold: new(int64(1)), + Interval: new("2s"), + IntervalJitter: new("3s"), + Timeout: new("4s"), + UnhealthyThreshold: new(int64(5)), }, - Name: utils.Ptr("name"), - TargetPort: utils.Ptr(int64(80)), + Name: new("name"), + TargetPort: new(int64(80)), Targets: &[]loadbalancer.Target{ { - DisplayName: utils.Ptr("display_name"), - Ip: utils.Ptr("ip"), + DisplayName: new("display_name"), + Ip: new("ip"), }, }, SessionPersistence: &loadbalancer.SessionPersistence{ - UseSourceIpAddress: utils.Ptr(true), + UseSourceIpAddress: new(true), }, }, }, @@ -274,29 +273,29 @@ func TestToCreatePayload(t *testing.T) { }), }, &loadbalancer.CreateLoadBalancerPayload{ - PlanId: utils.Ptr("p10"), - ExternalAddress: utils.Ptr("external_address"), + PlanId: new("p10"), + ExternalAddress: new("external_address"), Listeners: &[]loadbalancer.Listener{ { - DisplayName: utils.Ptr("display_name"), - Port: utils.Ptr(int64(80)), + DisplayName: new("display_name"), + Port: new(int64(80)), Protocol: loadbalancer.LISTENERPROTOCOL_TCP.Ptr(), ServerNameIndicators: &[]loadbalancer.ServerNameIndicator{ { - Name: utils.Ptr("domain.com"), + Name: new("domain.com"), }, }, - TargetPool: utils.Ptr("target_pool"), + TargetPool: new("target_pool"), }, }, - Name: utils.Ptr("name"), + Name: new("name"), Networks: &[]loadbalancer.Network{ { - NetworkId: utils.Ptr("network_id"), + NetworkId: new("network_id"), Role: loadbalancer.NETWORKROLE_LISTENERS_AND_TARGETS.Ptr(), }, { - NetworkId: utils.Ptr("network_id_2"), + NetworkId: new("network_id_2"), Role: loadbalancer.NETWORKROLE_LISTENERS_AND_TARGETS.Ptr(), }, }, @@ -304,37 +303,37 @@ func TestToCreatePayload(t *testing.T) { AccessControl: &loadbalancer.LoadbalancerOptionAccessControl{ AllowedSourceRanges: &[]string{"cidr"}, }, - PrivateNetworkOnly: utils.Ptr(true), + PrivateNetworkOnly: new(true), Observability: &loadbalancer.LoadbalancerOptionObservability{ Logs: &loadbalancer.LoadbalancerOptionLogs{ - CredentialsRef: utils.Ptr("logs-credentials_ref"), - PushUrl: utils.Ptr("logs-push_url"), + CredentialsRef: new("logs-credentials_ref"), + PushUrl: new("logs-push_url"), }, Metrics: &loadbalancer.LoadbalancerOptionMetrics{ - CredentialsRef: utils.Ptr("metrics-credentials_ref"), - PushUrl: utils.Ptr("metrics-push_url"), + CredentialsRef: new("metrics-credentials_ref"), + PushUrl: new("metrics-push_url"), }, }, }, TargetPools: &[]loadbalancer.TargetPool{ { ActiveHealthCheck: &loadbalancer.ActiveHealthCheck{ - HealthyThreshold: utils.Ptr(int64(1)), - Interval: utils.Ptr("2s"), - IntervalJitter: utils.Ptr("3s"), - Timeout: utils.Ptr("4s"), - UnhealthyThreshold: utils.Ptr(int64(5)), + HealthyThreshold: new(int64(1)), + Interval: new("2s"), + IntervalJitter: new("3s"), + Timeout: new("4s"), + UnhealthyThreshold: new(int64(5)), }, - Name: utils.Ptr("name"), - TargetPort: utils.Ptr(int64(80)), + Name: new("name"), + TargetPort: new(int64(80)), Targets: &[]loadbalancer.Target{ { - DisplayName: utils.Ptr("display_name"), - Ip: utils.Ptr("ip"), + DisplayName: new("display_name"), + Ip: new("ip"), }, }, SessionPersistence: &loadbalancer.SessionPersistence{ - UseSourceIpAddress: utils.Ptr(true), + UseSourceIpAddress: new(true), }, }, }, @@ -404,22 +403,22 @@ func TestToTargetPoolUpdatePayload(t *testing.T) { }, &loadbalancer.UpdateTargetPoolPayload{ ActiveHealthCheck: &loadbalancer.ActiveHealthCheck{ - HealthyThreshold: utils.Ptr(int64(1)), - Interval: utils.Ptr("2s"), - IntervalJitter: utils.Ptr("3s"), - Timeout: utils.Ptr("4s"), - UnhealthyThreshold: utils.Ptr(int64(5)), + HealthyThreshold: new(int64(1)), + Interval: new("2s"), + IntervalJitter: new("3s"), + Timeout: new("4s"), + UnhealthyThreshold: new(int64(5)), }, - Name: utils.Ptr("name"), - TargetPort: utils.Ptr(int64(80)), + Name: new("name"), + TargetPort: new(int64(80)), Targets: &[]loadbalancer.Target{ { - DisplayName: utils.Ptr("display_name"), - Ip: utils.Ptr("ip"), + DisplayName: new("display_name"), + Ip: new("ip"), }, }, SessionPersistence: &loadbalancer.SessionPersistence{ - UseSourceIpAddress: utils.Ptr(false), + UseSourceIpAddress: new(false), }, }, true, @@ -466,7 +465,7 @@ func TestMapFields(t *testing.T) { &loadbalancer.LoadBalancer{ ExternalAddress: nil, Listeners: nil, - Name: utils.Ptr("name"), + Name: new("name"), Networks: nil, Options: &loadbalancer.LoadBalancerOptions{ AccessControl: &loadbalancer.LoadbalancerOptionAccessControl{ @@ -513,73 +512,73 @@ func TestMapFields(t *testing.T) { { "simple_values_ok", &loadbalancer.LoadBalancer{ - ExternalAddress: utils.Ptr("external_address"), - Listeners: utils.Ptr([]loadbalancer.Listener{ + ExternalAddress: new("external_address"), + Listeners: new([]loadbalancer.Listener{ { - DisplayName: utils.Ptr("display_name"), - Port: utils.Ptr(int64(80)), + DisplayName: new("display_name"), + Port: new(int64(80)), Protocol: loadbalancer.LISTENERPROTOCOL_TCP.Ptr(), ServerNameIndicators: &[]loadbalancer.ServerNameIndicator{ { - Name: utils.Ptr("domain.com"), + Name: new("domain.com"), }, }, - TargetPool: utils.Ptr("target_pool"), + TargetPool: new("target_pool"), Tcp: &loadbalancer.OptionsTCP{ - IdleTimeout: utils.Ptr("50s"), + IdleTimeout: new("50s"), }, Udp: &loadbalancer.OptionsUDP{ - IdleTimeout: utils.Ptr("50s"), + IdleTimeout: new("50s"), }, }, }), - Name: utils.Ptr("name"), - Networks: utils.Ptr([]loadbalancer.Network{ + Name: new("name"), + Networks: new([]loadbalancer.Network{ { - NetworkId: utils.Ptr("network_id"), + NetworkId: new("network_id"), Role: loadbalancer.NETWORKROLE_LISTENERS_AND_TARGETS.Ptr(), }, { - NetworkId: utils.Ptr("network_id_2"), + NetworkId: new("network_id_2"), Role: loadbalancer.NETWORKROLE_LISTENERS_AND_TARGETS.Ptr(), }, }), - Options: utils.Ptr(loadbalancer.LoadBalancerOptions{ - PrivateNetworkOnly: utils.Ptr(true), + Options: new(loadbalancer.LoadBalancerOptions{ + PrivateNetworkOnly: new(true), Observability: &loadbalancer.LoadbalancerOptionObservability{ Logs: &loadbalancer.LoadbalancerOptionLogs{ - CredentialsRef: utils.Ptr("logs_credentials_ref"), - PushUrl: utils.Ptr("logs_push_url"), + CredentialsRef: new("logs_credentials_ref"), + PushUrl: new("logs_push_url"), }, Metrics: &loadbalancer.LoadbalancerOptionMetrics{ - CredentialsRef: utils.Ptr("metrics_credentials_ref"), - PushUrl: utils.Ptr("metrics_push_url"), + CredentialsRef: new("metrics_credentials_ref"), + PushUrl: new("metrics_push_url"), }, }, }), TargetSecurityGroup: loadbalancer.LoadBalancerGetTargetSecurityGroupAttributeType(&loadbalancer.SecurityGroup{ - Id: utils.Ptr("sg-id-12345"), - Name: utils.Ptr("sg-name-abcde"), + Id: new("sg-id-12345"), + Name: new("sg-name-abcde"), }), - TargetPools: utils.Ptr([]loadbalancer.TargetPool{ + TargetPools: new([]loadbalancer.TargetPool{ { - ActiveHealthCheck: utils.Ptr(loadbalancer.ActiveHealthCheck{ - HealthyThreshold: utils.Ptr(int64(1)), - Interval: utils.Ptr("2s"), - IntervalJitter: utils.Ptr("3s"), - Timeout: utils.Ptr("4s"), - UnhealthyThreshold: utils.Ptr(int64(5)), + ActiveHealthCheck: new(loadbalancer.ActiveHealthCheck{ + HealthyThreshold: new(int64(1)), + Interval: new("2s"), + IntervalJitter: new("3s"), + Timeout: new("4s"), + UnhealthyThreshold: new(int64(5)), }), - Name: utils.Ptr("name"), - TargetPort: utils.Ptr(int64(80)), - Targets: utils.Ptr([]loadbalancer.Target{ + Name: new("name"), + TargetPort: new(int64(80)), + Targets: new([]loadbalancer.Target{ { - DisplayName: utils.Ptr("display_name"), - Ip: utils.Ptr("ip"), + DisplayName: new("display_name"), + Ip: new("ip"), }, }), - SessionPersistence: utils.Ptr(loadbalancer.SessionPersistence{ - UseSourceIpAddress: utils.Ptr(true), + SessionPersistence: new(loadbalancer.SessionPersistence{ + UseSourceIpAddress: new(true), }), }, }), @@ -671,71 +670,71 @@ func TestMapFields(t *testing.T) { { "simple_values_ok_with_null_private_network_only_response", &loadbalancer.LoadBalancer{ - ExternalAddress: utils.Ptr("external_address"), - Listeners: utils.Ptr([]loadbalancer.Listener{ + ExternalAddress: new("external_address"), + Listeners: new([]loadbalancer.Listener{ { - DisplayName: utils.Ptr("display_name"), - Port: utils.Ptr(int64(80)), + DisplayName: new("display_name"), + Port: new(int64(80)), Protocol: loadbalancer.LISTENERPROTOCOL_TCP.Ptr(), ServerNameIndicators: &[]loadbalancer.ServerNameIndicator{ { - Name: utils.Ptr("domain.com"), + Name: new("domain.com"), }, }, - TargetPool: utils.Ptr("target_pool"), + TargetPool: new("target_pool"), }, }), - Name: utils.Ptr("name"), - Networks: utils.Ptr([]loadbalancer.Network{ + Name: new("name"), + Networks: new([]loadbalancer.Network{ { - NetworkId: utils.Ptr("network_id"), + NetworkId: new("network_id"), Role: loadbalancer.NETWORKROLE_LISTENERS_AND_TARGETS.Ptr(), }, { - NetworkId: utils.Ptr("network_id_2"), + NetworkId: new("network_id_2"), Role: loadbalancer.NETWORKROLE_LISTENERS_AND_TARGETS.Ptr(), }, }), - Options: utils.Ptr(loadbalancer.LoadBalancerOptions{ + Options: new(loadbalancer.LoadBalancerOptions{ AccessControl: &loadbalancer.LoadbalancerOptionAccessControl{ - AllowedSourceRanges: utils.Ptr([]string{"cidr"}), + AllowedSourceRanges: new([]string{"cidr"}), }, PrivateNetworkOnly: nil, // API sets this to nil if it's false in the request Observability: &loadbalancer.LoadbalancerOptionObservability{ Logs: &loadbalancer.LoadbalancerOptionLogs{ - CredentialsRef: utils.Ptr("logs_credentials_ref"), - PushUrl: utils.Ptr("logs_push_url"), + CredentialsRef: new("logs_credentials_ref"), + PushUrl: new("logs_push_url"), }, Metrics: &loadbalancer.LoadbalancerOptionMetrics{ - CredentialsRef: utils.Ptr("metrics_credentials_ref"), - PushUrl: utils.Ptr("metrics_push_url"), + CredentialsRef: new("metrics_credentials_ref"), + PushUrl: new("metrics_push_url"), }, }, }), - TargetPools: utils.Ptr([]loadbalancer.TargetPool{ + TargetPools: new([]loadbalancer.TargetPool{ { - ActiveHealthCheck: utils.Ptr(loadbalancer.ActiveHealthCheck{ - HealthyThreshold: utils.Ptr(int64(1)), - Interval: utils.Ptr("2s"), - IntervalJitter: utils.Ptr("3s"), - Timeout: utils.Ptr("4s"), - UnhealthyThreshold: utils.Ptr(int64(5)), + ActiveHealthCheck: new(loadbalancer.ActiveHealthCheck{ + HealthyThreshold: new(int64(1)), + Interval: new("2s"), + IntervalJitter: new("3s"), + Timeout: new("4s"), + UnhealthyThreshold: new(int64(5)), }), - Name: utils.Ptr("name"), - TargetPort: utils.Ptr(int64(80)), - Targets: utils.Ptr([]loadbalancer.Target{ + Name: new("name"), + TargetPort: new(int64(80)), + Targets: new([]loadbalancer.Target{ { - DisplayName: utils.Ptr("display_name"), - Ip: utils.Ptr("ip"), + DisplayName: new("display_name"), + Ip: new("ip"), }, }), - SessionPersistence: utils.Ptr(loadbalancer.SessionPersistence{ - UseSourceIpAddress: utils.Ptr(true), + SessionPersistence: new(loadbalancer.SessionPersistence{ + UseSourceIpAddress: new(true), }), }, }), }, - utils.Ptr(false), + new(false), testRegion, &Model{ Id: types.StringValue(id), @@ -884,7 +883,7 @@ func Test_validateConfig(t *testing.T) { { name: "happy case 1: private_network_only is not set and external_address is set", args: args{ - ExternalAddress: utils.Ptr(testExternalAddress), + ExternalAddress: new(testExternalAddress), PrivateNetworkOnly: nil, }, wantErr: false, @@ -892,8 +891,8 @@ func Test_validateConfig(t *testing.T) { { name: "happy case 2: private_network_only is set to false and external_address is set", args: args{ - ExternalAddress: utils.Ptr(testExternalAddress), - PrivateNetworkOnly: utils.Ptr(false), + ExternalAddress: new(testExternalAddress), + PrivateNetworkOnly: new(false), }, wantErr: false, }, @@ -901,15 +900,15 @@ func Test_validateConfig(t *testing.T) { name: "happy case 3: private_network_only is set to true and external_address is not set", args: args{ ExternalAddress: nil, - PrivateNetworkOnly: utils.Ptr(true), + PrivateNetworkOnly: new(true), }, wantErr: false, }, { name: "error case 1: private_network_only and external_address are set", args: args{ - ExternalAddress: utils.Ptr(testExternalAddress), - PrivateNetworkOnly: utils.Ptr(true), + ExternalAddress: new(testExternalAddress), + PrivateNetworkOnly: new(true), }, wantErr: true, }, @@ -925,7 +924,7 @@ func Test_validateConfig(t *testing.T) { name: "error case 3: private_network_only is set to false and external_address is not set", args: args{ ExternalAddress: nil, - PrivateNetworkOnly: utils.Ptr(false), + PrivateNetworkOnly: new(false), }, wantErr: true, }, diff --git a/stackit/internal/services/loadbalancer/observability-credential/resource_test.go b/stackit/internal/services/loadbalancer/observability-credential/resource_test.go index a6aaffe70..6f8a6c0ba 100644 --- a/stackit/internal/services/loadbalancer/observability-credential/resource_test.go +++ b/stackit/internal/services/loadbalancer/observability-credential/resource_test.go @@ -6,7 +6,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" ) @@ -35,9 +34,9 @@ func TestToCreatePayload(t *testing.T) { Password: types.StringValue("password"), }, &loadbalancer.CreateCredentialsPayload{ - DisplayName: utils.Ptr("display_name"), - Username: utils.Ptr("username"), - Password: utils.Ptr("password"), + DisplayName: new("display_name"), + Username: new("username"), + Password: new("password"), }, true, }, @@ -80,8 +79,8 @@ func TestMapFields(t *testing.T) { { "default_values_ok", &loadbalancer.CredentialsResponse{ - CredentialsRef: utils.Ptr("credentials_ref"), - Username: utils.Ptr("username"), + CredentialsRef: new("credentials_ref"), + Username: new("username"), }, testRegion, &Model{ @@ -97,9 +96,9 @@ func TestMapFields(t *testing.T) { { "simple_values_ok", &loadbalancer.CredentialsResponse{ - CredentialsRef: utils.Ptr("credentials_ref"), - DisplayName: utils.Ptr("display_name"), - Username: utils.Ptr("username"), + CredentialsRef: new("credentials_ref"), + DisplayName: new("display_name"), + Username: new("username"), }, testRegion, &Model{ @@ -122,8 +121,8 @@ func TestMapFields(t *testing.T) { { "no_username", &loadbalancer.CredentialsResponse{ - CredentialsRef: utils.Ptr("credentials_ref"), - DisplayName: utils.Ptr("display_name"), + CredentialsRef: new("credentials_ref"), + DisplayName: new("display_name"), }, testRegion, &Model{}, @@ -132,8 +131,8 @@ func TestMapFields(t *testing.T) { { "no_credentials_ref", &loadbalancer.CredentialsResponse{ - DisplayName: utils.Ptr("display_name"), - Username: utils.Ptr("username"), + DisplayName: new("display_name"), + Username: new("username"), }, testRegion, &Model{}, diff --git a/stackit/internal/services/logme/credential/resource.go b/stackit/internal/services/logme/credential/resource.go index ff146e56f..a5b1372a3 100644 --- a/stackit/internal/services/logme/credential/resource.go +++ b/stackit/internal/services/logme/credential/resource.go @@ -310,7 +310,7 @@ func (r *credentialResource) ImportState(ctx context.Context, req resource.Impor return } - ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]interface{}{ + ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{ "project_id": idParts[0], "instance_id": idParts[1], "credential_id": idParts[2], diff --git a/stackit/internal/services/logme/credential/resource_test.go b/stackit/internal/services/logme/credential/resource_test.go index ce1b51dee..e982d53a9 100644 --- a/stackit/internal/services/logme/credential/resource_test.go +++ b/stackit/internal/services/logme/credential/resource_test.go @@ -5,7 +5,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/logme" ) @@ -19,7 +18,7 @@ func TestMapFields(t *testing.T) { { "default_values", &logme.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), Raw: &logme.RawCredentials{}, }, Model{ @@ -38,14 +37,14 @@ func TestMapFields(t *testing.T) { { "simple_values", &logme.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), Raw: &logme.RawCredentials{ Credentials: &logme.Credentials{ - Host: utils.Ptr("host"), - Password: utils.Ptr("password"), - Port: utils.Ptr(int64(1234)), - Uri: utils.Ptr("uri"), - Username: utils.Ptr("username"), + Host: new("host"), + Password: new("password"), + Port: new(int64(1234)), + Uri: new("uri"), + Username: new("username"), }, }, }, @@ -65,14 +64,14 @@ func TestMapFields(t *testing.T) { { "null_fields_and_int_conversions", &logme.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), Raw: &logme.RawCredentials{ Credentials: &logme.Credentials{ - Host: utils.Ptr(""), - Password: utils.Ptr(""), - Port: utils.Ptr(int64(2123456789)), + Host: new(""), + Password: new(""), + Port: new(int64(2123456789)), Uri: nil, - Username: utils.Ptr(""), + Username: new(""), }, }, }, @@ -104,7 +103,7 @@ func TestMapFields(t *testing.T) { { "nil_raw_credential", &logme.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), }, Model{}, false, diff --git a/stackit/internal/services/logme/instance/resource.go b/stackit/internal/services/logme/instance/resource.go index cc7427c1b..f4571f98f 100644 --- a/stackit/internal/services/logme/instance/resource.go +++ b/stackit/internal/services/logme/instance/resource.go @@ -624,7 +624,7 @@ func (r *instanceResource) ImportState(ctx context.Context, req resource.ImportS return } - ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]interface{}{ + ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{ "project_id": idParts[0], "instance_id": idParts[1], }) @@ -670,10 +670,10 @@ func mapFields(instance *logme.Instance, model *Model) error { return nil } -func mapParameters(params map[string]interface{}) (types.Object, error) { +func mapParameters(params map[string]any) (types.Object, error) { attributes := map[string]attr.Value{} for attribute := range parametersTypes { - var valueInterface interface{} + var valueInterface any var ok bool // This replacement is necessary because Terraform does not allow hyphens in attribute names @@ -774,7 +774,7 @@ func mapParameters(params map[string]interface{}) (types.Object, error) { for _, x := range temp { valueList = append(valueList, types.StringValue(x)) } - case []interface{}: + case []any: for _, x := range temp { xString, ok := x.(string) if !ok { diff --git a/stackit/internal/services/logme/instance/resource_test.go b/stackit/internal/services/logme/instance/resource_test.go index d74d81d18..dce893f7b 100644 --- a/stackit/internal/services/logme/instance/resource_test.go +++ b/stackit/internal/services/logme/instance/resource_test.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/logme" ) @@ -72,25 +71,25 @@ var fixtureNullModelParameters = types.ObjectValueMust(parametersTypes, map[stri }) var fixtureInstanceParameters = logme.InstanceParameters{ - SgwAcl: utils.Ptr("acl"), - EnableMonitoring: utils.Ptr(true), - FluentdTcp: utils.Ptr(int64(10)), - FluentdTls: utils.Ptr(int64(10)), - FluentdTlsCiphers: utils.Ptr("ciphers"), - FluentdTlsMaxVersion: utils.Ptr("max_version"), - FluentdTlsMinVersion: utils.Ptr("min_version"), - FluentdTlsVersion: utils.Ptr("version"), - FluentdUdp: utils.Ptr(int64(10)), - Graphite: utils.Ptr("graphite"), - IsmDeletionAfter: utils.Ptr("deletion_after"), - IsmJitter: utils.Ptr(10.1), - IsmJobInterval: utils.Ptr(int64(10)), - JavaHeapspace: utils.Ptr(int64(10)), - JavaMaxmetaspace: utils.Ptr(int64(10)), - MaxDiskThreshold: utils.Ptr(int64(10)), - MetricsFrequency: utils.Ptr(int64(10)), - MetricsPrefix: utils.Ptr("prefix"), - MonitoringInstanceId: utils.Ptr("mid"), + SgwAcl: new("acl"), + EnableMonitoring: new(true), + FluentdTcp: new(int64(10)), + FluentdTls: new(int64(10)), + FluentdTlsCiphers: new("ciphers"), + FluentdTlsMaxVersion: new("max_version"), + FluentdTlsMinVersion: new("min_version"), + FluentdTlsVersion: new("version"), + FluentdUdp: new(int64(10)), + Graphite: new("graphite"), + IsmDeletionAfter: new("deletion_after"), + IsmJitter: new(10.1), + IsmJobInterval: new(int64(10)), + JavaHeapspace: new(int64(10)), + JavaMaxmetaspace: new(int64(10)), + MaxDiskThreshold: new(int64(10)), + MetricsFrequency: new(int64(10)), + MetricsPrefix: new("prefix"), + MonitoringInstanceId: new("mid"), OpensearchTlsCiphers: &[]string{"ciphers", "ciphers2"}, OpensearchTlsProtocols: &[]string{"protocols", "protocols2"}, Syslog: &[]string{"syslog", "syslog2"}, @@ -124,15 +123,15 @@ func TestMapFields(t *testing.T) { { "simple_values", &logme.Instance{ - PlanId: utils.Ptr("plan"), - CfGuid: utils.Ptr("cf"), - CfSpaceGuid: utils.Ptr("space"), - DashboardUrl: utils.Ptr("dashboard"), - ImageUrl: utils.Ptr("image"), - InstanceId: utils.Ptr("iid"), - Name: utils.Ptr("name"), - CfOrganizationGuid: utils.Ptr("org"), - Parameters: &map[string]interface{}{ + PlanId: new("plan"), + CfGuid: new("cf"), + CfSpaceGuid: new("space"), + DashboardUrl: new("dashboard"), + ImageUrl: new("image"), + InstanceId: new("iid"), + Name: new("name"), + CfOrganizationGuid: new("org"), + Parameters: &map[string]any{ // Using "-" on purpose on some fields because that is the API response "sgw_acl": "acl", "enable_monitoring": true, @@ -188,7 +187,7 @@ func TestMapFields(t *testing.T) { { "wrong_param_types_1", &logme.Instance{ - Parameters: &map[string]interface{}{ + Parameters: &map[string]any{ "sgw_acl": true, }, }, @@ -198,7 +197,7 @@ func TestMapFields(t *testing.T) { { "wrong_param_types_2", &logme.Instance{ - Parameters: &map[string]interface{}{ + Parameters: &map[string]any{ "sgw_acl": 1, }, }, @@ -250,8 +249,8 @@ func TestToCreatePayload(t *testing.T) { Parameters: fixtureModelParameters, }, &logme.CreateInstancePayload{ - InstanceName: utils.Ptr("name"), - PlanId: utils.Ptr("plan"), + InstanceName: new("name"), + PlanId: new("plan"), Parameters: &fixtureInstanceParameters, }, true, @@ -264,8 +263,8 @@ func TestToCreatePayload(t *testing.T) { Parameters: fixtureNullModelParameters, }, &logme.CreateInstancePayload{ - InstanceName: utils.Ptr(""), - PlanId: utils.Ptr(""), + InstanceName: new(""), + PlanId: new(""), Parameters: &logme.InstanceParameters{}, }, true, @@ -283,8 +282,8 @@ func TestToCreatePayload(t *testing.T) { PlanId: types.StringValue("plan"), }, &logme.CreateInstancePayload{ - InstanceName: utils.Ptr("name"), - PlanId: utils.Ptr("plan"), + InstanceName: new("name"), + PlanId: new("plan"), }, true, }, @@ -339,7 +338,7 @@ func TestToUpdatePayload(t *testing.T) { }, &logme.PartialUpdateInstancePayload{ Parameters: &fixtureInstanceParameters, - PlanId: utils.Ptr("plan"), + PlanId: new("plan"), }, true, }, @@ -351,7 +350,7 @@ func TestToUpdatePayload(t *testing.T) { }, &logme.PartialUpdateInstancePayload{ Parameters: &logme.InstanceParameters{}, - PlanId: utils.Ptr(""), + PlanId: new(""), }, true, }, @@ -367,7 +366,7 @@ func TestToUpdatePayload(t *testing.T) { PlanId: types.StringValue("plan"), }, &logme.PartialUpdateInstancePayload{ - PlanId: utils.Ptr("plan"), + PlanId: new("plan"), }, true, }, diff --git a/stackit/internal/services/logs/accesstoken/datasource.go b/stackit/internal/services/logs/accesstoken/datasource.go index 721c271bc..68801df6c 100644 --- a/stackit/internal/services/logs/accesstoken/datasource.go +++ b/stackit/internal/services/logs/accesstoken/datasource.go @@ -187,7 +187,7 @@ func (d *logsAccessTokenDataSource) Read(ctx context.Context, req datasource.Rea if resp.Diagnostics.HasError() { return } - tflog.Info(ctx, "Logs access token read", map[string]interface{}{ + tflog.Info(ctx, "Logs access token read", map[string]any{ "access_token_id": accessTokenID, }) } diff --git a/stackit/internal/services/logs/accesstoken/datasource_test.go b/stackit/internal/services/logs/accesstoken/datasource_test.go index a32d70c84..5338174d2 100644 --- a/stackit/internal/services/logs/accesstoken/datasource_test.go +++ b/stackit/internal/services/logs/accesstoken/datasource_test.go @@ -8,7 +8,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" ) @@ -55,12 +54,12 @@ func TestMapDataSourceFields(t *testing.T) { description: "max values", input: fixtureAccessToken(func(accessToken *logs.AccessToken) { accessToken.Permissions = []string{"write"} - accessToken.AccessToken = utils.Ptr("") - accessToken.Description = utils.Ptr("description") + accessToken.AccessToken = new("") + accessToken.Description = new("description") accessToken.DisplayName = "display-name" accessToken.Creator = "testUser" accessToken.Expires = false - accessToken.ValidUntil = utils.Ptr(testTime) + accessToken.ValidUntil = new(testTime) }), expected: fixtureDataSourceModel(func(model *DataSourceModel) { model.Permissions = types.ListValueMust(types.StringType, []attr.Value{ diff --git a/stackit/internal/services/logs/accesstoken/resource.go b/stackit/internal/services/logs/accesstoken/resource.go index 39301118e..a2f2e827f 100644 --- a/stackit/internal/services/logs/accesstoken/resource.go +++ b/stackit/internal/services/logs/accesstoken/resource.go @@ -325,7 +325,7 @@ func (r *logsAccessTokenResource) Read(ctx context.Context, req resource.ReadReq if resp.Diagnostics.HasError() { return } - tflog.Info(ctx, "Logs access token read", map[string]interface{}{ + tflog.Info(ctx, "Logs access token read", map[string]any{ "access_token_id": accessTokenID, }) } @@ -381,7 +381,7 @@ func (r *logsAccessTokenResource) Update(ctx context.Context, req resource.Updat if resp.Diagnostics.HasError() { return } - tflog.Info(ctx, "Logs access token updated", map[string]interface{}{ + tflog.Info(ctx, "Logs access token updated", map[string]any{ "access_token_id": accessTokenID, }) } diff --git a/stackit/internal/services/logs/accesstoken/resource_test.go b/stackit/internal/services/logs/accesstoken/resource_test.go index c85be225f..a33c48371 100644 --- a/stackit/internal/services/logs/accesstoken/resource_test.go +++ b/stackit/internal/services/logs/accesstoken/resource_test.go @@ -9,7 +9,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" ) @@ -71,12 +70,12 @@ func TestMapFields(t *testing.T) { description: "max values", input: fixtureAccessToken(func(accessToken *logs.AccessToken) { accessToken.Permissions = []string{"write"} - accessToken.AccessToken = utils.Ptr("") - accessToken.Description = utils.Ptr("description") + accessToken.AccessToken = new("") + accessToken.Description = new("description") accessToken.DisplayName = "display-name" accessToken.Creator = "testUser" accessToken.Expires = false - accessToken.ValidUntil = utils.Ptr(testTime) + accessToken.ValidUntil = new(testTime) }), expected: fixtureModel(func(model *Model) { model.Permissions = types.ListValueMust(types.StringType, []attr.Value{ @@ -151,9 +150,9 @@ func TestToCreatePayload(t *testing.T) { }), expected: &logs.CreateAccessTokenPayload{ Permissions: []string{"read", "write"}, - Description: utils.Ptr("description"), + Description: new("description"), DisplayName: "display-name", - Lifetime: utils.Ptr(int32(7)), + Lifetime: new(int32(7)), }, }, { @@ -197,8 +196,8 @@ func TestToUpdatePayload(t *testing.T) { model.DisplayName = types.StringValue("display-name") }), expected: &logs.UpdateAccessTokenPayload{ - Description: utils.Ptr("description"), - DisplayName: utils.Ptr("display-name"), + Description: new("description"), + DisplayName: new("display-name"), }, }, { diff --git a/stackit/internal/services/logs/instance/datasource.go b/stackit/internal/services/logs/instance/datasource.go index 899ab5b39..e9c4fa101 100644 --- a/stackit/internal/services/logs/instance/datasource.go +++ b/stackit/internal/services/logs/instance/datasource.go @@ -172,7 +172,7 @@ func (d *logsInstanceDataSource) Read(ctx context.Context, req datasource.ReadRe if resp.Diagnostics.HasError() { return } - tflog.Info(ctx, "Logs Instance read", map[string]interface{}{ + tflog.Info(ctx, "Logs Instance read", map[string]any{ "instance_id": instanceID, }) } diff --git a/stackit/internal/services/logs/instance/resource_test.go b/stackit/internal/services/logs/instance/resource_test.go index 0131e75d4..a0e1d822d 100644 --- a/stackit/internal/services/logs/instance/resource_test.go +++ b/stackit/internal/services/logs/instance/resource_test.go @@ -9,7 +9,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" ) @@ -73,13 +72,13 @@ func TestMapFields(t *testing.T) { description: "max values", input: fixtureInstance(func(instance *logs.LogsInstance) { instance.Acl = []string{"acl-entry-1", "acl-entry-2"} - instance.DatasourceUrl = utils.Ptr("datasource-url") - instance.Description = utils.Ptr("description") + instance.DatasourceUrl = new("datasource-url") + instance.Description = new("description") instance.DisplayName = "display-name" - instance.IngestOtlpUrl = utils.Ptr("ingest-otlp-url") - instance.IngestUrl = utils.Ptr("ingest-url") - instance.QueryRangeUrl = utils.Ptr("query-range-url") - instance.QueryUrl = utils.Ptr("query-url") + instance.IngestOtlpUrl = new("ingest-otlp-url") + instance.IngestUrl = new("ingest-url") + instance.QueryRangeUrl = new("query-range-url") + instance.QueryUrl = new("query-url") instance.RetentionDays = int32(7) }), expected: fixtureModel(func(model *Model) { @@ -151,7 +150,7 @@ func TestToCreatePayload(t *testing.T) { }), expected: &logs.CreateLogsInstancePayload{ Acl: []string{"acl-entry-1", "acl-entry-2"}, - Description: utils.Ptr("description"), + Description: new("description"), DisplayName: "display-name", RetentionDays: int32(7), }, @@ -203,9 +202,9 @@ func TestToUpdatePayload(t *testing.T) { }), expected: &logs.UpdateLogsInstancePayload{ Acl: []string{"acl-entry-1", "acl-entry-2"}, - Description: utils.Ptr("description"), - DisplayName: utils.Ptr("display-name"), - RetentionDays: utils.Ptr(int32(7)), + Description: new("description"), + DisplayName: new("display-name"), + RetentionDays: new(int32(7)), }, }, { diff --git a/stackit/internal/services/mariadb/credential/resource_test.go b/stackit/internal/services/mariadb/credential/resource_test.go index 911b57f3a..42e4d4d63 100644 --- a/stackit/internal/services/mariadb/credential/resource_test.go +++ b/stackit/internal/services/mariadb/credential/resource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/mariadb" ) @@ -26,7 +25,7 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue("pid"), }, &mariadb.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), Raw: &mariadb.RawCredentials{}, }, Model{ @@ -51,19 +50,19 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue("pid"), }, &mariadb.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), Raw: &mariadb.RawCredentials{ Credentials: &mariadb.Credentials{ - Host: utils.Ptr("host"), + Host: new("host"), Hosts: &[]string{ "host_1", "", }, - Name: utils.Ptr("name"), - Password: utils.Ptr("password"), - Port: utils.Ptr(int64(1234)), - Uri: utils.Ptr("uri"), - Username: utils.Ptr("username"), + Name: new("name"), + Password: new("password"), + Port: new(int64(1234)), + Uri: new("uri"), + Username: new("username"), }, }, }, @@ -97,20 +96,20 @@ func TestMapFields(t *testing.T) { }), }, &mariadb.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), Raw: &mariadb.RawCredentials{ Credentials: &mariadb.Credentials{ - Host: utils.Ptr("host"), + Host: new("host"), Hosts: &[]string{ "", "host_1", "host_2", }, - Name: utils.Ptr("name"), - Password: utils.Ptr("password"), - Port: utils.Ptr(int64(1234)), - Uri: utils.Ptr("uri"), - Username: utils.Ptr("username"), + Name: new("name"), + Password: new("password"), + Port: new(int64(1234)), + Uri: new("uri"), + Username: new("username"), }, }, }, @@ -140,16 +139,16 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue("pid"), }, &mariadb.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), Raw: &mariadb.RawCredentials{ Credentials: &mariadb.Credentials{ - Host: utils.Ptr(""), + Host: new(""), Hosts: &[]string{}, Name: nil, - Password: utils.Ptr(""), - Port: utils.Ptr(int64(2123456789)), + Password: new(""), + Port: new(int64(2123456789)), Uri: nil, - Username: utils.Ptr(""), + Username: new(""), }, }, }, @@ -195,7 +194,7 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue("pid"), }, &mariadb.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), }, Model{}, false, diff --git a/stackit/internal/services/mariadb/instance/resource.go b/stackit/internal/services/mariadb/instance/resource.go index 351b4e11d..42f6e46cd 100644 --- a/stackit/internal/services/mariadb/instance/resource.go +++ b/stackit/internal/services/mariadb/instance/resource.go @@ -569,7 +569,7 @@ func mapFields(instance *mariadb.Instance, model *Model) error { return nil } -func mapParameters(params map[string]interface{}) (types.Object, error) { +func mapParameters(params map[string]any) (types.Object, error) { attributes := map[string]attr.Value{} for attribute := range parametersTypes { valueInterface, ok := params[attribute] @@ -638,7 +638,7 @@ func mapParameters(params map[string]interface{}) (types.Object, error) { for _, x := range temp { valueList = append(valueList, types.StringValue(x)) } - case []interface{}: + case []any: for _, x := range temp { xString, ok := x.(string) if !ok { diff --git a/stackit/internal/services/mariadb/instance/resource_test.go b/stackit/internal/services/mariadb/instance/resource_test.go index c9a1af9de..ea1e9c759 100644 --- a/stackit/internal/services/mariadb/instance/resource_test.go +++ b/stackit/internal/services/mariadb/instance/resource_test.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/mariadb" ) @@ -38,13 +37,13 @@ var fixtureNullModelParameters = types.ObjectValueMust(parametersTypes, map[stri }) var fixtureInstanceParameters = mariadb.InstanceParameters{ - SgwAcl: utils.Ptr("acl"), - EnableMonitoring: utils.Ptr(true), - Graphite: utils.Ptr("graphite"), - MaxDiskThreshold: utils.Ptr(int64(10)), - MetricsFrequency: utils.Ptr(int64(10)), - MetricsPrefix: utils.Ptr("prefix"), - MonitoringInstanceId: utils.Ptr("mid"), + SgwAcl: new("acl"), + EnableMonitoring: new(true), + Graphite: new("graphite"), + MaxDiskThreshold: new(int64(10)), + MetricsFrequency: new(int64(10)), + MetricsPrefix: new("prefix"), + MonitoringInstanceId: new("mid"), Syslog: &[]string{"syslog", "syslog2"}, } @@ -76,15 +75,15 @@ func TestMapFields(t *testing.T) { { "simple_values", &mariadb.Instance{ - PlanId: utils.Ptr("plan"), - CfGuid: utils.Ptr("cf"), - CfSpaceGuid: utils.Ptr("space"), - DashboardUrl: utils.Ptr("dashboard"), - ImageUrl: utils.Ptr("image"), - InstanceId: utils.Ptr("iid"), - Name: utils.Ptr("name"), - CfOrganizationGuid: utils.Ptr("org"), - Parameters: &map[string]interface{}{ + PlanId: new("plan"), + CfGuid: new("cf"), + CfSpaceGuid: new("space"), + DashboardUrl: new("dashboard"), + ImageUrl: new("image"), + InstanceId: new("iid"), + Name: new("name"), + CfOrganizationGuid: new("org"), + Parameters: &map[string]any{ "sgw_acl": "acl", "enable_monitoring": true, "graphite": "graphite", @@ -125,7 +124,7 @@ func TestMapFields(t *testing.T) { { "wrong_param_types_1", &mariadb.Instance{ - Parameters: &map[string]interface{}{ + Parameters: &map[string]any{ "sgw_acl": true, }, }, @@ -135,7 +134,7 @@ func TestMapFields(t *testing.T) { { "wrong_param_types_2", &mariadb.Instance{ - Parameters: &map[string]interface{}{ + Parameters: &map[string]any{ "sgw_acl": 1, }, }, @@ -187,9 +186,9 @@ func TestToCreatePayload(t *testing.T) { Parameters: fixtureModelParameters, }, &mariadb.CreateInstancePayload{ - InstanceName: utils.Ptr("name"), + InstanceName: new("name"), Parameters: &fixtureInstanceParameters, - PlanId: utils.Ptr("plan"), + PlanId: new("plan"), }, true, }, @@ -201,9 +200,9 @@ func TestToCreatePayload(t *testing.T) { Parameters: fixtureNullModelParameters, }, &mariadb.CreateInstancePayload{ - InstanceName: utils.Ptr(""), + InstanceName: new(""), Parameters: &mariadb.InstanceParameters{}, - PlanId: utils.Ptr(""), + PlanId: new(""), }, true, }, @@ -220,8 +219,8 @@ func TestToCreatePayload(t *testing.T) { PlanId: types.StringValue("plan"), }, &mariadb.CreateInstancePayload{ - InstanceName: utils.Ptr("name"), - PlanId: utils.Ptr("plan"), + InstanceName: new("name"), + PlanId: new("plan"), }, true, }, @@ -276,7 +275,7 @@ func TestToUpdatePayload(t *testing.T) { }, &mariadb.PartialUpdateInstancePayload{ Parameters: &fixtureInstanceParameters, - PlanId: utils.Ptr("plan"), + PlanId: new("plan"), }, true, }, @@ -288,7 +287,7 @@ func TestToUpdatePayload(t *testing.T) { }, &mariadb.PartialUpdateInstancePayload{ Parameters: &mariadb.InstanceParameters{}, - PlanId: utils.Ptr(""), + PlanId: new(""), }, true, }, @@ -304,7 +303,7 @@ func TestToUpdatePayload(t *testing.T) { PlanId: types.StringValue("plan"), }, &mariadb.PartialUpdateInstancePayload{ - PlanId: utils.Ptr("plan"), + PlanId: new("plan"), }, true, }, diff --git a/stackit/internal/services/mariadb/mariadb_acc_test.go b/stackit/internal/services/mariadb/mariadb_acc_test.go index 3d40b8774..78ee04b3a 100644 --- a/stackit/internal/services/mariadb/mariadb_acc_test.go +++ b/stackit/internal/services/mariadb/mariadb_acc_test.go @@ -4,6 +4,7 @@ import ( "context" _ "embed" "fmt" + "maps" "strings" "testing" @@ -49,9 +50,7 @@ var testConfigVarsMax = config.Variables{ func configVarsMaxUpdated() config.Variables { updatedConfig := config.Variables{} - for k, v := range testConfigVarsMax { - updatedConfig[k] = v - } + maps.Copy(updatedConfig, testConfigVarsMax) updatedConfig["parameters_max_disk_threshold"] = config.IntegerVariable(85) updatedConfig["parameters_metrics_frequency"] = config.IntegerVariable(10) updatedConfig["parameters_graphite"] = config.StringVariable("graphite.stackit.cloud:2003") diff --git a/stackit/internal/services/mariadb/mariadb_test.go b/stackit/internal/services/mariadb/mariadb_test.go index 2fc23adcd..5ccf97d4f 100644 --- a/stackit/internal/services/mariadb/mariadb_test.go +++ b/stackit/internal/services/mariadb/mariadb_test.go @@ -49,7 +49,7 @@ resource "stackit_mariadb_instance" "example" { { Plans: &[]mariadb.Plan{ { - Id: utils.Ptr(planId), + Id: new(planId), Name: utils.Ptr(planName), }, }, @@ -69,7 +69,7 @@ resource "stackit_mariadb_instance" "example" { testutil.MockResponse{ Description: "create instance", ToJsonBody: mariadb.CreateInstanceResponse{ - InstanceId: utils.Ptr(instanceId), + InstanceId: new(instanceId), }, }, testutil.MockResponse{ @@ -139,7 +139,7 @@ resource "stackit_mariadb_credential" "example" { testutil.MockResponse{ Description: "create credentials", ToJsonBody: mariadb.CredentialsResponse{ - Id: utils.Ptr(credentialId), + Id: new(credentialId), }, }, testutil.MockResponse{ diff --git a/stackit/internal/services/modelserving/token/resource_test.go b/stackit/internal/services/modelserving/token/resource_test.go index ddd305ff5..3d8008f82 100644 --- a/stackit/internal/services/modelserving/token/resource_test.go +++ b/stackit/internal/services/modelserving/token/resource_test.go @@ -6,7 +6,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/modelserving" ) @@ -54,14 +53,14 @@ func TestMapGetTokenFields(t *testing.T) { }, input: &modelserving.GetTokenResponse{ Token: &modelserving.Token{ - Id: utils.Ptr("tid"), - ValidUntil: utils.Ptr( + Id: new("tid"), + ValidUntil: new( time.Date(2099, 1, 1, 0, 0, 0, 0, time.UTC), ), State: modelserving.TOKENSTATE_ACTIVE.Ptr(), - Name: utils.Ptr("name"), - Description: utils.Ptr("desc"), - Region: utils.Ptr("eu01"), + Name: new("name"), + Description: new("desc"), + Region: new("eu01"), }, }, expected: Model{ @@ -149,15 +148,15 @@ func TestMapCreateTokenFields(t *testing.T) { }, inputCreateTokenResponse: &modelserving.CreateTokenResponse{ Token: &modelserving.TokenCreated{ - Id: utils.Ptr("tid"), - ValidUntil: utils.Ptr( + Id: new("tid"), + ValidUntil: new( time.Date(2099, 1, 1, 0, 0, 0, 0, time.UTC), ), State: modelserving.TOKENCREATEDSTATE_ACTIVE.Ptr(), - Name: utils.Ptr("name"), - Description: utils.Ptr("desc"), - Region: utils.Ptr("eu01"), - Content: utils.Ptr("content"), + Name: new("name"), + Description: new("desc"), + Region: new("eu01"), + Content: new("content"), }, }, inputGetTokenResponse: nil, @@ -174,15 +173,15 @@ func TestMapCreateTokenFields(t *testing.T) { }, inputCreateTokenResponse: &modelserving.CreateTokenResponse{ Token: &modelserving.TokenCreated{ - Id: utils.Ptr("tid"), - ValidUntil: utils.Ptr( + Id: new("tid"), + ValidUntil: new( time.Date(2099, 1, 1, 0, 0, 0, 0, time.UTC), ), State: modelserving.TOKENCREATEDSTATE_ACTIVE.Ptr(), - Name: utils.Ptr("name"), - Description: utils.Ptr("desc"), - Region: utils.Ptr("eu01"), - Content: utils.Ptr("content"), + Name: new("name"), + Description: new("desc"), + Region: new("eu01"), + Content: new("content"), }, }, inputGetTokenResponse: &modelserving.GetTokenResponse{ @@ -257,9 +256,9 @@ func TestToCreatePayload(t *testing.T) { TTLDuration: types.StringValue("1h"), }, expected: &modelserving.CreateTokenPayload{ - Name: utils.Ptr("name"), - Description: utils.Ptr("desc"), - TtlDuration: utils.Ptr("1h"), + Name: new("name"), + Description: new("desc"), + TtlDuration: new("1h"), }, isValid: true, }, @@ -310,8 +309,8 @@ func TestToUpdatePayload(t *testing.T) { Description: types.StringValue("desc"), }, expected: &modelserving.PartialUpdateTokenPayload{ - Name: utils.Ptr("name"), - Description: utils.Ptr("desc"), + Name: new("name"), + Description: new("desc"), }, isValid: true, }, diff --git a/stackit/internal/services/mongodbflex/instance/resource_test.go b/stackit/internal/services/mongodbflex/instance/resource_test.go index 732b5038d..02acfbcf5 100644 --- a/stackit/internal/services/mongodbflex/instance/resource_test.go +++ b/stackit/internal/services/mongodbflex/instance/resource_test.go @@ -11,7 +11,6 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" ) @@ -108,20 +107,20 @@ func TestMapFields(t *testing.T) { "", }, }, - BackupSchedule: utils.Ptr("schedule"), + BackupSchedule: new("schedule"), Flavor: &mongodbflex.Flavor{ - Cpu: utils.Ptr(int64(12)), - Description: utils.Ptr("description"), - Id: utils.Ptr("flavor_id"), - Memory: utils.Ptr(int64(34)), + Cpu: new(int64(12)), + Description: new("description"), + Id: new("flavor_id"), + Memory: new(int64(34)), }, - Id: utils.Ptr(instanceId), - Name: utils.Ptr("name"), - Replicas: utils.Ptr(int64(56)), + Id: new(instanceId), + Name: new("name"), + Replicas: new(int64(56)), Status: mongodbflex.INSTANCESTATUS_READY.Ptr(), Storage: &mongodbflex.Storage{ - Class: utils.Ptr("class"), - Size: utils.Ptr(int64(78)), + Class: new("class"), + Size: new(int64(78)), }, Options: &map[string]string{ "type": "type", @@ -131,7 +130,7 @@ func TestMapFields(t *testing.T) { "monthlySnapshotRetentionMonths": "8", "pointInTimeWindowHours": "9", }, - Version: utils.Ptr("version"), + Version: new("version"), }, }, &flavorModel{}, @@ -188,11 +187,11 @@ func TestMapFields(t *testing.T) { "", }, }, - BackupSchedule: utils.Ptr("schedule"), + BackupSchedule: new("schedule"), Flavor: nil, - Id: utils.Ptr(instanceId), - Name: utils.Ptr("name"), - Replicas: utils.Ptr(int64(56)), + Id: new(instanceId), + Name: new("name"), + Replicas: new(int64(56)), Status: mongodbflex.INSTANCESTATUS_READY.Ptr(), Storage: nil, Options: &map[string]string{ @@ -203,7 +202,7 @@ func TestMapFields(t *testing.T) { "monthlySnapshotRetentionMonths": "8", "pointInTimeWindowHours": "9", }, - Version: utils.Ptr("version"), + Version: new("version"), }, }, &flavorModel{ @@ -273,11 +272,11 @@ func TestMapFields(t *testing.T) { "ip2", }, }, - BackupSchedule: utils.Ptr("schedule"), + BackupSchedule: new("schedule"), Flavor: nil, - Id: utils.Ptr(instanceId), - Name: utils.Ptr("name"), - Replicas: utils.Ptr(int64(56)), + Id: new(instanceId), + Name: new("name"), + Replicas: new(int64(56)), Status: mongodbflex.INSTANCESTATUS_READY.Ptr(), Storage: nil, Options: &map[string]string{ @@ -288,7 +287,7 @@ func TestMapFields(t *testing.T) { "monthlySnapshotRetentionMonths": "8", "pointInTimeWindowHours": "9", }, - Version: utils.Ptr("version"), + Version: new("version"), }, }, &flavorModel{ @@ -419,11 +418,11 @@ func TestMapOptions(t *testing.T) { Type: types.StringValue("type"), }, &mongodbflex.BackupSchedule{ - SnapshotRetentionDays: utils.Ptr(int64(1)), - DailySnapshotRetentionDays: utils.Ptr(int64(2)), - WeeklySnapshotRetentionWeeks: utils.Ptr(int64(3)), - MonthlySnapshotRetentionMonths: utils.Ptr(int64(4)), - PointInTimeWindowHours: utils.Ptr(int64(5)), + SnapshotRetentionDays: new(int64(1)), + DailySnapshotRetentionDays: new(int64(2)), + WeeklySnapshotRetentionWeeks: new(int64(3)), + MonthlySnapshotRetentionMonths: new(int64(4)), + PointInTimeWindowHours: new(int64(5)), }, &Model{ Options: types.ObjectValueMust(optionsTypes, map[string]attr.Value{ @@ -513,16 +512,16 @@ func TestToCreatePayload(t *testing.T) { "ip_2", }, }, - BackupSchedule: utils.Ptr("schedule"), - FlavorId: utils.Ptr("flavor_id"), - Name: utils.Ptr("name"), - Replicas: utils.Ptr(int64(12)), + BackupSchedule: new("schedule"), + FlavorId: new("flavor_id"), + Name: new("name"), + Replicas: new(int64(12)), Storage: &mongodbflex.Storage{ - Class: utils.Ptr("class"), - Size: utils.Ptr(int64(34)), + Class: new("class"), + Size: new(int64(34)), }, Options: &map[string]string{"type": "type"}, - Version: utils.Ptr("version"), + Version: new("version"), }, true, }, @@ -556,7 +555,7 @@ func TestToCreatePayload(t *testing.T) { BackupSchedule: nil, FlavorId: nil, Name: nil, - Replicas: utils.Ptr(int64(2123456789)), + Replicas: new(int64(2123456789)), Storage: &mongodbflex.Storage{ Class: nil, Size: nil, @@ -692,16 +691,16 @@ func TestToUpdatePayload(t *testing.T) { "ip_2", }, }, - BackupSchedule: utils.Ptr("schedule"), - FlavorId: utils.Ptr("flavor_id"), - Name: utils.Ptr("name"), - Replicas: utils.Ptr(int64(12)), + BackupSchedule: new("schedule"), + FlavorId: new("flavor_id"), + Name: new("name"), + Replicas: new(int64(12)), Storage: &mongodbflex.Storage{ - Class: utils.Ptr("class"), - Size: utils.Ptr(int64(34)), + Class: new("class"), + Size: new(int64(34)), }, Options: &map[string]string{"type": "type"}, - Version: utils.Ptr("version"), + Version: new("version"), }, true, }, @@ -735,7 +734,7 @@ func TestToUpdatePayload(t *testing.T) { BackupSchedule: nil, FlavorId: nil, Name: nil, - Replicas: utils.Ptr(int64(2123456789)), + Replicas: new(int64(2123456789)), Storage: &mongodbflex.Storage{ Class: nil, Size: nil, @@ -858,12 +857,12 @@ func TestToUpdateBackupScheduleOptionsPayload(t *testing.T) { PointInTimeWindowHours: types.Int64Value(10), }, &mongodbflex.UpdateBackupSchedulePayload{ - BackupSchedule: utils.Ptr("schedule"), - SnapshotRetentionDays: utils.Ptr(int64(6)), - DailySnapshotRetentionDays: utils.Ptr(int64(7)), - WeeklySnapshotRetentionWeeks: utils.Ptr(int64(8)), - MonthlySnapshotRetentionMonths: utils.Ptr(int64(9)), - PointInTimeWindowHours: utils.Ptr(int64(10)), + BackupSchedule: new("schedule"), + SnapshotRetentionDays: new(int64(6)), + DailySnapshotRetentionDays: new(int64(7)), + WeeklySnapshotRetentionWeeks: new(int64(8)), + MonthlySnapshotRetentionMonths: new(int64(9)), + PointInTimeWindowHours: new(int64(10)), }, true, }, @@ -888,12 +887,12 @@ func TestToUpdateBackupScheduleOptionsPayload(t *testing.T) { PointInTimeWindowHours: types.Int64Null(), }, &mongodbflex.UpdateBackupSchedulePayload{ - BackupSchedule: utils.Ptr("schedule"), - SnapshotRetentionDays: utils.Ptr(int64(6)), - DailySnapshotRetentionDays: utils.Ptr(int64(7)), - WeeklySnapshotRetentionWeeks: utils.Ptr(int64(3)), - MonthlySnapshotRetentionMonths: utils.Ptr(int64(4)), - PointInTimeWindowHours: utils.Ptr(int64(5)), + BackupSchedule: new("schedule"), + SnapshotRetentionDays: new(int64(6)), + DailySnapshotRetentionDays: new(int64(7)), + WeeklySnapshotRetentionWeeks: new(int64(3)), + MonthlySnapshotRetentionMonths: new(int64(4)), + PointInTimeWindowHours: new(int64(5)), }, true, }, @@ -957,10 +956,10 @@ func TestLoadFlavorId(t *testing.T) { &mongodbflex.ListFlavorsResponse{ Flavors: &[]mongodbflex.InstanceFlavor{ { - Id: utils.Ptr("fid-1"), - Cpu: utils.Ptr(int64(2)), - Description: utils.Ptr("description"), - Memory: utils.Ptr(int64(8)), + Id: new("fid-1"), + Cpu: new(int64(2)), + Description: new("description"), + Memory: new(int64(8)), }, }, }, @@ -982,16 +981,16 @@ func TestLoadFlavorId(t *testing.T) { &mongodbflex.ListFlavorsResponse{ Flavors: &[]mongodbflex.InstanceFlavor{ { - Id: utils.Ptr("fid-1"), - Cpu: utils.Ptr(int64(2)), - Description: utils.Ptr("description"), - Memory: utils.Ptr(int64(8)), + Id: new("fid-1"), + Cpu: new(int64(2)), + Description: new("description"), + Memory: new(int64(8)), }, { - Id: utils.Ptr("fid-2"), - Cpu: utils.Ptr(int64(1)), - Description: utils.Ptr("description"), - Memory: utils.Ptr(int64(4)), + Id: new("fid-2"), + Cpu: new(int64(1)), + Description: new("description"), + Memory: new(int64(4)), }, }, }, @@ -1013,16 +1012,16 @@ func TestLoadFlavorId(t *testing.T) { &mongodbflex.ListFlavorsResponse{ Flavors: &[]mongodbflex.InstanceFlavor{ { - Id: utils.Ptr("fid-1"), - Cpu: utils.Ptr(int64(1)), - Description: utils.Ptr("description"), - Memory: utils.Ptr(int64(8)), + Id: new("fid-1"), + Cpu: new(int64(1)), + Description: new("description"), + Memory: new(int64(8)), }, { - Id: utils.Ptr("fid-2"), - Cpu: utils.Ptr(int64(1)), - Description: utils.Ptr("description"), - Memory: utils.Ptr(int64(4)), + Id: new("fid-2"), + Cpu: new(int64(1)), + Description: new("description"), + Memory: new(int64(4)), }, }, }, diff --git a/stackit/internal/services/mongodbflex/mongodbflex_test.go b/stackit/internal/services/mongodbflex/mongodbflex_test.go index db454ff69..d3a1f8a08 100644 --- a/stackit/internal/services/mongodbflex/mongodbflex_test.go +++ b/stackit/internal/services/mongodbflex/mongodbflex_test.go @@ -8,7 +8,6 @@ import ( "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/testutil" ) @@ -65,16 +64,16 @@ resource "stackit_mongodbflex_instance" "instance" { Description: "ListFlavors", ToJsonBody: &mongodbflex.ListFlavorsResponse{Flavors: &[]mongodbflex.InstanceFlavor{ { - Description: utils.Ptr("flava-flav"), - Cpu: utils.Ptr(int64(2)), - Id: utils.Ptr("flavor-id"), - Memory: utils.Ptr(int64(4)), + Description: new("flava-flav"), + Cpu: new(int64(2)), + Id: new("flavor-id"), + Memory: new(int64(4)), }, }}, }, testutil.MockResponse{ Description: "create instance", - ToJsonBody: &mongodbflex.CreateInstanceResponse{Id: utils.Ptr(instanceId)}, + ToJsonBody: &mongodbflex.CreateInstanceResponse{Id: new(instanceId)}, }, testutil.MockResponse{Description: "create waiter", StatusCode: http.StatusInternalServerError}, ) @@ -136,7 +135,7 @@ resource "stackit_mongodbflex_user" "user" { s.Reset( testutil.MockResponse{ Description: "create user", - ToJsonBody: &mongodbflex.CreateUserResponse{Item: &mongodbflex.User{Id: utils.Ptr(userId)}}, + ToJsonBody: &mongodbflex.CreateUserResponse{Item: &mongodbflex.User{Id: new(userId)}}, }, testutil.MockResponse{Description: "failing waiter", StatusCode: http.StatusInternalServerError}, ) diff --git a/stackit/internal/services/mongodbflex/user/datasource_test.go b/stackit/internal/services/mongodbflex/user/datasource_test.go index e5ce87cf4..d3df40872 100644 --- a/stackit/internal/services/mongodbflex/user/datasource_test.go +++ b/stackit/internal/services/mongodbflex/user/datasource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" ) @@ -47,10 +46,10 @@ func TestMapDataSourceFields(t *testing.T) { "role_2", "", }, - Username: utils.Ptr("username"), - Database: utils.Ptr("database"), - Host: utils.Ptr("host"), - Port: utils.Ptr(int64(1234)), + Username: new("username"), + Database: new("database"), + Host: new("host"), + Port: new(int64(1234)), }, }, testRegion, @@ -75,12 +74,12 @@ func TestMapDataSourceFields(t *testing.T) { "null_fields_and_int_conversions", &mongodbflex.GetUserResponse{ Item: &mongodbflex.InstanceResponseUser{ - Id: utils.Ptr(userId), + Id: new(userId), Roles: &[]string{}, Username: nil, Database: nil, Host: nil, - Port: utils.Ptr(int64(2123456789)), + Port: new(int64(2123456789)), }, }, testRegion, diff --git a/stackit/internal/services/mongodbflex/user/resource_test.go b/stackit/internal/services/mongodbflex/user/resource_test.go index 53f31ef98..5081f11af 100644 --- a/stackit/internal/services/mongodbflex/user/resource_test.go +++ b/stackit/internal/services/mongodbflex/user/resource_test.go @@ -9,7 +9,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" ) @@ -35,8 +34,8 @@ func TestMapFieldsCreate(t *testing.T) { "default_values", &mongodbflex.CreateUserResponse{ Item: &mongodbflex.User{ - Id: utils.Ptr(userId), - Password: utils.Ptr(""), + Id: new(userId), + Password: new(""), }, }, testRegion, @@ -60,18 +59,18 @@ func TestMapFieldsCreate(t *testing.T) { "simple_values", &mongodbflex.CreateUserResponse{ Item: &mongodbflex.User{ - Id: utils.Ptr(userId), + Id: new(userId), Roles: &[]string{ "role_1", "role_2", "", }, - Username: utils.Ptr("username"), - Database: utils.Ptr("database"), - Password: utils.Ptr("password"), - Host: utils.Ptr("host"), - Port: utils.Ptr(int64(1234)), - Uri: utils.Ptr("uri"), + Username: new("username"), + Database: new("database"), + Password: new("password"), + Host: new("host"), + Port: new(int64(1234)), + Uri: new("uri"), }, }, testRegion, @@ -99,13 +98,13 @@ func TestMapFieldsCreate(t *testing.T) { "null_fields_and_int_conversions", &mongodbflex.CreateUserResponse{ Item: &mongodbflex.User{ - Id: utils.Ptr(userId), + Id: new(userId), Roles: &[]string{}, Username: nil, Database: nil, - Password: utils.Ptr(""), + Password: new(""), Host: nil, - Port: utils.Ptr(int64(2123456789)), + Port: new(int64(2123456789)), Uri: nil, }, }, @@ -153,7 +152,7 @@ func TestMapFieldsCreate(t *testing.T) { "no_password", &mongodbflex.CreateUserResponse{ Item: &mongodbflex.User{ - Id: utils.Ptr(userId), + Id: new(userId), }, }, testRegion, @@ -221,10 +220,10 @@ func TestMapFields(t *testing.T) { "role_2", "", }, - Username: utils.Ptr("username"), - Database: utils.Ptr("database"), - Host: utils.Ptr("host"), - Port: utils.Ptr(int64(1234)), + Username: new("username"), + Database: new("database"), + Host: new("host"), + Port: new(int64(1234)), }, }, testRegion, @@ -250,12 +249,12 @@ func TestMapFields(t *testing.T) { "null_fields_and_int_conversions", &mongodbflex.GetUserResponse{ Item: &mongodbflex.InstanceResponseUser{ - Id: utils.Ptr(userId), + Id: new(userId), Roles: &[]string{}, Username: nil, Database: nil, Host: nil, - Port: utils.Ptr(int64(2123456789)), + Port: new(int64(2123456789)), }, }, testRegion, @@ -355,8 +354,8 @@ func TestToCreatePayload(t *testing.T) { "role_1", "role_2", }, - Username: utils.Ptr("username"), - Database: utils.Ptr("database"), + Username: new("username"), + Database: new("database"), }, true, }, @@ -445,7 +444,7 @@ func TestToUpdatePayload(t *testing.T) { "role_1", "role_2", }, - Database: utils.Ptr("database"), + Database: new("database"), }, true, }, diff --git a/stackit/internal/services/objectstorage/bucket/resource_test.go b/stackit/internal/services/objectstorage/bucket/resource_test.go index 18aaa46c0..ecc0f3a58 100644 --- a/stackit/internal/services/objectstorage/bucket/resource_test.go +++ b/stackit/internal/services/objectstorage/bucket/resource_test.go @@ -8,7 +8,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/objectstorage" ) @@ -22,7 +21,7 @@ func (c *objectStorageClientMocked) EnableServiceExecute(_ context.Context, proj } return &objectstorage.ProjectStatus{ - Project: utils.Ptr(projectId), + Project: new(projectId), }, nil } @@ -54,9 +53,9 @@ func TestMapFields(t *testing.T) { "simple_values", &objectstorage.GetBucketResponse{ Bucket: &objectstorage.Bucket{ - UrlPathStyle: utils.Ptr("url/path/style"), - UrlVirtualHostedStyle: utils.Ptr("url/virtual/hosted/style"), - ObjectLockEnabled: utils.Ptr(true), + UrlPathStyle: new("url/path/style"), + UrlVirtualHostedStyle: new("url/virtual/hosted/style"), + ObjectLockEnabled: new(true), }, }, Model{ @@ -74,8 +73,8 @@ func TestMapFields(t *testing.T) { "empty_strings", &objectstorage.GetBucketResponse{ Bucket: &objectstorage.Bucket{ - UrlPathStyle: utils.Ptr(""), - UrlVirtualHostedStyle: utils.Ptr(""), + UrlPathStyle: new(""), + UrlVirtualHostedStyle: new(""), }, }, Model{ diff --git a/stackit/internal/services/objectstorage/credential/datasource_test.go b/stackit/internal/services/objectstorage/credential/datasource_test.go index e6ba0539a..fb17e4c2c 100644 --- a/stackit/internal/services/objectstorage/credential/datasource_test.go +++ b/stackit/internal/services/objectstorage/credential/datasource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/objectstorage" ) @@ -39,8 +38,8 @@ func TestMapDatasourceFields(t *testing.T) { { "simple_values", &objectstorage.AccessKey{ - DisplayName: utils.Ptr("name"), - Expires: utils.Ptr(now.Format(time.RFC3339)), + DisplayName: new("name"), + Expires: new(now.Format(time.RFC3339)), }, DataSourceModel{ Id: types.StringValue(id), @@ -56,7 +55,7 @@ func TestMapDatasourceFields(t *testing.T) { { "empty_strings", &objectstorage.AccessKey{ - DisplayName: utils.Ptr(""), + DisplayName: new(""), }, DataSourceModel{ Id: types.StringValue(id), @@ -72,7 +71,7 @@ func TestMapDatasourceFields(t *testing.T) { { "expiration_timestamp_with_fractional_seconds", &objectstorage.AccessKey{ - Expires: utils.Ptr(now.Format(time.RFC3339Nano)), + Expires: new(now.Format(time.RFC3339Nano)), }, DataSourceModel{ Id: types.StringValue(id), @@ -94,7 +93,7 @@ func TestMapDatasourceFields(t *testing.T) { { "bad_time", &objectstorage.AccessKey{ - Expires: utils.Ptr("foo-bar"), + Expires: new("foo-bar"), }, DataSourceModel{}, false, diff --git a/stackit/internal/services/objectstorage/credential/resource_test.go b/stackit/internal/services/objectstorage/credential/resource_test.go index 24746aa2f..827f41212 100644 --- a/stackit/internal/services/objectstorage/credential/resource_test.go +++ b/stackit/internal/services/objectstorage/credential/resource_test.go @@ -12,7 +12,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stackitcloud/stackit-sdk-go/core/config" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/objectstorage" ) @@ -26,7 +25,7 @@ func (c *objectStorageClientMocked) EnableServiceExecute(_ context.Context, proj } return &objectstorage.ProjectStatus{ - Project: utils.Ptr(projectId), + Project: new(projectId), }, nil } @@ -59,10 +58,10 @@ func TestMapFields(t *testing.T) { { "simple_values", &objectstorage.CreateAccessKeyResponse{ - AccessKey: utils.Ptr("key"), - DisplayName: utils.Ptr("name"), - Expires: objectstorage.NewNullableString(utils.Ptr(now.Format(time.RFC3339))), - SecretAccessKey: utils.Ptr("secret-key"), + AccessKey: new("key"), + DisplayName: new("name"), + Expires: objectstorage.NewNullableString(new(now.Format(time.RFC3339))), + SecretAccessKey: new("secret-key"), }, Model{ Id: types.StringValue(id), @@ -80,9 +79,9 @@ func TestMapFields(t *testing.T) { { "empty_strings", &objectstorage.CreateAccessKeyResponse{ - AccessKey: utils.Ptr(""), - DisplayName: utils.Ptr(""), - SecretAccessKey: utils.Ptr(""), + AccessKey: new(""), + DisplayName: new(""), + SecretAccessKey: new(""), }, Model{ Id: types.StringValue(id), @@ -100,7 +99,7 @@ func TestMapFields(t *testing.T) { { "expiration_timestamp_with_fractional_seconds", &objectstorage.CreateAccessKeyResponse{ - Expires: objectstorage.NewNullableString(utils.Ptr(now.Format(time.RFC3339Nano))), + Expires: objectstorage.NewNullableString(new(now.Format(time.RFC3339Nano))), }, Model{ Id: types.StringValue(id), @@ -123,7 +122,7 @@ func TestMapFields(t *testing.T) { { "bad_time", &objectstorage.CreateAccessKeyResponse{ - Expires: objectstorage.NewNullableString(utils.Ptr("foo-bar")), + Expires: objectstorage.NewNullableString(new("foo-bar")), }, Model{}, false, @@ -231,13 +230,13 @@ func TestReadCredentials(t *testing.T) { &objectstorage.ListAccessKeysResponse{ AccessKeys: &[]objectstorage.AccessKey{ { - KeyId: utils.Ptr("foo-cid"), + KeyId: new("foo-cid"), }, { - KeyId: utils.Ptr("bar-cid"), + KeyId: new("bar-cid"), }, { - KeyId: utils.Ptr("cid"), + KeyId: new("cid"), }, }, }, @@ -261,19 +260,19 @@ func TestReadCredentials(t *testing.T) { &objectstorage.ListAccessKeysResponse{ AccessKeys: &[]objectstorage.AccessKey{ { - KeyId: utils.Ptr("foo-cid"), - DisplayName: utils.Ptr("foo-name"), - Expires: utils.Ptr(now.Add(time.Hour).Format(time.RFC3339)), + KeyId: new("foo-cid"), + DisplayName: new("foo-name"), + Expires: new(now.Add(time.Hour).Format(time.RFC3339)), }, { - KeyId: utils.Ptr("bar-cid"), - DisplayName: utils.Ptr("bar-name"), - Expires: utils.Ptr(now.Add(time.Minute).Format(time.RFC3339)), + KeyId: new("bar-cid"), + DisplayName: new("bar-name"), + Expires: new(now.Add(time.Minute).Format(time.RFC3339)), }, { - KeyId: utils.Ptr("cid"), - DisplayName: utils.Ptr("name"), - Expires: utils.Ptr(now.Format(time.RFC3339)), + KeyId: new("cid"), + DisplayName: new("name"), + Expires: new(now.Format(time.RFC3339)), }, }, }, @@ -297,19 +296,19 @@ func TestReadCredentials(t *testing.T) { &objectstorage.ListAccessKeysResponse{ AccessKeys: &[]objectstorage.AccessKey{ { - KeyId: utils.Ptr("foo-cid"), - DisplayName: utils.Ptr("foo-name"), - Expires: utils.Ptr(now.Add(time.Hour).Format(time.RFC3339Nano)), + KeyId: new("foo-cid"), + DisplayName: new("foo-name"), + Expires: new(now.Add(time.Hour).Format(time.RFC3339Nano)), }, { - KeyId: utils.Ptr("bar-cid"), - DisplayName: utils.Ptr("bar-name"), - Expires: utils.Ptr(now.Add(time.Minute).Format(time.RFC3339Nano)), + KeyId: new("bar-cid"), + DisplayName: new("bar-name"), + Expires: new(now.Add(time.Minute).Format(time.RFC3339Nano)), }, { - KeyId: utils.Ptr("cid"), - DisplayName: utils.Ptr("name"), - Expires: utils.Ptr(now.Format(time.RFC3339Nano)), + KeyId: new("cid"), + DisplayName: new("name"), + Expires: new(now.Format(time.RFC3339Nano)), }, }, }, @@ -353,14 +352,14 @@ func TestReadCredentials(t *testing.T) { &objectstorage.ListAccessKeysResponse{ AccessKeys: &[]objectstorage.AccessKey{ { - KeyId: utils.Ptr("foo-cid"), - DisplayName: utils.Ptr("foo-name"), - Expires: utils.Ptr(now.Add(time.Hour).Format(time.RFC3339)), + KeyId: new("foo-cid"), + DisplayName: new("foo-name"), + Expires: new(now.Add(time.Hour).Format(time.RFC3339)), }, { - KeyId: utils.Ptr("bar-cid"), - DisplayName: utils.Ptr("bar-name"), - Expires: utils.Ptr(now.Add(time.Minute).Format(time.RFC3339)), + KeyId: new("bar-cid"), + DisplayName: new("bar-name"), + Expires: new(now.Add(time.Minute).Format(time.RFC3339)), }, }, }, @@ -376,9 +375,9 @@ func TestReadCredentials(t *testing.T) { &objectstorage.ListAccessKeysResponse{ AccessKeys: &[]objectstorage.AccessKey{ { - KeyId: utils.Ptr("cid"), - DisplayName: utils.Ptr("name"), - Expires: utils.Ptr(now.Format(time.RFC3339)), + KeyId: new("cid"), + DisplayName: new("name"), + Expires: new(now.Format(time.RFC3339)), }, }, }, diff --git a/stackit/internal/services/objectstorage/credentialsgroup/resource.go b/stackit/internal/services/objectstorage/credentialsgroup/resource.go index 49a8a3d76..5643081a7 100644 --- a/stackit/internal/services/objectstorage/credentialsgroup/resource.go +++ b/stackit/internal/services/objectstorage/credentialsgroup/resource.go @@ -21,7 +21,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" - sdkUtils "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/objectstorage" ) @@ -187,7 +186,7 @@ func (r *credentialsGroupResource) Create(ctx context.Context, req resource.Crea ctx = tflog.SetField(ctx, "region", region) createCredentialsGroupPayload := objectstorage.CreateCredentialsGroupPayload{ - DisplayName: sdkUtils.Ptr(credentialsGroupName), + DisplayName: new(credentialsGroupName), } // Handle project init diff --git a/stackit/internal/services/objectstorage/credentialsgroup/resource_test.go b/stackit/internal/services/objectstorage/credentialsgroup/resource_test.go index 37b0dae84..f5e92ed3f 100644 --- a/stackit/internal/services/objectstorage/credentialsgroup/resource_test.go +++ b/stackit/internal/services/objectstorage/credentialsgroup/resource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/objectstorage" ) @@ -22,7 +21,7 @@ func (c *objectStorageClientMocked) EnableServiceExecute(_ context.Context, proj } return &objectstorage.ProjectStatus{ - Project: utils.Ptr(projectId), + Project: new(projectId), }, nil } @@ -62,8 +61,8 @@ func TestMapFields(t *testing.T) { "simple_values", &objectstorage.CreateCredentialsGroupResponse{ CredentialsGroup: &objectstorage.CredentialsGroup{ - DisplayName: utils.Ptr("name"), - Urn: utils.Ptr("urn"), + DisplayName: new("name"), + Urn: new("urn"), }, }, Model{ @@ -80,8 +79,8 @@ func TestMapFields(t *testing.T) { "empty_strings", &objectstorage.CreateCredentialsGroupResponse{ CredentialsGroup: &objectstorage.CredentialsGroup{ - DisplayName: utils.Ptr(""), - Urn: utils.Ptr(""), + DisplayName: new(""), + Urn: new(""), }, }, Model{ @@ -179,10 +178,10 @@ func TestReadCredentialsGroups(t *testing.T) { &objectstorage.ListCredentialsGroupsResponse{ CredentialsGroups: &[]objectstorage.CredentialsGroup{ { - CredentialsGroupId: utils.Ptr("cid"), + CredentialsGroupId: new("cid"), }, { - CredentialsGroupId: utils.Ptr("foo-id"), + CredentialsGroupId: new("foo-id"), }, }, }, @@ -202,14 +201,14 @@ func TestReadCredentialsGroups(t *testing.T) { &objectstorage.ListCredentialsGroupsResponse{ CredentialsGroups: &[]objectstorage.CredentialsGroup{ { - CredentialsGroupId: utils.Ptr("cid"), - DisplayName: utils.Ptr("name"), - Urn: utils.Ptr("urn"), + CredentialsGroupId: new("cid"), + DisplayName: new("name"), + Urn: new("urn"), }, { - CredentialsGroupId: utils.Ptr("foo-cid"), - DisplayName: utils.Ptr("foo-name"), - Urn: utils.Ptr("foo-urn"), + CredentialsGroupId: new("foo-cid"), + DisplayName: new("foo-name"), + Urn: new("foo-urn"), }, }, }, @@ -257,9 +256,9 @@ func TestReadCredentialsGroups(t *testing.T) { &objectstorage.ListCredentialsGroupsResponse{ CredentialsGroups: &[]objectstorage.CredentialsGroup{ { - CredentialsGroupId: utils.Ptr("foo-other"), - DisplayName: utils.Ptr("foo-name"), - Urn: utils.Ptr("foo-urn"), + CredentialsGroupId: new("foo-other"), + DisplayName: new("foo-name"), + Urn: new("foo-urn"), }, }, }, @@ -273,9 +272,9 @@ func TestReadCredentialsGroups(t *testing.T) { &objectstorage.ListCredentialsGroupsResponse{ CredentialsGroups: &[]objectstorage.CredentialsGroup{ { - CredentialsGroupId: utils.Ptr("other_id"), - DisplayName: utils.Ptr("name"), - Urn: utils.Ptr("urn"), + CredentialsGroupId: new("other_id"), + DisplayName: new("name"), + Urn: new("urn"), }, }, }, diff --git a/stackit/internal/services/objectstorage/objectstorage_test.go b/stackit/internal/services/objectstorage/objectstorage_test.go index cdac8560c..62f30b5f3 100644 --- a/stackit/internal/services/objectstorage/objectstorage_test.go +++ b/stackit/internal/services/objectstorage/objectstorage_test.go @@ -42,7 +42,7 @@ resource "stackit_objectstorage_bucket" "instance" { testutil.MockResponse{ Description: "project enable", ToJsonBody: objectstorage.ProjectStatus{ - Project: utils.Ptr(projectId), + Project: new(projectId), Scope: utils.Ptr(objectstorage.PROJECTSCOPE_PUBLIC), }, }, diff --git a/stackit/internal/services/observability/alertgroup/resource_test.go b/stackit/internal/services/observability/alertgroup/resource_test.go index a9abc4501..21f3c009d 100644 --- a/stackit/internal/services/observability/alertgroup/resource_test.go +++ b/stackit/internal/services/observability/alertgroup/resource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/observability" ) @@ -41,8 +40,8 @@ func TestToCreatePayload(t *testing.T) { Interval: types.StringValue("5m"), }, expect: &observability.CreateAlertgroupsPayload{ - Name: utils.Ptr("test-alertgroup"), - Interval: utils.Ptr("5m"), + Name: new("test-alertgroup"), + Interval: new("5m"), }, expectErr: false, }, @@ -79,20 +78,20 @@ func TestToCreatePayload(t *testing.T) { ), }, expect: &observability.CreateAlertgroupsPayload{ - Name: utils.Ptr("full-alertgroup"), - Interval: utils.Ptr("10m"), + Name: new("full-alertgroup"), + Interval: new("10m"), Rules: &[]observability.UpdateAlertgroupsRequestInnerRulesInner{ { - Alert: utils.Ptr("alert"), - Annotations: &map[string]interface{}{ + Alert: new("alert"), + Annotations: &map[string]any{ "k": "v", }, - Expr: utils.Ptr("expression"), - For: utils.Ptr("10s"), - Labels: &map[string]interface{}{ + Expr: new("expression"), + For: new("10s"), + Labels: &map[string]any{ "k": "v", }, - Record: utils.Ptr("record"), + Record: new("record"), }, }, }, @@ -161,16 +160,16 @@ func TestToRulesPayload(t *testing.T) { }, expect: []observability.UpdateAlertgroupsRequestInnerRulesInner{ { - Alert: utils.Ptr("alert"), - Expr: utils.Ptr("expr"), - For: utils.Ptr("5s"), - Labels: &map[string]interface{}{ + Alert: new("alert"), + Expr: new("expr"), + For: new("5s"), + Labels: &map[string]any{ "key": "value", }, - Annotations: &map[string]interface{}{ + Annotations: &map[string]any{ "note": "important", }, - Record: utils.Ptr("record"), + Record: new("record"), }, }, expectErr: false, @@ -203,22 +202,22 @@ func TestToRulesPayload(t *testing.T) { }, expect: []observability.UpdateAlertgroupsRequestInnerRulesInner{ { - Alert: utils.Ptr("alert1"), - Expr: utils.Ptr("expr1"), - For: utils.Ptr("5s"), - Record: utils.Ptr("record1"), + Alert: new("alert1"), + Expr: new("expr1"), + For: new("5s"), + Record: new("record1"), }, { - Alert: utils.Ptr("alert2"), - Expr: utils.Ptr("expr2"), - For: utils.Ptr("10s"), - Labels: &map[string]interface{}{ + Alert: new("alert2"), + Expr: new("expr2"), + For: new("10s"), + Labels: &map[string]any{ "key": "value", }, - Annotations: &map[string]interface{}{ + Annotations: &map[string]any{ "note": "important", }, - Record: utils.Ptr("record2"), + Record: new("record2"), }, }, expectErr: false, @@ -265,7 +264,7 @@ func TestMapFields(t *testing.T) { { name: "Interval Missing", alertGroup: &observability.AlertGroup{ - Name: utils.Ptr("alert-group-name"), + Name: new("alert-group-name"), }, model: &Model{ Name: types.StringValue("alert-group-name"), @@ -279,7 +278,7 @@ func TestMapFields(t *testing.T) { { name: "Name Missing", alertGroup: &observability.AlertGroup{ - Interval: utils.Ptr("5m"), + Interval: new("5m"), }, model: &Model{ Name: types.StringValue("model-name"), @@ -290,8 +289,8 @@ func TestMapFields(t *testing.T) { { name: "Complete Model and AlertGroup", alertGroup: &observability.AlertGroup{ - Name: utils.Ptr("alert-group-name"), - Interval: utils.Ptr("10m"), + Name: new("alert-group-name"), + Interval: new("10m"), }, model: &Model{ Name: types.StringValue("alert-group-name"), @@ -347,12 +346,12 @@ func TestMapRules(t *testing.T) { alertGroup: &observability.AlertGroup{ Rules: &[]observability.AlertRuleRecord{ { - Alert: utils.Ptr("HighCPUUsage"), - Expr: utils.Ptr("rate(cpu_usage[5m]) > 0.9"), - For: utils.Ptr("2m"), + Alert: new("HighCPUUsage"), + Expr: new("rate(cpu_usage[5m]) > 0.9"), + For: new("2m"), Labels: &map[string]string{"severity": "critical"}, Annotations: &map[string]string{"summary": "CPU usage high"}, - Record: utils.Ptr("record1"), + Record: new("record1"), }, }, }, diff --git a/stackit/internal/services/observability/credential/resource_test.go b/stackit/internal/services/observability/credential/resource_test.go index 34ace309e..77cf67895 100644 --- a/stackit/internal/services/observability/credential/resource_test.go +++ b/stackit/internal/services/observability/credential/resource_test.go @@ -5,7 +5,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/observability" ) @@ -19,8 +18,8 @@ func TestMapFields(t *testing.T) { { "ok", &observability.Credentials{ - Username: utils.Ptr("username"), - Password: utils.Ptr("password"), + Username: new("username"), + Password: new("password"), }, Model{ Id: types.StringValue("pid,iid,username"), diff --git a/stackit/internal/services/observability/instance/resource.go b/stackit/internal/services/observability/instance/resource.go index a5c5db586..22eb677ad 100644 --- a/stackit/internal/services/observability/instance/resource.go +++ b/stackit/internal/services/observability/instance/resource.go @@ -32,7 +32,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" - sdkUtils "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/observability" "github.com/stackitcloud/stackit-sdk-go/services/observability/wait" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion" @@ -1889,25 +1888,25 @@ func mapGlobalConfigToAttributes(respGlobalConfigs *observability.Global, global if globalConfigsTF != nil { if respGlobalConfigs.SmtpSmarthost == nil && !globalConfigsTF.SmtpSmartHost.IsNull() && !globalConfigsTF.SmtpSmartHost.IsUnknown() { - smtpSmartHost = sdkUtils.Ptr(globalConfigsTF.SmtpSmartHost.ValueString()) + smtpSmartHost = new(globalConfigsTF.SmtpSmartHost.ValueString()) } if respGlobalConfigs.SmtpAuthIdentity == nil && !globalConfigsTF.SmtpAuthIdentity.IsNull() && !globalConfigsTF.SmtpAuthIdentity.IsUnknown() { - smtpAuthIdentity = sdkUtils.Ptr(globalConfigsTF.SmtpAuthIdentity.ValueString()) + smtpAuthIdentity = new(globalConfigsTF.SmtpAuthIdentity.ValueString()) } if respGlobalConfigs.SmtpAuthPassword == nil && !globalConfigsTF.SmtpAuthPassword.IsNull() && !globalConfigsTF.SmtpAuthPassword.IsUnknown() { - smtpAuthPassword = sdkUtils.Ptr(globalConfigsTF.SmtpAuthPassword.ValueString()) + smtpAuthPassword = new(globalConfigsTF.SmtpAuthPassword.ValueString()) } if respGlobalConfigs.SmtpAuthUsername == nil && !globalConfigsTF.SmtpAuthUsername.IsNull() && !globalConfigsTF.SmtpAuthUsername.IsUnknown() { - smtpAuthUsername = sdkUtils.Ptr(globalConfigsTF.SmtpAuthUsername.ValueString()) + smtpAuthUsername = new(globalConfigsTF.SmtpAuthUsername.ValueString()) } if respGlobalConfigs.OpsgenieApiKey == nil { - opsgenieApiKey = sdkUtils.Ptr(globalConfigsTF.OpsgenieApiKey.ValueString()) + opsgenieApiKey = new(globalConfigsTF.OpsgenieApiKey.ValueString()) } if respGlobalConfigs.OpsgenieApiUrl == nil { - opsgenieApiUrl = sdkUtils.Ptr(globalConfigsTF.OpsgenieApiUrl.ValueString()) + opsgenieApiUrl = new(globalConfigsTF.OpsgenieApiUrl.ValueString()) } } @@ -2154,7 +2153,7 @@ func toCreatePayload(model *Model, setGrafanaAdminEnabled bool) (*observability. return nil, fmt.Errorf("nil model") } elements := model.Parameters.Elements() - pa := make(map[string]interface{}, len(elements)) + pa := make(map[string]any, len(elements)) for k := range elements { pa[k] = elements[k].String() } @@ -2206,7 +2205,7 @@ func toUpdateMetricsStorageRetentionPayload(retentionDaysRaw, retentionDays5m, r func updateACL(ctx context.Context, projectId, instanceId string, acl []string, client *observability.APIClient) error { payload := observability.UpdateACLPayload{ - Acl: sdkUtils.Ptr(acl), + Acl: new(acl), } _, err := client.UpdateACL(ctx, instanceId, projectId).UpdateACLPayload(payload).Execute() @@ -2222,7 +2221,7 @@ func toUpdatePayload(model *Model, setGrafanaAdminEnabled bool) (*observability. return nil, fmt.Errorf("nil model") } elements := model.Parameters.Elements() - pa := make(map[string]interface{}, len(elements)) + pa := make(map[string]any, len(elements)) for k, v := range elements { pa[k] = v.String() } @@ -2439,7 +2438,7 @@ func toChildRoutePayload(ctx context.Context, routeTF *routeModelMiddle) (*obser } var groupByPayload, matchersPayload *[]string - var matchPayload, matchRegexPayload *map[string]interface{} + var matchPayload, matchRegexPayload *map[string]any if !utils.IsUndefined(routeTF.GroupBy) { groupByPayload = &[]string{} diff --git a/stackit/internal/services/observability/instance/resource_test.go b/stackit/internal/services/observability/instance/resource_test.go index 5c25d58e3..305e02da1 100644 --- a/stackit/internal/services/observability/instance/resource_test.go +++ b/stackit/internal/services/observability/instance/resource_test.go @@ -11,7 +11,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/observability" ) @@ -135,39 +134,39 @@ func fixtureNullGlobalConfigModel() basetypes.ObjectValue { func fixtureEmailConfigsPayload() observability.CreateAlertConfigReceiverPayloadEmailConfigsInner { return observability.CreateAlertConfigReceiverPayloadEmailConfigsInner{ - AuthIdentity: utils.Ptr("identity"), - AuthPassword: utils.Ptr("password"), - AuthUsername: utils.Ptr("username"), - From: utils.Ptr("notification@example.com"), - SendResolved: utils.Ptr(true), - Smarthost: utils.Ptr("smtp.example.com"), - To: utils.Ptr("me@example.com"), + AuthIdentity: new("identity"), + AuthPassword: new("password"), + AuthUsername: new("username"), + From: new("notification@example.com"), + SendResolved: new(true), + Smarthost: new("smtp.example.com"), + To: new("me@example.com"), } } func fixtureOpsGenieConfigsPayload() observability.CreateAlertConfigReceiverPayloadOpsgenieConfigsInner { return observability.CreateAlertConfigReceiverPayloadOpsgenieConfigsInner{ - ApiKey: utils.Ptr("key"), - Tags: utils.Ptr("tag"), - ApiUrl: utils.Ptr("ops.example.com"), - Priority: utils.Ptr("P3"), - SendResolved: utils.Ptr(true), + ApiKey: new("key"), + Tags: new("tag"), + ApiUrl: new("ops.example.com"), + Priority: new("P3"), + SendResolved: new(true), } } func fixtureWebHooksConfigsPayload() observability.CreateAlertConfigReceiverPayloadWebHookConfigsInner { return observability.CreateAlertConfigReceiverPayloadWebHookConfigsInner{ - Url: utils.Ptr("http://example.com"), - MsTeams: utils.Ptr(true), - GoogleChat: utils.Ptr(true), - SendResolved: utils.Ptr(true), + Url: new("http://example.com"), + MsTeams: new(true), + GoogleChat: new(true), + SendResolved: new(true), } } func fixtureReceiverPayload(emailConfigs *[]observability.CreateAlertConfigReceiverPayloadEmailConfigsInner, opsGenieConfigs *[]observability.CreateAlertConfigReceiverPayloadOpsgenieConfigsInner, webHooksConfigs *[]observability.CreateAlertConfigReceiverPayloadWebHookConfigsInner) observability.UpdateAlertConfigsPayloadReceiversInner { return observability.UpdateAlertConfigsPayloadReceiversInner{ EmailConfigs: emailConfigs, - Name: utils.Ptr("name"), + Name: new("name"), OpsgenieConfigs: opsGenieConfigs, WebHookConfigs: webHooksConfigs, } @@ -175,23 +174,23 @@ func fixtureReceiverPayload(emailConfigs *[]observability.CreateAlertConfigRecei func fixtureRoutePayload() *observability.UpdateAlertConfigsPayloadRoute { return &observability.UpdateAlertConfigsPayloadRoute{ - Continue: utils.Ptr(false), - GroupBy: utils.Ptr([]string{"label1", "label2"}), - GroupInterval: utils.Ptr("1m"), - GroupWait: utils.Ptr("1m"), - Receiver: utils.Ptr("name"), - RepeatInterval: utils.Ptr("1m"), + Continue: new(false), + GroupBy: new([]string{"label1", "label2"}), + GroupInterval: new("1m"), + GroupWait: new("1m"), + Receiver: new("name"), + RepeatInterval: new("1m"), Routes: &[]observability.UpdateAlertConfigsPayloadRouteRoutesInner{ { - Continue: utils.Ptr(false), - GroupBy: utils.Ptr([]string{"label1", "label2"}), - GroupInterval: utils.Ptr("1m"), - GroupWait: utils.Ptr("1m"), - Match: &map[string]interface{}{"key": "value"}, - MatchRe: &map[string]interface{}{"key": "value"}, + Continue: new(false), + GroupBy: new([]string{"label1", "label2"}), + GroupInterval: new("1m"), + GroupWait: new("1m"), + Match: &map[string]any{"key": "value"}, + MatchRe: &map[string]any{"key": "value"}, Matchers: &[]string{"matcher1", "matcher2"}, - Receiver: utils.Ptr("name"), - RepeatInterval: utils.Ptr("1m"), + Receiver: new("name"), + RepeatInterval: new("1m"), }, }, } @@ -199,20 +198,20 @@ func fixtureRoutePayload() *observability.UpdateAlertConfigsPayloadRoute { func fixtureGlobalConfigPayload() *observability.UpdateAlertConfigsPayloadGlobal { return &observability.UpdateAlertConfigsPayloadGlobal{ - OpsgenieApiKey: utils.Ptr("key"), - OpsgenieApiUrl: utils.Ptr("ops.example.com"), - ResolveTimeout: utils.Ptr("1m"), - SmtpAuthIdentity: utils.Ptr("identity"), - SmtpAuthUsername: utils.Ptr("username"), - SmtpAuthPassword: utils.Ptr("password"), - SmtpFrom: utils.Ptr("me@example.com"), - SmtpSmarthost: utils.Ptr("smtp.example.com:25"), + OpsgenieApiKey: new("key"), + OpsgenieApiUrl: new("ops.example.com"), + ResolveTimeout: new("1m"), + SmtpAuthIdentity: new("identity"), + SmtpAuthUsername: new("username"), + SmtpAuthPassword: new("password"), + SmtpFrom: new("me@example.com"), + SmtpSmarthost: new("smtp.example.com:25"), } } func fixtureReceiverResponse(emailConfigs *[]observability.EmailConfig, opsGenieConfigs *[]observability.OpsgenieConfig, webhookConfigs *[]observability.WebHook) observability.Receivers { return observability.Receivers{ - Name: utils.Ptr("name"), + Name: new("name"), EmailConfigs: emailConfigs, OpsgenieConfigs: opsGenieConfigs, WebHookConfigs: webhookConfigs, @@ -221,57 +220,57 @@ func fixtureReceiverResponse(emailConfigs *[]observability.EmailConfig, opsGenie func fixtureEmailConfigsResponse() observability.EmailConfig { return observability.EmailConfig{ - AuthIdentity: utils.Ptr("identity"), - AuthPassword: utils.Ptr("password"), - AuthUsername: utils.Ptr("username"), - From: utils.Ptr("notification@example.com"), - SendResolved: utils.Ptr(true), - Smarthost: utils.Ptr("smtp.example.com"), - To: utils.Ptr("me@example.com"), + AuthIdentity: new("identity"), + AuthPassword: new("password"), + AuthUsername: new("username"), + From: new("notification@example.com"), + SendResolved: new(true), + Smarthost: new("smtp.example.com"), + To: new("me@example.com"), } } func fixtureOpsGenieConfigsResponse() observability.OpsgenieConfig { return observability.OpsgenieConfig{ - ApiKey: utils.Ptr("key"), - Tags: utils.Ptr("tag"), - ApiUrl: utils.Ptr("ops.example.com"), - Priority: utils.Ptr("P3"), - SendResolved: utils.Ptr(true), + ApiKey: new("key"), + Tags: new("tag"), + ApiUrl: new("ops.example.com"), + Priority: new("P3"), + SendResolved: new(true), } } func fixtureWebHooksConfigsResponse() observability.WebHook { return observability.WebHook{ - Url: utils.Ptr("http://example.com"), - MsTeams: utils.Ptr(true), - GoogleChat: utils.Ptr(true), - SendResolved: utils.Ptr(true), + Url: new("http://example.com"), + MsTeams: new(true), + GoogleChat: new(true), + SendResolved: new(true), } } func fixtureRouteResponse() *observability.Route { return &observability.Route{ - Continue: utils.Ptr(false), - GroupBy: utils.Ptr([]string{"label1", "label2"}), - GroupInterval: utils.Ptr("1m"), - GroupWait: utils.Ptr("1m"), + Continue: new(false), + GroupBy: new([]string{"label1", "label2"}), + GroupInterval: new("1m"), + GroupWait: new("1m"), Match: &map[string]string{"key": "value"}, MatchRe: &map[string]string{"key": "value"}, Matchers: &[]string{"matcher1", "matcher2"}, - Receiver: utils.Ptr("name"), - RepeatInterval: utils.Ptr("1m"), + Receiver: new("name"), + RepeatInterval: new("1m"), Routes: &[]observability.RouteSerializer{ { - Continue: utils.Ptr(false), - GroupBy: utils.Ptr([]string{"label1", "label2"}), - GroupInterval: utils.Ptr("1m"), - GroupWait: utils.Ptr("1m"), + Continue: new(false), + GroupBy: new([]string{"label1", "label2"}), + GroupInterval: new("1m"), + GroupWait: new("1m"), Match: &map[string]string{"key": "value"}, MatchRe: &map[string]string{"key": "value"}, Matchers: &[]string{"matcher1", "matcher2"}, - Receiver: utils.Ptr("name"), - RepeatInterval: utils.Ptr("1m"), + Receiver: new("name"), + RepeatInterval: new("1m"), }, }, } @@ -279,14 +278,14 @@ func fixtureRouteResponse() *observability.Route { func fixtureGlobalConfigResponse() *observability.Global { return &observability.Global{ - OpsgenieApiKey: utils.Ptr("key"), - OpsgenieApiUrl: utils.Ptr("ops.example.com"), - ResolveTimeout: utils.Ptr("1m"), - SmtpAuthIdentity: utils.Ptr("identity"), - SmtpAuthUsername: utils.Ptr("username"), - SmtpAuthPassword: utils.Ptr("password"), - SmtpFrom: utils.Ptr("me@example.com"), - SmtpSmarthost: utils.Ptr("smtp.example.com:25"), + OpsgenieApiKey: new("key"), + OpsgenieApiUrl: new("ops.example.com"), + ResolveTimeout: new("1m"), + SmtpAuthIdentity: new("identity"), + SmtpAuthUsername: new("username"), + SmtpAuthPassword: new("password"), + SmtpFrom: new("me@example.com"), + SmtpSmarthost: new("smtp.example.com:25"), } } @@ -364,16 +363,16 @@ func TestMapFields(t *testing.T) { { "default_ok", &observability.GetInstanceResponse{ - Id: utils.Ptr("iid"), + Id: new("iid"), }, &observability.ListACLResponse{}, &observability.GetMetricsStorageRetentionResponse{ - MetricsRetentionTimeRaw: utils.Ptr("60d"), - MetricsRetentionTime1h: utils.Ptr("30d"), - MetricsRetentionTime5m: utils.Ptr("7d"), + MetricsRetentionTimeRaw: new("60d"), + MetricsRetentionTime1h: new("30d"), + MetricsRetentionTime5m: new("7d"), }, - &observability.LogsConfigResponse{Config: &observability.LogsConfig{Retention: utils.Ptr("168h")}}, - &observability.TracesConfigResponse{Config: &observability.TraceConfig{Retention: utils.Ptr("168h")}}, + &observability.LogsConfigResponse{Config: &observability.LogsConfig{Retention: new("168h")}}, + &observability.TracesConfigResponse{Config: &observability.TraceConfig{Retention: new("168h")}}, Model{ Id: types.StringValue("pid,iid"), ProjectId: types.StringValue("pid"), @@ -394,30 +393,30 @@ func TestMapFields(t *testing.T) { { "values_ok", &observability.GetInstanceResponse{ - Id: utils.Ptr("iid"), - Name: utils.Ptr("name"), - PlanName: utils.Ptr("plan1"), - PlanId: utils.Ptr("planId"), + Id: new("iid"), + Name: new("name"), + PlanName: new("plan1"), + PlanId: new("planId"), Parameters: &map[string]string{"key": "value"}, Instance: &observability.InstanceSensitiveData{ - MetricsRetentionTimeRaw: utils.Ptr(int64(60)), - MetricsRetentionTime1h: utils.Ptr(int64(30)), - MetricsRetentionTime5m: utils.Ptr(int64(7)), + MetricsRetentionTimeRaw: new(int64(60)), + MetricsRetentionTime1h: new(int64(30)), + MetricsRetentionTime5m: new(int64(7)), }, }, &observability.ListACLResponse{ Acl: &[]string{ "1.1.1.1/32", }, - Message: utils.Ptr("message"), + Message: new("message"), }, &observability.GetMetricsStorageRetentionResponse{ - MetricsRetentionTimeRaw: utils.Ptr("60d"), - MetricsRetentionTime1h: utils.Ptr("30d"), - MetricsRetentionTime5m: utils.Ptr("7d"), + MetricsRetentionTimeRaw: new("60d"), + MetricsRetentionTime1h: new("30d"), + MetricsRetentionTime5m: new("7d"), }, - &observability.LogsConfigResponse{Config: &observability.LogsConfig{Retention: utils.Ptr("168h")}}, - &observability.TracesConfigResponse{Config: &observability.TraceConfig{Retention: utils.Ptr("168h")}}, + &observability.LogsConfigResponse{Config: &observability.LogsConfig{Retention: new("168h")}}, + &observability.TracesConfigResponse{Config: &observability.TraceConfig{Retention: new("168h")}}, Model{ Id: types.StringValue("pid,iid"), ProjectId: types.StringValue("pid"), @@ -440,10 +439,10 @@ func TestMapFields(t *testing.T) { { "values_ok_multiple_acls", &observability.GetInstanceResponse{ - Id: utils.Ptr("iid"), - Name: utils.Ptr("name"), - PlanName: utils.Ptr("plan1"), - PlanId: utils.Ptr("planId"), + Id: new("iid"), + Name: new("name"), + PlanName: new("plan1"), + PlanId: new("planId"), Parameters: &map[string]string{"key": "value"}, }, &observability.ListACLResponse{ @@ -451,15 +450,15 @@ func TestMapFields(t *testing.T) { "1.1.1.1/32", "8.8.8.8/32", }, - Message: utils.Ptr("message"), + Message: new("message"), }, &observability.GetMetricsStorageRetentionResponse{ - MetricsRetentionTimeRaw: utils.Ptr("60d"), - MetricsRetentionTime1h: utils.Ptr("30d"), - MetricsRetentionTime5m: utils.Ptr("7d"), + MetricsRetentionTimeRaw: new("60d"), + MetricsRetentionTime1h: new("30d"), + MetricsRetentionTime5m: new("7d"), }, - &observability.LogsConfigResponse{Config: &observability.LogsConfig{Retention: utils.Ptr("168h")}}, - &observability.TracesConfigResponse{Config: &observability.TraceConfig{Retention: utils.Ptr("168h")}}, + &observability.LogsConfigResponse{Config: &observability.LogsConfig{Retention: new("168h")}}, + &observability.TracesConfigResponse{Config: &observability.TraceConfig{Retention: new("168h")}}, Model{ Id: types.StringValue("pid,iid"), ProjectId: types.StringValue("pid"), @@ -483,7 +482,7 @@ func TestMapFields(t *testing.T) { { "nullable_fields_ok", &observability.GetInstanceResponse{ - Id: utils.Ptr("iid"), + Id: new("iid"), Name: nil, }, &observability.ListACLResponse{ @@ -491,12 +490,12 @@ func TestMapFields(t *testing.T) { Message: nil, }, &observability.GetMetricsStorageRetentionResponse{ - MetricsRetentionTimeRaw: utils.Ptr("60d"), - MetricsRetentionTime1h: utils.Ptr("30d"), - MetricsRetentionTime5m: utils.Ptr("7d"), + MetricsRetentionTimeRaw: new("60d"), + MetricsRetentionTime1h: new("30d"), + MetricsRetentionTime5m: new("7d"), }, - &observability.LogsConfigResponse{Config: &observability.LogsConfig{Retention: utils.Ptr("168h")}}, - &observability.TracesConfigResponse{Config: &observability.TraceConfig{Retention: utils.Ptr("168h")}}, + &observability.LogsConfigResponse{Config: &observability.LogsConfig{Retention: new("168h")}}, + &observability.TracesConfigResponse{Config: &observability.TraceConfig{Retention: new("168h")}}, Model{ Id: types.StringValue("pid,iid"), ProjectId: types.StringValue("pid"), @@ -537,7 +536,7 @@ func TestMapFields(t *testing.T) { { "empty metrics retention", &observability.GetInstanceResponse{ - Id: utils.Ptr("iid"), + Id: new("iid"), Name: nil, }, &observability.ListACLResponse{ @@ -553,7 +552,7 @@ func TestMapFields(t *testing.T) { { "nil metrics retention", &observability.GetInstanceResponse{ - Id: utils.Ptr("iid"), + Id: new("iid"), Name: nil, }, &observability.ListACLResponse{ @@ -569,30 +568,30 @@ func TestMapFields(t *testing.T) { { "update metrics retention", &observability.GetInstanceResponse{ - Id: utils.Ptr("iid"), - Name: utils.Ptr("name"), - PlanName: utils.Ptr("plan1"), - PlanId: utils.Ptr("planId"), + Id: new("iid"), + Name: new("name"), + PlanName: new("plan1"), + PlanId: new("planId"), Parameters: &map[string]string{"key": "value"}, Instance: &observability.InstanceSensitiveData{ - MetricsRetentionTimeRaw: utils.Ptr(int64(30)), - MetricsRetentionTime1h: utils.Ptr(int64(15)), - MetricsRetentionTime5m: utils.Ptr(int64(10)), + MetricsRetentionTimeRaw: new(int64(30)), + MetricsRetentionTime1h: new(int64(15)), + MetricsRetentionTime5m: new(int64(10)), }, }, &observability.ListACLResponse{ Acl: &[]string{ "1.1.1.1/32", }, - Message: utils.Ptr("message"), + Message: new("message"), }, &observability.GetMetricsStorageRetentionResponse{ - MetricsRetentionTimeRaw: utils.Ptr("60d"), - MetricsRetentionTime1h: utils.Ptr("30d"), - MetricsRetentionTime5m: utils.Ptr("7d"), + MetricsRetentionTimeRaw: new("60d"), + MetricsRetentionTime1h: new("30d"), + MetricsRetentionTime5m: new("7d"), }, - &observability.LogsConfigResponse{Config: &observability.LogsConfig{Retention: utils.Ptr("480h")}}, - &observability.TracesConfigResponse{Config: &observability.TraceConfig{Retention: utils.Ptr("720h")}}, + &observability.LogsConfigResponse{Config: &observability.LogsConfig{Retention: new("480h")}}, + &observability.TracesConfigResponse{Config: &observability.TraceConfig{Retention: new("720h")}}, Model{ Id: types.StringValue("pid,iid"), ProjectId: types.StringValue("pid"), @@ -1007,10 +1006,10 @@ func TestToCreatePayload(t *testing.T) { }, true, &observability.CreateInstancePayload{ - GrafanaAdminEnabled: utils.Ptr(true), + GrafanaAdminEnabled: new(true), Name: nil, - PlanId: utils.Ptr("planId"), - Parameter: &map[string]interface{}{}, + PlanId: new("planId"), + Parameter: &map[string]any{}, }, true, }, @@ -1024,10 +1023,10 @@ func TestToCreatePayload(t *testing.T) { }, true, &observability.CreateInstancePayload{ - GrafanaAdminEnabled: utils.Ptr(false), - Name: utils.Ptr("Name"), - PlanId: utils.Ptr("planId"), - Parameter: &map[string]interface{}{"key": `"value"`}, + GrafanaAdminEnabled: new(false), + Name: new("Name"), + PlanId: new("planId"), + Parameter: &map[string]any{"key": `"value"`}, }, true, }, @@ -1040,9 +1039,9 @@ func TestToCreatePayload(t *testing.T) { }, false, &observability.CreateInstancePayload{ - Name: utils.Ptr("Name"), - PlanId: utils.Ptr("planId"), - Parameter: &map[string]interface{}{"key": `"value"`}, + Name: new("Name"), + PlanId: new("planId"), + Parameter: &map[string]any{"key": `"value"`}, }, true, }, @@ -1089,9 +1088,9 @@ func TestToPayloadUpdate(t *testing.T) { }, true, &observability.UpdateInstancePayload{ - GrafanaAdminEnabled: utils.Ptr(true), + GrafanaAdminEnabled: new(true), Name: nil, - PlanId: utils.Ptr("planId"), + PlanId: new("planId"), Parameter: &map[string]any{}, }, true, @@ -1106,9 +1105,9 @@ func TestToPayloadUpdate(t *testing.T) { }, true, &observability.UpdateInstancePayload{ - GrafanaAdminEnabled: utils.Ptr(false), - Name: utils.Ptr("Name"), - PlanId: utils.Ptr("planId"), + GrafanaAdminEnabled: new(false), + Name: new("Name"), + PlanId: new("planId"), Parameter: &map[string]any{"key": `"value"`}, }, true, @@ -1122,9 +1121,9 @@ func TestToPayloadUpdate(t *testing.T) { }, false, &observability.UpdateInstancePayload{ - Name: utils.Ptr("Name"), - PlanId: utils.Ptr("planId"), - Parameter: &map[string]interface{}{"key": `"value"`}, + Name: new("Name"), + PlanId: new("planId"), + Parameter: &map[string]any{"key": `"value"`}, }, true, }, @@ -1167,52 +1166,52 @@ func TestToUpdateMetricsStorageRetentionPayload(t *testing.T) { }{ { "basic_ok", - utils.Ptr(int64(120)), - utils.Ptr(int64(60)), - utils.Ptr(int64(14)), + new(int64(120)), + new(int64(60)), + new(int64(14)), &observability.GetMetricsStorageRetentionResponse{ - MetricsRetentionTimeRaw: utils.Ptr("60d"), - MetricsRetentionTime1h: utils.Ptr("30d"), - MetricsRetentionTime5m: utils.Ptr("7d"), + MetricsRetentionTimeRaw: new("60d"), + MetricsRetentionTime1h: new("30d"), + MetricsRetentionTime5m: new("7d"), }, &observability.UpdateMetricsStorageRetentionPayload{ - MetricsRetentionTimeRaw: utils.Ptr("120d"), - MetricsRetentionTime1h: utils.Ptr("60d"), - MetricsRetentionTime5m: utils.Ptr("14d"), + MetricsRetentionTimeRaw: new("120d"), + MetricsRetentionTime1h: new("60d"), + MetricsRetentionTime5m: new("14d"), }, true, }, { "only_raw_given", - utils.Ptr(int64(120)), + new(int64(120)), nil, nil, &observability.GetMetricsStorageRetentionResponse{ - MetricsRetentionTimeRaw: utils.Ptr("60d"), - MetricsRetentionTime1h: utils.Ptr("30d"), - MetricsRetentionTime5m: utils.Ptr("7d"), + MetricsRetentionTimeRaw: new("60d"), + MetricsRetentionTime1h: new("30d"), + MetricsRetentionTime5m: new("7d"), }, &observability.UpdateMetricsStorageRetentionPayload{ - MetricsRetentionTimeRaw: utils.Ptr("120d"), - MetricsRetentionTime1h: utils.Ptr("30d"), - MetricsRetentionTime5m: utils.Ptr("7d"), + MetricsRetentionTimeRaw: new("120d"), + MetricsRetentionTime1h: new("30d"), + MetricsRetentionTime5m: new("7d"), }, true, }, { "only_1h_given", nil, - utils.Ptr(int64(60)), + new(int64(60)), nil, &observability.GetMetricsStorageRetentionResponse{ - MetricsRetentionTimeRaw: utils.Ptr("60d"), - MetricsRetentionTime1h: utils.Ptr("30d"), - MetricsRetentionTime5m: utils.Ptr("7d"), + MetricsRetentionTimeRaw: new("60d"), + MetricsRetentionTime1h: new("30d"), + MetricsRetentionTime5m: new("7d"), }, &observability.UpdateMetricsStorageRetentionPayload{ - MetricsRetentionTimeRaw: utils.Ptr("60d"), - MetricsRetentionTime1h: utils.Ptr("60d"), - MetricsRetentionTime5m: utils.Ptr("7d"), + MetricsRetentionTimeRaw: new("60d"), + MetricsRetentionTime1h: new("60d"), + MetricsRetentionTime5m: new("7d"), }, true, }, @@ -1220,16 +1219,16 @@ func TestToUpdateMetricsStorageRetentionPayload(t *testing.T) { "only_5m_given", nil, nil, - utils.Ptr(int64(14)), + new(int64(14)), &observability.GetMetricsStorageRetentionResponse{ - MetricsRetentionTimeRaw: utils.Ptr("60d"), - MetricsRetentionTime1h: utils.Ptr("30d"), - MetricsRetentionTime5m: utils.Ptr("7d"), + MetricsRetentionTimeRaw: new("60d"), + MetricsRetentionTime1h: new("30d"), + MetricsRetentionTime5m: new("7d"), }, &observability.UpdateMetricsStorageRetentionPayload{ - MetricsRetentionTimeRaw: utils.Ptr("60d"), - MetricsRetentionTime1h: utils.Ptr("30d"), - MetricsRetentionTime5m: utils.Ptr("14d"), + MetricsRetentionTimeRaw: new("60d"), + MetricsRetentionTime1h: new("30d"), + MetricsRetentionTime5m: new("14d"), }, true, }, @@ -1239,14 +1238,14 @@ func TestToUpdateMetricsStorageRetentionPayload(t *testing.T) { nil, nil, &observability.GetMetricsStorageRetentionResponse{ - MetricsRetentionTimeRaw: utils.Ptr("60d"), - MetricsRetentionTime1h: utils.Ptr("30d"), - MetricsRetentionTime5m: utils.Ptr("7d"), + MetricsRetentionTimeRaw: new("60d"), + MetricsRetentionTime1h: new("30d"), + MetricsRetentionTime5m: new("7d"), }, &observability.UpdateMetricsStorageRetentionPayload{ - MetricsRetentionTimeRaw: utils.Ptr("60d"), - MetricsRetentionTime1h: utils.Ptr("30d"), - MetricsRetentionTime5m: utils.Ptr("7d"), + MetricsRetentionTimeRaw: new("60d"), + MetricsRetentionTime1h: new("30d"), + MetricsRetentionTime5m: new("7d"), }, true, }, diff --git a/stackit/internal/services/observability/log-alertgroup/resource_test.go b/stackit/internal/services/observability/log-alertgroup/resource_test.go index 39047012b..d76a2263a 100644 --- a/stackit/internal/services/observability/log-alertgroup/resource_test.go +++ b/stackit/internal/services/observability/log-alertgroup/resource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/observability" ) @@ -41,8 +40,8 @@ func TestToCreatePayload(t *testing.T) { Interval: types.StringValue("5m"), }, expect: &observability.CreateLogsAlertgroupsPayload{ - Name: utils.Ptr("test-alertgroup"), - Interval: utils.Ptr("5m"), + Name: new("test-alertgroup"), + Interval: new("5m"), }, expectErr: false, }, @@ -78,17 +77,17 @@ func TestToCreatePayload(t *testing.T) { ), }, expect: &observability.CreateLogsAlertgroupsPayload{ - Name: utils.Ptr("full-alertgroup"), - Interval: utils.Ptr("10m"), + Name: new("full-alertgroup"), + Interval: new("10m"), Rules: &[]observability.CreateLogsAlertgroupsPayloadRulesInner{ { - Alert: utils.Ptr("alert"), - Annotations: &map[string]interface{}{ + Alert: new("alert"), + Annotations: &map[string]any{ "k": "v", }, - Expr: utils.Ptr("expression"), - For: utils.Ptr("10s"), - Labels: &map[string]interface{}{ + Expr: new("expression"), + For: new("10s"), + Labels: &map[string]any{ "k": "v", }, }, @@ -158,13 +157,13 @@ func TestToRulesPayload(t *testing.T) { }, expect: []observability.CreateLogsAlertgroupsPayloadRulesInner{ { - Alert: utils.Ptr("alert"), - Expr: utils.Ptr("expr"), - For: utils.Ptr("5s"), - Labels: &map[string]interface{}{ + Alert: new("alert"), + Expr: new("expr"), + For: new("5s"), + Labels: &map[string]any{ "key": "value", }, - Annotations: &map[string]interface{}{ + Annotations: &map[string]any{ "note": "important", }, }, @@ -197,18 +196,18 @@ func TestToRulesPayload(t *testing.T) { }, expect: []observability.CreateLogsAlertgroupsPayloadRulesInner{ { - Alert: utils.Ptr("alert1"), - Expr: utils.Ptr("expr1"), - For: utils.Ptr("5s"), + Alert: new("alert1"), + Expr: new("expr1"), + For: new("5s"), }, { - Alert: utils.Ptr("alert2"), - Expr: utils.Ptr("expr2"), - For: utils.Ptr("10s"), - Labels: &map[string]interface{}{ + Alert: new("alert2"), + Expr: new("expr2"), + For: new("10s"), + Labels: &map[string]any{ "key": "value", }, - Annotations: &map[string]interface{}{ + Annotations: &map[string]any{ "note": "important", }, }, @@ -257,7 +256,7 @@ func TestMapFields(t *testing.T) { { name: "Interval Missing", alertGroup: &observability.AlertGroup{ - Name: utils.Ptr("alert-group-name"), + Name: new("alert-group-name"), }, model: &Model{ Name: types.StringValue("alert-group-name"), @@ -271,7 +270,7 @@ func TestMapFields(t *testing.T) { { name: "Name Missing", alertGroup: &observability.AlertGroup{ - Interval: utils.Ptr("5m"), + Interval: new("5m"), }, model: &Model{ Name: types.StringValue("model-name"), @@ -282,8 +281,8 @@ func TestMapFields(t *testing.T) { { name: "Complete Model and AlertGroup", alertGroup: &observability.AlertGroup{ - Name: utils.Ptr("alert-group-name"), - Interval: utils.Ptr("10m"), + Name: new("alert-group-name"), + Interval: new("10m"), }, model: &Model{ Name: types.StringValue("alert-group-name"), @@ -339,12 +338,12 @@ func TestMapRules(t *testing.T) { alertGroup: &observability.AlertGroup{ Rules: &[]observability.AlertRuleRecord{ { - Alert: utils.Ptr("HighCPUUsage"), - Expr: utils.Ptr("rate(cpu_usage[5m]) > 0.9"), - For: utils.Ptr("2m"), + Alert: new("HighCPUUsage"), + Expr: new("rate(cpu_usage[5m]) > 0.9"), + For: new("2m"), Labels: &map[string]string{"severity": "critical"}, Annotations: &map[string]string{"summary": "CPU usage high"}, - Record: utils.Ptr("record1"), + Record: new("record1"), }, }, }, diff --git a/stackit/internal/services/observability/observability_test.go b/stackit/internal/services/observability/observability_test.go index 2a7778320..f2552a30f 100644 --- a/stackit/internal/services/observability/observability_test.go +++ b/stackit/internal/services/observability/observability_test.go @@ -40,10 +40,10 @@ resource "stackit_observability_instance" "instance" { planList := testutil.MockResponse{ Description: "plan list", ToJsonBody: observability.PlansResponse{ - Plans: utils.Ptr([]observability.Plan{ + Plans: new([]observability.Plan{ { Name: utils.Ptr(planName), - PlanId: utils.Ptr(planId), + PlanId: new(planId), }, }), }, @@ -61,7 +61,7 @@ resource "stackit_observability_instance" "instance" { testutil.MockResponse{ Description: "create instance", ToJsonBody: observability.CreateInstanceResponse{ - InstanceId: utils.Ptr(instanceId), + InstanceId: new(instanceId), }, }, testutil.MockResponse{ @@ -90,7 +90,7 @@ resource "stackit_observability_instance" "instance" { testutil.MockResponse{ Description: "delete waiter", ToJsonBody: observability.GetInstanceResponse{ - Id: utils.Ptr(instanceId), + Id: new(instanceId), Status: observability.GETINSTANCERESPONSESTATUS_DELETE_SUCCEEDED.Ptr(), }, }, @@ -170,7 +170,7 @@ resource "stackit_observability_scrapeconfig" "instance" { testutil.MockResponse{ Description: "delete waiter", ToJsonBody: observability.ListScrapeConfigsResponse{ - Data: utils.Ptr([]observability.Job{}), + Data: new([]observability.Job{}), }, }, ) diff --git a/stackit/internal/services/observability/scrapeconfig/resource.go b/stackit/internal/services/observability/scrapeconfig/resource.go index af1f0654e..4b74bcd48 100644 --- a/stackit/internal/services/observability/scrapeconfig/resource.go +++ b/stackit/internal/services/observability/scrapeconfig/resource.go @@ -29,7 +29,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" - sdkUtils "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/observability" "github.com/stackitcloud/stackit-sdk-go/services/observability/wait" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion" @@ -722,13 +721,13 @@ func toCreatePayload(ctx context.Context, model *Model, saml2Model *saml2Model, ScrapeInterval: conversion.StringValueToPointer(model.ScrapeInterval), ScrapeTimeout: conversion.StringValueToPointer(model.ScrapeTimeout), // potentially lossy conversion, depending on the allowed range for sample_limit - SampleLimit: sdkUtils.Ptr(float64(model.SampleLimit.ValueInt64())), + SampleLimit: new(float64(model.SampleLimit.ValueInt64())), Scheme: observability.CreateScrapeConfigPayloadGetSchemeAttributeType(conversion.StringValueToPointer(model.Scheme)), } setDefaultsCreateScrapeConfig(&sc, model, saml2Model) if !saml2Model.EnableURLParameters.IsNull() && !saml2Model.EnableURLParameters.IsUnknown() { - m := make(map[string]interface{}) + m := make(map[string]any) if sc.Params != nil { m = *sc.Params } @@ -758,7 +757,7 @@ func toCreatePayload(ctx context.Context, model *Model, saml2Model *saml2Model, } ti.Targets = &urls - labels := map[string]interface{}{} + labels := map[string]any{} for k, v := range target.Labels.Elements() { labels[k], _ = conversion.ToString(ctx, v) } @@ -778,17 +777,17 @@ func setDefaultsCreateScrapeConfig(sc *observability.CreateScrapeConfigPayload, sc.Scheme = DefaultScheme.Ptr() } if model.ScrapeInterval.IsNull() || model.ScrapeInterval.IsUnknown() { - sc.ScrapeInterval = sdkUtils.Ptr(DefaultScrapeInterval) + sc.ScrapeInterval = new(DefaultScrapeInterval) } if model.ScrapeTimeout.IsNull() || model.ScrapeTimeout.IsUnknown() { - sc.ScrapeTimeout = sdkUtils.Ptr(DefaultScrapeTimeout) + sc.ScrapeTimeout = new(DefaultScrapeTimeout) } if model.SampleLimit.IsNull() || model.SampleLimit.IsUnknown() { - sc.SampleLimit = sdkUtils.Ptr(float64(DefaultSampleLimit)) + sc.SampleLimit = new(float64(DefaultSampleLimit)) } // Make the API default more explicit by setting the field. if saml2Model.EnableURLParameters.IsNull() || saml2Model.EnableURLParameters.IsUnknown() { - m := map[string]interface{}{} + m := map[string]any{} if sc.Params != nil { m = *sc.Params } @@ -811,13 +810,13 @@ func toUpdatePayload(ctx context.Context, model *Model, saml2Model *saml2Model, ScrapeInterval: conversion.StringValueToPointer(model.ScrapeInterval), ScrapeTimeout: conversion.StringValueToPointer(model.ScrapeTimeout), // potentially lossy conversion, depending on the allowed range for sample_limit - SampleLimit: sdkUtils.Ptr(float64(model.SampleLimit.ValueInt64())), + SampleLimit: new(float64(model.SampleLimit.ValueInt64())), Scheme: observability.UpdateScrapeConfigPayloadGetSchemeAttributeType(conversion.StringValueToPointer(model.Scheme)), } setDefaultsUpdateScrapeConfig(&sc, model) if !saml2Model.EnableURLParameters.IsNull() && !saml2Model.EnableURLParameters.IsUnknown() { - m := make(map[string]interface{}) + m := make(map[string]any) if sc.Params != nil { m = *sc.Params } @@ -847,7 +846,7 @@ func toUpdatePayload(ctx context.Context, model *Model, saml2Model *saml2Model, } ti.Targets = &urls - ls := map[string]interface{}{} + ls := map[string]any{} for k, v := range target.Labels.Elements() { ls[k], _ = conversion.ToString(ctx, v) } @@ -867,12 +866,12 @@ func setDefaultsUpdateScrapeConfig(sc *observability.UpdateScrapeConfigPayload, sc.Scheme = observability.UpdateScrapeConfigPayloadGetSchemeAttributeType(DefaultScheme.Ptr()) } if model.ScrapeInterval.IsNull() || model.ScrapeInterval.IsUnknown() { - sc.ScrapeInterval = sdkUtils.Ptr(DefaultScrapeInterval) + sc.ScrapeInterval = new(DefaultScrapeInterval) } if model.ScrapeTimeout.IsNull() || model.ScrapeTimeout.IsUnknown() { - sc.ScrapeTimeout = sdkUtils.Ptr(DefaultScrapeTimeout) + sc.ScrapeTimeout = new(DefaultScrapeTimeout) } if model.SampleLimit.IsNull() || model.SampleLimit.IsUnknown() { - sc.SampleLimit = sdkUtils.Ptr(float64(DefaultSampleLimit)) + sc.SampleLimit = new(float64(DefaultSampleLimit)) } } diff --git a/stackit/internal/services/observability/scrapeconfig/resource_test.go b/stackit/internal/services/observability/scrapeconfig/resource_test.go index bd74f04a1..c5279bbf4 100644 --- a/stackit/internal/services/observability/scrapeconfig/resource_test.go +++ b/stackit/internal/services/observability/scrapeconfig/resource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/observability" ) @@ -21,7 +20,7 @@ func TestMapFields(t *testing.T) { { "default_ok", &observability.Job{ - JobName: utils.Ptr("name"), + JobName: new("name"), }, Model{ Id: types.StringValue("pid,iid,name"), @@ -41,17 +40,17 @@ func TestMapFields(t *testing.T) { { description: "values_ok", input: &observability.Job{ - JobName: utils.Ptr("name"), - MetricsPath: utils.Ptr("/m"), + JobName: new("name"), + MetricsPath: new("/m"), BasicAuth: &observability.BasicAuth{ - Password: utils.Ptr("p"), - Username: utils.Ptr("u"), + Password: new("p"), + Username: new("u"), }, Params: &map[string][]string{"saml2": {"disabled"}, "x": {"y", "z"}}, Scheme: observability.JOBSCHEME_HTTP.Ptr(), - ScrapeInterval: utils.Ptr("1"), - ScrapeTimeout: utils.Ptr("2"), - SampleLimit: utils.Ptr(int64(17)), + ScrapeInterval: new("1"), + ScrapeTimeout: new("2"), + SampleLimit: new(int64(17)), StaticConfigs: &[]observability.StaticConfigs{ { Labels: &map[string]string{"k1": "v1"}, @@ -161,12 +160,12 @@ func TestToCreatePayload(t *testing.T) { &basicAuthModel{}, []targetModel{}, &observability.CreateScrapeConfigPayload{ - MetricsPath: utils.Ptr("/metrics"), + MetricsPath: new("/metrics"), // Defaults Scheme: observability.CREATESCRAPECONFIGPAYLOADSCHEME_HTTP.Ptr(), - ScrapeInterval: utils.Ptr("5m"), - ScrapeTimeout: utils.Ptr("2m"), - SampleLimit: utils.Ptr(float64(5000)), + ScrapeInterval: new("5m"), + ScrapeTimeout: new("2m"), + SampleLimit: new(float64(5000)), StaticConfigs: &[]observability.PartialUpdateScrapeConfigsRequestInnerStaticConfigsInner{}, Params: &map[string]any{"saml2": []string{"enabled"}}, }, @@ -184,14 +183,14 @@ func TestToCreatePayload(t *testing.T) { &basicAuthModel{}, []targetModel{}, &observability.CreateScrapeConfigPayload{ - MetricsPath: utils.Ptr("/metrics"), - JobName: utils.Ptr("Name"), + MetricsPath: new("/metrics"), + JobName: new("Name"), Params: &map[string]any{"saml2": []string{"disabled"}}, // Defaults Scheme: observability.CREATESCRAPECONFIGPAYLOADSCHEME_HTTP.Ptr(), - ScrapeInterval: utils.Ptr("5m"), - ScrapeTimeout: utils.Ptr("2m"), - SampleLimit: utils.Ptr(float64(5000)), + ScrapeInterval: new("5m"), + ScrapeTimeout: new("2m"), + SampleLimit: new(float64(5000)), StaticConfigs: &[]observability.PartialUpdateScrapeConfigsRequestInnerStaticConfigsInner{}, }, true, @@ -208,14 +207,14 @@ func TestToCreatePayload(t *testing.T) { &basicAuthModel{}, []targetModel{}, &observability.CreateScrapeConfigPayload{ - MetricsPath: utils.Ptr("/metrics"), - JobName: utils.Ptr("Name"), + MetricsPath: new("/metrics"), + JobName: new("Name"), Params: &map[string]any{"saml2": []string{"enabled"}}, // Defaults Scheme: observability.CREATESCRAPECONFIGPAYLOADSCHEME_HTTP.Ptr(), - ScrapeInterval: utils.Ptr("5m"), - ScrapeTimeout: utils.Ptr("2m"), - SampleLimit: utils.Ptr(float64(5000)), + ScrapeInterval: new("5m"), + ScrapeTimeout: new("2m"), + SampleLimit: new(float64(5000)), StaticConfigs: &[]observability.PartialUpdateScrapeConfigsRequestInnerStaticConfigsInner{}, }, true, @@ -233,17 +232,17 @@ func TestToCreatePayload(t *testing.T) { }, []targetModel{}, &observability.CreateScrapeConfigPayload{ - MetricsPath: utils.Ptr("/metrics"), - JobName: utils.Ptr("Name"), + MetricsPath: new("/metrics"), + JobName: new("Name"), BasicAuth: &observability.PartialUpdateScrapeConfigsRequestInnerBasicAuth{ - Username: utils.Ptr("u"), - Password: utils.Ptr("p"), + Username: new("u"), + Password: new("p"), }, // Defaults Scheme: observability.CREATESCRAPECONFIGPAYLOADSCHEME_HTTP.Ptr(), - ScrapeInterval: utils.Ptr("5m"), - ScrapeTimeout: utils.Ptr("2m"), - SampleLimit: utils.Ptr(float64(5000)), + ScrapeInterval: new("5m"), + ScrapeTimeout: new("2m"), + SampleLimit: new(float64(5000)), StaticConfigs: &[]observability.PartialUpdateScrapeConfigsRequestInnerStaticConfigsInner{}, Params: &map[string]any{"saml2": []string{"enabled"}}, }, @@ -272,27 +271,27 @@ func TestToCreatePayload(t *testing.T) { }, }, &observability.CreateScrapeConfigPayload{ - MetricsPath: utils.Ptr("/metrics"), - JobName: utils.Ptr("Name"), + MetricsPath: new("/metrics"), + JobName: new("Name"), StaticConfigs: &[]observability.PartialUpdateScrapeConfigsRequestInnerStaticConfigsInner{ { Targets: &[]string{"url1"}, - Labels: &map[string]interface{}{"k1": "v1"}, + Labels: &map[string]any{"k1": "v1"}, }, { Targets: &[]string{"url1", "url3"}, - Labels: &map[string]interface{}{"k2": "v2", "k3": "v3"}, + Labels: &map[string]any{"k2": "v2", "k3": "v3"}, }, { Targets: &[]string{}, - Labels: &map[string]interface{}{}, + Labels: &map[string]any{}, }, }, // Defaults Scheme: observability.CREATESCRAPECONFIGPAYLOADSCHEME_HTTP.Ptr(), - ScrapeInterval: utils.Ptr("5m"), - ScrapeTimeout: utils.Ptr("2m"), - SampleLimit: utils.Ptr(float64(5000)), + ScrapeInterval: new("5m"), + ScrapeTimeout: new("2m"), + SampleLimit: new(float64(5000)), Params: &map[string]any{"saml2": []string{"enabled"}}, }, true, @@ -345,12 +344,12 @@ func TestToUpdatePayload(t *testing.T) { &basicAuthModel{}, []targetModel{}, &observability.UpdateScrapeConfigPayload{ - MetricsPath: utils.Ptr("/metrics"), + MetricsPath: new("/metrics"), // Defaults Scheme: observability.UPDATESCRAPECONFIGPAYLOADSCHEME_HTTP.Ptr(), - ScrapeInterval: utils.Ptr("5m"), - ScrapeTimeout: utils.Ptr("2m"), - SampleLimit: utils.Ptr(float64(5000)), + ScrapeInterval: new("5m"), + ScrapeTimeout: new("2m"), + SampleLimit: new(float64(5000)), StaticConfigs: &[]observability.UpdateScrapeConfigPayloadStaticConfigsInner{}, }, true, @@ -367,12 +366,12 @@ func TestToUpdatePayload(t *testing.T) { &basicAuthModel{}, []targetModel{}, &observability.UpdateScrapeConfigPayload{ - MetricsPath: utils.Ptr("/metrics"), + MetricsPath: new("/metrics"), // Defaults Scheme: observability.UPDATESCRAPECONFIGPAYLOADSCHEME_HTTP.Ptr(), - ScrapeInterval: utils.Ptr("5m"), - ScrapeTimeout: utils.Ptr("2m"), - SampleLimit: utils.Ptr(float64(5000)), + ScrapeInterval: new("5m"), + ScrapeTimeout: new("2m"), + SampleLimit: new(float64(5000)), StaticConfigs: &[]observability.UpdateScrapeConfigPayloadStaticConfigsInner{}, Params: &map[string]any{"saml2": []string{"enabled"}}, }, @@ -390,12 +389,12 @@ func TestToUpdatePayload(t *testing.T) { &basicAuthModel{}, []targetModel{}, &observability.UpdateScrapeConfigPayload{ - MetricsPath: utils.Ptr("/metrics"), + MetricsPath: new("/metrics"), // Defaults Scheme: observability.UPDATESCRAPECONFIGPAYLOADSCHEME_HTTP.Ptr(), - ScrapeInterval: utils.Ptr("5m"), - ScrapeTimeout: utils.Ptr("2m"), - SampleLimit: utils.Ptr(float64(5000)), + ScrapeInterval: new("5m"), + ScrapeTimeout: new("2m"), + SampleLimit: new(float64(5000)), StaticConfigs: &[]observability.UpdateScrapeConfigPayloadStaticConfigsInner{}, Params: &map[string]any{"saml2": []string{"disabled"}}, }, @@ -414,16 +413,16 @@ func TestToUpdatePayload(t *testing.T) { }, []targetModel{}, &observability.UpdateScrapeConfigPayload{ - MetricsPath: utils.Ptr("/metrics"), + MetricsPath: new("/metrics"), BasicAuth: &observability.PartialUpdateScrapeConfigsRequestInnerBasicAuth{ - Username: utils.Ptr("u"), - Password: utils.Ptr("p"), + Username: new("u"), + Password: new("p"), }, // Defaults Scheme: observability.UPDATESCRAPECONFIGPAYLOADSCHEME_HTTP.Ptr(), - ScrapeInterval: utils.Ptr("5m"), - ScrapeTimeout: utils.Ptr("2m"), - SampleLimit: utils.Ptr(float64(5000)), + ScrapeInterval: new("5m"), + ScrapeTimeout: new("2m"), + SampleLimit: new(float64(5000)), StaticConfigs: &[]observability.UpdateScrapeConfigPayloadStaticConfigsInner{}, }, true, @@ -451,26 +450,26 @@ func TestToUpdatePayload(t *testing.T) { }, }, &observability.UpdateScrapeConfigPayload{ - MetricsPath: utils.Ptr("/metrics"), + MetricsPath: new("/metrics"), StaticConfigs: &[]observability.UpdateScrapeConfigPayloadStaticConfigsInner{ { Targets: &[]string{"url1"}, - Labels: &map[string]interface{}{"k1": "v1"}, + Labels: &map[string]any{"k1": "v1"}, }, { Targets: &[]string{"url1", "url3"}, - Labels: &map[string]interface{}{"k2": "v2", "k3": "v3"}, + Labels: &map[string]any{"k2": "v2", "k3": "v3"}, }, { Targets: &[]string{}, - Labels: &map[string]interface{}{}, + Labels: &map[string]any{}, }, }, // Defaults Scheme: observability.UPDATESCRAPECONFIGPAYLOADSCHEME_HTTP.Ptr(), - ScrapeInterval: utils.Ptr("5m"), - ScrapeTimeout: utils.Ptr("2m"), - SampleLimit: utils.Ptr(float64(5000)), + ScrapeInterval: new("5m"), + ScrapeTimeout: new("2m"), + SampleLimit: new(float64(5000)), }, true, }, diff --git a/stackit/internal/services/opensearch/credential/resource_test.go b/stackit/internal/services/opensearch/credential/resource_test.go index baab02521..c07494bda 100644 --- a/stackit/internal/services/opensearch/credential/resource_test.go +++ b/stackit/internal/services/opensearch/credential/resource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/opensearch" ) @@ -26,7 +25,7 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue("pid"), }, &opensearch.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), Raw: &opensearch.RawCredentials{}, }, Model{ @@ -51,19 +50,19 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue("pid"), }, &opensearch.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), Raw: &opensearch.RawCredentials{ Credentials: &opensearch.Credentials{ - Host: utils.Ptr("host"), + Host: new("host"), Hosts: &[]string{ "host_1", "", }, - Password: utils.Ptr("password"), - Port: utils.Ptr(int64(1234)), - Scheme: utils.Ptr("scheme"), - Uri: utils.Ptr("uri"), - Username: utils.Ptr("username"), + Password: new("password"), + Port: new(int64(1234)), + Scheme: new("scheme"), + Uri: new("uri"), + Username: new("username"), }, }, }, @@ -97,20 +96,20 @@ func TestMapFields(t *testing.T) { }), }, &opensearch.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), Raw: &opensearch.RawCredentials{ Credentials: &opensearch.Credentials{ - Host: utils.Ptr("host"), + Host: new("host"), Hosts: &[]string{ "", "host_1", "host_2", }, - Password: utils.Ptr("password"), - Port: utils.Ptr(int64(1234)), - Scheme: utils.Ptr("scheme"), - Uri: utils.Ptr("uri"), - Username: utils.Ptr("username"), + Password: new("password"), + Port: new(int64(1234)), + Scheme: new("scheme"), + Uri: new("uri"), + Username: new("username"), }, }, }, @@ -140,16 +139,16 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue("pid"), }, &opensearch.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), Raw: &opensearch.RawCredentials{ Credentials: &opensearch.Credentials{ - Host: utils.Ptr(""), + Host: new(""), Hosts: &[]string{}, - Password: utils.Ptr(""), - Port: utils.Ptr(int64(2123456789)), + Password: new(""), + Port: new(int64(2123456789)), Scheme: nil, Uri: nil, - Username: utils.Ptr(""), + Username: new(""), }, }, }, @@ -195,7 +194,7 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue("pid"), }, &opensearch.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), }, Model{}, false, diff --git a/stackit/internal/services/opensearch/instance/resource.go b/stackit/internal/services/opensearch/instance/resource.go index 844216c79..372088f3a 100644 --- a/stackit/internal/services/opensearch/instance/resource.go +++ b/stackit/internal/services/opensearch/instance/resource.go @@ -609,10 +609,10 @@ func mapFields(instance *opensearch.Instance, model *Model) error { return nil } -func mapParameters(params map[string]interface{}) (types.Object, error) { +func mapParameters(params map[string]any) (types.Object, error) { attributes := map[string]attr.Value{} for attribute := range parametersTypes { - var valueInterface interface{} + var valueInterface any var ok bool // This replacement is necessary because Terraform does not allow hyphens in attribute names @@ -693,7 +693,7 @@ func mapParameters(params map[string]interface{}) (types.Object, error) { for _, x := range temp { valueList = append(valueList, types.StringValue(x)) } - case []interface{}: + case []any: for _, x := range temp { xString, ok := x.(string) if !ok { diff --git a/stackit/internal/services/opensearch/instance/resource_test.go b/stackit/internal/services/opensearch/instance/resource_test.go index 82dd9b4d9..4d2535ee9 100644 --- a/stackit/internal/services/opensearch/instance/resource_test.go +++ b/stackit/internal/services/opensearch/instance/resource_test.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/opensearch" ) @@ -59,16 +58,16 @@ var fixtureNullModelParameters = types.ObjectValueMust(parametersTypes, map[stri }) var fixtureInstanceParameters = opensearch.InstanceParameters{ - SgwAcl: utils.Ptr("acl"), - EnableMonitoring: utils.Ptr(true), - Graphite: utils.Ptr("graphite"), + SgwAcl: new("acl"), + EnableMonitoring: new(true), + Graphite: new("graphite"), JavaGarbageCollector: opensearch.INSTANCEPARAMETERSJAVA_GARBAGE_COLLECTOR_USE_G1_GC.Ptr(), - JavaHeapspace: utils.Ptr(int64(10)), - JavaMaxmetaspace: utils.Ptr(int64(10)), - MaxDiskThreshold: utils.Ptr(int64(10)), - MetricsFrequency: utils.Ptr(int64(10)), - MetricsPrefix: utils.Ptr("prefix"), - MonitoringInstanceId: utils.Ptr("mid"), + JavaHeapspace: new(int64(10)), + JavaMaxmetaspace: new(int64(10)), + MaxDiskThreshold: new(int64(10)), + MetricsFrequency: new(int64(10)), + MetricsPrefix: new("prefix"), + MonitoringInstanceId: new("mid"), Plugins: &[]string{"plugin", "plugin2"}, Syslog: &[]string{"syslog", "syslog2"}, TlsCiphers: &[]string{"cipher", "cipher2"}, @@ -103,15 +102,15 @@ func TestMapFields(t *testing.T) { { "simple_values", &opensearch.Instance{ - PlanId: utils.Ptr("plan"), - CfGuid: utils.Ptr("cf"), - CfSpaceGuid: utils.Ptr("space"), - DashboardUrl: utils.Ptr("dashboard"), - ImageUrl: utils.Ptr("image"), - InstanceId: utils.Ptr("iid"), - Name: utils.Ptr("name"), - CfOrganizationGuid: utils.Ptr("org"), - Parameters: &map[string]interface{}{ + PlanId: new("plan"), + CfGuid: new("cf"), + CfSpaceGuid: new("space"), + DashboardUrl: new("dashboard"), + ImageUrl: new("image"), + InstanceId: new("iid"), + Name: new("name"), + CfOrganizationGuid: new("org"), + Parameters: &map[string]any{ // Using "-" on purpose on some fields because that is the API response "sgw_acl": "acl", "enable_monitoring": true, @@ -159,7 +158,7 @@ func TestMapFields(t *testing.T) { { "wrong_param_types_1", &opensearch.Instance{ - Parameters: &map[string]interface{}{ + Parameters: &map[string]any{ "sgw_acl": true, }, }, @@ -169,7 +168,7 @@ func TestMapFields(t *testing.T) { { "wrong_param_types_2", &opensearch.Instance{ - Parameters: &map[string]interface{}{ + Parameters: &map[string]any{ "sgw_acl": 1, }, }, @@ -221,9 +220,9 @@ func TestToCreatePayload(t *testing.T) { Parameters: fixtureModelParameters, }, &opensearch.CreateInstancePayload{ - InstanceName: utils.Ptr("name"), + InstanceName: new("name"), Parameters: &fixtureInstanceParameters, - PlanId: utils.Ptr("plan"), + PlanId: new("plan"), }, true, }, @@ -235,9 +234,9 @@ func TestToCreatePayload(t *testing.T) { Parameters: fixtureNullModelParameters, }, &opensearch.CreateInstancePayload{ - InstanceName: utils.Ptr(""), + InstanceName: new(""), Parameters: &opensearch.InstanceParameters{}, - PlanId: utils.Ptr(""), + PlanId: new(""), }, true, }, @@ -254,8 +253,8 @@ func TestToCreatePayload(t *testing.T) { PlanId: types.StringValue("plan"), }, &opensearch.CreateInstancePayload{ - InstanceName: utils.Ptr("name"), - PlanId: utils.Ptr("plan"), + InstanceName: new("name"), + PlanId: new("plan"), }, true, }, @@ -310,7 +309,7 @@ func TestToUpdatePayload(t *testing.T) { }, &opensearch.PartialUpdateInstancePayload{ Parameters: &fixtureInstanceParameters, - PlanId: utils.Ptr("plan"), + PlanId: new("plan"), }, true, }, @@ -322,7 +321,7 @@ func TestToUpdatePayload(t *testing.T) { }, &opensearch.PartialUpdateInstancePayload{ Parameters: &opensearch.InstanceParameters{}, - PlanId: utils.Ptr(""), + PlanId: new(""), }, true, }, @@ -338,7 +337,7 @@ func TestToUpdatePayload(t *testing.T) { PlanId: types.StringValue("plan"), }, &opensearch.PartialUpdateInstancePayload{ - PlanId: utils.Ptr("plan"), + PlanId: new("plan"), }, true, }, diff --git a/stackit/internal/services/opensearch/opensearch_acc_test.go b/stackit/internal/services/opensearch/opensearch_acc_test.go index 223b12cee..47a57aeae 100644 --- a/stackit/internal/services/opensearch/opensearch_acc_test.go +++ b/stackit/internal/services/opensearch/opensearch_acc_test.go @@ -41,16 +41,17 @@ func parametersConfig(params map[string]string) string { "syslog", "tls_ciphers", } - parameters := "parameters = {" + var parameters strings.Builder + parameters.WriteString("parameters = {") for k, v := range params { if utils.Contains(nonStringParams, k) { - parameters += fmt.Sprintf("%s = %s\n", k, v) + parameters.WriteString(fmt.Sprintf("%s = %s\n", k, v)) } else { - parameters += fmt.Sprintf("%s = %q\n", k, v) + parameters.WriteString(fmt.Sprintf("%s = %q\n", k, v)) } } - parameters += "\n}" - return parameters + parameters.WriteString("\n}") + return parameters.String() } func resourceConfig(params map[string]string) string { diff --git a/stackit/internal/services/opensearch/opensearch_test.go b/stackit/internal/services/opensearch/opensearch_test.go index 1077ee667..c783558d0 100644 --- a/stackit/internal/services/opensearch/opensearch_test.go +++ b/stackit/internal/services/opensearch/opensearch_test.go @@ -50,11 +50,11 @@ resource "stackit_opensearch_instance" "instance" { ToJsonBody: &opensearch.ListOfferingsResponse{ Offerings: &[]opensearch.Offering{ { - Name: utils.Ptr("offering-name"), + Name: new("offering-name"), Version: utils.Ptr(version), Plans: &[]opensearch.Plan{ { - Id: utils.Ptr("plan-id"), + Id: new("plan-id"), Name: utils.Ptr(planName), }, }, @@ -65,7 +65,7 @@ resource "stackit_opensearch_instance" "instance" { testutil.MockResponse{ Description: "create instance", ToJsonBody: &opensearch.CreateInstanceResponse{ - InstanceId: utils.Ptr(instanceId), + InstanceId: new(instanceId), }, }, testutil.MockResponse{Description: "failing waiter", StatusCode: http.StatusInternalServerError}, @@ -127,7 +127,7 @@ resource "stackit_opensearch_credential" "credential" { testutil.MockResponse{ Description: "create credential", ToJsonBody: &opensearch.CredentialsResponse{ - Id: utils.Ptr(credentialId), + Id: new(credentialId), }, }, testutil.MockResponse{Description: "create waiter", StatusCode: http.StatusInternalServerError}, diff --git a/stackit/internal/services/postgresflex/database/resource_test.go b/stackit/internal/services/postgresflex/database/resource_test.go index 1770801b6..d43e7e2fe 100644 --- a/stackit/internal/services/postgresflex/database/resource_test.go +++ b/stackit/internal/services/postgresflex/database/resource_test.go @@ -5,7 +5,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" ) @@ -21,7 +20,7 @@ func TestMapFields(t *testing.T) { { "default_values", &postgresflex.InstanceDatabase{ - Id: utils.Ptr("uid"), + Id: new("uid"), }, testRegion, Model{ @@ -38,9 +37,9 @@ func TestMapFields(t *testing.T) { { "simple_values", &postgresflex.InstanceDatabase{ - Id: utils.Ptr("uid"), - Name: utils.Ptr("dbname"), - Options: &map[string]interface{}{ + Id: new("uid"), + Name: new("dbname"), + Options: &map[string]any{ "owner": "username", }, }, @@ -59,9 +58,9 @@ func TestMapFields(t *testing.T) { { "null_fields_and_int_conversions", &postgresflex.InstanceDatabase{ - Id: utils.Ptr("uid"), - Name: utils.Ptr(""), - Options: &map[string]interface{}{ + Id: new("uid"), + Name: new(""), + Options: &map[string]any{ "owner": "", }, }, @@ -94,9 +93,9 @@ func TestMapFields(t *testing.T) { { "no_resource_id", &postgresflex.InstanceDatabase{ - Id: utils.Ptr(""), - Name: utils.Ptr("dbname"), - Options: &map[string]interface{}{ + Id: new(""), + Name: new("dbname"), + Options: &map[string]any{ "owner": "username", }, }, @@ -142,7 +141,7 @@ func TestToCreatePayload(t *testing.T) { Owner: types.StringValue("username"), }, &postgresflex.CreateDatabasePayload{ - Name: utils.Ptr("dbname"), + Name: new("dbname"), Options: &map[string]string{ "owner": "username", }, diff --git a/stackit/internal/services/postgresflex/instance/resource_test.go b/stackit/internal/services/postgresflex/instance/resource_test.go index 0d56ebd16..49532fa64 100644 --- a/stackit/internal/services/postgresflex/instance/resource_test.go +++ b/stackit/internal/services/postgresflex/instance/resource_test.go @@ -8,7 +8,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" ) @@ -87,22 +86,22 @@ func TestMapFields(t *testing.T) { "", }, }, - BackupSchedule: utils.Ptr("schedule"), + BackupSchedule: new("schedule"), Flavor: &postgresflex.Flavor{ - Cpu: utils.Ptr(int64(12)), - Description: utils.Ptr("description"), - Id: utils.Ptr("flavor_id"), - Memory: utils.Ptr(int64(34)), + Cpu: new(int64(12)), + Description: new("description"), + Id: new("flavor_id"), + Memory: new(int64(34)), }, - Id: utils.Ptr("iid"), - Name: utils.Ptr("name"), - Replicas: utils.Ptr(int64(56)), - Status: utils.Ptr("status"), + Id: new("iid"), + Name: new("name"), + Replicas: new(int64(56)), + Status: new("status"), Storage: &postgresflex.Storage{ - Class: utils.Ptr("class"), - Size: utils.Ptr(int64(78)), + Class: new("class"), + Size: new(int64(78)), }, - Version: utils.Ptr("version"), + Version: new("version"), }, }, &flavorModel{}, @@ -150,14 +149,14 @@ func TestMapFields(t *testing.T) { "", }, }, - BackupSchedule: utils.Ptr("schedule"), + BackupSchedule: new("schedule"), Flavor: nil, - Id: utils.Ptr("iid"), - Name: utils.Ptr("name"), - Replicas: utils.Ptr(int64(56)), - Status: utils.Ptr("status"), + Id: new("iid"), + Name: new("name"), + Replicas: new(int64(56)), + Status: new("status"), Storage: nil, - Version: utils.Ptr("version"), + Version: new("version"), }, }, &flavorModel{ @@ -216,14 +215,14 @@ func TestMapFields(t *testing.T) { "ip2", }, }, - BackupSchedule: utils.Ptr("schedule"), + BackupSchedule: new("schedule"), Flavor: nil, - Id: utils.Ptr("iid"), - Name: utils.Ptr("name"), - Replicas: utils.Ptr(int64(56)), - Status: utils.Ptr("status"), + Id: new("iid"), + Name: new("name"), + Replicas: new(int64(56)), + Status: new("status"), Storage: nil, - Version: utils.Ptr("version"), + Version: new("version"), }, }, &flavorModel{ @@ -358,15 +357,15 @@ func TestToCreatePayload(t *testing.T) { "ip_2", }, }, - BackupSchedule: utils.Ptr("schedule"), - FlavorId: utils.Ptr("flavor_id"), - Name: utils.Ptr("name"), - Replicas: utils.Ptr(int64(12)), + BackupSchedule: new("schedule"), + FlavorId: new("flavor_id"), + Name: new("name"), + Replicas: new(int64(12)), Storage: &postgresflex.Storage{ - Class: utils.Ptr("class"), - Size: utils.Ptr(int64(34)), + Class: new("class"), + Size: new(int64(34)), }, - Version: utils.Ptr("version"), + Version: new("version"), }, true, }, @@ -397,7 +396,7 @@ func TestToCreatePayload(t *testing.T) { BackupSchedule: nil, FlavorId: nil, Name: nil, - Replicas: utils.Ptr(int64(2123456789)), + Replicas: new(int64(2123456789)), Storage: &postgresflex.Storage{ Class: nil, Size: nil, @@ -511,11 +510,11 @@ func TestToUpdatePayload(t *testing.T) { "ip_2", }, }, - BackupSchedule: utils.Ptr("schedule"), - FlavorId: utils.Ptr("flavor_id"), - Name: utils.Ptr("name"), - Replicas: utils.Ptr(int64(12)), - Version: utils.Ptr("version"), + BackupSchedule: new("schedule"), + FlavorId: new("flavor_id"), + Name: new("name"), + Replicas: new(int64(12)), + Version: new("version"), }, true, }, @@ -546,7 +545,7 @@ func TestToUpdatePayload(t *testing.T) { BackupSchedule: nil, FlavorId: nil, Name: nil, - Replicas: utils.Ptr(int64(2123456789)), + Replicas: new(int64(2123456789)), Version: nil, }, true, @@ -625,10 +624,10 @@ func TestLoadFlavorId(t *testing.T) { &postgresflex.ListFlavorsResponse{ Flavors: &[]postgresflex.Flavor{ { - Id: utils.Ptr("fid-1"), - Cpu: utils.Ptr(int64(2)), - Description: utils.Ptr("description"), - Memory: utils.Ptr(int64(8)), + Id: new("fid-1"), + Cpu: new(int64(2)), + Description: new("description"), + Memory: new(int64(8)), }, }, }, @@ -650,16 +649,16 @@ func TestLoadFlavorId(t *testing.T) { &postgresflex.ListFlavorsResponse{ Flavors: &[]postgresflex.Flavor{ { - Id: utils.Ptr("fid-1"), - Cpu: utils.Ptr(int64(2)), - Description: utils.Ptr("description"), - Memory: utils.Ptr(int64(8)), + Id: new("fid-1"), + Cpu: new(int64(2)), + Description: new("description"), + Memory: new(int64(8)), }, { - Id: utils.Ptr("fid-2"), - Cpu: utils.Ptr(int64(1)), - Description: utils.Ptr("description"), - Memory: utils.Ptr(int64(4)), + Id: new("fid-2"), + Cpu: new(int64(1)), + Description: new("description"), + Memory: new(int64(4)), }, }, }, @@ -681,16 +680,16 @@ func TestLoadFlavorId(t *testing.T) { &postgresflex.ListFlavorsResponse{ Flavors: &[]postgresflex.Flavor{ { - Id: utils.Ptr("fid-1"), - Cpu: utils.Ptr(int64(1)), - Description: utils.Ptr("description"), - Memory: utils.Ptr(int64(8)), + Id: new("fid-1"), + Cpu: new(int64(1)), + Description: new("description"), + Memory: new(int64(8)), }, { - Id: utils.Ptr("fid-2"), - Cpu: utils.Ptr(int64(1)), - Description: utils.Ptr("description"), - Memory: utils.Ptr(int64(4)), + Id: new("fid-2"), + Cpu: new(int64(1)), + Description: new("description"), + Memory: new(int64(4)), }, }, }, diff --git a/stackit/internal/services/postgresflex/user/datasource_test.go b/stackit/internal/services/postgresflex/user/datasource_test.go index ac824ccbd..5132665ee 100644 --- a/stackit/internal/services/postgresflex/user/datasource_test.go +++ b/stackit/internal/services/postgresflex/user/datasource_test.go @@ -6,7 +6,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" ) @@ -47,9 +46,9 @@ func TestMapDataSourceFields(t *testing.T) { "role_2", "", }, - Username: utils.Ptr("username"), - Host: utils.Ptr("host"), - Port: utils.Ptr(int64(1234)), + Username: new("username"), + Host: new("host"), + Port: new(int64(1234)), }, }, testRegion, @@ -74,11 +73,11 @@ func TestMapDataSourceFields(t *testing.T) { "null_fields_and_int_conversions", &postgresflex.GetUserResponse{ Item: &postgresflex.UserResponse{ - Id: utils.Ptr("uid"), + Id: new("uid"), Roles: &[]string{}, Username: nil, Host: nil, - Port: utils.Ptr(int64(2123456789)), + Port: new(int64(2123456789)), }, }, testRegion, diff --git a/stackit/internal/services/postgresflex/user/resource_test.go b/stackit/internal/services/postgresflex/user/resource_test.go index b5c137162..e3f38a05a 100644 --- a/stackit/internal/services/postgresflex/user/resource_test.go +++ b/stackit/internal/services/postgresflex/user/resource_test.go @@ -6,7 +6,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" ) @@ -23,8 +22,8 @@ func TestMapFieldsCreate(t *testing.T) { "default_values", &postgresflex.CreateUserResponse{ Item: &postgresflex.User{ - Id: utils.Ptr("uid"), - Password: utils.Ptr(""), + Id: new("uid"), + Password: new(""), }, }, testRegion, @@ -47,17 +46,17 @@ func TestMapFieldsCreate(t *testing.T) { "simple_values", &postgresflex.CreateUserResponse{ Item: &postgresflex.User{ - Id: utils.Ptr("uid"), + Id: new("uid"), Roles: &[]string{ "role_1", "role_2", "", }, - Username: utils.Ptr("username"), - Password: utils.Ptr("password"), - Host: utils.Ptr("host"), - Port: utils.Ptr(int64(1234)), - Uri: utils.Ptr("uri"), + Username: new("username"), + Password: new("password"), + Host: new("host"), + Port: new(int64(1234)), + Uri: new("uri"), }, }, testRegion, @@ -84,12 +83,12 @@ func TestMapFieldsCreate(t *testing.T) { "null_fields_and_int_conversions", &postgresflex.CreateUserResponse{ Item: &postgresflex.User{ - Id: utils.Ptr("uid"), + Id: new("uid"), Roles: &[]string{}, Username: nil, - Password: utils.Ptr(""), + Password: new(""), Host: nil, - Port: utils.Ptr(int64(2123456789)), + Port: new(int64(2123456789)), Uri: nil, }, }, @@ -136,7 +135,7 @@ func TestMapFieldsCreate(t *testing.T) { "no_password", &postgresflex.CreateUserResponse{ Item: &postgresflex.User{ - Id: utils.Ptr("uid"), + Id: new("uid"), }, }, testRegion, @@ -204,9 +203,9 @@ func TestMapFields(t *testing.T) { "role_2", "", }, - Username: utils.Ptr("username"), - Host: utils.Ptr("host"), - Port: utils.Ptr(int64(1234)), + Username: new("username"), + Host: new("host"), + Port: new(int64(1234)), }, }, testRegion, @@ -231,11 +230,11 @@ func TestMapFields(t *testing.T) { "null_fields_and_int_conversions", &postgresflex.GetUserResponse{ Item: &postgresflex.UserResponse{ - Id: utils.Ptr("uid"), + Id: new("uid"), Roles: &[]string{}, Username: nil, Host: nil, - Port: utils.Ptr(int64(2123456789)), + Port: new(int64(2123456789)), }, }, testRegion, @@ -332,7 +331,7 @@ func TestToCreatePayload(t *testing.T) { "role_1", "role_2", }, - Username: utils.Ptr("username"), + Username: new("username"), }, true, }, diff --git a/stackit/internal/services/rabbitmq/credential/resource_test.go b/stackit/internal/services/rabbitmq/credential/resource_test.go index 5492d2fef..06f5639a7 100644 --- a/stackit/internal/services/rabbitmq/credential/resource_test.go +++ b/stackit/internal/services/rabbitmq/credential/resource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" ) @@ -26,7 +25,7 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue("pid"), }, &rabbitmq.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), Raw: &rabbitmq.RawCredentials{}, }, Model{ @@ -54,28 +53,28 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue("pid"), }, &rabbitmq.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), Raw: &rabbitmq.RawCredentials{ Credentials: &rabbitmq.Credentials{ - Host: utils.Ptr("host"), + Host: new("host"), Hosts: &[]string{ "host_1", "", }, - HttpApiUri: utils.Ptr("http"), + HttpApiUri: new("http"), HttpApiUris: &[]string{ "http_api_uri_1", "", }, - Management: utils.Ptr("management"), - Password: utils.Ptr("password"), - Port: utils.Ptr(int64(1234)), - Uri: utils.Ptr("uri"), + Management: new("management"), + Password: new("password"), + Port: new(int64(1234)), + Uri: new("uri"), Uris: &[]string{ "uri_1", "", }, - Username: utils.Ptr("username"), + Username: new("username"), }, }, }, @@ -128,31 +127,31 @@ func TestMapFields(t *testing.T) { }), }, &rabbitmq.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), Raw: &rabbitmq.RawCredentials{ Credentials: &rabbitmq.Credentials{ - Host: utils.Ptr("host"), + Host: new("host"), Hosts: &[]string{ "", "host_1", "host_2", }, - HttpApiUri: utils.Ptr("http"), + HttpApiUri: new("http"), HttpApiUris: &[]string{ "", "http_api_uri_1", "http_api_uri_2", }, - Management: utils.Ptr("management"), - Password: utils.Ptr("password"), - Port: utils.Ptr(int64(1234)), - Uri: utils.Ptr("uri"), + Management: new("management"), + Password: new("password"), + Port: new(int64(1234)), + Uri: new("uri"), Uris: &[]string{ "", "uri_1", "uri_2", }, - Username: utils.Ptr("username"), + Username: new("username"), }, }, }, @@ -193,19 +192,19 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue("pid"), }, &rabbitmq.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), Raw: &rabbitmq.RawCredentials{ Credentials: &rabbitmq.Credentials{ - Host: utils.Ptr(""), + Host: new(""), Hosts: &[]string{}, HttpApiUri: nil, HttpApiUris: &[]string{}, Management: nil, - Password: utils.Ptr(""), - Port: utils.Ptr(int64(2123456789)), + Password: new(""), + Port: new(int64(2123456789)), Uri: nil, Uris: &[]string{}, - Username: utils.Ptr(""), + Username: new(""), }, }, }, @@ -254,7 +253,7 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue("pid"), }, &rabbitmq.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), }, Model{}, false, diff --git a/stackit/internal/services/rabbitmq/instance/resource.go b/stackit/internal/services/rabbitmq/instance/resource.go index 8d853dcab..19f1c2e9c 100644 --- a/stackit/internal/services/rabbitmq/instance/resource.go +++ b/stackit/internal/services/rabbitmq/instance/resource.go @@ -614,10 +614,10 @@ func mapFields(instance *rabbitmq.Instance, model *Model) error { return nil } -func mapParameters(params map[string]interface{}) (types.Object, error) { +func mapParameters(params map[string]any) (types.Object, error) { attributes := map[string]attr.Value{} for attribute := range parametersTypes { - var valueInterface interface{} + var valueInterface any var ok bool // This replacement is necessary because Terraform does not allow hyphens in attribute names @@ -693,7 +693,7 @@ func mapParameters(params map[string]interface{}) (types.Object, error) { for _, x := range temp { valueList = append(valueList, types.StringValue(x)) } - case []interface{}: + case []any: for _, x := range temp { xString, ok := x.(string) if !ok { diff --git a/stackit/internal/services/rabbitmq/instance/resource_test.go b/stackit/internal/services/rabbitmq/instance/resource_test.go index f2e26ddee..a71cdf1f3 100644 --- a/stackit/internal/services/rabbitmq/instance/resource_test.go +++ b/stackit/internal/services/rabbitmq/instance/resource_test.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" ) @@ -44,14 +43,14 @@ var fixtureModelParameters = types.ObjectValueMust(parametersTypes, map[string]a }) var fixtureInstanceParameters = rabbitmq.InstanceParameters{ - SgwAcl: utils.Ptr("acl"), - ConsumerTimeout: utils.Ptr(int64(10)), - EnableMonitoring: utils.Ptr(true), - Graphite: utils.Ptr("1.1.1.1:91"), - MaxDiskThreshold: utils.Ptr(int64(100)), - MetricsFrequency: utils.Ptr(int64(10)), - MetricsPrefix: utils.Ptr("prefix"), - MonitoringInstanceId: utils.Ptr("mid"), + SgwAcl: new("acl"), + ConsumerTimeout: new(int64(10)), + EnableMonitoring: new(true), + Graphite: new("1.1.1.1:91"), + MaxDiskThreshold: new(int64(100)), + MetricsFrequency: new(int64(10)), + MetricsPrefix: new("prefix"), + MonitoringInstanceId: new("mid"), Plugins: &[]string{"plugin1", "plugin2"}, Roles: &[]string{"role1", "role2"}, Syslog: &[]string{"syslog", "syslog2"}, @@ -87,15 +86,15 @@ func TestMapFields(t *testing.T) { { "simple_values", &rabbitmq.Instance{ - PlanId: utils.Ptr("plan"), - CfGuid: utils.Ptr("cf"), - CfSpaceGuid: utils.Ptr("space"), - DashboardUrl: utils.Ptr("dashboard"), - ImageUrl: utils.Ptr("image"), - InstanceId: utils.Ptr("iid"), - Name: utils.Ptr("name"), - CfOrganizationGuid: utils.Ptr("org"), - Parameters: &map[string]interface{}{ + PlanId: new("plan"), + CfGuid: new("cf"), + CfSpaceGuid: new("space"), + DashboardUrl: new("dashboard"), + ImageUrl: new("image"), + InstanceId: new("iid"), + Name: new("name"), + CfOrganizationGuid: new("org"), + Parameters: &map[string]any{ "sgw_acl": "acl", "consumer_timeout": 10, "enable_monitoring": true, @@ -142,7 +141,7 @@ func TestMapFields(t *testing.T) { { "wrong_param_types_1", &rabbitmq.Instance{ - Parameters: &map[string]interface{}{ + Parameters: &map[string]any{ "sgw_acl": true, }, }, @@ -152,7 +151,7 @@ func TestMapFields(t *testing.T) { { "wrong_param_types_2", &rabbitmq.Instance{ - Parameters: &map[string]interface{}{ + Parameters: &map[string]any{ "sgw_acl": 1, }, }, @@ -204,9 +203,9 @@ func TestToCreatePayload(t *testing.T) { Parameters: fixtureModelParameters, }, &rabbitmq.CreateInstancePayload{ - InstanceName: utils.Ptr("name"), + InstanceName: new("name"), Parameters: &fixtureInstanceParameters, - PlanId: utils.Ptr("plan"), + PlanId: new("plan"), }, true, }, @@ -218,8 +217,8 @@ func TestToCreatePayload(t *testing.T) { Parameters: fixtureModelParameters, }, &rabbitmq.CreateInstancePayload{ - InstanceName: utils.Ptr(""), - PlanId: utils.Ptr(""), + InstanceName: new(""), + PlanId: new(""), Parameters: &fixtureInstanceParameters, }, true, @@ -237,8 +236,8 @@ func TestToCreatePayload(t *testing.T) { PlanId: types.StringValue("plan"), }, &rabbitmq.CreateInstancePayload{ - InstanceName: utils.Ptr("name"), - PlanId: utils.Ptr("plan"), + InstanceName: new("name"), + PlanId: new("plan"), }, true, }, @@ -294,7 +293,7 @@ func TestToUpdatePayload(t *testing.T) { }, &rabbitmq.PartialUpdateInstancePayload{ Parameters: &fixtureInstanceParameters, - PlanId: utils.Ptr("plan"), + PlanId: new("plan"), }, true, }, @@ -306,7 +305,7 @@ func TestToUpdatePayload(t *testing.T) { }, &rabbitmq.PartialUpdateInstancePayload{ Parameters: &fixtureInstanceParameters, - PlanId: utils.Ptr(""), + PlanId: new(""), }, true, }, @@ -322,7 +321,7 @@ func TestToUpdatePayload(t *testing.T) { PlanId: types.StringValue("plan"), }, &rabbitmq.PartialUpdateInstancePayload{ - PlanId: utils.Ptr("plan"), + PlanId: new("plan"), }, true, }, diff --git a/stackit/internal/services/rabbitmq/rabbitmq_acc_test.go b/stackit/internal/services/rabbitmq/rabbitmq_acc_test.go index ff9d3f417..12bc338c2 100644 --- a/stackit/internal/services/rabbitmq/rabbitmq_acc_test.go +++ b/stackit/internal/services/rabbitmq/rabbitmq_acc_test.go @@ -39,16 +39,17 @@ func parametersConfig(params map[string]string) string { "syslog", "tls_ciphers", } - parameters := "parameters = {" + var parameters strings.Builder + parameters.WriteString("parameters = {") for k, v := range params { if utils.Contains(nonStringParams, k) { - parameters += fmt.Sprintf("%s = %s\n", k, v) + parameters.WriteString(fmt.Sprintf("%s = %s\n", k, v)) } else { - parameters += fmt.Sprintf("%s = %q\n", k, v) + parameters.WriteString(fmt.Sprintf("%s = %q\n", k, v)) } } - parameters += "\n}" - return parameters + parameters.WriteString("\n}") + return parameters.String() } func resourceConfig(params map[string]string) string { diff --git a/stackit/internal/services/rabbitmq/rabbitmq_test.go b/stackit/internal/services/rabbitmq/rabbitmq_test.go index 4afc5aa9f..48201e308 100644 --- a/stackit/internal/services/rabbitmq/rabbitmq_test.go +++ b/stackit/internal/services/rabbitmq/rabbitmq_test.go @@ -62,7 +62,7 @@ resource "stackit_rabbitmq_instance" "instance" { testutil.MockResponse{ Description: "create", ToJsonBody: rabbitmq.CreateInstanceResponse{ - InstanceId: utils.Ptr(instanceId), + InstanceId: new(instanceId), }, }, testutil.MockResponse{ @@ -128,7 +128,7 @@ resource "stackit_rabbitmq_credential" "credential" { // initial post response testutil.MockResponse{ ToJsonBody: rabbitmq.CredentialsResponse{ - Id: utils.Ptr(credentialId), + Id: new(credentialId), }, }, // failing waiter diff --git a/stackit/internal/services/redis/credential/resource_test.go b/stackit/internal/services/redis/credential/resource_test.go index d4d1c6419..ade14f0ed 100644 --- a/stackit/internal/services/redis/credential/resource_test.go +++ b/stackit/internal/services/redis/credential/resource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/redis" ) @@ -26,7 +25,7 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue("pid"), }, &redis.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), Raw: &redis.RawCredentials{}, }, Model{ @@ -51,19 +50,19 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue("pid"), }, &redis.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), Raw: &redis.RawCredentials{ Credentials: &redis.Credentials{ - Host: utils.Ptr("host"), + Host: new("host"), Hosts: &[]string{ "host_1", "", }, - LoadBalancedHost: utils.Ptr("load_balanced_host"), - Password: utils.Ptr("password"), - Port: utils.Ptr(int64(1234)), - Uri: utils.Ptr("uri"), - Username: utils.Ptr("username"), + LoadBalancedHost: new("load_balanced_host"), + Password: new("password"), + Port: new(int64(1234)), + Uri: new("uri"), + Username: new("username"), }, }, }, @@ -97,20 +96,20 @@ func TestMapFields(t *testing.T) { }), }, &redis.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), Raw: &redis.RawCredentials{ Credentials: &redis.Credentials{ - Host: utils.Ptr("host"), + Host: new("host"), Hosts: &[]string{ "", "host_1", "host_2", }, - LoadBalancedHost: utils.Ptr("load_balanced_host"), - Password: utils.Ptr("password"), - Port: utils.Ptr(int64(1234)), - Uri: utils.Ptr("uri"), - Username: utils.Ptr("username"), + LoadBalancedHost: new("load_balanced_host"), + Password: new("password"), + Port: new(int64(1234)), + Uri: new("uri"), + Username: new("username"), }, }, }, @@ -140,16 +139,16 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue("pid"), }, &redis.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), Raw: &redis.RawCredentials{ Credentials: &redis.Credentials{ - Host: utils.Ptr(""), + Host: new(""), Hosts: &[]string{}, LoadBalancedHost: nil, - Password: utils.Ptr(""), - Port: utils.Ptr(int64(2123456789)), + Password: new(""), + Port: new(int64(2123456789)), Uri: nil, - Username: utils.Ptr(""), + Username: new(""), }, }, }, @@ -195,7 +194,7 @@ func TestMapFields(t *testing.T) { ProjectId: types.StringValue("pid"), }, &redis.CredentialsResponse{ - Id: utils.Ptr("cid"), + Id: new("cid"), }, Model{}, false, diff --git a/stackit/internal/services/redis/instance/resource.go b/stackit/internal/services/redis/instance/resource.go index b928e14b9..627261ff7 100644 --- a/stackit/internal/services/redis/instance/resource.go +++ b/stackit/internal/services/redis/instance/resource.go @@ -680,10 +680,10 @@ func mapFields(instance *redis.Instance, model *Model) error { return nil } -func mapParameters(params map[string]interface{}) (types.Object, error) { +func mapParameters(params map[string]any) (types.Object, error) { attributes := map[string]attr.Value{} for attribute := range parametersTypes { - var valueInterface interface{} + var valueInterface any var ok bool // This replacement is necessary because Terraform does not allow hyphens in attribute names @@ -773,7 +773,7 @@ func mapParameters(params map[string]interface{}) (types.Object, error) { for _, x := range temp { valueList = append(valueList, types.StringValue(x)) } - case []interface{}: + case []any: for _, x := range temp { xString, ok := x.(string) if !ok { diff --git a/stackit/internal/services/redis/instance/resource_test.go b/stackit/internal/services/redis/instance/resource_test.go index 9221878a6..0b205db6e 100644 --- a/stackit/internal/services/redis/instance/resource_test.go +++ b/stackit/internal/services/redis/instance/resource_test.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/redis" ) @@ -44,27 +43,27 @@ var fixtureModelParameters = types.ObjectValueMust(parametersTypes, map[string]a }) var fixtureInstanceParameters = redis.InstanceParameters{ - SgwAcl: utils.Ptr("acl"), - DownAfterMilliseconds: utils.Ptr(int64(10)), - EnableMonitoring: utils.Ptr(true), - FailoverTimeout: utils.Ptr(int64(10)), - Graphite: utils.Ptr("1.1.1.1:91"), + SgwAcl: new("acl"), + DownAfterMilliseconds: new(int64(10)), + EnableMonitoring: new(true), + FailoverTimeout: new(int64(10)), + Graphite: new("1.1.1.1:91"), LazyfreeLazyEviction: redis.INSTANCEPARAMETERSLAZYFREE_LAZY_EVICTION_NO.Ptr(), LazyfreeLazyExpire: redis.INSTANCEPARAMETERSLAZYFREE_LAZY_EXPIRE_NO.Ptr(), - LuaTimeLimit: utils.Ptr(int64(10)), - MaxDiskThreshold: utils.Ptr(int64(100)), - Maxclients: utils.Ptr(int64(10)), + LuaTimeLimit: new(int64(10)), + MaxDiskThreshold: new(int64(100)), + Maxclients: new(int64(10)), MaxmemoryPolicy: redis.INSTANCEPARAMETERSMAXMEMORY_POLICY_ALLKEYS_LRU.Ptr(), - MaxmemorySamples: utils.Ptr(int64(10)), - MetricsFrequency: utils.Ptr(int64(10)), - MetricsPrefix: utils.Ptr("prefix"), - MinReplicasMaxLag: utils.Ptr(int64(10)), - MonitoringInstanceId: utils.Ptr("mid"), - NotifyKeyspaceEvents: utils.Ptr("events"), - Snapshot: utils.Ptr("snapshot"), + MaxmemorySamples: new(int64(10)), + MetricsFrequency: new(int64(10)), + MetricsPrefix: new("prefix"), + MinReplicasMaxLag: new(int64(10)), + MonitoringInstanceId: new("mid"), + NotifyKeyspaceEvents: new("events"), + Snapshot: new("snapshot"), Syslog: &[]string{"syslog", "syslog2"}, TlsCiphers: &[]string{"ciphers1", "ciphers2"}, - TlsCiphersuites: utils.Ptr("ciphersuites"), + TlsCiphersuites: new("ciphersuites"), TlsProtocols: redis.INSTANCEPARAMETERSTLS_PROTOCOLS__2.Ptr(), } @@ -96,15 +95,15 @@ func TestMapFields(t *testing.T) { { "simple_values", &redis.Instance{ - PlanId: utils.Ptr("plan"), - CfGuid: utils.Ptr("cf"), - CfSpaceGuid: utils.Ptr("space"), - DashboardUrl: utils.Ptr("dashboard"), - ImageUrl: utils.Ptr("image"), - InstanceId: utils.Ptr("iid"), - Name: utils.Ptr("name"), - CfOrganizationGuid: utils.Ptr("org"), - Parameters: &map[string]interface{}{ + PlanId: new("plan"), + CfGuid: new("cf"), + CfSpaceGuid: new("space"), + DashboardUrl: new("dashboard"), + ImageUrl: new("image"), + InstanceId: new("iid"), + Name: new("name"), + CfOrganizationGuid: new("org"), + Parameters: &map[string]any{ "sgw_acl": "acl", "down-after-milliseconds": int64(10), "enable_monitoring": true, @@ -159,7 +158,7 @@ func TestMapFields(t *testing.T) { { "wrong_param_types_1", &redis.Instance{ - Parameters: &map[string]interface{}{ + Parameters: &map[string]any{ "sgw_acl": true, }, }, @@ -169,7 +168,7 @@ func TestMapFields(t *testing.T) { { "wrong_param_types_2", &redis.Instance{ - Parameters: &map[string]interface{}{ + Parameters: &map[string]any{ "sgw_acl": 1, }, }, @@ -221,9 +220,9 @@ func TestToCreatePayload(t *testing.T) { Parameters: fixtureModelParameters, }, &redis.CreateInstancePayload{ - InstanceName: utils.Ptr("name"), + InstanceName: new("name"), Parameters: &fixtureInstanceParameters, - PlanId: utils.Ptr("plan"), + PlanId: new("plan"), }, true, }, @@ -235,9 +234,9 @@ func TestToCreatePayload(t *testing.T) { Parameters: fixtureModelParameters, }, &redis.CreateInstancePayload{ - InstanceName: utils.Ptr(""), + InstanceName: new(""), Parameters: &fixtureInstanceParameters, - PlanId: utils.Ptr(""), + PlanId: new(""), }, true, }, @@ -254,8 +253,8 @@ func TestToCreatePayload(t *testing.T) { PlanId: types.StringValue("plan"), }, &redis.CreateInstancePayload{ - InstanceName: utils.Ptr("name"), - PlanId: utils.Ptr("plan"), + InstanceName: new("name"), + PlanId: new("plan"), }, true, }, @@ -310,7 +309,7 @@ func TestToUpdatePayload(t *testing.T) { }, &redis.PartialUpdateInstancePayload{ Parameters: &fixtureInstanceParameters, - PlanId: utils.Ptr("plan"), + PlanId: new("plan"), }, true, }, @@ -322,7 +321,7 @@ func TestToUpdatePayload(t *testing.T) { }, &redis.PartialUpdateInstancePayload{ Parameters: &fixtureInstanceParameters, - PlanId: utils.Ptr(""), + PlanId: new(""), }, true, }, @@ -338,7 +337,7 @@ func TestToUpdatePayload(t *testing.T) { PlanId: types.StringValue("plan"), }, &redis.PartialUpdateInstancePayload{ - PlanId: utils.Ptr("plan"), + PlanId: new("plan"), }, true, }, diff --git a/stackit/internal/services/redis/redis_acc_test.go b/stackit/internal/services/redis/redis_acc_test.go index e86fe3cab..0b99623c6 100644 --- a/stackit/internal/services/redis/redis_acc_test.go +++ b/stackit/internal/services/redis/redis_acc_test.go @@ -43,16 +43,17 @@ func parametersConfig(params map[string]string) string { "syslog", "tls_ciphers", } - parameters := "parameters = {" + var parameters strings.Builder + parameters.WriteString("parameters = {") for k, v := range params { if utils.Contains(nonStringParams, k) { - parameters += fmt.Sprintf("%s = %s\n", k, v) + parameters.WriteString(fmt.Sprintf("%s = %s\n", k, v)) } else { - parameters += fmt.Sprintf("%s = %q\n", k, v) + parameters.WriteString(fmt.Sprintf("%s = %q\n", k, v)) } } - parameters += "\n}" - return parameters + parameters.WriteString("\n}") + return parameters.String() } func resourceConfig(params map[string]string) string { diff --git a/stackit/internal/services/resourcemanager/folder/resource_test.go b/stackit/internal/services/resourcemanager/folder/resource_test.go index 33711cf4b..46361d3bf 100644 --- a/stackit/internal/services/resourcemanager/folder/resource_test.go +++ b/stackit/internal/services/resourcemanager/folder/resource_test.go @@ -9,7 +9,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" resourcemanager "github.com/stackitcloud/stackit-sdk-go/services/resourcemanager/v0api" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion" ) @@ -298,12 +297,12 @@ func TestToUpdatePayload(t *testing.T) { "label2": "2", }, &resourcemanager.PartialUpdateFolderPayload{ - ContainerParentId: utils.Ptr("pid"), + ContainerParentId: new("pid"), Labels: &map[string]string{ "label1": "1", "label2": "2", }, - Name: utils.Ptr("name"), + Name: new("name"), }, true, }, diff --git a/stackit/internal/services/resourcemanager/project/resource_test.go b/stackit/internal/services/resourcemanager/project/resource_test.go index 9f3292d9d..41cae93eb 100644 --- a/stackit/internal/services/resourcemanager/project/resource_test.go +++ b/stackit/internal/services/resourcemanager/project/resource_test.go @@ -9,7 +9,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" resourcemanager "github.com/stackitcloud/stackit-sdk-go/services/resourcemanager/v0api" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion" ) @@ -298,12 +297,12 @@ func TestToUpdatePayload(t *testing.T) { "label2": "2", }, &resourcemanager.PartialUpdateProjectPayload{ - ContainerParentId: utils.Ptr("pid"), + ContainerParentId: new("pid"), Labels: &map[string]string{ "label1": "1", "label2": "2", }, - Name: utils.Ptr("name"), + Name: new("name"), }, true, }, diff --git a/stackit/internal/services/scf/organization/resource_test.go b/stackit/internal/services/scf/organization/resource_test.go index 956933ff6..e4b47b1bd 100644 --- a/stackit/internal/services/scf/organization/resource_test.go +++ b/stackit/internal/services/scf/organization/resource_test.go @@ -8,7 +8,6 @@ import ( "github.com/google/go-cmp/cmp" "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/scf" ) @@ -35,12 +34,12 @@ func TestMapFields(t *testing.T) { { description: "minimal_input", input: &scf.Organization{ - Guid: utils.Ptr(testOrgId), - Name: utils.Ptr("scf-org-min-instance"), - Region: utils.Ptr(testRegion), + Guid: new(testOrgId), + Name: new("scf-org-min-instance"), + Region: new(testRegion), CreatedAt: &createdTime, UpdatedAt: &createdTime, - ProjectId: utils.Ptr(testProjectId), + ProjectId: new(testProjectId), }, expected: &Model{ Id: types.StringValue(fmt.Sprintf("%s,%s,%s", testProjectId, testRegion, testOrgId)), @@ -61,14 +60,14 @@ func TestMapFields(t *testing.T) { description: "max_input", input: &scf.Organization{ CreatedAt: &createdTime, - Guid: utils.Ptr(testOrgId), - Name: utils.Ptr("scf-full-org"), - PlatformId: utils.Ptr(testPlatformId), - ProjectId: utils.Ptr(testProjectId), - QuotaId: utils.Ptr(testQuotaId), - Region: utils.Ptr(testRegion), + Guid: new(testOrgId), + Name: new("scf-full-org"), + PlatformId: new(testPlatformId), + ProjectId: new(testProjectId), + QuotaId: new(testQuotaId), + Region: new(testRegion), Status: nil, - Suspended: utils.Ptr(true), + Suspended: new(true), UpdatedAt: &createdTime, }, expected: &Model{ @@ -101,7 +100,7 @@ func TestMapFields(t *testing.T) { { description: "missing_id", input: &scf.Organization{ - Name: utils.Ptr("scf-missing-id"), + Name: new("scf-missing-id"), }, expected: nil, isValid: false, @@ -144,8 +143,8 @@ func TestToCreatePayload(t *testing.T) { PlatformId: types.StringValue(testPlatformId), }, expected: scf.CreateOrganizationPayload{ - Name: utils.Ptr("example-org"), - PlatformId: utils.Ptr(testPlatformId), + Name: new("example-org"), + PlatformId: new(testPlatformId), }, expectError: false, }, diff --git a/stackit/internal/services/scf/organizationmanager/datasource_test.go b/stackit/internal/services/scf/organizationmanager/datasource_test.go index 4ed5e0040..fd058bfca 100644 --- a/stackit/internal/services/scf/organizationmanager/datasource_test.go +++ b/stackit/internal/services/scf/organizationmanager/datasource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/scf" ) @@ -26,10 +25,10 @@ func TestMapFieldsDataSource(t *testing.T) { { description: "minimal_input", input: &scf.OrgManager{ - Guid: utils.Ptr(testUserId), - OrgId: utils.Ptr(testOrgId), - ProjectId: utils.Ptr(testProjectId), - Region: utils.Ptr(testRegion), + Guid: new(testUserId), + OrgId: new(testOrgId), + ProjectId: new(testProjectId), + Region: new(testRegion), CreatedAt: &createdTime, UpdatedAt: &createdTime, }, @@ -49,14 +48,14 @@ func TestMapFieldsDataSource(t *testing.T) { { description: "max_input", input: &scf.OrgManager{ - Guid: utils.Ptr(testUserId), - OrgId: utils.Ptr(testOrgId), - ProjectId: utils.Ptr(testProjectId), - PlatformId: utils.Ptr(testPlatformId), - Region: utils.Ptr(testRegion), + Guid: new(testUserId), + OrgId: new(testOrgId), + ProjectId: new(testProjectId), + PlatformId: new(testPlatformId), + Region: new(testRegion), CreatedAt: &createdTime, UpdatedAt: &createdTime, - Username: utils.Ptr("test-user"), + Username: new("test-user"), }, expected: &DataSourceModel{ Id: types.StringValue(fmt.Sprintf("%s,%s,%s,%s", testProjectId, testRegion, testOrgId, testUserId)), @@ -86,7 +85,7 @@ func TestMapFieldsDataSource(t *testing.T) { { description: "missing_id", input: &scf.OrgManager{ - Username: utils.Ptr("scf-missing-id"), + Username: new("scf-missing-id"), }, expected: nil, isValid: false, diff --git a/stackit/internal/services/scf/organizationmanager/resource_test.go b/stackit/internal/services/scf/organizationmanager/resource_test.go index 1ca257596..8f9e2d777 100644 --- a/stackit/internal/services/scf/organizationmanager/resource_test.go +++ b/stackit/internal/services/scf/organizationmanager/resource_test.go @@ -8,7 +8,6 @@ import ( "github.com/google/go-cmp/cmp" "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/scf" ) @@ -35,10 +34,10 @@ func TestMapFields(t *testing.T) { { description: "minimal_input", input: &scf.OrgManager{ - Guid: utils.Ptr(testUserId), - OrgId: utils.Ptr(testOrgId), - ProjectId: utils.Ptr(testProjectId), - Region: utils.Ptr(testRegion), + Guid: new(testUserId), + OrgId: new(testOrgId), + ProjectId: new(testProjectId), + Region: new(testRegion), CreatedAt: &createdTime, UpdatedAt: &createdTime, }, @@ -58,14 +57,14 @@ func TestMapFields(t *testing.T) { { description: "max_input", input: &scf.OrgManager{ - Guid: utils.Ptr(testUserId), - OrgId: utils.Ptr(testOrgId), - ProjectId: utils.Ptr(testProjectId), - PlatformId: utils.Ptr(testPlatformId), - Region: utils.Ptr(testRegion), + Guid: new(testUserId), + OrgId: new(testOrgId), + ProjectId: new(testProjectId), + PlatformId: new(testPlatformId), + Region: new(testRegion), CreatedAt: &createdTime, UpdatedAt: &createdTime, - Username: utils.Ptr("test-user"), + Username: new("test-user"), }, expected: &Model{ Id: types.StringValue(fmt.Sprintf("%s,%s,%s,%s", testProjectId, testRegion, testOrgId, testUserId)), @@ -96,7 +95,7 @@ func TestMapFields(t *testing.T) { { description: "missing_id", input: &scf.OrgManager{ - Username: utils.Ptr("scf-missing-id"), + Username: new("scf-missing-id"), }, expected: nil, isValid: false, @@ -140,10 +139,10 @@ func TestMapFieldsCreate(t *testing.T) { { description: "minimal_input", input: &scf.OrgManagerResponse{ - Guid: utils.Ptr(testUserId), - OrgId: utils.Ptr(testOrgId), - ProjectId: utils.Ptr(testProjectId), - Region: utils.Ptr(testRegion), + Guid: new(testUserId), + OrgId: new(testOrgId), + ProjectId: new(testProjectId), + Region: new(testRegion), CreatedAt: &createdTime, UpdatedAt: &createdTime, }, @@ -164,15 +163,15 @@ func TestMapFieldsCreate(t *testing.T) { { description: "max_input", input: &scf.OrgManagerResponse{ - Guid: utils.Ptr(testUserId), - OrgId: utils.Ptr(testOrgId), - ProjectId: utils.Ptr(testProjectId), - PlatformId: utils.Ptr(testPlatformId), - Region: utils.Ptr(testRegion), + Guid: new(testUserId), + OrgId: new(testOrgId), + ProjectId: new(testProjectId), + PlatformId: new(testPlatformId), + Region: new(testRegion), CreatedAt: &createdTime, UpdatedAt: &createdTime, - Username: utils.Ptr("test-user"), - Password: utils.Ptr("test-password"), + Username: new("test-user"), + Password: new("test-password"), }, expected: &Model{ Id: types.StringValue(fmt.Sprintf("%s,%s,%s,%s", testProjectId, testRegion, testOrgId, testUserId)), @@ -203,7 +202,7 @@ func TestMapFieldsCreate(t *testing.T) { { description: "missing_id", input: &scf.OrgManagerResponse{ - Username: utils.Ptr("scf-missing-id"), + Username: new("scf-missing-id"), }, expected: nil, isValid: false, diff --git a/stackit/internal/services/scf/platform/datasource_test.go b/stackit/internal/services/scf/platform/datasource_test.go index b15ee231c..8307a46d1 100644 --- a/stackit/internal/services/scf/platform/datasource_test.go +++ b/stackit/internal/services/scf/platform/datasource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "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/scf" ) @@ -27,8 +26,8 @@ func TestMapFields(t *testing.T) { { description: "minimal_input", input: &scf.Platforms{ - Guid: utils.Ptr(testPlatformId), - Region: utils.Ptr(testRegion), + Guid: new(testPlatformId), + Region: new(testRegion), }, expected: &Model{ Id: types.StringValue(fmt.Sprintf("%s,%s,%s", testProjectId, testRegion, testPlatformId)), @@ -45,12 +44,12 @@ func TestMapFields(t *testing.T) { { description: "max_input", input: &scf.Platforms{ - Guid: utils.Ptr(testPlatformId), - SystemId: utils.Ptr("eu01.01"), - DisplayName: utils.Ptr("scf-full-org"), - Region: utils.Ptr(testRegion), - ApiUrl: utils.Ptr("https://example.scf.stackit.cloud"), - ConsoleUrl: utils.Ptr("https://example.console.scf.stackit.cloud"), + Guid: new(testPlatformId), + SystemId: new("eu01.01"), + DisplayName: new("scf-full-org"), + Region: new(testRegion), + ApiUrl: new("https://example.scf.stackit.cloud"), + ConsoleUrl: new("https://example.console.scf.stackit.cloud"), }, expected: &Model{ Id: types.StringValue(fmt.Sprintf("%s,%s,%s", testProjectId, testRegion, testPlatformId)), @@ -79,7 +78,7 @@ func TestMapFields(t *testing.T) { { description: "missing_id", input: &scf.Platforms{ - DisplayName: utils.Ptr("scf-missing-id"), + DisplayName: new("scf-missing-id"), }, expected: nil, isValid: false, diff --git a/stackit/internal/services/scf/scf_test.go b/stackit/internal/services/scf/scf_test.go index b1fcb12c3..784050639 100644 --- a/stackit/internal/services/scf/scf_test.go +++ b/stackit/internal/services/scf/scf_test.go @@ -8,7 +8,6 @@ import ( "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/scf" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/testutil" ) @@ -43,7 +42,7 @@ resource "stackit_scf_organization" "org" { testutil.MockResponse{ Description: "create", ToJsonBody: &scf.OrganizationCreateResponse{ - Guid: utils.Ptr(guid), + Guid: new(guid), }, }, testutil.MockResponse{Description: "create waiter", StatusCode: http.StatusNotFound}, diff --git a/stackit/internal/services/secretsmanager/instance/resource.go b/stackit/internal/services/secretsmanager/instance/resource.go index 8eb42a313..12ec898c4 100644 --- a/stackit/internal/services/secretsmanager/instance/resource.go +++ b/stackit/internal/services/secretsmanager/instance/resource.go @@ -25,7 +25,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" - sdkUtils "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" ) @@ -557,7 +556,7 @@ func updateACLs(ctx context.Context, projectId, instanceId string, acls []string for cidr, state := range aclsState { if state.isInModel && !state.isCreated { payload := secretsmanager.CreateACLPayload{ - Cidr: sdkUtils.Ptr(cidr), + Cidr: new(cidr), } _, err := client.CreateACL(ctx, projectId, instanceId).CreateACLPayload(payload).Execute() if err != nil { diff --git a/stackit/internal/services/secretsmanager/instance/resource_test.go b/stackit/internal/services/secretsmanager/instance/resource_test.go index 6c821a025..8c2dfe8b0 100644 --- a/stackit/internal/services/secretsmanager/instance/resource_test.go +++ b/stackit/internal/services/secretsmanager/instance/resource_test.go @@ -14,7 +14,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stackitcloud/stackit-sdk-go/core/config" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" ) @@ -42,21 +41,21 @@ func TestMapFields(t *testing.T) { { "simple_values", &secretsmanager.Instance{ - Name: utils.Ptr("name"), + Name: new("name"), }, &secretsmanager.ListACLsResponse{ Acls: &[]secretsmanager.ACL{ { - Cidr: utils.Ptr("cidr-1"), - Id: utils.Ptr("id-cidr-1"), + Cidr: new("cidr-1"), + Id: new("id-cidr-1"), }, { - Cidr: utils.Ptr("cidr-2"), - Id: utils.Ptr("id-cidr-2"), + Cidr: new("cidr-2"), + Id: new("id-cidr-2"), }, { - Cidr: utils.Ptr("cidr-3"), - Id: utils.Ptr("id-cidr-3"), + Cidr: new("cidr-3"), + Id: new("id-cidr-3"), }, }, }, @@ -137,7 +136,7 @@ func TestToCreatePayload(t *testing.T) { Name: types.StringValue("name"), }, &secretsmanager.CreateInstancePayload{ - Name: utils.Ptr("name"), + Name: new("name"), }, true, }, @@ -153,12 +152,12 @@ func TestToCreatePayload(t *testing.T) { }, }, &secretsmanager.CreateInstancePayload{ - Name: utils.Ptr("name"), + Name: new("name"), KmsKey: &secretsmanager.KmsKeyPayload{ - KeyId: utils.Ptr("kid"), - KeyRingId: utils.Ptr("key-ring-id"), - KeyVersion: utils.Ptr(int64(1)), - ServiceAccountEmail: utils.Ptr("service-account-email"), + KeyId: new("kid"), + KeyRingId: new("key-ring-id"), + KeyVersion: new(int64(1)), + ServiceAccountEmail: new("service-account-email"), }, }, true, @@ -169,7 +168,7 @@ func TestToCreatePayload(t *testing.T) { Name: types.StringValue(""), }, &secretsmanager.CreateInstancePayload{ - Name: utils.Ptr(""), + Name: new(""), }, true, }, @@ -204,20 +203,20 @@ func TestUpdateACLs(t *testing.T) { getAllACLsResp := secretsmanager.ListACLsResponse{ Acls: &[]secretsmanager.ACL{ { - Cidr: utils.Ptr("acl-1"), - Id: utils.Ptr("id-acl-1"), + Cidr: new("acl-1"), + Id: new("id-acl-1"), }, { - Cidr: utils.Ptr("acl-2"), - Id: utils.Ptr("id-acl-2"), + Cidr: new("acl-2"), + Id: new("id-acl-2"), }, { - Cidr: utils.Ptr("acl-3"), - Id: utils.Ptr("id-acl-3"), + Cidr: new("acl-3"), + Id: new("id-acl-3"), }, { - Cidr: utils.Ptr("acl-2"), - Id: utils.Ptr("id-acl-2-repeated"), + Cidr: new("acl-2"), + Id: new("id-acl-2-repeated"), }, }, } @@ -414,8 +413,8 @@ func TestUpdateACLs(t *testing.T) { } resp := secretsmanager.ACL{ - Cidr: utils.Ptr(cidr), - Id: utils.Ptr(fmt.Sprintf("id-%s", cidr)), + Cidr: new(cidr), + Id: new(fmt.Sprintf("id-%s", cidr)), } respBytes, err := json.Marshal(resp) if err != nil { @@ -527,7 +526,7 @@ func TestToUpdatePayload(t *testing.T) { Name: types.StringValue("name"), }, &secretsmanager.UpdateInstancePayload{ - Name: utils.Ptr("name"), + Name: new("name"), }, true, }, @@ -543,12 +542,12 @@ func TestToUpdatePayload(t *testing.T) { }, }, &secretsmanager.UpdateInstancePayload{ - Name: utils.Ptr("name"), + Name: new("name"), KmsKey: &secretsmanager.KmsKeyPayload{ - KeyId: utils.Ptr("kid"), - KeyRingId: utils.Ptr("key-ring-id"), - KeyVersion: utils.Ptr(int64(1)), - ServiceAccountEmail: utils.Ptr("service-account-email"), + KeyId: new("kid"), + KeyRingId: new("key-ring-id"), + KeyVersion: new(int64(1)), + ServiceAccountEmail: new("service-account-email"), }, }, true, @@ -559,7 +558,7 @@ func TestToUpdatePayload(t *testing.T) { Name: types.StringValue(""), }, &secretsmanager.UpdateInstancePayload{ - Name: utils.Ptr(""), + Name: new(""), }, true, }, diff --git a/stackit/internal/services/secretsmanager/user/datasource_test.go b/stackit/internal/services/secretsmanager/user/datasource_test.go index 7ecfaba4b..0728d432c 100644 --- a/stackit/internal/services/secretsmanager/user/datasource_test.go +++ b/stackit/internal/services/secretsmanager/user/datasource_test.go @@ -5,7 +5,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" ) @@ -19,7 +18,7 @@ func TestMapDataSourceFields(t *testing.T) { { "default_values", &secretsmanager.User{ - Id: utils.Ptr("uid"), + Id: new("uid"), }, DataSourceModel{ Id: types.StringValue("pid,iid,uid"), @@ -35,10 +34,10 @@ func TestMapDataSourceFields(t *testing.T) { { "simple_values", &secretsmanager.User{ - Id: utils.Ptr("uid"), - Description: utils.Ptr("description"), - Write: utils.Ptr(false), - Username: utils.Ptr("username"), + Id: new("uid"), + Description: new("description"), + Write: new(false), + Username: new("username"), }, DataSourceModel{ Id: types.StringValue("pid,iid,uid"), diff --git a/stackit/internal/services/secretsmanager/user/resource_test.go b/stackit/internal/services/secretsmanager/user/resource_test.go index 2555685c4..d325bfdc2 100644 --- a/stackit/internal/services/secretsmanager/user/resource_test.go +++ b/stackit/internal/services/secretsmanager/user/resource_test.go @@ -5,7 +5,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" ) @@ -20,7 +19,7 @@ func TestMapFields(t *testing.T) { { "default_values", &secretsmanager.User{ - Id: utils.Ptr("uid"), + Id: new("uid"), }, nil, Model{ @@ -38,11 +37,11 @@ func TestMapFields(t *testing.T) { { "simple_values", &secretsmanager.User{ - Id: utils.Ptr("uid"), - Description: utils.Ptr("description"), - Write: utils.Ptr(false), - Username: utils.Ptr("username"), - Password: utils.Ptr("password"), + Id: new("uid"), + Description: new("description"), + Write: new(false), + Username: new("username"), + Password: new("password"), }, nil, Model{ @@ -74,12 +73,12 @@ func TestMapFields(t *testing.T) { { "no_password_in_response_1", &secretsmanager.User{ - Id: utils.Ptr("uid"), - Description: utils.Ptr("description"), - Write: utils.Ptr(false), - Username: utils.Ptr("username"), + Id: new("uid"), + Description: new("description"), + Write: new(false), + Username: new("username"), }, - utils.Ptr("password"), + new("password"), Model{ Id: types.StringValue("pid,iid,uid"), UserId: types.StringValue("uid"), @@ -95,13 +94,13 @@ func TestMapFields(t *testing.T) { { "no_password_in_response_2", &secretsmanager.User{ - Id: utils.Ptr("uid"), - Description: utils.Ptr("description"), - Write: utils.Ptr(false), - Username: utils.Ptr("username"), - Password: utils.Ptr(""), + Id: new("uid"), + Description: new("description"), + Write: new(false), + Username: new("username"), + Password: new(""), }, - utils.Ptr("password"), + new("password"), Model{ Id: types.StringValue("pid,iid,uid"), UserId: types.StringValue("uid"), @@ -164,8 +163,8 @@ func TestToCreatePayload(t *testing.T) { WriteEnabled: types.BoolValue(false), }, &secretsmanager.CreateUserPayload{ - Description: utils.Ptr("description"), - Write: utils.Ptr(false), + Description: new("description"), + Write: new(false), }, true, }, @@ -188,7 +187,7 @@ func TestToCreatePayload(t *testing.T) { WriteEnabled: types.BoolNull(), }, &secretsmanager.CreateUserPayload{ - Description: utils.Ptr(""), + Description: new(""), Write: nil, }, true, @@ -240,7 +239,7 @@ func TestToUpdatePayload(t *testing.T) { WriteEnabled: types.BoolValue(false), }, &secretsmanager.UpdateUserPayload{ - Write: utils.Ptr(false), + Write: new(false), }, true, }, diff --git a/stackit/internal/services/serverbackup/enable/datasource_test.go b/stackit/internal/services/serverbackup/enable/datasource_test.go index 582bc9279..0709a1cc8 100644 --- a/stackit/internal/services/serverbackup/enable/datasource_test.go +++ b/stackit/internal/services/serverbackup/enable/datasource_test.go @@ -6,7 +6,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" ) @@ -33,7 +32,7 @@ func TestDataMapFields(t *testing.T) { { "simple_values", &serverbackup.GetBackupServiceResponse{ - Enabled: utils.Ptr(true), + Enabled: new(true), }, DataModel{ Id: types.StringValue(id), diff --git a/stackit/internal/services/serverbackup/enable/resource_test.go b/stackit/internal/services/serverbackup/enable/resource_test.go index d9050790c..decbaee44 100644 --- a/stackit/internal/services/serverbackup/enable/resource_test.go +++ b/stackit/internal/services/serverbackup/enable/resource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" ) @@ -34,7 +33,7 @@ func TestMapFields(t *testing.T) { { "simple_values", &serverbackup.GetBackupServiceResponse{ - Enabled: utils.Ptr(true), + Enabled: new(true), }, Model{ Id: types.StringValue(id), diff --git a/stackit/internal/services/serverbackup/schedule/resource_test.go b/stackit/internal/services/serverbackup/schedule/resource_test.go index c3ecd45fd..f40cea6f9 100644 --- a/stackit/internal/services/serverbackup/schedule/resource_test.go +++ b/stackit/internal/services/serverbackup/schedule/resource_test.go @@ -6,7 +6,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" sdk "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" ) @@ -20,7 +19,7 @@ func TestMapFields(t *testing.T) { { "default_values", &sdk.BackupSchedule{ - Id: utils.Ptr(int64(5)), + Id: new(int64(5)), }, Model{ ID: types.StringValue("project_uid,eu01,server_uid,5"), @@ -33,13 +32,13 @@ func TestMapFields(t *testing.T) { { "simple_values", &sdk.BackupSchedule{ - Id: utils.Ptr(int64(5)), - Enabled: utils.Ptr(true), - Name: utils.Ptr("backup_schedule_name_1"), - Rrule: utils.Ptr("DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1"), + Id: new(int64(5)), + Enabled: new(true), + Name: new("backup_schedule_name_1"), + Rrule: new("DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1"), BackupProperties: &sdk.BackupProperties{ - Name: utils.Ptr("backup_name_1"), - RetentionPeriod: utils.Ptr(int64(3)), + Name: new("backup_name_1"), + RetentionPeriod: new(int64(3)), VolumeIds: &[]string{"uuid1", "uuid2"}, }, }, @@ -121,9 +120,9 @@ func TestToCreatePayload(t *testing.T) { BackupProperties: nil, }, &sdk.CreateBackupSchedulePayload{ - Name: utils.Ptr("name"), - Enabled: utils.Ptr(true), - Rrule: utils.Ptr("DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1"), + Name: new("name"), + Enabled: new(true), + Rrule: new("DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1"), BackupProperties: &sdk.BackupProperties{}, }, true, @@ -136,8 +135,8 @@ func TestToCreatePayload(t *testing.T) { }, &sdk.CreateBackupSchedulePayload{ BackupProperties: &sdk.BackupProperties{}, - Name: utils.Ptr(""), - Rrule: utils.Ptr(""), + Name: new(""), + Rrule: new(""), }, true, }, @@ -191,9 +190,9 @@ func TestToUpdatePayload(t *testing.T) { BackupProperties: nil, }, &sdk.UpdateBackupSchedulePayload{ - Name: utils.Ptr("name"), - Enabled: utils.Ptr(true), - Rrule: utils.Ptr("DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1"), + Name: new("name"), + Enabled: new(true), + Rrule: new("DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1"), BackupProperties: &sdk.BackupProperties{}, }, true, @@ -206,8 +205,8 @@ func TestToUpdatePayload(t *testing.T) { }, &sdk.UpdateBackupSchedulePayload{ BackupProperties: &sdk.BackupProperties{}, - Name: utils.Ptr(""), - Rrule: utils.Ptr(""), + Name: new(""), + Rrule: new(""), }, true, }, diff --git a/stackit/internal/services/serverbackup/schedule/schedules_datasource_test.go b/stackit/internal/services/serverbackup/schedule/schedules_datasource_test.go index 70bb3d26b..9e2ae0203 100644 --- a/stackit/internal/services/serverbackup/schedule/schedules_datasource_test.go +++ b/stackit/internal/services/serverbackup/schedule/schedules_datasource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "github.com/stackitcloud/stackit-sdk-go/core/utils" sdk "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" ) @@ -42,13 +41,13 @@ func TestMapSchedulesDataSourceFields(t *testing.T) { &sdk.GetBackupSchedulesResponse{ Items: &[]sdk.BackupSchedule{ { - Id: utils.Ptr(int64(5)), - Enabled: utils.Ptr(true), - Name: utils.Ptr("backup_schedule_name_1"), - Rrule: utils.Ptr("DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1"), + Id: new(int64(5)), + Enabled: new(true), + Name: new("backup_schedule_name_1"), + Rrule: new("DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1"), BackupProperties: &sdk.BackupProperties{ - Name: utils.Ptr("backup_name_1"), - RetentionPeriod: utils.Ptr(int64(14)), + Name: new("backup_name_1"), + RetentionPeriod: new(int64(14)), VolumeIds: &[]string{"uuid1", "uuid2"}, }, }, diff --git a/stackit/internal/services/serverupdate/schedule/resource_test.go b/stackit/internal/services/serverupdate/schedule/resource_test.go index 43cb28951..b99305d75 100644 --- a/stackit/internal/services/serverupdate/schedule/resource_test.go +++ b/stackit/internal/services/serverupdate/schedule/resource_test.go @@ -5,7 +5,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" sdk "github.com/stackitcloud/stackit-sdk-go/services/serverupdate" ) @@ -21,7 +20,7 @@ func TestMapFields(t *testing.T) { { "default_values", &sdk.UpdateSchedule{ - Id: utils.Ptr(int64(5)), + Id: new(int64(5)), }, testRegion, Model{ @@ -36,11 +35,11 @@ func TestMapFields(t *testing.T) { { "simple_values", &sdk.UpdateSchedule{ - Id: utils.Ptr(int64(5)), - Enabled: utils.Ptr(true), - Name: utils.Ptr("update_schedule_name_1"), - Rrule: utils.Ptr("DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1"), - MaintenanceWindow: utils.Ptr(int64(1)), + Id: new(int64(5)), + Enabled: new(true), + Name: new("update_schedule_name_1"), + Rrule: new("DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1"), + MaintenanceWindow: new(int64(1)), }, testRegion, Model{ @@ -116,10 +115,10 @@ func TestToCreatePayload(t *testing.T) { MaintenanceWindow: types.Int64Value(1), }, &sdk.CreateUpdateSchedulePayload{ - Name: utils.Ptr("name"), - Enabled: utils.Ptr(true), - Rrule: utils.Ptr("DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1"), - MaintenanceWindow: utils.Ptr(int64(1)), + Name: new("name"), + Enabled: new(true), + Rrule: new("DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1"), + MaintenanceWindow: new(int64(1)), }, true, }, @@ -130,8 +129,8 @@ func TestToCreatePayload(t *testing.T) { Rrule: types.StringValue(""), }, &sdk.CreateUpdateSchedulePayload{ - Name: utils.Ptr(""), - Rrule: utils.Ptr(""), + Name: new(""), + Rrule: new(""), }, true, }, @@ -183,10 +182,10 @@ func TestToUpdatePayload(t *testing.T) { MaintenanceWindow: types.Int64Value(1), }, &sdk.UpdateUpdateSchedulePayload{ - Name: utils.Ptr("name"), - Enabled: utils.Ptr(true), - Rrule: utils.Ptr("DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1"), - MaintenanceWindow: utils.Ptr(int64(1)), + Name: new("name"), + Enabled: new(true), + Rrule: new("DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1"), + MaintenanceWindow: new(int64(1)), }, true, }, @@ -197,8 +196,8 @@ func TestToUpdatePayload(t *testing.T) { Rrule: types.StringValue(""), }, &sdk.UpdateUpdateSchedulePayload{ - Name: utils.Ptr(""), - Rrule: utils.Ptr(""), + Name: new(""), + Rrule: new(""), }, true, }, diff --git a/stackit/internal/services/serverupdate/schedule/schedules_datasource_test.go b/stackit/internal/services/serverupdate/schedule/schedules_datasource_test.go index 2619daf09..552c5704b 100644 --- a/stackit/internal/services/serverupdate/schedule/schedules_datasource_test.go +++ b/stackit/internal/services/serverupdate/schedule/schedules_datasource_test.go @@ -6,7 +6,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" sdk "github.com/stackitcloud/stackit-sdk-go/services/serverupdate" ) @@ -39,11 +38,11 @@ func TestMapSchedulesDataSourceFields(t *testing.T) { &sdk.GetUpdateSchedulesResponse{ Items: &[]sdk.UpdateSchedule{ { - Id: utils.Ptr(int64(5)), - Enabled: utils.Ptr(true), - Name: utils.Ptr("update_schedule_name_1"), - Rrule: utils.Ptr("DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1"), - MaintenanceWindow: utils.Ptr(int64(1)), + Id: new(int64(5)), + Enabled: new(true), + Name: new("update_schedule_name_1"), + Rrule: new("DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1"), + MaintenanceWindow: new(int64(1)), }, }, }, diff --git a/stackit/internal/services/serviceaccount/account/resource_test.go b/stackit/internal/services/serviceaccount/account/resource_test.go index d2ef4c37e..32aa47d06 100644 --- a/stackit/internal/services/serviceaccount/account/resource_test.go +++ b/stackit/internal/services/serviceaccount/account/resource_test.go @@ -5,7 +5,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/serviceaccount" ) @@ -22,7 +21,7 @@ func TestToCreatePayload(t *testing.T) { Name: types.StringValue("example-name1"), }, &serviceaccount.CreateServiceAccountPayload{ - Name: utils.Ptr("example-name1"), + Name: new("example-name1"), }, true, }, @@ -62,9 +61,9 @@ func TestMapFields(t *testing.T) { { "default_values", &serviceaccount.ServiceAccount{ - Id: utils.Ptr("550e8400-e29b-41d4-a716-446655440000"), - ProjectId: utils.Ptr("pid"), - Email: utils.Ptr("mail"), + Id: new("550e8400-e29b-41d4-a716-446655440000"), + ProjectId: new("pid"), + Email: new("mail"), }, Model{ Id: types.StringValue("pid,mail"), @@ -89,8 +88,8 @@ func TestMapFields(t *testing.T) { { "no_email", &serviceaccount.ServiceAccount{ - ProjectId: utils.Ptr("pid"), - Id: utils.Ptr("550e8400-e29b-41d4-a716-446655440000"), + ProjectId: new("pid"), + Id: new("550e8400-e29b-41d4-a716-446655440000"), }, Model{}, false, @@ -98,8 +97,8 @@ func TestMapFields(t *testing.T) { { "no_id", &serviceaccount.ServiceAccount{ - ProjectId: utils.Ptr("pid"), - Email: utils.Ptr("mail"), + ProjectId: new("pid"), + Email: new("mail"), }, Model{}, false, diff --git a/stackit/internal/services/serviceaccount/accounts/datasource_test.go b/stackit/internal/services/serviceaccount/accounts/datasource_test.go index fcf05b9e9..962b4031b 100644 --- a/stackit/internal/services/serviceaccount/accounts/datasource_test.go +++ b/stackit/internal/services/serviceaccount/accounts/datasource_test.go @@ -6,7 +6,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/serviceaccount" ) @@ -35,9 +34,9 @@ func TestMapDataSourceFields(t *testing.T) { { description: "default_sort_descending", apiItems: []serviceaccount.ServiceAccount{ - {Email: utils.Ptr(emailA), Id: utils.Ptr(idA)}, - {Email: utils.Ptr(emailC), Id: utils.Ptr(idC)}, - {Email: utils.Ptr(emailB), Id: utils.Ptr(idB)}, + {Email: new(emailA), Id: new(idA)}, + {Email: new(emailC), Id: new(idC)}, + {Email: new(emailB), Id: new(idB)}, }, initialModel: ServiceAccountsModel{ ProjectId: types.StringValue(projectId), @@ -58,9 +57,9 @@ func TestMapDataSourceFields(t *testing.T) { { description: "sort_ascending", apiItems: []serviceaccount.ServiceAccount{ - {Email: utils.Ptr(emailC), Id: utils.Ptr(idC)}, - {Email: utils.Ptr(emailA), Id: utils.Ptr(idA)}, - {Email: utils.Ptr(emailB), Id: utils.Ptr(idB)}, + {Email: new(emailC), Id: new(idC)}, + {Email: new(emailA), Id: new(idA)}, + {Email: new(emailB), Id: new(idB)}, }, initialModel: ServiceAccountsModel{ ProjectId: types.StringValue(projectId), @@ -81,9 +80,9 @@ func TestMapDataSourceFields(t *testing.T) { { description: "regex_filter_match", apiItems: []serviceaccount.ServiceAccount{ - {Email: utils.Ptr(emailA), Id: utils.Ptr(idA)}, - {Email: utils.Ptr(emailB), Id: utils.Ptr(idB)}, - {Email: utils.Ptr(emailC), Id: utils.Ptr(idC)}, + {Email: new(emailA), Id: new(idA)}, + {Email: new(emailB), Id: new(idB)}, + {Email: new(emailC), Id: new(idC)}, }, initialModel: ServiceAccountsModel{ ProjectId: types.StringValue(projectId), @@ -105,9 +104,9 @@ func TestMapDataSourceFields(t *testing.T) { { description: "suffix_filter_match", apiItems: []serviceaccount.ServiceAccount{ - {Email: utils.Ptr(emailA), Id: utils.Ptr(idA)}, - {Email: utils.Ptr(emailB), Id: utils.Ptr(idB)}, - {Email: utils.Ptr(emailC), Id: utils.Ptr(idC)}, + {Email: new(emailA), Id: new(idA)}, + {Email: new(emailB), Id: new(idB)}, + {Email: new(emailC), Id: new(idC)}, }, initialModel: ServiceAccountsModel{ ProjectId: types.StringValue(projectId), @@ -126,7 +125,7 @@ func TestMapDataSourceFields(t *testing.T) { { description: "skip_nil_email", apiItems: []serviceaccount.ServiceAccount{ - {Email: utils.Ptr(emailA), Id: utils.Ptr(idA)}, + {Email: new(emailA), Id: new(idA)}, {Email: nil}, // Should be skipped }, initialModel: ServiceAccountsModel{ diff --git a/stackit/internal/services/serviceaccount/key/resource_test.go b/stackit/internal/services/serviceaccount/key/resource_test.go index 15f90a1ba..3d2b177c2 100644 --- a/stackit/internal/services/serviceaccount/key/resource_test.go +++ b/stackit/internal/services/serviceaccount/key/resource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/serviceaccount" ) @@ -20,13 +19,13 @@ func TestComputeValidUntil(t *testing.T) { }{ { name: "ttlDays is 10", - ttlDays: utils.Ptr(10), + ttlDays: new(10), isValid: true, expected: time.Now().UTC().Add(time.Duration(10) * 24 * time.Hour), }, { name: "ttlDays is 0", - ttlDays: utils.Ptr(0), + ttlDays: new(0), isValid: true, expected: time.Now().UTC().Add(time.Duration(0) * 24 * time.Hour), }, @@ -62,7 +61,7 @@ func TestMapResponse(t *testing.T) { { description: "default_values", input: &serviceaccount.CreateServiceAccountKeyResponse{ - Id: utils.Ptr("id"), + Id: new("id"), }, expected: Model{ Id: types.StringValue("pid,email,id"), @@ -89,7 +88,7 @@ func TestMapResponse(t *testing.T) { { description: "no_id", input: &serviceaccount.CreateServiceAccountKeyResponse{ - Active: utils.Ptr(true), + Active: new(true), }, expected: Model{}, isValid: false, diff --git a/stackit/internal/services/sfs/export-policy/resource_test.go b/stackit/internal/services/sfs/export-policy/resource_test.go index ee939d703..02ffb6170 100644 --- a/stackit/internal/services/sfs/export-policy/resource_test.go +++ b/stackit/internal/services/sfs/export-policy/resource_test.go @@ -10,7 +10,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/sfs" ) @@ -20,20 +19,20 @@ var project_id = "project_id" func fixtureRulesResponse() *[]sfs.ShareExportPolicyRule { return &[]sfs.ShareExportPolicyRule{ { - Description: sfs.NewNullableString(utils.Ptr("description")), - IpAcl: utils.Ptr([]string{"172.16.0.0/24", "172.16.0.251/32"}), - Order: utils.Ptr(int64(0)), - ReadOnly: utils.Ptr(false), - SetUuid: utils.Ptr(false), - SuperUser: utils.Ptr(false), + Description: sfs.NewNullableString(new("description")), + IpAcl: new([]string{"172.16.0.0/24", "172.16.0.251/32"}), + Order: new(int64(0)), + ReadOnly: new(false), + SetUuid: new(false), + SuperUser: new(false), }, { - Description: sfs.NewNullableString(utils.Ptr("description")), - IpAcl: utils.Ptr([]string{"172.32.0.0/24", "172.32.0.251/32"}), - Order: utils.Ptr(int64(1)), - ReadOnly: utils.Ptr(false), - SetUuid: utils.Ptr(false), - SuperUser: utils.Ptr(false), + Description: sfs.NewNullableString(new("description")), + IpAcl: new([]string{"172.32.0.0/24", "172.32.0.251/32"}), + Order: new(int64(1)), + ReadOnly: new(false), + SetUuid: new(false), + SuperUser: new(false), }, } } @@ -79,26 +78,26 @@ func fixtureResponseModel(rulesModel basetypes.ListValue) *Model { func fixtureRulesCreatePayload() []sfs.CreateShareExportPolicyRequestRule { return []sfs.CreateShareExportPolicyRequestRule{ { - Description: sfs.NewNullableString(utils.Ptr("description")), + Description: sfs.NewNullableString(new("description")), IpAcl: &[]string{ "172.32.0.0/24", "172.32.0.251/32", }, - Order: utils.Ptr(int64(0)), - ReadOnly: utils.Ptr(false), - SetUuid: utils.Ptr(false), - SuperUser: utils.Ptr(false), + Order: new(int64(0)), + ReadOnly: new(false), + SetUuid: new(false), + SuperUser: new(false), }, { - Description: sfs.NewNullableString(utils.Ptr("description")), + Description: sfs.NewNullableString(new("description")), IpAcl: &[]string{ "172.16.0.0/24", "172.16.0.251/32", }, - Order: utils.Ptr(int64(1)), - ReadOnly: utils.Ptr(false), - SetUuid: utils.Ptr(false), - SuperUser: utils.Ptr(false), + Order: new(int64(1)), + ReadOnly: new(false), + SetUuid: new(false), + SuperUser: new(false), }, } } @@ -106,26 +105,26 @@ func fixtureRulesCreatePayload() []sfs.CreateShareExportPolicyRequestRule { func fixtureRulesUpdatePayload() []sfs.UpdateShareExportPolicyBodyRule { return []sfs.UpdateShareExportPolicyBodyRule{ { - Description: sfs.NewNullableString(utils.Ptr("description")), + Description: sfs.NewNullableString(new("description")), IpAcl: &[]string{ "172.32.0.0/24", "172.32.0.251/32", }, - Order: utils.Ptr(int64(0)), - ReadOnly: utils.Ptr(false), - SetUuid: utils.Ptr(false), - SuperUser: utils.Ptr(false), + Order: new(int64(0)), + ReadOnly: new(false), + SetUuid: new(false), + SuperUser: new(false), }, { - Description: sfs.NewNullableString(utils.Ptr("description")), + Description: sfs.NewNullableString(new("description")), IpAcl: &[]string{ "172.16.0.0/24", "172.16.0.251/32", }, - Order: utils.Ptr(int64(1)), - ReadOnly: utils.Ptr(false), - SetUuid: utils.Ptr(false), - SuperUser: utils.Ptr(false), + Order: new(int64(1)), + ReadOnly: new(false), + SetUuid: new(false), + SuperUser: new(false), }, } } @@ -153,7 +152,7 @@ func fixtureRulesPayloadModel() []rulesModel { func fixtureExportPolicyCreatePayload(rules *[]sfs.CreateShareExportPolicyRequestRule) *sfs.CreateShareExportPolicyPayload { return &sfs.CreateShareExportPolicyPayload{ - Name: utils.Ptr("createPayloadName"), + Name: new("createPayloadName"), Rules: rules, } } @@ -199,7 +198,7 @@ func TestMapFields(t *testing.T) { }, input: &sfs.GetShareExportPolicyResponse{ ShareExportPolicy: &sfs.GetShareExportPolicyResponseShareExportPolicy{ - Id: utils.Ptr("uuid1"), + Id: new("uuid1"), Rules: &[]sfs.ShareExportPolicyRule{}, }, }, @@ -214,7 +213,7 @@ func TestMapFields(t *testing.T) { }, input: &sfs.GetShareExportPolicyResponse{ ShareExportPolicy: &sfs.GetShareExportPolicyResponseShareExportPolicy{ - Id: utils.Ptr("uuid1"), + Id: new("uuid1"), Rules: fixtureRulesResponse(), }, }, @@ -282,7 +281,7 @@ func TestToCreatePayload(t *testing.T) { Name: types.StringValue("createPayloadName"), }, rules: fixtureRulesPayloadModel(), - expected: fixtureExportPolicyCreatePayload(utils.Ptr(fixtureRulesCreatePayload())), + expected: fixtureExportPolicyCreatePayload(new(fixtureRulesCreatePayload())), wantErr: false, }, } diff --git a/stackit/internal/services/sfs/resourcepool/datasource_test.go b/stackit/internal/services/sfs/resourcepool/datasource_test.go index 0cc1e629a..e39076e2c 100644 --- a/stackit/internal/services/sfs/resourcepool/datasource_test.go +++ b/stackit/internal/services/sfs/resourcepool/datasource_test.go @@ -62,19 +62,19 @@ func TestMapDatasourceFields(t *testing.T) { CreatedAt: &now, Id: testResourcePoolId.ValueStringPointer(), IpAcl: &[]string{"foo", "bar", "baz"}, - MountPath: utils.Ptr("mountpoint"), - Name: utils.Ptr("testname"), + MountPath: new("mountpoint"), + Name: new("testname"), PerformanceClass: &sfs.ResourcePoolPerformanceClass{ - Name: utils.Ptr("performance"), + Name: new("performance"), PeakIops: utils.Ptr[int64](42), Throughput: utils.Ptr[int64](54), }, - PerformanceClassDowngradableAt: utils.Ptr(now), - SizeReducibleAt: utils.Ptr(now.Add(1 * time.Hour)), + PerformanceClassDowngradableAt: new(now), + SizeReducibleAt: new(now.Add(1 * time.Hour)), Space: &sfs.ResourcePoolSpace{ SizeGigabytes: utils.Ptr[int64](42), }, - State: utils.Ptr("state"), + State: new("state"), }, expected: &dataSourceModel{ Id: testId, diff --git a/stackit/internal/services/sfs/resourcepool/resource_test.go b/stackit/internal/services/sfs/resourcepool/resource_test.go index 86eaf3a20..9a4c35fe9 100644 --- a/stackit/internal/services/sfs/resourcepool/resource_test.go +++ b/stackit/internal/services/sfs/resourcepool/resource_test.go @@ -70,10 +70,10 @@ func TestMapFields(t *testing.T) { CreatedAt: &testTime, Id: testResourcePoolId.ValueStringPointer(), IpAcl: &[]string{"foo", "bar", "baz"}, - MountPath: utils.Ptr("mountpoint"), - Name: utils.Ptr("testname"), + MountPath: new("mountpoint"), + Name: new("testname"), PerformanceClass: &sfs.ResourcePoolPerformanceClass{ - Name: utils.Ptr("performance"), + Name: new("performance"), PeakIops: utils.Ptr[int64](42), Throughput: utils.Ptr[int64](54), }, @@ -82,7 +82,7 @@ func TestMapFields(t *testing.T) { Space: &sfs.ResourcePoolSpace{ SizeGigabytes: utils.Ptr[int64](42), }, - State: utils.Ptr("state"), + State: new("state"), }, expected: &Model{ Id: testId, @@ -138,9 +138,9 @@ func TestToCreatePayload(t *testing.T) { }, &sfs.CreateResourcePoolPayload{ AvailabilityZone: testAvailabilityZone.ValueStringPointer(), - IpAcl: utils.Ptr([]string{"foo", "bar", "baz"}), - Name: utils.Ptr("testname"), - PerformanceClass: utils.Ptr("performance"), + IpAcl: new([]string{"foo", "bar", "baz"}), + Name: new("testname"), + PerformanceClass: new("performance"), SizeGigabytes: utils.Ptr[int64](42), }, false, @@ -160,8 +160,8 @@ func TestToCreatePayload(t *testing.T) { &sfs.CreateResourcePoolPayload{ AvailabilityZone: testAvailabilityZone.ValueStringPointer(), IpAcl: nil, - Name: utils.Ptr("testname"), - PerformanceClass: utils.Ptr("performance"), + Name: new("testname"), + PerformanceClass: new("performance"), SizeGigabytes: utils.Ptr[int64](42), }, false, @@ -202,10 +202,10 @@ func TestToUpdatePayload(t *testing.T) { SnapshotsAreVisible: types.BoolValue(true), }, &sfs.UpdateResourcePoolPayload{ - IpAcl: utils.Ptr([]string{"foo", "bar", "baz"}), - PerformanceClass: utils.Ptr("performance"), + IpAcl: new([]string{"foo", "bar", "baz"}), + PerformanceClass: new("performance"), SizeGigabytes: utils.Ptr[int64](42), - SnapshotsAreVisible: utils.Ptr[bool](true), + SnapshotsAreVisible: new(true), }, false, }, @@ -223,7 +223,7 @@ func TestToUpdatePayload(t *testing.T) { }, &sfs.UpdateResourcePoolPayload{ IpAcl: nil, - PerformanceClass: utils.Ptr("performance"), + PerformanceClass: new("performance"), SizeGigabytes: utils.Ptr[int64](42), }, false, @@ -241,8 +241,8 @@ func TestToUpdatePayload(t *testing.T) { SizeGigabytes: types.Int64Value(42), }, &sfs.UpdateResourcePoolPayload{ - IpAcl: utils.Ptr([]string{}), - PerformanceClass: utils.Ptr("performance"), + IpAcl: new([]string{}), + PerformanceClass: new("performance"), SizeGigabytes: utils.Ptr[int64](42), }, false, diff --git a/stackit/internal/services/sfs/sfs_test.go b/stackit/internal/services/sfs/sfs_test.go index a9af2fccf..27665e94c 100644 --- a/stackit/internal/services/sfs/sfs_test.go +++ b/stackit/internal/services/sfs/sfs_test.go @@ -8,7 +8,6 @@ import ( "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/sfs" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/testutil" ) @@ -48,7 +47,7 @@ resource "stackit_sfs_resource_pool" "resourcepool" { Description: "create instance", ToJsonBody: sfs.CreateResourcePoolResponse{ ResourcePool: &sfs.CreateResourcePoolResponseResourcePool{ - Id: utils.Ptr(instanceId), + Id: new(instanceId), }, }, }, @@ -123,7 +122,7 @@ resource "stackit_sfs_share" "example" { Description: "create instance", ToJsonBody: sfs.CreateShareResponse{ Share: &sfs.CreateShareResponseShare{ - Id: utils.Ptr(instanceId), + Id: new(instanceId), }, }, }, diff --git a/stackit/internal/services/sfs/share/datasource_test.go b/stackit/internal/services/sfs/share/datasource_test.go index 24cdc6ae5..d7f86d7c8 100644 --- a/stackit/internal/services/sfs/share/datasource_test.go +++ b/stackit/internal/services/sfs/share/datasource_test.go @@ -30,11 +30,11 @@ func TestMapDatasourceFields(t *testing.T) { &sfs.GetShareResponseShare{ ExportPolicy: sfs.NewNullableShareExportPolicy(&sfs.ShareExportPolicy{ Id: testId.ValueStringPointer(), - Name: utils.Ptr("test-policy"), + Name: new("test-policy"), }), Id: testShareId.ValueStringPointer(), - MountPath: utils.Ptr("/testmount"), - Name: utils.Ptr("test-name"), + MountPath: new("/testmount"), + Name: new("test-name"), SpaceHardLimitGigabytes: utils.Ptr[int64](42), }, &dataSourceModel{ diff --git a/stackit/internal/services/sfs/share/resource_test.go b/stackit/internal/services/sfs/share/resource_test.go index f9127374d..1846f5a16 100644 --- a/stackit/internal/services/sfs/share/resource_test.go +++ b/stackit/internal/services/sfs/share/resource_test.go @@ -42,9 +42,9 @@ func TestMapFields(t *testing.T) { "eu01", &sfs.GetShareResponseShare{ Id: testShareId.ValueStringPointer(), - Name: utils.Ptr("testname"), + Name: new("testname"), ExportPolicy: sfs.NewNullableShareExportPolicy(&sfs.ShareExportPolicy{ - Name: utils.Ptr("test-policy"), + Name: new("test-policy"), }), SpaceHardLimitGigabytes: utils.Ptr[int64](42), }, @@ -71,12 +71,12 @@ func TestMapFields(t *testing.T) { input: &sfs.GetShareResponseShare{ CreatedAt: &testTime, Id: testShareId.ValueStringPointer(), - MountPath: utils.Ptr("mountpoint"), - Name: utils.Ptr("testname"), + MountPath: new("mountpoint"), + Name: new("testname"), SpaceHardLimitGigabytes: sfs.PtrInt64(42), - State: utils.Ptr("state"), + State: new("state"), ExportPolicy: sfs.NewNullableShareExportPolicy(&sfs.ShareExportPolicy{ - Name: utils.Ptr("test-policy"), + Name: new("test-policy"), }), }, expected: &Model{ @@ -127,8 +127,8 @@ func TestToCreatePayload(t *testing.T) { SpaceHardLimitGigabytes: types.Int64Value(42), }, sfs.CreateSharePayload{ - ExportPolicyName: sfs.NewNullableString(utils.Ptr("test-policy")), - Name: sfs.PtrString("testname"), + ExportPolicyName: sfs.NewNullableString(new("test-policy")), + Name: new("testname"), SpaceHardLimitGigabytes: sfs.PtrInt64(42), }, false, diff --git a/stackit/internal/services/sfs/snapshots/datasource_test.go b/stackit/internal/services/sfs/snapshots/datasource_test.go index 68e8f5876..5ddd515ed 100644 --- a/stackit/internal/services/sfs/snapshots/datasource_test.go +++ b/stackit/internal/services/sfs/snapshots/datasource_test.go @@ -11,7 +11,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/sfs" ) @@ -50,20 +49,20 @@ func TestMapDatasourceFields(t *testing.T) { "eu01", &[]sfs.ResourcePoolSnapshot{ { - Comment: sfs.NewNullableString(utils.Ptr("comment 1")), - CreatedAt: utils.Ptr(testTime), + Comment: sfs.NewNullableString(new("comment 1")), + CreatedAt: new(testTime), ResourcePoolId: testResourcePoolId.ValueStringPointer(), - SnapshotName: utils.Ptr("snapshot-1"), - SizeGigabytes: utils.Ptr(int64(50)), - LogicalSizeGigabytes: utils.Ptr(int64(50)), + SnapshotName: new("snapshot-1"), + SizeGigabytes: new(int64(50)), + LogicalSizeGigabytes: new(int64(50)), }, { - Comment: sfs.NewNullableString(utils.Ptr("comment 2")), - CreatedAt: utils.Ptr(testTime.Add(1 * time.Hour)), + Comment: sfs.NewNullableString(new("comment 2")), + CreatedAt: new(testTime.Add(1 * time.Hour)), ResourcePoolId: testResourcePoolId.ValueStringPointer(), - SnapshotName: utils.Ptr("snapshot-2"), - SizeGigabytes: utils.Ptr(int64(50)), - LogicalSizeGigabytes: utils.Ptr(int64(50)), + SnapshotName: new("snapshot-2"), + SizeGigabytes: new(int64(50)), + LogicalSizeGigabytes: new(int64(50)), }, }, &dataSourceModel{ diff --git a/stackit/internal/services/ske/cluster/resource.go b/stackit/internal/services/ske/cluster/resource.go index 6f69b54da..e3d3ca182 100644 --- a/stackit/internal/services/ske/cluster/resource.go +++ b/stackit/internal/services/ske/cluster/resource.go @@ -1358,7 +1358,7 @@ func toMaintenancePayload(ctx context.Context, m *Model) (*ske.Maintenance, erro if err != nil { return nil, fmt.Errorf("converting maintenance object: %w", err) } - timeWindowStart = sdkUtils.Ptr(tempTime) + timeWindowStart = new(tempTime) } var timeWindowEnd *time.Time @@ -1367,7 +1367,7 @@ func toMaintenancePayload(ctx context.Context, m *Model) (*ske.Maintenance, erro if err != nil { return nil, fmt.Errorf("converting maintenance object: %w", err) } - timeWindowEnd = sdkUtils.Ptr(tempTime) + timeWindowEnd = new(tempTime) } return &ske.Maintenance{ diff --git a/stackit/internal/services/ske/cluster/resource_test.go b/stackit/internal/services/ske/cluster/resource_test.go index f8d7137e2..366f6841e 100644 --- a/stackit/internal/services/ske/cluster/resource_test.go +++ b/stackit/internal/services/ske/cluster/resource_test.go @@ -12,7 +12,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/ske" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core" @@ -49,7 +48,7 @@ func TestMapFields(t *testing.T) { types.ObjectNull(extensionsTypes), types.ListNull(types.ObjectType{AttrTypes: nodePoolTypes}), &ske.Cluster{ - Name: utils.Ptr("name"), + Name: new("name"), }, testRegion, Model{ @@ -75,49 +74,49 @@ func TestMapFields(t *testing.T) { Extensions: &ske.Extension{ Acl: &ske.ACL{ AllowedCidrs: &[]string{"cidr1"}, - Enabled: utils.Ptr(true), + Enabled: new(true), }, Observability: &ske.Observability{ - InstanceId: utils.Ptr("aid"), - Enabled: utils.Ptr(true), + InstanceId: new("aid"), + Enabled: new(true), }, Dns: &ske.DNS{ Zones: &[]string{"foo.onstackit.cloud"}, - Enabled: utils.Ptr(true), + Enabled: new(true), }, }, Hibernation: &ske.Hibernation{ Schedules: &[]ske.HibernationSchedule{ { - End: utils.Ptr("2"), - Start: utils.Ptr("1"), - Timezone: utils.Ptr("CET"), + End: new("2"), + Start: new("1"), + Timezone: new("CET"), }, }, }, Kubernetes: &ske.Kubernetes{ - Version: utils.Ptr("1.2.3"), + Version: new("1.2.3"), }, Maintenance: &ske.Maintenance{ AutoUpdate: &ske.MaintenanceAutoUpdate{ - KubernetesVersion: utils.Ptr(true), - MachineImageVersion: utils.Ptr(true), + KubernetesVersion: new(true), + MachineImageVersion: new(true), }, TimeWindow: &ske.TimeWindow{ - Start: utils.Ptr(time.Date(0, 1, 2, 3, 4, 5, 6, time.FixedZone("UTC+6:00", 6*60*60))), - End: utils.Ptr(time.Date(10, 11, 12, 13, 14, 15, 0, time.UTC)), + Start: new(time.Date(0, 1, 2, 3, 4, 5, 6, time.FixedZone("UTC+6:00", 6*60*60))), + End: new(time.Date(10, 11, 12, 13, 14, 15, 0, time.UTC)), }, }, Network: &ske.Network{ - Id: utils.Ptr("nid"), + Id: new("nid"), ControlPlane: &ske.V2ControlPlaneNetwork{ - AccessScope: ske.V2ControlPlaneNetworkGetAccessScopeAttributeType(utils.Ptr("SNA")), + AccessScope: ske.V2ControlPlaneNetworkGetAccessScopeAttributeType(new("SNA")), }, }, - Name: utils.Ptr("name"), + Name: new("name"), Nodepools: &[]ske.Nodepool{ { - AllowSystemComponents: utils.Ptr(true), + AllowSystemComponents: new(true), AvailabilityZones: &[]string{"z1", "z2"}, Cri: &ske.CRI{ Name: ske.CRINAME_DOCKER.Ptr(), @@ -125,26 +124,26 @@ func TestMapFields(t *testing.T) { Labels: &map[string]string{"k": "v"}, Machine: &ske.Machine{ Image: &ske.Image{ - Name: utils.Ptr("os"), - Version: utils.Ptr("os-ver"), + Name: new("os"), + Version: new("os-ver"), }, - Type: utils.Ptr("B"), + Type: new("B"), }, - MaxSurge: utils.Ptr(int64(3)), + MaxSurge: new(int64(3)), MaxUnavailable: nil, - Maximum: utils.Ptr(int64(5)), - Minimum: utils.Ptr(int64(1)), - Name: utils.Ptr("node"), + Maximum: new(int64(5)), + Minimum: new(int64(1)), + Name: new("node"), Taints: &[]ske.Taint{ { Effect: ske.TAINTEFFECT_NO_EXECUTE.Ptr(), - Key: utils.Ptr("key"), - Value: utils.Ptr("value"), + Key: new("key"), + Value: new("value"), }, }, Volume: &ske.Volume{ - Size: utils.Ptr(int64(3)), - Type: utils.Ptr("type"), + Size: new(int64(3)), + Type: new("type"), }, }, }, @@ -279,7 +278,7 @@ func TestMapFields(t *testing.T) { types.ObjectNull(extensionsTypes), types.ListNull(types.ObjectType{AttrTypes: nodePoolTypes}), &ske.Cluster{ - Name: utils.Ptr("name"), + Name: new("name"), Network: &ske.Network{}, }, testRegion, @@ -306,18 +305,18 @@ func TestMapFields(t *testing.T) { Extensions: &ske.Extension{ Acl: &ske.ACL{ AllowedCidrs: nil, - Enabled: utils.Ptr(true), + Enabled: new(true), }, Observability: &ske.Observability{ InstanceId: nil, - Enabled: utils.Ptr(true), + Enabled: new(true), }, Dns: &ske.DNS{ Zones: nil, - Enabled: utils.Ptr(true), + Enabled: new(true), }, }, - Name: utils.Ptr("name"), + Name: new("name"), }, testRegion, Model{ @@ -368,7 +367,7 @@ func TestMapFields(t *testing.T) { types.ListNull(types.ObjectType{AttrTypes: nodePoolTypes}), &ske.Cluster{ Extensions: &ske.Extension{}, - Name: utils.Ptr("name"), + Name: new("name"), }, testRegion, Model{ @@ -423,14 +422,14 @@ func TestMapFields(t *testing.T) { Extensions: &ske.Extension{ Acl: &ske.ACL{ AllowedCidrs: &[]string{"cidr1"}, - Enabled: utils.Ptr(true), + Enabled: new(true), }, Dns: &ske.DNS{ Zones: nil, - Enabled: utils.Ptr(true), + Enabled: new(true), }, }, - Name: utils.Ptr("name"), + Name: new("name"), }, testRegion, Model{ @@ -469,7 +468,7 @@ func TestMapFields(t *testing.T) { types.ListNull(types.ObjectType{AttrTypes: nodePoolTypes}), &ske.Cluster{ Extensions: &ske.Extension{}, - Name: utils.Ptr("name"), + Name: new("name"), }, testRegion, Model{ @@ -531,46 +530,46 @@ func TestMapFields(t *testing.T) { Extensions: &ske.Extension{ Acl: &ske.ACL{ AllowedCidrs: &[]string{"cidr1"}, - Enabled: utils.Ptr(true), + Enabled: new(true), }, Observability: &ske.Observability{ - InstanceId: utils.Ptr("aid"), - Enabled: utils.Ptr(true), + InstanceId: new("aid"), + Enabled: new(true), }, Dns: &ske.DNS{ Zones: &[]string{"zone1"}, - Enabled: utils.Ptr(true), + Enabled: new(true), }, }, Hibernation: &ske.Hibernation{ Schedules: &[]ske.HibernationSchedule{ { - End: utils.Ptr("2"), - Start: utils.Ptr("1"), - Timezone: utils.Ptr("CET"), + End: new("2"), + Start: new("1"), + Timezone: new("CET"), }, }, }, Kubernetes: &ske.Kubernetes{ - Version: utils.Ptr("1.2.3"), + Version: new("1.2.3"), }, Maintenance: &ske.Maintenance{ AutoUpdate: &ske.MaintenanceAutoUpdate{ - KubernetesVersion: utils.Ptr(true), - MachineImageVersion: utils.Ptr(true), + KubernetesVersion: new(true), + MachineImageVersion: new(true), }, TimeWindow: &ske.TimeWindow{ - Start: utils.Ptr(time.Date(0, 1, 2, 3, 4, 5, 6, time.FixedZone("UTC+6:00", 6*60*60))), - End: utils.Ptr(time.Date(10, 11, 12, 13, 14, 15, 0, time.UTC)), + Start: new(time.Date(0, 1, 2, 3, 4, 5, 6, time.FixedZone("UTC+6:00", 6*60*60))), + End: new(time.Date(10, 11, 12, 13, 14, 15, 0, time.UTC)), }, }, Network: &ske.Network{ - Id: utils.Ptr("nid"), + Id: new("nid"), ControlPlane: &ske.V2ControlPlaneNetwork{ - AccessScope: ske.V2ControlPlaneNetworkGetAccessScopeAttributeType(utils.Ptr("SNA")), + AccessScope: ske.V2ControlPlaneNetworkGetAccessScopeAttributeType(new("SNA")), }, }, - Name: utils.Ptr("name"), + Name: new("name"), Nodepools: &[]ske.Nodepool{ { AvailabilityZones: &[]string{"z1", "z2"}, @@ -580,20 +579,20 @@ func TestMapFields(t *testing.T) { Labels: &map[string]string{"k": "v"}, Machine: &ske.Machine{ Image: &ske.Image{ - Name: utils.Ptr("os"), - Version: utils.Ptr("os-ver"), + Name: new("os"), + Version: new("os-ver"), }, - Type: utils.Ptr("B"), + Type: new("B"), }, - MaxSurge: utils.Ptr(int64(3)), + MaxSurge: new(int64(3)), MaxUnavailable: nil, - Maximum: utils.Ptr(int64(5)), - Minimum: utils.Ptr(int64(1)), - Name: utils.Ptr("node"), + Maximum: new(int64(5)), + Minimum: new(int64(1)), + Name: new("node"), Taints: nil, Volume: &ske.Volume{ - Size: utils.Ptr(int64(3)), - Type: utils.Ptr("type"), + Size: new(int64(3)), + Type: new("type"), }, }, }, @@ -755,25 +754,25 @@ func TestLatestMatchingKubernetesVersion(t *testing.T) { "available_version", []ske.KubernetesVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.20.1"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.1"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.20.2"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.2"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, - utils.Ptr("1.20.1"), + new("1.20.1"), nil, - utils.Ptr("1.20.1"), + new("1.20.1"), false, false, true, @@ -782,25 +781,25 @@ func TestLatestMatchingKubernetesVersion(t *testing.T) { "available_version_zero_patch", []ske.KubernetesVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.20.1"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.1"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.20.2"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.2"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, - utils.Ptr("1.20.0"), + new("1.20.0"), nil, - utils.Ptr("1.20.0"), + new("1.20.0"), false, false, true, @@ -809,25 +808,25 @@ func TestLatestMatchingKubernetesVersion(t *testing.T) { "available_version_with_no_provided_patch", []ske.KubernetesVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.20.1"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.1"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.20.2"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.2"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, - utils.Ptr("1.20"), + new("1.20"), nil, - utils.Ptr("1.20.2"), + new("1.20.2"), false, false, true, @@ -836,25 +835,25 @@ func TestLatestMatchingKubernetesVersion(t *testing.T) { "available_version_with_higher_preview_patch_not_selected", []ske.KubernetesVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.20.1"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.1"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.20.2"), - State: utils.Ptr(VersionStatePreview), + Version: new("1.20.2"), + State: new(VersionStatePreview), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, - utils.Ptr("1.20"), + new("1.20"), nil, - utils.Ptr("1.20.1"), + new("1.20.1"), false, false, true, @@ -863,17 +862,17 @@ func TestLatestMatchingKubernetesVersion(t *testing.T) { "available_version_no_provided_patch_2", []ske.KubernetesVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, - utils.Ptr("1.20"), + new("1.20"), nil, - utils.Ptr("1.20.0"), + new("1.20.0"), false, false, true, @@ -882,17 +881,17 @@ func TestLatestMatchingKubernetesVersion(t *testing.T) { "deprecated_version", []ske.KubernetesVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateDeprecated), + Version: new("1.19.0"), + State: new(VersionStateDeprecated), }, }, - utils.Ptr("1.19"), + new("1.19"), nil, - utils.Ptr("1.19.0"), + new("1.19.0"), true, false, true, @@ -901,17 +900,17 @@ func TestLatestMatchingKubernetesVersion(t *testing.T) { "preview_version", []ske.KubernetesVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStatePreview), + Version: new("1.20.0"), + State: new(VersionStatePreview), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, - utils.Ptr("1.20.0"), + new("1.20.0"), nil, - utils.Ptr("1.20.0"), + new("1.20.0"), false, true, true, @@ -920,17 +919,17 @@ func TestLatestMatchingKubernetesVersion(t *testing.T) { "nil_provided_version_get_latest", []ske.KubernetesVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, nil, nil, - utils.Ptr("1.20.0"), + new("1.20.0"), false, false, true, @@ -939,17 +938,17 @@ func TestLatestMatchingKubernetesVersion(t *testing.T) { "nil_provided_version_use_current", []ske.KubernetesVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, nil, - utils.Ptr("1.19.0"), - utils.Ptr("1.19.0"), + new("1.19.0"), + new("1.19.0"), false, false, true, @@ -958,17 +957,17 @@ func TestLatestMatchingKubernetesVersion(t *testing.T) { "update_lower_min_provided", []ske.KubernetesVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, - utils.Ptr("1.19"), - utils.Ptr("1.20.0"), - utils.Ptr("1.20.0"), + new("1.19"), + new("1.20.0"), + new("1.20.0"), false, false, true, @@ -977,21 +976,21 @@ func TestLatestMatchingKubernetesVersion(t *testing.T) { "update_lower_min_provided_deprecated_version", []ske.KubernetesVersion{ { - Version: utils.Ptr("1.21.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.21.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateDeprecated), + Version: new("1.20.0"), + State: new(VersionStateDeprecated), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateDeprecated), + Version: new("1.19.0"), + State: new(VersionStateDeprecated), }, }, - utils.Ptr("1.19"), - utils.Ptr("1.20.0"), - utils.Ptr("1.20.0"), + new("1.19"), + new("1.20.0"), + new("1.20.0"), true, false, true, @@ -1000,17 +999,17 @@ func TestLatestMatchingKubernetesVersion(t *testing.T) { "update_matching_min_provided", []ske.KubernetesVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, - utils.Ptr("1.20"), - utils.Ptr("1.20.0"), - utils.Ptr("1.20.0"), + new("1.20"), + new("1.20.0"), + new("1.20.0"), false, false, true, @@ -1019,17 +1018,17 @@ func TestLatestMatchingKubernetesVersion(t *testing.T) { "update_higher_min_provided", []ske.KubernetesVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, - utils.Ptr("1.20"), - utils.Ptr("1.19.0"), - utils.Ptr("1.20.0"), + new("1.20"), + new("1.19.0"), + new("1.20.0"), false, false, true, @@ -1038,15 +1037,15 @@ func TestLatestMatchingKubernetesVersion(t *testing.T) { "no_matching_available_versions", []ske.KubernetesVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, - utils.Ptr("1.21"), + new("1.21"), nil, nil, false, @@ -1057,19 +1056,19 @@ func TestLatestMatchingKubernetesVersion(t *testing.T) { "no_matching_available_versions_patch", []ske.KubernetesVersion{ { - Version: utils.Ptr("1.21.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.21.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, - utils.Ptr("1.21.1"), + new("1.21.1"), nil, nil, false, @@ -1080,19 +1079,19 @@ func TestLatestMatchingKubernetesVersion(t *testing.T) { "no_matching_available_versions_patch_2", []ske.KubernetesVersion{ { - Version: utils.Ptr("1.21.2"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.21.2"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, - utils.Ptr("1.21.1"), + new("1.21.1"), nil, nil, false, @@ -1103,20 +1102,20 @@ func TestLatestMatchingKubernetesVersion(t *testing.T) { "no_matching_available_versions_patch_current", []ske.KubernetesVersion{ { - Version: utils.Ptr("1.21.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.21.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, nil, - utils.Ptr("1.21.1"), + new("1.21.1"), nil, false, false, @@ -1126,20 +1125,20 @@ func TestLatestMatchingKubernetesVersion(t *testing.T) { "no_matching_available_versions_patch_2_current", []ske.KubernetesVersion{ { - Version: utils.Ptr("1.21.2"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.21.2"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, nil, - utils.Ptr("1.21.1"), + new("1.21.1"), nil, false, false, @@ -1148,7 +1147,7 @@ func TestLatestMatchingKubernetesVersion(t *testing.T) { { "no_available_version", []ske.KubernetesVersion{}, - utils.Ptr("1.20"), + new("1.20"), nil, nil, false, @@ -1158,7 +1157,7 @@ func TestLatestMatchingKubernetesVersion(t *testing.T) { { "nil_available_version", nil, - utils.Ptr("1.20"), + new("1.20"), nil, nil, false, @@ -1169,15 +1168,15 @@ func TestLatestMatchingKubernetesVersion(t *testing.T) { "empty_provided_version", []ske.KubernetesVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, - utils.Ptr(""), + new(""), nil, nil, false, @@ -1187,15 +1186,15 @@ func TestLatestMatchingKubernetesVersion(t *testing.T) { { description: "minimum_version_without_patch_version_results_in_latest_supported_version,even_if_preview_is_available", availableVersions: []ske.KubernetesVersion{ - {Version: utils.Ptr("1.20.0"), State: utils.Ptr(VersionStateSupported)}, - {Version: utils.Ptr("1.20.1"), State: utils.Ptr(VersionStateSupported)}, - {Version: utils.Ptr("1.20.2"), State: utils.Ptr(VersionStateSupported)}, - {Version: utils.Ptr("1.20.3"), State: utils.Ptr(VersionStateSupported)}, - {Version: utils.Ptr("1.20.4"), State: utils.Ptr(VersionStatePreview)}, + {Version: new("1.20.0"), State: new(VersionStateSupported)}, + {Version: new("1.20.1"), State: new(VersionStateSupported)}, + {Version: new("1.20.2"), State: new(VersionStateSupported)}, + {Version: new("1.20.3"), State: new(VersionStateSupported)}, + {Version: new("1.20.4"), State: new(VersionStatePreview)}, }, - kubernetesVersionMin: utils.Ptr("1.20"), + kubernetesVersionMin: new("1.20"), currentKubernetesVersion: nil, - expectedVersionUsed: utils.Ptr("1.20.3"), + expectedVersionUsed: new("1.20.3"), expectedHasDeprecatedVersion: false, expectedWarning: false, isValid: true, @@ -1203,15 +1202,15 @@ func TestLatestMatchingKubernetesVersion(t *testing.T) { { description: "use_preview_when_no_supported_release_is_available", availableVersions: []ske.KubernetesVersion{ - {Version: utils.Ptr("1.19.5"), State: utils.Ptr(VersionStateSupported)}, - {Version: utils.Ptr("1.19.6"), State: utils.Ptr(VersionStateSupported)}, - {Version: utils.Ptr("1.19.7"), State: utils.Ptr(VersionStateSupported)}, - {Version: utils.Ptr("1.20.0"), State: utils.Ptr(VersionStateDeprecated)}, - {Version: utils.Ptr("1.20.1"), State: utils.Ptr(VersionStatePreview)}, + {Version: new("1.19.5"), State: new(VersionStateSupported)}, + {Version: new("1.19.6"), State: new(VersionStateSupported)}, + {Version: new("1.19.7"), State: new(VersionStateSupported)}, + {Version: new("1.20.0"), State: new(VersionStateDeprecated)}, + {Version: new("1.20.1"), State: new(VersionStatePreview)}, }, - kubernetesVersionMin: utils.Ptr("1.20"), + kubernetesVersionMin: new("1.20"), currentKubernetesVersion: nil, - expectedVersionUsed: utils.Ptr("1.20.1"), + expectedVersionUsed: new("1.20.1"), expectedHasDeprecatedVersion: false, expectedWarning: true, isValid: true, @@ -1257,31 +1256,31 @@ func TestLatestMatchingMachineVersion(t *testing.T) { "available_version", []ske.MachineImage{ { - Name: utils.Ptr("foo"), + Name: new("foo"), Versions: &[]ske.MachineImageVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.20.1"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.1"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.20.2"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.2"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, }, }, - utils.Ptr("1.20.1"), + new("1.20.1"), "foo", nil, - utils.Ptr("1.20.1"), + new("1.20.1"), false, true, }, @@ -1289,31 +1288,31 @@ func TestLatestMatchingMachineVersion(t *testing.T) { "available_version_zero_patch", []ske.MachineImage{ { - Name: utils.Ptr("foo"), + Name: new("foo"), Versions: &[]ske.MachineImageVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.20.1"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.1"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.20.2"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.2"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, }, }, - utils.Ptr("1.20.0"), + new("1.20.0"), "foo", nil, - utils.Ptr("1.20.0"), + new("1.20.0"), false, true, }, @@ -1321,31 +1320,31 @@ func TestLatestMatchingMachineVersion(t *testing.T) { "available_version_with_no_provided_patch", []ske.MachineImage{ { - Name: utils.Ptr("foo"), + Name: new("foo"), Versions: &[]ske.MachineImageVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.20.1"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.1"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.20.2"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.2"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, }, }, - utils.Ptr("1.20"), + new("1.20"), "foo", nil, - utils.Ptr("1.20.2"), + new("1.20.2"), false, true, }, @@ -1353,31 +1352,31 @@ func TestLatestMatchingMachineVersion(t *testing.T) { "available_version_with_higher_preview_patch_not_selected", []ske.MachineImage{ { - Name: utils.Ptr("foo"), + Name: new("foo"), Versions: &[]ske.MachineImageVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.20.1"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.1"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.20.2"), - State: utils.Ptr(VersionStatePreview), + Version: new("1.20.2"), + State: new(VersionStatePreview), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, }, }, - utils.Ptr("1.20"), + new("1.20"), "foo", nil, - utils.Ptr("1.20.1"), + new("1.20.1"), false, true, }, @@ -1385,23 +1384,23 @@ func TestLatestMatchingMachineVersion(t *testing.T) { "available_version_with_no_provided_patch_2", []ske.MachineImage{ { - Name: utils.Ptr("foo"), + Name: new("foo"), Versions: &[]ske.MachineImageVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, }, }, - utils.Ptr("1.20"), + new("1.20"), "foo", nil, - utils.Ptr("1.20.0"), + new("1.20.0"), false, true, }, @@ -1409,23 +1408,23 @@ func TestLatestMatchingMachineVersion(t *testing.T) { "deprecated_version", []ske.MachineImage{ { - Name: utils.Ptr("foo"), + Name: new("foo"), Versions: &[]ske.MachineImageVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateDeprecated), + Version: new("1.19.0"), + State: new(VersionStateDeprecated), }, }, }, }, - utils.Ptr("1.19"), + new("1.19"), "foo", nil, - utils.Ptr("1.19.0"), + new("1.19.0"), true, true, }, @@ -1433,23 +1432,23 @@ func TestLatestMatchingMachineVersion(t *testing.T) { "preview_version_selected", []ske.MachineImage{ { - Name: utils.Ptr("foo"), + Name: new("foo"), Versions: &[]ske.MachineImageVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStatePreview), + Version: new("1.20.0"), + State: new(VersionStatePreview), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateDeprecated), + Version: new("1.19.0"), + State: new(VersionStateDeprecated), }, }, }, }, - utils.Ptr("1.20.0"), + new("1.20.0"), "foo", nil, - utils.Ptr("1.20.0"), + new("1.20.0"), false, true, }, @@ -1457,15 +1456,15 @@ func TestLatestMatchingMachineVersion(t *testing.T) { "nil_provided_version_get_latest", []ske.MachineImage{ { - Name: utils.Ptr("foo"), + Name: new("foo"), Versions: &[]ske.MachineImageVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, }, @@ -1473,7 +1472,7 @@ func TestLatestMatchingMachineVersion(t *testing.T) { nil, "foo", nil, - utils.Ptr("1.20.0"), + new("1.20.0"), false, true, }, @@ -1481,15 +1480,15 @@ func TestLatestMatchingMachineVersion(t *testing.T) { "nil_provided_version_use_current", []ske.MachineImage{ { - Name: utils.Ptr("foo"), + Name: new("foo"), Versions: &[]ske.MachineImageVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, }, @@ -1497,10 +1496,10 @@ func TestLatestMatchingMachineVersion(t *testing.T) { nil, "foo", &ske.Image{ - Name: utils.Ptr("foo"), - Version: utils.Ptr("1.19.0"), + Name: new("foo"), + Version: new("1.19.0"), }, - utils.Ptr("1.19.0"), + new("1.19.0"), false, true, }, @@ -1508,15 +1507,15 @@ func TestLatestMatchingMachineVersion(t *testing.T) { "nil_provided_version_os_image_update_get_latest", []ske.MachineImage{ { - Name: utils.Ptr("foo"), + Name: new("foo"), Versions: &[]ske.MachineImageVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, }, @@ -1524,10 +1523,10 @@ func TestLatestMatchingMachineVersion(t *testing.T) { nil, "foo", &ske.Image{ - Name: utils.Ptr("bar"), - Version: utils.Ptr("1.19.0"), + Name: new("bar"), + Version: new("1.19.0"), }, - utils.Ptr("1.20.0"), + new("1.20.0"), false, true, }, @@ -1535,26 +1534,26 @@ func TestLatestMatchingMachineVersion(t *testing.T) { "update_lower_min_provided", []ske.MachineImage{ { - Name: utils.Ptr("foo"), + Name: new("foo"), Versions: &[]ske.MachineImageVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, }, }, - utils.Ptr("1.19"), + new("1.19"), "foo", &ske.Image{ - Name: utils.Ptr("foo"), - Version: utils.Ptr("1.20.0"), + Name: new("foo"), + Version: new("1.20.0"), }, - utils.Ptr("1.20.0"), + new("1.20.0"), false, true, }, @@ -1562,30 +1561,30 @@ func TestLatestMatchingMachineVersion(t *testing.T) { "update_lower_min_provided_deprecated_version", []ske.MachineImage{ { - Name: utils.Ptr("foo"), + Name: new("foo"), Versions: &[]ske.MachineImageVersion{ { - Version: utils.Ptr("1.21.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.21.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateDeprecated), + Version: new("1.20.0"), + State: new(VersionStateDeprecated), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, }, }, - utils.Ptr("1.19"), + new("1.19"), "foo", &ske.Image{ - Name: utils.Ptr("foo"), - Version: utils.Ptr("1.20.0"), + Name: new("foo"), + Version: new("1.20.0"), }, - utils.Ptr("1.20.0"), + new("1.20.0"), true, true, }, @@ -1593,26 +1592,26 @@ func TestLatestMatchingMachineVersion(t *testing.T) { "update_higher_min_provided", []ske.MachineImage{ { - Name: utils.Ptr("foo"), + Name: new("foo"), Versions: &[]ske.MachineImageVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, }, }, - utils.Ptr("1.20"), + new("1.20"), "foo", &ske.Image{ - Name: utils.Ptr("foo"), - Version: utils.Ptr("1.19.0"), + Name: new("foo"), + Version: new("1.19.0"), }, - utils.Ptr("1.20.0"), + new("1.20.0"), false, true, }, @@ -1620,20 +1619,20 @@ func TestLatestMatchingMachineVersion(t *testing.T) { "no_matching_available_versions", []ske.MachineImage{ { - Name: utils.Ptr("foo"), + Name: new("foo"), Versions: &[]ske.MachineImageVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, { - Version: utils.Ptr("1.19.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.19.0"), + State: new(VersionStateSupported), }, }, }, }, - utils.Ptr("1.21"), + new("1.21"), "foo", nil, nil, @@ -1644,11 +1643,11 @@ func TestLatestMatchingMachineVersion(t *testing.T) { "no_available_versions", []ske.MachineImage{ { - Name: utils.Ptr("foo"), + Name: new("foo"), Versions: &[]ske.MachineImageVersion{}, }, }, - utils.Ptr("1.20"), + new("1.20"), "foo", nil, nil, @@ -1659,11 +1658,11 @@ func TestLatestMatchingMachineVersion(t *testing.T) { "nil_available_versions", []ske.MachineImage{ { - Name: utils.Ptr("foo"), + Name: new("foo"), Versions: nil, }, }, - utils.Ptr("1.20"), + new("1.20"), "foo", nil, nil, @@ -1677,13 +1676,13 @@ func TestLatestMatchingMachineVersion(t *testing.T) { Name: nil, Versions: &[]ske.MachineImageVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, }, }, }, - utils.Ptr("1.20"), + new("1.20"), "foo", nil, nil, @@ -1694,16 +1693,16 @@ func TestLatestMatchingMachineVersion(t *testing.T) { "name_not_available", []ske.MachineImage{ { - Name: utils.Ptr("bar"), + Name: new("bar"), Versions: &[]ske.MachineImageVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, }, }, }, - utils.Ptr("1.20"), + new("1.20"), "foo", nil, nil, @@ -1714,16 +1713,16 @@ func TestLatestMatchingMachineVersion(t *testing.T) { "empty_provided_version", []ske.MachineImage{ { - Name: utils.Ptr("foo"), + Name: new("foo"), Versions: &[]ske.MachineImageVersion{ { - Version: utils.Ptr("1.20.0"), - State: utils.Ptr(VersionStateSupported), + Version: new("1.20.0"), + State: new(VersionStateSupported), }, }, }, }, - utils.Ptr(""), + new(""), "foo", nil, nil, @@ -1782,9 +1781,9 @@ func TestGetMaintenanceTimes(t *testing.T) { { description: "tf_state_filled_in_1", startAPI: time.Date(1, 2, 3, 4, 5, 6, 7, time.FixedZone("UTC+7:08", 7*60*60+8*60)), - startTF: utils.Ptr("04:05:06+07:08"), + startTF: new("04:05:06+07:08"), endAPI: time.Date(11, 12, 13, 14, 15, 16, 17, time.FixedZone("UTC+17:18", 17*60*60+18*60)), - endTF: utils.Ptr("14:15:16+17:18"), + endTF: new("14:15:16+17:18"), isValid: true, startExpected: "04:05:06+07:08", endExpected: "14:15:16+17:18", @@ -1792,9 +1791,9 @@ func TestGetMaintenanceTimes(t *testing.T) { { description: "tf_state_filled_in_2", startAPI: time.Date(1, 2, 3, 4, 5, 6, 0, time.UTC), - startTF: utils.Ptr("04:05:06+00:00"), + startTF: new("04:05:06+00:00"), endAPI: time.Date(11, 12, 13, 14, 15, 16, 0, time.UTC), - endTF: utils.Ptr("14:15:16+00:00"), + endTF: new("14:15:16+00:00"), isValid: true, startExpected: "04:05:06+00:00", endExpected: "14:15:16+00:00", @@ -1802,9 +1801,9 @@ func TestGetMaintenanceTimes(t *testing.T) { { description: "tf_state_filled_in_3", startAPI: time.Date(1, 2, 3, 4, 5, 6, 0, time.UTC), - startTF: utils.Ptr("04:05:06Z"), + startTF: new("04:05:06Z"), endAPI: time.Date(11, 12, 13, 14, 15, 16, 0, time.UTC), - endTF: utils.Ptr("14:15:16Z"), + endTF: new("14:15:16Z"), isValid: true, startExpected: "04:05:06Z", endExpected: "14:15:16Z", @@ -1812,9 +1811,9 @@ func TestGetMaintenanceTimes(t *testing.T) { { description: "api_takes_precedence_if_different_1", startAPI: time.Date(1, 2, 3, 4, 5, 6, 7, time.FixedZone("UTC+7:08", 7*60*60+8*60)), - startTF: utils.Ptr("00:00:00+07:08"), + startTF: new("00:00:00+07:08"), endAPI: time.Date(11, 12, 13, 14, 15, 16, 17, time.FixedZone("UTC+17:18", 17*60*60+18*60)), - endTF: utils.Ptr("14:15:16+17:18"), + endTF: new("14:15:16+17:18"), isValid: true, startExpected: "04:05:06+07:08", endExpected: "14:15:16+17:18", @@ -1822,9 +1821,9 @@ func TestGetMaintenanceTimes(t *testing.T) { { description: "api_takes_precedence_if_different_2", startAPI: time.Date(1, 2, 3, 4, 5, 6, 7, time.FixedZone("UTC+7:08", 7*60*60+8*60)), - startTF: utils.Ptr("04:05:06+07:08"), + startTF: new("04:05:06+07:08"), endAPI: time.Date(11, 12, 13, 14, 15, 16, 17, time.FixedZone("UTC+17:18", 17*60*60+18*60)), - endTF: utils.Ptr("00:00:00+17:18"), + endTF: new("00:00:00+17:18"), isValid: true, startExpected: "04:05:06+07:08", endExpected: "14:15:16+17:18", @@ -1832,9 +1831,9 @@ func TestGetMaintenanceTimes(t *testing.T) { { description: "api_takes_precedence_if_different_3", startAPI: time.Date(1, 2, 3, 4, 5, 6, 7, time.FixedZone("UTC+7:08", 7*60*60+8*60)), - startTF: utils.Ptr("04:05:06Z"), + startTF: new("04:05:06Z"), endAPI: time.Date(11, 12, 13, 14, 15, 16, 17, time.FixedZone("UTC+17:18", 17*60*60+18*60)), - endTF: utils.Ptr("14:15:16+17:18"), + endTF: new("14:15:16+17:18"), isValid: true, startExpected: "04:05:06+07:08", endExpected: "14:15:16+17:18", @@ -1842,9 +1841,9 @@ func TestGetMaintenanceTimes(t *testing.T) { { description: "api_takes_precedence_if_different_3", startAPI: time.Date(1, 2, 3, 4, 5, 6, 7, time.FixedZone("UTC+7:08", 7*60*60+8*60)), - startTF: utils.Ptr("04:05:06+07:08"), + startTF: new("04:05:06+07:08"), endAPI: time.Date(11, 12, 13, 14, 15, 16, 17, time.FixedZone("UTC+17:18", 17*60*60+18*60)), - endTF: utils.Ptr("14:15:16Z"), + endTF: new("14:15:16Z"), isValid: true, startExpected: "04:05:06+07:08", endExpected: "14:15:16+17:18", @@ -1855,8 +1854,8 @@ func TestGetMaintenanceTimes(t *testing.T) { apiResponse := &ske.Cluster{ Maintenance: &ske.Maintenance{ TimeWindow: &ske.TimeWindow{ - Start: utils.Ptr(tt.startAPI), - End: utils.Ptr(tt.endAPI), + Start: new(tt.startAPI), + End: new(tt.endAPI), }, }, } @@ -1908,38 +1907,38 @@ func TestGetCurrentVersion(t *testing.T) { "ok", &ske.Cluster{ Kubernetes: &ske.Kubernetes{ - Version: utils.Ptr("v1.0.0"), + Version: new("v1.0.0"), }, Nodepools: &[]ske.Nodepool{ { - Name: utils.Ptr("foo"), + Name: new("foo"), Machine: &ske.Machine{ Image: &ske.Image{ - Name: utils.Ptr("foo"), - Version: utils.Ptr("v1.0.0"), + Name: new("foo"), + Version: new("v1.0.0"), }, }, }, { - Name: utils.Ptr("bar"), + Name: new("bar"), Machine: &ske.Machine{ Image: &ske.Image{ - Name: utils.Ptr("bar"), - Version: utils.Ptr("v2.0.0"), + Name: new("bar"), + Version: new("v2.0.0"), }, }, }, }, }, - utils.Ptr("v1.0.0"), + new("v1.0.0"), map[string]*ske.Image{ "foo": { - Name: utils.Ptr("foo"), - Version: utils.Ptr("v1.0.0"), + Name: new("foo"), + Version: new("v1.0.0"), }, "bar": { - Name: utils.Ptr("bar"), - Version: utils.Ptr("v2.0.0"), + Name: new("bar"), + Version: new("v2.0.0"), }, }, false, @@ -1975,11 +1974,11 @@ func TestGetCurrentVersion(t *testing.T) { "nil nodepools", &ske.Cluster{ Kubernetes: &ske.Kubernetes{ - Version: utils.Ptr("v1.0.0"), + Version: new("v1.0.0"), }, Nodepools: nil, }, - utils.Ptr("v1.0.0"), + new("v1.0.0"), nil, false, }, @@ -1987,16 +1986,16 @@ func TestGetCurrentVersion(t *testing.T) { "nil nodepools machine", &ske.Cluster{ Kubernetes: &ske.Kubernetes{ - Version: utils.Ptr("v1.0.0"), + Version: new("v1.0.0"), }, Nodepools: &[]ske.Nodepool{ { - Name: utils.Ptr("foo"), + Name: new("foo"), Machine: nil, }, }, }, - utils.Ptr("v1.0.0"), + new("v1.0.0"), map[string]*ske.Image{}, false, }, @@ -2004,18 +2003,18 @@ func TestGetCurrentVersion(t *testing.T) { "nil nodepools machine image", &ske.Cluster{ Kubernetes: &ske.Kubernetes{ - Version: utils.Ptr("v1.0.0"), + Version: new("v1.0.0"), }, Nodepools: &[]ske.Nodepool{ { - Name: utils.Ptr("foo"), + Name: new("foo"), Machine: &ske.Machine{ Image: nil, }, }, }, }, - utils.Ptr("v1.0.0"), + new("v1.0.0"), map[string]*ske.Image{}, false, }, @@ -2023,11 +2022,11 @@ func TestGetCurrentVersion(t *testing.T) { "nil nodepools machine image name", &ske.Cluster{ Kubernetes: &ske.Kubernetes{ - Version: utils.Ptr("v1.0.0"), + Version: new("v1.0.0"), }, Nodepools: &[]ske.Nodepool{ { - Name: utils.Ptr("foo"), + Name: new("foo"), Machine: &ske.Machine{ Image: &ske.Image{ Name: nil, @@ -2036,7 +2035,7 @@ func TestGetCurrentVersion(t *testing.T) { }, }, }, - utils.Ptr("v1.0.0"), + new("v1.0.0"), map[string]*ske.Image{}, false, }, @@ -2044,24 +2043,24 @@ func TestGetCurrentVersion(t *testing.T) { "nil nodepools machine image version", &ske.Cluster{ Kubernetes: &ske.Kubernetes{ - Version: utils.Ptr("v1.0.0"), + Version: new("v1.0.0"), }, Nodepools: &[]ske.Nodepool{ { - Name: utils.Ptr("foo"), + Name: new("foo"), Machine: &ske.Machine{ Image: &ske.Image{ - Name: utils.Ptr("foo"), + Name: new("foo"), Version: nil, }, }, }, }, }, - utils.Ptr("v1.0.0"), + new("v1.0.0"), map[string]*ske.Image{ "foo": { - Name: utils.Ptr("foo"), + Name: new("foo"), Version: nil, }, }, @@ -2110,20 +2109,20 @@ func TestGetLatestSupportedKubernetesVersion(t *testing.T) { description: "base", listKubernetesVersion: []ske.KubernetesVersion{ { - State: utils.Ptr("supported"), - Version: utils.Ptr("1.2.3"), + State: new("supported"), + Version: new("1.2.3"), }, { - State: utils.Ptr("supported"), - Version: utils.Ptr("3.2.1"), + State: new("supported"), + Version: new("3.2.1"), }, { - State: utils.Ptr("not-supported"), - Version: utils.Ptr("4.4.4"), + State: new("not-supported"), + Version: new("4.4.4"), }, }, isValid: true, - expectedVersion: utils.Ptr("3.2.1"), + expectedVersion: new("3.2.1"), }, { description: "no Kubernetes versions 1", @@ -2139,8 +2138,8 @@ func TestGetLatestSupportedKubernetesVersion(t *testing.T) { description: "no supported Kubernetes versions", listKubernetesVersion: []ske.KubernetesVersion{ { - State: utils.Ptr("not-supported"), - Version: utils.Ptr("1.2.3"), + State: new("not-supported"), + Version: new("1.2.3"), }, }, isValid: false, @@ -2179,20 +2178,20 @@ func TestGetLatestSupportedMachineVersion(t *testing.T) { description: "base", listMachineVersion: []ske.MachineImageVersion{ { - State: utils.Ptr("supported"), - Version: utils.Ptr("1.2.3"), + State: new("supported"), + Version: new("1.2.3"), }, { - State: utils.Ptr("supported"), - Version: utils.Ptr("3.2.1"), + State: new("supported"), + Version: new("3.2.1"), }, { - State: utils.Ptr("not-supported"), - Version: utils.Ptr("4.4.4"), + State: new("not-supported"), + Version: new("4.4.4"), }, }, isValid: true, - expectedVersion: utils.Ptr("3.2.1"), + expectedVersion: new("3.2.1"), }, { description: "no mchine versions 1", @@ -2208,8 +2207,8 @@ func TestGetLatestSupportedMachineVersion(t *testing.T) { description: "no supported machine versions", listMachineVersion: []ske.MachineImageVersion{ { - State: utils.Ptr("not-supported"), - Version: utils.Ptr("1.2.3"), + State: new("not-supported"), + Version: new("1.2.3"), }, }, isValid: false, @@ -2257,9 +2256,9 @@ func TestToNetworkPayload(t *testing.T) { }), }, &ske.Network{ - Id: utils.Ptr("nid"), + Id: new("nid"), ControlPlane: &ske.V2ControlPlaneNetwork{ - AccessScope: ske.V2ControlPlaneNetworkGetAccessScopeAttributeType(utils.Ptr("SNA")), + AccessScope: ske.V2ControlPlaneNetworkGetAccessScopeAttributeType(new("SNA")), }, }, true, @@ -2288,7 +2287,7 @@ func TestToNetworkPayload(t *testing.T) { }), }, &ske.Network{ - Id: utils.Ptr("nid"), + Id: new("nid"), ControlPlane: nil, }, true, @@ -2444,54 +2443,54 @@ func TestSortK8sVersion(t *testing.T) { { description: "slice with well formed elements", versions: []ske.KubernetesVersion{ - {Version: utils.Ptr("v1.2.3")}, - {Version: utils.Ptr("v1.1.10")}, - {Version: utils.Ptr("v1.2.1")}, - {Version: utils.Ptr("v1.2.0")}, - {Version: utils.Ptr("v1.1")}, - {Version: utils.Ptr("v1.2.2")}, + {Version: new("v1.2.3")}, + {Version: new("v1.1.10")}, + {Version: new("v1.2.1")}, + {Version: new("v1.2.0")}, + {Version: new("v1.1")}, + {Version: new("v1.2.2")}, }, wantSorted: []ske.KubernetesVersion{ - {Version: utils.Ptr("v1.2.3")}, - {Version: utils.Ptr("v1.2.2")}, - {Version: utils.Ptr("v1.2.1")}, - {Version: utils.Ptr("v1.2.0")}, - {Version: utils.Ptr("v1.1.10")}, - {Version: utils.Ptr("v1.1")}, + {Version: new("v1.2.3")}, + {Version: new("v1.2.2")}, + {Version: new("v1.2.1")}, + {Version: new("v1.2.0")}, + {Version: new("v1.1.10")}, + {Version: new("v1.1")}, }, }, { description: "slice with undefined elements", versions: []ske.KubernetesVersion{ - {Version: utils.Ptr("v1.2.3")}, - {Version: utils.Ptr("v1.1.10")}, + {Version: new("v1.2.3")}, + {Version: new("v1.1.10")}, {}, - {Version: utils.Ptr("v1.2.0")}, - {Version: utils.Ptr("v1.1")}, - {Version: utils.Ptr("v1.2.2")}, + {Version: new("v1.2.0")}, + {Version: new("v1.1")}, + {Version: new("v1.2.2")}, }, wantSorted: []ske.KubernetesVersion{ - {Version: utils.Ptr("v1.2.3")}, - {Version: utils.Ptr("v1.2.2")}, - {Version: utils.Ptr("v1.2.0")}, - {Version: utils.Ptr("v1.1.10")}, - {Version: utils.Ptr("v1.1")}, + {Version: new("v1.2.3")}, + {Version: new("v1.2.2")}, + {Version: new("v1.2.0")}, + {Version: new("v1.1.10")}, + {Version: new("v1.1")}, {Version: nil}, }, }, { description: "slice without prefix and minor version change", versions: []ske.KubernetesVersion{ - {Version: utils.Ptr("1.20.0")}, - {Version: utils.Ptr("1.19.0")}, - {Version: utils.Ptr("1.20.1")}, - {Version: utils.Ptr("1.20.2")}, + {Version: new("1.20.0")}, + {Version: new("1.19.0")}, + {Version: new("1.20.1")}, + {Version: new("1.20.2")}, }, wantSorted: []ske.KubernetesVersion{ - {Version: utils.Ptr("1.20.2")}, - {Version: utils.Ptr("1.20.1")}, - {Version: utils.Ptr("1.20.0")}, - {Version: utils.Ptr("1.19.0")}, + {Version: new("1.20.2")}, + {Version: new("1.20.1")}, + {Version: new("1.20.0")}, + {Version: new("1.19.0")}, }, }, { diff --git a/stackit/internal/services/ske/kubeconfig/resource.go b/stackit/internal/services/ske/kubeconfig/resource.go index b738456c1..ec804d89c 100644 --- a/stackit/internal/services/ske/kubeconfig/resource.go +++ b/stackit/internal/services/ske/kubeconfig/resource.go @@ -27,7 +27,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/types" - sdkUtils "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/ske" ) @@ -448,7 +447,7 @@ func toCreatePayload(model *Model) (*ske.CreateKubeconfigPayload, error) { expiration := conversion.Int64ValueToPointer(model.Expiration) var expirationStringPtr *string if expiration != nil { - expirationStringPtr = sdkUtils.Ptr(strconv.FormatInt(*expiration, 10)) + expirationStringPtr = new(strconv.FormatInt(*expiration, 10)) } return &ske.CreateKubeconfigPayload{ diff --git a/stackit/internal/services/ske/kubeconfig/resource_test.go b/stackit/internal/services/ske/kubeconfig/resource_test.go index f2a7fac8a..e01c25978 100644 --- a/stackit/internal/services/ske/kubeconfig/resource_test.go +++ b/stackit/internal/services/ske/kubeconfig/resource_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/ske" ) @@ -22,8 +21,8 @@ func TestMapFields(t *testing.T) { { "simple_values", &ske.Kubeconfig{ - ExpirationTimestamp: utils.Ptr(time.Date(2024, 2, 7, 16, 42, 12, 0, time.UTC)), - Kubeconfig: utils.Ptr("kubeconfig"), + ExpirationTimestamp: new(time.Date(2024, 2, 7, 16, 42, 12, 0, time.UTC)), + Kubeconfig: new("kubeconfig"), }, Model{ ClusterName: types.StringValue("name"), @@ -53,7 +52,7 @@ func TestMapFields(t *testing.T) { { "no_kubeconfig_field", &ske.Kubeconfig{ - ExpirationTimestamp: utils.Ptr(time.Date(2024, 2, 7, 16, 42, 12, 0, time.UTC)), + ExpirationTimestamp: new(time.Date(2024, 2, 7, 16, 42, 12, 0, time.UTC)), }, Model{}, false, @@ -102,7 +101,7 @@ func TestToCreatePayload(t *testing.T) { Expiration: types.Int64Value(3600), }, &ske.CreateKubeconfigPayload{ - ExpirationSeconds: utils.Ptr("3600"), + ExpirationSeconds: new("3600"), }, true, }, @@ -219,7 +218,7 @@ func TestCheckCredentialsRotation(t *testing.T) { inputCluster: &ske.Cluster{ Status: &ske.ClusterStatus{ CredentialsRotation: &ske.CredentialsRotationState{ - LastCompletionTime: utils.Ptr(time.Now().Add(-1 * time.Hour)), // one hour ago + LastCompletionTime: new(time.Now().Add(-1 * time.Hour)), // one hour ago }, }, }, @@ -234,7 +233,7 @@ func TestCheckCredentialsRotation(t *testing.T) { inputCluster: &ske.Cluster{ Status: &ske.ClusterStatus{ CredentialsRotation: &ske.CredentialsRotationState{ - LastCompletionTime: utils.Ptr(time.Now().Add(1 * time.Hour)), + LastCompletionTime: new(time.Now().Add(1 * time.Hour)), }, }, }, @@ -286,7 +285,7 @@ func TestCheckClusterRecreation(t *testing.T) { description: "cluster creation time after kubeconfig creation time", inputCluster: &ske.Cluster{ Status: &ske.ClusterStatus{ - CreationTime: utils.Ptr(time.Now().Add(-1 * time.Hour)), + CreationTime: new(time.Now().Add(-1 * time.Hour)), }, }, inputModel: &Model{ @@ -299,7 +298,7 @@ func TestCheckClusterRecreation(t *testing.T) { description: "cluster creation time before kubeconfig creation time", inputCluster: &ske.Cluster{ Status: &ske.ClusterStatus{ - CreationTime: utils.Ptr(time.Now().Add(1 * time.Hour)), + CreationTime: new(time.Now().Add(1 * time.Hour)), }, }, inputModel: &Model{ diff --git a/stackit/internal/services/ske/provideroptions/kubernetesversions/datasource_test.go b/stackit/internal/services/ske/provideroptions/kubernetesversions/datasource_test.go index bf7d8a482..b095c085a 100644 --- a/stackit/internal/services/ske/provideroptions/kubernetesversions/datasource_test.go +++ b/stackit/internal/services/ske/provideroptions/kubernetesversions/datasource_test.go @@ -8,7 +8,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - skeutils "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/ske" ) @@ -38,44 +37,44 @@ func TestMapFields(t *testing.T) { input: &ske.ProviderOptions{ KubernetesVersions: &[]ske.KubernetesVersion{ { - Version: skeutils.Ptr("1.31.14"), - State: skeutils.Ptr("deprecated"), + Version: new("1.31.14"), + State: new("deprecated"), ExpirationDate: &expDeprecated1, FeatureGates: &map[string]string{}, }, { - Version: skeutils.Ptr("1.32.10"), - State: skeutils.Ptr("deprecated"), + Version: new("1.32.10"), + State: new("deprecated"), ExpirationDate: &expDeprecated2, FeatureGates: &map[string]string{}, }, { - Version: skeutils.Ptr("1.33.6"), - State: skeutils.Ptr("deprecated"), + Version: new("1.33.6"), + State: new("deprecated"), ExpirationDate: &expDeprecated2, FeatureGates: &map[string]string{}, }, { - Version: skeutils.Ptr("1.34.2"), - State: skeutils.Ptr("deprecated"), + Version: new("1.34.2"), + State: new("deprecated"), ExpirationDate: &expDeprecated2, FeatureGates: &map[string]string{}, }, { - Version: skeutils.Ptr("1.32.11"), - State: skeutils.Ptr("supported"), + Version: new("1.32.11"), + State: new("supported"), ExpirationDate: nil, FeatureGates: &map[string]string{}, }, { - Version: skeutils.Ptr("1.33.7"), - State: skeutils.Ptr("supported"), + Version: new("1.33.7"), + State: new("supported"), ExpirationDate: nil, FeatureGates: &map[string]string{}, }, { - Version: skeutils.Ptr("1.34.3"), - State: skeutils.Ptr("supported"), + Version: new("1.34.3"), + State: new("supported"), ExpirationDate: nil, FeatureGates: &map[string]string{}, }, @@ -159,8 +158,8 @@ func TestMapFields(t *testing.T) { input: &ske.ProviderOptions{ KubernetesVersions: &[]ske.KubernetesVersion{ { - Version: skeutils.Ptr("1.32.11"), - State: skeutils.Ptr("supported"), + Version: new("1.32.11"), + State: new("supported"), ExpirationDate: nil, FeatureGates: &map[string]string{ "SomeGate": "foo", @@ -238,8 +237,8 @@ func TestMapFields(t *testing.T) { input: &ske.ProviderOptions{ KubernetesVersions: &[]ske.KubernetesVersion{ { - Version: skeutils.Ptr("1.33.7"), - State: skeutils.Ptr("supported"), + Version: new("1.33.7"), + State: new("supported"), ExpirationDate: nil, FeatureGates: &map[string]string{}, }, @@ -270,8 +269,8 @@ func TestMapFields(t *testing.T) { input: &ske.ProviderOptions{ KubernetesVersions: &[]ske.KubernetesVersion{ { - Version: skeutils.Ptr("1.32.11"), - State: skeutils.Ptr("supported"), + Version: new("1.32.11"), + State: new("supported"), ExpirationDate: nil, FeatureGates: &map[string]string{}, }, diff --git a/stackit/internal/services/ske/provideroptions/machineimages/datasource_test.go b/stackit/internal/services/ske/provideroptions/machineimages/datasource_test.go index 385b57c2b..71857db90 100644 --- a/stackit/internal/services/ske/provideroptions/machineimages/datasource_test.go +++ b/stackit/internal/services/ske/provideroptions/machineimages/datasource_test.go @@ -33,11 +33,11 @@ func TestMapFields(t *testing.T) { input: &ske.ProviderOptions{ MachineImages: &[]ske.MachineImage{ { - Name: skeutils.Ptr("flatcar"), + Name: new("flatcar"), Versions: &[]ske.MachineImageVersion{ { - Version: skeutils.Ptr("4230.2.1"), - State: skeutils.Ptr("supported"), + Version: new("4230.2.1"), + State: new("supported"), ExpirationDate: ×tamp, Cri: &[]ske.CRI{ { @@ -82,11 +82,11 @@ func TestMapFields(t *testing.T) { input: &ske.ProviderOptions{ MachineImages: &[]ske.MachineImage{ { - Name: skeutils.Ptr("flatcar"), + Name: new("flatcar"), Versions: &[]ske.MachineImageVersion{ { - Version: skeutils.Ptr("4230.2.1"), - State: skeutils.Ptr("supported"), + Version: new("4230.2.1"), + State: new("supported"), ExpirationDate: ×tamp, Cri: &[]ske.CRI{ { @@ -148,11 +148,11 @@ func TestMapFields(t *testing.T) { input: &ske.ProviderOptions{ MachineImages: &[]ske.MachineImage{ { - Name: skeutils.Ptr("flatcar"), + Name: new("flatcar"), Versions: &[]ske.MachineImageVersion{ { - Version: skeutils.Ptr("4230.2.1"), - State: skeutils.Ptr("deprecated"), + Version: new("4230.2.1"), + State: new("deprecated"), ExpirationDate: ×tamp, Cri: &[]ske.CRI{ { @@ -161,8 +161,8 @@ func TestMapFields(t *testing.T) { }, }, { - Version: skeutils.Ptr("4230.2.3"), - State: skeutils.Ptr("supported"), + Version: new("4230.2.3"), + State: new("supported"), ExpirationDate: nil, // no expiration Cri: &[]ske.CRI{ { @@ -171,8 +171,8 @@ func TestMapFields(t *testing.T) { }, }, { - Version: skeutils.Ptr("4459.2.1"), - State: skeutils.Ptr("preview"), + Version: new("4459.2.1"), + State: new("preview"), ExpirationDate: nil, Cri: &[]ske.CRI{ { @@ -183,11 +183,11 @@ func TestMapFields(t *testing.T) { }, }, { - Name: skeutils.Ptr("ubuntu"), + Name: new("ubuntu"), Versions: &[]ske.MachineImageVersion{ { - Version: skeutils.Ptr("2204.20250728.0"), - State: skeutils.Ptr("supported"), + Version: new("2204.20250728.0"), + State: new("supported"), ExpirationDate: nil, // empty CRI slice Cri: &[]ske.CRI{}, @@ -296,11 +296,11 @@ func TestMapFields(t *testing.T) { input: &ske.ProviderOptions{ MachineImages: &[]ske.MachineImage{ { - Name: skeutils.Ptr("ubuntu"), + Name: new("ubuntu"), Versions: &[]ske.MachineImageVersion{ { - Version: skeutils.Ptr("2204.20250728.0"), - State: skeutils.Ptr("supported"), + Version: new("2204.20250728.0"), + State: new("supported"), ExpirationDate: nil, Cri: nil, // explicit nil => empty list }, diff --git a/stackit/internal/services/ske/ske_test.go b/stackit/internal/services/ske/ske_test.go index f47ecca6c..b700acb26 100644 --- a/stackit/internal/services/ske/ske_test.go +++ b/stackit/internal/services/ske/ske_test.go @@ -73,15 +73,15 @@ resource "stackit_ske_cluster" "cluster" { testutil.MockResponse{ Description: "kubernetes versions", ToJsonBody: ske.ProviderOptions{ - MachineImages: utils.Ptr([]ske.MachineImage{ + MachineImages: new([]ske.MachineImage{ { - Name: utils.Ptr("flatcar"), - Versions: utils.Ptr([]ske.MachineImageVersion{ + Name: new("flatcar"), + Versions: new([]ske.MachineImageVersion{ { - State: utils.Ptr("supported"), - Version: utils.Ptr("1.0.0"), + State: new("supported"), + Version: new("1.0.0"), ExpirationDate: nil, - Cri: utils.Ptr([]ske.CRI{ + Cri: new([]ske.CRI{ { Name: utils.Ptr(ske.CRINAME_CONTAINERD), }, @@ -90,14 +90,14 @@ resource "stackit_ske_cluster" "cluster" { }), }, }), - MachineTypes: utils.Ptr([]ske.MachineType{ + MachineTypes: new([]ske.MachineType{ { Name: utils.Ptr(machineType), }, }), - KubernetesVersions: utils.Ptr([]ske.KubernetesVersion{ + KubernetesVersions: new([]ske.KubernetesVersion{ { - State: utils.Ptr("supported"), + State: new("supported"), ExpirationDate: nil, Version: utils.Ptr(kubernetesVersionMin), }, diff --git a/stackit/internal/services/sqlserverflex/instance/resource.go b/stackit/internal/services/sqlserverflex/instance/resource.go index 2ca1cb8f4..d45cdc19c 100644 --- a/stackit/internal/services/sqlserverflex/instance/resource.go +++ b/stackit/internal/services/sqlserverflex/instance/resource.go @@ -31,7 +31,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" - coreUtils "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex" "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/wait" ) @@ -826,7 +825,7 @@ func toCreatePayload(model *Model, acl []string, flavor *flavorModel, storage *s retentionDaysInt := conversion.Int64ValueToPointer(options.RetentionDays) var retentionDays *string if retentionDaysInt != nil { - retentionDays = coreUtils.Ptr(strconv.FormatInt(*retentionDaysInt, 10)) + retentionDays = new(strconv.FormatInt(*retentionDaysInt, 10)) } optionsPayload.RetentionDays = retentionDays } diff --git a/stackit/internal/services/sqlserverflex/instance/resource_test.go b/stackit/internal/services/sqlserverflex/instance/resource_test.go index 66021845b..92d154336 100644 --- a/stackit/internal/services/sqlserverflex/instance/resource_test.go +++ b/stackit/internal/services/sqlserverflex/instance/resource_test.go @@ -8,7 +8,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex" ) @@ -93,26 +92,26 @@ func TestMapFields(t *testing.T) { "", }, }, - BackupSchedule: utils.Ptr("schedule"), + BackupSchedule: new("schedule"), Flavor: &sqlserverflex.Flavor{ - Cpu: utils.Ptr(int64(12)), - Description: utils.Ptr("description"), - Id: utils.Ptr("flavor_id"), - Memory: utils.Ptr(int64(34)), + Cpu: new(int64(12)), + Description: new("description"), + Id: new("flavor_id"), + Memory: new(int64(34)), }, - Id: utils.Ptr("iid"), - Name: utils.Ptr("name"), - Replicas: utils.Ptr(int64(56)), - Status: utils.Ptr("status"), + Id: new("iid"), + Name: new("name"), + Replicas: new(int64(56)), + Status: new("status"), Storage: &sqlserverflex.Storage{ - Class: utils.Ptr("class"), - Size: utils.Ptr(int64(78)), + Class: new("class"), + Size: new(int64(78)), }, Options: &map[string]string{ "edition": "edition", "retentionDays": "1", }, - Version: utils.Ptr("version"), + Version: new("version"), }, }, &flavorModel{}, @@ -165,18 +164,18 @@ func TestMapFields(t *testing.T) { "", }, }, - BackupSchedule: utils.Ptr("schedule"), + BackupSchedule: new("schedule"), Flavor: nil, - Id: utils.Ptr("iid"), - Name: utils.Ptr("name"), - Replicas: utils.Ptr(int64(56)), - Status: utils.Ptr("status"), + Id: new("iid"), + Name: new("name"), + Replicas: new(int64(56)), + Status: new("status"), Storage: nil, Options: &map[string]string{ "edition": "edition", "retentionDays": "1", }, - Version: utils.Ptr("version"), + Version: new("version"), }, }, &flavorModel{ @@ -243,18 +242,18 @@ func TestMapFields(t *testing.T) { "ip2", }, }, - BackupSchedule: utils.Ptr("schedule"), + BackupSchedule: new("schedule"), Flavor: nil, - Id: utils.Ptr("iid"), - Name: utils.Ptr("name"), - Replicas: utils.Ptr(int64(56)), - Status: utils.Ptr("status"), + Id: new("iid"), + Name: new("name"), + Replicas: new(int64(56)), + Status: new("status"), Storage: nil, Options: &map[string]string{ "edition": "edition", "retentionDays": "1", }, - Version: utils.Ptr("version"), + Version: new("version"), }, }, &flavorModel{ @@ -403,18 +402,18 @@ func TestToCreatePayload(t *testing.T) { "ip_2", }, }, - BackupSchedule: utils.Ptr("schedule"), - FlavorId: utils.Ptr("flavor_id"), - Name: utils.Ptr("name"), + BackupSchedule: new("schedule"), + FlavorId: new("flavor_id"), + Name: new("name"), Storage: &sqlserverflex.CreateInstancePayloadStorage{ - Class: utils.Ptr("class"), - Size: utils.Ptr(int64(34)), + Class: new("class"), + Size: new(int64(34)), }, Options: &sqlserverflex.CreateInstancePayloadOptions{ - Edition: utils.Ptr("edition"), - RetentionDays: utils.Ptr("1"), + Edition: new("edition"), + RetentionDays: new("1"), }, - Version: utils.Ptr("version"), + Version: new("version"), }, true, }, @@ -587,10 +586,10 @@ func TestToUpdatePayload(t *testing.T) { "ip_2", }, }, - BackupSchedule: utils.Ptr("schedule"), - FlavorId: utils.Ptr("flavor_id"), - Name: utils.Ptr("name"), - Version: utils.Ptr("version"), + BackupSchedule: new("schedule"), + FlavorId: new("flavor_id"), + Name: new("name"), + Version: new("version"), }, true, }, @@ -685,10 +684,10 @@ func TestLoadFlavorId(t *testing.T) { &sqlserverflex.ListFlavorsResponse{ Flavors: &[]sqlserverflex.InstanceFlavorEntry{ { - Id: utils.Ptr("fid-1"), - Cpu: utils.Ptr(int64(2)), - Description: utils.Ptr("description"), - Memory: utils.Ptr(int64(8)), + Id: new("fid-1"), + Cpu: new(int64(2)), + Description: new("description"), + Memory: new(int64(8)), }, }, }, @@ -710,16 +709,16 @@ func TestLoadFlavorId(t *testing.T) { &sqlserverflex.ListFlavorsResponse{ Flavors: &[]sqlserverflex.InstanceFlavorEntry{ { - Id: utils.Ptr("fid-1"), - Cpu: utils.Ptr(int64(2)), - Description: utils.Ptr("description"), - Memory: utils.Ptr(int64(8)), + Id: new("fid-1"), + Cpu: new(int64(2)), + Description: new("description"), + Memory: new(int64(8)), }, { - Id: utils.Ptr("fid-2"), - Cpu: utils.Ptr(int64(1)), - Description: utils.Ptr("description"), - Memory: utils.Ptr(int64(4)), + Id: new("fid-2"), + Cpu: new(int64(1)), + Description: new("description"), + Memory: new(int64(4)), }, }, }, @@ -741,16 +740,16 @@ func TestLoadFlavorId(t *testing.T) { &sqlserverflex.ListFlavorsResponse{ Flavors: &[]sqlserverflex.InstanceFlavorEntry{ { - Id: utils.Ptr("fid-1"), - Cpu: utils.Ptr(int64(1)), - Description: utils.Ptr("description"), - Memory: utils.Ptr(int64(8)), + Id: new("fid-1"), + Cpu: new(int64(1)), + Description: new("description"), + Memory: new(int64(8)), }, { - Id: utils.Ptr("fid-2"), - Cpu: utils.Ptr(int64(1)), - Description: utils.Ptr("description"), - Memory: utils.Ptr(int64(4)), + Id: new("fid-2"), + Cpu: new(int64(1)), + Description: new("description"), + Memory: new(int64(4)), }, }, }, diff --git a/stackit/internal/services/sqlserverflex/sqlserverflex_test.go b/stackit/internal/services/sqlserverflex/sqlserverflex_test.go index a35a417a9..7d5517aeb 100644 --- a/stackit/internal/services/sqlserverflex/sqlserverflex_test.go +++ b/stackit/internal/services/sqlserverflex/sqlserverflex_test.go @@ -49,7 +49,7 @@ resource "stackit_sqlserverflex_instance" "instance" { Cpu: utils.Ptr(int64(flavorCpu)), Memory: utils.Ptr(int64(flavorRam)), Id: utils.Ptr(flavorId), - Description: utils.Ptr("test-flavor-id"), + Description: new("test-flavor-id"), }, }, }, @@ -65,7 +65,7 @@ resource "stackit_sqlserverflex_instance" "instance" { testutil.MockResponse{ Description: "create", ToJsonBody: sqlserverflex.CreateInstanceResponse{ - Id: utils.Ptr(instanceId), + Id: new(instanceId), }, }, testutil.MockResponse{ diff --git a/stackit/internal/services/sqlserverflex/user/datasource_test.go b/stackit/internal/services/sqlserverflex/user/datasource_test.go index b5179c44b..acd1f02c8 100644 --- a/stackit/internal/services/sqlserverflex/user/datasource_test.go +++ b/stackit/internal/services/sqlserverflex/user/datasource_test.go @@ -6,7 +6,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex" ) @@ -47,9 +46,9 @@ func TestMapDataSourceFields(t *testing.T) { "role_2", "", }, - Username: utils.Ptr("username"), - Host: utils.Ptr("host"), - Port: utils.Ptr(int64(1234)), + Username: new("username"), + Host: new("host"), + Port: new(int64(1234)), }, }, testRegion, @@ -74,11 +73,11 @@ func TestMapDataSourceFields(t *testing.T) { "null_fields_and_int_conversions", &sqlserverflex.GetUserResponse{ Item: &sqlserverflex.UserResponseUser{ - Id: utils.Ptr("uid"), + Id: new("uid"), Roles: &[]string{}, Username: nil, Host: nil, - Port: utils.Ptr(int64(2123456789)), + Port: new(int64(2123456789)), }, }, testRegion, diff --git a/stackit/internal/services/sqlserverflex/user/resource_test.go b/stackit/internal/services/sqlserverflex/user/resource_test.go index 058b213d4..8e954a891 100644 --- a/stackit/internal/services/sqlserverflex/user/resource_test.go +++ b/stackit/internal/services/sqlserverflex/user/resource_test.go @@ -6,7 +6,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex" ) @@ -23,8 +22,8 @@ func TestMapFieldsCreate(t *testing.T) { "default_values", &sqlserverflex.CreateUserResponse{ Item: &sqlserverflex.SingleUser{ - Id: utils.Ptr("uid"), - Password: utils.Ptr(""), + Id: new("uid"), + Password: new(""), }, }, testRegion, @@ -46,16 +45,16 @@ func TestMapFieldsCreate(t *testing.T) { "simple_values", &sqlserverflex.CreateUserResponse{ Item: &sqlserverflex.SingleUser{ - Id: utils.Ptr("uid"), + Id: new("uid"), Roles: &[]string{ "role_1", "role_2", "", }, - Username: utils.Ptr("username"), - Password: utils.Ptr("password"), - Host: utils.Ptr("host"), - Port: utils.Ptr(int64(1234)), + Username: new("username"), + Password: new("password"), + Host: new("host"), + Port: new(int64(1234)), }, }, testRegion, @@ -81,12 +80,12 @@ func TestMapFieldsCreate(t *testing.T) { "null_fields_and_int_conversions", &sqlserverflex.CreateUserResponse{ Item: &sqlserverflex.SingleUser{ - Id: utils.Ptr("uid"), + Id: new("uid"), Roles: &[]string{}, Username: nil, - Password: utils.Ptr(""), + Password: new(""), Host: nil, - Port: utils.Ptr(int64(2123456789)), + Port: new(int64(2123456789)), }, }, testRegion, @@ -131,7 +130,7 @@ func TestMapFieldsCreate(t *testing.T) { "no_password", &sqlserverflex.CreateUserResponse{ Item: &sqlserverflex.SingleUser{ - Id: utils.Ptr("uid"), + Id: new("uid"), }, }, testRegion, @@ -199,9 +198,9 @@ func TestMapFields(t *testing.T) { "role_2", "", }, - Username: utils.Ptr("username"), - Host: utils.Ptr("host"), - Port: utils.Ptr(int64(1234)), + Username: new("username"), + Host: new("host"), + Port: new(int64(1234)), }, }, testRegion, @@ -226,11 +225,11 @@ func TestMapFields(t *testing.T) { "null_fields_and_int_conversions", &sqlserverflex.GetUserResponse{ Item: &sqlserverflex.UserResponseUser{ - Id: utils.Ptr("uid"), + Id: new("uid"), Roles: &[]string{}, Username: nil, Host: nil, - Port: utils.Ptr(int64(2123456789)), + Port: new(int64(2123456789)), }, }, testRegion, @@ -327,7 +326,7 @@ func TestToCreatePayload(t *testing.T) { "role_1", "role_2", }, - Username: utils.Ptr("username"), + Username: new("username"), }, true, }, @@ -362,7 +361,7 @@ func TestToCreatePayload(t *testing.T) { []string{}, &sqlserverflex.CreateUserPayload{ Roles: &[]string{}, - Username: utils.Ptr("username"), + Username: new("username"), }, true, }, diff --git a/stackit/internal/utils/attributes.go b/stackit/internal/utils/attributes.go index ae38c2af3..f9af5930f 100644 --- a/stackit/internal/utils/attributes.go +++ b/stackit/internal/utils/attributes.go @@ -15,7 +15,7 @@ import ( ) type attributeGetter interface { - GetAttribute(ctx context.Context, attributePath path.Path, target interface{}) diag.Diagnostics + GetAttribute(ctx context.Context, attributePath path.Path, target any) diag.Diagnostics } func ToTime(ctx context.Context, format string, val types.String, target *time.Time) (diags diag.Diagnostics) { diff --git a/stackit/internal/utils/attributes_test.go b/stackit/internal/utils/attributes_test.go index b7b3c8a12..fc467a398 100644 --- a/stackit/internal/utils/attributes_test.go +++ b/stackit/internal/utils/attributes_test.go @@ -11,9 +11,9 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" ) -type attributeGetterFunc func(ctx context.Context, attributePath path.Path, target interface{}) diag.Diagnostics +type attributeGetterFunc func(ctx context.Context, attributePath path.Path, target any) diag.Diagnostics -func (a attributeGetterFunc) GetAttribute(ctx context.Context, attributePath path.Path, target interface{}) diag.Diagnostics { +func (a attributeGetterFunc) GetAttribute(ctx context.Context, attributePath path.Path, target any) diag.Diagnostics { return a(ctx, attributePath, target) } @@ -41,7 +41,7 @@ func TestGetTimeFromString(t *testing.T) { name: "simple string", args: args{ path: path.Root("foo"), - source: func(_ context.Context, _ path.Path, target interface{}) diag.Diagnostics { + source: func(_ context.Context, _ path.Path, target any) diag.Diagnostics { t, ok := target.(*types.String) if !ok { log.Panicf("wrong type %T", target) @@ -57,7 +57,7 @@ func TestGetTimeFromString(t *testing.T) { name: "invalid type", args: args{ path: path.Root("foo"), - source: func(_ context.Context, p path.Path, _ interface{}) (diags diag.Diagnostics) { + source: func(_ context.Context, p path.Path, _ any) (diags diag.Diagnostics) { diags.AddAttributeError(p, "kapow", "kapow") return diags }, diff --git a/stackit/internal/utils/utils_test.go b/stackit/internal/utils/utils_test.go index 48287d800..856460f05 100644 --- a/stackit/internal/utils/utils_test.go +++ b/stackit/internal/utils/utils_test.go @@ -19,7 +19,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "github.com/stackitcloud/stackit-sdk-go/core/utils" ) func TestReconcileStrLists(t *testing.T) { @@ -152,12 +151,12 @@ func TestConvertPointerSliceToStringSlice(t *testing.T) { }, { description: "slice with valid pointers", - input: []*string{utils.Ptr("apple"), utils.Ptr("banana"), utils.Ptr("cherry")}, + input: []*string{new("apple"), new("banana"), new("cherry")}, expected: []string{"apple", "banana", "cherry"}, }, { description: "slice with some nil pointers", - input: []*string{utils.Ptr("apple"), nil, utils.Ptr("cherry"), nil}, + input: []*string{new("apple"), nil, new("cherry"), nil}, expected: []string{"apple", "cherry"}, }, { @@ -167,7 +166,7 @@ func TestConvertPointerSliceToStringSlice(t *testing.T) { }, { description: "slice with a pointer to an empty string", - input: []*string{utils.Ptr("apple"), utils.Ptr(""), utils.Ptr("cherry")}, + input: []*string{new("apple"), new(""), new("cherry")}, expected: []string{"apple", "", "cherry"}, }, } @@ -535,7 +534,7 @@ func TestSetAndLogStateFields(t *testing.T) { type args struct { diags *diag.Diagnostics state *tfsdk.State - values map[string]interface{} + values map[string]any } type want struct { hasError bool @@ -551,7 +550,7 @@ func TestSetAndLogStateFields(t *testing.T) { args: args{ diags: &diag.Diagnostics{}, state: &tfsdk.State{}, - values: map[string]interface{}{}, + values: map[string]any{}, }, want: want{ hasError: false, @@ -573,7 +572,7 @@ func TestSetAndLogStateFields(t *testing.T) { } return &state }(), - values: map[string]interface{}{ + values: map[string]any{ "project_id": "a414f971-3f7a-4e9a-8671-51a8acb7bcc8", "instance_id": "97073250-8cad-46c3-8424-6258ac0b3731", }, From 9e9048576df6dc96c49788f81d20e8ceb2144684 Mon Sep 17 00:00:00 2001 From: Carlo Goetz Date: Fri, 27 Mar 2026 15:12:14 +0100 Subject: [PATCH 3/7] chore(deps) update golangci-lint version --- scripts/project.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/project.sh b/scripts/project.sh index 91bb1efd3..48623f0b8 100755 --- a/scripts/project.sh +++ b/scripts/project.sh @@ -16,7 +16,7 @@ elif [ "$action" = "tools" ]; then go mod download - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.0 + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v2.11.4 go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@v0.21.0 else echo "Invalid action: '$action', please use $0 help for help" From f6d889069de705696be64f901c1bf7da47647749 Mon Sep 17 00:00:00 2001 From: Carlo Goetz Date: Fri, 27 Mar 2026 15:15:26 +0100 Subject: [PATCH 4/7] fix(deps) use correct golangci-lint url --- scripts/project.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/project.sh b/scripts/project.sh index 48623f0b8..747053a1c 100755 --- a/scripts/project.sh +++ b/scripts/project.sh @@ -16,7 +16,7 @@ elif [ "$action" = "tools" ]; then go mod download - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v2.11.4 + go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.11.4 go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@v0.21.0 else echo "Invalid action: '$action', please use $0 help for help" From e447cdacfa05656b20148303a8202e833f0ca046 Mon Sep 17 00:00:00 2001 From: Carlo Goetz Date: Fri, 27 Mar 2026 15:28:52 +0100 Subject: [PATCH 5/7] fix(deps) migrate golangci-lint config --- golang-ci.yaml | 154 +++++++++++++++++++++++++------------------------ 1 file changed, 78 insertions(+), 76 deletions(-) diff --git a/golang-ci.yaml b/golang-ci.yaml index 5fc3d26e6..1d72a2c98 100644 --- a/golang-ci.yaml +++ b/golang-ci.yaml @@ -1,6 +1,7 @@ # This file contains all available configuration options # with their default values. +version: "2" # options for analysis running run: # default concurrency is a available CPU number @@ -8,93 +9,94 @@ run: # timeout for analysis, e.g. 30s, 5m, default is 1m timeout: 5m -linters-settings: - goimports: - # put imports beginning with prefix after 3rd-party packages; - # it's a comma-separated list of prefixes - local-prefixes: github.com/freiheit-com/nmww - depguard: - rules: - main: - list-mode: lax # Everything is allowed unless it is denied - deny: - - pkg: "github.com/stretchr/testify" - desc: Do not use a testing framework - misspell: - # Correct spellings using locale preferences for US or UK. - # Default is to use a neutral variety of English. - # Setting locale to US will correct the British spelling of 'colour' to 'color'. - locale: US - golint: - min-confidence: 0.8 - gosec: - excludes: - # Suppressions: (see https://github.com/securego/gosec#available-rules for details) - - G104 # "Audit errors not checked" -> which we don't need and is a badly implemented version of errcheck - - G102 # "Bind to all interfaces" -> since this is normal in k8s - - G304 # "File path provided as taint input" -> too many false positives - - G307 # "Deferring unsafe method "Close" on type "io.ReadCloser" -> false positive when calling defer resp.Body.Close() - nakedret: - max-func-lines: 0 - revive: - ignore-generated-header: true - severity: error - # https://github.com/mgechev/revive - rules: - - name: errorf - - name: context-as-argument - - name: error-return - - name: increment-decrement - - name: indent-error-flow - - name: superfluous-else - - name: unused-parameter - - name: unreachable-code - - name: atomic - - name: empty-lines - - name: early-return - gocritic: - enabled-tags: - - performance - - style - - experimental - disabled-checks: - - wrapperFunc - - typeDefFirst - - ifElseChain - - dupImport # https://github.com/go-critic/go-critic/issues/845 linters: enable: - # https://golangci-lint.run/usage/linters/ - # default linters - - gosimple - - govet - - ineffassign - - staticcheck - - typecheck - - unused - # additional linters + - bodyclose + - depguard - errorlint + - forcetypeassert - gochecknoinits - gocritic - - gofmt - - goimports - gosec - misspell - nakedret - revive - - depguard - - bodyclose - sqlclosecheck - wastedassign - - forcetypeassert - - errcheck disable: - noctx # false positive: finds errors with http.NewRequest that dont make sense - unparam # false positives -issues: - exclude-use-default: false - # disable deprecation errors while we switch over to the SDK structure with multi API version support - exclude-rules: - - linters: - - staticcheck - text: "SA1019:" + settings: + depguard: + rules: + main: + list-mode: lax # Everything is allowed unless it is denied + deny: + - pkg: github.com/stretchr/testify + desc: Do not use a testing framework + gocritic: + disabled-checks: + - wrapperFunc + - typeDefFirst + - ifElseChain + - dupImport # https://github.com/go-critic/go-critic/issues/845 + enabled-tags: + - performance + - style + - experimental + gosec: + excludes: + # Suppressions: (see https://github.com/securego/gosec#available-rules for details) + - G104 # "Audit errors not checked" -> which we don't need and is a badly implemented version of errcheck + - G102 # "Bind to all interfaces" -> since this is normal in k8s + - G304 # "File path provided as taint input" -> too many false positives + - G307 # "Deferring unsafe method "Close" on type "io.ReadCloser" -> false positive when calling defer resp.Body.Close() + misspell: + # Correct spellings using locale preferences for US or UK. + # Default is to use a neutral variety of English. + # Setting locale to US will correct the British spelling of 'colour' to 'color'. + locale: US + nakedret: + max-func-lines: 0 + revive: + severity: error + # https://github.com/mgechev/revive + rules: + - name: errorf + - name: context-as-argument + - name: error-return + - name: increment-decrement + - name: indent-error-flow + - name: superfluous-else + - name: unused-parameter + - name: unreachable-code + - name: atomic + - name: empty-lines + - name: early-return + exclusions: + generated: lax + rules: + # disable deprecation errors while we switch over to the SDK structure with multi API version support + - linters: + - staticcheck + text: 'SA1019:' + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gofmt + - goimports + settings: + goimports: + # put imports beginning with prefix after 3rd-party packages; + # it's a comma-separated list of prefixes + local-prefixes: + - github.com/freiheit-com/nmww + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ From 573a47452ef7581206aaeec5069c67f1ddd923f1 Mon Sep 17 00:00:00 2001 From: Carlo Goetz Date: Fri, 27 Mar 2026 17:06:52 +0100 Subject: [PATCH 6/7] fix(lint) configure linter after update, fix linting issues --- golang-ci.yaml | 21 +++++++++-- .../authorization/roleassignments/resource.go | 2 +- .../services/authorization/utils/util_test.go | 1 - .../services/cdn/distribution/resource.go | 18 +++++----- .../iaas/networkarea/resource_test.go | 5 +-- .../iaas/networkarearegion/resource_test.go | 5 +-- .../internal/services/iaas/server/resource.go | 6 ++-- .../services/iaas/volume/datasource.go | 2 +- .../internal/services/iaas/volume/resource.go | 2 +- .../observability/instance/resource.go | 36 +++++++++---------- .../postgresflex/database/resource.go | 6 ++-- .../secretsmanager/instance/resource_test.go | 5 +-- .../serverbackup/schedule/resource.go | 4 ++- .../services/sfs/resourcepool/resource.go | 3 +- .../internal/services/sfs/share/resource.go | 3 +- .../internal/services/ske/cluster/resource.go | 5 +-- 16 files changed, 70 insertions(+), 54 deletions(-) diff --git a/golang-ci.yaml b/golang-ci.yaml index 1d72a2c98..35e8aeeb4 100644 --- a/golang-ci.yaml +++ b/golang-ci.yaml @@ -47,6 +47,7 @@ linters: gosec: excludes: # Suppressions: (see https://github.com/securego/gosec#available-rules for details) + - G101 # "Look for hardcoded credentials" -> a lot of false positives in descriptions for resources like mariadb/credential - G104 # "Audit errors not checked" -> which we don't need and is a badly implemented version of errcheck - G102 # "Bind to all interfaces" -> since this is normal in k8s - G304 # "File path provided as taint input" -> too many false positives @@ -73,13 +74,27 @@ linters: - name: atomic - name: empty-lines - name: early-return + staticcheck: + checks: + # default from https://golangci-lint.run/docs/linters/configuration/#staticcheck + - all + - "-ST1000" + - "-ST1003" + - "-ST1016" + - "-ST1020" + - "-ST1021" + - "-ST1022" + # customizations + - "-SA1019" # disable deprecation errors while we switch over to the SDK structure with multi API version support + - "-QF1001" # disable 'could apply De Morgan's law': readability of boolean expressions is subjective and should be decided on a case-by-case basis + - "-QF1012" # disable 'use fmt.Fprintf instead' Fprintf returns bytes written and an error, which we'd have to handle/ignore to appease some other linter exclusions: generated: lax rules: - # disable deprecation errors while we switch over to the SDK structure with multi API version support - linters: - - staticcheck - text: 'SA1019:' + - gocritic + text: 'dupOption' + path: _acc_test\.go paths: - third_party$ - builtin$ diff --git a/stackit/internal/services/authorization/roleassignments/resource.go b/stackit/internal/services/authorization/roleassignments/resource.go index 46259617f..76afe20b4 100644 --- a/stackit/internal/services/authorization/roleassignments/resource.go +++ b/stackit/internal/services/authorization/roleassignments/resource.go @@ -70,7 +70,7 @@ type roleAssignmentResource struct { // Metadata returns the resource type name. func (r *roleAssignmentResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = fmt.Sprintf("%s_authorization_%s_role_assignment", req.ProviderTypeName, strings.Replace(r.apiName, "-", "_", -1)) + resp.TypeName = fmt.Sprintf("%s_authorization_%s_role_assignment", req.ProviderTypeName, strings.ReplaceAll(r.apiName, "-", "_")) } // Configure adds the provider configured client to the resource. diff --git a/stackit/internal/services/authorization/utils/util_test.go b/stackit/internal/services/authorization/utils/util_test.go index 70714b10d..0e7f8c2f9 100644 --- a/stackit/internal/services/authorization/utils/util_test.go +++ b/stackit/internal/services/authorization/utils/util_test.go @@ -172,7 +172,6 @@ func TestLockAssignment(t *testing.T) { // Wait a tiny bit to ensure G1 has started and acquired the lock time.Sleep(10 * time.Millisecond) wg.Go(func() { - // This should block until G1 releases the lock unlock := LockAssignment(key) defer unlock() diff --git a/stackit/internal/services/cdn/distribution/resource.go b/stackit/internal/services/cdn/distribution/resource.go index e11c8a35a..17b0ce0ca 100644 --- a/stackit/internal/services/cdn/distribution/resource.go +++ b/stackit/internal/services/cdn/distribution/resource.go @@ -570,7 +570,8 @@ func (r *distributionResource) Update(ctx context.Context, req resource.UpdateRe configPatchBackend := &cdn.ConfigPatchBackend{} - if configModel.Backend.Type == "http" { + switch configModel.Backend.Type { + case "http": geofencingPatch := map[string][]string{} if configModel.Backend.Geofencing != nil { gf := make(map[string][]string) @@ -594,7 +595,7 @@ func (r *distributionResource) Update(ctx context.Context, req resource.UpdateRe Type: new("http"), Geofencing: &geofencingPatch, } - } else if configModel.Backend.Type == "bucket" { + case "bucket": configPatchBackend.BucketBackendPatch = &cdn.BucketBackendPatch{ Type: new("bucket"), BucketUrl: configModel.Backend.BucketURL, @@ -713,7 +714,7 @@ func mapFields(ctx context.Context, distribution *cdn.Distribution, model *Model } if distribution.ProjectId == nil { - return fmt.Errorf("Project ID not present") + return fmt.Errorf("'Project ID' not present") } if distribution.Id == nil { @@ -721,15 +722,15 @@ func mapFields(ctx context.Context, distribution *cdn.Distribution, model *Model } if distribution.CreatedAt == nil { - return fmt.Errorf("CreatedAt missing in response") + return fmt.Errorf("'CreatedAt' missing in response") } if distribution.UpdatedAt == nil { - return fmt.Errorf("UpdatedAt missing in response") + return fmt.Errorf("'UpdatedAt' missing in response") } if distribution.Status == nil { - return fmt.Errorf("Status missing in response") + return fmt.Errorf("'Status' missing in response") } model.ID = utils.BuildInternalTerraformId(*distribution.ProjectId, *distribution.Id) @@ -1083,7 +1084,8 @@ func convertConfig(ctx context.Context, model *Model) (*cdn.Config, error) { BlockedCountries: &blockedCountries, } - if configModel.Backend.Type == "http" { + switch configModel.Backend.Type { + case "http": originRequestHeaders := map[string]string{} if configModel.Backend.OriginRequestHeaders != nil { maps.Copy(originRequestHeaders, *configModel.Backend.OriginRequestHeaders) @@ -1094,7 +1096,7 @@ func convertConfig(ctx context.Context, model *Model) (*cdn.Config, error) { Type: new("http"), Geofencing: &geofencing, } - } else if configModel.Backend.Type == "bucket" { + case "bucket": cdnConfig.Backend.BucketBackend = &cdn.BucketBackend{ Type: new("bucket"), BucketUrl: configModel.Backend.BucketURL, diff --git a/stackit/internal/services/iaas/networkarea/resource_test.go b/stackit/internal/services/iaas/networkarea/resource_test.go index d2fd6d0af..69f97d67b 100644 --- a/stackit/internal/services/iaas/networkarea/resource_test.go +++ b/stackit/internal/services/iaas/networkarea/resource_test.go @@ -1086,9 +1086,10 @@ func TestUpdateNetworkRanges(t *testing.T) { // Setup server and client router := mux.NewRouter() router.HandleFunc("/v2/organizations/{organizationId}/network-areas/{areaId}/regions/{region}/network-ranges", func(w http.ResponseWriter, r *http.Request) { - if r.Method == "GET" { + switch r.Method { + case http.MethodGet: getAllNetworkRangesHandler(w, r) - } else if r.Method == "POST" { + case http.MethodPost: createNetworkRangeHandler(w, r) } }) diff --git a/stackit/internal/services/iaas/networkarearegion/resource_test.go b/stackit/internal/services/iaas/networkarearegion/resource_test.go index e7d669fd8..8463a05cf 100644 --- a/stackit/internal/services/iaas/networkarearegion/resource_test.go +++ b/stackit/internal/services/iaas/networkarearegion/resource_test.go @@ -905,9 +905,10 @@ func Test_updateIpv4NetworkRanges(t *testing.T) { // Setup server and client router := mux.NewRouter() router.HandleFunc("/v2/organizations/{organizationId}/network-areas/{areaId}/regions/{region}/network-ranges", func(w http.ResponseWriter, r *http.Request) { - if r.Method == "GET" { + switch r.Method { + case http.MethodGet: getAllNetworkRangesHandler(w, r) - } else if r.Method == "POST" { + case http.MethodPost: createNetworkRangeHandler(w, r) } }) diff --git a/stackit/internal/services/iaas/server/resource.go b/stackit/internal/services/iaas/server/resource.go index a10fe9386..9f368f610 100644 --- a/stackit/internal/services/iaas/server/resource.go +++ b/stackit/internal/services/iaas/server/resource.go @@ -711,7 +711,7 @@ func (r *serverResource) updateServerAttributes(ctx context.Context, model, stat // Generate API request body from model payload, err := toUpdatePayload(ctx, model, stateModel.Labels) if err != nil { - return nil, fmt.Errorf("Creating API payload: %w", err) + return nil, fmt.Errorf("creating API payload: %w", err) } projectId := model.ProjectId.ValueString() serverId := model.ServerId.ValueString() @@ -720,7 +720,7 @@ func (r *serverResource) updateServerAttributes(ctx context.Context, model, stat // Update existing server updatedServer, err = r.client.UpdateServer(ctx, projectId, region, serverId).UpdateServerPayload(*payload).Execute() if err != nil { - return nil, fmt.Errorf("Calling API: %w", err) + return nil, fmt.Errorf("calling API: %w", err) } // Update machine type @@ -731,7 +731,7 @@ func (r *serverResource) updateServerAttributes(ctx context.Context, model, stat } err := r.client.ResizeServer(ctx, projectId, region, serverId).ResizeServerPayload(payload).Execute() if err != nil { - return nil, fmt.Errorf("Resizing the server, calling API: %w", err) + return nil, fmt.Errorf("resizing the server, calling API: %w", err) } _, err = wait.ResizeServerWaitHandler(ctx, r.client, projectId, region, serverId).WaitWithContext(ctx) diff --git a/stackit/internal/services/iaas/volume/datasource.go b/stackit/internal/services/iaas/volume/datasource.go index d3553037c..d884e0d73 100644 --- a/stackit/internal/services/iaas/volume/datasource.go +++ b/stackit/internal/services/iaas/volume/datasource.go @@ -226,7 +226,7 @@ func mapDatasourceFields(ctx context.Context, volumeResp *iaas.Volume, model *Da } else if volumeResp.Id != nil { volumeId = *volumeResp.Id } else { - return fmt.Errorf("Volume id not present") + return fmt.Errorf("volume id not present") } model.Id = utils.BuildInternalTerraformId(model.ProjectId.ValueString(), region, volumeId) diff --git a/stackit/internal/services/iaas/volume/resource.go b/stackit/internal/services/iaas/volume/resource.go index f0ec57a0c..6e01157c5 100644 --- a/stackit/internal/services/iaas/volume/resource.go +++ b/stackit/internal/services/iaas/volume/resource.go @@ -694,7 +694,7 @@ func mapFields(ctx context.Context, volumeResp *iaas.Volume, model *Model, regio } else if volumeResp.Id != nil { volumeId = *volumeResp.Id } else { - return fmt.Errorf("Volume id not present") + return fmt.Errorf("volume id not present") } model.Id = utils.BuildInternalTerraformId(model.ProjectId.ValueString(), region, volumeId) diff --git a/stackit/internal/services/observability/instance/resource.go b/stackit/internal/services/observability/instance/resource.go index 22eb677ad..cb609196f 100644 --- a/stackit/internal/services/observability/instance/resource.go +++ b/stackit/internal/services/observability/instance/resource.go @@ -2540,30 +2540,30 @@ func (r *instanceResource) getAlertConfigs(ctx context.Context, alertConfig *ale if utils.IsUndefined(model.AlertConfig) { *alertConfig, err = getMockAlertConfig(ctx) if err != nil { - return fmt.Errorf("Getting mock alert config: %w", err) + return fmt.Errorf("getting mock alert config: %w", err) } } alertConfigPayload, err := toUpdateAlertConfigPayload(ctx, alertConfig) if err != nil { - return fmt.Errorf("Building alert config payload: %w", err) + return fmt.Errorf("building alert config payload: %w", err) } if alertConfigPayload != nil { _, err = r.client.UpdateAlertConfigs(ctx, instanceId, projectId).UpdateAlertConfigsPayload(*alertConfigPayload).Execute() if err != nil { - return fmt.Errorf("Setting alert config: %w", err) + return fmt.Errorf("setting alert config: %w", err) } } alertConfigResp, err := r.client.GetAlertConfigs(ctx, instanceId, projectId).Execute() if err != nil { - return fmt.Errorf("Calling API to get alert config: %w", err) + return fmt.Errorf("calling API to get alert config: %w", err) } // Map response body to schema err = mapAlertConfigField(ctx, alertConfigResp, model) if err != nil { - return fmt.Errorf("Processing API response for the alert config: %w", err) + return fmt.Errorf("processing API response for the alert config: %w", err) } return nil } @@ -2576,7 +2576,7 @@ func (r *instanceResource) getTracesRetention(ctx context.Context, model *Model) if tracesRetentionDays != nil { tracesResp, err := r.client.GetTracesConfigs(ctx, instanceId, projectId).Execute() if err != nil { - return fmt.Errorf("Getting traces retention policy: %w", err) + return fmt.Errorf("getting traces retention policy: %w", err) } if tracesResp == nil { return fmt.Errorf("nil response") @@ -2585,18 +2585,18 @@ func (r *instanceResource) getTracesRetention(ctx context.Context, model *Model) retentionDays := fmt.Sprintf("%dh", *tracesRetentionDays*24) _, err = r.client.UpdateTracesConfigs(ctx, instanceId, projectId).UpdateTracesConfigsPayload(observability.UpdateTracesConfigsPayload{Retention: &retentionDays}).Execute() if err != nil { - return fmt.Errorf("Setting traces retention policy: %w", err) + return fmt.Errorf("setting traces retention policy: %w", err) } } tracesResp, err := r.client.GetTracesConfigsExecute(ctx, instanceId, projectId) if err != nil { - return fmt.Errorf("Getting traces retention policy: %w", err) + return fmt.Errorf("getting traces retention policy: %w", err) } err = mapTracesRetentionField(tracesResp, model) if err != nil { - return fmt.Errorf("Processing API response for the traces retention %w", err) + return fmt.Errorf("processing API response for the traces retention %w", err) } return nil @@ -2610,7 +2610,7 @@ func (r *instanceResource) getLogsRetention(ctx context.Context, model *Model) e if logsRetentionDays != nil { logsResp, err := r.client.GetLogsConfigs(ctx, instanceId, projectId).Execute() if err != nil { - return fmt.Errorf("Getting logs retention policy: %w", err) + return fmt.Errorf("getting logs retention policy: %w", err) } if logsResp == nil { return fmt.Errorf("nil response") @@ -2619,18 +2619,18 @@ func (r *instanceResource) getLogsRetention(ctx context.Context, model *Model) e retentionDays := fmt.Sprintf("%dh", *logsRetentionDays*24) _, err = r.client.UpdateLogsConfigs(ctx, instanceId, projectId).UpdateLogsConfigsPayload(observability.UpdateLogsConfigsPayload{Retention: &retentionDays}).Execute() if err != nil { - return fmt.Errorf("Setting logs retention policy: %w", err) + return fmt.Errorf("setting logs retention policy: %w", err) } } logsResp, err := r.client.GetLogsConfigsExecute(ctx, instanceId, projectId) if err != nil { - return fmt.Errorf("Getting logs retention policy: %w", err) + return fmt.Errorf("getting logs retention policy: %w", err) } err = mapLogsRetentionField(logsResp, model) if err != nil { - return fmt.Errorf("Processing API response for the logs retention %w", err) + return fmt.Errorf("processing API response for the logs retention %w", err) } return nil @@ -2648,29 +2648,29 @@ func (r *instanceResource) getMetricsRetention(ctx context.Context, model *Model // Need to get the metrics retention policy because update endpoint is a PUT and we need to send all fields metricsResp, err := r.client.GetMetricsStorageRetentionExecute(ctx, instanceId, projectId) if err != nil { - return fmt.Errorf("Getting metrics retention policy: %w", err) + return fmt.Errorf("getting metrics retention policy: %w", err) } metricsRetentionPayload, err := toUpdateMetricsStorageRetentionPayload(metricsRetentionDays, metricsRetentionDays5mDownsampling, metricsRetentionDays1hDownsampling, metricsResp) if err != nil { - return fmt.Errorf("Building metrics retention policy payload: %w", err) + return fmt.Errorf("building metrics retention policy payload: %w", err) } _, err = r.client.UpdateMetricsStorageRetention(ctx, instanceId, projectId).UpdateMetricsStorageRetentionPayload(*metricsRetentionPayload).Execute() if err != nil { - return fmt.Errorf("Setting metrics retention policy: %w", err) + return fmt.Errorf("setting metrics retention policy: %w", err) } } // Get metrics retention policy after update metricsResp, err := r.client.GetMetricsStorageRetentionExecute(ctx, instanceId, projectId) if err != nil { - return fmt.Errorf("Getting metrics retention policy: %w", err) + return fmt.Errorf("getting metrics retention policy: %w", err) } // Map response body to schema err = mapMetricsRetentionField(metricsResp, model) if err != nil { - return fmt.Errorf("Processing API response for the metrics retention %w", err) + return fmt.Errorf("processing API response for the metrics retention %w", err) } return nil } diff --git a/stackit/internal/services/postgresflex/database/resource.go b/stackit/internal/services/postgresflex/database/resource.go index cd2e88e05..619aed53b 100644 --- a/stackit/internal/services/postgresflex/database/resource.go +++ b/stackit/internal/services/postgresflex/database/resource.go @@ -273,7 +273,7 @@ func (r *databaseResource) Read(ctx context.Context, req resource.ReadRequest, r databaseResp, err := getDatabase(ctx, r.client, projectId, region, instanceId, databaseId) if err != nil { oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped - if (ok && oapiErr.StatusCode == http.StatusNotFound) || errors.Is(err, databaseNotFoundErr) { + if (ok && oapiErr.StatusCode == http.StatusNotFound) || errors.Is(err, errDatabaseNotFound) { resp.State.RemoveResource(ctx) return } @@ -418,7 +418,7 @@ func toCreatePayload(model *Model) (*postgresflex.CreateDatabasePayload, error) }, nil } -var databaseNotFoundErr = errors.New("database not found") +var errDatabaseNotFound = errors.New("database not found") // The API does not have a GetDatabase endpoint, only ListDatabases func getDatabase(ctx context.Context, client *postgresflex.APIClient, projectId, region, instanceId, databaseId string) (*postgresflex.InstanceDatabase, error) { @@ -434,5 +434,5 @@ func getDatabase(ctx context.Context, client *postgresflex.APIClient, projectId, return &database, nil } } - return nil, databaseNotFoundErr + return nil, errDatabaseNotFound } diff --git a/stackit/internal/services/secretsmanager/instance/resource_test.go b/stackit/internal/services/secretsmanager/instance/resource_test.go index 8c2dfe8b0..764d1fbc9 100644 --- a/stackit/internal/services/secretsmanager/instance/resource_test.go +++ b/stackit/internal/services/secretsmanager/instance/resource_test.go @@ -472,9 +472,10 @@ func TestUpdateACLs(t *testing.T) { // Setup server and client router := mux.NewRouter() router.HandleFunc("/v1/projects/{projectId}/instances/{instanceId}/acls", func(w http.ResponseWriter, r *http.Request) { - if r.Method == "GET" { + switch r.Method { + case http.MethodGet: getAllACLsHandler(w, r) - } else if r.Method == "POST" { + case http.MethodPost: createACLHandler(w, r) } }) diff --git a/stackit/internal/services/serverbackup/schedule/resource.go b/stackit/internal/services/serverbackup/schedule/resource.go index e88f72b0f..62f0c2725 100644 --- a/stackit/internal/services/serverbackup/schedule/resource.go +++ b/stackit/internal/services/serverbackup/schedule/resource.go @@ -512,6 +512,7 @@ func mapFields(ctx context.Context, schedule *serverbackup.BackupSchedule, model } // If already enabled, just continues + // Deprecated: This function will be removed on 26.09.2026. Use `server_backup_enable` resource instead. func (r *scheduleResource) enableBackupsService(ctx context.Context, model *Model) error { projectId := model.ProjectId.ValueString() @@ -534,6 +535,7 @@ func (r *scheduleResource) enableBackupsService(ctx context.Context, model *Mode } // Disables only if no backup schedules are present and no backups are present + // Deprecated: This function will be removed on 26.09.2026. Use `server_backup_enable` resource instead. func (r *scheduleResource) disableBackupsService(ctx context.Context, model *Model) error { tflog.Debug(ctx, "Disabling server backup service (in case there are no backups and no backup schedules)") @@ -547,7 +549,7 @@ func (r *scheduleResource) disableBackupsService(ctx context.Context, model *Mod if err != nil { return fmt.Errorf("list backups: %w", err) } - if *backups.Items != nil && len(*backups.Items) > 0 { + if len(*backups.Items) > 0 { tflog.Debug(ctx, "Backups found - will not disable server backup service") return nil } diff --git a/stackit/internal/services/sfs/resourcepool/resource.go b/stackit/internal/services/sfs/resourcepool/resource.go index a1fda38fb..3686ce346 100644 --- a/stackit/internal/services/sfs/resourcepool/resource.go +++ b/stackit/internal/services/sfs/resourcepool/resource.go @@ -26,7 +26,6 @@ import ( "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/features" sfsUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/sfs/utils" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils" - coreutils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate" ) @@ -80,7 +79,7 @@ func (r *resourcePoolResource) ModifyPlan(ctx context.Context, req resource.Modi return } - coreutils.AdaptRegion(ctx, configModel.Region, &planModel.Region, r.providerData.GetRegion(), resp) + utils.AdaptRegion(ctx, configModel.Region, &planModel.Region, r.providerData.GetRegion(), resp) if resp.Diagnostics.HasError() { return } diff --git a/stackit/internal/services/sfs/share/resource.go b/stackit/internal/services/sfs/share/resource.go index 50d17e916..70e2e72c2 100644 --- a/stackit/internal/services/sfs/share/resource.go +++ b/stackit/internal/services/sfs/share/resource.go @@ -23,7 +23,6 @@ import ( "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/features" sfsUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/sfs/utils" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils" - coreutils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate" ) @@ -75,7 +74,7 @@ func (r *shareResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanR return } - coreutils.AdaptRegion(ctx, configModel.Region, &planModel.Region, r.providerData.GetRegion(), resp) + utils.AdaptRegion(ctx, configModel.Region, &planModel.Region, r.providerData.GetRegion(), resp) if resp.Diagnostics.HasError() { return } diff --git a/stackit/internal/services/ske/cluster/resource.go b/stackit/internal/services/ske/cluster/resource.go index e3d3ca182..69b916fbc 100644 --- a/stackit/internal/services/ske/cluster/resource.go +++ b/stackit/internal/services/ske/cluster/resource.go @@ -1858,10 +1858,7 @@ func mapExtensions(ctx context.Context, cl *ske.Cluster, m *Model) error { if err != nil { return fmt.Errorf("checking if extensions are disabled: %w", err) } - disabledExtensions := false - if aclDisabled && observabilityDisabled && dnsDisabled { - disabledExtensions = true - } + disabledExtensions := aclDisabled && observabilityDisabled && dnsDisabled emptyExtensions := &ske.Extension{} if *cl.Extensions == *emptyExtensions && (disabledExtensions || m.Extensions.IsNull()) { From 027a5d3a152f64902a185fd0f79d208d06a6d430 Mon Sep 17 00:00:00 2001 From: Carlo Goetz Date: Fri, 27 Mar 2026 17:15:45 +0100 Subject: [PATCH 7/7] fix(lint) ignore false positive --- .../internal/services/access_token/ephemeral_resource_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stackit/internal/services/access_token/ephemeral_resource_test.go b/stackit/internal/services/access_token/ephemeral_resource_test.go index a468ad97b..92301ced1 100644 --- a/stackit/internal/services/access_token/ephemeral_resource_test.go +++ b/stackit/internal/services/access_token/ephemeral_resource_test.go @@ -30,7 +30,7 @@ func startMockTokenServer() *httptest.Server { Scope: "mock_scope", } w.Header().Set("Content-Type", "application/json") - _ = json.NewEncoder(w).Encode(resp) + _ = json.NewEncoder(w).Encode(resp) // nolint:gosec // mock_access_token is not sensitive information }) return httptest.NewServer(handler) }