only pass set variable to modify input

This commit is contained in:
Felix Kunde 2026-07-24 15:48:18 +02:00
parent e35e217064
commit 19b56cf7a1
1 changed files with 8 additions and 7 deletions

View File

@ -155,31 +155,32 @@ func (r *EBSVolumeResizer) ResizeVolume(volumeID string, newSize int64) error {
// ModifyVolume Modify EBS volume
func (r *EBSVolumeResizer) ModifyVolume(volumeID string, newType *string, newSize *int64, iops *int64, throughput *int64) error {
/* first check if the volume is already of a requested size */
var sizeInt32 *int32
var iopsInt32 *int32
var throughputInt32 *int32
input := ec2.ModifyVolumeInput{
VolumeId: &volumeID,
}
if newSize != nil {
s := int32(*newSize)
sizeInt32 = &s
input.Size = sizeInt32
}
if iops != nil {
i := int32(*iops)
iopsInt32 = &i
input.Iops = iopsInt32
}
if throughput != nil {
t := int32(*throughput)
throughputInt32 = &t
}
input := ec2.ModifyVolumeInput{
Size: sizeInt32,
VolumeId: &volumeID,
Iops: iopsInt32,
Throughput: throughputInt32,
input.Throughput = throughputInt32
}
if newType != nil {
input.VolumeType = types.VolumeType(*newType)
}
output, err := r.connection.ModifyVolume(context.TODO(), &input)
if err != nil {
return fmt.Errorf("could not modify persistent volume: %v", err)