Update SDK dependencies (#100)
* Update dependencies * Fix tests * Fix field assignment * Update field assignment * Remove unused functions --------- Co-authored-by: Henrique Santos <henrique.santos@freiheit.com>
This commit is contained in:
parent
9937717104
commit
c3618f2b63
35 changed files with 249 additions and 224 deletions
|
|
@ -14,7 +14,6 @@ import (
|
|||
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
|
||||
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
|
||||
"github.com/hashicorp/terraform-plugin-log/tflog"
|
||||
"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/validate"
|
||||
|
||||
|
|
@ -591,8 +590,8 @@ func mapFields(resp *mongodbflex.GetInstanceResponse, model *Model, flavor *flav
|
|||
flavorValues = map[string]attr.Value{
|
||||
"id": types.StringValue(*instance.Flavor.Id),
|
||||
"description": types.StringValue(*instance.Flavor.Description),
|
||||
"cpu": conversion.ToTypeInt64(instance.Flavor.Cpu),
|
||||
"ram": conversion.ToTypeInt64(instance.Flavor.Memory),
|
||||
"cpu": types.Int64PointerValue(instance.Flavor.Cpu),
|
||||
"ram": types.Int64PointerValue(instance.Flavor.Memory),
|
||||
}
|
||||
}
|
||||
flavorObject, diags := types.ObjectValue(flavorTypes, flavorValues)
|
||||
|
|
@ -609,7 +608,7 @@ func mapFields(resp *mongodbflex.GetInstanceResponse, model *Model, flavor *flav
|
|||
} else {
|
||||
storageValues = map[string]attr.Value{
|
||||
"class": types.StringValue(*instance.Storage.Class),
|
||||
"size": conversion.ToTypeInt64(instance.Storage.Size),
|
||||
"size": types.Int64PointerValue(instance.Storage.Size),
|
||||
}
|
||||
}
|
||||
storageObject, diags := types.ObjectValue(storageTypes, storageValues)
|
||||
|
|
@ -650,7 +649,7 @@ func mapFields(resp *mongodbflex.GetInstanceResponse, model *Model, flavor *flav
|
|||
model.Name = types.StringPointerValue(instance.Name)
|
||||
model.ACL = aclList
|
||||
model.Flavor = flavorObject
|
||||
model.Replicas = conversion.ToTypeInt64(instance.Replicas)
|
||||
model.Replicas = types.Int64PointerValue(instance.Replicas)
|
||||
model.Storage = storageObject
|
||||
model.Version = types.StringPointerValue(instance.Version)
|
||||
model.Options = optionsObject
|
||||
|
|
@ -686,10 +685,10 @@ func toCreatePayload(model *Model, acl []string, flavor *flavorModel, storage *s
|
|||
BackupSchedule: model.BackupSchedule.ValueStringPointer(),
|
||||
FlavorId: flavor.Id.ValueStringPointer(),
|
||||
Name: model.Name.ValueStringPointer(),
|
||||
Replicas: conversion.ToPtrInt32(model.Replicas),
|
||||
Replicas: model.Replicas.ValueInt64Pointer(),
|
||||
Storage: &mongodbflex.InstanceStorage{
|
||||
Class: storage.Class.ValueStringPointer(),
|
||||
Size: conversion.ToPtrInt32(storage.Size),
|
||||
Size: storage.Size.ValueInt64Pointer(),
|
||||
},
|
||||
Version: model.Version.ValueStringPointer(),
|
||||
Options: &payloadOptions,
|
||||
|
|
@ -725,10 +724,10 @@ func toUpdatePayload(model *Model, acl []string, flavor *flavorModel, storage *s
|
|||
BackupSchedule: model.BackupSchedule.ValueStringPointer(),
|
||||
FlavorId: flavor.Id.ValueStringPointer(),
|
||||
Name: model.Name.ValueStringPointer(),
|
||||
Replicas: conversion.ToPtrInt32(model.Replicas),
|
||||
Replicas: model.Replicas.ValueInt64Pointer(),
|
||||
Storage: &mongodbflex.InstanceStorage{
|
||||
Class: storage.Class.ValueStringPointer(),
|
||||
Size: conversion.ToPtrInt32(storage.Size),
|
||||
Size: storage.Size.ValueInt64Pointer(),
|
||||
},
|
||||
Version: model.Version.ValueStringPointer(),
|
||||
Options: &payloadOptions,
|
||||
|
|
@ -746,11 +745,11 @@ func loadFlavorId(ctx context.Context, client mongoDBFlexClient, model *Model, f
|
|||
if flavor == nil {
|
||||
return fmt.Errorf("nil flavor")
|
||||
}
|
||||
cpu := conversion.ToPtrInt32(flavor.CPU)
|
||||
cpu := flavor.CPU.ValueInt64Pointer()
|
||||
if cpu == nil {
|
||||
return fmt.Errorf("nil CPU")
|
||||
}
|
||||
ram := conversion.ToPtrInt32(flavor.RAM)
|
||||
ram := flavor.RAM.ValueInt64Pointer()
|
||||
if ram == nil {
|
||||
return fmt.Errorf("nil RAM")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,18 +81,18 @@ func TestMapFields(t *testing.T) {
|
|||
},
|
||||
BackupSchedule: utils.Ptr("schedule"),
|
||||
Flavor: &mongodbflex.InstanceFlavor{
|
||||
Cpu: utils.Ptr(int32(12)),
|
||||
Cpu: utils.Ptr(int64(12)),
|
||||
Description: utils.Ptr("description"),
|
||||
Id: utils.Ptr("flavor_id"),
|
||||
Memory: utils.Ptr(int32(34)),
|
||||
Memory: utils.Ptr(int64(34)),
|
||||
},
|
||||
Id: utils.Ptr("iid"),
|
||||
Name: utils.Ptr("name"),
|
||||
Replicas: utils.Ptr(int32(56)),
|
||||
Replicas: utils.Ptr(int64(56)),
|
||||
Status: utils.Ptr("status"),
|
||||
Storage: &mongodbflex.InstanceStorage{
|
||||
Class: utils.Ptr("class"),
|
||||
Size: utils.Ptr(int32(78)),
|
||||
Size: utils.Ptr(int64(78)),
|
||||
},
|
||||
Options: &map[string]string{
|
||||
"type": "type",
|
||||
|
|
@ -147,7 +147,7 @@ func TestMapFields(t *testing.T) {
|
|||
Flavor: nil,
|
||||
Id: utils.Ptr("iid"),
|
||||
Name: utils.Ptr("name"),
|
||||
Replicas: utils.Ptr(int32(56)),
|
||||
Replicas: utils.Ptr(int64(56)),
|
||||
Status: utils.Ptr("status"),
|
||||
Storage: nil,
|
||||
Options: &map[string]string{
|
||||
|
|
@ -297,10 +297,10 @@ func TestToCreatePayload(t *testing.T) {
|
|||
BackupSchedule: utils.Ptr("schedule"),
|
||||
FlavorId: utils.Ptr("flavor_id"),
|
||||
Name: utils.Ptr("name"),
|
||||
Replicas: utils.Ptr(int32(12)),
|
||||
Replicas: utils.Ptr(int64(12)),
|
||||
Storage: &mongodbflex.InstanceStorage{
|
||||
Class: utils.Ptr("class"),
|
||||
Size: utils.Ptr(int32(34)),
|
||||
Size: utils.Ptr(int64(34)),
|
||||
},
|
||||
Options: &map[string]string{"type": "type"},
|
||||
Version: utils.Ptr("version"),
|
||||
|
|
@ -337,7 +337,7 @@ func TestToCreatePayload(t *testing.T) {
|
|||
BackupSchedule: nil,
|
||||
FlavorId: nil,
|
||||
Name: nil,
|
||||
Replicas: utils.Ptr(int32(2123456789)),
|
||||
Replicas: utils.Ptr(int64(2123456789)),
|
||||
Storage: &mongodbflex.InstanceStorage{
|
||||
Class: nil,
|
||||
Size: nil,
|
||||
|
|
@ -476,10 +476,10 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
BackupSchedule: utils.Ptr("schedule"),
|
||||
FlavorId: utils.Ptr("flavor_id"),
|
||||
Name: utils.Ptr("name"),
|
||||
Replicas: utils.Ptr(int32(12)),
|
||||
Replicas: utils.Ptr(int64(12)),
|
||||
Storage: &mongodbflex.InstanceStorage{
|
||||
Class: utils.Ptr("class"),
|
||||
Size: utils.Ptr(int32(34)),
|
||||
Size: utils.Ptr(int64(34)),
|
||||
},
|
||||
Options: &map[string]string{"type": "type"},
|
||||
Version: utils.Ptr("version"),
|
||||
|
|
@ -516,7 +516,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
BackupSchedule: nil,
|
||||
FlavorId: nil,
|
||||
Name: nil,
|
||||
Replicas: utils.Ptr(int32(2123456789)),
|
||||
Replicas: utils.Ptr(int64(2123456789)),
|
||||
Storage: &mongodbflex.InstanceStorage{
|
||||
Class: nil,
|
||||
Size: nil,
|
||||
|
|
@ -615,9 +615,9 @@ func TestLoadFlavorId(t *testing.T) {
|
|||
Flavors: &[]mongodbflex.HandlersInfraFlavor{
|
||||
{
|
||||
Id: utils.Ptr("fid-1"),
|
||||
Cpu: utils.Ptr(int32(2)),
|
||||
Cpu: utils.Ptr(int64(2)),
|
||||
Description: utils.Ptr("description"),
|
||||
Memory: utils.Ptr(int32(8)),
|
||||
Memory: utils.Ptr(int64(8)),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -640,15 +640,15 @@ func TestLoadFlavorId(t *testing.T) {
|
|||
Flavors: &[]mongodbflex.HandlersInfraFlavor{
|
||||
{
|
||||
Id: utils.Ptr("fid-1"),
|
||||
Cpu: utils.Ptr(int32(2)),
|
||||
Cpu: utils.Ptr(int64(2)),
|
||||
Description: utils.Ptr("description"),
|
||||
Memory: utils.Ptr(int32(8)),
|
||||
Memory: utils.Ptr(int64(8)),
|
||||
},
|
||||
{
|
||||
Id: utils.Ptr("fid-2"),
|
||||
Cpu: utils.Ptr(int32(1)),
|
||||
Cpu: utils.Ptr(int64(1)),
|
||||
Description: utils.Ptr("description"),
|
||||
Memory: utils.Ptr(int32(4)),
|
||||
Memory: utils.Ptr(int64(4)),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -671,15 +671,15 @@ func TestLoadFlavorId(t *testing.T) {
|
|||
Flavors: &[]mongodbflex.HandlersInfraFlavor{
|
||||
{
|
||||
Id: utils.Ptr("fid-1"),
|
||||
Cpu: utils.Ptr(int32(1)),
|
||||
Cpu: utils.Ptr(int64(1)),
|
||||
Description: utils.Ptr("description"),
|
||||
Memory: utils.Ptr(int32(8)),
|
||||
Memory: utils.Ptr(int64(8)),
|
||||
},
|
||||
{
|
||||
Id: utils.Ptr("fid-2"),
|
||||
Cpu: utils.Ptr(int32(1)),
|
||||
Cpu: utils.Ptr(int64(1)),
|
||||
Description: utils.Ptr("description"),
|
||||
Memory: utils.Ptr(int32(4)),
|
||||
Memory: utils.Ptr(int64(4)),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue