diff --git a/operator/patch-sources.sh b/operator/patch-sources.sh deleted file mode 100755 index df13f322a3..0000000000 --- a/operator/patch-sources.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env bash - -sedCommand="sed" -if [ "$(uname)" == "Darwin" ]; then - if hash gsed 2>/dev/null; then - sedCommand="gsed" - fi -fi - -function addAnnotation() { - local match=$1 - local annotation=$2 - local file=$3 - - $sedCommand -i "/^.*${match}.*/i ${annotation}" ${file} -} - -addAnnotation \ - "protected List subGroups;" \ - "@io.fabric8.crd.generator.annotation.SchemaFrom(type = org.keycloak.representations.overrides.NoSubGroupsGroupRepresentationList.class)" \ - target/keycloak-core/org/keycloak/representations/idm/GroupRepresentation.java - -addAnnotation \ - "private MultivaluedHashMap components;" \ - "@io.fabric8.crd.generator.annotation.SchemaFrom(type = org.keycloak.representations.overrides.ComponentExportRepresentationMap.class)" \ - target/keycloak-core/org/keycloak/representations/idm/RealmRepresentation.java - -addAnnotation \ - "private MultivaluedHashMap config;" \ - "@io.fabric8.crd.generator.annotation.SchemaFrom(type = org.keycloak.representations.overrides.MultivaluedStringStringHashMap.class)" \ - target/keycloak-core/org/keycloak/representations/idm/CredentialRepresentation.java - -addAnnotation \ - "private MultivaluedHashMap config;" \ - "@io.fabric8.crd.generator.annotation.SchemaFrom(type = org.keycloak.representations.overrides.MultivaluedStringStringHashMap.class)" \ - target/keycloak-core/org/keycloak/representations/idm/ComponentRepresentation.java - -addAnnotation \ - "private MultivaluedHashMap subComponents = new MultivaluedHashMap<>();" \ - "@io.fabric8.crd.generator.annotation.SchemaFrom(type = org.keycloak.representations.overrides.NoSubcomponentsComponentExportRepresentationMap.class)" \ - target/keycloak-core/org/keycloak/representations/idm/ComponentExportRepresentation.java - -addAnnotation \ - "private MultivaluedHashMap config = new MultivaluedHashMap<>();" \ - "@io.fabric8.crd.generator.annotation.SchemaFrom(type = org.keycloak.representations.overrides.MultivaluedStringStringHashMap.class)" \ - target/keycloak-core/org/keycloak/representations/idm/ComponentExportRepresentation.java - -addAnnotation \ - "private List policies;" \ - "@com.fasterxml.jackson.annotation.JsonIgnore" \ - target/keycloak-core/org/keycloak/representations/idm/authorization/ScopeRepresentation.java - -addAnnotation \ - "private List resources;" \ - "@com.fasterxml.jackson.annotation.JsonIgnore" \ - target/keycloak-core/org/keycloak/representations/idm/authorization/ScopeRepresentation.java diff --git a/operator/pom.xml b/operator/pom.xml index c16e39c7f2..2ec336a7a5 100644 --- a/operator/pom.xml +++ b/operator/pom.xml @@ -103,7 +103,7 @@ org.keycloak - keycloak-common + keycloak-core @@ -192,22 +192,6 @@ - - import-keycloak-core - validate - - copy-resources - - - ${basedir}/target/keycloak-core - - - ${basedir}/../core/src/main/java - true - - - - copy-ubi-null validate @@ -241,7 +225,6 @@ - ${basedir}/target/keycloak-core ${basedir}/target/generated-sources/java @@ -249,23 +232,6 @@ - - exec-maven-plugin - org.codehaus.mojo - 1.6.0 - - - patch-core-sources - generate-sources - - exec - - - ${basedir}/patch-sources.sh - - - - maven-surefire-plugin @@ -288,6 +254,27 @@ + + + maven-antrun-plugin + + + filterEnum + package + + + + + + + run + + + + org.apache.maven.plugins diff --git a/operator/src/main/java/org/keycloak/operator/crds/v2alpha1/realmimport/KeycloakRealmImport.java b/operator/src/main/java/org/keycloak/operator/crds/v2alpha1/realmimport/KeycloakRealmImport.java index ca9e49680f..d951ac7ea1 100644 --- a/operator/src/main/java/org/keycloak/operator/crds/v2alpha1/realmimport/KeycloakRealmImport.java +++ b/operator/src/main/java/org/keycloak/operator/crds/v2alpha1/realmimport/KeycloakRealmImport.java @@ -16,13 +16,20 @@ */ package org.keycloak.operator.crds.v2alpha1.realmimport; +import io.fabric8.crd.generator.annotation.SchemaSwap; import io.fabric8.kubernetes.api.model.Namespaced; import io.fabric8.kubernetes.client.CustomResource; import io.fabric8.kubernetes.model.annotation.Group; import io.fabric8.kubernetes.model.annotation.Version; import io.sundr.builder.annotations.Buildable; import io.sundr.builder.annotations.BuildableReference; + import org.keycloak.operator.Constants; +import org.keycloak.representations.idm.ComponentExportRepresentation; +import org.keycloak.representations.idm.CredentialRepresentation; +import org.keycloak.representations.idm.GroupRepresentation; +import org.keycloak.representations.idm.RealmRepresentation; +import org.keycloak.representations.idm.authorization.ScopeRepresentation; @Group(Constants.CRDS_GROUP) @Version(Constants.CRDS_VERSION) @@ -32,6 +39,13 @@ import org.keycloak.operator.Constants; @BuildableReference(io.fabric8.kubernetes.client.CustomResource.class), @BuildableReference(KeycloakRealmImportSpec.class) }) +@SchemaSwap(originalType = GroupRepresentation.class, fieldName = "subGroups", targetType = org.keycloak.representations.overrides.NoSubGroupsGroupRepresentationList.class) +@SchemaSwap(originalType = RealmRepresentation.class, fieldName = "components", targetType = org.keycloak.representations.overrides.ComponentExportRepresentationMap.class) +@SchemaSwap(originalType = CredentialRepresentation.class, fieldName = "config", targetType = org.keycloak.representations.overrides.MultivaluedStringStringHashMap.class) +@SchemaSwap(originalType = ComponentExportRepresentation.class, fieldName = "subComponents", targetType = org.keycloak.representations.overrides.NoSubcomponentsComponentExportRepresentationMap.class) +@SchemaSwap(originalType = ComponentExportRepresentation.class, fieldName = "config", targetType = org.keycloak.representations.overrides.MultivaluedStringStringHashMap.class) +@SchemaSwap(originalType = ScopeRepresentation.class, fieldName = "policies") +@SchemaSwap(originalType = ScopeRepresentation.class, fieldName = "resources") public class KeycloakRealmImport extends CustomResource implements Namespaced { }