Upgrade Operator SDK to 6.0.0.CR1

---
Quarkus3 branch sync no. 14 (24.4.2023)
Resolved conflicts:
keycloak/operator/pom.xml - Modified
This commit is contained in:
Václav Muzikář 2023-04-04 13:04:15 +02:00 committed by Václav Muzikář
parent 30ea43f06f
commit dd6e73ec7c
11 changed files with 92 additions and 19 deletions

View file

@ -21,9 +21,8 @@
See https://github.com/quarkusio/quarkus/blob/<versionTag>/bom/application/pom.xml
for reference
-->
<resteasy.version>4.7.7.Final</resteasy.version>
<kubernetes-client.version>6.5.1</kubernetes-client.version>
<wildfly.common.version>1.5.4.Final-format-001</wildfly.common.version>
<kubernetes-client.version>5.12.4</kubernetes-client.version>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<maven.compiler.parameters>true</maven.compiler.parameters>
@ -32,8 +31,8 @@
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.operator.sdk.version>4.0.7</quarkus.operator.sdk.version>
<quarkus.version>2.13.7.Final</quarkus.version>
<quarkus.operator.sdk.version>6.0.0.CR1</quarkus.operator.sdk.version>
<quarkus.version>3.0.0.CR1</quarkus.version>
<quarkus.container-image.group>keycloak</quarkus.container-image.group>
</properties>
@ -96,6 +95,12 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-container-image-docker</artifactId>
</dependency>
<!-- FIXME: We should not need OKHttp Client, see HttpClientFactory class -->
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-httpclient-okhttp</artifactId>
<version>${kubernetes-client.version}</version>
</dependency>
<!-- Keycloak -->
<dependency>

View file

@ -0,0 +1,42 @@
/*
* Copyright 2023 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.keycloak.kubernetes.client;
import io.fabric8.kubernetes.client.okhttp.OkHttpClientFactory;
/**
* FIXME: This Factory is meant to force Fabric8 to use OKHttp Client. We should not normally do that as it is not aligned with Quarkus.
* Remove once the following are resolved:
* https://github.com/fabric8io/kubernetes-client/issues/5036
* https://github.com/fabric8io/kubernetes-client/issues/5033 (only needed by tests)
*
* Tracked by: https://github.com/keycloak/keycloak/issues/19573
*
* @author Vaclav Muzikar <vmuzikar@redhat.com>
*/
public class HttpClientFactory extends OkHttpClientFactory {
@Override
public boolean isDefault() {
return false;
}
@Override
public int priority() {
return 10000;
}
}

View file

@ -40,7 +40,7 @@ import org.keycloak.operator.crds.v2alpha1.deployment.KeycloakStatus;
import org.keycloak.operator.crds.v2alpha1.deployment.KeycloakStatusBuilder;
import org.keycloak.operator.crds.v2alpha1.deployment.KeycloakStatusCondition;
import javax.inject.Inject;
import jakarta.inject.Inject;
import java.util.Map;
import java.util.concurrent.TimeUnit;

View file

@ -38,7 +38,7 @@ import org.keycloak.operator.crds.v2alpha1.realmimport.KeycloakRealmImportStatus
import org.keycloak.operator.crds.v2alpha1.realmimport.KeycloakRealmImportStatusBuilder;
import org.keycloak.operator.crds.v2alpha1.realmimport.KeycloakRealmImportStatusCondition;
import javax.inject.Inject;
import jakarta.inject.Inject;
import java.util.Map;
import java.util.concurrent.TimeUnit;

View file

@ -19,7 +19,7 @@ package org.keycloak.operator.crds.v2alpha1.realmimport;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import org.keycloak.representations.idm.RealmRepresentation;
import javax.validation.constraints.NotNull;
import jakarta.validation.constraints.NotNull;
public class KeycloakRealmImportSpec {

View file

@ -0,0 +1,18 @@
#
# Copyright 2023 Red Hat, Inc. and/or its affiliates
# and other contributors as indicated by the @author tags.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
org.keycloak.kubernetes.client.HttpClientFactory

View file

@ -25,10 +25,13 @@ import io.fabric8.kubernetes.client.ConfigBuilder;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.javaoperatorsdk.operator.Operator;
import io.javaoperatorsdk.operator.api.config.ConfigurationServiceProvider;
import io.javaoperatorsdk.operator.api.reconciler.Reconciler;
import io.quarkiverse.operatorsdk.runtime.OperatorProducer;
import io.quarkiverse.operatorsdk.runtime.QuarkusConfigurationService;
import io.quarkus.logging.Log;
import jakarta.enterprise.inject.Instance;
import jakarta.enterprise.inject.spi.CDI;
import jakarta.enterprise.util.TypeLiteral;
import org.awaitility.Awaitility;
import org.eclipse.microprofile.config.ConfigProvider;
import org.junit.jupiter.api.AfterAll;
@ -39,9 +42,6 @@ import org.junit.jupiter.api.TestInfo;
import org.keycloak.operator.Constants;
import org.keycloak.operator.crds.v2alpha1.deployment.Keycloak;
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.spi.CDI;
import javax.enterprise.util.TypeLiteral;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@ -147,12 +147,13 @@ public abstract class BaseOperatorTest {
for (Reconciler<?> reconciler : reconcilers) {
Log.info("Register and apply : " + reconciler.getClass().getName());
OperatorProducer.applyCRDAndRegister(operator, reconciler, configuration);
operator.register(reconciler);
}
}
private static void createOperator() {
configuration.getClientConfiguration().setNamespace(namespace);
ConfigurationServiceProvider.reset();
operator = new Operator(k8sclient, configuration);
}
@ -254,7 +255,11 @@ public abstract class BaseOperatorTest {
}
Log.info("Deleting namespace : " + namespace);
assertThat(k8sclient.namespaces().withName(namespace).delete()).isTrue();
assertThat(k8sclient.namespaces().withName(namespace).delete()).isNotNull();
k8sclient.close();
}
public static String getCurrentNamespace() {
return namespace;
}
}

View file

@ -193,7 +193,7 @@ public class KeycloakDeploymentTest extends BaseOperatorTest {
deployKeycloak(k8sclient, kc, true);
Log.info("Trying to delete deployment");
assertThat(k8sclient.apps().statefulSets().withName(deploymentName).delete()).isTrue();
assertThat(k8sclient.apps().statefulSets().withName(deploymentName).delete()).isNotNull();
Awaitility.await()
.untilAsserted(() -> assertThat(k8sclient.apps().statefulSets().withName(deploymentName).get()).isNotNull());

View file

@ -157,7 +157,7 @@ public class KeycloakIngressTest extends BaseOperatorTest {
.withName(ingress.getName());
Log.info("Trying to delete the ingress");
assertThat(ingressSelector.delete()).isTrue();
assertThat(ingressSelector.delete()).isNotNull();
Awaitility.await()
.untilAsserted(() -> assertThat(ingressSelector.get()).isNotNull());
@ -234,7 +234,7 @@ public class KeycloakIngressTest extends BaseOperatorTest {
} finally {
Log.info("Destroying the Custom Ingress created manually to avoid errors in others Tests methods");
if (customIngressDeployedManuallySelector != null && customIngressDeployedManuallySelector.isReady()) {
assertThat(customIngressDeployedManuallySelector.delete()).isTrue();
assertThat(customIngressDeployedManuallySelector.delete()).isNotNull();
Awaitility.await().untilAsserted(() -> {
assertThat(k8sclient.network().v1().ingresses().inNamespace(namespace).list().getItems().size()).isEqualTo(0);
});

View file

@ -40,7 +40,7 @@ public class KeycloakServicesTest extends BaseOperatorTest {
var serviceSelector = k8sclient.services().inNamespace(namespace).withName(service.getName());
Log.info("Trying to delete the service");
assertThat(serviceSelector.delete()).isTrue();
assertThat(serviceSelector.delete()).isNotNull();
Awaitility.await()
.untilAsserted(() -> assertThat(serviceSelector.get()).isNotNull());
@ -79,7 +79,7 @@ public class KeycloakServicesTest extends BaseOperatorTest {
var discoveryServiceSelector = k8sclient.services().inNamespace(namespace).withName(discoveryService.getName());
Log.info("Trying to delete the discovery service");
assertThat(discoveryServiceSelector.delete()).isTrue();
assertThat(discoveryServiceSelector.delete()).isNotNull();
Awaitility.await()
.untilAsserted(() -> assertThat(discoveryServiceSelector.get()).isNotNull());

View file

@ -29,6 +29,7 @@ import io.quarkus.logging.Log;
import org.awaitility.Awaitility;
import org.keycloak.operator.crds.v2alpha1.deployment.Keycloak;
import org.keycloak.operator.crds.v2alpha1.deployment.KeycloakStatusCondition;
import org.keycloak.operator.testsuite.integration.BaseOperatorTest;
import java.util.Objects;
import java.util.UUID;
@ -43,7 +44,9 @@ public final class K8sUtils {
}
public static Keycloak getDefaultKeycloakDeployment() {
return getResourceFromFile("example-keycloak.yaml", Keycloak.class);
Keycloak kc = getResourceFromFile("example-keycloak.yaml", Keycloak.class);
kc.getMetadata().setNamespace(BaseOperatorTest.getCurrentNamespace());
return kc;
}
public static Secret getDefaultTlsSecret() {