So I have created this function that will add a disk if needed and it takes a disk and a size as inputs. The idea is that I need to update data.disks with a few properties. Disk is called from an external request and it follows the pattern of "disk1", "disk2" and so on. Looking at it there are a few hard-coded values and some that are null. However I left them on purpose to show the structure of data.disk for the next person that might read it or modify it. Because of this it looks verbose and I don't really like it all that much. Do you see a way to make this function more readable/better in any way?
function addDisk(disk, size) {
var diskNumber = disk.slice(-1);
var diskLabel = "Hard disk " + diskNumber;
var diskIndex = diskNumber - 1;
//Updating JSON data object
data.disks[diskIndex] = {
"componentTypeId" : "com.vmware.csp.iaas.blueprint.service",
"componentId" : null,
"classId" : "Infrastructure.Compute.Machine.MachineDisk",
"typeFilter" : null,
"data" : {
"capacity" : size,
"custom_properties" : null,
"id" : null,
"initial_location" : "",
"is_clone" : false,
"label" : diskLabel,
"storage_reservation_policy" : "",
"userCreated" : true,
"volumeId" : diskIndex
}
}
log(diskLabel + " has capacity of: " + size + " GBs");
}
disk
does not seem evident – konijn yesterday