summaryrefslogtreecommitdiff
path: root/module
diff options
context:
space:
mode:
Diffstat (limited to 'module')
-rw-r--r--module/acme/classpath.txt57
-rw-r--r--module/acme/pom.xml24
-rw-r--r--module/acme/src/main/java/io/trygvis/acme/AcmeMyApp.java (renamed from module/ri-engine/src/main/java/io/trygvis/rules/acme/AcmeMyApp.java)2
-rw-r--r--module/acme/src/main/java/io/trygvis/acme/AcmeOps.java4
-rw-r--r--module/acme/src/main/java/io/trygvis/acme/VpnMain.java25
-rw-r--r--module/acme/src/main/resources/META-INF/kmodule.xml11
-rw-r--r--module/acme/src/main/resources/io/trygvis/acme/acme.drl (renamed from module/ri-engine/src/main/resources/io/trygvis/rules/acme/acme.drl)2
-rw-r--r--module/ri-engine/pom.xml1
-rw-r--r--module/ri-engine/src/main/java/io/trygvis/rules/acme/AcmeOps.java4
-rw-r--r--module/ri-engine/src/main/java/io/trygvis/rules/engine/DbIo.java (renamed from module/ri-engine/src/main/java/io/trygvis/rules/acme/AcmeIo.java)13
-rw-r--r--module/ri-engine/src/main/java/io/trygvis/rules/engine/DbObject.java (renamed from module/ri-engine/src/main/java/io/trygvis/rules/acme/AcmeObject.java)8
-rw-r--r--module/ri-engine/src/main/java/io/trygvis/rules/engine/Engine.java (renamed from module/ri-engine/src/main/java/io/trygvis/rules/engine/Main.java)33
-rw-r--r--module/ri-engine/src/main/resources/META-INF/kmodule.xml5
-rw-r--r--module/ri-engine/src/main/resources/io/trygvis/rules/dba/dba.drl1
-rw-r--r--module/ri-engine/src/main/resources/io/trygvis/rules/engine/default.drl1
-rw-r--r--module/ri-engine/src/main/resources/io/trygvis/rules/machine/machine.drl6
-rw-r--r--module/ri-wireguard/src/main/resources/META-INF/kmodule.xml2
17 files changed, 149 insertions, 50 deletions
diff --git a/module/acme/classpath.txt b/module/acme/classpath.txt
new file mode 100644
index 0000000..5d086d8
--- /dev/null
+++ b/module/acme/classpath.txt
@@ -0,0 +1,57 @@
+io.trygvis.rules-sandbox:acme:1.0-SNAPSHOT:jar
+ch.obermuhlner:big-math:2.0.1:jar
+ch.qos.logback:logback-classic:1.2.3:jar
+ch.qos.logback:logback-core:1.2.3:jar
+com.fasterxml.jackson.core:jackson-annotations:2.12.0:jar
+com.fasterxml.jackson.core:jackson-core:2.12.0:jar
+com.fasterxml.jackson.core:jackson-databind:2.12.0:jar
+com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.12.0:jar
+com.github.virtuald:curvesapi:1.06:jar
+com.google.code.findbugs:annotations:3.0.1:jar
+com.google.errorprone:error_prone_annotations:2.1.3:jar
+com.google.guava:guava:25.0-jre:jar
+com.google.j2objc:j2objc-annotations:1.1:jar
+com.google.re2j:re2j:1.2:jar
+com.googlecode.java-ipv6:java-ipv6:0.17:jar
+com.hubspot.jinjava:jinjava:2.5.6:jar
+com.thoughtworks.xstream:xstream:1.4.14:jar
+com.zaxxer:SparseBitSet:1.2:jar
+commons-codec:commons-codec:1.11:jar
+commons-io:commons-io:2.6:jar
+commons-net:commons-net:2.2:jar
+io.trygvis.rules-sandbox:ri-engine:1.0-SNAPSHOT:jar
+io.trygvis.rules-sandbox:ri-wireguard:1.0-SNAPSHOT:jar
+org.antlr:antlr-runtime:3.5.2:jar
+org.apache.commons:commons-collections4:4.4:jar
+org.apache.commons:commons-compress:1.19:jar
+org.apache.commons:commons-lang3:3.9:jar
+org.apache.commons:commons-math3:3.4.1:jar
+org.apache.poi:poi:4.1.2:jar
+org.apache.poi:poi-ooxml:4.1.2:jar
+org.apache.poi:poi-ooxml-schemas:4.1.2:jar
+org.apache.xmlbeans:xmlbeans:3.1.0:jar
+org.checkerframework:checker-compat-qual:2.0.0:jar
+org.codehaus.mojo:animal-sniffer-annotations:1.14:jar
+org.drools:drools-compiler:7.47.0.Final:jar
+org.drools:drools-core:7.47.0.Final:jar
+org.drools:drools-core-dynamic:7.47.0.Final:jar
+org.drools:drools-core-reflective:7.47.0.Final:jar
+org.drools:drools-decisiontables:7.47.0.Final:jar
+org.drools:drools-ecj:7.47.0.Final:jar
+org.drools:drools-mvel:7.47.0.Final:jar
+org.drools:drools-templates:7.47.0.Final:jar
+org.javassist:javassist:3.26.0-GA:jar
+org.jsoup:jsoup:1.8.3:jar
+org.kie:kie-api:7.47.0.Final:jar
+org.kie:kie-internal:7.47.0.Final:jar
+org.kie:kie-memory-compiler:7.47.0.Final:jar
+org.kie.soup:kie-soup-commons:7.47.0.Final:jar
+org.kie.soup:kie-soup-maven-support:7.47.0.Final:jar
+org.kie.soup:kie-soup-project-datamodel-api:7.47.0.Final:jar
+org.kie.soup:kie-soup-project-datamodel-commons:7.47.0.Final:jar
+org.kie.soup:kie-soup-xstream:7.47.0.Final:jar
+org.mvel:mvel2:2.4.10.Final:jar
+org.slf4j:slf4j-api:1.7.26:jar
+org.yaml:snakeyaml:1.26:jar
+xmlpull:xmlpull:1.2.0:jar
+xpp3:xpp3_min:1.2.0:jar
diff --git a/module/acme/pom.xml b/module/acme/pom.xml
new file mode 100644
index 0000000..b3fc43c
--- /dev/null
+++ b/module/acme/pom.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>io.trygvis.rules-sandbox</groupId>
+ <artifactId>rules-sandbox</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>acme</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ri-engine</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/module/ri-engine/src/main/java/io/trygvis/rules/acme/AcmeMyApp.java b/module/acme/src/main/java/io/trygvis/acme/AcmeMyApp.java
index a1340e7..dfe374b 100644
--- a/module/ri-engine/src/main/java/io/trygvis/rules/acme/AcmeMyApp.java
+++ b/module/acme/src/main/java/io/trygvis/acme/AcmeMyApp.java
@@ -1,4 +1,4 @@
-package io.trygvis.rules.acme;
+package io.trygvis.acme;
public class AcmeMyApp {
public String environment;
diff --git a/module/acme/src/main/java/io/trygvis/acme/AcmeOps.java b/module/acme/src/main/java/io/trygvis/acme/AcmeOps.java
new file mode 100644
index 0000000..844c7f0
--- /dev/null
+++ b/module/acme/src/main/java/io/trygvis/acme/AcmeOps.java
@@ -0,0 +1,4 @@
+package io.trygvis.acme;
+
+public class AcmeOps {
+}
diff --git a/module/acme/src/main/java/io/trygvis/acme/VpnMain.java b/module/acme/src/main/java/io/trygvis/acme/VpnMain.java
new file mode 100644
index 0000000..d5f986d
--- /dev/null
+++ b/module/acme/src/main/java/io/trygvis/acme/VpnMain.java
@@ -0,0 +1,25 @@
+package io.trygvis.acme;
+
+import io.trygvis.rules.dns.DnsEntry;
+import io.trygvis.rules.engine.Engine;
+import io.trygvis.rules.machine.Machine;
+import io.trygvis.rules.network.Ipv4Address;
+import io.trygvis.rules.network.Ipv4Cidr;
+
+import java.io.IOException;
+
+public class VpnMain {
+ public static void main(String[] args) throws IOException {
+ try (var engine = new Engine("acme.yaml")) {
+ engine.io.dump("phase-1", engine.session.getFactHandles());
+
+ engine.io.dump("vpn0", engine.session.getFactHandles(), (Object o) ->
+ o.getClass().getName().contains("Wg")
+ || o instanceof Machine
+ || o instanceof DnsEntry
+ || o instanceof Ipv4Cidr
+ || o instanceof Ipv4Address
+ );
+ }
+ }
+}
diff --git a/module/acme/src/main/resources/META-INF/kmodule.xml b/module/acme/src/main/resources/META-INF/kmodule.xml
new file mode 100644
index 0000000..351a25e
--- /dev/null
+++ b/module/acme/src/main/resources/META-INF/kmodule.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kmodule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ 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 packages="io.trygvis.acme" default="true"
+ includes="engine,wireguard">
+ <ksession name="Default" default="true">
+ </ksession>
+ </kbase>
+</kmodule>
diff --git a/module/ri-engine/src/main/resources/io/trygvis/rules/acme/acme.drl b/module/acme/src/main/resources/io/trygvis/acme/acme.drl
index 7d53763..d978579 100644
--- a/module/ri-engine/src/main/resources/io/trygvis/rules/acme/acme.drl
+++ b/module/acme/src/main/resources/io/trygvis/acme/acme.drl
@@ -1,4 +1,4 @@
-package io.trygvis.rules.acme;
+package io.trygvis.acme;
import io.trygvis.rules.machine.Machine;
import io.trygvis.rules.dba.Cluster;
diff --git a/module/ri-engine/pom.xml b/module/ri-engine/pom.xml
index addd8c5..fd9ba7c 100644
--- a/module/ri-engine/pom.xml
+++ b/module/ri-engine/pom.xml
@@ -74,7 +74,6 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
- <version>2.8.0</version>
</dependency>
<dependency>
diff --git a/module/ri-engine/src/main/java/io/trygvis/rules/acme/AcmeOps.java b/module/ri-engine/src/main/java/io/trygvis/rules/acme/AcmeOps.java
deleted file mode 100644
index 147fcfa..0000000
--- a/module/ri-engine/src/main/java/io/trygvis/rules/acme/AcmeOps.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package io.trygvis.rules.acme;
-
-public class AcmeOps {
-}
diff --git a/module/ri-engine/src/main/java/io/trygvis/rules/acme/AcmeIo.java b/module/ri-engine/src/main/java/io/trygvis/rules/engine/DbIo.java
index 456195d..b835da5 100644
--- a/module/ri-engine/src/main/java/io/trygvis/rules/acme/AcmeIo.java
+++ b/module/ri-engine/src/main/java/io/trygvis/rules/engine/DbIo.java
@@ -1,10 +1,9 @@
-package io.trygvis.rules.acme;
+package io.trygvis.rules.engine;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.TypeFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
-import org.apache.commons.collections4.OrderedMap;
import org.drools.core.common.DefaultFactHandle;
import org.kie.api.KieBase;
import org.kie.api.runtime.rule.FactHandle;
@@ -16,10 +15,10 @@ import java.util.*;
import java.util.function.Function;
@SuppressWarnings("unchecked")
-public class AcmeIo {
+public class DbIo {
private final ObjectMapper mapper;
- public AcmeIo(KieBase kieBase) {
+ public DbIo(KieBase kieBase) {
var factory = new YAMLFactory();
factory.enable(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID);
factory.enable(YAMLGenerator.Feature.USE_NATIVE_OBJECT_ID);
@@ -33,10 +32,10 @@ public class AcmeIo {
public List<Object> load(String file) throws IOException {
var parser = mapper.getFactory().createParser(new File(file));
- var objects = mapper.readValues(parser, AcmeObject.class).readAll(new ArrayList<>());
+ var objects = mapper.readValues(parser, DbObject.class).readAll(new ArrayList<>());
List<Object> items = new ArrayList<>(objects.size());
- for (AcmeObject object : objects) {
+ for (DbObject object : objects) {
try {
var type = mapper.getTypeFactory().findClass(object.type);
var x = mapper.treeToValue(object.data, type);
@@ -221,7 +220,7 @@ public class AcmeIo {
var collection = e.getValue();
collection.sort();
for (var fact : collection.values) {
- g.writeObject(new AcmeObject(name, mapper.valueToTree(fact)));
+ g.writeObject(new DbObject(name, mapper.valueToTree(fact)));
}
}
}
diff --git a/module/ri-engine/src/main/java/io/trygvis/rules/acme/AcmeObject.java b/module/ri-engine/src/main/java/io/trygvis/rules/engine/DbObject.java
index a75c4ba..6b9817e 100644
--- a/module/ri-engine/src/main/java/io/trygvis/rules/acme/AcmeObject.java
+++ b/module/ri-engine/src/main/java/io/trygvis/rules/engine/DbObject.java
@@ -1,15 +1,15 @@
-package io.trygvis.rules.acme;
+package io.trygvis.rules.engine;
import com.fasterxml.jackson.databind.node.ObjectNode;
-public final class AcmeObject {
+public final class DbObject {
public String type;
public ObjectNode data;
- public AcmeObject() {
+ public DbObject() {
}
- public AcmeObject(String type, ObjectNode data) {
+ public DbObject(String type, ObjectNode data) {
this.type = type;
this.data = data;
}
diff --git a/module/ri-engine/src/main/java/io/trygvis/rules/engine/Main.java b/module/ri-engine/src/main/java/io/trygvis/rules/engine/Engine.java
index 7c96be6..2565112 100644
--- a/module/ri-engine/src/main/java/io/trygvis/rules/engine/Main.java
+++ b/module/ri-engine/src/main/java/io/trygvis/rules/engine/Engine.java
@@ -1,27 +1,27 @@
package io.trygvis.rules.engine;
-import io.trygvis.rules.acme.AcmeIo;
-import io.trygvis.rules.dns.DnsEntry;
-import io.trygvis.rules.machine.Machine;
-import io.trygvis.rules.network.Ipv4Address;
-import io.trygvis.rules.network.Ipv4Cidr;
import org.drools.core.audit.WorkingMemoryConsoleLogger;
import org.kie.api.KieServices;
import org.kie.api.event.rule.AgendaEventListener;
import org.kie.api.event.rule.RuleRuntimeEventListener;
+import org.kie.api.runtime.KieSession;
+import java.io.Closeable;
import java.io.IOException;
-public class Main {
- public static void main(String[] args) throws IOException {
+public class Engine implements Closeable {
+ public final DbIo io;
+ public final KieSession session;
+
+ public Engine(String database) throws IOException {
var services = KieServices.Factory.get();
var container = services.getKieClasspathContainer();
var kieBase = container.getKieBase();
- var io = new AcmeIo(kieBase);
- var objects = io.load("acme.yaml");
+ io = new DbIo(kieBase);
+ var objects = io.load(database);
- var session = container.newKieSession();
+ session = container.newKieSession();
session.setGlobal("te", new TemplateEngine());
@@ -37,17 +37,10 @@ public class Main {
session.getAgenda().getAgendaGroup("init").setFocus();
session.fireAllRules();
+ }
- io.dump("phase-1", session.getFactHandles());
-
- io.dump("vpn0", session.getFactHandles(), (Object o) ->
- o.getClass().getName().contains("Wg")
- || o instanceof Machine
- || o instanceof DnsEntry
- || o instanceof Ipv4Cidr
- || o instanceof Ipv4Address
- );
-
+ @Override
+ public void close() {
session.dispose();
}
}
diff --git a/module/ri-engine/src/main/resources/META-INF/kmodule.xml b/module/ri-engine/src/main/resources/META-INF/kmodule.xml
index 7a46b1a..ffba357 100644
--- a/module/ri-engine/src/main/resources/META-INF/kmodule.xml
+++ b/module/ri-engine/src/main/resources/META-INF/kmodule.xml
@@ -3,9 +3,6 @@
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 packages="io.trygvis.rules,io.trygvis.rules.acme,io.trygvis.rules.dba,io.trygvis.rules.engine,io.trygvis.rules.machine,io.trygvis.rules.terraform"
- default="true" includes="wireguard">
- <ksession name="Default" default="true">
- </ksession>
+ <kbase name="engine" packages="io.trygvis.rules.dba,io.trygvis.rules.engine,io.trygvis.rules.machine,io.trygvis.rules.terraform">
</kbase>
</kmodule>
diff --git a/module/ri-engine/src/main/resources/io/trygvis/rules/dba/dba.drl b/module/ri-engine/src/main/resources/io/trygvis/rules/dba/dba.drl
deleted file mode 100644
index 7beceef..0000000
--- a/module/ri-engine/src/main/resources/io/trygvis/rules/dba/dba.drl
+++ /dev/null
@@ -1 +0,0 @@
-package io.trygvis.rules.dba;
diff --git a/module/ri-engine/src/main/resources/io/trygvis/rules/engine/default.drl b/module/ri-engine/src/main/resources/io/trygvis/rules/engine/default.drl
index 090fddf..a933bd9 100644
--- a/module/ri-engine/src/main/resources/io/trygvis/rules/engine/default.drl
+++ b/module/ri-engine/src/main/resources/io/trygvis/rules/engine/default.drl
@@ -1,4 +1,5 @@
package io.trygvis.rules.engine;
+
import java.util.Map
import org.apache.commons.io.FileSystem
import org.apache.commons.io.FileUtils
diff --git a/module/ri-engine/src/main/resources/io/trygvis/rules/machine/machine.drl b/module/ri-engine/src/main/resources/io/trygvis/rules/machine/machine.drl
deleted file mode 100644
index a9a379f..0000000
--- a/module/ri-engine/src/main/resources/io/trygvis/rules/machine/machine.drl
+++ /dev/null
@@ -1,6 +0,0 @@
-package io.trygvis.rules.machine;
-
-import io.trygvis.rules.dba.Cluster;
-import io.trygvis.rules.dba.Container;
-import io.trygvis.rules.machine.Machine;
-import io.trygvis.rules.dns.DnsEntry;
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 f046259..de617f7 100644
--- a/module/ri-wireguard/src/main/resources/META-INF/kmodule.xml
+++ b/module/ri-wireguard/src/main/resources/META-INF/kmodule.xml
@@ -4,6 +4,6 @@
xsi:schemaLocation="http://www.drools.org/xsd/kmodule https://www.drools.org/xsd/kmodule_7_1.xsd">
<kbase name="wireguard" packages="io.trygvis.rules.wireguard">
- <ksession name="wireguard"/>
+<!-- <ksession name="wireguard"/>-->
</kbase>
</kmodule>