Replace ValuePointer function with custom conversion (#121)

This commit is contained in:
Vicente Pinto 2023-11-02 15:28:06 +00:00 committed by GitHub
parent b10302c6de
commit b6100ec8d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 221 additions and 191 deletions

View file

@ -671,15 +671,15 @@ func toCreatePayload(model *Model, acl []string, flavor *flavorModel, storage *s
Acl: &mongodbflex.InstanceAcl{
Items: &acl,
},
BackupSchedule: model.BackupSchedule.ValueStringPointer(),
FlavorId: flavor.Id.ValueStringPointer(),
Name: model.Name.ValueStringPointer(),
Replicas: model.Replicas.ValueInt64Pointer(),
BackupSchedule: core.StringValueToPointer(model.BackupSchedule),
FlavorId: core.StringValueToPointer(flavor.Id),
Name: core.StringValueToPointer(model.Name),
Replicas: core.Int64ValueToPointer(model.Replicas),
Storage: &mongodbflex.InstanceStorage{
Class: storage.Class.ValueStringPointer(),
Size: storage.Size.ValueInt64Pointer(),
Class: core.StringValueToPointer(storage.Class),
Size: core.Int64ValueToPointer(storage.Size),
},
Version: model.Version.ValueStringPointer(),
Version: core.StringValueToPointer(model.Version),
Options: &payloadOptions,
}, nil
}
@ -710,15 +710,15 @@ func toUpdatePayload(model *Model, acl []string, flavor *flavorModel, storage *s
Acl: &mongodbflex.InstanceAcl{
Items: &acl,
},
BackupSchedule: model.BackupSchedule.ValueStringPointer(),
FlavorId: flavor.Id.ValueStringPointer(),
Name: model.Name.ValueStringPointer(),
Replicas: model.Replicas.ValueInt64Pointer(),
BackupSchedule: core.StringValueToPointer(model.BackupSchedule),
FlavorId: core.StringValueToPointer(flavor.Id),
Name: core.StringValueToPointer(model.Name),
Replicas: core.Int64ValueToPointer(model.Replicas),
Storage: &mongodbflex.InstanceStorage{
Class: storage.Class.ValueStringPointer(),
Size: storage.Size.ValueInt64Pointer(),
Class: core.StringValueToPointer(storage.Class),
Size: core.Int64ValueToPointer(storage.Size),
},
Version: model.Version.ValueStringPointer(),
Version: core.StringValueToPointer(model.Version),
Options: &payloadOptions,
}, nil
}
@ -734,11 +734,11 @@ func loadFlavorId(ctx context.Context, client mongoDBFlexClient, model *Model, f
if flavor == nil {
return fmt.Errorf("nil flavor")
}
cpu := flavor.CPU.ValueInt64Pointer()
cpu := core.Int64ValueToPointer(flavor.CPU)
if cpu == nil {
return fmt.Errorf("nil CPU")
}
ram := flavor.RAM.ValueInt64Pointer()
ram := core.Int64ValueToPointer(flavor.RAM)
if ram == nil {
return fmt.Errorf("nil RAM")
}