Repository: EnMasseProject/enmasse
Pull request #2587 (2019-04-05 10:25:19)

Use correct module name


Patch:
diff --git a/api-model/src/main/java/io/enmasse/iot/model/v1/AddressConfig.java b/api-model/src/main/java/io/enmasse/iot/model/v1/AddressConfig.java
new file mode 100644
index 000000000..3af696f66
--- /dev/null
+++ b/api-model/src/main/java/io/enmasse/iot/model/v1/AddressConfig.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2019, EnMasse authors.
+ * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
+ */
+
+package io.enmasse.iot.model.v1;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+import io.fabric8.kubernetes.api.model.Doneable;
+import io.sundr.builder.annotations.Buildable;
+import io.sundr.builder.annotations.Inline;
+
+@Buildable(
+        editableEnabled = false,
+        generateBuilderPackage = false,
+        builderPackage = "io.fabric8.kubernetes.api.builder",
+        inline = @Inline(
+                type = Doneable.class,
+                prefix = "Doneable",
+                value = "done"))
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class AddressConfig {
+
+    private String plan;
+
+    public AddressConfig() {}
+
+    public AddressConfig(String plan) {
+        this.plan = plan;
+    }
+
+    public String getPlan() {
+        return plan;
+    }
+
+    public void setPlan(String plan) {
+        this.plan = plan;
+    }
+}
diff --git a/api-model/src/main/java/io/enmasse/iot/model/v1/AddressSpaceConfig.java b/api-model/src/main/java/io/enmasse/iot/model/v1/AddressSpaceConfig.java
new file mode 100644
index 000000000..c8c87f656
--- /dev/null
+++ b/api-model/src/main/java/io/enmasse/iot/model/v1/AddressSpaceConfig.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2019, EnMasse authors.
+ * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
+ */
+package io.enmasse.iot.model.v1;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+import io.fabric8.kubernetes.api.model.Doneable;
+import io.sundr.builder.annotations.Buildable;
+import io.sundr.builder.annotations.Inline;
+
+@Buildable(
+        editableEnabled = false,
+        generateBuilderPackage = false,
+        builderPackage = "io.fabric8.kubernetes.api.builder",
+        inline = @Inline(
+                type = Doneable.class,
+                prefix = "Doneable",
+                value = "done"))
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class AddressSpaceConfig {
+    private String name;
+    private String plan;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getPlan() {
+        return plan;
+    }
+
+    public void setPlan(String plan) {
+        this.plan = plan;
+    }
+
+
+}
diff --git a/api-model/src/main/java/io/enmasse/iot/model/v1/AddressesConfig.java b/api-model/src/main/java/io/enmasse/iot/model/v1/AddressesConfig.java
new file mode 100644
index 000000000..90ad1a2a9
--- /dev/null
+++ b/api-model/src/main/java/io/enmasse/iot/model/v1/AddressesConfig.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2019, EnMasse authors.
+ * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
+ */
+
+package io.enmasse.iot.model.v1;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+import io.fabric8.kubernetes.api.model.Doneable;
+import io.sundr.builder.annotations.Buildable;
+import io.sundr.builder.annotations.Inline;
+
+@Buildable(
+        editableEnabled = false,
+        generateBuilderPackage = false,
+        builderPackage = "io.fabric8.kubernetes.api.builder",
+        inline = @Inline(
+                type = Doneable.class,
+                prefix = "Doneable",
+                value = "done"))
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class AddressesConfig {
+
+    private AddressConfig command;
+    private AddressConfig event;
+    private AddressConfig telemetry;
+
+    public AddressConfig getCommand() {
+        return command;
+    }
+
+    public void setCommand(AddressConfig command) {
+        this.command = command;
+    }
+
+    public AddressConfig getEvent() {
+        return event;
+    }
+
+    public void setEvent(AddressConfig event) {
+        this.event = event;
+    }
+
+    public AddressConfig getTelemetry() {
+        return telemetry;
+    }
+
+    public void setTelemetry(AddressConfig telemetry) {
+        this.telemetry = telemetry;
+    }
+
+}
diff --git a/api-model/src/main/java/io/enmasse/iot/model/v1/IoTConfigList.java b/api-model/src/main/java/io/enmasse/iot/model/v1/IoTConfigList.java
new file mode 100644
index 000000000..818fd6eb1
--- /dev/null
+++ b/api-model/src/main/java/io/enmasse/iot/model/v1/IoTConfigList.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2019, EnMasse authors.
+ * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
+ */
+package io.enmasse.iot.model.v1;
+
+import io.enmasse.common.model.AbstractList;
+import io.enmasse.common.model.DefaultCustomResource;
+
+@DefaultCustomResource
+@SuppressWarnings("serial")
+public class IoTConfigList extends AbstractList<IoTConfig> {
+
+    public static final String KIND = "IoTConfigList";
+
+    public IoTConfigList() {
+        super(KIND, IoTCrd.API_VERSION);
+    }
+}
diff --git a/api-model/src/main/java/io/enmasse/iot/model/v1/IoTCrd.java b/api-model/src/main/java/io/enmasse/iot/model/v1/IoTCrd.java
index 4f4c50d2e..466f7d4ff 100644
--- a/api-model/src/main/java/io/enmasse/iot/model/v1/IoTCrd.java
+++ b/api-model/src/main/java/io/enmasse/iot/model/v1/IoTCrd.java
@@ -15,9 +15,11 @@ public class IoTCrd {
     public static final String API_VERSION = GROUP + "/" + VERSION;
 
     private static final CustomResourceDefinition PROJECT_CRD;
+    private static final CustomResourceDefinition CONFIG_CRD;
 
     static {
         PROJECT_CRD = CustomResources.createCustomResource(GROUP, VERSION, IoTProject.KIND);
+        CONFIG_CRD = CustomResources.createCustomResource(GROUP, VERSION, IoTConfig.KIND);
     }
 
     public static void registerCustomCrds() {
@@ -30,4 +32,8 @@ public class IoTCrd {
         return PROJECT_CRD;
     }
 
+    public static CustomResourceDefinition config() {
+        return CONFIG_CRD;
+    }
+
 }
diff --git a/api-model/src/main/java/io/enmasse/iot/model/v1/ManagedDownstreamStrategy.java b/api-model/src/main/java/io/enmasse/iot/model/v1/ManagedDownstreamStrategy.java
index d67bf9a75..393314619 100644
--- a/api-model/src/main/java/io/enmasse/iot/model/v1/ManagedDownstreamStrategy.java
+++ b/api-model/src/main/java/io/enmasse/iot/model/v1/ManagedDownstreamStrategy.java
@@ -6,7 +6,6 @@ package io.enmasse.iot.model.v1;
 
 import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
 
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import com.fasterxml.jackson.annotation.JsonInclude;
 
 import io.fabric8.kubernetes.api.model.Doneable;
@@ -20,21 +19,27 @@ import io.sundr.builder.annotations.Inline;
         inline = @Inline(
                 type = Doneable.class,
                 prefix = "Doneable",
-                value = "done"
-                )
-        )
-@JsonIgnoreProperties(ignoreUnknown = true)
+                value = "done"))
 @JsonInclude(NON_NULL)
 public class ManagedDownstreamStrategy {
 
-    private String addressSpaceName;
+    private AddressSpaceConfig addressSpace;
+    private AddressesConfig addresses;
 
-    public String getAddressSpaceName() {
-        return addressSpaceName;
+    public AddressSpaceConfig getAddressSpace() {
+        return addressSpace;
     }
 
-    public void setAddressSpaceName(String addressSpaceName) {
-        this.addressSpaceName = addressSpaceName;
+    public void setAddressSpace(AddressSpaceConfig addressSpace) {
+        this.addressSpace = addressSpace;
+    }
+
+    public AddressesConfig getAddresses() {
+        return addresses;
+    }
+
+    public void setAddresses(AddressesConfig addresses) {
+        this.addresses = addresses;
     }
 
 }
diff --git a/keycloak-plugin/src/main/sh/init-keycloak.sh b/keycloak-plugin/src/main/sh/init-keycloak.sh
index 69123eee1..937996a74 100755
--- a/keycloak-plugin/src/main/sh/init-keycloak.sh
+++ b/keycloak-plugin/src/main/sh/init-keycloak.sh
@@ -4,6 +4,7 @@ KEYCLOAK_CONFIG=${KEYCLOAK_DIR}/standalone/configuration/
 OPENSHIFT_CA=${OPENSHIFT_CA:-/var/run/secrets/kubernetes.io/serviceaccount/ca.crt}
 
 cp ${KEYCLOAK_PLUGIN_DIR}/configuration/* ${KEYCLOAK_CONFIG}/
+cp ${KEYCLOAK_PLUGIN_DIR}/configuration/${KEYCLOAK_CONFIG_FILE} ${KEYCLOAK_CONFIG}/standalone-openshift.xml
 cp ${KEYCLOAK_PLUGIN_DIR}/providers/* ${KEYCLOAK_DIR}/providers/
 
 KEYSTORE_PATH=${KEYCLOAK_DIR}/standalone/configuration/certificates.keystore
diff --git a/pkg/controller/authenticationservice/standard.go b/pkg/controller/authenticationservice/standard.go
index 2a12394f3..c87b851f1 100644
--- a/pkg/controller/authenticationservice/standard.go
+++ b/pkg/controller/authenticationservice/standard.go
@@ -104,6 +104,10 @@ func applyStandardAuthServiceDeployment(authservice *adminv1beta1.Authentication
 		install.ApplyVolumeMountSimple(container, "keycloak-providers", "/opt/jboss/keycloak/providers", false)
 		install.ApplyVolumeMountSimple(container, "keycloak-configuration", "/opt/jboss/keycloak/standalone/configuration", false)
 		install.ApplyVolumeMountSimple(container, "standard-authservice-cert", "/opt/enmasse/cert", false)
+		// Only allow setting data source on initial creation
+		if util.IsNewObject(deployment) {
+			install.ApplyEnvSimple(container, "KEYCLOAK_CONFIG_FILE", "standalone-"+string(authservice.Spec.Standard.Datasource.Type)+".xml")
+		}
 	})
 	install.ApplyContainer(deployment, "keycloak", func(container *corev1.Container) {
 		install.ApplyContainerImage(container, "keycloak", authservice.Spec.Standard.Image)
@@ -127,10 +131,7 @@ func applyStandardAuthServiceDeployment(authservice *adminv1beta1.Authentication
 			install.ApplyEnvSecret(container, "DB_PASSWORD", "database-password", authservice.Spec.Standard.Datasource.CredentialsSecret.Name)
 		}
 
-		// Only allow setting data source on initial creation
-		if util.IsNewObject(deployment) {
-			container.Args = []string{"start-keycloak.sh", "-b", "0.0.0.0", "-c", "standalone-" + string(authservice.Spec.Standard.Datasource.Type) + ".xml"}
-		}
+		container.Args = []string{"start-keycloak.sh", "-b", "0.0.0.0", "-c", "standalone-openshift.xml"}
 
 		container.Ports = []corev1.ContainerPort{{
 			ContainerPort: 5671,
diff --git a/templates/Makefile b/templates/Makefile
index 6f89effaf..17f3f53fa 100644
--- a/templates/Makefile
+++ b/templates/Makefile
@@ -101,7 +101,7 @@ $(ENMASSE_BUNDLE): replace_images
 MONITORING_BUNDLE=$(PACKAGE_INSTALL_DIR)/bundles/monitoring
 $(MONITORING_BUNDLE): replace_images
 	mkdir -p $(MONITORING_BUNDLE)
-	for i in alertmanager grafana kube-state-metrics prometheus service-monitor prometheus-rules; do \
+	for i in alertmanager grafana kube-state-metrics prometheus service-monitors prometheus-rules; do \
 		cp $(BUILDDIR)/replaced/$$i/*.yaml $(MONITORING_BUNDLE)/; \
 	done
 


Test patch:
diff --git a/api-model/src/test/java/io/enmasse/iot/model/v1/IoTProjectTest.java b/api-model/src/test/java/io/enmasse/iot/model/v1/IoTProjectTest.java
index 9a3138b2b..6e20754be 100644
--- a/api-model/src/test/java/io/enmasse/iot/model/v1/IoTProjectTest.java
+++ b/api-model/src/test/java/io/enmasse/iot/model/v1/IoTProjectTest.java
@@ -60,14 +60,16 @@ public class IoTProjectTest {
                 .withNewSpec()
                 .withNewDownstreamStrategy()
                 .withNewManagedStrategy()
-                .withAddressSpaceName("managed")
+                .withNewAddressSpace()
+                .withName("managed")
+                .endAddressSpace()
                 .endManagedStrategy()
                 .endDownstreamStrategy()
                 .endSpec()
                 .build();
 
         assertEquals("proj", project.getMetadata().getName());
-        assertEquals("managed", project.getSpec().getDownstreamStrategy().getManagedStrategy().getAddressSpaceName());
+        assertEquals("managed", project.getSpec().getDownstreamStrategy().getManagedStrategy().getAddressSpace().getName());
         assertNull(project.getSpec().getDownstreamStrategy().getExternalStrategy());
     }