Skip to content

Commit

Permalink
validation: fix openstack shared disk validation
Browse files Browse the repository at this point in the history
Fix the shared disk validation when the attachments
array is empty.

Fixes #442

Signed-off-by: Miguel Martín <[email protected]>
  • Loading branch information
mmartinv authored and ahadas committed Aug 2, 2023
1 parent 4c16b47 commit bf680ca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package io.konveyor.forklift.openstack

volumes := input.volumes

non_shared_disks[i] {
shared_disks[i] {
some i
count(volumes[i].attachments) == 1
count(volumes[i].attachments) > 1
}

concerns[flag] {
count(non_shared_disks) != count(volumes)
count(shared_disks) > 0
flag := {
"category": "Warning",
"label": "Shared disk detected",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
package io.konveyor.forklift.openstack

test_with_no_volumes {
mock_vm := {
"name": "test",
"volumes": [],
}
results := concerns with input as mock_vm
count(results) == 0
}

test_without_shared_disk {
mock_vm := {
"name": "test",
"volumes": [
{"id": "1", "status": "in-use", "attachments": [{"AttachmentID": "1"}]},
{"id": "2", "status": "in-use", "attachments": [{"AttachmentID": "1"}]},
{"id": "3", "status": "in-use", "attachments": [{"AttachmentID": "1"}]},
{"id": "4", "status": "in-use", "attachments": []},
{"id": "5", "status": "in-use" },
],
}
results := concerns with input as mock_vm
Expand All @@ -20,6 +31,8 @@ test_with_shared_disk {
{"id": "1", "status": "in-use", "attachments": [{"AttachmentID": "1"}, {"AttachmentID": "2"}]},
{"id": "2", "status": "in-use", "attachments": [{"AttachmentID": "1"}]},
{"id": "3", "status": "in-use", "attachments": [{"AttachmentID": "1"}]},
{"id": "4", "status": "in-use", "attachments": []},
{"id": "5", "status": "in-use" },
],
}
results := concerns with input as mock_vm
Expand Down

0 comments on commit bf680ca

Please sign in to comment.