Skip to content

Commit

Permalink
Make broader use of future.keywords.if/in
Browse files Browse the repository at this point in the history
Signed-off-by: Arik Hadas <[email protected]>
  • Loading branch information
ahadas committed May 4, 2023
1 parent 3280c5d commit 90a5a9b
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package io.konveyor.forklift.openstack

import future.keywords.if

default has_boot_menu_enabled = false

has_boot_menu_enabled {
input.image.properties.hw_boot_menu == "true"
}
has_boot_menu_enabled if input.image.properties.hw_boot_menu == "true"

concerns[flag] {
has_boot_menu_enabled
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package io.konveyor.forklift.openstack

import future.keywords.if
import future.keywords.in

default host_devices = false

host_devices {
input.flavor.extraSpecs["pci_passthrough:alias"]
}
host_devices if "pci_passthrough:alias" in object.keys(input.flavor.extraSpecs)

concerns[flag] {
host_devices
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package io.konveyor.forklift.openstack

import future.keywords.if
import future.keywords.in

default has_numa_enabled = false

has_numa_enabled {
input.flavor.extraSpecs["hw:pci_numa_affinity_policy"]
}
has_numa_enabled if "hw:pci_numa_affinity_policy" in object.keys(input.flavor.extraSpecs)

has_numa_enabled {
input.flavor.extraSpecs["hw:numa_nodes"]
}
has_numa_enabled if "hw:numa_nodes" in object.keys(input.flavor.extraSpecs)

concerns[flag] {
has_numa_enabled
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package io.konveyor.forklift.openstack

import future.keywords.if

default secure_boot_enabled = false

secure_boot_enabled {
input.image.properties.os_secure_boot == "required"
}
secure_boot_enabled if input.image.properties.os_secure_boot == "required"

secure_boot_enabled {
input.flavor.extraSpecs["os:secure_boot"] == "required"
}
secure_boot_enabled if input.flavor.extraSpecs["os:secure_boot"] == "required"

concerns[flag] {
secure_boot_enabled
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package io.konveyor.forklift.openstack

image_based_vm {
input.imageID != ""
}
import future.keywords.if

default image_based_vm = false

image_based_vm if input.imageID != ""

concerns[flag] {
image_based_vm
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package io.konveyor.forklift.openstack

import future.keywords.if

default valid_status_string = false

default legal_vm_status = false

valid_status_string {
is_string(input.status)
}
valid_status_string if is_string(input.status)

legal_vm_status {
regex.match(`ACTIVE|SHUTOFF`, input.status)
}
legal_vm_status if regex.match(`ACTIVE|SHUTOFF`, input.status)

concerns[flag] {
valid_status_string
Expand Down
11 changes: 5 additions & 6 deletions validation/policies/io/konveyor/forklift/openstack/watchdog.rego
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package io.konveyor.forklift.openstack

import future.keywords.if
import future.keywords.in

default has_watchdog_enabled = false

has_watchdog_enabled {
input.flavor.extraSpecs["hw:watchdog_action"]
}
has_watchdog_enabled if "hw:watchdog_action" in object.keys(input.flavor.extraSpecs)

has_watchdog_enabled {
input.image.properties.hw_watchdog_action
}
has_watchdog_enabled if input.image.properties.hw_watchdog_action

concerns[flag] {
has_watchdog_enabled
Expand Down

0 comments on commit 90a5a9b

Please sign in to comment.