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
|
|
@ -13,7 +13,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"
|
||||
|
||||
|
|
@ -542,8 +541,8 @@ func mapFields(resp *postgresflex.InstanceResponse, model *Model, flavor *flavor
|
|||
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)
|
||||
|
|
@ -560,7 +559,7 @@ func mapFields(resp *postgresflex.InstanceResponse, model *Model, flavor *flavor
|
|||
} 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)
|
||||
|
|
@ -580,7 +579,7 @@ func mapFields(resp *postgresflex.InstanceResponse, model *Model, flavor *flavor
|
|||
model.ACL = aclList
|
||||
model.BackupSchedule = types.StringPointerValue(instance.BackupSchedule)
|
||||
model.Flavor = flavorObject
|
||||
model.Replicas = conversion.ToTypeInt64(instance.Replicas)
|
||||
model.Replicas = types.Int64PointerValue(instance.Replicas)
|
||||
model.Storage = storageObject
|
||||
model.Version = types.StringPointerValue(instance.Version)
|
||||
return nil
|
||||
|
|
@ -607,10 +606,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: &postgresflex.InstanceStorage{
|
||||
Class: storage.Class.ValueStringPointer(),
|
||||
Size: conversion.ToPtrInt32(storage.Size),
|
||||
Size: storage.Size.ValueInt64Pointer(),
|
||||
},
|
||||
Version: model.Version.ValueStringPointer(),
|
||||
}, nil
|
||||
|
|
@ -637,10 +636,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: &postgresflex.InstanceStorage{
|
||||
Class: storage.Class.ValueStringPointer(),
|
||||
Size: conversion.ToPtrInt32(storage.Size),
|
||||
Size: storage.Size.ValueInt64Pointer(),
|
||||
},
|
||||
Version: model.Version.ValueStringPointer(),
|
||||
}, nil
|
||||
|
|
@ -657,11 +656,11 @@ func loadFlavorId(ctx context.Context, client postgresFlexClient, model *Model,
|
|||
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")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,18 +76,18 @@ func TestMapFields(t *testing.T) {
|
|||
},
|
||||
BackupSchedule: utils.Ptr("schedule"),
|
||||
Flavor: &postgresflex.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: &postgresflex.InstanceStorage{
|
||||
Class: utils.Ptr("class"),
|
||||
Size: utils.Ptr(int32(78)),
|
||||
Size: utils.Ptr(int64(78)),
|
||||
},
|
||||
Version: utils.Ptr("version"),
|
||||
},
|
||||
|
|
@ -135,7 +135,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,
|
||||
Version: utils.Ptr("version"),
|
||||
|
|
@ -268,10 +268,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: &postgresflex.InstanceStorage{
|
||||
Class: utils.Ptr("class"),
|
||||
Size: utils.Ptr(int32(34)),
|
||||
Size: utils.Ptr(int64(34)),
|
||||
},
|
||||
Version: utils.Ptr("version"),
|
||||
},
|
||||
|
|
@ -304,7 +304,7 @@ func TestToCreatePayload(t *testing.T) {
|
|||
BackupSchedule: nil,
|
||||
FlavorId: nil,
|
||||
Name: nil,
|
||||
Replicas: utils.Ptr(int32(2123456789)),
|
||||
Replicas: utils.Ptr(int64(2123456789)),
|
||||
Storage: &postgresflex.InstanceStorage{
|
||||
Class: nil,
|
||||
Size: nil,
|
||||
|
|
@ -422,10 +422,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: &postgresflex.InstanceStorage{
|
||||
Class: utils.Ptr("class"),
|
||||
Size: utils.Ptr(int32(34)),
|
||||
Size: utils.Ptr(int64(34)),
|
||||
},
|
||||
Version: utils.Ptr("version"),
|
||||
},
|
||||
|
|
@ -458,7 +458,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
BackupSchedule: nil,
|
||||
FlavorId: nil,
|
||||
Name: nil,
|
||||
Replicas: utils.Ptr(int32(2123456789)),
|
||||
Replicas: utils.Ptr(int64(2123456789)),
|
||||
Storage: &postgresflex.InstanceStorage{
|
||||
Class: nil,
|
||||
Size: nil,
|
||||
|
|
@ -542,9 +542,9 @@ func TestLoadFlavorId(t *testing.T) {
|
|||
Flavors: &[]postgresflex.InstanceFlavor{
|
||||
{
|
||||
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)),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -567,15 +567,15 @@ func TestLoadFlavorId(t *testing.T) {
|
|||
Flavors: &[]postgresflex.InstanceFlavor{
|
||||
{
|
||||
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)),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -598,15 +598,15 @@ func TestLoadFlavorId(t *testing.T) {
|
|||
Flavors: &[]postgresflex.InstanceFlavor{
|
||||
{
|
||||
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