I've got all servere problems by as a []array. Problem is how to slice(groupBy) status,bootable. I just wanna take as status = available, bootable = false
Controller
slicedBy := make(map[string]interface{})
server := blockstorage.ListVolumes(tenantID.(string)) <----- this is array
for _, sg := range server{
slicedBy[sg.ID] = sg.Status <------- slice by Status
slicedBy[sg.ID] = sg.Bootable <------- slice by Bootable
}
Json array
{
id 123
status available
bootable false
...
}
server as array
[
{
"id": "a8b123fc-a141-4682-b65b-d56899621959",
"status": "available",
"size": 1,
"availability_zone": "nova",
"attachments": [],
"name": "snapshot 1",
"description": "",
"bootable": "false",
},
{
"id": "ccb734d4-c098-4929-8ce5-281b6a58421d",
"status": "error",
"size": 2,
"availability_zone": "nova",
"attachments": [],
"name": "",
"description": "",
"volume_type": "",
"bootable": "false",
"volume_image_metadata": {
"signature_verified": "False"
}
},
for _, sg := range server {
if(sg.Status == "available" && sg.Bootable == "false"){
jsons["Data"] = sg
}
}
It worked perfectly. I just found it.