diff --git a/core/src/main/java/io/javaoperatorsdk/webhook/admission/AdmissionUtils.java b/core/src/main/java/io/javaoperatorsdk/webhook/admission/AdmissionUtils.java index 5ae7cb1f..cdf044fb 100644 --- a/core/src/main/java/io/javaoperatorsdk/webhook/admission/AdmissionUtils.java +++ b/core/src/main/java/io/javaoperatorsdk/webhook/admission/AdmissionUtils.java @@ -33,8 +33,8 @@ public static AdmissionResponse notAllowedExceptionToAdmissionResponse( public static KubernetesResource getTargetResource(AdmissionRequest admissionRequest, Operation operation) { - return operation == Operation.DELETE ? admissionRequest.getOldObject() - : admissionRequest.getObject(); + return (KubernetesResource) (operation == Operation.DELETE ? admissionRequest.getOldObject() + : admissionRequest.getObject()); } public static AdmissionResponse admissionResponseFromMutation(KubernetesResource originalResource, diff --git a/pom.xml b/pom.xml index 588a73de..02b5e9f7 100644 --- a/pom.xml +++ b/pom.xml @@ -51,7 +51,7 @@ https://sonarcloud.io 5.10.2 - 6.13.4 + 7.1.0 1.7.36 2.24.3 5.14.2 @@ -73,7 +73,7 @@ 3.2.7 3.3.1 2.43.0 - 3.4.1 + 3.4.2 diff --git a/samples/commons/pom.xml b/samples/commons/pom.xml index edaf133e..fd8d3eb0 100644 --- a/samples/commons/pom.xml +++ b/samples/commons/pom.xml @@ -47,7 +47,6 @@ org.junit.jupiter junit-jupiter-api - test diff --git a/samples/quarkus/pom.xml b/samples/quarkus/pom.xml index 4ec07e21..ad81f97e 100644 --- a/samples/quarkus/pom.xml +++ b/samples/quarkus/pom.xml @@ -15,7 +15,7 @@ UTF-8 quarkus-bom io.quarkus.platform - 3.11.0 + 3.18.1 true 3.5.2 @@ -43,6 +43,14 @@ io.quarkus quarkus-arc + + io.quarkus + quarkus-rest + + + io.quarkus + quarkus-rest-jackson + io.quarkus quarkus-junit5 @@ -53,15 +61,10 @@ quarkus-certmanager 1.0.3 - - io.quarkus - quarkus-resteasy-reactive-jackson - io.quarkus quarkus-minikube - io.quarkus quarkus-container-image-jib @@ -71,7 +74,6 @@ rest-assured test - org.assertj assertj-core diff --git a/samples/spring-boot/k8s/kubernetes.yml b/samples/spring-boot/k8s/kubernetes.yml new file mode 100644 index 00000000..75654b39 --- /dev/null +++ b/samples/spring-boot/k8s/kubernetes.yml @@ -0,0 +1,131 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + app.dekorate.io/vcs-url: <> + labels: + app.kubernetes.io/name: spring-boot-sample + app.kubernetes.io/version: 1.1.7-SNAPSHOT + name: spring-boot-sample +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/name: spring-boot-sample + app.kubernetes.io/version: 1.1.7-SNAPSHOT + template: + metadata: + annotations: + app.dekorate.io/vcs-url: <> + labels: + app.kubernetes.io/name: spring-boot-sample + app.kubernetes.io/version: 1.1.7-SNAPSHOT + spec: + containers: + - env: + - name: KUBERNETES_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: SERVER_SSL_KEY_STORE + value: /etc/certs/keystore.p12 + - name: SERVER_SSL_KEY_STORE_PASSWORD + valueFrom: + secretKeyRef: + key: password + name: pkcs12-pass + image: test/spring-boot-sample:1.1.7-SNAPSHOT + imagePullPolicy: IfNotPresent + name: spring-boot-sample + ports: + - containerPort: 443 + name: http + protocol: TCP + volumeMounts: + - mountPath: /etc/certs + name: volume-certs + readOnly: true + volumes: + - name: volume-certs + secret: + optional: false + secretName: tls-secret +--- +apiVersion: v1 +kind: Secret +metadata: + name: pkcs12-pass +data: + password: c3VwZXJzZWNyZXQ= +type: Opaque +--- +apiVersion: cert-manager.io/v1 +kind: Issuer +metadata: + annotations: + app.dekorate.io/vcs-url: <> + labels: + app.kubernetes.io/name: spring-boot-sample + app.kubernetes.io/version: 1.1.7-SNAPSHOT + name: spring-boot-sample +spec: + selfSigned: {} +--- +apiVersion: v1 +kind: Service +metadata: + annotations: + app.dekorate.io/vcs-url: <> + labels: + app.kubernetes.io/name: spring-boot-sample + app.kubernetes.io/version: 1.1.7-SNAPSHOT + name: spring-boot-sample +spec: + ports: + - name: http + port: 443 + protocol: TCP + targetPort: 443 + selector: + app.kubernetes.io/name: spring-boot-sample + app.kubernetes.io/version: 1.1.7-SNAPSHOT + type: ClusterIP +--- +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + annotations: + app.dekorate.io/vcs-url: <> + labels: + app.kubernetes.io/name: spring-boot-sample + app.kubernetes.io/version: 1.1.7-SNAPSHOT + name: spring-boot-sample +spec: + dnsNames: + - spring-boot-sample.default.svc + - localhost + duration: 7776000000000000ns + encodeUsagesInRequest: false + isCA: false + issuerRef: + name: spring-boot-sample + keystores: + pkcs12: + create: true + passwordSecretRef: + key: password + name: pkcs12-pass + privateKey: + algorithm: RSA + encoding: PKCS8 + size: 2048 + renewBefore: 1296000000000000ns + secretName: tls-secret + subject: + organizations: + - Dekorate + - Community + usages: + - server auth + - client auth diff --git a/samples/spring-boot/pom.xml b/samples/spring-boot/pom.xml index 2762ac96..b634159e 100644 --- a/samples/spring-boot/pom.xml +++ b/samples/spring-boot/pom.xml @@ -12,7 +12,6 @@ Kubernetes Webhooks Framework - Samples - Spring Boot - 17 3.4.4 4.1.4 @@ -80,26 +79,6 @@ test-jar test - - io.dekorate - kubernetes-spring-starter - ${dekorate.version} - - - io.dekorate - certmanager-annotations - ${dekorate.version} - - - io.dekorate - kubernetes-annotations - ${dekorate.version} - - - io.dekorate - jib-annotations - ${dekorate.version} - @@ -109,6 +88,9 @@ jib-maven-plugin ${jib-maven-plugin.version} + + eclipse-temurin:17-jre + test/spring-boot-sample:${project.version} diff --git a/samples/spring-boot/src/test/java/io/javaoperatorsdk/webhook/sample/springboot/SpringBootWebhooksE2E.java b/samples/spring-boot/src/test/java/io/javaoperatorsdk/webhook/sample/springboot/SpringBootWebhooksE2E.java index ad944a3d..44e5b9e1 100644 --- a/samples/spring-boot/src/test/java/io/javaoperatorsdk/webhook/sample/springboot/SpringBootWebhooksE2E.java +++ b/samples/spring-boot/src/test/java/io/javaoperatorsdk/webhook/sample/springboot/SpringBootWebhooksE2E.java @@ -5,6 +5,7 @@ import org.junit.jupiter.api.BeforeAll; +import io.fabric8.kubernetes.client.ConfigBuilder; import io.fabric8.kubernetes.client.KubernetesClientBuilder; import io.javaoperatorsdk.webhook.sample.AbstractEndToEndTest; @@ -15,12 +16,14 @@ class SpringBootWebhooksE2E extends AbstractEndToEndTest { @BeforeAll static void deployService() throws IOException { - try (var client = new KubernetesClientBuilder().build(); + try (var client = new KubernetesClientBuilder().withConfig(new ConfigBuilder() + .withNamespace("default") + .build()).build(); var certManager = new URL( "https://github.com/cert-manager/cert-manager/releases/download/v1.10.1/cert-manager.yaml") .openStream()) { applyAndWait(client, certManager); - applyAndWait(client, "target/classes/META-INF/dekorate/kubernetes.yml"); + applyAndWait(client, "k8s/kubernetes.yml"); applyAndWait(client, "k8s/validating-webhook-configuration.yml"); applyAndWait(client, "k8s/mutating-webhook-configuration.yml"); applyAndWait(client,