diff options
Diffstat (limited to 'module')
-rw-r--r-- | module/ri-engine/src/main/java/io/trygvis/rules/network/IpCalc.java (renamed from module/ri-engine/src/main/java/io/trygvis/rules/acme/IpCalc.java) | 18 | ||||
-rw-r--r-- | module/ri-engine/src/main/resources/io/trygvis/rules/acme/acme.drl | 10 | ||||
-rw-r--r-- | module/ri-engine/src/test/java/io/trygvis/rules/network/IpCalcTest.java (renamed from module/ri-engine/src/test/java/io/trygvis/rules/acme/IpCalcTest.java) | 8 | ||||
-rw-r--r-- | module/ri-wireguard/src/main/java/io/trygvis/rules/acme/Foo.java | 7 | ||||
-rw-r--r-- | module/ri-wireguard/src/main/resources/META-INF/kmodule.xml | 2 | ||||
-rw-r--r-- | module/ri-wireguard/src/main/resources/io/trygvis/rules/wireguard/wireguard.drl (renamed from module/ri-wireguard/src/main/resources/io/trygvis/rules/acme/vpn.drl) | 6 |
6 files changed, 12 insertions, 39 deletions
diff --git a/module/ri-engine/src/main/java/io/trygvis/rules/acme/IpCalc.java b/module/ri-engine/src/main/java/io/trygvis/rules/network/IpCalc.java index 5369d62..e40e169 100644 --- a/module/ri-engine/src/main/java/io/trygvis/rules/acme/IpCalc.java +++ b/module/ri-engine/src/main/java/io/trygvis/rules/network/IpCalc.java @@ -1,26 +1,10 @@ -package io.trygvis.rules.acme; +package io.trygvis.rules.network; -import io.trygvis.rules.network.Ipv4Cidr; - -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.List; import java.util.regex.Pattern; public class IpCalc { private static final Pattern pattern = Pattern.compile("([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})/([0-9]{1,3})"); - public static class FirstLast { - public final int first; - public final int last; - - public FirstLast(int first, int last) { - this.first = first; - this.last = last; - } - } - public static Ipv4Cidr cidr(String cidr) { var matcher = pattern.matcher(cidr); if (!matcher.matches()) { diff --git a/module/ri-engine/src/main/resources/io/trygvis/rules/acme/acme.drl b/module/ri-engine/src/main/resources/io/trygvis/rules/acme/acme.drl index 0465343..7d53763 100644 --- a/module/ri-engine/src/main/resources/io/trygvis/rules/acme/acme.drl +++ b/module/ri-engine/src/main/resources/io/trygvis/rules/acme/acme.drl @@ -4,16 +4,13 @@ import io.trygvis.rules.machine.Machine; import io.trygvis.rules.dba.Cluster; import io.trygvis.rules.dba.Container; +dialect "mvel" + declare AcmeServer name : String machine : Machine end -//declare MachinePublicName -// machine : Machine -// fqdn : String -//end - rule "Ops" when $ops: AcmeOps() @@ -56,7 +53,6 @@ when $m : Machine(fqdn == null) $s : AcmeServer(machine == $m) then - var fqdn = "%s.machine.acme.com".formatted($s.machine.name); - $s.machine.fqdn = fqdn; + $s.machine.fqdn = "%s.machine.acme.com".formatted($s.machine.name); update($s.machine) end diff --git a/module/ri-engine/src/test/java/io/trygvis/rules/acme/IpCalcTest.java b/module/ri-engine/src/test/java/io/trygvis/rules/network/IpCalcTest.java index 8b1e2c6..e0642d6 100644 --- a/module/ri-engine/src/test/java/io/trygvis/rules/acme/IpCalcTest.java +++ b/module/ri-engine/src/test/java/io/trygvis/rules/network/IpCalcTest.java @@ -1,17 +1,17 @@ -package io.trygvis.rules.acme; +package io.trygvis.rules.network; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; class IpCalcTest { @Test public void basic() { - Assertions.assertThrows(IllegalArgumentException.class, () -> IpCalc.cidr("192.168.1.1/24").addresses()); + assertThrows(IllegalArgumentException.class, () -> IpCalc.cidr("192.168.1.1/24").addresses()); assertEquals(256, IpCalc.cidr("192.168.1.0/24").addresses().size()); assertEquals(128, IpCalc.cidr("192.168.1.128/25").addresses().size()); } diff --git a/module/ri-wireguard/src/main/java/io/trygvis/rules/acme/Foo.java b/module/ri-wireguard/src/main/java/io/trygvis/rules/acme/Foo.java deleted file mode 100644 index 44f5eba..0000000 --- a/module/ri-wireguard/src/main/java/io/trygvis/rules/acme/Foo.java +++ /dev/null @@ -1,7 +0,0 @@ -package io.trygvis.rules.acme; - -public class Foo { - public static void main(String[] args) { - System.out.println("Foo.main"); - } -} diff --git a/module/ri-wireguard/src/main/resources/META-INF/kmodule.xml b/module/ri-wireguard/src/main/resources/META-INF/kmodule.xml index 64cc4d2..f046259 100644 --- a/module/ri-wireguard/src/main/resources/META-INF/kmodule.xml +++ b/module/ri-wireguard/src/main/resources/META-INF/kmodule.xml @@ -3,7 +3,7 @@ xmlns="http://www.drools.org/xsd/kmodule" xsi:schemaLocation="http://www.drools.org/xsd/kmodule https://www.drools.org/xsd/kmodule_7_1.xsd"> - <kbase name="wireguard" packages="io.trygvis.rules.acme"> + <kbase name="wireguard" packages="io.trygvis.rules.wireguard"> <ksession name="wireguard"/> </kbase> </kmodule> diff --git a/module/ri-wireguard/src/main/resources/io/trygvis/rules/acme/vpn.drl b/module/ri-wireguard/src/main/resources/io/trygvis/rules/wireguard/wireguard.drl index 7896953..342cbb5 100644 --- a/module/ri-wireguard/src/main/resources/io/trygvis/rules/acme/vpn.drl +++ b/module/ri-wireguard/src/main/resources/io/trygvis/rules/wireguard/wireguard.drl @@ -1,11 +1,11 @@ -package io.trygvis.rules.acme; +package io.trygvis.rules.wireguard; import java.util.ArrayList -import io.trygvis.rules.machine.Machine; import io.trygvis.rules.dns.DnsEntry; -import io.trygvis.rules.acme.AcmeServer +import io.trygvis.rules.machine.Machine; import io.trygvis.rules.network.Ipv4Address import io.trygvis.rules.network.Ipv4Cidr +import io.trygvis.rules.network.IpCalc dialect "mvel" |