porter_run_labels.rego 670 B

1234567891011121314151617181920212223
  1. package node.porter_run_labels
  2. import future.keywords
  3. POLICY_ID := sprintf("porter_run_labels_%s", [input.metadata.name])
  4. POLICY_VERSION := "v0.0.1"
  5. POLICY_SEVERITY := "high"
  6. POLICY_TITLE := sprintf("The node %s should have the label porter.run/workload-kind", [input.metadata.name])
  7. POLICY_SUCCESS_MESSAGE := sprintf("Success: this node has the label porter.run/workload-kind", [])
  8. # determine if the label porter.run/workload-kind exists
  9. allow if {
  10. input.metadata.labels["porter.run/workload-kind"]
  11. }
  12. FAILURE_MESSAGE contains msg if {
  13. not allow
  14. msg := sprintf("Failed: the node %s does not have the label porter.run/workload-kind", [input.metadata.name])
  15. }