Skip to content

Files

Latest commit

7ad3cea · Oct 7, 2024

History

History
This branch is 226 commits behind apache/incubator-kie-drools:main.

drools-drlonyaml-parent

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Sep 11, 2024
Dec 18, 2023
Sep 11, 2024
Sep 27, 2024
Dec 18, 2023
Sep 11, 2024
May 9, 2024
Oct 7, 2024

drools-drlonyaml

This tool offer a mechanism of bidirectional translation between a subset of DRL and an analogous YAML representation.

This is an experimental feature. The APIs may change in future versions.

Please note that there is no guarantee that roundtrips of the translation process results in the original file; for instance, this translation process does not maintain across translations the original formatting, whitespaces, etc.

Example

Given a DRL snippet of:

rule "Fix the PersistentVolume Claim Pod PENDING"
when
  $pvc : PersistentVolumeClaim( status.phase == "Pending" )
  $pod : Pod( status.phase == "Pending" )
  Volume( persistentVolumeClaim!.claimName == $pvc.metadata.name ) from $pod.spec.volumes
then
  insert(new Advice("Fix the PersistentVolume","Pod PENDING: "+$pod.getMetadata().getName() + " pvc PENDING: "+$pvc.getMetadata().getName()));
end

this capability can translate it to YAML as:

rules:
- name: Fix the PersistentVolume Claim Pod PENDING
  when:
  - given: PersistentVolumeClaim
    as: $pvc
    having:
    - status.phase == "Pending"
  - given: Pod
    as: $pod
    having:
    - status.phase == "Pending"
  - given: Volume
    having:
    - persistentVolumeClaim!.claimName == $pvc.metadata.name
    from: $pod.spec.volumes
  then: |
    insert(new Advice("Fix the PersistentVolume","Pod PENDING: "+$pod.getMetadata().getName() + " pvc PENDING: "+$pvc.getMetadata().getName()));

The YAML may be translated back again into a DRL file using this capability.