From b42a1a489250f1f069bd75a63f15e0fc0b136239 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Wed, 5 Jul 2023 10:49:17 +0200 Subject: [PATCH 01/65] fix: proper plugin management configuration Signed-off-by: Marc Nuri --- gradle-plugin/doc/pom.xml | 2 +- gradle-plugin/kubernetes/pom.xml | 1 - gradle-plugin/openshift/pom.xml | 1 - gradle-plugin/pom.xml | 15 --- .../docker/helper/VolumeBindingUtil.java | 5 +- jkube-kit/parent/pom.xml | 5 - kubernetes-maven-plugin/doc/pom.xml | 2 +- kubernetes-maven-plugin/plugin/pom.xml | 2 +- kubernetes-maven-plugin/pom.xml | 14 --- openshift-maven-plugin/plugin/pom.xml | 2 +- openshift-maven-plugin/pom.xml | 4 - pom.xml | 113 ++++++++++-------- 12 files changed, 68 insertions(+), 98 deletions(-) diff --git a/gradle-plugin/doc/pom.xml b/gradle-plugin/doc/pom.xml index 6300cf6637..52f57daac1 100644 --- a/gradle-plugin/doc/pom.xml +++ b/gradle-plugin/doc/pom.xml @@ -55,8 +55,8 @@ + org.apache.maven.plugins maven-resources-plugin - ${version.maven-resources-plugin} copy-asciidoc diff --git a/gradle-plugin/kubernetes/pom.xml b/gradle-plugin/kubernetes/pom.xml index 4ce3ba2128..2a0fd6cbf7 100644 --- a/gradle-plugin/kubernetes/pom.xml +++ b/gradle-plugin/kubernetes/pom.xml @@ -258,7 +258,6 @@ org.apache.maven.plugins maven-surefire-plugin - ${version.maven-surefire-plugin} diff --git a/gradle-plugin/openshift/pom.xml b/gradle-plugin/openshift/pom.xml index 8cbb4663cf..b4d5f38c5d 100644 --- a/gradle-plugin/openshift/pom.xml +++ b/gradle-plugin/openshift/pom.xml @@ -162,7 +162,6 @@ org.apache.maven.plugins maven-surefire-plugin - ${version.maven-surefire-plugin} diff --git a/gradle-plugin/pom.xml b/gradle-plugin/pom.xml index ec66de7a6c..7e538f3fca 100644 --- a/gradle-plugin/pom.xml +++ b/gradle-plugin/pom.xml @@ -155,21 +155,6 @@ true - - org.apache.maven.plugins - maven-failsafe-plugin - ${version.maven-failsafe-plugin} - - - org.apache.maven.plugins - maven-enforcer-plugin - ${version.maven-enforcer-plugin} - - - org.apache.maven.plugins - maven-source-plugin - ${version.maven-source-plugin} - diff --git a/jkube-kit/build/service/docker/src/main/java/org/eclipse/jkube/kit/build/service/docker/helper/VolumeBindingUtil.java b/jkube-kit/build/service/docker/src/main/java/org/eclipse/jkube/kit/build/service/docker/helper/VolumeBindingUtil.java index 07ae040286..ffc33cde60 100644 --- a/jkube-kit/build/service/docker/src/main/java/org/eclipse/jkube/kit/build/service/docker/helper/VolumeBindingUtil.java +++ b/jkube-kit/build/service/docker/src/main/java/org/eclipse/jkube/kit/build/service/docker/helper/VolumeBindingUtil.java @@ -100,7 +100,8 @@ private VolumeBindingUtil() { } * Resolves relative paths in the supplied {@code bindingString}, and returns a binding string that has relative * paths replaced with absolute paths. If the supplied {@code bindingString} does not contain a relative path, it * is returned unmodified. - *

Discussion:

+ * + *
Discussion: *

* Volumes may be defined inside of {@code service} blocks * as documented here: @@ -131,7 +132,7 @@ private VolumeBindingUtil() { } *

* Volume strings that do not begin with a {@code ./}, {@code ../}, or {@code ~} are returned as-is. *

- *

Examples:

+ *
Examples: *

* Given {@code baseDir} equal to "/path/to/basedir" and a {@code bindingString} string equal to * "./reldir:/some/other/dir", this method returns {@code /path/to/basedir/reldir:/some/other/dir} diff --git a/jkube-kit/parent/pom.xml b/jkube-kit/parent/pom.xml index 085c5c61c6..c0689938b0 100644 --- a/jkube-kit/parent/pom.xml +++ b/jkube-kit/parent/pom.xml @@ -49,7 +49,6 @@ 5.12.0.202106070339-r 0.38.20 3.0.2 - 1.18.28 3.6.0 3.6.3 3.3.1 @@ -851,13 +850,11 @@ org.apache.maven.plugins maven-enforcer-plugin - ${version.maven-enforcer-plugin} org.apache.maven.plugins maven-failsafe-plugin - ${version.maven-failsafe-plugin} @@ -871,7 +868,6 @@ org.apache.maven.plugins maven-surefire-plugin - ${version.maven-surefire-plugin} -javaagent:"${settings.localRepository}/org/jmockit/jmockit/${version.jmockit}/jmockit-${version.jmockit}.jar" @@ -892,7 +888,6 @@ org.asciidoctor asciidoctor-maven-plugin - ${version.asciidoctor-maven-plugin} org.asciidoctor diff --git a/kubernetes-maven-plugin/doc/pom.xml b/kubernetes-maven-plugin/doc/pom.xml index 84cb94df86..7ba8430ce1 100644 --- a/kubernetes-maven-plugin/doc/pom.xml +++ b/kubernetes-maven-plugin/doc/pom.xml @@ -55,8 +55,8 @@ + org.apache.maven.plugins maven-resources-plugin - ${version.maven-resources-plugin} copy-asciidoc diff --git a/kubernetes-maven-plugin/plugin/pom.xml b/kubernetes-maven-plugin/plugin/pom.xml index e793a003d9..8be04547b2 100644 --- a/kubernetes-maven-plugin/plugin/pom.xml +++ b/kubernetes-maven-plugin/plugin/pom.xml @@ -192,8 +192,8 @@ + org.apache.maven.plugins maven-resources-plugin - ${version.maven-resources-plugin} copy-plexus-resources diff --git a/kubernetes-maven-plugin/pom.xml b/kubernetes-maven-plugin/pom.xml index 4671e1f4d8..efe5c16dde 100644 --- a/kubernetes-maven-plugin/pom.xml +++ b/kubernetes-maven-plugin/pom.xml @@ -72,13 +72,11 @@ org.apache.maven.plugins maven-failsafe-plugin - ${version.maven-failsafe-plugin} org.apache.maven.plugins maven-surefire-plugin - ${version.maven-surefire-plugin} -javaagent:"${settings.localRepository}/org/jmockit/jmockit/${version.jmockit}/jmockit-${version.jmockit}.jar" @@ -98,18 +96,6 @@ maven-invoker-plugin ${version.maven-invoker-plugin} - - - org.apache.maven.plugins - maven-enforcer-plugin - ${version.maven-enforcer-plugin} - - - - org.apache.maven.plugins - maven-source-plugin - ${version.maven-source-plugin} - diff --git a/openshift-maven-plugin/plugin/pom.xml b/openshift-maven-plugin/plugin/pom.xml index 90af01205c..bb82af5ea1 100644 --- a/openshift-maven-plugin/plugin/pom.xml +++ b/openshift-maven-plugin/plugin/pom.xml @@ -82,8 +82,8 @@ + org.apache.maven.plugins maven-resources-plugin - ${version.maven-resources-plugin} copy-plexus-resources diff --git a/openshift-maven-plugin/pom.xml b/openshift-maven-plugin/pom.xml index 4c044398b9..9577a775e3 100644 --- a/openshift-maven-plugin/pom.xml +++ b/openshift-maven-plugin/pom.xml @@ -71,13 +71,11 @@ org.apache.maven.plugins maven-failsafe-plugin - ${version.maven-failsafe-plugin} org.apache.maven.plugins maven-surefire-plugin - ${version.maven-surefire-plugin} -javaagent:"${settings.localRepository}/org/jmockit/jmockit/${version.jmockit}/jmockit-${version.jmockit}.jar" @@ -101,13 +99,11 @@ org.apache.maven.plugins maven-enforcer-plugin - ${version.maven-enforcer-plugin} org.apache.maven.plugins maven-source-plugin - ${version.maven-source-plugin} diff --git a/pom.xml b/pom.xml index 164731c084..12b0c8d01e 100644 --- a/pom.xml +++ b/pom.xml @@ -97,6 +97,7 @@ 5.9.2 6.7.2 4.2 + 1.18.28 1.18.20.0 3.11.0 3.3.0 @@ -109,10 +110,11 @@ 3.0.1 3.3.1 3.2.1 - 3.0.0-M5 + 3.1.2 4.6.1 2.1.1 1.7.36 + 3.9.1.2184 2.9.2 2023-06-16T07:02:10Z ${project.build.directory}/generated-docs @@ -175,21 +177,6 @@ - - org.apache.maven.plugins - maven-jar-plugin - ${version.maven-jar-plugin} - - - org.apache.maven.plugins - maven-javadoc-plugin - ${version.maven-javadoc-plugin} - - - org.apache.maven.plugins - maven-release-plugin - ${version.maven-release-plugin} - org.apache.maven.plugins maven-plugin-plugin @@ -210,10 +197,62 @@ + + org.apache.maven.plugins + maven-enforcer-plugin + ${version.maven-enforcer-plugin} + + + org.apache.maven.plugins + maven-failsafe-plugin + ${version.maven-failsafe-plugin} + + + org.apache.maven.plugins + maven-gpg-plugin + ${version.maven-gpg-plugin} + + + org.apache.maven.plugins + maven-jar-plugin + ${version.maven-jar-plugin} + + + org.apache.maven.plugins + maven-javadoc-plugin + ${version.maven-javadoc-plugin} + + + org.apache.maven.plugins + maven-release-plugin + ${version.maven-release-plugin} + + + org.apache.maven.plugins + maven-resources-plugin + ${version.maven-resources-plugin} + + + org.apache.maven.plugins + maven-source-plugin + ${version.maven-source-plugin} + + + org.apache.maven.plugins + maven-surefire-plugin + ${version.maven-surefire-plugin} + org.projectlombok lombok-maven-plugin ${version.lombok-maven-plugin} + + + org.projectlombok + lombok + ${version.lombok} + + org.asciidoctor @@ -233,7 +272,6 @@ left false - coderay html5 @@ -279,13 +317,17 @@ + + org.sonarsource.scanner.maven + sonar-maven-plugin + ${version.sonar-maven-plugin} + org.apache.maven.plugins maven-enforcer-plugin - ${version.maven-enforcer-plugin} dependency-convergence @@ -313,7 +355,6 @@ org.projectlombok lombok-maven-plugin - ${version.lombok-maven-plugin} delombok @@ -356,7 +397,6 @@ org.apache.maven.plugins maven-gpg-plugin - ${version.maven-gpg-plugin} sign-artifacts @@ -365,9 +405,9 @@ sign - ${gpg.passphrase} true + --batch --pinentry-mode loopback @@ -378,7 +418,6 @@ org.apache.maven.plugins maven-enforcer-plugin - ${version.maven-enforcer-plugin} enforce-no-snapshots @@ -399,7 +438,6 @@ org.projectlombok lombok-maven-plugin - ${version.lombok-maven-plugin} prepare-javadoc-sources @@ -435,7 +473,6 @@ org.apache.maven.plugins maven-source-plugin - ${version.maven-source-plugin} attach-sources @@ -449,33 +486,6 @@ - - - milestone - - - - org.apache.maven.plugins - maven-gpg-plugin - ${version.maven-gpg-plugin} - - - sign-artifacts - verify - - sign - - - - - true - rhuss@redhat.com - - - - - - jacoco @@ -527,7 +537,6 @@ asciidoctor-maven-plugin html - coderay left From 8f1917f328c5f1b6465e60a4b19880093e2d3157 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Wed, 5 Jul 2023 11:16:19 +0200 Subject: [PATCH 02/65] ci: configurations for SNAPSHOT release Signed-off-by: Marc Nuri --- pom.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pom.xml b/pom.xml index 12b0c8d01e..6d0871360e 100644 --- a/pom.xml +++ b/pom.xml @@ -72,6 +72,11 @@ + + ossrh + Sonatype OSS Repository (Snapshots) + https://oss.sonatype.org/content/repositories/snapshots + ossrh Nexus Release Repository @@ -112,6 +117,7 @@ 3.2.1 3.1.2 4.6.1 + 1.6.13 2.1.1 1.7.36 3.9.1.2184 @@ -322,6 +328,12 @@ sonar-maven-plugin ${version.sonar-maven-plugin} + + org.sonatype.plugins + nexus-staging-maven-plugin + ${version.nexus-staging-maven-plugin} + true + From 35e3a7f30c2a701612ae7bab55a304b1558db4c4 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Wed, 5 Jul 2023 13:01:50 +0200 Subject: [PATCH 03/65] ci: SNAPSHOT release pipeline for Jenkins (https://ci.eclipse.org/jkube) Signed-off-by: Marc Nuri --- .../pipelines/release-snapshots.Jenkinsfile | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .jenkins/pipelines/release-snapshots.Jenkinsfile diff --git a/.jenkins/pipelines/release-snapshots.Jenkinsfile b/.jenkins/pipelines/release-snapshots.Jenkinsfile new file mode 100644 index 0000000000..d8b90a7105 --- /dev/null +++ b/.jenkins/pipelines/release-snapshots.Jenkinsfile @@ -0,0 +1,29 @@ +#!groovy + +pipeline { + agent any + tools { + maven 'apache-maven-latest' + jdk 'temurin-jdk8-latest' + } + stages { + stage('Release Snapshots') { + steps { + withCredentials([file(credentialsId: 'secret-subkeys.asc', variable: 'KEYRING')]) { + sh 'echo "Setting up GPG signing keys"' + sh 'gpg --batch --import "${KEYRING}"' + sh 'for fpr in $(gpg --list-keys --with-colons | awk -F: \'/fpr:/ {print $10}\' | sort -u); do echo -e "5\ny\n" | gpg --batch --command-fd 0 --expert --edit-key ${fpr} trust; done' + } + sshagent(['github-bot-ssh']) { + sh 'echo "Cloning Project"' + // sh 'git clone git@github.com:eclipse/jkube.git' // disabled temporarily, credentials not working + sh 'git clone https://github.com/eclipse/jkube.git' + } + dir('jkube') { + sh 'echo "Deploying Snapshots"' + sh 'mvn -V -B -e -U -Prelease -Denforcer.skip=true deploy' + } + } + } + } +} From 70e9ff96fbb1c8870ab6cd3987a26e93e054db9a Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Thu, 22 Jun 2023 21:03:01 +0530 Subject: [PATCH 04/65] fix (jkube-kit-helidon) : HelidonHealthCheckEnricher should extract ports from properties HelidonHealthCheckEnricher should be able to automatically detect configured ports from `application.yml`/`microprofile-config.properties` Signed-off-by: Rohan Kumar --- .../enricher/HelidonHealthCheckEnricher.java | 6 +-- .../HelidonHealthCheckEnricherTest.java | 45 +++++++++++++++++++ .../HelidonGeneratorExposedPortsTest.java | 2 +- .../application.yaml | 0 .../META-INF/microprofile-config.properties | 1 + 5 files changed, 50 insertions(+), 4 deletions(-) rename jkube-kit/jkube-kit-helidon/src/test/resources/{generator-extract-ports => custom-port-configuration}/application.yaml (100%) create mode 100644 jkube-kit/jkube-kit-helidon/src/test/resources/custom-port-microprofile-configuration/META-INF/microprofile-config.properties diff --git a/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/enricher/HelidonHealthCheckEnricher.java b/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/enricher/HelidonHealthCheckEnricher.java index 588273cba3..a31d97912e 100644 --- a/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/enricher/HelidonHealthCheckEnricher.java +++ b/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/enricher/HelidonHealthCheckEnricher.java @@ -16,8 +16,8 @@ import org.eclipse.jkube.kit.enricher.api.JKubeEnricherContext; import org.eclipse.jkube.microprofile.enricher.AbstractMicroprofileHealthCheckEnricher; -import java.util.Optional; - +import static org.eclipse.jkube.helidon.HelidonUtils.extractPort; +import static org.eclipse.jkube.helidon.HelidonUtils.getHelidonConfiguration; import static org.eclipse.jkube.helidon.HelidonUtils.hasHelidonHealthDependency; import static org.eclipse.jkube.kit.common.Configs.asInteger; @@ -34,6 +34,6 @@ protected boolean shouldAddProbe() { @Override protected int getPort() { - return asInteger(Optional.ofNullable(getPortFromConfiguration()).orElse(DEFAULT_HELIDON_PORT)); + return asInteger(extractPort(getHelidonConfiguration(getContext().getProject()), DEFAULT_HELIDON_PORT)); } } \ No newline at end of file diff --git a/jkube-kit/jkube-kit-helidon/src/test/java/org/eclipse/jkube/helidon/enricher/HelidonHealthCheckEnricherTest.java b/jkube-kit/jkube-kit-helidon/src/test/java/org/eclipse/jkube/helidon/enricher/HelidonHealthCheckEnricherTest.java index 17960486ab..d91ab057a0 100644 --- a/jkube-kit/jkube-kit-helidon/src/test/java/org/eclipse/jkube/helidon/enricher/HelidonHealthCheckEnricherTest.java +++ b/jkube-kit/jkube-kit-helidon/src/test/java/org/eclipse/jkube/helidon/enricher/HelidonHealthCheckEnricherTest.java @@ -31,6 +31,7 @@ import java.io.File; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.Properties; import java.util.function.Supplier; @@ -169,6 +170,50 @@ void create_withMicroprofileEnabledAndEnricherConfiguration_shouldProbesAsConfig .hasFieldOrPropertyWithValue("startupProbe.httpGet.port.IntVal", 8080); } + @Test + void create_whenPortConfiguredViaApplicationYaml_thenUseThatPort() { + // Given + withHelidonHealth(); + withMicroprofileDependency("5.0"); + context = context.toBuilder() + .project(context.getProject().toBuilder() + .compileClassPathElement(Objects.requireNonNull(getClass().getResource("/custom-port-configuration")).getPath()) + .build()) + .build(); + HelidonHealthCheckEnricher helidonHealthCheckEnricher = new HelidonHealthCheckEnricher(context); + + // When + helidonHealthCheckEnricher.create(PlatformMode.kubernetes, klb); + + // Then + assertThat(getFirstContainerFromDeployment()) + .hasFieldOrPropertyWithValue("livenessProbe.httpGet.port.IntVal", 1337) + .hasFieldOrPropertyWithValue("readinessProbe.httpGet.port.IntVal", 1337) + .hasFieldOrPropertyWithValue("startupProbe.httpGet.port.IntVal", 1337); + } + + @Test + void create_whenPortConfiguredViaMicroprofileConfigProperties_thenUseThatPort() { + // Given + withHelidonHealth(); + withMicroprofileDependency("5.0"); + context = context.toBuilder() + .project(context.getProject().toBuilder() + .compileClassPathElement(Objects.requireNonNull(getClass().getResource("/custom-port-microprofile-configuration")).getPath()) + .build()) + .build(); + HelidonHealthCheckEnricher helidonHealthCheckEnricher = new HelidonHealthCheckEnricher(context); + + // When + helidonHealthCheckEnricher.create(PlatformMode.kubernetes, klb); + + // Then + assertThat(getFirstContainerFromDeployment()) + .hasFieldOrPropertyWithValue("livenessProbe.httpGet.port.IntVal", 1337) + .hasFieldOrPropertyWithValue("readinessProbe.httpGet.port.IntVal", 1337) + .hasFieldOrPropertyWithValue("startupProbe.httpGet.port.IntVal", 1337); + } + private void withMicroprofileDependency(String microProfileVersion) { final List deps = new ArrayList<>(javaProject.getDependencies()); deps.add(Dependency.builder() diff --git a/jkube-kit/jkube-kit-helidon/src/test/java/org/eclipse/jkube/helidon/generator/HelidonGeneratorExposedPortsTest.java b/jkube-kit/jkube-kit-helidon/src/test/java/org/eclipse/jkube/helidon/generator/HelidonGeneratorExposedPortsTest.java index 824907438d..cc826fa697 100644 --- a/jkube-kit/jkube-kit-helidon/src/test/java/org/eclipse/jkube/helidon/generator/HelidonGeneratorExposedPortsTest.java +++ b/jkube-kit/jkube-kit-helidon/src/test/java/org/eclipse/jkube/helidon/generator/HelidonGeneratorExposedPortsTest.java @@ -91,7 +91,7 @@ void withApplicationYaml_shouldAddConfigured() throws IOException { // Given whenStandardJarInTarget(); ctx = ctx.toBuilder().project(ctx.getProject().toBuilder() - .compileClassPathElement(HelidonGeneratorExposedPortsTest.class.getResource("/generator-extract-ports").getPath()) + .compileClassPathElement(HelidonGeneratorExposedPortsTest.class.getResource("/custom-port-configuration").getPath()) .build()) .build(); // When diff --git a/jkube-kit/jkube-kit-helidon/src/test/resources/generator-extract-ports/application.yaml b/jkube-kit/jkube-kit-helidon/src/test/resources/custom-port-configuration/application.yaml similarity index 100% rename from jkube-kit/jkube-kit-helidon/src/test/resources/generator-extract-ports/application.yaml rename to jkube-kit/jkube-kit-helidon/src/test/resources/custom-port-configuration/application.yaml diff --git a/jkube-kit/jkube-kit-helidon/src/test/resources/custom-port-microprofile-configuration/META-INF/microprofile-config.properties b/jkube-kit/jkube-kit-helidon/src/test/resources/custom-port-microprofile-configuration/META-INF/microprofile-config.properties new file mode 100644 index 0000000000..d9c6b1ef6b --- /dev/null +++ b/jkube-kit/jkube-kit-helidon/src/test/resources/custom-port-microprofile-configuration/META-INF/microprofile-config.properties @@ -0,0 +1 @@ +server.port=1337 From f340e480c44e58aec0c3176956ba727193f7c515 Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Wed, 5 Jul 2023 11:42:31 +0530 Subject: [PATCH 05/65] test (gradle-plugin/it) : Add integration test to verify port is automatically detected from helidon properties Signed-off-by: Rohan Kumar --- .../it/src/it/helidon-properties/build.gradle | 66 +++++++++ .../expected/kubernetes.yml | 107 ++++++++++++++ .../helidon-properties/expected/openshift.yml | 122 ++++++++++++++++ .../it/gradle/helidon/GreetResource.java | 137 ++++++++++++++++++ .../it/gradle/helidon/GreetingProvider.java | 47 ++++++ .../src/main/resources/META-INF/beans.xml | 8 + .../META-INF/microprofile-config.properties | 10 ++ .../plugin/tests/HelidonPropertiesIT.java | 66 +++++++++ 8 files changed, 563 insertions(+) create mode 100644 gradle-plugin/it/src/it/helidon-properties/build.gradle create mode 100644 gradle-plugin/it/src/it/helidon-properties/expected/kubernetes.yml create mode 100644 gradle-plugin/it/src/it/helidon-properties/expected/openshift.yml create mode 100644 gradle-plugin/it/src/it/helidon-properties/src/main/java/org/eclipse/jkube/it/gradle/helidon/GreetResource.java create mode 100644 gradle-plugin/it/src/it/helidon-properties/src/main/java/org/eclipse/jkube/it/gradle/helidon/GreetingProvider.java create mode 100644 gradle-plugin/it/src/it/helidon-properties/src/main/resources/META-INF/beans.xml create mode 100644 gradle-plugin/it/src/it/helidon-properties/src/main/resources/META-INF/microprofile-config.properties create mode 100644 gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/HelidonPropertiesIT.java diff --git a/gradle-plugin/it/src/it/helidon-properties/build.gradle b/gradle-plugin/it/src/it/helidon-properties/build.gradle new file mode 100644 index 0000000000..1f84317aae --- /dev/null +++ b/gradle-plugin/it/src/it/helidon-properties/build.gradle @@ -0,0 +1,66 @@ +plugins { + id 'java' + id 'org.kordamp.gradle.jandex' version '0.6.0' + id 'application' + id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}" + id 'org.eclipse.jkube.openshift' version "${jKubeVersion}" +} + +group = 'org.eclipse.jkube.integration.tests.gradle' +version = '0.0.1-SNAPSHOT' +sourceCompatibility = '11' +targetCompatibility = '11' +tasks.withType(JavaCompile) { + options.encoding = 'UTF-8' +} + +ext { + helidonversion = '2.6.0' + mainClass='io.helidon.microprofile.cdi.Main' +} + +repositories { + mavenLocal() + mavenCentral() + gradlePluginPortal() +} + +dependencies { + // import Helidon BOM + implementation enforcedPlatform("io.helidon:helidon-dependencies:${project.helidonversion}") + implementation 'io.helidon.microprofile.bundles:helidon-microprofile' + implementation 'org.glassfish.jersey.media:jersey-media-json-binding' + + runtimeOnly 'org.jboss:jandex' + runtimeOnly 'jakarta.activation:jakarta.activation-api' +} + +task copyLibs(type: Copy) { + from configurations.runtimeClasspath + into 'build/libs/libs' +} + +jar.dependsOn jandex +copyLibs.dependsOn jar +assemble.dependsOn copyLibs + +jar { + archiveFileName = "${project.name}.jar" + manifest { + attributes ('Main-Class': "${project.mainClass}" , + 'Class-Path': configurations.runtimeClasspath.files.collect { "libs/$it.name" }.join(' ') + ) + } +} + +application { + mainClass = "${project.mainClass}" +} + +kubernetes { + offline = true +} + +openshift { + offline = true +} diff --git a/gradle-plugin/it/src/it/helidon-properties/expected/kubernetes.yml b/gradle-plugin/it/src/it/helidon-properties/expected/kubernetes.yml new file mode 100644 index 0000000000..c88ab2120e --- /dev/null +++ b/gradle-plugin/it/src/it/helidon-properties/expected/kubernetes.yml @@ -0,0 +1,107 @@ +--- +apiVersion: v1 +kind: List +items: +- apiVersion: v1 + kind: Service + metadata: + annotations: + jkube.eclipse.org/git-commit: "@ignore@" + prometheus.io/path: "@ignore@" + prometheus.io/port: "@ignore@" + jkube.eclipse.org/git-url: "@ignore@" + prometheus.io/scrape: "@ignore@" + jkube.eclipse.org/git-branch: "@ignore@" + labels: + app: helidon-properties + provider: jkube + version: "@ignore@" + group: org.eclipse.jkube.integration.tests.gradle + name: helidon-properties + spec: + ports: + - name: http-alt + port: 8008 + protocol: TCP + targetPort: 8008 + selector: + app: helidon-properties + provider: jkube + group: org.eclipse.jkube.integration.tests.gradle +- apiVersion: apps/v1 + kind: Deployment + metadata: + annotations: + jkube.eclipse.org/git-commit: "@ignore@" + jkube.eclipse.org/git-url: "@ignore@" + jkube.eclipse.org/git-branch: "@ignore@" + labels: + app: helidon-properties + provider: jkube + version: "@ignore@" + group: org.eclipse.jkube.integration.tests.gradle + name: helidon-properties + spec: + replicas: 1 + revisionHistoryLimit: 2 + selector: + matchLabels: + app: helidon-properties + provider: jkube + group: org.eclipse.jkube.integration.tests.gradle + template: + metadata: + annotations: + jkube.eclipse.org/git-commit: "@ignore@" + jkube.eclipse.org/git-url: "@ignore@" + jkube.eclipse.org/git-branch: "@ignore@" + labels: + app: helidon-properties + provider: jkube + version: "@ignore@" + group: org.eclipse.jkube.integration.tests.gradle + name: helidon-properties + spec: + containers: + - env: + - name: KUBERNETES_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: HOSTNAME + valueFrom: + fieldRef: + fieldPath: metadata.name + image: gradle/helidon-properties:latest + imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 3 + httpGet: + path: /health/live + port: 8008 + scheme: HTTP + initialDelaySeconds: 0 + periodSeconds: 10 + successThreshold: 1 + name: helidon + ports: + - containerPort: 8008 + name: http-alt + protocol: TCP + - containerPort: 9779 + name: prometheus + protocol: TCP + - containerPort: 8778 + name: jolokia + protocol: TCP + readinessProbe: + failureThreshold: 3 + httpGet: + path: /health/ready + port: 8008 + scheme: HTTP + initialDelaySeconds: 0 + periodSeconds: 10 + successThreshold: 1 + securityContext: + privileged: false diff --git a/gradle-plugin/it/src/it/helidon-properties/expected/openshift.yml b/gradle-plugin/it/src/it/helidon-properties/expected/openshift.yml new file mode 100644 index 0000000000..b1dc6ffcca --- /dev/null +++ b/gradle-plugin/it/src/it/helidon-properties/expected/openshift.yml @@ -0,0 +1,122 @@ +--- +apiVersion: v1 +kind: List +items: +- apiVersion: v1 + kind: Service + metadata: + annotations: + jkube.eclipse.org/git-commit: "@ignore@" + app.openshift.io/vcs-ref: "@ignore@" + prometheus.io/path: "@ignore@" + prometheus.io/port: "@ignore@" + jkube.eclipse.org/git-url: "@ignore@" + prometheus.io/scrape: "@ignore@" + app.openshift.io/vcs-uri: "@ignore@" + jkube.eclipse.org/git-branch: "@ignore@" + labels: + app: helidon-properties + provider: jkube + version: "@ignore@" + group: org.eclipse.jkube.integration.tests.gradle + name: helidon-properties + spec: + ports: + - name: http-alt + port: 8008 + protocol: TCP + targetPort: 8008 + selector: + app: helidon-properties + provider: jkube + group: org.eclipse.jkube.integration.tests.gradle +- apiVersion: apps.openshift.io/v1 + kind: DeploymentConfig + metadata: + annotations: + jkube.eclipse.org/git-commit: "@ignore@" + jkube.eclipse.org/git-url: "@ignore@" + app.openshift.io/vcs-ref: "@ignore@" + app.openshift.io/vcs-uri: "@ignore@" + jkube.eclipse.org/git-branch: "@ignore@" + labels: + app: helidon-properties + provider: jkube + version: "@ignore@" + group: org.eclipse.jkube.integration.tests.gradle + name: helidon-properties + spec: + replicas: 1 + revisionHistoryLimit: 2 + selector: + app: helidon-properties + provider: jkube + group: org.eclipse.jkube.integration.tests.gradle + strategy: + rollingParams: + timeoutSeconds: 3600 + type: Rolling + template: + metadata: + annotations: + jkube.eclipse.org/git-commit: "@ignore@" + jkube.eclipse.org/git-url: "@ignore@" + app.openshift.io/vcs-ref: "@ignore@" + app.openshift.io/vcs-uri: "@ignore@" + jkube.eclipse.org/git-branch: "@ignore@" + labels: + app: helidon-properties + provider: jkube + version: "@ignore@" + group: org.eclipse.jkube.integration.tests.gradle + name: helidon-properties + spec: + containers: + - env: + - name: KUBERNETES_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + image: helidon-properties:latest + imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 3 + httpGet: + path: /health/live + port: 8008 + scheme: HTTP + initialDelaySeconds: 0 + periodSeconds: 10 + successThreshold: 1 + name: helidon + ports: + - containerPort: 8008 + name: http-alt + protocol: TCP + - containerPort: 9779 + name: prometheus + protocol: TCP + - containerPort: 8778 + name: jolokia + protocol: TCP + readinessProbe: + failureThreshold: 3 + httpGet: + path: /health/ready + port: 8008 + scheme: HTTP + initialDelaySeconds: 0 + periodSeconds: 10 + successThreshold: 1 + securityContext: + privileged: false + triggers: + - type: ConfigChange + - imageChangeParams: + automatic: true + containerNames: + - helidon + from: + kind: ImageStreamTag + name: helidon-properties:latest + type: ImageChange \ No newline at end of file diff --git a/gradle-plugin/it/src/it/helidon-properties/src/main/java/org/eclipse/jkube/it/gradle/helidon/GreetResource.java b/gradle-plugin/it/src/it/helidon-properties/src/main/java/org/eclipse/jkube/it/gradle/helidon/GreetResource.java new file mode 100644 index 0000000000..0551f6785d --- /dev/null +++ b/gradle-plugin/it/src/it/helidon-properties/src/main/java/org/eclipse/jkube/it/gradle/helidon/GreetResource.java @@ -0,0 +1,137 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.it.gradle.helidon; + +import java.util.Collections; + +import javax.inject.Inject; +import javax.json.Json; +import javax.json.JsonBuilderFactory; +import javax.json.JsonObject; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; +import org.eclipse.microprofile.openapi.annotations.media.Content; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.eclipse.microprofile.openapi.annotations.parameters.RequestBody; +import org.eclipse.microprofile.openapi.annotations.responses.APIResponse; +import org.eclipse.microprofile.openapi.annotations.responses.APIResponses; + +/** + * A simple JAX-RS resource to greet you. Examples: + * + * Get default greeting message: + * curl -X GET http://localhost:8080/greet + * + * Get greeting message for Joe: + * curl -X GET http://localhost:8080/greet/Joe + * + * Change greeting + * curl -X PUT -H "Content-Type: application/json" -d '{"greeting" : "Howdy"}' http://localhost:8080/greet/greeting + * + * The message is returned as a JSON object. + */ +@Path("/greet") +public class GreetResource { + + private static final JsonBuilderFactory JSON = Json.createBuilderFactory(Collections.emptyMap()); + + /** + * The greeting message provider. + */ + private final GreetingProvider greetingProvider; + + /** + * Using constructor injection to get a configuration property. + * By default this gets the value from META-INF/microprofile-config + * + * @param greetingConfig the configured greeting message + */ + @Inject + public GreetResource(GreetingProvider greetingConfig) { + this.greetingProvider = greetingConfig; + } + + /** + * Return a worldly greeting message. + * + * @return {@link JsonObject} + */ + @GET + @Produces(MediaType.APPLICATION_JSON) + public JsonObject getDefaultMessage() { + return createResponse("World"); + } + + /** + * Return a greeting message using the name that was provided. + * + * @param name the name to greet + * @return {@link JsonObject} + */ + @Path("/{name}") + @GET + @Produces(MediaType.APPLICATION_JSON) + public JsonObject getMessage(@PathParam("name") String name) { + return createResponse(name); + } + + /** + * Set the greeting to use in future messages. + * + * @param jsonObject JSON containing the new greeting + * @return {@link Response} + */ + @Path("/greeting") + @PUT + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @RequestBody(name = "greeting", + required = true, + content = @Content(mediaType = "application/json", + schema = @Schema(type = SchemaType.OBJECT, requiredProperties = { "greeting" }))) + @APIResponses({ + @APIResponse(name = "normal", responseCode = "204", description = "Greeting updated"), + @APIResponse(name = "missing 'greeting'", responseCode = "400", + description = "JSON did not contain setting for 'greeting'")}) + public Response updateGreeting(JsonObject jsonObject) { + + if (!jsonObject.containsKey("greeting")) { + JsonObject entity = JSON.createObjectBuilder() + .add("error", "No greeting provided") + .build(); + return Response.status(Response.Status.BAD_REQUEST).entity(entity).build(); + } + + String newGreeting = jsonObject.getString("greeting"); + + greetingProvider.setMessage(newGreeting); + return Response.status(Response.Status.NO_CONTENT).build(); + } + + private JsonObject createResponse(String who) { + String msg = String.format("%s %s!", greetingProvider.getMessage(), who); + + return JSON.createObjectBuilder() + .add("message", msg) + .build(); + } +} diff --git a/gradle-plugin/it/src/it/helidon-properties/src/main/java/org/eclipse/jkube/it/gradle/helidon/GreetingProvider.java b/gradle-plugin/it/src/it/helidon-properties/src/main/java/org/eclipse/jkube/it/gradle/helidon/GreetingProvider.java new file mode 100644 index 0000000000..aa70f3018a --- /dev/null +++ b/gradle-plugin/it/src/it/helidon-properties/src/main/java/org/eclipse/jkube/it/gradle/helidon/GreetingProvider.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.it.gradle.helidon; + +import java.util.concurrent.atomic.AtomicReference; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; + +import org.eclipse.microprofile.config.inject.ConfigProperty; + +/** + * Provider for greeting message. + */ +@ApplicationScoped +public class GreetingProvider { + private final AtomicReference message = new AtomicReference<>(); + + /** + * Create a new greeting provider, reading the message from configuration. + * + * @param message greeting to use + */ + @Inject + public GreetingProvider(@ConfigProperty(name = "app.greeting") String message) { + this.message.set(message); + } + + String getMessage() { + return message.get(); + } + + void setMessage(String message) { + this.message.set(message); + } +} diff --git a/gradle-plugin/it/src/it/helidon-properties/src/main/resources/META-INF/beans.xml b/gradle-plugin/it/src/it/helidon-properties/src/main/resources/META-INF/beans.xml new file mode 100644 index 0000000000..5d94aab5a2 --- /dev/null +++ b/gradle-plugin/it/src/it/helidon-properties/src/main/resources/META-INF/beans.xml @@ -0,0 +1,8 @@ + + + diff --git a/gradle-plugin/it/src/it/helidon-properties/src/main/resources/META-INF/microprofile-config.properties b/gradle-plugin/it/src/it/helidon-properties/src/main/resources/META-INF/microprofile-config.properties new file mode 100644 index 0000000000..52388ad7ac --- /dev/null +++ b/gradle-plugin/it/src/it/helidon-properties/src/main/resources/META-INF/microprofile-config.properties @@ -0,0 +1,10 @@ + +# Application properties. This is the default greeting +app.greeting=Hello + +# Microprofile server properties +server.port=8008 +server.host=0.0.0.0 + +# Turn on support for REST.request SimpleTimers for all JAX-RS endpoints +metrics.rest-request.enabled=true diff --git a/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/HelidonPropertiesIT.java b/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/HelidonPropertiesIT.java new file mode 100644 index 0000000000..57831a62b5 --- /dev/null +++ b/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/HelidonPropertiesIT.java @@ -0,0 +1,66 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.gradle.plugin.tests; + +import net.minidev.json.parser.ParseException; +import org.eclipse.jkube.kit.common.ResourceVerify; +import org.gradle.testkit.runner.BuildResult; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import java.io.IOException; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + +class HelidonPropertiesIT { + @RegisterExtension + private final ITGradleRunnerExtension gradleRunner = new ITGradleRunnerExtension(); + + @Test + void k8sResource_whenRun_generatesK8sManifestsWithProbes() throws IOException, ParseException { + // When + final BuildResult result = gradleRunner.withITProject("helidon-properties") + .withArguments("build", "k8sResource", "--stacktrace") + .build(); + // Then + ResourceVerify.verifyResourceDescriptors(gradleRunner.resolveDefaultKubernetesResourceFile(), + gradleRunner.resolveFile("expected", "kubernetes.yml")); + assertThat(result).extracting(BuildResult::getOutput).asString() + .contains("jkube-controller: Adding a default Deployment") + .contains("jkube-service: Adding a default service") + .contains("jkube-healthcheck-helidon: Adding readiness probe on port 8008") + .contains("jkube-healthcheck-helidon: Adding liveness probe on port 8008") + .contains("jkube-service-discovery: Using first mentioned service port '8008' ") + .contains("jkube-revision-history: Adding revision history limit to 2"); + } + + @Test + void ocResource_whenRun_generatesOpenShiftManifestsWithProbes() throws IOException, ParseException { + // When + final BuildResult result = gradleRunner.withITProject("helidon-properties") + .withArguments("build", "ocResource", "--stacktrace") + .build(); + // Then + ResourceVerify.verifyResourceDescriptors(gradleRunner.resolveDefaultOpenShiftResourceFile(), + gradleRunner.resolveFile("expected", "openshift.yml")); + assertThat(result).extracting(BuildResult::getOutput).asString() + .contains("jkube-controller: Adding a default Deployment") + .contains("jkube-service: Adding a default service") + .contains("jkube-openshift-deploymentconfig: Converting Deployment to DeploymentConfig") + .contains("jkube-healthcheck-helidon: Adding readiness probe on port 8008") + .contains("jkube-healthcheck-helidon: Adding liveness probe on port 8008") + .contains("jkube-service-discovery: Using first mentioned service port '8008' ") + .contains("jkube-revision-history: Adding revision history limit to 2"); + } +} From 6e7c8a53949a5533a0c828dda3076d35b49a6327 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Tue, 4 Jul 2023 13:03:59 +0200 Subject: [PATCH 06/65] refactor: initial simplification of ApplyService Signed-off-by: Marc Nuri --- .../kit/common/util/KubernetesHelper.java | 6 +- .../kit/common/util/KubernetesHelperTest.java | 19 ++ .../kit/config/service/ApplyService.java | 213 +++++------------- .../kit/config/service/ApplyServiceTest.java | 36 ++- 4 files changed, 116 insertions(+), 158 deletions(-) diff --git a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/KubernetesHelper.java b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/KubernetesHelper.java index 64cdbf62eb..e3d4a47f8a 100644 --- a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/KubernetesHelper.java +++ b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/KubernetesHelper.java @@ -40,6 +40,7 @@ import java.util.stream.Collectors; import io.fabric8.kubernetes.api.model.HTTPHeader; +import io.fabric8.kubernetes.api.model.KubernetesResource; import io.fabric8.kubernetes.api.model.authorization.v1.ResourceAttributesBuilder; import io.fabric8.kubernetes.api.model.authorization.v1.SelfSubjectAccessReview; import io.fabric8.kubernetes.api.model.authorization.v1.SelfSubjectAccessReviewBuilder; @@ -246,11 +247,12 @@ public static String getNamespace(HasMetadata entity) { * @param entity entity as HasMetadata * @return kind of resource */ - public static String getKind(HasMetadata entity) { + public static String getKind(KubernetesResource entity) { if (entity != null) { - // TODO use reflection to find the kind? if (entity instanceof KubernetesList) { return "List"; + } else if (entity instanceof HasMetadata) { + return ((HasMetadata) entity).getKind(); } else { return entity.getClass().getSimpleName(); } diff --git a/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/KubernetesHelperTest.java b/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/KubernetesHelperTest.java index 65999494e0..08203d15a8 100644 --- a/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/KubernetesHelperTest.java +++ b/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/KubernetesHelperTest.java @@ -24,8 +24,11 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Stream; +import io.fabric8.kubernetes.api.model.KubernetesResource; +import io.fabric8.kubernetes.api.model.Pod; import io.fabric8.kubernetes.api.model.authorization.v1.SelfSubjectAccessReview; import io.fabric8.kubernetes.api.model.authorization.v1.SelfSubjectAccessReviewBuilder; +import io.fabric8.kubernetes.api.model.runtime.RawExtension; import io.fabric8.kubernetes.client.KubernetesClient; import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient; import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer; @@ -463,6 +466,22 @@ void hasAccessForAction_whenApiServerReturnsAccessReviewWithStatus_thenReturnAll .hasFieldOrPropertyWithValue("spec.resourceAttributes.verb", "list"); } + @ParameterizedTest(name = "{index}: {0} returns {1}") + @MethodSource("getKindTestCases") + void getKind(KubernetesResource resource, String expectedKind) { + assertThat(KubernetesHelper.getKind(resource)).isEqualTo(expectedKind); + } + + static Stream getKindTestCases() { + return Stream.of( + Arguments.of(new Pod(), "Pod"), + Arguments.of(new Template(), "Template"), + Arguments.of(new KubernetesList(), "List"), + Arguments.of(new RawExtension(), "RawExtension"), + Arguments.of(null, null) + ); + } + private void assertLocalFragments(File[] fragments, int expectedSize) { assertThat(fragments).hasSize(expectedSize); assertThat(Arrays.stream(fragments).anyMatch( f -> f.getName().equals("deployment.yml"))).isTrue(); diff --git a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/ApplyService.java b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/ApplyService.java index 1d39a1dc73..c0a2a56b33 100644 --- a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/ApplyService.java +++ b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/ApplyService.java @@ -24,11 +24,11 @@ import java.util.Map; import java.util.Objects; import java.util.Set; -import java.util.function.Consumer; import java.util.stream.Collectors; import io.fabric8.kubernetes.api.model.GenericKubernetesResource; import io.fabric8.kubernetes.api.model.HasMetadataComparator; +import io.fabric8.kubernetes.api.model.Namespaced; import io.fabric8.kubernetes.client.dsl.base.PatchContext; import io.fabric8.kubernetes.client.dsl.base.PatchType; import org.eclipse.jkube.kit.common.KitLogger; @@ -127,7 +127,7 @@ public ApplyService(JKubeServiceHub serviceHub) { /** * Applies the given DTOs onto the Kubernetes master */ - public void apply(Object dto, String sourceName) { + public void apply(Object dto, String fileName) { if (dto instanceof List) { List list = (List) dto; for (Object element : list) { @@ -135,12 +135,12 @@ public void apply(Object dto, String sourceName) { log.warn("Found recursive nested object for %s of class: %s", dto, dto.getClass().getName()); continue; } - apply(element, sourceName); + apply(element, fileName); } } else if (dto instanceof KubernetesList) { - applyList((KubernetesList) dto, sourceName); + applyList((KubernetesList) dto, fileName); } else if (dto != null) { - applyEntity(dto, sourceName); + applyEntity(dto, fileName); } } @@ -384,7 +384,7 @@ public void applyServiceAccount(ServiceAccount serviceAccount, String sourceName } else { if (isRecreateMode()) { kubernetesClient.serviceAccounts().inNamespace(currentNamespace).withName(id).delete(); - doCreateServiceAccount(serviceAccount, currentNamespace, sourceName); + doCreate(serviceAccount, currentNamespace, sourceName); } else { log.info("Updating a ServiceAccount from " + sourceName); try { @@ -399,22 +399,11 @@ public void applyServiceAccount(ServiceAccount serviceAccount, String sourceName if (!isAllowCreate()) { log.warn("Creation disabled so not creating a ServiceAccount from " + sourceName + " namespace " + currentNamespace + " name " + getName(serviceAccount)); } else { - doCreateServiceAccount(serviceAccount, currentNamespace, sourceName); + doCreate(serviceAccount, currentNamespace, sourceName); } } } - protected void doCreateServiceAccount(ServiceAccount serviceAccount, String namespace, String sourceName) { - log.info("Creating a ServiceAccount from " + sourceName + " namespace " + namespace + " name " + getName - (serviceAccount)); - try { - Object answer = kubernetesClient.serviceAccounts().inNamespace(namespace).create(serviceAccount); - logGeneratedEntity("Created ServiceAccount: ", namespace, serviceAccount, answer); - } catch (Exception e) { - onApplyError("Failed to create ServiceAccount from " + sourceName + ". " + e + ". " + serviceAccount, e); - } - } - public void applyPersistentVolumeClaim(PersistentVolumeClaim entity, String sourceName) { // we cannot update PVCs boolean alwaysRecreate = true; @@ -438,7 +427,7 @@ public void applyPersistentVolumeClaim(PersistentVolumeClaim entity, String sour kubernetesClient.persistentVolumeClaims().inNamespace(currentNamespace).withName(id).delete(); log.info("Deleted PersistentVolumeClaim from namespace " + currentNamespace + " with name " + id); - doCreatePersistentVolumeClaim(entity, currentNamespace, sourceName); + doCreate(entity, currentNamespace, sourceName); } } else { doPatchEntity(old, entity, currentNamespace, sourceName); @@ -448,68 +437,46 @@ public void applyPersistentVolumeClaim(PersistentVolumeClaim entity, String sour if (!isAllowCreate()) { log.warn("Creation disabled so not creating a PersistentVolumeClaim from " + sourceName + " namespace " + currentNamespace + " name " + getName(entity)); } else { - doCreatePersistentVolumeClaim(entity, currentNamespace, sourceName); + doCreate(entity, currentNamespace, sourceName); } } } - public void applyCustomResourceDefinition(CustomResourceDefinition entity, String sourceName) { - String currentNamespace = applicableNamespace(entity, namespace, fallbackNamespace); - String id = getName(entity); - Objects.requireNonNull(id, "No name for " + entity + " " + sourceName); + public void applyCustomResourceDefinition(CustomResourceDefinition entity, String fileName) { + final String name = getName(entity); + Objects.requireNonNull(name, "No name for CustomResourceDefinition " + fileName); if (isServicesOnlyMode()) { - log.debug("Only processing Services right now so ignoring Custom Resource Definition: " + currentNamespace + ":" + id); + log.debug("Only processing Services right now so ignoring Custom Resource Definition: %s", name); return; } - CustomResourceDefinition old = kubernetesClient.apiextensions().v1().customResourceDefinitions().withName(id).get(); + CustomResourceDefinition old = kubernetesClient.apiextensions().v1().customResourceDefinitions().withName(name).get(); if (isRunning(old)) { if (UserConfigurationCompare.configEqual(entity, old)) { log.info("Custom Resource Definition has not changed so not doing anything"); } else { if (isRecreateMode()) { - log.info("Deleting Custom Resource Definition: " + id); - kubernetesClient.apiextensions().v1().customResourceDefinitions().withName(id).delete(); - doCreateCustomResourceDefinition(entity, sourceName); + log.info("Deleting Custom Resource Definition: %s", name); + kubernetesClient.apiextensions().v1().customResourceDefinitions().withName(name).delete(); + doCreate(entity, null, fileName); } else { - doPatchEntity(old, entity, currentNamespace, sourceName); + doPatchEntity(old, entity, null, fileName); } } } else { if (!isAllowCreate()) { - log.warn("Creation disabled so not creating a Custom Resource Definition from " + sourceName + " name " + getName(entity)); + log.warn("Creation disabled so not creating a Custom Resource Definition from " + fileName + " name " + getName(entity)); } else { - doCreateCustomResourceDefinition(entity, sourceName); + doCreate(entity, null, fileName); } } } - private void doCreateCustomResourceDefinition(CustomResourceDefinition entity, String sourceName) { - log.info("Creating a Custom Resource Definition from " + sourceName + " name " + getName(entity)); - try { - CustomResourceDefinition answer = kubernetesClient.apiextensions().v1().customResourceDefinitions().create(entity); - log.info("Created Custom Resource Definition result: %s", answer.getMetadata().getName()); - } catch (Exception e) { - onApplyError("Failed to create Custom Resource Definition from " + sourceName + ". " + e + ". " + entity, e); - } - } - protected boolean isBound(PersistentVolumeClaim claim) { return claim != null && claim.getStatus() != null && "Bound".equals(claim.getStatus().getPhase()); } - protected void doCreatePersistentVolumeClaim(PersistentVolumeClaim entity, String namespace, String sourceName) { - log.info("Creating a PersistentVolumeClaim from " + sourceName + " namespace " + namespace + " name " + getName(entity)); - try { - Object answer; - answer = kubernetesClient.persistentVolumeClaims().inNamespace(namespace).create(entity); - logGeneratedEntity("Created PersistentVolumeClaim: ", namespace, entity, answer); - } catch (Exception e) { - onApplyError("Failed to create PersistentVolumeClaim from " + sourceName + ". " + e + ". " + entity, e); - } - } - public void applySecret(Secret secret, String sourceName) { String currentNamespace = applicableNamespace(secret, namespace, fallbackNamespace); String id = getName(secret); @@ -528,7 +495,7 @@ public void applySecret(Secret secret, String sourceName) { } else { if (isRecreateMode()) { kubernetesClient.secrets().inNamespace(currentNamespace).withName(id).delete(); - doCreateSecret(secret, currentNamespace, sourceName); + doCreate(secret, currentNamespace, sourceName); } else { doPatchEntity(old, secret, currentNamespace, sourceName); } @@ -537,25 +504,15 @@ public void applySecret(Secret secret, String sourceName) { if (!isAllowCreate()) { log.warn("Creation disabled so not creating a Secret from " + sourceName + " namespace " + currentNamespace + " name " + getName(secret)); } else { - doCreateSecret(secret, currentNamespace, sourceName); + doCreate(secret, currentNamespace, sourceName); } } } - protected void doCreateSecret(Secret secret, String namespace, String sourceName) { - log.info("Creating a Secret from " + sourceName + " namespace " + namespace + " name " + getName(secret)); - try { - Object answer = kubernetesClient.secrets().inNamespace(namespace).create(secret); - logGeneratedEntity("Created Secret: ", namespace, secret, answer); - } catch (Exception e) { - onApplyError("Failed to create Secret from " + sourceName + ". " + e + ". " + secret, e); - } - } - - protected void logGeneratedEntity(String message, String namespace, HasMetadata entity, Object result) { + private void logGeneratedEntity(String message, String namespace, HasMetadata entity, Object result) { if (logJsonDir != null) { - File namespaceDir = new File(logJsonDir, namespace); - namespaceDir.mkdirs(); + final File directory = StringUtils.isBlank(namespace) ? logJsonDir : new File(logJsonDir, namespace); + directory.mkdirs(); String kind = getKind(entity); String name = getName(entity); if (isNotBlank(kind)) { @@ -565,12 +522,12 @@ protected void logGeneratedEntity(String message, String namespace, HasMetadata log.warn("No name for the entity " + entity); } else { String fileName = name + ".json"; - File file = new File(namespaceDir, fileName); + File file = new File(directory, fileName); if (file.exists()) { int idx = 1; while (true) { fileName = name + "-" + idx++ + ".json"; - file = new File(namespaceDir, fileName); + file = new File(directory, fileName); if (!file.exists()) { break; } @@ -713,7 +670,7 @@ public void applyRoleBinding(RoleBinding entity, String sourceName) { Objects.requireNonNull(id, "No name for " + entity + " " + sourceName); String currentNamespace = applicableNamespace(entity, namespace, fallbackNamespace); - applyNamespace(currentNamespace); + RoleBinding old = kubernetesClient.rbac().roleBindings().inNamespace(currentNamespace).withName(id).get(); if (isRunning(old)) { if (UserConfigurationCompare.configEqual(entity, old)) { @@ -722,7 +679,7 @@ public void applyRoleBinding(RoleBinding entity, String sourceName) { if (isRecreateMode()) { log.info("Deleting RoleBinding: " + id); kubernetesClient.rbac().roleBindings().inNamespace(currentNamespace).withName(id).delete(); - doCreateRoleBinding(entity, currentNamespace, sourceName); + doCreate(entity, currentNamespace, sourceName); } else { log.info("Updating RoleBinding from " + sourceName); try { @@ -741,20 +698,11 @@ public void applyRoleBinding(RoleBinding entity, String sourceName) { if (!isAllowCreate()) { log.warn("Creation disabled so not creating RoleBinding from " + sourceName + " namespace " + currentNamespace + " name " + getName(entity)); } else { - doCreateRoleBinding(entity, currentNamespace, sourceName); + doCreate(entity, currentNamespace, sourceName); } } } - public void doCreateRoleBinding(RoleBinding entity, String namespace , String sourceName) { - try { - log.info("Creating RoleBinding from " + sourceName + " namespace " + namespace + " name " + getName(entity)); - kubernetesClient.rbac().roleBindings().inNamespace(namespace).create(entity); - } catch (Exception e) { - onApplyError("Failed to create RoleBinding from " + sourceName + ". " + e, e); - } - } - public void applyImageStream(ImageStream entity, String sourceName) { if (OpenshiftHelper.isOpenShift(kubernetesClient)) { String kind = getKind(entity); @@ -849,7 +797,7 @@ public void applyService(Service service, String sourceName) { if (isRecreateMode()) { log.info("Deleting Service: " + id); kubernetesClient.services().inNamespace(currentNamespace).withName(id).delete(); - doCreateService(service, currentNamespace, sourceName); + doCreate(service, currentNamespace, sourceName); } else { doPatchEntity(old, service, currentNamespace, sourceName); } @@ -858,7 +806,7 @@ public void applyService(Service service, String sourceName) { if (!isAllowCreate()) { log.warn("Creation disabled so not creating a Service from " + sourceName + " namespace " + currentNamespace + " name " + getName(service)); } else { - doCreateService(service, currentNamespace, sourceName); + doCreate(service, currentNamespace, sourceName); } } } @@ -880,7 +828,7 @@ public void applyResource(T resource, String sourceNam if (isRecreateMode()) { log.info("Deleting " + kind + ": " + id); resources.inNamespace(currentNamespace).withName(id).delete(); - doCreateResource(resource, currentNamespace, sourceName, resources); + doCreate(resource, currentNamespace, sourceName); } else { log.info("Updating " + kind + " from " + sourceName); try { @@ -895,22 +843,11 @@ public void applyResource(T resource, String sourceNam if (!isAllowCreate()) { log.warn("Creation disabled so not creating a " + kind + " from " + sourceName + " namespace " + currentNamespace + " name " + getName(resource)); } else { - doCreateResource(resource, currentNamespace, sourceName, resources); + doCreate(resource, currentNamespace, sourceName); } } } - protected void doCreateResource(T resource, String namespace , String sourceName, MixedOperation> resources) { - String kind = getKind(resource); - log.info("Creating a " + kind + " from " + sourceName + " namespace " + namespace + " name " + getName(resource)); - try { - Object answer = resources.inNamespace(namespace).create(resource); - logGeneratedEntity("Created " + kind + ": ", namespace, resource, answer); - } catch (Exception e) { - onApplyError("Failed to create " + kind + " from " + sourceName + ". " + e + ". " + resource, e); - } - } - private void doPatchEntity(T oldEntity, T newEntity, String namespace, String sourceName) { String kind = newEntity.getKind(); log.info("Updating %s from %s", kind, sourceName); @@ -922,16 +859,6 @@ private void doPatchEntity(T oldEntity, T newEntity, Str } } - protected void doCreateService(Service service, String namespace, String sourceName) { - log.info("Creating a Service from " + sourceName + " namespace " + namespace + " name " + getName(service)); - try { - Object answer = kubernetesClient.services().inNamespace(namespace).create(service); - logGeneratedEntity("Created Service: ", namespace, service, answer); - } catch (Exception e) { - onApplyError("Failed to create Service from " + sourceName + ". " + e + ". " + service, e); - } - } - public boolean checkNamespace(String namespaceName) { if (StringUtils.isBlank(namespaceName)) { return false; @@ -1059,6 +986,24 @@ public boolean applyProjectRequest(ProjectRequest entity) { return false; } + private void doCreate(HasMetadata resource, String namespace, String fileName) { + final String kind = getKind(resource); + try { + final Object answer; + if (resource instanceof Namespaced) { + log.info("Creating a %s in %s namespace with name %s from %s", + kind, namespace, getName(resource), fileName); + answer = kubernetesClient.resource(resource).inNamespace(namespace).create(); + } else { + log.info("Creating a %s with name %s from %s", kind, getName(resource), fileName); + answer = kubernetesClient.resource(resource).create(); + } + logGeneratedEntity("Created " + kind + ": ", namespace, resource, answer); + } catch (Exception e) { + onApplyError("Failed to create " + kind + " from " + fileName + ". " + e + ". " + resource, e); + } + } + public void applyReplicationController(ReplicationController replicationController, String sourceName) { String currentNamespace = applicableNamespace(replicationController, namespace, fallbackNamespace); String id = getName(replicationController); @@ -1090,7 +1035,7 @@ public void applyReplicationController(ReplicationController replicationControll } else if (isRecreateMode()) { log.info("Deleting ReplicationController: " + id); kubernetesClient.replicationControllers().inNamespace(currentNamespace).withName(id).delete(); - doCreateReplicationController(replicationController, currentNamespace, sourceName); + doCreate(replicationController, currentNamespace, sourceName); } else { log.info("Updating ReplicationController from " + sourceName + " namespace " + currentNamespace + " name " + getName(replicationController)); try { @@ -1112,21 +1057,11 @@ public void applyReplicationController(ReplicationController replicationControll if (!isAllowCreate()) { log.warn("Creation disabled so not creating a ReplicationController from " + sourceName + " namespace " + currentNamespace + " name " + getName(replicationController)); } else { - doCreateReplicationController(replicationController, currentNamespace, sourceName); + doCreate(replicationController, currentNamespace, sourceName); } } } - protected void doCreateReplicationController(ReplicationController replicationController, String namespace, String sourceName) { - log.info("Creating a ReplicationController from " + sourceName + " namespace " + namespace + " name " + getName(replicationController)); - try { - Object answer = kubernetesClient.replicationControllers().inNamespace(namespace).create(replicationController); - logGeneratedEntity("Created ReplicationController: ", namespace, replicationController, answer); - } catch (Exception e) { - onApplyError("Failed to create ReplicationController from " + sourceName + ". " + e + ". " + replicationController, e); - } - } - public void applyPod(Pod pod, String sourceName) { String currentNamespace = applicableNamespace(pod, namespace, fallbackNamespace); String id = getName(pod); @@ -1143,7 +1078,7 @@ public void applyPod(Pod pod, String sourceName) { if (isRecreateMode()) { log.info("Deleting Pod: " + id); kubernetesClient.pods().inNamespace(currentNamespace).withName(id).delete(); - doCreatePod(pod, currentNamespace, sourceName); + doCreate(pod, currentNamespace, sourceName); } else { doPatchEntity(old, pod, currentNamespace, sourceName); } @@ -1152,21 +1087,11 @@ public void applyPod(Pod pod, String sourceName) { if (!isAllowCreate()) { log.warn("Creation disabled so not creating a pod from " + sourceName + " namespace " + currentNamespace + " name " + getName(pod)); } else { - doCreatePod(pod, currentNamespace, sourceName); + doCreate(pod, currentNamespace, sourceName); } } } - protected void doCreatePod(Pod pod, String namespace, String sourceName) { - log.info("Creating a Pod from " + sourceName + " namespace " + namespace + " name " + getName(pod)); - try { - Object answer = kubernetesClient.pods().inNamespace(namespace).create(pod); - log.info("Created Pod result: " + answer); - } catch (Exception e) { - onApplyError("Failed to create Pod from " + sourceName + ". " + e + ". " + pod, e); - } - } - protected void applyJob(Job job, String sourceName) { String currentNamespace = applicableNamespace(job, namespace, fallbackNamespace); String id = getName(job); @@ -1177,7 +1102,8 @@ protected void applyJob(Job job, String sourceName) { } // Not using createOrReplace() here (https://github.com/fabric8io/kubernetes-client/issues/1586) try { - doCreateJob(job, currentNamespace, sourceName); + log.info("Creating a Job from " + sourceName + " namespace " + namespace + " name " + getName(job)); + kubernetesClient.batch().v1().jobs().inNamespace(namespace).resource(job).create(); } catch (KubernetesClientException exception) { if(exception.getStatus().getCode().equals(HttpURLConnection.HTTP_CONFLICT)) { Job old = kubernetesClient.batch().v1().jobs().inNamespace(currentNamespace).withName(id).get(); @@ -1189,11 +1115,6 @@ protected void applyJob(Job job, String sourceName) { } } - public void doCreateJob(Job job, String namespace, String sourceName) { - kubernetesClient.batch().v1().jobs().inNamespace(namespace).create(job); - log.info("Creating a Job from " + sourceName + " namespace " + namespace + " name " + getName(job)); - } - public String getNamespace() { return namespace; } @@ -1282,7 +1203,7 @@ public boolean isRecreateMode() { } public void setRecreateMode(boolean recreateMode) { - this.recreateMode = recreateMode; + this.recreateMode = recreateMode; } public void setServicesOnlyMode(boolean servicesOnlyMode) { @@ -1345,21 +1266,7 @@ public void setRollingUpgradePreserveScale(boolean rollingUpgradePreserveScale) } public void applyEntities(String fileName, Collection entities) { - getK8sListWithNamespaceFirst(entities).forEach(applyStandardEntities(fileName)); - } - - private Consumer applyStandardEntities(String fileName) { - return entity -> { - if (entity instanceof Pod) { - applyPod((Pod) entity, fileName); - } else if (entity instanceof Service) { - applyService((Service) entity, fileName); - } else if (entity instanceof ReplicationController) { - applyReplicationController((ReplicationController) entity, fileName); - } else if (entity != null) { - apply(entity, fileName); - } - }; + getK8sListWithNamespaceFirst(entities).forEach(entity -> applyEntity(entity, fileName)); } public static List getK8sListWithNamespaceFirst(Collection k8sList) { diff --git a/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceTest.java b/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceTest.java index eac06a1ab1..2257d21054 100644 --- a/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceTest.java +++ b/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceTest.java @@ -28,11 +28,15 @@ import io.fabric8.kubernetes.api.model.ConfigMap; import io.fabric8.kubernetes.api.model.GenericKubernetesResource; import io.fabric8.kubernetes.api.model.GenericKubernetesResourceBuilder; +import io.fabric8.kubernetes.api.model.PersistentVolumeClaimBuilder; +import io.fabric8.kubernetes.api.model.SecretBuilder; import io.fabric8.kubernetes.api.model.ServiceAccount; import io.fabric8.kubernetes.api.model.ServiceAccountBuilder; +import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionBuilder; import io.fabric8.kubernetes.api.model.authorization.v1.SelfSubjectAccessReviewBuilder; import io.fabric8.kubernetes.api.model.networking.v1.Ingress; import io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder; +import io.fabric8.kubernetes.api.model.rbac.RoleBindingBuilder; import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient; import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer; import io.fabric8.openshift.client.OpenShiftClient; @@ -106,7 +110,12 @@ void applyEntities() { new ReplicationControllerBuilder().withNewMetadata().withName("rc1").endMetadata().build(), new NamespaceBuilder().withNewMetadata().withName("ns1").endMetadata().build(), new NetworkPolicyBuilder().withNewMetadata().withName("npv1").endMetadata().build(), - new io.fabric8.kubernetes.api.model.extensions.NetworkPolicyBuilder().withNewMetadata().withName("np-ext").endMetadata().build() + new io.fabric8.kubernetes.api.model.extensions.NetworkPolicyBuilder().withNewMetadata().withName("np-ext").endMetadata().build(), + new SecretBuilder().withNewMetadata().withName("secret1").endMetadata().build(), + new RoleBindingBuilder().withNewMetadata().withName("rb1").endMetadata().build(), + new ServiceAccountBuilder().withNewMetadata().withName("sa1").endMetadata().build(), + new PersistentVolumeClaimBuilder().withNewMetadata().withName("pvc1").endMetadata().build(), + new CustomResourceDefinitionBuilder().withNewMetadata().withName("crd1").endMetadata().build() )); String fileName = "foo.yml"; WebServerEventCollector collector = new WebServerEventCollector(); @@ -142,13 +151,34 @@ void applyEntities() { .withPath("/apis/extensions/v1beta1/namespaces/default/networkpolicies") .andReply(collector.record("new-np-extensions").andReturn(HTTP_CREATED, "")) .once(); + mockServer.expect().post() + .withPath("/api/v1/namespaces/default/secrets") + .andReply(collector.record("new-secret").andReturn(HTTP_CREATED, "")) + .once(); + mockServer.expect().post() + .withPath("/apis/rbac.authorization.k8s.io/v1/namespaces/default/rolebindings") + .andReply(collector.record("new-rb").andReturn(HTTP_CREATED, "")) + .once(); + mockServer.expect().post() + .withPath("/api/v1/namespaces/default/serviceaccounts") + .andReply(collector.record("new-sa").andReturn(HTTP_CREATED, "")) + .once(); + mockServer.expect().post() + .withPath("/api/v1/namespaces/default/persistentvolumeclaims") + .andReply(collector.record("new-pvc").andReturn(HTTP_CREATED, "")) + .once(); + mockServer.expect().post() + .withPath("/apis/apiextensions.k8s.io/v1/customresourcedefinitions") + .andReply(collector.record("new-crd").andReturn(HTTP_CREATED, "")) + .once(); // When applyService.applyEntities(fileName, entities); // Then - collector.assertEventsRecordedInOrder("new-ns", "new-service", "new-configmap", "new-deploy", "new-pod", "new-rc"); - collector.assertEventsRecorded("new-np-v1", "new-np-extensions"); + collector.assertEventsRecordedInOrder( + "new-ns", "new-secret", "new-sa", "new-service", "new-rb", "new-pvc", "new-configmap", "new-deploy", "new-pod", "new-rc"); + collector.assertEventsRecorded("new-np-v1", "new-np-extensions", "new-crd"); } @Test From 03d63b9b31c8aeb81badc2ef088d2b880d216d31 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Thu, 6 Jul 2023 07:08:05 +0200 Subject: [PATCH 07/65] ci: clone repo using SSH https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/issues/3361 Signed-off-by: Marc Nuri --- .jenkins/pipelines/release-snapshots.Jenkinsfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.jenkins/pipelines/release-snapshots.Jenkinsfile b/.jenkins/pipelines/release-snapshots.Jenkinsfile index d8b90a7105..311b1b9053 100644 --- a/.jenkins/pipelines/release-snapshots.Jenkinsfile +++ b/.jenkins/pipelines/release-snapshots.Jenkinsfile @@ -16,8 +16,7 @@ pipeline { } sshagent(['github-bot-ssh']) { sh 'echo "Cloning Project"' - // sh 'git clone git@github.com:eclipse/jkube.git' // disabled temporarily, credentials not working - sh 'git clone https://github.com/eclipse/jkube.git' + sh 'git clone git@github.com:eclipse/jkube.git' } dir('jkube') { sh 'echo "Deploying Snapshots"' From 163f75f6204f9d7e6c4165fbc2bedee824a74b22 Mon Sep 17 00:00:00 2001 From: balbusm Date: Sat, 21 Jan 2023 02:47:47 +0100 Subject: [PATCH 08/65] Fix #1929 Fixed parsing image name Signed-off-by: balbusm --- CHANGELOG.md | 2 + .../jkube/kit/config/image/ImageName.java | 38 +--- .../image/ImageNameFullNameParseTest.java | 203 ++++++++++++++---- .../jkube/kit/config/image/ImageNameTest.java | 24 ++- .../handler/ContainerHandlerTest.java | 8 +- 5 files changed, 199 insertions(+), 76 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b3179e58b..b279807840 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ Usage: ### 1.13.0 (2023-06-14) * Fix #1478: Should detect and warn the user if creating ingress and ingress controller not available +* Fix #1929: Docker Image Name parsing fix * Fix #2092: Support for `Chart.yaml` fragments * Fix #2150: Bump Kubernetes Client to 6.6.0 (fixes issues when trace-logging OpenShift builds) * Fix #2162: Bump Kubernetes Client to 6.6.1 (HttpClient with support for PUT + InputStream) @@ -494,3 +495,4 @@ Only the set of documented features are available to users. ### 0.1.0 (2019-12-19) * Initial release + diff --git a/jkube-kit/config/image/src/main/java/org/eclipse/jkube/kit/config/image/ImageName.java b/jkube-kit/config/image/src/main/java/org/eclipse/jkube/kit/config/image/ImageName.java index 4bf43e4336..c41b8e4e55 100644 --- a/jkube-kit/config/image/src/main/java/org/eclipse/jkube/kit/config/image/ImageName.java +++ b/jkube-kit/config/image/src/main/java/org/eclipse/jkube/kit/config/image/ImageName.java @@ -142,18 +142,10 @@ private String joinTail(String[] parts) { return builder.toString(); } - private boolean containsPeriodOrColon(String part) { - return containsPeriod(part) || containsColon(part); - } - - private boolean containsPeriod(String part) { + private boolean isRegistryPart(String part) { return part.contains("."); } - private boolean containsColon(String part) { - return part.contains(":"); - } - /** * Get the full name of this image, including the registry but without * any tag (e.g. privateregistry:fabric8io/java) @@ -281,26 +273,18 @@ private void parseComponentsBeforeTag(String rest) { registry = null; user = null; repository = parts[0]; - } else if (parts.length >= 2) { - if (containsPeriodOrColon(parts[0])) { - if (parts.length > 2) { - assignRegistryUserAndRepository(parts); - } else { - checkWhetherFirstElementIsUserOrRegistryAndAssign(parts); - } + } else if (parts.length == 2) { + if (isRegistryPart(parts[0])) { + assignRegistryAndRepository(parts); } else { - registry = null; - user = parts[0]; - repository = rest; + assignUserAndRepository(parts); + } + } else if (parts.length >= 3) { + if (isRegistryPart(parts[0])) { + assignRegistryUserAndRepository(parts); + } else { + assignUserAndRepository(parts); } - } - } - - private void checkWhetherFirstElementIsUserOrRegistryAndAssign(String[] parts) { - if (containsColon(parts[0])) { - assignRegistryAndRepository(parts); - } else { - assignUserAndRepository(parts); } } diff --git a/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameFullNameParseTest.java b/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameFullNameParseTest.java index 2dd88259c7..0fb469cdda 100644 --- a/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameFullNameParseTest.java +++ b/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameFullNameParseTest.java @@ -13,59 +13,180 @@ */ package org.eclipse.jkube.kit.config.image; +import lombok.Builder; +import lombok.Value; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; class ImageNameFullNameParseTest { - public static Stream data() { + public static Stream validData() { return Stream.of( - new Object[][] { - {"Repo and Name", "eclipse/eclipse_jkube", - "eclipse/eclipse_jkube:latest", null, "eclipse", "eclipse/eclipse_jkube", "latest", null}, - {"Repo and Name with special characters", "valid.name-with__separators/eclipse_jkube", - "valid.name-with__separators/eclipse_jkube:latest", null, - "valid.name-with__separators", "valid.name-with__separators/eclipse_jkube", "latest", null}, - {"Repo, Name and Tag", "eclipse/eclipse_jkube:1.3.3.7", - "eclipse/eclipse_jkube:1.3.3.7", null, "eclipse", "eclipse/eclipse_jkube", "1.3.3.7", null}, - {"Repo, Name and Tag with special characters", "valid.name-with__separators/eclipse_jkube:valid__tag-4.2", - "valid.name-with__separators/eclipse_jkube:valid__tag-4.2", null, - "valid.name-with__separators", "valid.name-with__separators/eclipse_jkube", "valid__tag-4.2", null}, - {"Registry, Repo and Name", "docker.io/eclipse/eclipse_jkube", - "docker.io/eclipse/eclipse_jkube:latest", "docker.io", "eclipse", "eclipse/eclipse_jkube", "latest", null}, - {"Registry, Repo and Name with special characters", - "long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube", - "long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:latest", - "long.registry.example.com:8080", - "valid.name--with__separators", "valid.name--with__separators/eclipse_jkube", "latest", null}, - {"Registry, Repo, Name and Tag", "docker.io/eclipse/eclipse_jkube:1.33.7", - "docker.io/eclipse/eclipse_jkube:1.33.7", "docker.io", "eclipse", "eclipse/eclipse_jkube", "1.33.7", null}, - {"Registry, Repo, Name and Tag with special characters", - "long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:very--special__tag.2.A", - "long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:very--special__tag.2.A", - "long.registry.example.com:8080", - "valid.name--with__separators", "valid.name--with__separators/eclipse_jkube", "very--special__tag.2.A", null}, - }); + new Object[][] { + { + "Repo and Name", "eclipse/eclipse_jkube", + SimpleImageName.builder() + .fullName("eclipse/eclipse_jkube:latest") + .registry(null) + .user("eclipse") + .repository("eclipse/eclipse_jkube") + .tag("latest") + .digest(null) + .build() + }, + { + "Repo, Name and Tag", "eclipse/eclipse_jkube:1.3.3.7", + SimpleImageName.builder() + .fullName("eclipse/eclipse_jkube:1.3.3.7") + .registry(null) + .user("eclipse") + .repository("eclipse/eclipse_jkube") + .tag("1.3.3.7") + .digest(null) + .build() + }, + { + "Registry, Repo and Name", "docker.io/eclipse/eclipse_jkube", + SimpleImageName.builder() + .fullName("docker.io/eclipse/eclipse_jkube:latest") + .registry("docker.io") + .user("eclipse") + .repository("eclipse/eclipse_jkube") + .tag("latest") + .digest(null) + .build() + }, + { "Registry, Repo and Name with special characters", + "long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube", + SimpleImageName.builder() + .fullName("long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:latest") + .registry("long.registry.example.com:8080") + .user("valid.name--with__separators") + .repository("valid.name--with__separators/eclipse_jkube") + .tag("latest") + .digest(null) + .build() + }, + { "Registry, Repo, Name and Tag", "docker.io/eclipse/eclipse_jkube:1.33.7", + SimpleImageName.builder() + .fullName("docker.io/eclipse/eclipse_jkube:1.33.7") + .registry("docker.io") + .user("eclipse") + .repository("eclipse/eclipse_jkube") + .tag("1.33.7") + .digest(null) + .build() + }, + { + "Registry, Repo, Name and Tag with special characters", + "long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:very--special__tag.2.A", + SimpleImageName.builder() + .fullName( + "long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:very--special__tag.2.A") + .registry("long.registry.example.com:8080") + .user("valid.name--with__separators") + .repository("valid.name--with__separators/eclipse_jkube") + .tag("very--special__tag.2.A") + .digest(null) + .build() + }, + { + "Repo only", "eclipse-temurin:11", + SimpleImageName.builder() + .fullName("eclipse-temurin:11") + .registry(null) + .user(null) + .repository("eclipse-temurin") + .tag("11") + .digest(null) + .build() + }, + { + "User and repo", "user/my-repo_z:11", + SimpleImageName.builder() + .fullName("user/my-repo_z:11") + .registry(null) + .user("user") + .repository("user/my-repo_z") + .tag("11") + .digest(null) + .build() + }, + { + "Registry and repo", "foo-bar-registry.jfrog.io/java:jre-17", + SimpleImageName.builder() + .fullName("foo-bar-registry.jfrog.io/java:jre-17") + .registry("foo-bar-registry.jfrog.io") + .user(null) + .repository("java") + .tag("jre-17") + .digest(null) + .build() + }, + { + "JFrog repo", "user.jfrog.io/my-jkube/openjdk:jre-17", + SimpleImageName.builder() + .fullName("user.jfrog.io/my-jkube/openjdk:jre-17") + .registry("user.jfrog.io") + .user("my-jkube") + .repository("my-jkube/openjdk") + .tag("jre-17") + .digest(null) + .build() + }, + }); } @ParameterizedTest(name = "{0}") - @MethodSource("data") - void fullNameParse(String testName, String providedFullName, String expectedFullName, String registry, String user, - String repository, String tag, String digest) { - final ImageName result = new ImageName(providedFullName); - assertThat(result) - .extracting( - ImageName::getFullName, - ImageName::getRegistry, - ImageName::getUser, - ImageName::getRepository, - ImageName::getTag, - ImageName::getDigest - ) - .containsExactly(expectedFullName, registry, user, repository, tag, digest); + @MethodSource("validData") + void shouldParseImageName(String testName, String providedImageName, SimpleImageName expectedImageName) { + ImageName imageName = new ImageName(providedImageName); + SimpleImageName currentImageName = SimpleImageName.toSimpleImageName(imageName); + assertThat(currentImageName).isEqualTo(expectedImageName); + } + + public static Stream invalidData() { + return Stream.of( + new Object[][] { + { + "Repo and Name with special characters", "invalid.name-with__separators/eclipse_jkube" + }, + { + "Repo, Name and Tag with special characters", "invalid.name-with__separators/eclipse_jkube:valid__tag-4.2" + }, + }); + } + + @ParameterizedTest(name = "{0}") + @MethodSource("invalidData") + void shouldFailedParseImageName(String testName, String providedImageName) { + assertThatCode(() -> new ImageName(providedImageName)) + .isInstanceOf(IllegalArgumentException.class); + } + + @Builder + @Value + public static class SimpleImageName { + String fullName; + String registry; + String user; + String repository; + String tag; + String digest; + + public static SimpleImageName toSimpleImageName(ImageName imageName) { + return new SimpleImageName(imageName.getFullName(), + imageName.getRegistry(), + imageName.getUser(), + imageName.getRepository(), + imageName.getTag(), + imageName.getDigest()); + } + } } diff --git a/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameTest.java b/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameTest.java index f39178dfc4..d3645afed1 100644 --- a/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameTest.java +++ b/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameTest.java @@ -154,21 +154,37 @@ void namesUsedByDockerTests() { } @Test - void testImageNameWithUsernameHavingPeriods() { + void testImageNameWithUsernameHavingNumber() { // Given - String name = "roman.gordill/customer-service-cache:latest"; + String name = "romangordill10/customer-service-cache:latest"; // When ImageName imageName = new ImageName(name); // Then assertThat(imageName).isNotNull(); - assertThat(imageName.getUser()).isEqualTo("roman.gordill"); - assertThat(imageName.getRepository()).isEqualTo("roman.gordill/customer-service-cache"); + assertThat(imageName.getUser()).isEqualTo("romangordill10"); + assertThat(imageName.getRepository()).isEqualTo("romangordill10/customer-service-cache"); assertThat(imageName.getTag()).isEqualTo("latest"); assertThat(imageName.getRegistry()).isNull(); } + @Test + void testImageNameWithRegistry() { + // Given + String name = "foo.com/customer-service-cache:latest"; + + // When + ImageName imageName = new ImageName(name); + + // Then + assertThat(imageName).isNotNull(); + assertThat(imageName.getUser()).isNull(); + assertThat(imageName.getRepository()).isEqualTo("customer-service-cache"); + assertThat(imageName.getTag()).isEqualTo("latest"); + assertThat(imageName.getRegistry()).isEqualTo("foo.com"); + } + @Test void testImageNameWithNameContainingRegistryAndName() { // Given diff --git a/jkube-kit/enricher/api/src/test/java/org/eclipse/jkube/kit/enricher/handler/ContainerHandlerTest.java b/jkube-kit/enricher/api/src/test/java/org/eclipse/jkube/kit/enricher/handler/ContainerHandlerTest.java index e8e2ce9ebd..31c4c72c44 100644 --- a/jkube-kit/enricher/api/src/test/java/org/eclipse/jkube/kit/enricher/handler/ContainerHandlerTest.java +++ b/jkube-kit/enricher/api/src/test/java/org/eclipse/jkube/kit/enricher/handler/ContainerHandlerTest.java @@ -201,13 +201,13 @@ void withImageNames_shouldReturnContainersWithConfiguredImages() { } @Test - @DisplayName("with user, image and tag with period in image user, should return configured image") - void withUserAndImageAndTagWithPeriodInImageUser_shouldReturnConfiguredImage() { + @DisplayName("with user, image and tag with dash in image user, should return configured image") + void withUserAndImageAndTagWithDashInImageUser_shouldReturnConfiguredImage() { // Given ContainerHandler containerHandler = createContainerHandler(project); List imageConfigurations = new ArrayList<>(); imageConfigurations.add(ImageConfiguration.builder() - .name("roman.gordill/customer-service-cache:latest") + .name("roman-gordill/customer-service-cache:latest") .registry("quay.io") .build(BuildConfiguration.builder() .from("quay.io/jkube/jkube-java:0.0.13") @@ -222,7 +222,7 @@ void withUserAndImageAndTagWithPeriodInImageUser_shouldReturnConfiguredImage() { // Then assertThat(containers).singleElement() - .hasFieldOrPropertyWithValue("image", "quay.io/roman.gordill/customer-service-cache:latest"); + .hasFieldOrPropertyWithValue("image", "quay.io/roman-gordill/customer-service-cache:latest"); } @Test From dc623e761d77f90e1b3f58b1cb994b60a9b186a0 Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Tue, 30 May 2023 15:51:34 +0530 Subject: [PATCH 09/65] refactor (jkube-kit) : revert changes to ImageName and ContainerHandlerTest Signed-off-by: Rohan Kumar --- .../jkube/kit/config/image/ImageName.java | 38 +++++++++++++------ .../image/ImageNameFullNameParseTest.java | 4 +- .../jkube/kit/config/image/ImageNameTest.java | 8 ++-- .../handler/ContainerHandlerTest.java | 8 ++-- 4 files changed, 37 insertions(+), 21 deletions(-) diff --git a/jkube-kit/config/image/src/main/java/org/eclipse/jkube/kit/config/image/ImageName.java b/jkube-kit/config/image/src/main/java/org/eclipse/jkube/kit/config/image/ImageName.java index c41b8e4e55..4bf43e4336 100644 --- a/jkube-kit/config/image/src/main/java/org/eclipse/jkube/kit/config/image/ImageName.java +++ b/jkube-kit/config/image/src/main/java/org/eclipse/jkube/kit/config/image/ImageName.java @@ -142,10 +142,18 @@ private String joinTail(String[] parts) { return builder.toString(); } - private boolean isRegistryPart(String part) { + private boolean containsPeriodOrColon(String part) { + return containsPeriod(part) || containsColon(part); + } + + private boolean containsPeriod(String part) { return part.contains("."); } + private boolean containsColon(String part) { + return part.contains(":"); + } + /** * Get the full name of this image, including the registry but without * any tag (e.g. privateregistry:fabric8io/java) @@ -273,21 +281,29 @@ private void parseComponentsBeforeTag(String rest) { registry = null; user = null; repository = parts[0]; - } else if (parts.length == 2) { - if (isRegistryPart(parts[0])) { - assignRegistryAndRepository(parts); + } else if (parts.length >= 2) { + if (containsPeriodOrColon(parts[0])) { + if (parts.length > 2) { + assignRegistryUserAndRepository(parts); + } else { + checkWhetherFirstElementIsUserOrRegistryAndAssign(parts); + } } else { - assignUserAndRepository(parts); - } - } else if (parts.length >= 3) { - if (isRegistryPart(parts[0])) { - assignRegistryUserAndRepository(parts); - } else { - assignUserAndRepository(parts); + registry = null; + user = parts[0]; + repository = rest; } } } + private void checkWhetherFirstElementIsUserOrRegistryAndAssign(String[] parts) { + if (containsColon(parts[0])) { + assignRegistryAndRepository(parts); + } else { + assignUserAndRepository(parts); + } + } + private void assignRegistryUserAndRepository(String[] parts) { registry = parts[0]; user = parts[1]; diff --git a/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameFullNameParseTest.java b/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameFullNameParseTest.java index 0fb469cdda..362d38345d 100644 --- a/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameFullNameParseTest.java +++ b/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameFullNameParseTest.java @@ -154,10 +154,10 @@ public static Stream invalidData() { return Stream.of( new Object[][] { { - "Repo and Name with special characters", "invalid.name-with__separators/eclipse_jkube" + "Repo and Name with special characters", "invalid.name-with__separators/eclipse_-jkube" }, { - "Repo, Name and Tag with special characters", "invalid.name-with__separators/eclipse_jkube:valid__tag-4.2" + "Repo, Name and Tag with special characters", "invalid.name-with__separators/eclipse_jkube:valid!__tag-4.2" }, }); } diff --git a/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameTest.java b/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameTest.java index d3645afed1..79a0492117 100644 --- a/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameTest.java +++ b/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameTest.java @@ -154,17 +154,17 @@ void namesUsedByDockerTests() { } @Test - void testImageNameWithUsernameHavingNumber() { + void testImageNameWithUsernameHavingPeriods() { // Given - String name = "romangordill10/customer-service-cache:latest"; + String name = "roman.gordill/customer-service-cache:latest"; // When ImageName imageName = new ImageName(name); // Then assertThat(imageName).isNotNull(); - assertThat(imageName.getUser()).isEqualTo("romangordill10"); - assertThat(imageName.getRepository()).isEqualTo("romangordill10/customer-service-cache"); + assertThat(imageName.getUser()).isEqualTo("roman.gordill"); + assertThat(imageName.getRepository()).isEqualTo("roman.gordill/customer-service-cache"); assertThat(imageName.getTag()).isEqualTo("latest"); assertThat(imageName.getRegistry()).isNull(); } diff --git a/jkube-kit/enricher/api/src/test/java/org/eclipse/jkube/kit/enricher/handler/ContainerHandlerTest.java b/jkube-kit/enricher/api/src/test/java/org/eclipse/jkube/kit/enricher/handler/ContainerHandlerTest.java index 31c4c72c44..e8e2ce9ebd 100644 --- a/jkube-kit/enricher/api/src/test/java/org/eclipse/jkube/kit/enricher/handler/ContainerHandlerTest.java +++ b/jkube-kit/enricher/api/src/test/java/org/eclipse/jkube/kit/enricher/handler/ContainerHandlerTest.java @@ -201,13 +201,13 @@ void withImageNames_shouldReturnContainersWithConfiguredImages() { } @Test - @DisplayName("with user, image and tag with dash in image user, should return configured image") - void withUserAndImageAndTagWithDashInImageUser_shouldReturnConfiguredImage() { + @DisplayName("with user, image and tag with period in image user, should return configured image") + void withUserAndImageAndTagWithPeriodInImageUser_shouldReturnConfiguredImage() { // Given ContainerHandler containerHandler = createContainerHandler(project); List imageConfigurations = new ArrayList<>(); imageConfigurations.add(ImageConfiguration.builder() - .name("roman-gordill/customer-service-cache:latest") + .name("roman.gordill/customer-service-cache:latest") .registry("quay.io") .build(BuildConfiguration.builder() .from("quay.io/jkube/jkube-java:0.0.13") @@ -222,7 +222,7 @@ void withUserAndImageAndTagWithDashInImageUser_shouldReturnConfiguredImage() { // Then assertThat(containers).singleElement() - .hasFieldOrPropertyWithValue("image", "quay.io/roman-gordill/customer-service-cache:latest"); + .hasFieldOrPropertyWithValue("image", "quay.io/roman.gordill/customer-service-cache:latest"); } @Test From 023b012546c6f46bbc319e580f8e8efdd75bc2b7 Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Tue, 23 May 2023 01:25:30 +0530 Subject: [PATCH 10/65] fix (jkube-kit/config/image) : Remove user field from ImageName In Docker reference package, there is no mention of user field. A valid repository is split into a domain and path component. Remove this user field, but keep getUser method which will try to extract possible username from path component (repository). Signed-off-by: Rohan Kumar --- CHANGELOG.md | 3 +- .../kit/build/api/helper/RegistryUtil.java | 18 +++-- .../build/api/helper/RegistryUtilTest.java | 64 ++++++++++++----- .../access/hc/DockerAccessWithHcClient.java | 5 +- .../jkube/kit/config/image/ImageName.java | 71 ++++++++++--------- .../jkube/kit/config/image/ImageNameTest.java | 22 +++--- ...BuildServiceGetApplicableRegistryTest.java | 8 +-- 7 files changed, 116 insertions(+), 75 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b279807840..21736adc46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,9 @@ Usage: ### 1.14-SNAPSHOT * Fix #1713: Add HelidonHealthCheckEnricher to add Kubernetes health checks for Helidon applications * Fix #1714: Add HelidonGenerator to add opinionated container image for Helidon applications +* Fix #1929: Docker Image Name parsing fix * Fix #1985: Update outdated methods in Spring Boot CRD Maven Quickstart +* Fix #2116: Remove user field from ImageName class * Fix #2224: Quarkus native base image read from properties (configurable) * Fix #2228: Quarkus native base image uses UBI 8.7 @@ -32,7 +34,6 @@ Usage: ### 1.13.0 (2023-06-14) * Fix #1478: Should detect and warn the user if creating ingress and ingress controller not available -* Fix #1929: Docker Image Name parsing fix * Fix #2092: Support for `Chart.yaml` fragments * Fix #2150: Bump Kubernetes Client to 6.6.0 (fixes issues when trace-logging OpenShift builds) * Fix #2162: Bump Kubernetes Client to 6.6.1 (HttpClient with support for PUT + InputStream) diff --git a/jkube-kit/build/api/src/main/java/org/eclipse/jkube/kit/build/api/helper/RegistryUtil.java b/jkube-kit/build/api/src/main/java/org/eclipse/jkube/kit/build/api/helper/RegistryUtil.java index f9515ecaa8..6969b549a4 100644 --- a/jkube-kit/build/api/src/main/java/org/eclipse/jkube/kit/build/api/helper/RegistryUtil.java +++ b/jkube-kit/build/api/src/main/java/org/eclipse/jkube/kit/build/api/helper/RegistryUtil.java @@ -23,13 +23,23 @@ private RegistryUtil() { } public static String getApplicablePushRegistryFrom(ImageConfiguration imageConfiguration, RegistryConfig registryConfig) { ImageName imageName = new ImageName(imageConfiguration.getName()); - return EnvUtil.firstRegistryOf(imageName.getRegistry(), - imageConfiguration.getRegistry(), - registryConfig.getRegistry()); + if (imageName.isFullyQualifiedName()) { + return EnvUtil.firstRegistryOf(imageName.getRegistry(), + imageConfiguration.getRegistry(), + registryConfig.getRegistry()); + } else { + return EnvUtil.firstRegistryOf(imageConfiguration.getRegistry(), + registryConfig.getRegistry(), + imageName.getRegistry()); + } } public static String getApplicablePullRegistryFrom(String fromImage, RegistryConfig registryConfig) { ImageName imageName = new ImageName(fromImage); - return EnvUtil.firstRegistryOf(imageName.getRegistry(), registryConfig.getRegistry()); + if (imageName.isFullyQualifiedName()) { + return EnvUtil.firstRegistryOf(imageName.getRegistry(), registryConfig.getRegistry()); + } else { + return EnvUtil.firstRegistryOf(registryConfig.getRegistry(), imageName.getRegistry()); + } } } diff --git a/jkube-kit/build/api/src/test/java/org/eclipse/jkube/kit/build/api/helper/RegistryUtilTest.java b/jkube-kit/build/api/src/test/java/org/eclipse/jkube/kit/build/api/helper/RegistryUtilTest.java index 5220d97107..ed256bbac3 100644 --- a/jkube-kit/build/api/src/test/java/org/eclipse/jkube/kit/build/api/helper/RegistryUtilTest.java +++ b/jkube-kit/build/api/src/test/java/org/eclipse/jkube/kit/build/api/helper/RegistryUtilTest.java @@ -13,6 +13,7 @@ */ package org.eclipse.jkube.kit.build.api.helper; +import org.apache.commons.lang3.StringUtils; import org.eclipse.jkube.kit.common.RegistryConfig; import org.eclipse.jkube.kit.config.image.ImageConfiguration; import org.junit.jupiter.api.Test; @@ -22,10 +23,8 @@ class RegistryUtilTest { @Test void getApplicablePushRegistryFrom_whenImageNameContainsRegistry_thenUseRegistryFromImageName() { // Given - ImageConfiguration imageConfiguration = ImageConfiguration.builder() - .name("word.word/word/word:tag") - .build(); - RegistryConfig registryConfig = RegistryConfig.builder().registry("registry-config.io").build(); + ImageConfiguration imageConfiguration = createNewImageConfiguration("word.word/word/word:tag", null); + RegistryConfig registryConfig = createNewRegistryConfig(); // When + Then assertThat(RegistryUtil.getApplicablePushRegistryFrom(imageConfiguration, registryConfig)) @@ -35,24 +34,30 @@ void getApplicablePushRegistryFrom_whenImageNameContainsRegistry_thenUseRegistry @Test void getApplicablePushRegistryFrom_whenImageNameHasNoRegistryAndImageConfigHasRegistry_thenUseImageConfigRegistry() { // Given - ImageConfiguration imageConfiguration = ImageConfiguration.builder() - .name("word/word:tag") - .registry("word.word") - .build(); - RegistryConfig registryConfig = RegistryConfig.builder().registry("registry-config.io").build(); + ImageConfiguration imageConfiguration = createNewImageConfiguration("word/word:tag", "word.word"); + RegistryConfig registryConfig = createNewRegistryConfig(); // When + Then assertThat(RegistryUtil.getApplicablePushRegistryFrom(imageConfiguration, registryConfig)) .isEqualTo("word.word"); } + @Test + void getApplicablePushRegistryFrom_whenImageNameNotFullyQualified_thenGivePriorityToOtherSources() { + // Given + ImageConfiguration imageConfiguration = createNewImageConfiguration("word.word/word:tag", null); + RegistryConfig registryConfig = createNewRegistryConfig(); + + // When + Then + assertThat(RegistryUtil.getApplicablePushRegistryFrom(imageConfiguration, registryConfig)) + .isEqualTo("registry-config.io"); + } + @Test void getApplicablePushRegistryFrom_whenNoRegistryInImageConfig_thenUseImageConfigRegistry() { // Given - ImageConfiguration imageConfiguration = ImageConfiguration.builder() - .name("word/word:tag") - .build(); - RegistryConfig registryConfig = RegistryConfig.builder().registry("registry-config.io").build(); + ImageConfiguration imageConfiguration = createNewImageConfiguration("word/word:tag", null); + RegistryConfig registryConfig = createNewRegistryConfig(); // When + Then assertThat(RegistryUtil.getApplicablePushRegistryFrom(imageConfiguration, registryConfig)) @@ -62,9 +67,7 @@ void getApplicablePushRegistryFrom_whenNoRegistryInImageConfig_thenUseImageConfi @Test void getApplicablePullRegistryFrom_whenRegistryInImageName_thenUseRegistryFromImageName() { // Given - RegistryConfig registryConfig = RegistryConfig.builder() - .registry("registry-config.io") - .build(); + RegistryConfig registryConfig = createNewRegistryConfig(); // When + Then assertThat(RegistryUtil.getApplicablePullRegistryFrom("word.word/word/word:tag", registryConfig)) @@ -74,12 +77,35 @@ void getApplicablePullRegistryFrom_whenRegistryInImageName_thenUseRegistryFromIm @Test void getApplicablePullRegistryFrom_whenRegistryInRegistryConfig_thenUseRegistryFromRegistryConfig() { // Given - RegistryConfig registryConfig = RegistryConfig.builder() - .registry("registry-config.io") - .build(); + RegistryConfig registryConfig = createNewRegistryConfig(); // When + Then assertThat(RegistryUtil.getApplicablePullRegistryFrom("word:tag", registryConfig)) .isEqualTo("registry-config.io"); } + + @Test + void getApplicablePullRegistryFrom_whenRegistryInRegistryConfigAndImageNameNotFullyQualified_thenUseRegistryFromRegistryConfig() { + // Given + RegistryConfig registryConfig = createNewRegistryConfig(); + + // When + Then + assertThat(RegistryUtil.getApplicablePullRegistryFrom("word.word/word:tag", registryConfig)) + .isEqualTo("registry-config.io"); + } + + private ImageConfiguration createNewImageConfiguration(String name, String registry) { + ImageConfiguration.ImageConfigurationBuilder imageConfigurationBuilder = ImageConfiguration.builder(); + imageConfigurationBuilder.name(name); + if (StringUtils.isNotBlank(registry)) { + imageConfigurationBuilder.registry(registry); + } + return imageConfigurationBuilder.build(); + } + + private RegistryConfig createNewRegistryConfig() { + return RegistryConfig.builder() + .registry("registry-config.io") + .build(); + } } \ No newline at end of file diff --git a/jkube-kit/build/service/docker/src/main/java/org/eclipse/jkube/kit/build/service/docker/access/hc/DockerAccessWithHcClient.java b/jkube-kit/build/service/docker/src/main/java/org/eclipse/jkube/kit/build/service/docker/access/hc/DockerAccessWithHcClient.java index 63cb0229a4..a7895add8b 100644 --- a/jkube-kit/build/service/docker/src/main/java/org/eclipse/jkube/kit/build/service/docker/access/hc/DockerAccessWithHcClient.java +++ b/jkube-kit/build/service/docker/src/main/java/org/eclipse/jkube/kit/build/service/docker/access/hc/DockerAccessWithHcClient.java @@ -650,15 +650,14 @@ private void doPushImage(String url, Map header, HcChunkedRespon private TemporaryImageHandler tagTemporaryImage(ImageName name, String registry) throws DockerAccessException { String targetImage = name.getFullName(registry); - if (name.hasRegistry() || registry == null) { + String fullName = name.getFullName(); + if ((name.isFullyQualifiedName() && name.hasRegistry()) || targetImage.equals(fullName) || registry == null) { return () -> log.info("Temporary image tag skipped. Target image '%s' already has registry set or no registry is available", targetImage); } - String fullName = name.getFullName(); boolean alreadyHasImage = hasImage(targetImage); - if (alreadyHasImage) { log.warn("Target image '%s' already exists. Tagging of '%s' will replace existing image", targetImage, fullName); diff --git a/jkube-kit/config/image/src/main/java/org/eclipse/jkube/kit/config/image/ImageName.java b/jkube-kit/config/image/src/main/java/org/eclipse/jkube/kit/config/image/ImageName.java index 4bf43e4336..3c3bb27c69 100644 --- a/jkube-kit/config/image/src/main/java/org/eclipse/jkube/kit/config/image/ImageName.java +++ b/jkube-kit/config/image/src/main/java/org/eclipse/jkube/kit/config/image/ImageName.java @@ -13,6 +13,8 @@ */ package org.eclipse.jkube.kit.config.image; +import org.apache.commons.lang3.StringUtils; + import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; @@ -53,9 +55,6 @@ public class ImageName { // Digest private String digest; - // User name - private String user; - /** * Create an image name * @@ -131,6 +130,16 @@ public boolean hasRegistry() { return registry != null && registry.length() > 0; } + public boolean isFullyQualifiedName() { + if (StringUtils.isNotBlank(registry) && containsColon(registry)) { + return true; + } + return StringUtils.isNotBlank(registry) && + StringUtils.isNotBlank(getUser()) && + StringUtils.isNotBlank(getRepository()) && + (StringUtils.isNotBlank(getTag()) || StringUtils.isNotBlank(getDigest())); + } + private String joinTail(String[] parts) { StringBuilder builder = new StringBuilder(); for (int i = 1;i < parts.length; i++) { @@ -175,7 +184,10 @@ public String getNameWithoutTag() { */ public String getNameWithoutTag(String optionalRegistry) { StringBuilder ret = new StringBuilder(); - if (registry != null || optionalRegistry != null) { + if (!isFullyQualifiedName() && isRegistryValidPathComponent() && + StringUtils.isNotBlank(optionalRegistry) && !optionalRegistry.equals(registry)) { + ret.append(optionalRegistry).append("/").append(registry).append("/"); + } else if (registry != null || optionalRegistry != null) { ret.append(registry != null ? registry : optionalRegistry).append("/"); } ret.append(repository); @@ -220,7 +232,13 @@ public String getFullName(String optionalRegistry) { * @return user part or null if no user is present in the name */ public String getUser() { - return user; + if (StringUtils.isNotBlank(repository)) { + if (repository.contains("/")) { + return repository.split("/")[0]; + } + return null; + } + return null; } /** @@ -229,8 +247,11 @@ public String getUser() { * @return simple name of the image */ public String getSimpleName() { - String prefix = user + "/"; - return repository.startsWith(prefix) ? repository.substring(prefix.length()) : repository; + int delimiterIndex = repository.indexOf('/'); + if (delimiterIndex >= 0) { + return repository.substring(delimiterIndex + 1); + } + return repository; } /** @@ -247,6 +268,7 @@ public static void validate(String image) { private void doValidate() { List errors = new ArrayList<>(); // Strip off user from repository name + String user = getUser(); String image = user != null ? repository.substring(user.length() + 1) : repository; Object[] checks = new Object[] { "registry", DOMAIN_REGEXP, registry, @@ -279,45 +301,24 @@ private void parseComponentsBeforeTag(String rest) { String[] parts = rest.split("\\s*/\\s*"); if (parts.length == 1) { registry = null; - user = null; repository = parts[0]; } else if (parts.length >= 2) { - if (containsPeriodOrColon(parts[0])) { - if (parts.length > 2) { - assignRegistryUserAndRepository(parts); - } else { - checkWhetherFirstElementIsUserOrRegistryAndAssign(parts); - } + if (isValidDomain(parts[0])) { + registry = parts[0]; + repository = joinTail(parts); } else { registry = null; - user = parts[0]; repository = rest; } } } - private void checkWhetherFirstElementIsUserOrRegistryAndAssign(String[] parts) { - if (containsColon(parts[0])) { - assignRegistryAndRepository(parts); - } else { - assignUserAndRepository(parts); - } - } - - private void assignRegistryUserAndRepository(String[] parts) { - registry = parts[0]; - user = parts[1]; - repository = joinTail(parts); - } - - private void assignUserAndRepository(String[] parts) { - user = parts[0]; - repository = String.join("/", parts); + private boolean isValidDomain(String str) { + return containsPeriodOrColon(str) && DOMAIN_REGEXP.matcher(str).matches(); } - private void assignRegistryAndRepository(String[] parts) { - registry = parts[0]; - repository = parts[1]; + private boolean isRegistryValidPathComponent() { + return StringUtils.isNotBlank(registry) && !containsColon(registry); } // ================================================================================================ diff --git a/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameTest.java b/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameTest.java index 79a0492117..8bfdfbf28d 100644 --- a/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameTest.java +++ b/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameTest.java @@ -17,6 +17,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.CsvSource; import org.junit.jupiter.params.provider.MethodSource; import java.util.stream.Stream; @@ -159,30 +160,33 @@ void testImageNameWithUsernameHavingPeriods() { String name = "roman.gordill/customer-service-cache:latest"; // When - ImageName imageName = new ImageName(name); + String nameWithRegistry = new ImageName(name).getFullName("quay.io"); + ImageName imageName = new ImageName(nameWithRegistry); // Then assertThat(imageName).isNotNull(); assertThat(imageName.getUser()).isEqualTo("roman.gordill"); assertThat(imageName.getRepository()).isEqualTo("roman.gordill/customer-service-cache"); assertThat(imageName.getTag()).isEqualTo("latest"); - assertThat(imageName.getRegistry()).isNull(); + assertThat(imageName.getRegistry()).isEqualTo("quay.io"); } - @Test - void testImageNameWithRegistry() { + @ParameterizedTest + @CsvSource({ + "foo.com/customer-service-cache:latest,foo.com,customer-service-cache,latest", + "myregistry.127.0.0.1.nip.io/eclipse-temurin:11.0.18_10-jdk-alpine,myregistry.127.0.0.1.nip.io,eclipse-temurin,11.0.18_10-jdk-alpine" + }) + void testImageNameWithRegistry(String name, String registry, String repository, String tag) { // Given - String name = "foo.com/customer-service-cache:latest"; - // When ImageName imageName = new ImageName(name); // Then assertThat(imageName).isNotNull(); assertThat(imageName.getUser()).isNull(); - assertThat(imageName.getRepository()).isEqualTo("customer-service-cache"); - assertThat(imageName.getTag()).isEqualTo("latest"); - assertThat(imageName.getRegistry()).isEqualTo("foo.com"); + assertThat(imageName.getRegistry()).isEqualTo(registry); + assertThat(imageName.getRepository()).isEqualTo(repository); + assertThat(imageName.getTag()).isEqualTo(tag); } @Test diff --git a/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/kubernetes/JibBuildServiceGetApplicableRegistryTest.java b/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/kubernetes/JibBuildServiceGetApplicableRegistryTest.java index 28ca5dca1f..9a06fe41ff 100644 --- a/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/kubernetes/JibBuildServiceGetApplicableRegistryTest.java +++ b/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/kubernetes/JibBuildServiceGetApplicableRegistryTest.java @@ -28,9 +28,9 @@ class JibBuildServiceGetApplicableRegistryTest { "word.word/word/word:tag,word.word", "word:5000/word:tag,word:5000", "word.word:5000/word:tag,word.word:5000", -// "word.word/word:tag,", + "word.word/word:tag,word.word", "word.word/word.word/word:tag,word.word", -// "word.word.word/word:tag,", + "word.word.word/word:tag,word.word.word", "word.word.word/word/word:tag,word.word.word" }) void pull_whenRegistryNotPresentFromAnySource_thenReturnRegistryFromImageName(String from, String expectedPullRegistry) { @@ -87,12 +87,12 @@ void pull_whenRegistryFromRegistryConfig_thenReturnRegistryFromRegistryConfig(St @CsvSource({ "word:word,", "word/word:tag,", -// "word.word/word:tag,", + "word.word/word:tag,word.word", "word.word/word/word:tag,word.word", "word.word/word.word/word:tag,word.word", "word:5000/word:tag,word:5000", "word.word:5000/word:tag,word.word:5000", -// "word.word.word/word:tag,", + "word.word.word/word:tag,word.word.word", "word.word.word/word/word:tag,word.word.word" }) void push_whenRegistryNotPresentFromAnySource_thenReturnRegistryFromImageName(String imageName, String expectedPushRegistry) { From 74e092e8596e975d46b132807ffab4010f54214b Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Thu, 6 Jul 2023 13:03:15 +0200 Subject: [PATCH 11/65] review: tests are explicit, renamed getName to inferName to provide clear expectations Signed-off-by: Marc Nuri --- .../build/service/docker/RegistryService.java | 2 +- .../jkube/kit/config/image/ImageName.java | 26 +- .../image/ImageNameFullNameParseTest.java | 345 +++++++++--------- .../jkube/kit/config/image/ImageNameTest.java | 22 +- .../api/util/KubernetesResourceUtil.java | 2 +- .../generic/TriggersAnnotationEnricher.java | 2 +- .../generator/api/support/BaseGenerator.java | 4 +- 7 files changed, 211 insertions(+), 192 deletions(-) diff --git a/jkube-kit/build/service/docker/src/main/java/org/eclipse/jkube/kit/build/service/docker/RegistryService.java b/jkube-kit/build/service/docker/src/main/java/org/eclipse/jkube/kit/build/service/docker/RegistryService.java index 685ac21481..891933e51f 100644 --- a/jkube-kit/build/service/docker/src/main/java/org/eclipse/jkube/kit/build/service/docker/RegistryService.java +++ b/jkube-kit/build/service/docker/src/main/java/org/eclipse/jkube/kit/build/service/docker/RegistryService.java @@ -61,7 +61,7 @@ public void pushImage(ImageConfiguration imageConfig, if (buildConfig != null) { String configuredRegistry = getApplicablePushRegistryFrom(imageConfig, registryConfig); - AuthConfig authConfig = createAuthConfig(true, new ImageName(name).getUser(), configuredRegistry, registryConfig); + AuthConfig authConfig = createAuthConfig(true, new ImageName(name).inferUser(), configuredRegistry, registryConfig); long start = System.currentTimeMillis(); docker.pushImage(name, authConfig, configuredRegistry, retries); diff --git a/jkube-kit/config/image/src/main/java/org/eclipse/jkube/kit/config/image/ImageName.java b/jkube-kit/config/image/src/main/java/org/eclipse/jkube/kit/config/image/ImageName.java index 3c3bb27c69..cd7e421482 100644 --- a/jkube-kit/config/image/src/main/java/org/eclipse/jkube/kit/config/image/ImageName.java +++ b/jkube-kit/config/image/src/main/java/org/eclipse/jkube/kit/config/image/ImageName.java @@ -135,7 +135,7 @@ public boolean isFullyQualifiedName() { return true; } return StringUtils.isNotBlank(registry) && - StringUtils.isNotBlank(getUser()) && + StringUtils.isNotBlank(inferUser()) && StringUtils.isNotBlank(getRepository()) && (StringUtils.isNotBlank(getTag()) || StringUtils.isNotBlank(getDigest())); } @@ -206,7 +206,7 @@ public String getFullName() { } /** - * Get the full name of this image like {@link #getFullName(String)} does, but allow + * Get the full name of this image like {@link #getFullName()} does, but allow * an optional registry. This registry is used when this image does not already * contain a registry. If no tag was provided in the initial name, latest is used. * @@ -226,12 +226,14 @@ public String getFullName(String optionalRegistry) { } /** - * Get the user (or "project") part of the image name. This is the part after the registry and before - * the image name + * Try to infer the user (or "project") part of the image name. This is usually the part after the registry + * and before the image name. + *

The main purpose of this method is to allow the inference of user credentials for the registry from the image + * name. * - * @return user part or null if no user is present in the name + * @return user part or null if no user can't be inferred from the image name. */ - public String getUser() { + public String inferUser() { if (StringUtils.isNotBlank(repository)) { if (repository.contains("/")) { return repository.split("/")[0]; @@ -268,7 +270,7 @@ public static void validate(String image) { private void doValidate() { List errors = new ArrayList<>(); // Strip off user from repository name - String user = getUser(); + String user = inferUser(); String image = user != null ? repository.substring(user.length() + 1) : repository; Object[] checks = new Object[] { "registry", DOMAIN_REGEXP, registry, @@ -329,21 +331,21 @@ private boolean isRegistryValidPathComponent() { // --------------------------------------------------------------------- // https://github.com/docker/docker/blob/04da4041757370fb6f85510c8977c5a18ddae380/vendor/github.com/docker/distribution/reference/regexp.go#L18 - private static final String nameComponentRegexp = "[a-z0-9]+(?:(?:(?:[._]|__|[-]*)[a-z0-9]+)+)?"; + private static final String NAME_COMPONENT_REGEXP = "[a-z0-9]+(?:(?:(?:[._]|__|[-]*)[a-z0-9]+)+)?"; // https://github.com/docker/docker/blob/04da4041757370fb6f85510c8977c5a18ddae380/vendor/github.com/docker/distribution/reference/regexp.go#L25 - private static final String domainComponentRegexp = "(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])"; + private static final String DOMAIN_COMPONENT_REGEXP = "(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])"; // ========================================================== // https://github.com/docker/docker/blob/04da4041757370fb6f85510c8977c5a18ddae380/vendor/github.com/docker/distribution/reference/regexp.go#L18 - private static final Pattern NAME_COMP_REGEXP = Pattern.compile(nameComponentRegexp); + private static final Pattern NAME_COMP_REGEXP = Pattern.compile(NAME_COMPONENT_REGEXP); // https://github.com/docker/docker/blob/04da4041757370fb6f85510c8977c5a18ddae380/vendor/github.com/docker/distribution/reference/regexp.go#L53 - private static final Pattern IMAGE_NAME_REGEXP = Pattern.compile(nameComponentRegexp + "(?:(?:/" + nameComponentRegexp + ")+)?"); + private static final Pattern IMAGE_NAME_REGEXP = Pattern.compile(NAME_COMPONENT_REGEXP + "(?:(?:/" + NAME_COMPONENT_REGEXP + ")+)?"); // https://github.com/docker/docker/blob/04da4041757370fb6f85510c8977c5a18ddae380/vendor/github.com/docker/distribution/reference/regexp.go#L31 - private static final Pattern DOMAIN_REGEXP = Pattern.compile("^" + domainComponentRegexp + "(?:\\." + domainComponentRegexp + ")*(?::[0-9]+)?$"); + private static final Pattern DOMAIN_REGEXP = Pattern.compile("^" + DOMAIN_COMPONENT_REGEXP + "(?:\\." + DOMAIN_COMPONENT_REGEXP + ")*(?::[0-9]+)?$"); // https://github.com/docker/docker/blob/04da4041757370fb6f85510c8977c5a18ddae380/vendor/github.com/docker/distribution/reference/regexp.go#L37 private static final Pattern TAG_REGEXP = Pattern.compile("^[\\w][\\w.-]{0,127}$"); diff --git a/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameFullNameParseTest.java b/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameFullNameParseTest.java index 362d38345d..cd5a688ca2 100644 --- a/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameFullNameParseTest.java +++ b/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameFullNameParseTest.java @@ -13,180 +13,199 @@ */ package org.eclipse.jkube.kit.config.image; -import lombok.Builder; -import lombok.Value; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.Assertions.assertThatThrownBy; class ImageNameFullNameParseTest { - public static Stream validData() { + @ParameterizedTest(name ="{index}: With full name ''{0}'' should return same or complete full name (''{1}'')") + @DisplayName("getFullName") + @MethodSource("getFullNameData") + void getFullName(String providedFullName, String expectedFullName) { + assertThat(new ImageName(providedFullName).getFullName()).isEqualTo(expectedFullName); + } + + static Stream getFullNameData() { + return Stream.of( + Arguments.of("eclipse/eclipse_jkube:latest", "eclipse/eclipse_jkube:latest"), + Arguments.of("eclipse/eclipse_jkube:1.3.3.7", "eclipse/eclipse_jkube:1.3.3.7"), + Arguments.of("docker.io/eclipse/eclipse_jkube", "docker.io/eclipse/eclipse_jkube:latest"), + Arguments.of("long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube", "long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:latest"), + Arguments.of("docker.io/eclipse/eclipse_jkube:1.33.7", "docker.io/eclipse/eclipse_jkube:1.33.7"), + Arguments.of("long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:very--special__tag.2.A", "long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:very--special__tag.2.A"), + Arguments.of("eclipse-temurin:11", "eclipse-temurin:11"), + Arguments.of("user/my-repo_z:11", "user/my-repo_z:11"), + Arguments.of("foo-bar-registry.jfrog.io/java:jre-17", "foo-bar-registry.jfrog.io/java:jre-17"), + Arguments.of("user.jfrog.io/my-jkube/openjdk:jre-17", "user.jfrog.io/my-jkube/openjdk:jre-17"), + Arguments.of("quay.io/jkube/jkube-java:0.0.19@sha256:b7d8650e04b282b9d7b94daedf38321512f9910bce896cd40ffa15b1b92bab17", "quay.io/jkube/jkube-java:0.0.19@sha256:b7d8650e04b282b9d7b94daedf38321512f9910bce896cd40ffa15b1b92bab17") + ); + } + + @ParameterizedTest(name ="{index}: With full name ''{0}'' should return ''{1}'' as repository") + @DisplayName("getRepository") + @MethodSource("getRepositoryData") + void getRepository(String providedFullName, String expectedRepository) { + assertThat(new ImageName(providedFullName).getRepository()).isEqualTo(expectedRepository); + } + + static Stream getRepositoryData() { + return Stream.of( + Arguments.of("eclipse/eclipse_jkube:latest", "eclipse/eclipse_jkube"), + Arguments.of("eclipse/eclipse_jkube:1.3.3.7", "eclipse/eclipse_jkube"), + Arguments.of("docker.io/eclipse/eclipse_jkube", "eclipse/eclipse_jkube"), + Arguments.of("long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube", "valid.name--with__separators/eclipse_jkube"), + Arguments.of("docker.io/eclipse/eclipse_jkube:1.33.7", "eclipse/eclipse_jkube"), + Arguments.of("long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:very--special__tag.2.A", "valid.name--with__separators/eclipse_jkube"), + Arguments.of("eclipse-temurin:11", "eclipse-temurin"), + Arguments.of("user/my-repo_z:11", "user/my-repo_z"), + Arguments.of("foo-bar-registry.jfrog.io/java:jre-17", "java"), + Arguments.of("user.jfrog.io/my-jkube/openjdk:jre-17", "my-jkube/openjdk"), + Arguments.of("quay.io/jkube/jkube-java:0.0.19@sha256:b7d8650e04b282b9d7b94daedf38321512f9910bce896cd40ffa15b1b92bab17", "jkube/jkube-java") + ); + } + + @ParameterizedTest(name ="{index}: With full name ''{0}'' should return ''{1}'' as registry") + @DisplayName("getRegistry") + @MethodSource("getRegistryData") + void getRegistry(String providedFullName, String expectedRegistry) { + assertThat(new ImageName(providedFullName).getRegistry()).isEqualTo(expectedRegistry); + } + + static Stream getRegistryData() { + return Stream.of( + Arguments.of("eclipse/eclipse_jkube:latest", null), + Arguments.of("eclipse/eclipse_jkube:1.3.3.7", null), + Arguments.of("docker.io/eclipse/eclipse_jkube", "docker.io"), + Arguments.of("long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube", "long.registry.example.com:8080"), + Arguments.of("docker.io/eclipse/eclipse_jkube:1.33.7", "docker.io"), + Arguments.of("long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:very--special__tag.2.A", "long.registry.example.com:8080"), + Arguments.of("eclipse-temurin:11", null), + Arguments.of("user/my-repo_z:11", null), + Arguments.of("foo-bar-registry.jfrog.io/java:jre-17", "foo-bar-registry.jfrog.io"), + Arguments.of("user.jfrog.io/my-jkube/openjdk:jre-17", "user.jfrog.io"), + Arguments.of("quay.io/jkube/jkube-java:0.0.19@sha256:b7d8650e04b282b9d7b94daedf38321512f9910bce896cd40ffa15b1b92bab17", "quay.io") + ); + } + + @ParameterizedTest(name ="{index}: With full name ''{0}'' should return ''{1}'' as tag") + @DisplayName("getTag") + @MethodSource("getTagData") + void getTag(String providedFullName, String expectedTag) { + assertThat(new ImageName(providedFullName).getTag()).isEqualTo(expectedTag); + } + + static Stream getTagData() { return Stream.of( - new Object[][] { - { - "Repo and Name", "eclipse/eclipse_jkube", - SimpleImageName.builder() - .fullName("eclipse/eclipse_jkube:latest") - .registry(null) - .user("eclipse") - .repository("eclipse/eclipse_jkube") - .tag("latest") - .digest(null) - .build() - }, - { - "Repo, Name and Tag", "eclipse/eclipse_jkube:1.3.3.7", - SimpleImageName.builder() - .fullName("eclipse/eclipse_jkube:1.3.3.7") - .registry(null) - .user("eclipse") - .repository("eclipse/eclipse_jkube") - .tag("1.3.3.7") - .digest(null) - .build() - }, - { - "Registry, Repo and Name", "docker.io/eclipse/eclipse_jkube", - SimpleImageName.builder() - .fullName("docker.io/eclipse/eclipse_jkube:latest") - .registry("docker.io") - .user("eclipse") - .repository("eclipse/eclipse_jkube") - .tag("latest") - .digest(null) - .build() - }, - { "Registry, Repo and Name with special characters", - "long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube", - SimpleImageName.builder() - .fullName("long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:latest") - .registry("long.registry.example.com:8080") - .user("valid.name--with__separators") - .repository("valid.name--with__separators/eclipse_jkube") - .tag("latest") - .digest(null) - .build() - }, - { "Registry, Repo, Name and Tag", "docker.io/eclipse/eclipse_jkube:1.33.7", - SimpleImageName.builder() - .fullName("docker.io/eclipse/eclipse_jkube:1.33.7") - .registry("docker.io") - .user("eclipse") - .repository("eclipse/eclipse_jkube") - .tag("1.33.7") - .digest(null) - .build() - }, - { - "Registry, Repo, Name and Tag with special characters", - "long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:very--special__tag.2.A", - SimpleImageName.builder() - .fullName( - "long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:very--special__tag.2.A") - .registry("long.registry.example.com:8080") - .user("valid.name--with__separators") - .repository("valid.name--with__separators/eclipse_jkube") - .tag("very--special__tag.2.A") - .digest(null) - .build() - }, - { - "Repo only", "eclipse-temurin:11", - SimpleImageName.builder() - .fullName("eclipse-temurin:11") - .registry(null) - .user(null) - .repository("eclipse-temurin") - .tag("11") - .digest(null) - .build() - }, - { - "User and repo", "user/my-repo_z:11", - SimpleImageName.builder() - .fullName("user/my-repo_z:11") - .registry(null) - .user("user") - .repository("user/my-repo_z") - .tag("11") - .digest(null) - .build() - }, - { - "Registry and repo", "foo-bar-registry.jfrog.io/java:jre-17", - SimpleImageName.builder() - .fullName("foo-bar-registry.jfrog.io/java:jre-17") - .registry("foo-bar-registry.jfrog.io") - .user(null) - .repository("java") - .tag("jre-17") - .digest(null) - .build() - }, - { - "JFrog repo", "user.jfrog.io/my-jkube/openjdk:jre-17", - SimpleImageName.builder() - .fullName("user.jfrog.io/my-jkube/openjdk:jre-17") - .registry("user.jfrog.io") - .user("my-jkube") - .repository("my-jkube/openjdk") - .tag("jre-17") - .digest(null) - .build() - }, - }); - } - - @ParameterizedTest(name = "{0}") - @MethodSource("validData") - void shouldParseImageName(String testName, String providedImageName, SimpleImageName expectedImageName) { - ImageName imageName = new ImageName(providedImageName); - SimpleImageName currentImageName = SimpleImageName.toSimpleImageName(imageName); - assertThat(currentImageName).isEqualTo(expectedImageName); - } - - public static Stream invalidData() { + Arguments.of("eclipse/eclipse_jkube:latest", "latest"), + Arguments.of("eclipse/eclipse_jkube:1.3.3.7", "1.3.3.7"), + Arguments.of("docker.io/eclipse/eclipse_jkube", "latest"), + Arguments.of("long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube", "latest"), + Arguments.of("docker.io/eclipse/eclipse_jkube:1.33.7", "1.33.7"), + Arguments.of("long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:very--special__tag.2.A", "very--special__tag.2.A"), + Arguments.of("eclipse-temurin:11", "11"), + Arguments.of("user/my-repo_z:11", "11"), + Arguments.of("foo-bar-registry.jfrog.io/java:jre-17", "jre-17"), + Arguments.of("user.jfrog.io/my-jkube/openjdk:jre-17", "jre-17"), + Arguments.of("quay.io/jkube/jkube-java:0.0.19@sha256:b7d8650e04b282b9d7b94daedf38321512f9910bce896cd40ffa15b1b92bab17", "0.0.19") + ); + } + + @ParameterizedTest(name ="{index}: With full name ''{0}'' should return ''{1}'' as digest") + @DisplayName("getDigest") + @MethodSource("getDigestData") + void getDigest(String providedFullName, String expectedDigest) { + assertThat(new ImageName(providedFullName).getDigest()).isEqualTo(expectedDigest); + } + + static Stream getDigestData() { return Stream.of( - new Object[][] { - { - "Repo and Name with special characters", "invalid.name-with__separators/eclipse_-jkube" - }, - { - "Repo, Name and Tag with special characters", "invalid.name-with__separators/eclipse_jkube:valid!__tag-4.2" - }, - }); - } - - @ParameterizedTest(name = "{0}") - @MethodSource("invalidData") - void shouldFailedParseImageName(String testName, String providedImageName) { - assertThatCode(() -> new ImageName(providedImageName)) - .isInstanceOf(IllegalArgumentException.class); - } - - @Builder - @Value - public static class SimpleImageName { - String fullName; - String registry; - String user; - String repository; - String tag; - String digest; - - public static SimpleImageName toSimpleImageName(ImageName imageName) { - return new SimpleImageName(imageName.getFullName(), - imageName.getRegistry(), - imageName.getUser(), - imageName.getRepository(), - imageName.getTag(), - imageName.getDigest()); - } + Arguments.of("eclipse/eclipse_jkube:latest", null), + Arguments.of("eclipse/eclipse_jkube:1.3.3.7", null), + Arguments.of("docker.io/eclipse/eclipse_jkube", null), + Arguments.of("long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube", null), + Arguments.of("docker.io/eclipse/eclipse_jkube:1.33.7", null), + Arguments.of("long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:very--special__tag.2.A", null), + Arguments.of("eclipse-temurin:11", null), + Arguments.of("user/my-repo_z:11", null), + Arguments.of("foo-bar-registry.jfrog.io/java:jre-17", null), + Arguments.of("user.jfrog.io/my-jkube/openjdk:jre-17", null), + Arguments.of("quay.io/jkube/jkube-java:0.0.19@sha256:b7d8650e04b282b9d7b94daedf38321512f9910bce896cd40ffa15b1b92bab17", "sha256:b7d8650e04b282b9d7b94daedf38321512f9910bce896cd40ffa15b1b92bab17") + ); + } + @ParameterizedTest(name ="{index}: With full name ''{0}'' should return ''{1}'' as inferred user") + @DisplayName("inferUser") + @MethodSource("inferUserData") + void getUser(String providedFullName, String expectedUser) { + assertThat(new ImageName(providedFullName).inferUser()).isEqualTo(expectedUser); } + + static Stream inferUserData() { + return Stream.of( + Arguments.of("eclipse/eclipse_jkube:latest", "eclipse"), + Arguments.of("eclipse/eclipse_jkube:1.3.3.7", "eclipse"), + Arguments.of("docker.io/eclipse/eclipse_jkube", "eclipse"), + Arguments.of("long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube", "valid.name--with__separators"), + Arguments.of("docker.io/eclipse/eclipse_jkube:1.33.7", "eclipse"), + Arguments.of("long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:very--special__tag.2.A", "valid.name--with__separators"), + Arguments.of("eclipse-temurin:11", null), + Arguments.of("user/my-repo_z:11", "user"), + Arguments.of("foo-bar-registry.jfrog.io/java:jre-17", null), + Arguments.of("user.jfrog.io/my-jkube/openjdk:jre-17", "my-jkube"), + Arguments.of("quay.io/jkube/jkube-java:0.0.19@sha256:b7d8650e04b282b9d7b94daedf38321512f9910bce896cd40ffa15b1b92bab17", "jkube") + ); + } + + @ParameterizedTest(name ="{index}: With full name ''{0}'' should return ''{1}'' as simple name") + @DisplayName("getSimpleName") + @MethodSource("getSimpleNameData") + void getSimpleName(String providedFullName, String expectedSimpleName) { + assertThat(new ImageName(providedFullName).getSimpleName()).isEqualTo(expectedSimpleName); + } + + static Stream getSimpleNameData() { + return Stream.of( + Arguments.of("eclipse/eclipse_jkube:latest", "eclipse_jkube"), + Arguments.of("eclipse/eclipse_jkube:1.3.3.7", "eclipse_jkube"), + Arguments.of("docker.io/eclipse/eclipse_jkube", "eclipse_jkube"), + Arguments.of("long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube", "eclipse_jkube"), + Arguments.of("docker.io/eclipse/eclipse_jkube:1.33.7", "eclipse_jkube"), + Arguments.of("long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:very--special__tag.2.A", "eclipse_jkube"), + Arguments.of("eclipse-temurin:11", "eclipse-temurin"), + Arguments.of("user/my-repo_z:11", "my-repo_z"), + Arguments.of("foo-bar-registry.jfrog.io/java:jre-17", "java"), + Arguments.of("user.jfrog.io/my-jkube/openjdk:jre-17", "openjdk"), + Arguments.of("quay.io/jkube/jkube-java:0.0.19@sha256:b7d8650e04b282b9d7b94daedf38321512f9910bce896cd40ffa15b1b92bab17", "jkube-java") + ); + } + @Test + @DisplayName("With special characters in name, should throw Exception") + void withSpecialCharactersInName() { + assertThatThrownBy(() -> new ImageName("invalid.name-with__separators/eclipse_-jkube")) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageStartingWith("Given Docker name 'invalid.name-with__separators/eclipse_-jkube:latest' is invalid"); + } + @Test + @DisplayName("With special characters in tag, should throw Exception") + void withSpecialCharactersInTag() { + assertThatThrownBy(() -> new ImageName("invalid.name-with__separators/eclipse_jkube:valid!__tag-4.2")) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageStartingWith("Given Docker name 'invalid.name-with__separators/eclipse_jkube:valid!__tag-4.2' is invalid"); + } + @Test + @DisplayName("With null full name, should throw Exception") + void withNullFullName() { + assertThatThrownBy(() -> new ImageName(null)) + .isInstanceOf(NullPointerException.class) + .hasMessage("Image name must not be null"); + } + } diff --git a/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameTest.java b/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameTest.java index 8bfdfbf28d..5d3059bbf9 100644 --- a/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameTest.java +++ b/jkube-kit/config/image/src/test/java/org/eclipse/jkube/kit/config/image/ImageNameTest.java @@ -157,18 +157,16 @@ void namesUsedByDockerTests() { @Test void testImageNameWithUsernameHavingPeriods() { // Given - String name = "roman.gordill/customer-service-cache:latest"; - + final String name = "quay.io/roman.gordill/customer-service-cache:latest"; // When - String nameWithRegistry = new ImageName(name).getFullName("quay.io"); - ImageName imageName = new ImageName(nameWithRegistry); - + final ImageName result = new ImageName(name); // Then - assertThat(imageName).isNotNull(); - assertThat(imageName.getUser()).isEqualTo("roman.gordill"); - assertThat(imageName.getRepository()).isEqualTo("roman.gordill/customer-service-cache"); - assertThat(imageName.getTag()).isEqualTo("latest"); - assertThat(imageName.getRegistry()).isEqualTo("quay.io"); + assertThat(result) + .isNotNull() + .hasFieldOrPropertyWithValue("repository", "roman.gordill/customer-service-cache") + .hasFieldOrPropertyWithValue("tag", "latest") + .hasFieldOrPropertyWithValue("registry", "quay.io") + .returns("roman.gordill", ImageName::inferUser); } @ParameterizedTest @@ -183,7 +181,7 @@ void testImageNameWithRegistry(String name, String registry, String repository, // Then assertThat(imageName).isNotNull(); - assertThat(imageName.getUser()).isNull(); + assertThat(imageName.inferUser()).isNull(); assertThat(imageName.getRegistry()).isEqualTo(registry); assertThat(imageName.getRepository()).isEqualTo(repository); assertThat(imageName.getTag()).isEqualTo(tag); @@ -199,7 +197,7 @@ void testImageNameWithNameContainingRegistryAndName() { // Then assertThat(imageName).isNotNull(); - assertThat(imageName.getUser()).isNull(); + assertThat(imageName.inferUser()).isNull(); assertThat(imageName.getRegistry()).isEqualTo("foo.com:5000"); assertThat(imageName.getRepository()).isEqualTo("customer-service-cache"); assertThat(imageName.getTag()).isEqualTo("latest"); diff --git a/jkube-kit/enricher/api/src/main/java/org/eclipse/jkube/kit/enricher/api/util/KubernetesResourceUtil.java b/jkube-kit/enricher/api/src/main/java/org/eclipse/jkube/kit/enricher/api/util/KubernetesResourceUtil.java index a418d6e8d6..3ab01e43d4 100644 --- a/jkube-kit/enricher/api/src/main/java/org/eclipse/jkube/kit/enricher/api/util/KubernetesResourceUtil.java +++ b/jkube-kit/enricher/api/src/main/java/org/eclipse/jkube/kit/enricher/api/util/KubernetesResourceUtil.java @@ -147,7 +147,7 @@ public static String extractContainerName(GroupArtifactVersion groupArtifactVers private static String extractImageUser(String image, String groupId) { ImageName name = new ImageName(image); - String imageUser = name.getUser(); + String imageUser = name.inferUser(); if(imageUser != null) { return imageUser; } else { diff --git a/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/TriggersAnnotationEnricher.java b/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/TriggersAnnotationEnricher.java index b892fadfe5..487c3e8838 100644 --- a/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/TriggersAnnotationEnricher.java +++ b/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/TriggersAnnotationEnricher.java @@ -133,7 +133,7 @@ public void visit(ContainerBuilder cb) { String containerName = container.getName(); String containerImage = container.getImage(); ImageName image = new ImageName(containerImage); - if (isContainerAllowed(containerName) && image.getRegistry() == null && image.getUser() == null) { + if (isContainerAllowed(containerName) && image.getRegistry() == null && image.inferUser() == null) { // Imagestreams used as trigger are in the same namespace String tag = image.getTag() != null ? image.getTag() : "latest"; diff --git a/jkube-kit/generator/api/src/main/java/org/eclipse/jkube/generator/api/support/BaseGenerator.java b/jkube-kit/generator/api/src/main/java/org/eclipse/jkube/generator/api/support/BaseGenerator.java index 9bf94f15a1..6947578a17 100644 --- a/jkube-kit/generator/api/src/main/java/org/eclipse/jkube/generator/api/support/BaseGenerator.java +++ b/jkube-kit/generator/api/src/main/java/org/eclipse/jkube/generator/api/support/BaseGenerator.java @@ -157,8 +157,8 @@ protected void addFrom(BuildConfiguration.BuildConfigurationBuilder builder) { tag = "latest"; } fromExt.put(JKubeBuildStrategy.SourceStrategy.name.key(), iName.getSimpleName() + ":" + tag); - if (iName.getUser() != null) { - fromExt.put(JKubeBuildStrategy.SourceStrategy.namespace.key(), iName.getUser()); + if (iName.inferUser() != null) { + fromExt.put(JKubeBuildStrategy.SourceStrategy.namespace.key(), iName.inferUser()); } fromExt.put(JKubeBuildStrategy.SourceStrategy.kind.key(), "ImageStreamTag"); } else { From b75b230d212eeac38ca847a895beb25581f19b87 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Fri, 7 Jul 2023 11:00:15 +0200 Subject: [PATCH 12/65] ci: notifications for failed SNAPSHOT release Signed-off-by: Marc Nuri --- .jenkins/pipelines/release-snapshots.Jenkinsfile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.jenkins/pipelines/release-snapshots.Jenkinsfile b/.jenkins/pipelines/release-snapshots.Jenkinsfile index 311b1b9053..0c1849c1bc 100644 --- a/.jenkins/pipelines/release-snapshots.Jenkinsfile +++ b/.jenkins/pipelines/release-snapshots.Jenkinsfile @@ -1,5 +1,7 @@ #!groovy +def jKubeInfraEmail = 'jkube-infra@eclipse.org' + pipeline { agent any tools { @@ -25,4 +27,18 @@ pipeline { } } } + post { + unsuccessful { + emailext subject: '[JKube] SNAPSHOT deployment: Failure $BUILD_STATUS $PROJECT_NAME #$BUILD_NUMBER', + body: '''Check console output at $BUILD_URL to view the results.''', + recipientProviders: [recipients()], + to: jKubeInfraEmail + } + fixed { + emailext subject: '[JKube] SNAPSHOT deployment: Bach to normal $BUILD_STATUS $PROJECT_NAME #$BUILD_NUMBER', + body: '''Check console output at $BUILD_URL to view the results.''', + recipientProviders: [recipients()], + to: jKubeInfraEmail + } + } } From bf9394d929a48d21bb1f10b9e24d923f6dc56291 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Fri, 7 Jul 2023 12:01:20 +0200 Subject: [PATCH 13/65] ci: replace CircleCI Javadoc job with Jenkins Signed-off-by: Marc Nuri --- .circleci/config.yml | 17 ----------------- .jenkins/pipelines/javadoc.Jenkinsfile | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 .jenkins/pipelines/javadoc.Jenkinsfile diff --git a/.circleci/config.yml b/.circleci/config.yml index 292a923f7c..6e75fa8ffe 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -55,22 +55,6 @@ jobs: paths: - ~/.m2 - javadoc: - docker: - - image: cimg/openjdk:11.0 - steps: - - checkout - - restore_cache: - key: maven-javadoc-{{ .Branch }}-{{ .Revision }}-{{ checksum "pom.xml" }} - - run: - command: | - # Run Maven build with javadoc jar generation - ./mvnw clean install javadoc:jar -DskipTests -Pjavadoc - - save_cache: - key: maven-javadoc-{{ .Branch }}-{{ .Revision }}-{{ checksum "pom.xml" }} - paths: - - ~/.m2 - sonar: docker: - image: cimg/openjdk:11.0 @@ -139,7 +123,6 @@ workflows: all: jobs: - build - - javadoc - test - sonar: filters: diff --git a/.jenkins/pipelines/javadoc.Jenkinsfile b/.jenkins/pipelines/javadoc.Jenkinsfile new file mode 100644 index 0000000000..741b94777c --- /dev/null +++ b/.jenkins/pipelines/javadoc.Jenkinsfile @@ -0,0 +1,24 @@ +#!groovy + +pipeline { + agent any + tools { + maven 'apache-maven-latest' + // https://wiki.eclipse.org/Jenkins#JDK + jdk 'temurin-jdk11-latest' + } + stages { + stage('Validate Javadoc') { + steps { + sshagent(['github-bot-ssh']) { + sh 'echo "Cloning Project"' + sh 'git clone git@github.com:eclipse/jkube.git' + } + dir('jkube') { + sh 'echo "Building Project with Javadoc"' + sh './mvnw -V -B -e -Pjavadoc -DskipTests install javadoc:jar' + } + } + } + } +} From 0fea11c888b4a57635a0c0bc35642ca2f9b3bd0b Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Fri, 7 Jul 2023 15:20:41 +0200 Subject: [PATCH 14/65] ci: replace CircleCI Sonar (PR) job with Jenkins Signed-off-by: Marc Nuri --- .circleci/config.yml | 22 ---------------------- .jenkins/pipelines/sonar.Jenkinsfile | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 22 deletions(-) create mode 100644 .jenkins/pipelines/sonar.Jenkinsfile diff --git a/.circleci/config.yml b/.circleci/config.yml index 6e75fa8ffe..7b2f7bded1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -69,27 +69,6 @@ jobs: paths: - ~/.m2 - sonar-pr: - docker: - - image: cimg/openjdk:11.0 - steps: - - checkout - - restore_cache: - key: maven-sonar-pr-{{ .Branch }}-{{ .Revision }}-{{ checksum "pom.xml" }} - - run: | - if [ -n "${CIRCLE_PULL_REQUEST}" ]; then - MAVEN_OPTS="-Xmx3000m" ./mvnw -B -Pjacoco,sonar clean install \ - -Dsonar.pullrequest.key=${CIRCLE_PULL_REQUEST##*/} \ - -Dsonar.pullrequest.branch=${CIRCLE_BRANCH} \ - -Dsonar.pullrequest.base=master - else - echo "No Sonar PR analysis as this is not a pull request" - fi - - save_cache: - key: maven-sonar-pr-{{ .Branch }}-{{ .Revision }}-{{ checksum "pom.xml" }} - paths: - - ~/.m2 - doc-preview-pr: docker: - image: cimg/openjdk:11.0 @@ -128,6 +107,5 @@ workflows: filters: branches: only: master - - sonar-pr - doc-preview-pr - dependencies-pr diff --git a/.jenkins/pipelines/sonar.Jenkinsfile b/.jenkins/pipelines/sonar.Jenkinsfile new file mode 100644 index 0000000000..0f66ab6c8f --- /dev/null +++ b/.jenkins/pipelines/sonar.Jenkinsfile @@ -0,0 +1,28 @@ +#!groovy + +pipeline { + agent any + tools { + maven 'apache-maven-latest' + // https://wiki.eclipse.org/Jenkins#JDK + jdk 'temurin-jdk11-latest' + } + stages { + stage('Sonar') { + steps { + sshagent(['github-bot-ssh']) { + sh 'echo "Cloning Project"' + sh 'git clone git@github.com:eclipse/jkube.git' + } + dir('jkube') { + sh 'echo "Building Project and analyzing with Sonar"' + // Needs install instad of verify since ITs rely on artifacts from previous modules + sh './mvnw -V -B -e -Pjacoco,sonar install ' + + '-Dsonar.pullrequest.key=${CHANGE_ID} ' + + '-Dsonar.pullrequest.branch=${GIT_BRANCH} ' + + '-Dsonar.pullrequest.base=master' + } + } + } + } +} From 686e1853962ad21a80e514f21b4d1ce286a7eab6 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Mon, 10 Jul 2023 09:54:37 +0200 Subject: [PATCH 15/65] ci: disable concurrent builds Signed-off-by: Marc Nuri --- .jenkins/pipelines/javadoc.Jenkinsfile | 3 +++ .jenkins/pipelines/sonar.Jenkinsfile | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.jenkins/pipelines/javadoc.Jenkinsfile b/.jenkins/pipelines/javadoc.Jenkinsfile index 741b94777c..22d7c106c9 100644 --- a/.jenkins/pipelines/javadoc.Jenkinsfile +++ b/.jenkins/pipelines/javadoc.Jenkinsfile @@ -7,6 +7,9 @@ pipeline { // https://wiki.eclipse.org/Jenkins#JDK jdk 'temurin-jdk11-latest' } + options { + disableConcurrentBuilds(abortPrevious: true) + } stages { stage('Validate Javadoc') { steps { diff --git a/.jenkins/pipelines/sonar.Jenkinsfile b/.jenkins/pipelines/sonar.Jenkinsfile index 0f66ab6c8f..98370cf559 100644 --- a/.jenkins/pipelines/sonar.Jenkinsfile +++ b/.jenkins/pipelines/sonar.Jenkinsfile @@ -7,6 +7,9 @@ pipeline { // https://wiki.eclipse.org/Jenkins#JDK jdk 'temurin-jdk11-latest' } + options { + disableConcurrentBuilds(abortPrevious: true) + } stages { stage('Sonar') { steps { From a098274648f057106e4eed2ae792871bebc5da01 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Mon, 10 Jul 2023 07:40:05 +0200 Subject: [PATCH 16/65] ci: replace CircleCI Dependency check job with Jenkins Signed-off-by: Marc Nuri --- .circleci/config.yml | 15 ----------- .jenkins/pipelines/dependencies.Jenkinsfile | 28 +++++++++++++++++++++ scripts/eclipse-dash-tool.sh | 14 ++++++++--- 3 files changed, 39 insertions(+), 18 deletions(-) create mode 100644 .jenkins/pipelines/dependencies.Jenkinsfile diff --git a/.circleci/config.yml b/.circleci/config.yml index 7b2f7bded1..4c3073331c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -83,20 +83,6 @@ jobs: - store_artifacts: path: ./docs-generated/ - dependencies-pr: - docker: - - image: cimg/openjdk:11.0 - steps: - - checkout - - run: | # Script dependencies - sudo apt-get update && sudo apt-get install -y libxml-xpath-perl - - run: | - if [ -n "${CIRCLE_PULL_REQUEST}" ]; then - mvn install -DskipTests && ./scripts/eclipse-dash-tool.sh - fi - - store_artifacts: - path: ./target/dependencies-resolved.csv - workflows: version: 2 all: @@ -108,4 +94,3 @@ workflows: branches: only: master - doc-preview-pr - - dependencies-pr diff --git a/.jenkins/pipelines/dependencies.Jenkinsfile b/.jenkins/pipelines/dependencies.Jenkinsfile new file mode 100644 index 0000000000..20dff5ebb5 --- /dev/null +++ b/.jenkins/pipelines/dependencies.Jenkinsfile @@ -0,0 +1,28 @@ +#!groovy + +pipeline { + agent any + tools { + maven 'apache-maven-latest' + // https://wiki.eclipse.org/Jenkins#JDK + jdk 'temurin-jdk11-latest' + } + options { + disableConcurrentBuilds(abortPrevious: true) + } + stages { + stage('Check dependency licenses') { + steps { + sh 'echo "Eclipse Dash Tool"' + // Eclipse Dash tool retrieves dependencies from submodules which might need artifacts from previous modules + sh './mvnw -V -B -e -DskipTests install' + sh 'ECLIPSE_DASH_VERSION=1.0.2 ./scripts/eclipse-dash-tool.sh' + } + } + } + post { + success { + archiveArtifacts artifacts: 'target/dependencies-resolved.csv', fingerprint: true + } + } +} diff --git a/scripts/eclipse-dash-tool.sh b/scripts/eclipse-dash-tool.sh index bd07a56e4b..0beae036c7 100755 --- a/scripts/eclipse-dash-tool.sh +++ b/scripts/eclipse-dash-tool.sh @@ -18,7 +18,7 @@ trap 'exit' ERR BASEDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) source "$BASEDIR/common.sh" -REPOSITORY="https://repo.eclipse.org/content/repositories/dash-licenses/org/eclipse/dash/org.eclipse.dash.licenses/0.0.1-SNAPSHOT" +REPOSITORY="https://repo.eclipse.org/content/repositories/dash-licenses/org/eclipse/dash/org.eclipse.dash.licenses" TARGET_DIR="$PROJECT_ROOT/target" DEPENDENCY_LIST="$TARGET_DIR/dependencies.txt" TOOL_JAR="$TARGET_DIR/eclipse-dash.jar" @@ -26,10 +26,18 @@ TOOL_JAR="$TARGET_DIR/eclipse-dash.jar" function downloadTool() { if [[ ! -f "$TOOL_JAR" ]] then + if [[ -z "$ECLIPSE_DASH_VERSION" ]] + then + echo "Getting latest Eclipse Dash 0.0.1-SNAPSHOT version" + version=$(curl -s "${REPOSITORY}/0.0.1-SNAPSHOT/maven-metadata.xml" | xpath -q -e "/metadata/versioning/snapshotVersions/snapshotVersion[extension='jar']/value/text()") + downloadUrl="${REPOSITORY}/0.0.1-SNAPSHOT/org.eclipse.dash.licenses-${version}.jar" + else + echo "Using provided Eclipse Dash version ($ECLIPSE_DASH_VERSION)" + downloadUrl="${REPOSITORY}/${ECLIPSE_DASH_VERSION}/org.eclipse.dash.licenses-${ECLIPSE_DASH_VERSION}.jar" + fi echo "Downloading eclipse-dash.jar" mkdir -p "$TARGET_DIR" - version=$(curl -s "$REPOSITORY/maven-metadata.xml" | xpath -q -e "/metadata/versioning/snapshotVersions/snapshotVersion[extension='jar']/value/text()") - curl "$REPOSITORY/org.eclipse.dash.licenses-${version}.jar" -o "$TOOL_JAR" + curl "$downloadUrl" -o "$TOOL_JAR" fi } From 6e1150455a29bb9127bec8e5ce2879bcd7f9331e Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Mon, 10 Jul 2023 11:06:44 +0200 Subject: [PATCH 17/65] ci: replace CircleCI Sonar (main) job with Jenkins Signed-off-by: Marc Nuri --- .circleci/config.yml | 18 ----------------- .jenkins/pipelines/sonar.Jenkinsfile | 29 +++++++++++++++------------- 2 files changed, 16 insertions(+), 31 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4c3073331c..cac2d157b4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -55,20 +55,6 @@ jobs: paths: - ~/.m2 - sonar: - docker: - - image: cimg/openjdk:11.0 - steps: - - checkout - - restore_cache: - key: maven-sonar-{{ .Branch }}-{{ .Revision }}-{{ checksum "pom.xml" }} - - run: | - MAVEN_OPTS="-Xmx3000m" ./mvnw -B -Pjacoco,sonar clean install - - save_cache: - key: maven-sonar-{{ .Branch }}-{{ .Revision }}-{{ checksum "pom.xml" }} - paths: - - ~/.m2 - doc-preview-pr: docker: - image: cimg/openjdk:11.0 @@ -89,8 +75,4 @@ workflows: jobs: - build - test - - sonar: - filters: - branches: - only: master - doc-preview-pr diff --git a/.jenkins/pipelines/sonar.Jenkinsfile b/.jenkins/pipelines/sonar.Jenkinsfile index 98370cf559..6134259c02 100644 --- a/.jenkins/pipelines/sonar.Jenkinsfile +++ b/.jenkins/pipelines/sonar.Jenkinsfile @@ -11,20 +11,23 @@ pipeline { disableConcurrentBuilds(abortPrevious: true) } stages { - stage('Sonar') { + stage('Sonar (PR)') { + when { changeRequest() } steps { - sshagent(['github-bot-ssh']) { - sh 'echo "Cloning Project"' - sh 'git clone git@github.com:eclipse/jkube.git' - } - dir('jkube') { - sh 'echo "Building Project and analyzing with Sonar"' - // Needs install instad of verify since ITs rely on artifacts from previous modules - sh './mvnw -V -B -e -Pjacoco,sonar install ' + - '-Dsonar.pullrequest.key=${CHANGE_ID} ' + - '-Dsonar.pullrequest.branch=${GIT_BRANCH} ' + - '-Dsonar.pullrequest.base=master' - } + sh 'echo "Building Project and analyzing with Sonar"' + // Needs install instad of verify since ITs rely on artifacts from previous modules + sh './mvnw -V -B -e -Pjacoco,sonar install ' + + '-Dsonar.pullrequest.key=${CHANGE_ID} ' + + '-Dsonar.pullrequest.branch=${GIT_BRANCH} ' + + '-Dsonar.pullrequest.base=master' + } + } + stage('Sonar (main)') { + when { not { changeRequest() } } + steps { + sh 'echo "Building Project and analyzing with Sonar"' + // Needs install instad of verify since ITs rely on artifacts from previous modules + sh './mvnw -V -B -e -Pjacoco,sonar install' } } } From 28c26d847866094a953353915dc2d439c7632771 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Mon, 10 Jul 2023 11:39:20 +0200 Subject: [PATCH 18/65] ci:fix: Javadoc pipeline checks the appropriate branch Signed-off-by: Marc Nuri --- .jenkins/pipelines/javadoc.Jenkinsfile | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.jenkins/pipelines/javadoc.Jenkinsfile b/.jenkins/pipelines/javadoc.Jenkinsfile index 22d7c106c9..0f72afc380 100644 --- a/.jenkins/pipelines/javadoc.Jenkinsfile +++ b/.jenkins/pipelines/javadoc.Jenkinsfile @@ -13,14 +13,8 @@ pipeline { stages { stage('Validate Javadoc') { steps { - sshagent(['github-bot-ssh']) { - sh 'echo "Cloning Project"' - sh 'git clone git@github.com:eclipse/jkube.git' - } - dir('jkube') { - sh 'echo "Building Project with Javadoc"' - sh './mvnw -V -B -e -Pjavadoc -DskipTests install javadoc:jar' - } + sh 'echo "Building Project with Javadoc"' + sh './mvnw -V -B -e -Pjavadoc -DskipTests install javadoc:jar' } } } From 7eafb3cc90948e9f1b6e5cfa241d0a3eb8ec1076 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Mon, 10 Jul 2023 12:09:08 +0200 Subject: [PATCH 19/65] ci: replace CircleCI documentation preview job with Jenkins Signed-off-by: Marc Nuri --- .circleci/config.yml | 15 ------------ .jenkins/pipelines/doc-preview.Jenkinsfile | 27 ++++++++++++++++++++++ jkube-kit/doc/pom.xml | 2 -- pom.xml | 23 +----------------- scripts/generateDoc.sh | 1 + 5 files changed, 29 insertions(+), 39 deletions(-) create mode 100644 .jenkins/pipelines/doc-preview.Jenkinsfile diff --git a/.circleci/config.yml b/.circleci/config.yml index cac2d157b4..e219462a95 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -55,24 +55,9 @@ jobs: paths: - ~/.m2 - doc-preview-pr: - docker: - - image: cimg/openjdk:11.0 - steps: - - checkout - - run: | - if [ -n "${CIRCLE_PULL_REQUEST}" ]; then - ./scripts/generateDoc.sh - else - echo "No Doc preview run as this is not a pull request" - fi - - store_artifacts: - path: ./docs-generated/ - workflows: version: 2 all: jobs: - build - test - - doc-preview-pr diff --git a/.jenkins/pipelines/doc-preview.Jenkinsfile b/.jenkins/pipelines/doc-preview.Jenkinsfile new file mode 100644 index 0000000000..68649d3136 --- /dev/null +++ b/.jenkins/pipelines/doc-preview.Jenkinsfile @@ -0,0 +1,27 @@ +#!groovy + +pipeline { + agent any + tools { + maven 'apache-maven-latest' + // https://wiki.eclipse.org/Jenkins#JDK + jdk 'temurin-jdk11-latest' + } + options { + disableConcurrentBuilds(abortPrevious: true) + } + stages { + stage('Generate documentation preview') { + when { changeRequest() } + steps { + sh 'echo "Generating project documentation"' + sh './scripts/generateDoc.sh' + } + } + } + post { + success { + archiveArtifacts artifacts: 'docs-generated/*.html,docs-generated/*.txt,docs-generated/*.css', fingerprint: true + } + } +} diff --git a/jkube-kit/doc/pom.xml b/jkube-kit/doc/pom.xml index 7524878147..9b964ff5b6 100644 --- a/jkube-kit/doc/pom.xml +++ b/jkube-kit/doc/pom.xml @@ -63,8 +63,6 @@ process-asciidoc - - diff --git a/pom.xml b/pom.xml index 6d0871360e..1eced2c925 100644 --- a/pom.xml +++ b/pom.xml @@ -276,7 +276,7 @@ - true left - false + true html5 @@ -538,27 +538,6 @@ - - - - doc-html - - - - org.asciidoctor - asciidoctor-maven-plugin - - html - - left - - - - - generate-resources asciidoctor:process-asciidoc - - - sonar diff --git a/scripts/generateDoc.sh b/scripts/generateDoc.sh index 84634a8a69..327fa33c89 100755 --- a/scripts/generateDoc.sh +++ b/scripts/generateDoc.sh @@ -29,6 +29,7 @@ cp gradle-plugin/doc/target/generated-docs/index.html docs-generated/openshift-g # OpenShift Maven Plugin mvn -f kubernetes-maven-plugin/doc -Phtml package -Dplugin=openshift-maven-plugin -Dgoal-prefix=oc -Dcluster=OpenShift cp kubernetes-maven-plugin/doc/target/generated-docs/index.html docs-generated/openshift-maven-plugin.html +cp kubernetes-maven-plugin/doc/target/generated-docs/asciidoctor.css docs-generated/asciidoctor.css cat << EOF >> docs-generated/index.html From ac77c4760526cc0fc6e3c5d7f6f161de2dbe6b9d Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Mon, 10 Jul 2023 15:02:19 +0200 Subject: [PATCH 20/65] test: HelmServiceIT uses internal Serialization utils Signed-off-by: Marc Nuri --- .../eclipse/jkube/kit/resource/helm/HelmServiceIT.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceIT.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceIT.java index 9c7b834574..4277416cfa 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceIT.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceIT.java @@ -30,8 +30,6 @@ import org.eclipse.jkube.kit.common.KitLogger; import org.eclipse.jkube.kit.common.assertj.ArchiveAssertions; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import io.fabric8.openshift.api.model.ParameterBuilder; import io.fabric8.openshift.api.model.Template; import org.apache.commons.io.FileUtils; @@ -46,14 +44,12 @@ class HelmServiceIT { - private ObjectMapper mapper; private HelmService helmService; private HelmConfig helmConfig; private File helmOutputDir; @BeforeEach void setUp(@TempDir Path temporaryFolder) throws Exception { - mapper = new ObjectMapper(new YAMLFactory()); helmService = new HelmService( JKubeConfiguration.builder().project(JavaProject.builder().properties(new Properties()).build()).build(), new ResourceServiceConfig(), @@ -133,9 +129,9 @@ private void assertYamls() throws Exception { final Path expectations = new File(HelmServiceIT.class.getResource("/it/expected").toURI()).toPath(); final Path generatedYamls = helmOutputDir.toPath(); for (Path expected : Files.walk(expectations).filter(Files::isRegularFile).collect(Collectors.toList())) { - final Map expectedContent = mapper.readValue(replacePlaceholders(expected), Map.class); - final Map actualContent = - mapper.readValue(replacePlaceholders(generatedYamls.resolve(expectations.relativize(expected))), Map.class); + final Map expectedContent = Serialization.unmarshal(replacePlaceholders(expected), Map.class); + final Map actualContent = Serialization.unmarshal( + replacePlaceholders(generatedYamls.resolve(expectations.relativize(expected))), Map.class); assertThat(actualContent).isEqualTo(expectedContent); } } From a7655bfa8fe7cbfcd10ae5546adf126256ab1881 Mon Sep 17 00:00:00 2001 From: Ankit Singh Date: Wed, 5 Jul 2023 19:09:08 +0530 Subject: [PATCH 21/65] Fixed javadoc warnings Signed-off-by: Ankit Singh --- .../eclipse/jkube/kit/common/util/BuildReferenceDateUtil.java | 1 + .../main/java/org/eclipse/jkube/kit/common/util/MapUtil.java | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/BuildReferenceDateUtil.java b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/BuildReferenceDateUtil.java index 510f73beee..8e4cfe82f6 100644 --- a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/BuildReferenceDateUtil.java +++ b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/BuildReferenceDateUtil.java @@ -40,6 +40,7 @@ public static File getBuildTimestampFile(String projectBuildDirectory, String do * @param projectBuildDir project's build directory * @param dockerBuildTimestampFile docker build timestamp file * @return timestamp to use + * @throws IOException IO Exception */ public static Date getBuildTimestamp(Map pluginContext, String buildTimestampContextKey, String projectBuildDir, String dockerBuildTimestampFile) throws IOException { diff --git a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/MapUtil.java b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/MapUtil.java index d3b0857033..2148473b3c 100644 --- a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/MapUtil.java +++ b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/MapUtil.java @@ -89,6 +89,8 @@ public static void putAllIfNotNull(Map ret, Map *

{@code
      * Collections.singletonMap("key.nested-key", "value");
      * }
+ * @param source map of maps + * @return map with merged nested-keys */ public static Map getFlattenedMap(Map source) { return buildFlattenedMap(source, null); @@ -113,6 +115,8 @@ public static Map getFlattenedMap(Map source) { * key: value * three: other * } + * @param flattenedMap map with a flat structure + * @return Hash map */ public static Map getNestedMap(Map flattenedMap) { final Map result = new LinkedHashMap<>(); From 8439beb914dd3225303292415273a08ad6742326 Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Tue, 11 Jul 2023 10:20:46 +0530 Subject: [PATCH 22/65] doc (jkube-kit/common) : Fix javadocs in BuildReferenceDateUtil and MapUtil (#2210) Signed-off-by: Rohan Kumar --- .../eclipse/jkube/kit/common/util/BuildReferenceDateUtil.java | 2 +- .../main/java/org/eclipse/jkube/kit/common/util/MapUtil.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/BuildReferenceDateUtil.java b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/BuildReferenceDateUtil.java index 8e4cfe82f6..c34d126d9a 100644 --- a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/BuildReferenceDateUtil.java +++ b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/BuildReferenceDateUtil.java @@ -40,7 +40,7 @@ public static File getBuildTimestampFile(String projectBuildDirectory, String do * @param projectBuildDir project's build directory * @param dockerBuildTimestampFile docker build timestamp file * @return timestamp to use - * @throws IOException IO Exception + * @throws IOException If failure in reading build timestamp file */ public static Date getBuildTimestamp(Map pluginContext, String buildTimestampContextKey, String projectBuildDir, String dockerBuildTimestampFile) throws IOException { diff --git a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/MapUtil.java b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/MapUtil.java index 2148473b3c..e11895f017 100644 --- a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/MapUtil.java +++ b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/MapUtil.java @@ -116,7 +116,7 @@ public static Map getFlattenedMap(Map source) { * three: other * } * @param flattenedMap map with a flat structure - * @return Hash map + * @return converted nested map */ public static Map getNestedMap(Map flattenedMap) { final Map result = new LinkedHashMap<>(); From cc8d2faa5b2756938594c85ed6595520be9e3525 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Tue, 11 Jul 2023 09:42:14 +0200 Subject: [PATCH 23/65] test:refactor: Helm upload tests are whiteboxed Signed-off-by: Marc Nuri --- jkube-kit/resource/helm/pom.xml | 4 + .../jkube/kit/resource/helm/HelmUploader.java | 4 +- .../kit/resource/helm/HelmRepoTypeTest.java | 131 ----- .../kit/resource/helm/HelmRepositoryTest.java | 29 +- .../kit/resource/helm/HelmServiceTest.java | 110 ----- .../resource/helm/HelmServiceUploadIT.java | 453 ++++++++++++++++++ .../kit/resource/helm/HelmUploaderTest.java | 145 ------ 7 files changed, 481 insertions(+), 395 deletions(-) delete mode 100644 jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmRepoTypeTest.java create mode 100644 jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUploadIT.java delete mode 100644 jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderTest.java diff --git a/jkube-kit/resource/helm/pom.xml b/jkube-kit/resource/helm/pom.xml index 528040d2a0..0fd55c3f0f 100644 --- a/jkube-kit/resource/helm/pom.xml +++ b/jkube-kit/resource/helm/pom.xml @@ -68,5 +68,9 @@ mockito-core test + + io.fabric8 + mockwebserver + diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploader.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploader.java index 9c66394bda..b3ddeb5b10 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploader.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploader.java @@ -31,7 +31,7 @@ public HelmUploader(KitLogger logger) { this.logger = logger; } - protected void uploadSingle(File file, HelmRepository repository) + void uploadSingle(File file, HelmRepository repository) throws IOException, BadUploadException { HttpURLConnection connection; @@ -64,7 +64,7 @@ protected void uploadSingle(File file, HelmRepository repository) connection.disconnect(); } - protected void writeFileOnConnection(File file, HttpURLConnection connection) throws IOException { + private void writeFileOnConnection(File file, HttpURLConnection connection) throws IOException { try (FileInputStream fileInputStream = new FileInputStream(file)) { IOUtils.copy(fileInputStream, connection.getOutputStream()); } diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmRepoTypeTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmRepoTypeTest.java deleted file mode 100644 index 11707bd1f8..0000000000 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmRepoTypeTest.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * Copyright (c) 2019 Red Hat, Inc. - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at: - * - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - */ -package org.eclipse.jkube.kit.resource.helm; - - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; - -import java.io.File; -import java.io.IOException; -import java.net.Authenticator; -import java.net.HttpURLConnection; -import java.net.InetAddress; -import java.net.URL; -import java.nio.file.Files; -import java.util.Collections; - -import static org.assertj.core.api.Assertions.assertThat; - -class HelmRepoTypeTest { - - @TempDir - File temporaryFolder; - - private HelmRepository.HelmRepositoryBuilder helmRepositoryBuilder; - - @BeforeEach - void setUp() { - helmRepositoryBuilder = HelmRepository.builder() - .url("https://example.com/base/"); - } - - @Test - void createConnection_withChartMuseumAndNoAuth_shouldReturnConnection() throws IOException { - // When - final HttpURLConnection result = HelmRepository.HelmRepoType.CHARTMUSEUM - .createConnection(File.createTempFile("junit", "ext", temporaryFolder), helmRepositoryBuilder.build()); - // Then - assertThat(result) - .isNotNull() - .hasFieldOrPropertyWithValue("url", new URL("https://example.com/base/")) - .hasFieldOrPropertyWithValue("requestMethod", "POST") - .hasFieldOrPropertyWithValue("doOutput", true) - .extracting(HttpURLConnection::getRequestProperties) - .hasFieldOrPropertyWithValue("Content-Type", Collections.singletonList("application/gzip")); - assertThat(Authenticator.requestPasswordAuthentication(InetAddress.getLocalHost(), 443, "https", "test", "basic")) - .isNull(); - } - - @Test - void createConnection_withChartMuseumAndAuth_shouldReturnConnection() throws IOException { - helmRepositoryBuilder.username("user").password("s3cret"); - // When - final HttpURLConnection result = HelmRepository.HelmRepoType.CHARTMUSEUM - .createConnection(File.createTempFile("junit", "ext", temporaryFolder), helmRepositoryBuilder.build()); - // Then - assertThat(result) - .isNotNull() - .hasFieldOrPropertyWithValue("url", new URL("https://example.com/base/")) - .hasFieldOrPropertyWithValue("requestMethod", "POST") - .hasFieldOrPropertyWithValue("doOutput", true) - .extracting(HttpURLConnection::getRequestProperties) - .hasFieldOrPropertyWithValue("Content-Type", Collections.singletonList("application/gzip")); - assertThat(Authenticator.requestPasswordAuthentication(InetAddress.getLocalHost(), 443, "https", "test", "basic")) - .isNotNull() - .hasFieldOrPropertyWithValue("userName", "user") - .hasFieldOrPropertyWithValue("password", new char[]{'s', '3', 'c', 'r', 'e', 't'}); - } - - @Test - void createConnection_withArtifactoryAndNoAuth_shouldReturnConnection() throws IOException { - // When - final HttpURLConnection result = HelmRepository.HelmRepoType.ARTIFACTORY - .createConnection(Files.createFile(temporaryFolder.toPath().resolve("chart.tar")).toFile(), - helmRepositoryBuilder.build()); - // Then - assertThat(result) - .isNotNull() - .hasFieldOrPropertyWithValue("url", new URL("https://example.com/base/chart.tar")) - .hasFieldOrPropertyWithValue("requestMethod", "PUT") - .hasFieldOrPropertyWithValue("doOutput", true) - .extracting(HttpURLConnection::getRequestProperties) - .hasFieldOrPropertyWithValue("Content-Type", Collections.singletonList("application/gzip")); - } - - @Test - void createConnection_withNexusAndNoAuthAndTarGzExtension_shouldReturnConnectionToTgzUrl() throws IOException { - // Given - helmRepositoryBuilder.url("https://example.com"); - // When - final HttpURLConnection result = HelmRepository.HelmRepoType.NEXUS - .createConnection(Files.createFile(temporaryFolder.toPath().resolve("chart.tar.gz")).toFile(), - helmRepositoryBuilder.build()); - // Then - assertThat(result) - .isNotNull() - .hasFieldOrPropertyWithValue("url", new URL("https://example.com/chart.tgz")) - .hasFieldOrPropertyWithValue("requestMethod", "PUT") - .hasFieldOrPropertyWithValue("doOutput", true) - .extracting(HttpURLConnection::getRequestProperties) - .hasFieldOrPropertyWithValue("Content-Type", Collections.singletonList("application/gzip")); - } - - @Test - void createConnection_withNexusAndNoAuthAndTgzExtension_shouldReturnConnection() throws IOException { - // When - final HttpURLConnection result = HelmRepository.HelmRepoType.NEXUS - .createConnection(Files.createFile(temporaryFolder.toPath().resolve("chart.tgz")).toFile(), - helmRepositoryBuilder.build()); - // Then - assertThat(result) - .isNotNull() - .hasFieldOrPropertyWithValue("url", new URL("https://example.com/base/chart.tgz")) - .hasFieldOrPropertyWithValue("requestMethod", "PUT") - .hasFieldOrPropertyWithValue("doOutput", true) - .extracting(HttpURLConnection::getRequestProperties) - .hasFieldOrPropertyWithValue("Content-Type", Collections.singletonList("application/gzip")); - } -} diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmRepositoryTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmRepositoryTest.java index d036380bbe..bcdf392774 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmRepositoryTest.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmRepositoryTest.java @@ -41,7 +41,7 @@ void deserialize() throws Exception { // Given final String serializedChart = "{" + "\"name\":\"repo-name\"," + - "\"url\":\"http://example.com/url\"," + + "\"url\":\"https://example.com/url\"," + "\"username\":\"user\"," + "\"password\":\"pass\"," + "\"type\":\"ARTIFACTORY\"}"; @@ -50,11 +50,11 @@ void deserialize() throws Exception { // Then assertThat(result) .hasFieldOrPropertyWithValue("name", "repo-name") - .hasFieldOrPropertyWithValue("url", "http://example.com/url") + .hasFieldOrPropertyWithValue("url", "https://example.com/url") .hasFieldOrPropertyWithValue("username", "user") .hasFieldOrPropertyWithValue("password", "pass") .hasFieldOrPropertyWithValue("type", HelmRepoType.ARTIFACTORY) - .hasToString("[repo-name / http://example.com/url]"); + .hasToString("[repo-name / https://example.com/url]"); } @Test @@ -62,7 +62,7 @@ void builder() { // Given final HelmRepository.HelmRepositoryBuilder builder = HelmRepository.builder() .name("repo-name") - .url("http://example.com/url") + .url("https://example.com/url") .username("user") .password("pass") .type(HelmRepoType.ARTIFACTORY); @@ -71,11 +71,26 @@ void builder() { // Then assertThat(result) .hasFieldOrPropertyWithValue("name", "repo-name") - .hasFieldOrPropertyWithValue("url", "http://example.com/url") + .hasFieldOrPropertyWithValue("url", "https://example.com/url") .hasFieldOrPropertyWithValue("username", "user") .hasFieldOrPropertyWithValue("password", "pass") - .hasFieldOrPropertyWithValue("type", HelmRepoType.ARTIFACTORY) - .hasToString("[repo-name / http://example.com/url]"); + .hasFieldOrPropertyWithValue("type", HelmRepoType.ARTIFACTORY); } + @Test + void toString_returnsStringRepresentationWithNameAndUrl() { + // Given + final HelmRepository repository = HelmRepository.builder() + .name("repo-name") + .url("https://example.com/url") + .username("user") + .password("pass") + .type(HelmRepoType.ARTIFACTORY) + .build(); + // When + final String result = repository.toString(); + // Then + assertThat(result).isEqualTo("[repo-name / https://example.com/url]"); + + } } diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceTest.java index 706eb213fe..e8b870edae 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceTest.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceTest.java @@ -39,20 +39,15 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; import org.mockito.ArgumentCaptor; -import org.mockito.MockedConstruction; import org.mockito.MockedStatic; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.notNull; -import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.mockConstruction; import static org.mockito.Mockito.mockStatic; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; class HelmServiceTest { @@ -193,109 +188,4 @@ void createChartYamlWithDependencies() throws Exception { Collections.singletonList(helmDependency)); } } - - @Test - void uploadChart_withValidRepository_shouldUpload() - throws IOException, BadUploadException { - try (MockedConstruction helmUploaderMockedConstruction = mockConstruction(HelmUploader.class, - (mock, ctx) -> doNothing().when(mock).uploadSingle(any(File.class), any()))) { - // Given - final HelmRepository helmRepository = completeValidRepository().name("stable-repo").build(); - helmConfig - .types(Collections.singletonList(HelmType.KUBERNETES)) - .chart("chartName") - .version("1337") - .chartExtension("tar.gz") - .outputDir("target") - .tarballOutputDir("target") - .snapshotRepository(HelmRepository.builder().name("Snapshot-Repo").build()) - .stableRepository(helmRepository); - // When - helmService.uploadHelmChart(helmConfig.build()); - // Then - ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(File.class); - assertThat(helmUploaderMockedConstruction.constructed()).hasSize(1); - HelmUploader constructedHelmUploader = helmUploaderMockedConstruction.constructed().get(0); - verify(constructedHelmUploader).uploadSingle(argumentCaptor.capture(), eq(helmRepository)); - String fileName = "chartName-1337.tar.gz"; - assertThat(argumentCaptor.getValue()) - .hasName(fileName); - } - } - - @Test - void uploadHelmChart_withInvalidRepositoryConfiguration_shouldFail() { - // Given - final HelmConfig helm = helmConfig.chart("chart").version("1337-SNAPSHOT") - .snapshotRepository(HelmRepository.builder().name("INVALID").build()) - .build(); - // When - final IllegalStateException result = assertThrows(IllegalStateException.class, - () -> helmService.uploadHelmChart(helm)); - // Then - assertThat(result).hasMessage("No repository or invalid repository configured for upload"); - } - - @Test - void uploadHelmChart_withMissingRepositoryConfiguration_shouldFail() { - // Given - final HelmConfig helm = helmConfig.chart("chart").version("1337-SNAPSHOT").build(); - // When - final IllegalStateException result = assertThrows(IllegalStateException.class, - () -> helmService.uploadHelmChart(helm)); - // Then - assertThat(result).hasMessage("No repository or invalid repository configured for upload"); - } - - @Test - void uploadHelmChart_withServerConfigurationWithoutUsername_shouldFail() { - // Given - final HelmConfig helm = helmConfig.chart("chart").version("1337-SNAPSHOT") - .snapshotRepository(completeValidRepository().username(null).build()).build(); - jKubeConfiguration.getRegistryConfig().getSettings() - .add(RegistryServerConfiguration.builder().id("SNAP-REPO").build()); - // When - final IllegalArgumentException result = assertThrows(IllegalArgumentException.class, () -> - helmService.uploadHelmChart(helm)); - // Then - assertThat(result).hasMessage("Repo SNAP-REPO was found in server list but has no username/password."); - } - - @Test - void uploadHelmChart_withServerConfigurationWithoutPassword_shouldFail() { - // Given - final HelmConfig helm = helmConfig.chart("chart").version("1337-SNAPSHOT") - .snapshotRepository(completeValidRepository().password(null).build()).build(); - jKubeConfiguration.getRegistryConfig().getSettings() - .add(RegistryServerConfiguration.builder().id("SNAP-REPO").build()); - // When - final IllegalArgumentException result = assertThrows(IllegalArgumentException.class, () -> - helmService.uploadHelmChart(helm)); - // Then - assertThat(result).hasMessage("Repo SNAP-REPO has a username but no password defined."); - } - - - @Test - void uploadHelmChart_withMissingServerConfiguration_shouldFail() { - // Given - final HelmConfig helm = helmConfig.chart("chart").version("1337-SNAPSHOT") - .snapshotRepository(completeValidRepository().username(null).build()).build(); - jKubeConfiguration.getRegistryConfig().getSettings() - .add(RegistryServerConfiguration.builder().id("DIFFERENT").build()); - // When - final IllegalArgumentException result = assertThrows(IllegalArgumentException.class, () -> - helmService.uploadHelmChart(helm)); - // Then - assertThat(result).hasMessage("No credentials found for SNAP-REPO in configuration or settings.xml server list."); - } - - private static HelmRepository.HelmRepositoryBuilder completeValidRepository() { - return HelmRepository.builder() - .name("SNAP-REPO") - .type(HelmRepository.HelmRepoType.ARTIFACTORY) - .url("https://example.com/artifactory") - .username("User") - .password("S3cret"); - } } diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUploadIT.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUploadIT.java new file mode 100644 index 0000000000..b3205a2e95 --- /dev/null +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUploadIT.java @@ -0,0 +1,453 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.resource.helm; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayDeque; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.Queue; + +import io.fabric8.mockwebserver.Context; +import io.fabric8.mockwebserver.DefaultMockServer; +import io.fabric8.mockwebserver.MockServer; +import io.fabric8.mockwebserver.ServerRequest; +import io.fabric8.mockwebserver.ServerResponse; +import io.fabric8.mockwebserver.dsl.HttpMethod; +import io.fabric8.mockwebserver.internal.SimpleRequest; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.eclipse.jkube.kit.common.JKubeConfiguration; +import org.eclipse.jkube.kit.common.JavaProject; +import org.eclipse.jkube.kit.common.KitLogger; +import org.eclipse.jkube.kit.common.RegistryConfig; +import org.eclipse.jkube.kit.common.RegistryServerConfiguration; +import org.eclipse.jkube.kit.common.util.Base64Util; +import org.eclipse.jkube.kit.config.resource.ResourceServiceConfig; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; + +@DisplayName("HelmService.uploadHelmChart") +class HelmServiceUploadIT { + + private Map> responses; + private MockServer mockServer; + private KitLogger logger; + private HelmConfig helmConfig; + private RegistryServerConfiguration registryServerConfiguration; + private HelmService helmService; + + @BeforeEach + void setUp(@TempDir Path temporaryFolder) throws IOException { + responses = new HashMap<>(); + mockServer = new DefaultMockServer(new Context(), new MockWebServer(), responses, true); + logger = spy(new KitLogger.SilentLogger()); + final Path helmOutput = Files.createDirectory(temporaryFolder.resolve("helm-output")); + Files.write(Files.createDirectory(helmOutput.resolve("kubernetes")) + .resolve("Helm-Chart-1337-SNAPSHOT.tar"), "archive content".getBytes(StandardCharsets.UTF_8)); + helmConfig = HelmConfig.builder() + .chart("Helm-Chart") + .version("1337-SNAPSHOT") + .types(Collections.singletonList(HelmConfig.HelmType.KUBERNETES)) + .snapshotRepository(HelmRepository.builder() + .type(HelmRepository.HelmRepoType.ARTIFACTORY) + .name("SNAP-REPO") + .url(mockServer.url("/")) + .build()) + .outputDir(helmOutput.toFile().getAbsolutePath()) + .tarballOutputDir(helmOutput.toFile().getAbsolutePath()) + .chartExtension("tar") + .build(); + registryServerConfiguration = RegistryServerConfiguration.builder() + .id("SNAP-REPO") + .username("user") + .password("pa33word") + .build(); + helmService = new HelmService( + JKubeConfiguration.builder() + .project(JavaProject.builder().properties(new Properties()).build()) + .registryConfig(RegistryConfig.builder() + .settings(Collections.singletonList(registryServerConfiguration)).build()) + .build(), + new ResourceServiceConfig(), + logger); + } + + @AfterEach + void tearDown() { + helmService = null; + } + @Test + @DisplayName("With no repository configuration throws Exception") + void withNoRepositoryConfiguration_shouldFail() { + // Given + helmConfig.setVersion("1337-SNAPSHOT"); + helmConfig.setSnapshotRepository(null); + // When + final IllegalStateException result = assertThrows(IllegalStateException.class, + () -> helmService.uploadHelmChart(helmConfig)); + // Then + assertThat(result).hasMessage("No repository or invalid repository configured for upload"); + } + + @Test + @DisplayName("With repository configuration missing URL throws Exception") + void withRepositoryConfigurationMissingUrl_shouldFail() { + // Given + helmConfig.setVersion("1337-SNAPSHOT"); + helmConfig.setSnapshotRepository(HelmRepository.builder() + .type(HelmRepository.HelmRepoType.ARTIFACTORY) + .name("name") + .build()); + // When + final IllegalStateException result = assertThrows(IllegalStateException.class, + () -> helmService.uploadHelmChart(helmConfig)); + // Then + assertThat(result).hasMessage("No repository or invalid repository configured for upload"); + } + + @Test + @DisplayName("With repository configuration missing type throws Exception") + void withRepositoryConfigurationMissingType_shouldFail() { + // Given + helmConfig.setVersion("1337-SNAPSHOT"); + helmConfig.setSnapshotRepository(HelmRepository.builder() + .name("name") + .url("https://example.com") + .build()); + // When + final IllegalStateException result = assertThrows(IllegalStateException.class, + () -> helmService.uploadHelmChart(helmConfig)); + // Then + assertThat(result).hasMessage("No repository or invalid repository configured for upload"); + } + + @Test + @DisplayName("With repository configuration missing name throws Exception") + void withRepositoryConfigurationMissingName_shouldFail() { + // Given + helmConfig.setVersion("1337-SNAPSHOT"); + helmConfig.setSnapshotRepository(HelmRepository.builder() + .type(HelmRepository.HelmRepoType.ARTIFACTORY) + .url("https://example.com") + .build()); + // When + final IllegalStateException result = assertThrows(IllegalStateException.class, + () -> helmService.uploadHelmChart(helmConfig)); + // Then + assertThat(result).hasMessage("No repository or invalid repository configured for upload"); + } + + @Test + @DisplayName("With no server configuration throws Exception") + void withNoServerConfiguration_shouldFail() { + // Given + helmConfig.getSnapshotRepository().setName("NOT-SNAP-REPO"); + // When + final IllegalArgumentException result = assertThrows(IllegalArgumentException.class, () -> + helmService.uploadHelmChart(helmConfig)); + // Then + assertThat(result).hasMessage("No credentials found for NOT-SNAP-REPO in configuration or settings.xml server list."); + } + + @Test + @DisplayName("With no server configuration and repository with username throws Exception") + void withNoServerConfigurationAndRepositoryWithUsername_shouldFail() { + // Given + helmConfig.getSnapshotRepository().setName("NOT-SNAP-REPO"); + helmConfig.getSnapshotRepository().setUsername("user"); + // When + final IllegalArgumentException result = assertThrows(IllegalArgumentException.class, () -> + helmService.uploadHelmChart(helmConfig)); + // Then + assertThat(result).hasMessage("Repo NOT-SNAP-REPO has a username but no password defined."); + } + + @Test + @DisplayName("With server configuration missing username throws Exception") + void withServerConfigurationWithoutUsername_shouldFail() { + // Given + registryServerConfiguration.setUsername(null); + // When + final IllegalArgumentException result = assertThrows(IllegalArgumentException.class, () -> + helmService.uploadHelmChart(helmConfig)); + // Then + assertThat(result).hasMessage("Repo SNAP-REPO was found in server list but has no username/password."); + } + + @Test + @DisplayName("With server configuration missing password throws Exception") + void withServerConfigurationWithoutPassword_shouldFail() { + // Given + registryServerConfiguration.setPassword(null); + // When + final IllegalArgumentException result = assertThrows(IllegalArgumentException.class, () -> + helmService.uploadHelmChart(helmConfig)); + // Then + assertThat(result).hasMessage("Repo SNAP-REPO was found in server list but has no username/password."); + } + + @Test + void withServerErrorAndErrorStream_shouldThrowException() { + // Given + mockServer.expect() + .put().withPath("/Helm-Chart-1337-SNAPSHOT.tar") + .andReturn(500, "Server error in ES") + .always(); + // When + final BadUploadException result = assertThrows(BadUploadException.class, + () -> helmService.uploadHelmChart(helmConfig)); + // Then + assertThat(result) + .isNotNull() + .hasMessage("Server error in ES"); + } + + @Test + void withServerErrorAndInputStream_shouldThrowException() { + // Given + mockServer.expect() + .put().withPath("/Helm-Chart-1337-SNAPSHOT.tar") + .andReturn(302, "Server error in IS") + .always(); + // When + final BadUploadException result = assertThrows(BadUploadException.class, + () -> helmService.uploadHelmChart(helmConfig)); + // Then + assertThat(result) + .isNotNull() + .hasMessage("Server error in IS"); + } + + @Test + void withServerErrorAndNoDetails_shouldThrowException() { + // Given + mockServer.expect() + .put().withPath("/Helm-Chart-1337-SNAPSHOT.tar") + .andReturn(404, "") + .always(); + // When + final FileNotFoundException result = assertThrows(FileNotFoundException.class, + () -> helmService.uploadHelmChart(helmConfig)); + // Then + assertThat(result).isNotNull(); + } + + @DisplayName("Authorizes with registry server credentials (PUT)") + @ParameterizedTest(name = "{index}: with repository type {0}") + @ValueSource(strings = {"ARTIFACTORY", "NEXUS"}) + void withPutUpload_shouldUseRegistryServerCredentials(String repositoryType) throws Exception { + // Given + helmConfig.getSnapshotRepository().setType(repositoryType); + expect(HttpMethod.PUT, "/Helm-Chart-1337-SNAPSHOT.tar", new NeedsAuthorizationResponse()); + // When + helmService.uploadHelmChart(helmConfig); + // Then + assertThat(mockServer.getLastRequest()) + .extracting(r -> r.getHeader("Authorization")) + .isEqualTo("Basic " + Base64Util.encodeToString("user:pa33word")); + } + + @DisplayName("Authorizes with registry server credentials (POST)") + @ParameterizedTest(name = "{index}: with repository type {0}") + @ValueSource(strings = {"CHARTMUSEUM"}) + void withPostUpload_shouldUseRegistryServerCredentials(String repositoryType) throws Exception { + // Given + helmConfig.getSnapshotRepository().setType(repositoryType); + expect(HttpMethod.POST, "/", new NeedsAuthorizationResponse()); + // When + helmService.uploadHelmChart(helmConfig); + // Then + assertThat(mockServer.getLastRequest()) + .extracting(r -> r.getHeader("Authorization")) + .isEqualTo("Basic " + Base64Util.encodeToString("user:pa33word")); + } + + @DisplayName("Authorizes with repository credentials -take precedence- (PUT)") + @ParameterizedTest(name = "{index}: with repository type {0}") + @ValueSource(strings = {"ARTIFACTORY", "NEXUS"}) + void withPutUploadAndRepositoryCredentials_shouldUseRepositoryCredentials(String repositoryType) throws Exception { + // Given + helmConfig.getSnapshotRepository().setType(repositoryType); + helmConfig.getSnapshotRepository().setUsername("these"); + helmConfig.getSnapshotRepository().setPassword("take-precedence"); + expect(HttpMethod.PUT, "/Helm-Chart-1337-SNAPSHOT.tar", new NeedsAuthorizationResponse()); + // When + helmService.uploadHelmChart(helmConfig); + // Then + assertThat(mockServer.getLastRequest()) + .extracting(r -> r.getHeader("Authorization")) + .isEqualTo("Basic " + Base64Util.encodeToString("these:take-precedence")); + } + + @DisplayName("Authorizes with repository credentials -take precedence- (POST)") + @ParameterizedTest(name = "{index}: with repository type {0}") + @ValueSource(strings = {"CHARTMUSEUM"}) + void withPostUploadAndRepositoryCredentials_shouldUseRepositoryCredentials(String repositoryType) throws Exception { + // Given + helmConfig.getSnapshotRepository().setType(repositoryType); + helmConfig.getSnapshotRepository().setUsername("these"); + helmConfig.getSnapshotRepository().setPassword("take-precedence"); + expect(HttpMethod.POST, "/", new NeedsAuthorizationResponse()); + // When + helmService.uploadHelmChart(helmConfig); + // Then + assertThat(mockServer.getLastRequest()) + .extracting(r -> r.getHeader("Authorization")) + .isEqualTo("Basic " + Base64Util.encodeToString("these:take-precedence")); + } + + @DisplayName("Logs success after successful PUT request") + @ParameterizedTest(name = "{index}: with repository type {0}") + @ValueSource(strings = {"ARTIFACTORY", "NEXUS"}) + void withSuccessfulPutUpload_shouldLogSuccess(String repositoryType) throws Exception { + // Given + helmConfig.getSnapshotRepository().setType(repositoryType); + mockServer.expect() + .put().withPath("/Helm-Chart-1337-SNAPSHOT.tar") + .andReturn(201, "Upload successful") + .always(); + // When + helmService.uploadHelmChart(helmConfig); + // Then + verify(logger).info("201 - Upload successful"); + } + + @DisplayName("Logs success after successful POST request") + @ParameterizedTest(name = "{index}: with repository type {0}") + @ValueSource(strings = {"CHARTMUSEUM"}) + void withSuccessfulPostUpload_shouldLogSuccess(String repositoryType) throws Exception { + // Given + helmConfig.getSnapshotRepository().setType(repositoryType); + mockServer.expect() + .post().withPath("/") + .andReturn(201, "Upload successful") + .always(); + // When + helmService.uploadHelmChart(helmConfig); + // Then + verify(logger).info("201 - Upload successful"); + } + + @DisplayName("Sends file in PUT request") + @ParameterizedTest(name = "{index}: with repository type {0}") + @ValueSource(strings = {"ARTIFACTORY", "NEXUS"}) + void withSuccessfulPutUpload_shouldPutFile(String repositoryType) throws Exception { + // Given + helmConfig.getSnapshotRepository().setType(repositoryType); + mockServer.expect() + .put().withPath("/Helm-Chart-1337-SNAPSHOT.tar") + .andReturn(201, "Upload successful") + .always(); + // When + helmService.uploadHelmChart(helmConfig); + // Then + assertThat(mockServer.getLastRequest().getBody().readUtf8()) + .isEqualTo("archive content"); + } + + @DisplayName("Sends file in POST request") + @ParameterizedTest(name = "{index}: with repository type {0}") + @ValueSource(strings = {"CHARTMUSEUM"}) + void withSuccessfulPostUpload_shouldPostFile(String repositoryType) throws Exception { + // Given + helmConfig.getSnapshotRepository().setType(repositoryType); + mockServer.expect() + .post().withPath("/") + .andReturn(201, "Upload successful") + .always(); + // When + helmService.uploadHelmChart(helmConfig); + // Then + assertThat(mockServer.getLastRequest().getBody().readUtf8()) + .isEqualTo("archive content"); + } + + @DisplayName("Nexus repository specifics") + @Nested + class Nexus { + + @BeforeEach + void setUp() { + helmConfig.getSnapshotRepository().setType("NEXUS"); + } + + @Test + @DisplayName(".tar.gz extension is contracted to .tgz") + void tgzExtensionHandling() throws Exception { + // Given + helmConfig.setChartExtension("tar.gz"); + Files.write( + Paths.get(helmConfig.getOutputDir()).resolve("kubernetes") + .resolve("Helm-Chart-1337-SNAPSHOT.tar.gz"), + "I'm a tar.gz, not a .tgz".getBytes(StandardCharsets.UTF_8)); + mockServer.expect() + .put().withPath("/Helm-Chart-1337-SNAPSHOT.tgz") + .andReturn(201, "Upload successful") + .always(); + // When + helmService.uploadHelmChart(helmConfig); + // Then + assertThat(mockServer.getLastRequest().getBody().readUtf8()) + .isEqualTo("I'm a tar.gz, not a .tgz"); + } + } + + private void expect(HttpMethod method, String path, ServerResponse response) { + responses.computeIfAbsent( + new SimpleRequest(method, path), + k -> new ArrayDeque<>()) + .add(response); + } + + private static final class NeedsAuthorizationResponse implements ServerResponse { + @Override + public boolean isRepeatable() { + // always() + return true; + } + + @Override + public MockResponse toMockResponse(RecordedRequest recordedRequest) { + if (recordedRequest.getHeader("Authorization") != null) { + return new MockResponse() + .setResponseCode(201).setBody("Upload successful"); + } else { + return new MockResponse() + .setResponseCode(401) + .setHeader("WWW-Authenticate", "Basic") + .setBody("Unauthorized"); + } + } + } +} diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderTest.java deleted file mode 100644 index e7170fe9d8..0000000000 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/** - * Copyright (c) 2019 Red Hat, Inc. - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at: - * - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - */ -package org.eclipse.jkube.kit.resource.helm; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.net.HttpURLConnection; - -import org.eclipse.jkube.kit.common.KitLogger; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.RETURNS_DEEP_STUBS; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -class HelmUploaderTest { - - @TempDir - File temporaryFolder; - - private KitLogger kitLogger; - - private HelmUploader helmUploader; - - @BeforeEach - void setUp() { - kitLogger = mock(KitLogger.class); - helmUploader = new HelmUploader(kitLogger); - } - - @AfterEach - void tearDown() { - kitLogger = null; - helmUploader = null; - } - - @Test - void uploadSingle_withMissingType_shouldThrowException() { - HelmRepository helmRepository = mock(HelmRepository.class); - // Given - File file = new File("test"); - when(helmRepository.getType()).thenReturn(null); - // When - final IllegalArgumentException result = assertThrows(IllegalArgumentException.class, - () -> helmUploader.uploadSingle(file, helmRepository)); - // Then - assertThat(result) - .isNotNull() - .hasMessage("Repository type missing. Check your plugin configuration."); - } - - @Test - void uploadSingle_withServerErrorAndErrorStream_shouldThrowException() throws IOException { - HelmRepository helmRepository = mock(HelmRepository.class, RETURNS_DEEP_STUBS); - HttpURLConnection httpURLConnection = mock(HttpURLConnection.class); - // Given - File file = File.createTempFile("test", "tmp", temporaryFolder); - when(helmRepository.getType().createConnection(any(File.class), eq(helmRepository))).thenReturn(httpURLConnection); - when(httpURLConnection.getResponseCode()).thenReturn(500); - when(httpURLConnection.getErrorStream()).thenReturn(new ByteArrayInputStream("Server error in ES".getBytes())); - when(httpURLConnection.getInputStream()).thenReturn(new ByteArrayInputStream("Server error in IS".getBytes())); - - // When - final BadUploadException result = assertThrows(BadUploadException.class, - () -> helmUploader.uploadSingle(file, helmRepository)); - // Then - assertThat(result) - .isNotNull() - .hasMessage("Server error in ES"); - } - - @Test - void uploadSingle_withServerErrorAndInputStream_shouldThrowException() throws IOException { - // Given - HelmRepository helmRepository = mock(HelmRepository.class, RETURNS_DEEP_STUBS); - HttpURLConnection httpURLConnection = mock(HttpURLConnection.class); - File file = File.createTempFile("test", "tmp", temporaryFolder); - when(helmRepository.getType().createConnection(any(File.class), eq(helmRepository))).thenReturn(httpURLConnection); - when(httpURLConnection.getResponseCode()).thenReturn(500); - when(httpURLConnection.getErrorStream()).thenReturn(null); - when(httpURLConnection.getInputStream()).thenReturn(new ByteArrayInputStream("Server error in IS".getBytes())); - // When - final BadUploadException result = assertThrows(BadUploadException.class, - () -> helmUploader.uploadSingle(file, helmRepository)); - // Then - assertThat(result) - .isNotNull() - .hasMessage("Server error in IS"); - } - - @Test - void uploadSingle_withServerError_shouldThrowException() throws IOException { - // Given - HelmRepository helmRepository = mock(HelmRepository.class, RETURNS_DEEP_STUBS); - HttpURLConnection httpURLConnection = mock(HttpURLConnection.class); - File file = File.createTempFile("test", "tmp", temporaryFolder); - when(helmRepository.getType().createConnection(any(File.class), eq(helmRepository))).thenReturn(httpURLConnection); - when(httpURLConnection.getResponseCode()).thenReturn(500); - when(httpURLConnection.getErrorStream()).thenReturn(null); - when(httpURLConnection.getInputStream()).thenReturn(null); - // When - final BadUploadException result = assertThrows(BadUploadException.class, - () -> helmUploader.uploadSingle(file, helmRepository)); - // Then - assertThat(result) - .isNotNull() - .hasMessage("No details provided"); - } - - @Test - void uploadSingle_withCreatedStatus_shouldDisconnect()throws IOException, BadUploadException { - // Given - HelmRepository helmRepository = mock(HelmRepository.class, RETURNS_DEEP_STUBS); - HttpURLConnection httpURLConnection = mock(HttpURLConnection.class); - File file = File.createTempFile("test", "tmp", temporaryFolder); - when(helmRepository.getType().createConnection(any(File.class), eq(helmRepository))).thenReturn(httpURLConnection); - when(httpURLConnection.getResponseCode()).thenReturn(201); - when(httpURLConnection.getInputStream()).thenReturn(null); - // When - helmUploader.uploadSingle(file, helmRepository); - // Then - verify(httpURLConnection, times(1)).disconnect(); - } -} From 0ca194de004364726a0cb2420e7f990c6976e6ce Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Thu, 6 Jul 2023 20:20:09 +0530 Subject: [PATCH 24/65] test (jkube-kit-spring-boot) : Add more tests for Spring Boot generator + Add SpringBootGeneratorIntegrationTest to test SpringBootGenerator behavior + Add test for SpringBootConfigurationHelper for cases that are not covered by AbstractSpringBootHealthCheckEnricherTest + Add additional missing test cases in SprignBootGeneratorTest Signed-off-by: Rohan Kumar --- .../SpringBootConfigurationHelperTest.java | 44 +++ .../SpringBootGeneratorIntegrationTest.java | 306 ++++++++++++++++++ .../generator/SpringBootGeneratorTest.java | 116 +++++++ .../application.properties | 1 + .../application.properties | 1 + 5 files changed, 468 insertions(+) create mode 100644 jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/SpringBootConfigurationHelperTest.java create mode 100644 jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/generator/SpringBootGeneratorIntegrationTest.java create mode 100644 jkube-kit/jkube-kit-spring-boot/src/test/resources/devtools-application-properties/application.properties create mode 100644 jkube-kit/jkube-kit-spring-boot/src/test/resources/port-override-application-properties/application.properties diff --git a/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/SpringBootConfigurationHelperTest.java b/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/SpringBootConfigurationHelperTest.java new file mode 100644 index 0000000000..cc99a0a13e --- /dev/null +++ b/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/SpringBootConfigurationHelperTest.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.common.util; + +import org.junit.jupiter.api.Test; + +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; + +class SpringBootConfigurationHelperTest { + @Test + void undefinedSpringBootVersion_shouldDefaultToSpringBoot1ConfigurationProperties() { + // Given + Optional springBootVersion = Optional.of("undefined"); + SpringBootConfigurationHelper springBootConfigurationHelper = new SpringBootConfigurationHelper(springBootVersion); + + // When + Then + assertSpringBoot1ConfigurationProperties(springBootConfigurationHelper); + } + + private void assertSpringBoot1ConfigurationProperties(SpringBootConfigurationHelper springBootConfigurationHelper) { + assertThat(springBootConfigurationHelper.getManagementPortPropertyKey()).isEqualTo("management.port"); + assertThat(springBootConfigurationHelper.getServerPortPropertyKey()).isEqualTo("server.port"); + assertThat(springBootConfigurationHelper.getServerKeystorePropertyKey()).isEqualTo("server.ssl.key-store"); + assertThat(springBootConfigurationHelper.getManagementKeystorePropertyKey()).isEqualTo("management.ssl.key-store"); + assertThat(springBootConfigurationHelper.getServletPathPropertyKey()).isEqualTo("server.servlet-path"); + assertThat(springBootConfigurationHelper.getServerContextPathPropertyKey()).isEqualTo("server.context-path"); + assertThat(springBootConfigurationHelper.getManagementContextPathPropertyKey()).isEqualTo("management.context-path"); + assertThat(springBootConfigurationHelper.getActuatorBasePathPropertyKey()).isEmpty(); + assertThat(springBootConfigurationHelper.getActuatorDefaultBasePath()).isEmpty(); + } +} diff --git a/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/generator/SpringBootGeneratorIntegrationTest.java b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/generator/SpringBootGeneratorIntegrationTest.java new file mode 100644 index 0000000000..d376551d26 --- /dev/null +++ b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/generator/SpringBootGeneratorIntegrationTest.java @@ -0,0 +1,306 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.springboot.generator; + +import org.assertj.core.api.InstanceOfAssertFactories; +import org.eclipse.jkube.generator.api.GeneratorContext; +import org.eclipse.jkube.generator.api.GeneratorMode; +import org.eclipse.jkube.generator.javaexec.FatJarDetector; +import org.eclipse.jkube.kit.common.Assembly; +import org.eclipse.jkube.kit.common.AssemblyConfiguration; +import org.eclipse.jkube.kit.common.Dependency; +import org.eclipse.jkube.kit.common.JavaProject; +import org.eclipse.jkube.kit.common.KitLogger; +import org.eclipse.jkube.kit.common.Plugin; +import org.eclipse.jkube.kit.config.image.ImageConfiguration; +import org.eclipse.jkube.kit.config.image.build.BuildConfiguration; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.mockito.MockedConstruction; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.Properties; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.mockConstruction; +import static org.mockito.Mockito.when; + +class SpringBootGeneratorIntegrationTest { + private File targetDir; + private Properties properties; + @TempDir + Path temporaryFolder; + + private GeneratorContext context; + + @BeforeEach + void setUp() throws IOException { + properties = new Properties(); + targetDir = Files.createDirectory(temporaryFolder.resolve("target")).toFile(); + JavaProject javaProject = JavaProject.builder() + .baseDirectory(temporaryFolder.toFile()) + .buildDirectory(targetDir.getAbsoluteFile()) + .buildPackageDirectory(targetDir.getAbsoluteFile()) + .outputDirectory(targetDir) + .properties(properties) + .version("1.0.0") + .dependency(Dependency.builder() + .groupId("org.springframework.boot") + .artifactId("spring-boot-web") + .version("2.7.2") + .build()) + .plugin(Plugin.builder() + .groupId("org.springframework.boot") + .artifactId("spring-boot-maven-plugin") + .version("2.7.2") + .build()) + .buildFinalName("sample") + .build(); + context = GeneratorContext.builder() + .logger(new KitLogger.SilentLogger()) + .project(javaProject) + .build(); + } + + @Test + @DisplayName("customize, with standard packaging, has image name") + void customize_withStandardPackaging_thenImageNameContainsGroupArtifactAndLatestTag() { + // Given + withCustomMainClass(); + SpringBootGenerator springBootGenerator = new SpringBootGenerator(context); + List images = new ArrayList<>(); + + // When + images = springBootGenerator.customize(images, false); + + // Then + assertThat(images) + .singleElement(InstanceOfAssertFactories.type(ImageConfiguration.class)) + .hasFieldOrPropertyWithValue("name", "%g/%a:%l"); + } + + @Test + @DisplayName("customize, with standard packaging, has image alias") + void customize_withStandardPackaging_thenImageAliasSpringBoot() { + // Given + withCustomMainClass(); + SpringBootGenerator springBootGenerator = new SpringBootGenerator(context); + List images = new ArrayList<>(); + + // When + images = springBootGenerator.customize(images, false); + + // Then + assertThat(images) + .singleElement(InstanceOfAssertFactories.type(ImageConfiguration.class)) + .hasFieldOrPropertyWithValue("alias", "spring-boot"); + } + + @Test + @DisplayName("customize, with standard packaging, has image from") + void customize_withStandardPackaging_hasFrom() { + // Given + withCustomMainClass(); + SpringBootGenerator springBootGenerator = new SpringBootGenerator(context); + List images = new ArrayList<>(); + + // When + images = springBootGenerator.customize(images, false); + + // Then + assertThat(images) + .singleElement(InstanceOfAssertFactories.type(ImageConfiguration.class)) + .extracting(ImageConfiguration::getBuild) + .extracting(BuildConfiguration::getFrom) + .asString() + .startsWith("quay.io/jkube/jkube-java"); + } + + @Test + @DisplayName("customize, with standard packaging, has default web port") + void customize_withStandardPackaging_thenImageHasDefaultWebPort() { + // Given + withCustomMainClass(); + SpringBootGenerator springBootGenerator = new SpringBootGenerator(context); + List images = new ArrayList<>(); + + // When + images = springBootGenerator.customize(images, false); + + // Then + assertThat(images) + .singleElement() + .extracting("buildConfiguration.ports").asList() + .contains("8080"); + } + + @Test + @DisplayName("customize, with standard packaging, has Jolokia port") + void customize_withStandardPackaging_hasJolokiaPort() { + // When + final List result = new SpringBootGenerator(context).customize(new ArrayList<>(), true); + // Then + assertThat(result).singleElement() + .extracting("buildConfiguration.ports").asList() + .contains("8778"); + } + + @Test + @DisplayName("customize, with standard packaging, has Prometheus port") + void customize_withStandardPackaging_hasPrometheusPort() { + // When + final List result = new SpringBootGenerator(context).customize(new ArrayList<>(), true); + // Then + assertThat(result).singleElement() + .extracting("buildConfiguration.ports").asList() + .contains("9779"); + } + + @Test + @DisplayName("customize, in Kubernetes and jar artifact, should create assembly") + void customize_inKubernetesAndJarArtifact_shouldCreateAssembly() throws IOException { + try (MockedConstruction ignore = mockConstruction(FatJarDetector.class, (mock, ctx) -> { + FatJarDetector.Result fatJarDetectorResult = mock(FatJarDetector.Result.class); + when(mock.scan()).thenReturn(fatJarDetectorResult); + when(fatJarDetectorResult.getArchiveFile()).thenReturn(targetDir.toPath().resolve("sample.jar").toFile()); + })) { + // Given + Files.createFile(targetDir.toPath().resolve("sample.jar")); + + // When + final List resultImages = new SpringBootGenerator(context).customize(new ArrayList<>(), false); + + // Then + assertThat(resultImages) + .isNotNull() + .singleElement() + .extracting(ImageConfiguration::getBuild) + .extracting(BuildConfiguration::getAssembly) + .hasFieldOrPropertyWithValue("targetDir", "/deployments") + .hasFieldOrPropertyWithValue("excludeFinalOutputArtifact", true) + .extracting(AssemblyConfiguration::getLayers) + .asList().hasSize(1) + .satisfies(layers -> assertThat(layers).element(0).asInstanceOf(InstanceOfAssertFactories.type(Assembly.class)) + .extracting(Assembly::getFileSets) + .asList().element(2) + .hasFieldOrPropertyWithValue("outputDirectory", new File(".")) + .extracting("includes").asList() + .containsExactly("sample.jar")); + } + } + + @Test + @DisplayName("customize, with standard packaging, has java environment variables") + void customize_withStandardPackaging_thenImageHasJavaMainClassAndJavaAppDirEnvVars() { + // Given + withCustomMainClass(); + SpringBootGenerator springBootGenerator = new SpringBootGenerator(context); + List images = new ArrayList<>(); + + // When + images = springBootGenerator.customize(images, false); + + // Then + assertThat(images) + .singleElement(InstanceOfAssertFactories.type(ImageConfiguration.class)) + .extracting(ImageConfiguration::getBuild) + .extracting(BuildConfiguration::getEnv) + .asInstanceOf(InstanceOfAssertFactories.MAP) + .containsEntry("JAVA_MAIN_CLASS", "org.example.Foo") + .containsEntry("JAVA_APP_DIR", "/deployments"); + } + + @Test + @DisplayName("customize, with custom port in application.properties, has overridden web port in image") + void customize_whenApplicationPortOverridden_shouldUseOverriddenWebPort() { + // Given + withCustomMainClass(); + context = context.toBuilder() + .project(context.getProject().toBuilder() + .compileClassPathElement(Objects.requireNonNull(getClass().getResource("/port-override-application-properties")).getPath()) + .build()) + .build(); + SpringBootGenerator springBootGenerator = new SpringBootGenerator(context); + List images = new ArrayList<>(); + + // When + images = springBootGenerator.customize(images, false); + + // Then + assertThat(images) + .singleElement() + .extracting("buildConfiguration.ports").asList() + .contains("8081"); + } + + @Test + @DisplayName("customize, when generator mode WATCH, then add Spring Boot Devtools environment variable to image") + void customize_whenGeneratorModeWatch_shouldAddSpringBootDevtoolsSecretEnvVar() { + // Given + withCustomMainClass(); + context = context.toBuilder() + .generatorMode(GeneratorMode.WATCH) + .project(context.getProject().toBuilder() + .compileClassPathElement(Objects.requireNonNull(getClass().getResource("/devtools-application-properties")).getPath()) + .build()) + .build(); + SpringBootGenerator springBootGenerator = new SpringBootGenerator(context); + List images = new ArrayList<>(); + + // When + images = springBootGenerator.customize(images, false); + + // Then + assertThat(images) + .singleElement(InstanceOfAssertFactories.type(ImageConfiguration.class)) + .extracting(ImageConfiguration::getBuild) + .extracting(BuildConfiguration::getEnv) + .asInstanceOf(InstanceOfAssertFactories.MAP) + .containsEntry("SPRING_DEVTOOLS_REMOTE_SECRET", "some-secret"); + } + + @Test + @DisplayName("customize, when color configuration provided, then add spring.output.ansi.enabled property to JAVA_OPTIONS environment variable") + void customize_withColorConfiguration_shouldAddAnsiEnabledPropertyToJavaOptions() { + // Given + properties.put("jkube.generator.spring-boot.color", "always"); + withCustomMainClass(); + List images = new ArrayList<>(); + SpringBootGenerator springBootGenerator = new SpringBootGenerator(context); + + // When + images = springBootGenerator.customize(images, false); + + // Then + assertThat(images) + .singleElement(InstanceOfAssertFactories.type(ImageConfiguration.class)) + .extracting(ImageConfiguration::getBuild) + .extracting(BuildConfiguration::getEnv) + .asInstanceOf(InstanceOfAssertFactories.MAP) + .containsEntry("JAVA_OPTIONS", "-Dspring.output.ansi.enabled=always"); + } + + private void withCustomMainClass() { + properties.put("jkube.generator.spring-boot.mainClass", "org.example.Foo"); + } +} diff --git a/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/generator/SpringBootGeneratorTest.java b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/generator/SpringBootGeneratorTest.java index 830a180c43..109b81a9d5 100644 --- a/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/generator/SpringBootGeneratorTest.java +++ b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/generator/SpringBootGeneratorTest.java @@ -13,6 +13,7 @@ */ package org.eclipse.jkube.springboot.generator; +import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -20,8 +21,12 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Properties; import org.eclipse.jkube.generator.api.GeneratorContext; +import org.eclipse.jkube.generator.api.GeneratorMode; import org.eclipse.jkube.kit.common.JavaProject; import org.eclipse.jkube.kit.common.KitLogger; import org.eclipse.jkube.kit.common.Plugin; @@ -29,10 +34,12 @@ import org.eclipse.jkube.kit.config.image.build.BuildConfiguration; import org.assertj.core.api.InstanceOfAssertFactories; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; class SpringBootGeneratorTest { @@ -49,6 +56,22 @@ void setUp(@TempDir Path temporaryFolder) throws IOException { .build(); } + @Test + @DisplayName("isApplicable, when valid ImageConfiguration present, then returns false") + void isApplicable_whenImageConfigurationPresent_thenReturnFalse() { + // Given + final List configs = Collections.singletonList(ImageConfiguration.builder() + .name("foo:latest") + .build(BuildConfiguration.builder() + .from("foo-base:latest") + .build()) + .build()); + // When + boolean result = new SpringBootGenerator(context).isApplicable(configs); + // Then + assertThat(result).isFalse(); + } + @Test void isApplicable_withNoImageConfigurations_shouldReturnFalse() { // When @@ -106,6 +129,99 @@ void customize_withEmptyList_shouldReturnAddedImage() { .containsEntry("JAVA_APP_DIR", "/deployments"); } + @Test + void isFatJar_whenSpringBootRepackageAndNoMainClass_thenReturnTrue() { + // Given + context = context.toBuilder() + .project(context.getProject().toBuilder().plugin(Plugin.builder() + .groupId("org.springframework.boot") + .artifactId("spring-boot-maven-plugin") + .executions(Collections.singletonList("repackage")) + .build()) + .build()) + .build(); + SpringBootGenerator springBootGenerator = new SpringBootGenerator(context); + + // When + boolean result = springBootGenerator.isFatJar(); + + // Then + assertThat(result).isTrue(); + } + + @Test + void getEnv_whenGeneratorModeWatch_thenAddSpringBootDevtoolsEnvVar() { + // Given + context = context.toBuilder().generatorMode(GeneratorMode.WATCH) + .project(context.getProject().toBuilder().compileClassPathElement(Objects.requireNonNull(getClass().getResource("/devtools-application-properties")).getPath()) + .build()) + .build(); + SpringBootGenerator springBootGenerator = new SpringBootGenerator(context); + + // When + Map result = springBootGenerator.getEnv(true); + + // Then + assertThat(result) + .containsEntry("SPRING_DEVTOOLS_REMOTE_SECRET", "some-secret"); + } + + @Test + void customize_whenGeneratorModeWatchAndNoDevtoolsRemoteSecret_shouldThrowException(@TempDir File temporaryFolder) { + // Given + context = context.toBuilder() + .project(context.getProject().toBuilder() + .baseDirectory(temporaryFolder) + .build()) + .generatorMode(GeneratorMode.WATCH) + .build(); + + // When + Then + assertThatIllegalStateException() + .isThrownBy(() -> new SpringBootGenerator(context).customize(new ArrayList<>(), false)) + .withMessage("No spring.devtools.remote.secret found in application.properties. Plugin has added it, please re-run goals"); + } + + @Test + void customize_whenGeneratorModeWatchAndDevtoolsSecretPresent_thenAddDevtoolsSecretEnvVar() { + // Given + Properties properties = new Properties(); + properties.put("jkube.generator.spring-boot.mainClass", "org.example.Foo"); + context = context.toBuilder() + .generatorMode(GeneratorMode.WATCH) + .project(context.getProject().toBuilder() + .properties(properties) + .compileClassPathElement(Objects.requireNonNull(getClass().getResource("/devtools-application-properties")).getPath()) + .build()) + .build(); + + // When + List imageConfigurations = new SpringBootGenerator(context).customize(new ArrayList<>(), false); + + // Then + assertThat(imageConfigurations) + .singleElement(InstanceOfAssertFactories.type(ImageConfiguration.class)) + .extracting(ImageConfiguration::getBuild) + .extracting(BuildConfiguration::getEnv) + .asInstanceOf(InstanceOfAssertFactories.MAP) + .containsEntry("SPRING_DEVTOOLS_REMOTE_SECRET", "some-secret"); + } + + @Test + void getExtraJavaOptions_whenColorEnabled_thenAddColorOption() { + // Given + Properties properties = new Properties(); + properties.put("jkube.generator.spring-boot.color", "detect"); + context = context.toBuilder().project(context.getProject().toBuilder().properties(properties).build()).build(); + SpringBootGenerator springBootGenerator = new SpringBootGenerator(context); + + // When + List javaOptions = springBootGenerator.getExtraJavaOptions(); + + // Then + assertThat(javaOptions).contains("-Dspring.output.ansi.enabled=detect"); + } + private void withPlugin(Plugin plugin) { context = context.toBuilder() .project(JavaProject.builder().plugin(plugin).build()) diff --git a/jkube-kit/jkube-kit-spring-boot/src/test/resources/devtools-application-properties/application.properties b/jkube-kit/jkube-kit-spring-boot/src/test/resources/devtools-application-properties/application.properties new file mode 100644 index 0000000000..51acd0c109 --- /dev/null +++ b/jkube-kit/jkube-kit-spring-boot/src/test/resources/devtools-application-properties/application.properties @@ -0,0 +1 @@ +spring.devtools.remote.secret=some-secret \ No newline at end of file diff --git a/jkube-kit/jkube-kit-spring-boot/src/test/resources/port-override-application-properties/application.properties b/jkube-kit/jkube-kit-spring-boot/src/test/resources/port-override-application-properties/application.properties new file mode 100644 index 0000000000..bafddced85 --- /dev/null +++ b/jkube-kit/jkube-kit-spring-boot/src/test/resources/port-override-application-properties/application.properties @@ -0,0 +1 @@ +server.port=8081 \ No newline at end of file From 2022659d98e7933e418690c095c148e974c4a1e2 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Tue, 11 Jul 2023 13:06:51 +0200 Subject: [PATCH 25/65] test: SpringBootConfigurationHelperTest has specific assertions Signed-off-by: Marc Nuri --- .../SpringBootConfigurationHelperTest.java | 177 ++++++++++++++++-- .../SpringBootGeneratorIntegrationTest.java | 10 +- 2 files changed, 164 insertions(+), 23 deletions(-) diff --git a/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/SpringBootConfigurationHelperTest.java b/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/SpringBootConfigurationHelperTest.java index cc99a0a13e..7a0ba90e3d 100644 --- a/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/SpringBootConfigurationHelperTest.java +++ b/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/SpringBootConfigurationHelperTest.java @@ -13,32 +13,173 @@ */ package org.eclipse.jkube.kit.common.util; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import java.util.Optional; +import java.util.Properties; import static org.assertj.core.api.Assertions.assertThat; class SpringBootConfigurationHelperTest { - @Test - void undefinedSpringBootVersion_shouldDefaultToSpringBoot1ConfigurationProperties() { - // Given - Optional springBootVersion = Optional.of("undefined"); - SpringBootConfigurationHelper springBootConfigurationHelper = new SpringBootConfigurationHelper(springBootVersion); - - // When + Then - assertSpringBoot1ConfigurationProperties(springBootConfigurationHelper); + + private Properties properties; + + @BeforeEach + void setUp() { + properties = new Properties(); + properties.put("management.port", "1"); + properties.put("management.server.port", "2"); + properties.put("server.port", "1"); } - private void assertSpringBoot1ConfigurationProperties(SpringBootConfigurationHelper springBootConfigurationHelper) { - assertThat(springBootConfigurationHelper.getManagementPortPropertyKey()).isEqualTo("management.port"); - assertThat(springBootConfigurationHelper.getServerPortPropertyKey()).isEqualTo("server.port"); - assertThat(springBootConfigurationHelper.getServerKeystorePropertyKey()).isEqualTo("server.ssl.key-store"); - assertThat(springBootConfigurationHelper.getManagementKeystorePropertyKey()).isEqualTo("management.ssl.key-store"); - assertThat(springBootConfigurationHelper.getServletPathPropertyKey()).isEqualTo("server.servlet-path"); - assertThat(springBootConfigurationHelper.getServerContextPathPropertyKey()).isEqualTo("server.context-path"); - assertThat(springBootConfigurationHelper.getManagementContextPathPropertyKey()).isEqualTo("management.context-path"); - assertThat(springBootConfigurationHelper.getActuatorBasePathPropertyKey()).isEmpty(); - assertThat(springBootConfigurationHelper.getActuatorDefaultBasePath()).isEmpty(); + @Nested + @DisplayName("With '2.0' Spring Boot Version") + class SpringBoot2 { + private SpringBootConfigurationHelper springBootConfigurationHelper; + + @BeforeEach + void setUp() { + springBootConfigurationHelper = new SpringBootConfigurationHelper(Optional.of("2.0")); + } + + @Test + @DisplayName("getManagementPort defaults to 'management.server.port'") + void getManagementPort() { + assertThat(springBootConfigurationHelper.getManagementPort(properties)).isEqualTo(2); + } + + @Test + @DisplayName("getServerPort defaults to 'server.port'") + void getServerPort() { + assertThat(springBootConfigurationHelper.getServerPort(properties)).isEqualTo(1); + } + + @Test + @DisplayName("getServerKeystorePropertyKey defaults to 'server.ssl.key-store'") + void getServerKeystorePropertyKey() { + assertThat(springBootConfigurationHelper.getServerKeystorePropertyKey()).isEqualTo("server.ssl.key-store"); + } + + @Test + @DisplayName("getManagementKeystorePropertyKey defaults to 'management.server.ssl.key-store'") + void getManagementKeystorePropertyKey() { + assertThat(springBootConfigurationHelper.getManagementKeystorePropertyKey()) + .isEqualTo("management.server.ssl.key-store"); + } + + @Test + @DisplayName("getServletPathPropertyKey defaults to 'server.servlet.path'") + void getServletPathPropertyKey() { + assertThat(springBootConfigurationHelper.getServletPathPropertyKey()).isEqualTo("server.servlet.path"); + } + + @Test + @DisplayName("getServerContextPathPropertyKey defaults to 'server.servlet.context-path'") + void getServerContextPathPropertyKey() { + assertThat(springBootConfigurationHelper.getServerContextPathPropertyKey()) + .isEqualTo("server.servlet.context-path"); + } + + @Test + @DisplayName("getManagementContextPathPropertyKey defaults to 'management.server.servlet.context-path'") + void getManagementContextPathPropertyKey() { + assertThat(springBootConfigurationHelper.getManagementContextPathPropertyKey()) + .isEqualTo("management.server.servlet.context-path"); + } + + @Test + @DisplayName("getActuatorBasePathPropertyKey defaults to 'management.endpoints.web.base-path'") + void getActuatorBasePathPropertyKey() { + assertThat(springBootConfigurationHelper.getActuatorBasePathPropertyKey()) + .isEqualTo("management.endpoints.web.base-path"); + } + + @Test + @DisplayName("getActuatorDefaultBasePath defaults to '/actuator'") + void getActuatorDefaultBasePath() { + assertThat(springBootConfigurationHelper.getActuatorDefaultBasePath()).isEqualTo("/actuator"); + } + } + + @Nested + @DisplayName("With '1.0' (or undefined) Spring Boot Version") + class SpringBoot1 { + + @ParameterizedTest(name = "{0}") + @ValueSource(strings = { "1.0", "undefined" }) + @DisplayName("getManagementPort defaults to 'management.port' (Spring Boot 1)") + void getManagementPort(String version) { + assertThat(new SpringBootConfigurationHelper(Optional.of(version)).getManagementPort(properties)) + .isEqualTo(1); + } + + @ParameterizedTest(name = "{0}") + @ValueSource(strings = { "1.0", "undefined" }) + @DisplayName("getServerPort defaults to 'server.port' (Spring Boot 1)") + void getServerPort(String version) { + assertThat(new SpringBootConfigurationHelper(Optional.of(version)).getServerPort(properties)) + .isEqualTo(1); + } + + @ParameterizedTest(name = "{0}") + @ValueSource(strings = { "1.0", "undefined" }) + @DisplayName("getServerKeystorePropertyKey defaults to 'server.ssl.key-store' (Spring Boot 1)") + void getServerKeystorePropertyKey(String version) { + assertThat(new SpringBootConfigurationHelper(Optional.of(version)).getServerKeystorePropertyKey()) + .isEqualTo("server.ssl.key-store"); + } + + @ParameterizedTest(name = "{0}") + @ValueSource(strings = { "1.0", "undefined" }) + @DisplayName("getManagementKeystorePropertyKey defaults to 'management.ssl.key-store' (Spring Boot 1)") + void getManagementKeystorePropertyKey(String version) { + assertThat(new SpringBootConfigurationHelper(Optional.of(version)).getManagementKeystorePropertyKey()) + .isEqualTo("management.ssl.key-store"); + } + + @ParameterizedTest(name = "{0}") + @ValueSource(strings = { "1.0", "undefined" }) + @DisplayName("getServletPathPropertyKey defaults to 'server.servlet-path' (Spring Boot 1)") + void getServletPathPropertyKey(String version) { + assertThat(new SpringBootConfigurationHelper(Optional.of(version)).getServletPathPropertyKey()) + .isEqualTo("server.servlet-path"); + } + + @ParameterizedTest(name = "{0}") + @ValueSource(strings = { "1.0", "undefined" }) + @DisplayName("getServerContextPathPropertyKey defaults to 'server.context-path' (Spring Boot 1)") + void getServerContextPathPropertyKey(String version) { + assertThat(new SpringBootConfigurationHelper(Optional.of(version)).getServerContextPathPropertyKey()) + .isEqualTo("server.context-path"); + } + + @ParameterizedTest(name = "{0}") + @ValueSource(strings = { "1.0", "undefined" }) + @DisplayName("getManagementContextPathPropertyKey defaults to 'management.context-path' (Spring Boot 1)") + void getManagementContextPathPropertyKey(String version) { + assertThat(new SpringBootConfigurationHelper(Optional.of(version)).getManagementContextPathPropertyKey()) + .isEqualTo("management.context-path"); + } + + @ParameterizedTest(name = "{0}") + @ValueSource(strings = { "1.0", "undefined" }) + @DisplayName("getActuatorBasePathPropertyKey defaults to '' (Spring Boot 1)") + void getActuatorBasePathPropertyKey(String version) { + assertThat(new SpringBootConfigurationHelper(Optional.of(version)).getActuatorBasePathPropertyKey()) + .isEmpty(); + } + + @ParameterizedTest(name = "{0}") + @ValueSource(strings = { "1.0", "undefined" }) + @DisplayName("getActuatorDefaultBasePath defaults to '' (Spring Boot 1)") + void getActuatorDefaultBasePath(String version) { + assertThat(new SpringBootConfigurationHelper(Optional.of(version)).getActuatorDefaultBasePath()). + isEmpty(); + } } } diff --git a/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/generator/SpringBootGeneratorIntegrationTest.java b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/generator/SpringBootGeneratorIntegrationTest.java index d376551d26..9b352f420a 100644 --- a/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/generator/SpringBootGeneratorIntegrationTest.java +++ b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/generator/SpringBootGeneratorIntegrationTest.java @@ -83,7 +83,7 @@ void setUp() throws IOException { } @Test - @DisplayName("customize, with standard packaging, has image name") + @DisplayName("customize, with standard packaging, has standard image name") void customize_withStandardPackaging_thenImageNameContainsGroupArtifactAndLatestTag() { // Given withCustomMainClass(); @@ -100,7 +100,7 @@ void customize_withStandardPackaging_thenImageNameContainsGroupArtifactAndLatest } @Test - @DisplayName("customize, with standard packaging, has image alias") + @DisplayName("customize, with standard packaging, has 'spring-boot' image alias") void customize_withStandardPackaging_thenImageAliasSpringBoot() { // Given withCustomMainClass(); @@ -117,7 +117,7 @@ void customize_withStandardPackaging_thenImageAliasSpringBoot() { } @Test - @DisplayName("customize, with standard packaging, has image from") + @DisplayName("customize, with standard packaging, has image from based on standard Java Exec generator image") void customize_withStandardPackaging_hasFrom() { // Given withCustomMainClass(); @@ -137,7 +137,7 @@ void customize_withStandardPackaging_hasFrom() { } @Test - @DisplayName("customize, with standard packaging, has default web port") + @DisplayName("customize, with standard packaging, has '8080' web port") void customize_withStandardPackaging_thenImageHasDefaultWebPort() { // Given withCustomMainClass(); @@ -280,7 +280,7 @@ void customize_whenGeneratorModeWatch_shouldAddSpringBootDevtoolsSecretEnvVar() } @Test - @DisplayName("customize, when color configuration provided, then add spring.output.ansi.enabled property to JAVA_OPTIONS environment variable") + @DisplayName("customize, when color configuration provided, enables ANSI color output") void customize_withColorConfiguration_shouldAddAnsiEnabledPropertyToJavaOptions() { // Given properties.put("jkube.generator.spring-boot.color", "always"); From 37b3f05d0ef09a99d7ea24ad3f9590d143389141 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Thu, 6 Jul 2023 11:18:26 +0200 Subject: [PATCH 26/65] test: ApplyService tests prior to further refactoring and method consolidation Signed-off-by: Marc Nuri --- .../kit/config/service/ApplyService.java | 54 ++--- .../config/service/ApplyServiceCrudTest.java | 225 ++++++++++++++++++ 2 files changed, 250 insertions(+), 29 deletions(-) create mode 100644 jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceCrudTest.java diff --git a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/ApplyService.java b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/ApplyService.java index c0a2a56b33..d0e586a0a6 100644 --- a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/ApplyService.java +++ b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/ApplyService.java @@ -944,46 +944,41 @@ public boolean applyNamespace(Namespace entity) { } /** - * Creates and return a project in openshift - * @param project - * @return + * Creates an OpenShift Project */ - public boolean applyProject(Project project) { - return applyProjectRequest(new ProjectRequestBuilder() - .withDisplayName(project.getMetadata().getName()) - .withMetadata(project.getMetadata()).build()); + public void applyProject(Project project) { + applyProjectRequest(new ProjectRequestBuilder() + .withDisplayName(project.getMetadata().getName()) + .withMetadata(project.getMetadata()).build()); } /** * Returns true if the ProjectRequest is created */ - public boolean applyProjectRequest(ProjectRequest entity) { + public void applyProjectRequest(ProjectRequest entity) { + final String projectName = getOrCreateMetadata(entity).getName(); + Objects.requireNonNull(projectName, "No name for " + entity); // Check whether project creation attempted before - if (projectsCreated.contains(getName(entity))) { - return false; + if (projectsCreated.contains(projectName)) { + return; } - String currentNamespace = getOrCreateMetadata(entity).getName(); - log.info("Creating project: " + currentNamespace); - String name = getName(entity); - Objects.requireNonNull(name, "No name for " + entity); + log.info("Creating project: " + projectName); if (!OpenshiftHelper.isOpenShift(kubernetesClient)) { - log.warn("Cannot check for Project " + currentNamespace + " as not running against OpenShift!"); - return false; + log.warn("Cannot check for Project " + projectName + " as not running against OpenShift!"); + return; } - boolean exists = checkNamespace(name); + boolean exists = checkNamespace(projectName); // We may want to be more fine-grained on the phase of the project if (!exists) { try { Object answer = asOpenShiftClient().projectrequests().create(entity); // Add project to created projects - projectsCreated.add(name); - logGeneratedEntity("Created ProjectRequest: ", currentNamespace, entity, answer); - return true; + projectsCreated.add(projectName); + logGeneratedEntity("Created ProjectRequest: ", projectName, entity, answer); } catch (Exception e) { - onApplyError("Failed to create ProjectRequest: " + name + " due " + e.getMessage(), e); + onApplyError("Failed to create ProjectRequest: " + projectName + " due " + e.getMessage(), e); } } - return false; } private void doCreate(HasMetadata resource, String namespace, String fileName) { @@ -1064,20 +1059,20 @@ public void applyReplicationController(ReplicationController replicationControll public void applyPod(Pod pod, String sourceName) { String currentNamespace = applicableNamespace(pod, namespace, fallbackNamespace); - String id = getName(pod); - Objects.requireNonNull(id, "No name for " + pod + " " + sourceName); + final String name = getName(pod); + Objects.requireNonNull(name, "No name for " + pod + " " + sourceName); if (isServicesOnlyMode()) { - log.debug("Only processing Services right now so ignoring Pod: " + currentNamespace + ":" + id); + log.debug("Only processing Services right now so ignoring Pod: " + currentNamespace + ":" + name); return; } - Pod old = kubernetesClient.pods().inNamespace(currentNamespace).withName(id).get(); + Pod old = kubernetesClient.pods().inNamespace(currentNamespace).withName(name).get(); if (isRunning(old)) { if (UserConfigurationCompare.configEqual(pod, old)) { log.info("Pod has not changed so not doing anything"); } else { if (isRecreateMode()) { - log.info("Deleting Pod: " + id); - kubernetesClient.pods().inNamespace(currentNamespace).withName(id).delete(); + log.info("Deleting Pod: " + name); + kubernetesClient.pods().inNamespace(currentNamespace).withName(name).delete(); doCreate(pod, currentNamespace, sourceName); } else { doPatchEntity(old, pod, currentNamespace, sourceName); @@ -1085,7 +1080,8 @@ public void applyPod(Pod pod, String sourceName) { } } else { if (!isAllowCreate()) { - log.warn("Creation disabled so not creating a pod from " + sourceName + " namespace " + currentNamespace + " name " + getName(pod)); + log.warn("Creation disabled so not creating a pod from %s in namespace %s with name %s", + sourceName, currentNamespace, name); } else { doCreate(pod, currentNamespace, sourceName); } diff --git a/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceCrudTest.java b/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceCrudTest.java new file mode 100644 index 0000000000..d7b8dba613 --- /dev/null +++ b/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceCrudTest.java @@ -0,0 +1,225 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.config.service; + +import io.fabric8.kubernetes.api.model.APIGroupBuilder; +import io.fabric8.kubernetes.api.model.APIGroupList; +import io.fabric8.kubernetes.api.model.ConfigMapBuilder; +import io.fabric8.kubernetes.api.model.HasMetadata; +import io.fabric8.kubernetes.api.model.KubernetesList; +import io.fabric8.kubernetes.api.model.KubernetesListBuilder; +import io.fabric8.kubernetes.api.model.Pod; +import io.fabric8.kubernetes.api.model.PodBuilder; +import io.fabric8.kubernetes.api.model.ServiceBuilder; +import io.fabric8.kubernetes.client.KubernetesClient; +import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient; +import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer; +import io.fabric8.openshift.api.model.Project; +import io.fabric8.openshift.api.model.ProjectBuilder; +import io.fabric8.openshift.api.model.ProjectRequestBuilder; +import io.fabric8.openshift.client.OpenShiftClient; +import org.eclipse.jkube.kit.common.JKubeConfiguration; +import org.eclipse.jkube.kit.common.KitLogger; +import org.eclipse.jkube.kit.config.access.ClusterAccess; +import org.eclipse.jkube.kit.config.access.ClusterConfiguration; +import org.eclipse.jkube.kit.config.resource.RuntimeMode; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.startsWith; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; + +@EnableKubernetesMockClient(crud = true) +class ApplyServiceCrudTest { + + KubernetesMockServer kubernetesMockServer; + KubernetesClient kubernetesClient; + private KitLogger log; + private APIGroupList apiGroupList; + private ApplyService applyService; + + @BeforeEach + void setUp() { + log = spy(new KitLogger.SilentLogger()); + apiGroupList = new APIGroupList(); + final JKubeServiceHub serviceHub = JKubeServiceHub.builder() + .log(log) + .configuration(JKubeConfiguration.builder().build()) + .platformMode(RuntimeMode.KUBERNETES) + .clusterAccess(new ClusterAccess(ClusterConfiguration.from(kubernetesClient.getConfiguration()).build())) + .build(); + applyService = new ApplyService(serviceHub); + applyService.setNamespace("default"); + kubernetesMockServer.expect() + .get() + .withPath("/apis") + .andReply(200, rr -> apiGroupList) + .always(); + } + + @Test + @DisplayName("apply from List with nested objects, should apply all objects") + void applyWithNestedObjectsInList() { + // Given + final List toApply = Arrays.asList( + new PodBuilder().withNewMetadata().withName("a-pod").endMetadata().build(), + new ConfigMapBuilder().withNewMetadata().withName("a-config-map").endMetadata().build() + ); + // When + applyService.apply(toApply, "list.yml"); + // Then + assertThat(kubernetesClient) + .returns("a-pod", c -> c.pods().inNamespace("default").withName("a-pod").get().getMetadata().getName()) + .returns("a-config-map", c -> c.configMaps().inNamespace("default").withName("a-config-map").get().getMetadata().getName()); + } + + @Test + @DisplayName("apply from KubernetesList with nested objects, should apply all objects") + void applyWithNestedObjectsInKubernetesList() { + // Given + final KubernetesList toApply = new KubernetesListBuilder() + .addToItems(new PodBuilder().withNewMetadata().withName("a-pod").endMetadata().build()) + .addToItems(new ConfigMapBuilder().withNewMetadata().withName("a-config-map").endMetadata().build()) + .build(); + // When + applyService.apply(toApply, "list.yml"); + // Then + assertThat(kubernetesClient) + .returns("a-pod", c -> c.pods().inNamespace("default").withName("a-pod").get().getMetadata().getName()) + .returns("a-config-map", c -> c.configMaps().inNamespace("default").withName("a-config-map").get().getMetadata().getName()); + } + + @Test + @DisplayName("apply from recursive List with nested objects, should apply only objects") + void applyWithNestedObjectsInRecursiveList() { + // Given + final List toApply = new ArrayList<>(); + toApply.add(new PodBuilder().withNewMetadata().withName("a-pod").endMetadata().build()); + toApply.add(new ConfigMapBuilder().withNewMetadata().withName("a-config-map").endMetadata().build()); + //noinspection CollectionAddedToSelf + toApply.add(toApply); + // When + applyService.apply(toApply, "list.yml"); + // Then + assertThat(kubernetesClient) + .returns("a-pod", c -> c.pods().inNamespace("default").withName("a-pod").get().getMetadata().getName()) + .returns("a-config-map", c -> c.configMaps().inNamespace("default").withName("a-config-map").get().getMetadata().getName()); + } + + @Test + @DisplayName("apply in services mode, should apply only services") + void applyInServicesMode() { + // Given + final KubernetesList toApply = new KubernetesListBuilder() + .addToItems(new PodBuilder().withNewMetadata().withName("a-pod").endMetadata().build()) + .addToItems(new ServiceBuilder().withNewMetadata().withName("a-service").endMetadata().build()) + .build(); + applyService.setServicesOnlyMode(true); + // When + applyService.apply(toApply, "list.yml"); + // Then + assertThat(kubernetesClient) + .returns(null, c -> c.pods().inNamespace("default").withName("a-pod").get()) + .returns("a-service", c -> c.services().inNamespace("default").withName("a-service").get().getMetadata().getName()); + } + + @Test + @DisplayName("apply with new resource and creation disabled, should do nothing") + void applyWithNewResourceAndCreationDisabled() { + // Given + final Pod toApply = new PodBuilder().withNewMetadata() + .withName("a-pod") + .endMetadata().build(); + applyService.setAllowCreate(false); + // When + applyService.apply(toApply, "pod.yml"); + // Then + assertThat(kubernetesClient.pods().inNamespace("default").withName("a-pod").get()) + .isNull(); + verify(log).warn("Creation disabled so not creating a pod from %s in namespace %s with name %s", + "pod.yml", "default", "a-pod"); + } + + @Test + @DisplayName("apply with existing resource, should update the resource") + void applyWithExistingResource() { + // Given + final Pod toApply = new PodBuilder().withNewMetadata() + .withName("a-pod") + .endMetadata().build(); + final Pod original = kubernetesClient.resource(toApply).inNamespace("default").create(); + // When + applyService.apply(toApply, "pod.yml"); + // Then + assertThat(kubernetesClient.pods().inNamespace("default").withName("a-pod").get()) + .hasFieldOrPropertyWithValue("metadata.uid", original.getMetadata().getUid()) + .hasFieldOrPropertyWithValue("metadata.creationTimestamp", original.getMetadata().getCreationTimestamp()); + } + + @Test + @DisplayName("apply with existing resource, in recreate mode, should delete and recreate resource") + void applyWithExistingResourceInRecreateMode() { + // Given + final Pod toApply = new PodBuilder().withNewMetadata() + .withName("a-pod") + .endMetadata().build(); + final Pod original = kubernetesClient.resource(toApply).inNamespace("default").create(); + applyService.setRecreateMode(true); + // When + applyService.apply(toApply, "pod.yml"); + // Then + assertThat(kubernetesClient.pods().inNamespace("default").withName("a-pod").get()) + .extracting("metadata.uid") + .isNotEqualTo(original.getMetadata().getUid()); + } + + @Test + @DisplayName("apply with Project, in vanilla Kubernetes, should do nothing") + void applyProjectInKubernetes() { + // Given + final Project toApply = new ProjectBuilder().withNewMetadata() + .withName("a-project") + .endMetadata().build(); + // When + applyService.apply(toApply, "project.yml"); + // Then + assertThat(kubernetesClient.adapt(OpenShiftClient.class).projects().withName("a-project").get()) + .isNull(); + verify(log).warn("Cannot check for Project a-project as not running against OpenShift!"); + } + + @Test + @DisplayName("apply with Project, in OpenShift, should request Project") + void applyProjectInOpenShift() { + // Given + final Project toApply = new ProjectBuilder().withNewMetadata() + .withName("a-project") + .endMetadata().build(); + apiGroupList.getGroups().add(new APIGroupBuilder().withName("build.openshift.io").withApiVersion("v1").build()); + // When + applyService.apply(toApply, "project.yml"); + // Then + // Hack to retrieve the ProjectRequest from the mock API server (the real OpenShift API won't allow the get operation) + assertThat(kubernetesClient.resource(new ProjectRequestBuilder().withNewMetadata().withName("a-project").endMetadata().build()).get()) + .isNotNull(); + verify(log).info(startsWith("Created ProjectRequest:")); + } +} From 0bf40bd8f83b34841d1b4b601759cf9c977c3dfa Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Tue, 11 Jul 2023 14:49:56 +0200 Subject: [PATCH 27/65] ci: Sonar has complete report "Could not find ref 'master' in refs/heads, refs/remotes/upstream or refs/remotes/origin. You may see unexpected issues and changes. Please make sure to fetch this ref before pull request analysis." Signed-off-by: Marc Nuri --- .jenkins/pipelines/sonar.Jenkinsfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.jenkins/pipelines/sonar.Jenkinsfile b/.jenkins/pipelines/sonar.Jenkinsfile index 6134259c02..e186f416df 100644 --- a/.jenkins/pipelines/sonar.Jenkinsfile +++ b/.jenkins/pipelines/sonar.Jenkinsfile @@ -15,6 +15,9 @@ pipeline { when { changeRequest() } steps { sh 'echo "Building Project and analyzing with Sonar"' + // Required by Sonar to compare coverage info, etc. with master + sh 'git remote add upstream https://github.com/eclipse/jkube.git' + sh 'git fetch upstream' // Needs install instad of verify since ITs rely on artifacts from previous modules sh './mvnw -V -B -e -Pjacoco,sonar install ' + '-Dsonar.pullrequest.key=${CHANGE_ID} ' + From 1ac4f7cbd304f7e516d7f3104a03c84c0ad48f46 Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Tue, 11 Jul 2023 18:11:51 +0530 Subject: [PATCH 28/65] feat (jkube-kit/common) : Add HTTP utility methods to Fabric8HttpUtil Add various methods required for performing HTTP requests to Fabric8HttpUtil. Use Fabric8 K8s Client's HttpResponse abstractions for HTTP requests. Signed-off-by: Rohan Kumar --- .../kit/common/util/Fabric8HttpUtil.java | 71 +++++++++++++++++++ .../kit/common/util/Fabric8HttpUtilTest.java | 68 ++++++++++++++++++ .../common/util/TestFabric8HttpResponse.java | 62 ++++++++++++++++ 3 files changed, 201 insertions(+) create mode 100644 jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/Fabric8HttpUtil.java create mode 100644 jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/Fabric8HttpUtilTest.java create mode 100644 jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/TestFabric8HttpResponse.java diff --git a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/Fabric8HttpUtil.java b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/Fabric8HttpUtil.java new file mode 100644 index 0000000000..0041fe7bc4 --- /dev/null +++ b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/Fabric8HttpUtil.java @@ -0,0 +1,71 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.common.util; + +import io.fabric8.kubernetes.client.http.HttpResponse; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; + +import static org.apache.commons.lang3.StringUtils.strip; + +public class Fabric8HttpUtil { + private static final String WWW_AUTHENTICATE = "WWW-Authenticate"; + + private Fabric8HttpUtil() { } + + /** + * Parse WWW-Authenticate Header as map + * + * @param response Http Response of a particular request + * @return map containing various components of header as key value pairs + */ + public static Map extractAuthenticationChallengeIntoMap(HttpResponse response) { + String wwwAuthenticateHeader = response.header(WWW_AUTHENTICATE); + String[] wwwAuthenticateHeaders = wwwAuthenticateHeader.split(","); + Map result = new HashMap<>(); + for (String challenge : wwwAuthenticateHeaders) { + if (challenge.contains("=")) { + String[] challengeParts = challenge.split("="); + if (challengeParts.length == 2) { + result.put(challengeParts[0], strip(challengeParts[1], "\"")); + } + } + } + return result; + } + + + /** + * Create Form Data String from map + * + * @param formData map containing key value pairs for form data + * @return URL encoded value of form data + */ + public static String toFormData(Map formData) throws UnsupportedEncodingException { + StringBuilder result = new StringBuilder(); + for (Map.Entry e : formData.entrySet()) { + if (result.length() > 0) { + result.append("&"); + } + result.append(URLEncoder.encode(e.getKey(), StandardCharsets.UTF_8.name())); + result.append("="); + result.append(URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8.name())); + } + return result.toString(); + } +} diff --git a/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/Fabric8HttpUtilTest.java b/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/Fabric8HttpUtilTest.java new file mode 100644 index 0000000000..e99fe45832 --- /dev/null +++ b/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/Fabric8HttpUtilTest.java @@ -0,0 +1,68 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.common.util; + +import io.fabric8.kubernetes.client.http.HttpResponse; +import org.junit.jupiter.api.Test; + +import java.io.UnsupportedEncodingException; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static java.net.HttpURLConnection.HTTP_OK; +import static org.assertj.core.api.Assertions.assertThat; + +class Fabric8HttpUtilTest { + + @Test + void toFormData_whenDataProvidedAsMap_thenCreateFormDataPayload() throws UnsupportedEncodingException { + // Given + Map formDataMap = new HashMap<>(); + formDataMap.put("grant_type", "password"); + formDataMap.put("refresh_token", "secret"); + formDataMap.put("service", "auth.example.com"); + formDataMap.put("scope", "repository=myuser/test-chart:pull"); + formDataMap.put("client id", "Eclipse&JKube"); + formDataMap.put("username", "?myuser"); + formDataMap.put("password", "secret"); + + // When + String formDataPayload = Fabric8HttpUtil.toFormData(formDataMap); + + // Then + assertThat(formDataPayload) + .isEqualTo("client+id=Eclipse%26JKube&refresh_token=secret&password=secret&grant_type=password&service=auth.example.com&scope=repository%3Dmyuser%2Ftest-chart%3Apull&username=%3Fmyuser"); + } + + @Test + void extractAuthenticationChallengeIntoMap_whenWwwHeaderProvided_thenParseDataIntoMap() { + // Given + String wwwAuthenticateValue = "Bearer realm=\"https://auth.example.com/token\",service=\"registry.example.com\",scope=\"repository:myuser/test-chart:pull\""; + Map> responseHeaders = new HashMap<>(); + responseHeaders.put("WWW-Authenticate", Collections.singletonList(wwwAuthenticateValue)); + HttpResponse response = new TestFabric8HttpResponse(HTTP_OK, responseHeaders, null, null); + + // When + Map wwwAuthenticateAsMap = Fabric8HttpUtil.extractAuthenticationChallengeIntoMap(response); + + // Then + assertThat(wwwAuthenticateAsMap) + .hasSize(3) + .containsEntry("Bearer realm", "https://auth.example.com/token") + .containsEntry("service", "registry.example.com") + .containsEntry("scope", "repository:myuser/test-chart:pull"); + } +} diff --git a/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/TestFabric8HttpResponse.java b/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/TestFabric8HttpResponse.java new file mode 100644 index 0000000000..7cc1c536c5 --- /dev/null +++ b/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/TestFabric8HttpResponse.java @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.common.util; + +import io.fabric8.kubernetes.client.http.HttpRequest; +import io.fabric8.kubernetes.client.http.HttpResponse; +import org.apache.commons.lang3.StringUtils; + +import java.util.List; +import java.util.Map; +import java.util.Optional; + +public class TestFabric8HttpResponse implements HttpResponse { + private final int code; + private final Map> headers; + private final String body; + private final String message; + + public TestFabric8HttpResponse(int code, Map> headers, String body, String message) { + this.code = code; + this.headers = headers; + this.body = body; + this.message = message; + } + + @Override + public int code() { return code; } + + @Override + public byte[] body() { + if (StringUtils.isNotBlank(body)) { + return body.getBytes(); + } + return null; + } + + @Override + public HttpRequest request() { return null; } + + @Override + public Optional> previousResponse() { return Optional.empty(); } + + @Override + public List headers(String s) { return headers.get(s); } + + @Override + public Map> headers() { return headers; } + + @Override + public String message() { return message; } +} From 4fff79df20f5bb5d048aa664652899ca4b60fb93 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Wed, 12 Jul 2023 10:28:48 +0200 Subject: [PATCH 29/65] test: apply service behaviors tested regardless of underlying method Signed-off-by: Marc Nuri --- .../kit/config/service/ApplyService.java | 13 ++-- .../config/service/ApplyServiceCrudTest.java | 70 +++++++++++-------- 2 files changed, 50 insertions(+), 33 deletions(-) diff --git a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/ApplyService.java b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/ApplyService.java index d0e586a0a6..7cf59a6587 100644 --- a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/ApplyService.java +++ b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/ApplyService.java @@ -397,7 +397,8 @@ public void applyServiceAccount(ServiceAccount serviceAccount, String sourceName } } else { if (!isAllowCreate()) { - log.warn("Creation disabled so not creating a ServiceAccount from " + sourceName + " namespace " + currentNamespace + " name " + getName(serviceAccount)); + log.warn("Creation disabled so not creating a %s from %s in namespace %s with name %s", + "ServiceAccount", sourceName, currentNamespace, id); } else { doCreate(serviceAccount, currentNamespace, sourceName); } @@ -804,7 +805,8 @@ public void applyService(Service service, String sourceName) { } } else { if (!isAllowCreate()) { - log.warn("Creation disabled so not creating a Service from " + sourceName + " namespace " + currentNamespace + " name " + getName(service)); + log.warn("Creation disabled so not creating a %s from %s in namespace %s with name %s", + "Service", sourceName, currentNamespace, id); } else { doCreate(service, currentNamespace, sourceName); } @@ -841,7 +843,8 @@ public void applyResource(T resource, String sourceNam } } else { if (!isAllowCreate()) { - log.warn("Creation disabled so not creating a " + kind + " from " + sourceName + " namespace " + currentNamespace + " name " + getName(resource)); + log.warn("Creation disabled so not creating a %s from %s in namespace %s with name %s", + kind, sourceName, currentNamespace, id); } else { doCreate(resource, currentNamespace, sourceName); } @@ -1080,8 +1083,8 @@ public void applyPod(Pod pod, String sourceName) { } } else { if (!isAllowCreate()) { - log.warn("Creation disabled so not creating a pod from %s in namespace %s with name %s", - sourceName, currentNamespace, name); + log.warn("Creation disabled so not creating a %s from %s in namespace %s with name %s", + "Pod", sourceName, currentNamespace, name); } else { doCreate(pod, currentNamespace, sourceName); } diff --git a/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceCrudTest.java b/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceCrudTest.java index d7b8dba613..7962e3c5d0 100644 --- a/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceCrudTest.java +++ b/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceCrudTest.java @@ -19,9 +19,10 @@ import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.KubernetesList; import io.fabric8.kubernetes.api.model.KubernetesListBuilder; -import io.fabric8.kubernetes.api.model.Pod; import io.fabric8.kubernetes.api.model.PodBuilder; +import io.fabric8.kubernetes.api.model.ServiceAccountBuilder; import io.fabric8.kubernetes.api.model.ServiceBuilder; +import io.fabric8.kubernetes.api.model.apps.DeploymentBuilder; import io.fabric8.kubernetes.client.KubernetesClient; import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient; import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer; @@ -37,10 +38,14 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.startsWith; @@ -130,67 +135,76 @@ void applyInServicesMode() { // Given final KubernetesList toApply = new KubernetesListBuilder() .addToItems(new PodBuilder().withNewMetadata().withName("a-pod").endMetadata().build()) + .addToItems(new DeploymentBuilder().withNewMetadata().withName("a-deployment").endMetadata().build()) .addToItems(new ServiceBuilder().withNewMetadata().withName("a-service").endMetadata().build()) + .addToItems(new ServiceAccountBuilder().withNewMetadata().withName("a-sa").endMetadata().build()) .build(); applyService.setServicesOnlyMode(true); // When applyService.apply(toApply, "list.yml"); // Then assertThat(kubernetesClient) + .returns(null, c -> c.apps().deployments().inNamespace("default").withName("a-deployment").get()) .returns(null, c -> c.pods().inNamespace("default").withName("a-pod").get()) + .returns(null, c -> c.serviceAccounts().inNamespace("default").withName("a-sa").get()) .returns("a-service", c -> c.services().inNamespace("default").withName("a-service").get().getMetadata().getName()); } - @Test - @DisplayName("apply with new resource and creation disabled, should do nothing") - void applyWithNewResourceAndCreationDisabled() { + @DisplayName("apply with new resources and creation disabled, should do nothing") + @ParameterizedTest + @MethodSource("applyResourcesData") + void applyWithNewResourceAndCreationDisabled(HasMetadata toApplyResource) { // Given - final Pod toApply = new PodBuilder().withNewMetadata() - .withName("a-pod") - .endMetadata().build(); applyService.setAllowCreate(false); // When - applyService.apply(toApply, "pod.yml"); + applyService.apply(toApplyResource, "resource.yml"); // Then - assertThat(kubernetesClient.pods().inNamespace("default").withName("a-pod").get()) + assertThat(kubernetesClient.resource(toApplyResource).inNamespace("default").get()) .isNull(); - verify(log).warn("Creation disabled so not creating a pod from %s in namespace %s with name %s", - "pod.yml", "default", "a-pod"); + verify(log).warn("Creation disabled so not creating a %s from %s in namespace %s with name %s", + toApplyResource.getKind(), "resource.yml", "default", "a-resource"); } - @Test @DisplayName("apply with existing resource, should update the resource") - void applyWithExistingResource() { + @ParameterizedTest + @MethodSource("applyResourcesData") + void applyWithExistingResources(HasMetadata toApplyResource) { // Given - final Pod toApply = new PodBuilder().withNewMetadata() - .withName("a-pod") - .endMetadata().build(); - final Pod original = kubernetesClient.resource(toApply).inNamespace("default").create(); + final HasMetadata original = kubernetesClient.resource(toApplyResource).inNamespace("default").create(); + toApplyResource.getMetadata().getAnnotations().put("updated", "true"); // When - applyService.apply(toApply, "pod.yml"); + applyService.apply(toApplyResource, "resource.yml"); // Then - assertThat(kubernetesClient.pods().inNamespace("default").withName("a-pod").get()) + assertThat(kubernetesClient.resource(toApplyResource).inNamespace("default").get()) .hasFieldOrPropertyWithValue("metadata.uid", original.getMetadata().getUid()) - .hasFieldOrPropertyWithValue("metadata.creationTimestamp", original.getMetadata().getCreationTimestamp()); + .hasFieldOrPropertyWithValue("metadata.creationTimestamp", original.getMetadata().getCreationTimestamp()) + .hasFieldOrPropertyWithValue("metadata.annotations.updated", "true"); } - @Test @DisplayName("apply with existing resource, in recreate mode, should delete and recreate resource") - void applyWithExistingResourceInRecreateMode() { + @ParameterizedTest + @MethodSource("applyResourcesData") + void applyWithExistingResourceInRecreateMode(HasMetadata toApplyResource) { // Given - final Pod toApply = new PodBuilder().withNewMetadata() - .withName("a-pod") - .endMetadata().build(); - final Pod original = kubernetesClient.resource(toApply).inNamespace("default").create(); applyService.setRecreateMode(true); + final HasMetadata original = kubernetesClient.resource(toApplyResource).inNamespace("default").create(); // When - applyService.apply(toApply, "pod.yml"); + applyService.apply(toApplyResource, "resource.yml"); // Then - assertThat(kubernetesClient.pods().inNamespace("default").withName("a-pod").get()) + assertThat(kubernetesClient.resource(toApplyResource).inNamespace("default").get()) .extracting("metadata.uid") .isNotEqualTo(original.getMetadata().getUid()); } + static Stream applyResourcesData() { + return Stream.of( + Arguments.of(new PodBuilder().withNewMetadata().withName("a-resource").endMetadata().build()), + Arguments.of(new DeploymentBuilder().withNewMetadata().withName("a-resource").endMetadata().build()), + Arguments.of(new ServiceBuilder().withNewMetadata().withName("a-resource").endMetadata().withNewSpec().endSpec().build()), + Arguments.of(new ServiceAccountBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) + ); + } + @Test @DisplayName("apply with Project, in vanilla Kubernetes, should do nothing") void applyProjectInKubernetes() { From a35ac20284f59ad520b95327d2b7b1e5292ca09d Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Wed, 12 Jul 2023 11:10:09 +0200 Subject: [PATCH 30/65] refactor: remove redundant applyResource calls Signed-off-by: Marc Nuri --- .../kit/config/service/ApplyService.java | 46 ++++--------------- .../config/service/ApplyServiceCrudTest.java | 34 ++++++++++---- 2 files changed, 34 insertions(+), 46 deletions(-) diff --git a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/ApplyService.java b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/ApplyService.java index 7cf59a6587..d11d09d371 100644 --- a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/ApplyService.java +++ b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/ApplyService.java @@ -40,7 +40,6 @@ import org.eclipse.jkube.kit.config.service.ingresscontroller.IngressControllerDetectorManager; import org.eclipse.jkube.kit.config.service.kubernetes.KubernetesClientUtil; -import io.fabric8.kubernetes.api.model.ConfigMap; import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.KubernetesList; import io.fabric8.kubernetes.api.model.Namespace; @@ -53,18 +52,11 @@ import io.fabric8.kubernetes.api.model.Service; import io.fabric8.kubernetes.api.model.ServiceAccount; import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition; -import io.fabric8.kubernetes.api.model.apps.DaemonSet; -import io.fabric8.kubernetes.api.model.apps.Deployment; -import io.fabric8.kubernetes.api.model.apps.ReplicaSet; -import io.fabric8.kubernetes.api.model.apps.StatefulSet; import io.fabric8.kubernetes.api.model.batch.v1.Job; import io.fabric8.kubernetes.api.model.extensions.Ingress; -import io.fabric8.kubernetes.api.model.networking.v1.NetworkPolicy; -import io.fabric8.kubernetes.api.model.rbac.Role; import io.fabric8.kubernetes.api.model.rbac.RoleBinding; import io.fabric8.kubernetes.client.KubernetesClient; import io.fabric8.kubernetes.client.KubernetesClientException; -import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.Resource; import io.fabric8.openshift.api.model.BuildConfig; import io.fabric8.openshift.api.model.DeploymentConfig; @@ -166,14 +158,12 @@ private void applyEntity(Object dto, String sourceName) { } else if (dto instanceof DeploymentConfig) { DeploymentConfig resource = (DeploymentConfig) dto; if (OpenshiftHelper.isOpenShift(kubernetesClient)) { - applyResource(resource, sourceName, asOpenShiftClient().deploymentConfigs()); + applyResource(resource, sourceName); } else { log.warn("Not connected to OpenShift cluster so cannot apply entity %s", dto); } } else if (dto instanceof RoleBinding) { applyRoleBinding((RoleBinding) dto, sourceName); - } else if (dto instanceof Role) { - applyResource((Role) dto, sourceName, kubernetesClient.rbac().roles()); } else if (dto instanceof ImageStream) { applyImageStream((ImageStream) dto, sourceName); } else if (dto instanceof OAuthClient) { @@ -184,21 +174,11 @@ private void applyEntity(Object dto, String sourceName) { applyServiceAccount((ServiceAccount) dto, sourceName); } else if (dto instanceof Secret) { applySecret((Secret) dto, sourceName); - } else if (dto instanceof ConfigMap) { - applyResource((ConfigMap) dto, sourceName, kubernetesClient.configMaps()); - } else if (dto instanceof DaemonSet) { - applyResource((DaemonSet) dto, sourceName, kubernetesClient.apps().daemonSets()); - } else if (dto instanceof Deployment) { - applyResource((Deployment) dto, sourceName, kubernetesClient.apps().deployments()); - } else if (dto instanceof ReplicaSet) { - applyResource((ReplicaSet) dto, sourceName, kubernetesClient.apps().replicaSets()); - } else if (dto instanceof StatefulSet) { - applyResource((StatefulSet) dto, sourceName, kubernetesClient.apps().statefulSets()); } else if (dto instanceof Ingress) { - applyResource((Ingress) dto, sourceName, kubernetesClient.extensions().ingresses()); + applyResource((Ingress) dto, sourceName); ingressControllerDetectorManager.detect(); - }else if (dto instanceof io.fabric8.kubernetes.api.model.networking.v1.Ingress) { - applyResource((io.fabric8.kubernetes.api.model.networking.v1.Ingress) dto, sourceName, kubernetesClient.network().v1().ingresses()); + } else if (dto instanceof io.fabric8.kubernetes.api.model.networking.v1.Ingress) { + applyResource((io.fabric8.kubernetes.api.model.networking.v1.Ingress) dto, sourceName); ingressControllerDetectorManager.detect(); } else if (dto instanceof PersistentVolumeClaim) { applyPersistentVolumeClaim((PersistentVolumeClaim) dto, sourceName); @@ -206,8 +186,6 @@ private void applyEntity(Object dto, String sourceName) { applyCustomResourceDefinition((CustomResourceDefinition) dto, sourceName); } else if (dto instanceof Job) { applyJob((Job) dto, sourceName); - } else if (dto instanceof NetworkPolicy) { - applyResource( (NetworkPolicy) dto, sourceName, kubernetesClient.network().networkPolicies()); } else if (dto instanceof Namespace) { applyNamespace((Namespace) dto); } else if (dto instanceof Project) { @@ -215,13 +193,7 @@ private void applyEntity(Object dto, String sourceName) { } else if (dto instanceof GenericKubernetesResource) { applyGenericKubernetesResource((GenericKubernetesResource) dto, sourceName); } else if (dto instanceof HasMetadata) { - HasMetadata entity = (HasMetadata) dto; - try { - log.info("Applying %s %s from %s", getKind(entity), getName(entity), sourceName); - kubernetesClient.resource(entity).inNamespace(applicableNamespace((HasMetadata) dto, namespace, fallbackNamespace)).createOrReplace(); - } catch (Exception e) { - onApplyError("Failed to create " + getKind(entity) + " from " + sourceName + ". " + e, e); - } + applyResource((HasMetadata) dto, sourceName); } else { throw new IllegalArgumentException("Unknown entity type " + dto); } @@ -813,7 +785,7 @@ public void applyService(Service service, String sourceName) { } } - public void applyResource(T resource, String sourceName, MixedOperation> resources) { + public void applyResource(T resource, String sourceName) { String currentNamespace = applicableNamespace(resource, namespace, fallbackNamespace); String id = getName(resource); String kind = getKind(resource); @@ -822,19 +794,19 @@ public void applyResource(T resource, String sourceNam log.debug("Ignoring " + kind + ": " + currentNamespace + ":" + id); return; } - T old = resources.inNamespace(currentNamespace).withName(id).get(); + T old = kubernetesClient.resource(resource).inNamespace(currentNamespace).get(); if (isRunning(old)) { if (UserConfigurationCompare.configEqual(resource, old)) { log.info(kind + " has not changed so not doing anything"); } else { if (isRecreateMode()) { log.info("Deleting " + kind + ": " + id); - resources.inNamespace(currentNamespace).withName(id).delete(); + kubernetesClient.resource(resource).inNamespace(currentNamespace).delete(); doCreate(resource, currentNamespace, sourceName); } else { log.info("Updating " + kind + " from " + sourceName); try { - Object answer = resources.inNamespace(currentNamespace).withName(id).replace(resource); + Object answer = kubernetesClient.resource(resource).inNamespace(currentNamespace).replace(); logGeneratedEntity("Updated " + kind + ": ", currentNamespace, resource, answer); } catch (Exception e) { onApplyError("Failed to update " + kind + " from " + sourceName + ". " + e + ". " + resource, e); diff --git a/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceCrudTest.java b/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceCrudTest.java index 7962e3c5d0..060b44ee44 100644 --- a/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceCrudTest.java +++ b/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceCrudTest.java @@ -22,7 +22,11 @@ import io.fabric8.kubernetes.api.model.PodBuilder; import io.fabric8.kubernetes.api.model.ServiceAccountBuilder; import io.fabric8.kubernetes.api.model.ServiceBuilder; +import io.fabric8.kubernetes.api.model.apps.DaemonSetBuilder; import io.fabric8.kubernetes.api.model.apps.DeploymentBuilder; +import io.fabric8.kubernetes.api.model.apps.ReplicaSetBuilder; +import io.fabric8.kubernetes.api.model.apps.StatefulSetBuilder; +import io.fabric8.kubernetes.api.model.rbac.RoleBuilder; import io.fabric8.kubernetes.client.KubernetesClient; import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient; import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer; @@ -134,20 +138,28 @@ void applyWithNestedObjectsInRecursiveList() { void applyInServicesMode() { // Given final KubernetesList toApply = new KubernetesListBuilder() - .addToItems(new PodBuilder().withNewMetadata().withName("a-pod").endMetadata().build()) - .addToItems(new DeploymentBuilder().withNewMetadata().withName("a-deployment").endMetadata().build()) - .addToItems(new ServiceBuilder().withNewMetadata().withName("a-service").endMetadata().build()) - .addToItems(new ServiceAccountBuilder().withNewMetadata().withName("a-sa").endMetadata().build()) + .addToItems(new PodBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) + .addToItems(new DeploymentBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) + .addToItems(new ServiceBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) + .addToItems(new ServiceAccountBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) + .addToItems(new RoleBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) + .addToItems(new DaemonSetBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) + .addToItems(new ReplicaSetBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) + .addToItems(new StatefulSetBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) .build(); applyService.setServicesOnlyMode(true); // When applyService.apply(toApply, "list.yml"); // Then assertThat(kubernetesClient) - .returns(null, c -> c.apps().deployments().inNamespace("default").withName("a-deployment").get()) - .returns(null, c -> c.pods().inNamespace("default").withName("a-pod").get()) - .returns(null, c -> c.serviceAccounts().inNamespace("default").withName("a-sa").get()) - .returns("a-service", c -> c.services().inNamespace("default").withName("a-service").get().getMetadata().getName()); + .returns(null, c -> c.apps().deployments().inNamespace("default").withName("a-resource").get()) + .returns(null, c -> c.pods().inNamespace("default").withName("a-resource").get()) + .returns(null, c -> c.serviceAccounts().inNamespace("default").withName("a-resource").get()) + .returns(null, c -> c.rbac().roles().inNamespace("default").withName("a-resource").get()) + .returns(null, c -> c.apps().daemonSets().inNamespace("default").withName("a-resource").get()) + .returns(null, c -> c.apps().replicaSets().inNamespace("default").withName("a-resource").get()) + .returns(null, c -> c.apps().statefulSets().inNamespace("default").withName("a-resource").get()) + .returns("a-resource", c -> c.services().inNamespace("default").withName("a-resource").get().getMetadata().getName()); } @DisplayName("apply with new resources and creation disabled, should do nothing") @@ -201,7 +213,11 @@ static Stream applyResourcesData() { Arguments.of(new PodBuilder().withNewMetadata().withName("a-resource").endMetadata().build()), Arguments.of(new DeploymentBuilder().withNewMetadata().withName("a-resource").endMetadata().build()), Arguments.of(new ServiceBuilder().withNewMetadata().withName("a-resource").endMetadata().withNewSpec().endSpec().build()), - Arguments.of(new ServiceAccountBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) + Arguments.of(new ServiceAccountBuilder().withNewMetadata().withName("a-resource").endMetadata().build()), + Arguments.of(new RoleBuilder().withNewMetadata().withName("a-resource").endMetadata().build()), + Arguments.of(new DaemonSetBuilder().withNewMetadata().withName("a-resource").endMetadata().build()), + Arguments.of(new ReplicaSetBuilder().withNewMetadata().withName("a-resource").endMetadata().build()), + Arguments.of(new StatefulSetBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) ); } From d63d280b2ae1bef8c19b5639bf4abd87af38bd26 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Tue, 11 Jul 2023 16:34:48 +0200 Subject: [PATCH 31/65] ci: replace CircleCI test job with Jenkins Signed-off-by: Marc Nuri --- .circleci/config.yml | 19 ------------------- .jenkins/pipelines/sonar.Jenkinsfile | 4 ++++ 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e219462a95..49ffa37465 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,24 +15,6 @@ version: 2.1 jobs: - test: - docker: - - image: cimg/openjdk:11.0 - steps: - - checkout - - restore_cache: - key: maven-test-{{ .Branch }}-{{ .Revision }}-{{ checksum "pom.xml" }} - - run: - command: | - # Run maven build - ./mvnw -B -Pjacoco clean install - # Run codeocov analysis - bash <(curl -s https://codecov.io/bash) - - save_cache: - key: maven-test-{{ .Branch }}-{{ .Revision }}-{{ checksum "pom.xml" }} - paths: - - ~/.m2 - build: docker: - image: cimg/openjdk:8.0 @@ -60,4 +42,3 @@ workflows: all: jobs: - build - - test diff --git a/.jenkins/pipelines/sonar.Jenkinsfile b/.jenkins/pipelines/sonar.Jenkinsfile index e186f416df..41dd7968b6 100644 --- a/.jenkins/pipelines/sonar.Jenkinsfile +++ b/.jenkins/pipelines/sonar.Jenkinsfile @@ -23,6 +23,8 @@ pipeline { '-Dsonar.pullrequest.key=${CHANGE_ID} ' + '-Dsonar.pullrequest.branch=${GIT_BRANCH} ' + '-Dsonar.pullrequest.base=master' + // CodeCov + sh 'wget -O - https://codecov.io/bash | bash' } } stage('Sonar (main)') { @@ -31,6 +33,8 @@ pipeline { sh 'echo "Building Project and analyzing with Sonar"' // Needs install instad of verify since ITs rely on artifacts from previous modules sh './mvnw -V -B -e -Pjacoco,sonar install' + // CodeCov + sh 'wget -O - https://codecov.io/bash | bash' } } } From adb4dd89708c94f845cff206ac3c54abaf8e5552 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Wed, 12 Jul 2023 09:28:50 +0200 Subject: [PATCH 32/65] ci: replace CircleCI Java 8 job with Jenkins Signed-off-by: Marc Nuri --- .circleci/config.yml | 44 --------------------------- .jenkins/pipelines/java-8.Jenkinsfile | 29 ++++++++++++++++++ 2 files changed, 29 insertions(+), 44 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .jenkins/pipelines/java-8.Jenkinsfile diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 49ffa37465..0000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,44 +0,0 @@ -# -# Copyright (c) 2019 Red Hat, Inc. -# This program and the accompanying materials are made -# available under the terms of the Eclipse Public License 2.0 -# which is available at: -# -# https://www.eclipse.org/legal/epl-2.0/ -# -# SPDX-License-Identifier: EPL-2.0 -# -# Contributors: -# Red Hat, Inc. - initial API and implementation -# - -version: 2.1 - -jobs: - build: - docker: - - image: cimg/openjdk:8.0 - steps: - - checkout - - restore_cache: - key: maven-build-{{ .Branch }}-{{ .Revision }}-{{ checksum "pom.xml" }} - - run: - command: | - if [[ `javac -version 2>&1` == *"1.8.0"* ]]; then - echo "Java 8 Present." - else - echo "Java 8 Not Present." - exit 1 - fi - # Run maven build - ./mvnw clean install - - save_cache: - key: maven-build-{{ .Branch }}-{{ .Revision }}-{{ checksum "pom.xml" }} - paths: - - ~/.m2 - -workflows: - version: 2 - all: - jobs: - - build diff --git a/.jenkins/pipelines/java-8.Jenkinsfile b/.jenkins/pipelines/java-8.Jenkinsfile new file mode 100644 index 0000000000..bb6ade18d8 --- /dev/null +++ b/.jenkins/pipelines/java-8.Jenkinsfile @@ -0,0 +1,29 @@ +#!groovy + +pipeline { + agent any + tools { + maven 'apache-maven-latest' + // https://wiki.eclipse.org/Jenkins#JDK + jdk 'temurin-jdk8-latest' + } + options { + disableConcurrentBuilds(abortPrevious: true) + } + stages { + stage('Build & Test (Java 8)') { + steps { + sh 'echo "Building Project with Java 8"' + sh ''' + if [[ `javac -version 2>&1` == *"1.8.0"* ]]; then + echo "Java 8 Present." + else + echo "Java 8 Not Present." + exit 1 + fi + ''' + sh './mvnw -V -B -e install' + } + } + } +} From c354872afc73a2388d0802335b20ec46057a861d Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Tue, 11 Jul 2023 17:47:57 +0530 Subject: [PATCH 33/65] refactor (jkube-kit/resource/helm) : Add HelmUploaderManager to manage different Helm repository uploaders HelmUploaderManager would use PluginServiceFactory to detect applicable Helm repository uploaders Signed-off-by: Rohan Kumar --- .../jkube/kit/common/util/AsyncUtil.java | 17 ++++ .../jkube/kit/common/util/AsyncUtilTest.java | 50 +++++++++++ .../ArtifactoryHelmRepositoryUploader.java | 30 +++++++ .../ChartMuseumHelmRepositoryUploader.java | 30 +++++++ .../jkube/kit/resource/helm/HelmService.java | 4 +- .../jkube/kit/resource/helm/HelmUploader.java | 59 +----------- .../resource/helm/HelmUploaderManager.java | 40 +++++++++ .../helm/NexusHelmRepositoryUploader.java | 33 +++++++ .../helm/StandardRepositoryUploader.java | 89 +++++++++++++++++++ .../resources/META-INF/jkube/helm-uploaders | 3 + .../resource/helm/HelmServiceUploadIT.java | 3 +- .../helm/HelmUploaderManagerTest.java | 47 ++++++++++ 12 files changed, 346 insertions(+), 59 deletions(-) create mode 100644 jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/AsyncUtilTest.java create mode 100644 jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ArtifactoryHelmRepositoryUploader.java create mode 100644 jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ChartMuseumHelmRepositoryUploader.java create mode 100644 jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManager.java create mode 100644 jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/NexusHelmRepositoryUploader.java create mode 100644 jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/StandardRepositoryUploader.java create mode 100644 jkube-kit/resource/helm/src/main/resources/META-INF/jkube/helm-uploaders create mode 100644 jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManagerTest.java diff --git a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/AsyncUtil.java b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/AsyncUtil.java index 4945bdf589..9990f1e6bb 100644 --- a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/AsyncUtil.java +++ b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/AsyncUtil.java @@ -13,10 +13,14 @@ */ package org.eclipse.jkube.kit.common.util; +import java.time.Duration; import java.util.concurrent.Callable; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; @@ -56,4 +60,17 @@ public static Function, CompletableFuture> await(Supplier return ret; }); } + + public static T get(CompletableFuture completableFuture, Duration duration) { + try { + return completableFuture.get(duration.toMillis(), TimeUnit.MILLISECONDS); + } catch (ExecutionException e) { + throw new IllegalStateException(e); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new IllegalStateException(e); + } catch (TimeoutException e) { + throw new IllegalStateException("Failure while waiting to get future ", e); + } + } } diff --git a/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/AsyncUtilTest.java b/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/AsyncUtilTest.java new file mode 100644 index 0000000000..93888f7a57 --- /dev/null +++ b/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/AsyncUtilTest.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.common.util; + +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.time.Duration; +import java.util.concurrent.CompletableFuture; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; + +class AsyncUtilTest { + @Test + void get_whenFuturePresent_thenReturnValue() { + // Given + CompletableFuture completableFuture = CompletableFuture.completedFuture("foo"); + + // When + String result = AsyncUtil.get(completableFuture, Duration.ofMinutes(1)); + + // Then + assertThat(result).isEqualTo("foo"); + } + + @Test + void get_whenFutureCompletedExceptionally_then() { + // Given + CompletableFuture completableFuture = new CompletableFuture<>(); + completableFuture.completeExceptionally(new IOException("io exception")); + + // When + // Then + assertThatIllegalStateException() + .isThrownBy(() -> AsyncUtil.get(completableFuture, Duration.ofMinutes(1))) + .withMessageContaining("io exception"); + } +} diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ArtifactoryHelmRepositoryUploader.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ArtifactoryHelmRepositoryUploader.java new file mode 100644 index 0000000000..362bbeb367 --- /dev/null +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ArtifactoryHelmRepositoryUploader.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.resource.helm; + +import org.eclipse.jkube.kit.common.KitLogger; + +import java.io.File; + +public class ArtifactoryHelmRepositoryUploader extends StandardRepositoryUploader { + + public ArtifactoryHelmRepositoryUploader(KitLogger logger) { + super("PUT", logger, HelmRepository.HelmRepoType.ARTIFACTORY); + } + + @Override + public String url(File helmChart, HelmRepository repository) { + return formatRepositoryURL(helmChart, repository); + } +} diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ChartMuseumHelmRepositoryUploader.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ChartMuseumHelmRepositoryUploader.java new file mode 100644 index 0000000000..9906687bd6 --- /dev/null +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ChartMuseumHelmRepositoryUploader.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.resource.helm; + +import org.eclipse.jkube.kit.common.KitLogger; + +import java.io.File; + +public class ChartMuseumHelmRepositoryUploader extends StandardRepositoryUploader { + + public ChartMuseumHelmRepositoryUploader(KitLogger logger) { + super("POST", logger, HelmRepository.HelmRepoType.CHARTMUSEUM); + } + + @Override + public String url(File helmChart, HelmRepository repository) { + return repository.getUrl(); + } +} diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmService.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmService.java index f40635eac0..97d5083f98 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmService.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmService.java @@ -160,7 +160,7 @@ private void uploadHelmChart(HelmConfig helmConfig, HelmRepository helmRepositor throws IOException, BadUploadException { for (HelmConfig.HelmType helmType : helmConfig.getTypes()) { - final HelmUploader helmUploader = new HelmUploader(logger); + final HelmUploaderManager helmUploaderManager = new HelmUploaderManager(logger); logger.info("Uploading Helm Chart \"%s\" to %s", helmConfig.getChart(), helmRepository.getName()); logger.debug("OutputDir: %s", helmConfig.getOutputDir()); @@ -170,7 +170,7 @@ private void uploadHelmChart(HelmConfig helmConfig, HelmRepository helmRepositor final File tarballFile = new File(tarballOutputDir, String.format("%s-%s%s.%s", helmConfig.getChart(), helmConfig.getVersion(), resolveHelmClassifier(helmConfig), helmConfig.getChartExtension())); - helmUploader.uploadSingle(tarballFile, helmRepository); + helmUploaderManager.getHelmUploader(helmRepository.getType()).uploadSingle(tarballFile, helmRepository); } } diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploader.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploader.java index b3ddeb5b10..26b46b504b 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploader.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploader.java @@ -14,60 +14,9 @@ package org.eclipse.jkube.kit.resource.helm; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; -import java.net.HttpURLConnection; -import java.nio.charset.Charset; -import org.eclipse.jkube.kit.common.KitLogger; - -import org.apache.commons.io.IOUtils; - -public class HelmUploader { - - private final KitLogger logger; - - public HelmUploader(KitLogger logger) { - this.logger = logger; - } - - void uploadSingle(File file, HelmRepository repository) - throws IOException, BadUploadException { - HttpURLConnection connection; - - if (repository.getType() == null) { - throw new IllegalArgumentException( - "Repository type missing. Check your plugin configuration."); - } - - connection = repository.getType().createConnection(file, repository); - - writeFileOnConnection(file, connection); - - if (connection.getResponseCode() >= HttpURLConnection.HTTP_MULT_CHOICE) { - String response; - if (connection.getErrorStream() != null) { - response = IOUtils.toString(connection.getErrorStream(), Charset.defaultCharset()); - } else if (connection.getInputStream() != null) { - response = IOUtils.toString(connection.getInputStream(), Charset.defaultCharset()); - } else { - response = "No details provided"; - } - throw new BadUploadException(response); - } else { - String message = Integer.toString(connection.getResponseCode()); - if (connection.getInputStream() != null) { - message += " - " + IOUtils.toString(connection.getInputStream(), Charset.defaultCharset()); - } - logger.info(message); - } - connection.disconnect(); - } - - private void writeFileOnConnection(File file, HttpURLConnection connection) throws IOException { - try (FileInputStream fileInputStream = new FileInputStream(file)) { - IOUtils.copy(fileInputStream, connection.getOutputStream()); - } - } - -} +public interface HelmUploader { + HelmRepository.HelmRepoType getType(); + void uploadSingle(File file, HelmRepository repository) throws IOException, BadUploadException ; +} \ No newline at end of file diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManager.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManager.java new file mode 100644 index 0000000000..2d8d67b836 --- /dev/null +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManager.java @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.resource.helm; + +import org.eclipse.jkube.kit.common.KitLogger; +import org.eclipse.jkube.kit.common.util.PluginServiceFactory; + +import java.util.List; + +public class HelmUploaderManager { + private static final String[] SERVICE_PATHS = new String[] { + "META-INF/jkube/helm-uploaders" + }; + + private final List helmUploaderList; + + public HelmUploaderManager(KitLogger log) { + this.helmUploaderList = new PluginServiceFactory<>(log).createServiceObjects(SERVICE_PATHS); + } + + public HelmUploader getHelmUploader(HelmRepository.HelmRepoType type) { + for (HelmUploader helmUploader : helmUploaderList) { + if (helmUploader.getType().equals(type)) { + return helmUploader; + } + } + throw new IllegalStateException("Could not find Helm Uploader for type " + type); + } +} \ No newline at end of file diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/NexusHelmRepositoryUploader.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/NexusHelmRepositoryUploader.java new file mode 100644 index 0000000000..dd0cc4380b --- /dev/null +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/NexusHelmRepositoryUploader.java @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.resource.helm; + +import org.eclipse.jkube.kit.common.KitLogger; + +import java.io.File; + +public class NexusHelmRepositoryUploader extends StandardRepositoryUploader { + public NexusHelmRepositoryUploader(KitLogger logger) { + super("PUT", logger, HelmRepository.HelmRepoType.NEXUS); + } + + @Override + public String url(File helmChart, HelmRepository repository) { + String url = formatRepositoryURL(helmChart, repository); + if (url.endsWith(".tar.gz")) { + url = url.replaceAll("tar.gz$", "tgz"); + } + return url; + } +} diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/StandardRepositoryUploader.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/StandardRepositoryUploader.java new file mode 100644 index 0000000000..e03bb4d203 --- /dev/null +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/StandardRepositoryUploader.java @@ -0,0 +1,89 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.resource.helm; + +import io.fabric8.kubernetes.client.RequestConfigBuilder; +import io.fabric8.kubernetes.client.http.HttpClient; +import io.fabric8.kubernetes.client.http.HttpRequest; +import io.fabric8.kubernetes.client.http.HttpResponse; +import io.fabric8.kubernetes.client.utils.HttpClientUtils; +import org.apache.commons.lang3.StringUtils; +import org.eclipse.jkube.kit.common.KitLogger; +import org.eclipse.jkube.kit.common.util.Base64Util; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.time.Duration; + +import static org.eclipse.jkube.kit.common.util.AsyncUtil.get; + +public abstract class StandardRepositoryUploader implements HelmUploader { + private final String method; + private final KitLogger logger; + private final HelmRepository.HelmRepoType type; + private static final long HELM_UPLOAD_TIMEOUT_MINUTES = 30; + + protected StandardRepositoryUploader(String method, KitLogger logger, HelmRepository.HelmRepoType type) { + this.method = method; + this.logger = logger; + this.type = type; + } + + public abstract String url(File helmChart, HelmRepository repository); + + @Override + public HelmRepository.HelmRepoType getType() { + return type; + } + + @Override + public void uploadSingle(File file, HelmRepository repository) throws IOException, BadUploadException { + String uploadUrl = url(file, repository); + + try (HttpClient httpClient = HttpClientUtils.getHttpClientFactory().newBuilder().tag(new RequestConfigBuilder().withRequestRetryBackoffLimit(0).build()).build()) { + HttpRequest.Builder httpRequestBuilder = httpClient.newHttpRequestBuilder(); + httpRequestBuilder.uri(uploadUrl); + // At this point username and password are always populated since this is requirement in HelmService + httpRequestBuilder.header("Authorization", String.format("Basic %s", Base64Util.encodeToString(repository.getUsername() + ":" + repository.getPassword()))); + httpRequestBuilder.method(method, "application/gzip", Files.newInputStream(file.toPath()), file.length()); + HttpResponse response = get(httpClient.sendAsync(httpRequestBuilder.build(), byte[].class), Duration.ofMinutes(HELM_UPLOAD_TIMEOUT_MINUTES)); + handleHttpResponse(response); + } + } + + private void handleHttpResponse(HttpResponse response) throws BadUploadException { + if (!response.isSuccessful()) { + String responseStr; + if (response.body() != null) { + responseStr = new String(response.body()); + } else if (StringUtils.isNotBlank(response.message())) { + responseStr = response.message(); + } else { + responseStr = "No details provided"; + } + throw new BadUploadException(responseStr); + } else { + String message = Integer.toString(response.code()); + if (response.body() != null) { + message += " - " + new String(response.body()); + } + logger.info(message); + } + } + + protected String formatRepositoryURL(File file, HelmRepository repository) { + return String.format("%s%s", StringUtils.appendIfMissing(repository.getUrl(), "/"), file.getName()); + } +} diff --git a/jkube-kit/resource/helm/src/main/resources/META-INF/jkube/helm-uploaders b/jkube-kit/resource/helm/src/main/resources/META-INF/jkube/helm-uploaders new file mode 100644 index 0000000000..1c88bb86bf --- /dev/null +++ b/jkube-kit/resource/helm/src/main/resources/META-INF/jkube/helm-uploaders @@ -0,0 +1,3 @@ +org.eclipse.jkube.kit.resource.helm.ArtifactoryHelmRepositoryUploader,100 +org.eclipse.jkube.kit.resource.helm.ChartMuseumHelmRepositoryUploader,100 +org.eclipse.jkube.kit.resource.helm.NexusHelmRepositoryUploader,100 \ No newline at end of file diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUploadIT.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUploadIT.java index b3205a2e95..449f387d75 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUploadIT.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUploadIT.java @@ -13,7 +13,6 @@ */ package org.eclipse.jkube.kit.resource.helm; -import java.io.FileNotFoundException; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -257,7 +256,7 @@ void withServerErrorAndNoDetails_shouldThrowException() { .andReturn(404, "") .always(); // When - final FileNotFoundException result = assertThrows(FileNotFoundException.class, + final BadUploadException result = assertThrows(BadUploadException.class, () -> helmService.uploadHelmChart(helmConfig)); // Then assertThat(result).isNotNull(); diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManagerTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManagerTest.java new file mode 100644 index 0000000000..4722612c15 --- /dev/null +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManagerTest.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.resource.helm; + +import org.eclipse.jkube.kit.common.KitLogger; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import java.util.stream.Stream; + +import static org.assertj.core.api.Assertions.assertThat; + +class HelmUploaderManagerTest { + private static Stream testData() { + return Stream.of( + Arguments.of("ARTIFACTORY", ArtifactoryHelmRepositoryUploader.class), + Arguments.of("NEXUS", NexusHelmRepositoryUploader.class), + Arguments.of("CHARTMUSEUM", ChartMuseumHelmRepositoryUploader.class) + ); + } + + @ParameterizedTest + @MethodSource("testData") + void getHelmUploader_whenValidHelmTypeProvided_thenReturnAppropriateUploader(HelmRepository.HelmRepoType type, Class helmUploaderType) { + // Given + HelmUploaderManager helmUploaderManager = new HelmUploaderManager(new KitLogger.SilentLogger()); + + // When + HelmUploader helmUploader = helmUploaderManager.getHelmUploader(type); + + // Then + assertThat(helmUploader) + .isInstanceOf(helmUploaderType); + } +} From f0d95abfc601ac862a2501b2e2ccc6ccfbb0ee80 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Thu, 13 Jul 2023 10:23:27 +0200 Subject: [PATCH 34/65] ci: fix doc-preview works on master branch Signed-off-by: Marc Nuri --- .jenkins/pipelines/doc-preview.Jenkinsfile | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.jenkins/pipelines/doc-preview.Jenkinsfile b/.jenkins/pipelines/doc-preview.Jenkinsfile index 68649d3136..d1d24c1a47 100644 --- a/.jenkins/pipelines/doc-preview.Jenkinsfile +++ b/.jenkins/pipelines/doc-preview.Jenkinsfile @@ -16,12 +16,8 @@ pipeline { steps { sh 'echo "Generating project documentation"' sh './scripts/generateDoc.sh' + archiveArtifacts artifacts: 'docs-generated/*.html,docs-generated/*.txt,docs-generated/*.css', fingerprint: true } } } - post { - success { - archiveArtifacts artifacts: 'docs-generated/*.html,docs-generated/*.txt,docs-generated/*.css', fingerprint: true - } - } } From b016b35b83c3e5a37fd65282ee7f16d85d316e5c Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Wed, 12 Jul 2023 13:03:54 +0200 Subject: [PATCH 35/65] refactor: remove consolidate redundant applyXxx methods into applyResource Signed-off-by: Marc Nuri --- .../kit/config/service/ApplyService.java | 241 ++---------------- .../kit/config/service/PatchService.java | 119 +-------- .../config/service/ApplyServiceCrudTest.java | 62 ++++- .../kit/config/service/DebugServiceTest.java | 9 +- .../{openshift => }/PatchServiceTest.java | 62 +---- 5 files changed, 91 insertions(+), 402 deletions(-) rename jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/{openshift => }/PatchServiceTest.java (59%) diff --git a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/ApplyService.java b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/ApplyService.java index d11d09d371..7c8cd92027 100644 --- a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/ApplyService.java +++ b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/ApplyService.java @@ -45,16 +45,11 @@ import io.fabric8.kubernetes.api.model.Namespace; import io.fabric8.kubernetes.api.model.ObjectMeta; import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; -import io.fabric8.kubernetes.api.model.Pod; import io.fabric8.kubernetes.api.model.ReplicationController; import io.fabric8.kubernetes.api.model.ReplicationControllerSpec; -import io.fabric8.kubernetes.api.model.Secret; import io.fabric8.kubernetes.api.model.Service; -import io.fabric8.kubernetes.api.model.ServiceAccount; -import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition; import io.fabric8.kubernetes.api.model.batch.v1.Job; import io.fabric8.kubernetes.api.model.extensions.Ingress; -import io.fabric8.kubernetes.api.model.rbac.RoleBinding; import io.fabric8.kubernetes.client.KubernetesClient; import io.fabric8.kubernetes.client.KubernetesClientException; import io.fabric8.kubernetes.client.dsl.Resource; @@ -145,12 +140,8 @@ public boolean isAlreadyApplied(HasMetadata resource) { * Applies the given DTOs onto the Kubernetes master */ private void applyEntity(Object dto, String sourceName) { - if (dto instanceof Pod) { - applyPod((Pod) dto, sourceName); - } else if (dto instanceof ReplicationController) { + if (dto instanceof ReplicationController) { applyReplicationController((ReplicationController) dto, sourceName); - } else if (dto instanceof Service) { - applyService((Service) dto, sourceName); } else if (dto instanceof Route) { applyRoute((Route) dto, sourceName); } else if (dto instanceof BuildConfig) { @@ -162,18 +153,12 @@ private void applyEntity(Object dto, String sourceName) { } else { log.warn("Not connected to OpenShift cluster so cannot apply entity %s", dto); } - } else if (dto instanceof RoleBinding) { - applyRoleBinding((RoleBinding) dto, sourceName); } else if (dto instanceof ImageStream) { applyImageStream((ImageStream) dto, sourceName); } else if (dto instanceof OAuthClient) { applyOAuthClient((OAuthClient) dto, sourceName); } else if (dto instanceof Template) { applyTemplate((Template) dto, sourceName); - } else if (dto instanceof ServiceAccount) { - applyServiceAccount((ServiceAccount) dto, sourceName); - } else if (dto instanceof Secret) { - applySecret((Secret) dto, sourceName); } else if (dto instanceof Ingress) { applyResource((Ingress) dto, sourceName); ingressControllerDetectorManager.detect(); @@ -182,8 +167,6 @@ private void applyEntity(Object dto, String sourceName) { ingressControllerDetectorManager.detect(); } else if (dto instanceof PersistentVolumeClaim) { applyPersistentVolumeClaim((PersistentVolumeClaim) dto, sourceName); - } else if (dto instanceof CustomResourceDefinition) { - applyCustomResourceDefinition((CustomResourceDefinition) dto, sourceName); } else if (dto instanceof Job) { applyJob((Job) dto, sourceName); } else if (dto instanceof Namespace) { @@ -338,45 +321,6 @@ protected void doCreateTemplate(Template entity, String namespace, String source } } - /** - * Creates/updates a service account and processes it returning the processed DTOs - */ - public void applyServiceAccount(ServiceAccount serviceAccount, String sourceName) { - String currentNamespace = applicableNamespace(serviceAccount, namespace, fallbackNamespace); - String id = getName(serviceAccount); - Objects.requireNonNull(id, "No name for " + serviceAccount + " " + sourceName); - if (isServicesOnlyMode()) { - log.debug("Only processing Services right now so ignoring ServiceAccount: " + id); - return; - } - ServiceAccount old = kubernetesClient.serviceAccounts().inNamespace(currentNamespace).withName(id).get(); - if (isRunning(old)) { - if (UserConfigurationCompare.configEqual(serviceAccount, old)) { - log.info("ServiceAccount has not changed so not doing anything"); - } else { - if (isRecreateMode()) { - kubernetesClient.serviceAccounts().inNamespace(currentNamespace).withName(id).delete(); - doCreate(serviceAccount, currentNamespace, sourceName); - } else { - log.info("Updating a ServiceAccount from " + sourceName); - try { - Object answer = kubernetesClient.serviceAccounts().inNamespace(currentNamespace).withName(id).replace(serviceAccount); - logGeneratedEntity("Updated ServiceAccount: ", currentNamespace, serviceAccount, answer); - } catch (Exception e) { - onApplyError("Failed to update ServiceAccount from " + sourceName + ". " + e + ". " + serviceAccount, e); - } - } - } - } else { - if (!isAllowCreate()) { - log.warn("Creation disabled so not creating a %s from %s in namespace %s with name %s", - "ServiceAccount", sourceName, currentNamespace, id); - } else { - doCreate(serviceAccount, currentNamespace, sourceName); - } - } - } - public void applyPersistentVolumeClaim(PersistentVolumeClaim entity, String sourceName) { // we cannot update PVCs boolean alwaysRecreate = true; @@ -408,80 +352,20 @@ public void applyPersistentVolumeClaim(PersistentVolumeClaim entity, String sour } } else { if (!isAllowCreate()) { - log.warn("Creation disabled so not creating a PersistentVolumeClaim from " + sourceName + " namespace " + currentNamespace + " name " + getName(entity)); + log.warn("Creation disabled so not creating a %s from %s in namespace %s with name %s", + "PersistentVolumeClaim", sourceName, currentNamespace, id); } else { doCreate(entity, currentNamespace, sourceName); } } } - public void applyCustomResourceDefinition(CustomResourceDefinition entity, String fileName) { - final String name = getName(entity); - Objects.requireNonNull(name, "No name for CustomResourceDefinition " + fileName); - if (isServicesOnlyMode()) { - log.debug("Only processing Services right now so ignoring Custom Resource Definition: %s", name); - return; - } - CustomResourceDefinition old = kubernetesClient.apiextensions().v1().customResourceDefinitions().withName(name).get(); - if (isRunning(old)) { - if (UserConfigurationCompare.configEqual(entity, old)) { - log.info("Custom Resource Definition has not changed so not doing anything"); - } else { - if (isRecreateMode()) { - log.info("Deleting Custom Resource Definition: %s", name); - kubernetesClient.apiextensions().v1().customResourceDefinitions().withName(name).delete(); - doCreate(entity, null, fileName); - } else { - doPatchEntity(old, entity, null, fileName); - } - } - } else { - if (!isAllowCreate()) { - log.warn("Creation disabled so not creating a Custom Resource Definition from " + fileName + " name " + getName(entity)); - } else { - doCreate(entity, null, fileName); - } - } - } - protected boolean isBound(PersistentVolumeClaim claim) { return claim != null && claim.getStatus() != null && "Bound".equals(claim.getStatus().getPhase()); } - public void applySecret(Secret secret, String sourceName) { - String currentNamespace = applicableNamespace(secret, namespace, fallbackNamespace); - String id = getName(secret); - Objects.requireNonNull(id, "No name for " + secret + " " + sourceName); - if (isServicesOnlyMode()) { - log.debug("Only processing Services right now so ignoring Secrets: " + id); - return; - } - - Secret old = kubernetesClient.secrets().inNamespace(currentNamespace).withName(id).get(); - // check if the secret already exists or not - if (isRunning(old)) { - // if the secret already exists and is the same, then do nothing - if (UserConfigurationCompare.configEqual(secret, old)) { - log.info("Secret has not changed so not doing anything"); - } else { - if (isRecreateMode()) { - kubernetesClient.secrets().inNamespace(currentNamespace).withName(id).delete(); - doCreate(secret, currentNamespace, sourceName); - } else { - doPatchEntity(old, secret, currentNamespace, sourceName); - } - } - } else { - if (!isAllowCreate()) { - log.warn("Creation disabled so not creating a Secret from " + sourceName + " namespace " + currentNamespace + " name " + getName(secret)); - } else { - doCreate(secret, currentNamespace, sourceName); - } - } - } - private void logGeneratedEntity(String message, String namespace, HasMetadata entity, Object result) { if (logJsonDir != null) { final File directory = StringUtils.isBlank(namespace) ? logJsonDir : new File(logJsonDir, namespace); @@ -638,44 +522,6 @@ public void doCreateBuildConfig(BuildConfig entity, String namespace , String so } } - public void applyRoleBinding(RoleBinding entity, String sourceName) { - String id = getName(entity); - - Objects.requireNonNull(id, "No name for " + entity + " " + sourceName); - String currentNamespace = applicableNamespace(entity, namespace, fallbackNamespace); - - RoleBinding old = kubernetesClient.rbac().roleBindings().inNamespace(currentNamespace).withName(id).get(); - if (isRunning(old)) { - if (UserConfigurationCompare.configEqual(entity, old)) { - log.info("RoleBinding has not changed so not doing anything"); - } else { - if (isRecreateMode()) { - log.info("Deleting RoleBinding: " + id); - kubernetesClient.rbac().roleBindings().inNamespace(currentNamespace).withName(id).delete(); - doCreate(entity, currentNamespace, sourceName); - } else { - log.info("Updating RoleBinding from " + sourceName); - try { - String resourceVersion = KubernetesHelper.getResourceVersion(old); - ObjectMeta metadata = getOrCreateMetadata(entity); - metadata.setNamespace(currentNamespace); - metadata.setResourceVersion(resourceVersion); - Object answer = kubernetesClient.rbac().roleBindings().inNamespace(currentNamespace).withName(id).replace(entity); - logGeneratedEntity("Updated RoleBinding: ", currentNamespace, entity, answer); - } catch (Exception e) { - onApplyError("Failed to update RoleBinding from " + sourceName + ". " + e + ". " + entity, e); - } - } - } - } else { - if (!isAllowCreate()) { - log.warn("Creation disabled so not creating RoleBinding from " + sourceName + " namespace " + currentNamespace + " name " + getName(entity)); - } else { - doCreate(entity, currentNamespace, sourceName); - } - } - } - public void applyImageStream(ImageStream entity, String sourceName) { if (OpenshiftHelper.isOpenShift(kubernetesClient)) { String kind = getKind(entity); @@ -754,43 +600,12 @@ public void applyList(KubernetesList list, String sourceName) { } } - public void applyService(Service service, String sourceName) { - String currentNamespace = applicableNamespace(service, namespace, fallbackNamespace); - String id = getName(service); - Objects.requireNonNull(id, "No name for " + service + " " + sourceName); - if (isIgnoreServiceMode()) { - log.debug("Ignoring Service: " + currentNamespace + ":" + id); - return; - } - Service old = kubernetesClient.services().inNamespace(currentNamespace).withName(id).get(); - if (isRunning(old)) { - if (UserConfigurationCompare.configEqual(service, old)) { - log.info("Service has not changed so not doing anything"); - } else { - if (isRecreateMode()) { - log.info("Deleting Service: " + id); - kubernetesClient.services().inNamespace(currentNamespace).withName(id).delete(); - doCreate(service, currentNamespace, sourceName); - } else { - doPatchEntity(old, service, currentNamespace, sourceName); - } - } - } else { - if (!isAllowCreate()) { - log.warn("Creation disabled so not creating a %s from %s in namespace %s with name %s", - "Service", sourceName, currentNamespace, id); - } else { - doCreate(service, currentNamespace, sourceName); - } - } - } - - public void applyResource(T resource, String sourceName) { + public void applyResource(T resource, String sourceName) { String currentNamespace = applicableNamespace(resource, namespace, fallbackNamespace); String id = getName(resource); String kind = getKind(resource); Objects.requireNonNull(id, "No name for " + resource + " " + sourceName); - if (isServicesOnlyMode()) { + if (isServicesOnlyMode() && !(resource instanceof Service)) { log.debug("Ignoring " + kind + ": " + currentNamespace + ":" + id); return; } @@ -806,17 +621,23 @@ public void applyResource(T resource, String sourceNam } else { log.info("Updating " + kind + " from " + sourceName); try { - Object answer = kubernetesClient.resource(resource).inNamespace(currentNamespace).replace(); - logGeneratedEntity("Updated " + kind + ": ", currentNamespace, resource, answer); + T updatedResource = kubernetesClient + .resource(resource) + .inNamespace(currentNamespace) + .patch(); + logGeneratedEntity("Updated " + kind + ": ", currentNamespace, resource, updatedResource); } catch (Exception e) { onApplyError("Failed to update " + kind + " from " + sourceName + ". " + e + ". " + resource, e); } } } } else { - if (!isAllowCreate()) { + if (!isAllowCreate() && resource instanceof Namespaced) { log.warn("Creation disabled so not creating a %s from %s in namespace %s with name %s", kind, sourceName, currentNamespace, id); + } else if (!isAllowCreate()) { + log.warn("Creation disabled so not creating a %s from %s with name %s", + kind, sourceName, id); } else { doCreate(resource, currentNamespace, sourceName); } @@ -1023,42 +844,12 @@ public void applyReplicationController(ReplicationController replicationControll } } } - } else { - if (!isAllowCreate()) { - log.warn("Creation disabled so not creating a ReplicationController from " + sourceName + " namespace " + currentNamespace + " name " + getName(replicationController)); - } else { - doCreate(replicationController, currentNamespace, sourceName); - } - } - } - - public void applyPod(Pod pod, String sourceName) { - String currentNamespace = applicableNamespace(pod, namespace, fallbackNamespace); - final String name = getName(pod); - Objects.requireNonNull(name, "No name for " + pod + " " + sourceName); - if (isServicesOnlyMode()) { - log.debug("Only processing Services right now so ignoring Pod: " + currentNamespace + ":" + name); - return; - } - Pod old = kubernetesClient.pods().inNamespace(currentNamespace).withName(name).get(); - if (isRunning(old)) { - if (UserConfigurationCompare.configEqual(pod, old)) { - log.info("Pod has not changed so not doing anything"); - } else { - if (isRecreateMode()) { - log.info("Deleting Pod: " + name); - kubernetesClient.pods().inNamespace(currentNamespace).withName(name).delete(); - doCreate(pod, currentNamespace, sourceName); - } else { - doPatchEntity(old, pod, currentNamespace, sourceName); - } - } } else { if (!isAllowCreate()) { log.warn("Creation disabled so not creating a %s from %s in namespace %s with name %s", - "Pod", sourceName, currentNamespace, name); + "ReplicationController", sourceName, currentNamespace, id); } else { - doCreate(pod, currentNamespace, sourceName); + doCreate(replicationController, currentNamespace, sourceName); } } } diff --git a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/PatchService.java b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/PatchService.java index 1baf97f59e..f9c13482d3 100644 --- a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/PatchService.java +++ b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/PatchService.java @@ -16,19 +16,11 @@ import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; import io.fabric8.kubernetes.api.model.PersistentVolumeClaimBuilder; -import io.fabric8.kubernetes.api.model.Pod; -import io.fabric8.kubernetes.api.model.PodBuilder; import io.fabric8.kubernetes.api.model.ReplicationController; import io.fabric8.kubernetes.api.model.ReplicationControllerBuilder; -import io.fabric8.kubernetes.api.model.Secret; -import io.fabric8.kubernetes.api.model.SecretBuilder; -import io.fabric8.kubernetes.api.model.Service; -import io.fabric8.kubernetes.api.model.ServiceBuilder; -import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionBuilder; import io.fabric8.kubernetes.api.model.batch.v1.Job; import io.fabric8.kubernetes.api.model.batch.v1.JobBuilder; import io.fabric8.kubernetes.client.KubernetesClient; -import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition; import io.fabric8.openshift.api.model.BuildConfig; import io.fabric8.openshift.api.model.BuildConfigBuilder; import io.fabric8.openshift.api.model.ImageStream; @@ -64,14 +56,10 @@ interface EntityPatcher { static { patchers = new HashMap<>(); - patchers.put("Pod", podPatcher()); patchers.put("ReplicationController", rcPatcher()); - patchers.put("Service", servicePatcher()); patchers.put("BuildConfig", bcPatcher()); patchers.put("ImageStream", isPatcher()); - patchers.put("Secret", secretPatcher()); patchers.put("PersistentVolumeClaim", pvcPatcher()); - patchers.put("CustomResourceDefinition", crdPatcher()); patchers.put("Job", jobPatcher()); patchers.put("Route", routePatcher()); } @@ -85,40 +73,13 @@ public T compareAndPatchEntity(String namespace, T newDt if (dispatcher == null) { throw new IllegalArgumentException("Internal: No patcher for " + newDto.getKind() + " found"); } - /** + /* * This is done in order to fix https://github.com/openshift/origin/issues/19905 */ newDto.getMetadata().setResourceVersion(oldDto.getMetadata().getResourceVersion()); return dispatcher.patch(kubernetesClient, namespace, newDto, oldDto); } - private static EntityPatcher podPatcher() { - return (KubernetesClient client, String namespace, Pod newObj, Pod oldObj) -> { - if (UserConfigurationCompare.configEqual(newObj, oldObj)) { - return oldObj; - } - - PodBuilder entity = - new PodBuilder(client.pods() - .inNamespace(namespace) - .withName(oldObj.getMetadata().getName()) - .get()); - - - if (!UserConfigurationCompare.configEqual(newObj.getMetadata(), oldObj.getMetadata())) { - entity.withMetadata(newObj.getMetadata()); - } - - if(!UserConfigurationCompare.configEqual(newObj.getSpec(), oldObj.getSpec())) { - entity.withSpec(newObj.getSpec()); - } - return client.pods() - .inNamespace(namespace) - .withName(oldObj.getMetadata().getName()) - .edit(p -> entity.build()); - }; - } - private static EntityPatcher rcPatcher() { return (KubernetesClient client, String namespace, ReplicationController newObj, ReplicationController oldObj) -> { if (UserConfigurationCompare.configEqual(newObj, oldObj)) { @@ -145,60 +106,6 @@ private static EntityPatcher rcPatcher() { }; } - private static EntityPatcher servicePatcher() { - return (KubernetesClient client, String namespace, Service newObj, Service oldObj) -> { - if (UserConfigurationCompare.configEqual(newObj, oldObj)) { - return oldObj; - } - - ServiceBuilder entity = - new ServiceBuilder(client.services() - .inNamespace(namespace) - .withName(newObj.getMetadata().getName()) - .get()); - - if (!UserConfigurationCompare.configEqual(newObj.getMetadata(), oldObj.getMetadata())) { - entity.withMetadata(newObj.getMetadata()); - } - - if(!UserConfigurationCompare.configEqual(newObj.getSpec(), oldObj.getSpec())) { - entity.withSpec(newObj.getSpec()); - } - return client.services() - .inNamespace(namespace) - .withName(newObj.getMetadata().getName()) - .patch(entity.build()); - }; - } - - private static EntityPatcher secretPatcher() { - return (KubernetesClient client, String namespace, Secret newObj, Secret oldObj) -> { - if (UserConfigurationCompare.configEqual(newObj, oldObj)) { - return oldObj; - } - SecretBuilder entity = - new SecretBuilder(client.secrets() - .inNamespace(namespace) - .withName(oldObj.getMetadata().getName()) - .get()); - - if (!UserConfigurationCompare.configEqual(newObj.getMetadata(), oldObj.getMetadata())) { - entity.withMetadata(newObj.getMetadata()); - } - - if(!UserConfigurationCompare.configEqual(newObj.getData(), oldObj.getData())) { - entity.withData(newObj.getData()); - } - if(!UserConfigurationCompare.configEqual(newObj.getStringData(), oldObj.getStringData())) { - entity.withStringData(newObj.getStringData()); - } - return client.secrets() - .inNamespace(namespace) - .withName(oldObj.getMetadata().getName()) - .edit(p -> entity.build()); - }; - } - private static EntityPatcher pvcPatcher() { return (KubernetesClient client, String namespace, PersistentVolumeClaim newObj, PersistentVolumeClaim oldObj) -> { if (UserConfigurationCompare.configEqual(newObj, oldObj)) { @@ -224,30 +131,6 @@ private static EntityPatcher pvcPatcher() { }; } - private static EntityPatcher crdPatcher() { - return (KubernetesClient client, String namespace, CustomResourceDefinition newObj, CustomResourceDefinition oldObj) -> { - if (UserConfigurationCompare.configEqual(newObj, oldObj)) { - return oldObj; - } - - CustomResourceDefinitionBuilder entity = - new CustomResourceDefinitionBuilder(client.apiextensions().v1().customResourceDefinitions() - .withName(oldObj.getMetadata().getName()) - .get()); - - if (!UserConfigurationCompare.configEqual(newObj.getMetadata(), oldObj.getMetadata())) { - entity.withMetadata(newObj.getMetadata()); - } - - if (!UserConfigurationCompare.configEqual(newObj.getSpec(), oldObj.getSpec())) { - entity.withSpec(newObj.getSpec()); - } - return client.apiextensions().v1().customResourceDefinitions() - .withName(oldObj.getMetadata().getName()) - .edit(p -> entity.build()); - }; - } - private static EntityPatcher jobPatcher() { return (KubernetesClient client, String namespace, Job newObj, Job oldObj) -> { if (UserConfigurationCompare.configEqual(newObj, oldObj)) { diff --git a/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceCrudTest.java b/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceCrudTest.java index 060b44ee44..265aef3576 100644 --- a/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceCrudTest.java +++ b/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceCrudTest.java @@ -19,13 +19,18 @@ import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.KubernetesList; import io.fabric8.kubernetes.api.model.KubernetesListBuilder; +import io.fabric8.kubernetes.api.model.PersistentVolumeClaimBuilder; import io.fabric8.kubernetes.api.model.PodBuilder; +import io.fabric8.kubernetes.api.model.ReplicationControllerBuilder; +import io.fabric8.kubernetes.api.model.SecretBuilder; import io.fabric8.kubernetes.api.model.ServiceAccountBuilder; import io.fabric8.kubernetes.api.model.ServiceBuilder; +import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionBuilder; import io.fabric8.kubernetes.api.model.apps.DaemonSetBuilder; import io.fabric8.kubernetes.api.model.apps.DeploymentBuilder; import io.fabric8.kubernetes.api.model.apps.ReplicaSetBuilder; import io.fabric8.kubernetes.api.model.apps.StatefulSetBuilder; +import io.fabric8.kubernetes.api.model.rbac.RoleBindingBuilder; import io.fabric8.kubernetes.api.model.rbac.RoleBuilder; import io.fabric8.kubernetes.client.KubernetesClient; import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient; @@ -143,9 +148,14 @@ void applyInServicesMode() { .addToItems(new ServiceBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) .addToItems(new ServiceAccountBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) .addToItems(new RoleBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) + .addToItems(new RoleBindingBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) .addToItems(new DaemonSetBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) .addToItems(new ReplicaSetBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) .addToItems(new StatefulSetBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) + .addToItems(new ReplicationControllerBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) + .addToItems(new PersistentVolumeClaimBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) + .addToItems(new CustomResourceDefinitionBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) + .addToItems(new SecretBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) .build(); applyService.setServicesOnlyMode(true); // When @@ -156,16 +166,20 @@ void applyInServicesMode() { .returns(null, c -> c.pods().inNamespace("default").withName("a-resource").get()) .returns(null, c -> c.serviceAccounts().inNamespace("default").withName("a-resource").get()) .returns(null, c -> c.rbac().roles().inNamespace("default").withName("a-resource").get()) + .returns(null, c -> c.rbac().roleBindings().inNamespace("default").withName("a-resource").get()) .returns(null, c -> c.apps().daemonSets().inNamespace("default").withName("a-resource").get()) .returns(null, c -> c.apps().replicaSets().inNamespace("default").withName("a-resource").get()) .returns(null, c -> c.apps().statefulSets().inNamespace("default").withName("a-resource").get()) + .returns(null, c -> c.replicationControllers().inNamespace("default").withName("a-resource").get()) + .returns(null, c -> c.persistentVolumeClaims().inNamespace("default").withName("a-resource").get()) + .returns(null, c -> c.apiextensions().v1().customResourceDefinitions().withName("a-resource").get()) .returns("a-resource", c -> c.services().inNamespace("default").withName("a-resource").get().getMetadata().getName()); } - @DisplayName("apply with new resources and creation disabled, should do nothing") + @DisplayName("apply with new namespaced resource and creation disabled, should do nothing") @ParameterizedTest - @MethodSource("applyResourcesData") - void applyWithNewResourceAndCreationDisabled(HasMetadata toApplyResource) { + @MethodSource("applyNamespacedResourcesData") + void applyWithNewNamespacedResourceAndCreationDisabled(HasMetadata toApplyResource) { // Given applyService.setAllowCreate(false); // When @@ -177,10 +191,25 @@ void applyWithNewResourceAndCreationDisabled(HasMetadata toApplyResource) { toApplyResource.getKind(), "resource.yml", "default", "a-resource"); } + @DisplayName("apply with new cluster-scoped resource and creation disabled, should do nothing") + @ParameterizedTest + @MethodSource("applyClusterScopedResourcesData") + void applyWithNewResourceAndCreationDisabled(HasMetadata toApplyResource) { + // Given + applyService.setAllowCreate(false); + // When + applyService.apply(toApplyResource, "resource.yml"); + // Then + assertThat(kubernetesClient.resource(toApplyResource).inNamespace("default").get()) + .isNull(); + verify(log).warn("Creation disabled so not creating a %s from %s with name %s", + toApplyResource.getKind(), "resource.yml", "a-resource"); + } + @DisplayName("apply with existing resource, should update the resource") @ParameterizedTest - @MethodSource("applyResourcesData") - void applyWithExistingResources(HasMetadata toApplyResource) { + @MethodSource("applyAllResourcesData") + void applyWithExistingNamespacedResources(HasMetadata toApplyResource) { // Given final HasMetadata original = kubernetesClient.resource(toApplyResource).inNamespace("default").create(); toApplyResource.getMetadata().getAnnotations().put("updated", "true"); @@ -195,8 +224,8 @@ void applyWithExistingResources(HasMetadata toApplyResource) { @DisplayName("apply with existing resource, in recreate mode, should delete and recreate resource") @ParameterizedTest - @MethodSource("applyResourcesData") - void applyWithExistingResourceInRecreateMode(HasMetadata toApplyResource) { + @MethodSource("applyAllResourcesData") + void applyWithExistingNamespacedResourceInRecreateMode(HasMetadata toApplyResource) { // Given applyService.setRecreateMode(true); final HasMetadata original = kubernetesClient.resource(toApplyResource).inNamespace("default").create(); @@ -208,19 +237,34 @@ void applyWithExistingResourceInRecreateMode(HasMetadata toApplyResource) { .isNotEqualTo(original.getMetadata().getUid()); } - static Stream applyResourcesData() { + static Stream applyNamespacedResourcesData() { return Stream.of( Arguments.of(new PodBuilder().withNewMetadata().withName("a-resource").endMetadata().build()), Arguments.of(new DeploymentBuilder().withNewMetadata().withName("a-resource").endMetadata().build()), Arguments.of(new ServiceBuilder().withNewMetadata().withName("a-resource").endMetadata().withNewSpec().endSpec().build()), Arguments.of(new ServiceAccountBuilder().withNewMetadata().withName("a-resource").endMetadata().build()), Arguments.of(new RoleBuilder().withNewMetadata().withName("a-resource").endMetadata().build()), + Arguments.of(new RoleBindingBuilder().withNewMetadata().withName("a-resource").endMetadata().build()), Arguments.of(new DaemonSetBuilder().withNewMetadata().withName("a-resource").endMetadata().build()), Arguments.of(new ReplicaSetBuilder().withNewMetadata().withName("a-resource").endMetadata().build()), - Arguments.of(new StatefulSetBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) + Arguments.of(new StatefulSetBuilder().withNewMetadata().withName("a-resource").endMetadata().build()), + Arguments.of(new ReplicationControllerBuilder().withNewMetadata().withName("a-resource").endMetadata().withNewSpec().endSpec().build()), + Arguments.of(new SecretBuilder().withNewMetadata().withName("a-resource").endMetadata().build()) ); } + static Stream applyClusterScopedResourcesData() { + return Stream.of( + Arguments.of(new CustomResourceDefinitionBuilder().withNewMetadata().withName("a-resource").endMetadata() + .withNewSpec().withNewNames().withKind("Custom").withPlural("customs").endNames().endSpec() + .build()) + ); + } + + static Stream applyAllResourcesData() { + return Stream.concat(applyNamespacedResourcesData(), applyClusterScopedResourcesData()); + } + @Test @DisplayName("apply with Project, in vanilla Kubernetes, should do nothing") void applyProjectInKubernetes() { diff --git a/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/DebugServiceTest.java b/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/DebugServiceTest.java index 4d307d4677..0ae73a6809 100644 --- a/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/DebugServiceTest.java +++ b/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/DebugServiceTest.java @@ -13,6 +13,7 @@ */ package org.eclipse.jkube.kit.config.service; +import com.fasterxml.jackson.databind.JsonNode; import io.fabric8.kubernetes.api.model.APIGroupListBuilder; import io.fabric8.kubernetes.api.model.ConfigMap; import io.fabric8.kubernetes.api.model.LabelSelector; @@ -39,6 +40,7 @@ import io.fabric8.openshift.api.model.DeploymentConfigBuilder; import io.fabric8.openshift.api.model.DeploymentConfigSpecBuilder; import io.fabric8.openshift.client.OpenShiftClient; +import io.fabric8.zjsonpatch.JsonPatch; import okhttp3.mockwebserver.RecordedRequest; import org.assertj.core.groups.Tuple; import org.eclipse.jkube.kit.common.JKubeConfiguration; @@ -341,10 +343,13 @@ private static DeploymentConfig initDeploymentConfig() { } private Deployment withDeploymentRollout(Deployment deployment) { - mockServer.expect().put() + mockServer.expect().patch() .withPath("/apis/apps/v1/namespaces/test/deployments/" + deployment.getMetadata().getName()) .andReply(200, r -> { - final Deployment d = Serialization.unmarshal(r.getBody().inputStream(), Deployment.class); + final Deployment d = Serialization.convertValue( + JsonPatch.apply(Serialization.unmarshal(r.getBody().inputStream(), JsonNode.class), + Serialization.convertValue(deployment, JsonNode.class)), + Deployment.class); kubernetesClient.resource(new PodBuilder() .withMetadata(new ObjectMetaBuilder(d.getSpec().getTemplate().getMetadata()) .withName("pod-in-debug-mode") diff --git a/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/openshift/PatchServiceTest.java b/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/PatchServiceTest.java similarity index 59% rename from jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/openshift/PatchServiceTest.java rename to jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/PatchServiceTest.java index 9917c73f94..2903b664e9 100644 --- a/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/openshift/PatchServiceTest.java +++ b/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/PatchServiceTest.java @@ -11,22 +11,18 @@ * Contributors: * Red Hat, Inc. - initial API and implementation */ -package org.eclipse.jkube.kit.config.service.openshift; +package org.eclipse.jkube.kit.config.service; import io.fabric8.kubernetes.api.model.ConfigMap; import io.fabric8.kubernetes.api.model.ConfigMapBuilder; -import io.fabric8.kubernetes.api.model.IntOrString; -import io.fabric8.kubernetes.api.model.Secret; -import io.fabric8.kubernetes.api.model.SecretBuilder; -import io.fabric8.kubernetes.api.model.Service; -import io.fabric8.kubernetes.api.model.ServiceBuilder; +import io.fabric8.kubernetes.api.model.ReplicationController; +import io.fabric8.kubernetes.api.model.ReplicationControllerBuilder; import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient; import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer; import io.fabric8.openshift.api.model.Route; import io.fabric8.openshift.api.model.RouteBuilder; import io.fabric8.openshift.client.OpenShiftClient; import org.eclipse.jkube.kit.common.util.UserConfigurationCompare; -import org.eclipse.jkube.kit.config.service.PatchService; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -50,55 +46,25 @@ void setUp() { @Test void resourcePatching() { - Service oldService = new ServiceBuilder() - .withNewMetadata().withName("service1").endMetadata() + ReplicationController old = new ReplicationControllerBuilder() + .withNewMetadata().withName("resource").endMetadata() .withNewSpec() - .withClusterIP("192.168.1.3") .withSelector(Collections.singletonMap("app", "MyApp")) - .addNewPort() - .withProtocol("TCP") - .withTargetPort(new IntOrString("9376")) - .withPort(80) - .endPort() .endSpec() .build(); - Service newService = new ServiceBuilder() - .withNewMetadata().withName("service1").addToAnnotations(Collections.singletonMap("app", "org.eclipse.jkube")).endMetadata() - .withSpec(oldService.getSpec()) + ReplicationController newResource = new ReplicationControllerBuilder() + .withNewMetadata().withName("resource").addToAnnotations(Collections.singletonMap("app", "org.eclipse.jkube")).endMetadata() + .withSpec(old.getSpec()) .build(); - mockServer.expect().get().withPath("/api/v1/namespaces/test/services/service1").andReturn(200, oldService).always(); - mockServer.expect().patch().withPath("/api/v1/namespaces/test/services/service1").andReturn(200, new ServiceBuilder().withMetadata(newService.getMetadata()).withSpec(oldService.getSpec()).build()).once(); + mockServer.expect().get().withPath("/api/v1/namespaces/test/replicationcontrollers/resource") + .andReturn(200, old).always(); + mockServer.expect().patch().withPath("/api/v1/namespaces/test/replicationcontrollers/resource") + .andReturn(200, new ReplicationControllerBuilder(newResource).build()).once(); - Service patchedService = patchService.compareAndPatchEntity("test", newService, oldService); + ReplicationController patchedService = patchService.compareAndPatchEntity("test", old, newResource); - assertThat(UserConfigurationCompare.configEqual(patchedService.getMetadata(), newService.getMetadata())).isTrue(); - } - - @Test - void secretPatching() { - Secret oldSecret = new SecretBuilder() - .withNewMetadata().withName("secret").endMetadata() - .addToData("test", "dGVzdA==") - .build(); - Secret newSecret = new SecretBuilder() - .withNewMetadata().withName("secret").endMetadata() - .addToStringData("test", "test") - .build(); - WebServerEventCollector collector = new WebServerEventCollector(); - mockServer.expect().get().withPath("/api/v1/namespaces/test/secrets/secret") - .andReply(collector.record("get-secret").andReturn(200, oldSecret)).always(); - mockServer.expect().patch().withPath("/api/v1/namespaces/test/secrets/secret") - .andReply(collector.record("patch-secret") - .andReturn(200, new SecretBuilder().withMetadata(newSecret.getMetadata()) - .addToStringData(oldSecret.getData()).build())).once(); - - patchService.compareAndPatchEntity("test", newSecret, oldSecret); - collector.assertEventsRecordedInOrder("get-secret", "get-secret", "patch-secret"); - // Due to recent patch related improvements in KubernetesClient now edit call requires 2 GET requests - // for resource from server instead of 3 GET requests. - assertThat(collector.getBodies().get(2)) - .isEqualTo("[{\"op\":\"remove\",\"path\":\"/data\"},{\"op\":\"add\",\"path\":\"/stringData\",\"value\":{\"test\":\"test\"}}]"); + assertThat(UserConfigurationCompare.configEqual(patchedService.getMetadata(), newResource.getMetadata())).isTrue(); } @Test From 552d5e9aeb56f2515e321d0c8753fb97da2b39e5 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Fri, 14 Jul 2023 11:51:07 +0200 Subject: [PATCH 36/65] quickstarts: bootstrapped an Apache Camel 3 + Karaf example We have now 2 quickstarts to demonstrate the usage of Apache Camel and Apache Karaf with both Apache Camel 2 and Apache Camel 3 Signed-off-by: Marc Nuri --- quickstarts/maven/karaf-camel-2-log/README.md | 61 +++++++ .../pom.xml | 10 +- .../quickstart/karaf/OrderGenerator.java | 0 .../OSGI-INF/blueprint/camel-log.xml | 0 .../assembly/etc/org.ops4j.pax.logging.cfg | 0 .../src/main/resources/data/order1.xml | 0 .../src/main/resources/data/order2.xml | 0 .../src/main/resources/data/order3.xml | 0 .../src/main/resources/data/order4.xml | 0 .../src/main/resources/data/order5.xml | 0 .../README.md | 4 +- quickstarts/maven/karaf-camel-3-log/pom.xml | 164 ++++++++++++++++++ .../quickstart/karaf/OrderGenerator.java | 34 ++++ .../OSGI-INF/blueprint/camel-log.xml | 72 ++++++++ .../assembly/etc/org.ops4j.pax.logging.cfg | 34 ++++ .../src/main/resources/data/order1.xml | 41 +++++ .../src/main/resources/data/order2.xml | 41 +++++ .../src/main/resources/data/order3.xml | 41 +++++ .../src/main/resources/data/order4.xml | 41 +++++ .../src/main/resources/data/order5.xml | 41 +++++ 20 files changed, 577 insertions(+), 7 deletions(-) create mode 100644 quickstarts/maven/karaf-camel-2-log/README.md rename quickstarts/maven/{karaf-camel-log => karaf-camel-2-log}/pom.xml (93%) rename quickstarts/maven/{karaf-camel-log => karaf-camel-2-log}/src/main/java/org/eclipse/jkube/quickstart/karaf/OrderGenerator.java (100%) rename quickstarts/maven/{karaf-camel-log => karaf-camel-2-log}/src/main/resources/OSGI-INF/blueprint/camel-log.xml (100%) rename quickstarts/maven/{karaf-camel-log => karaf-camel-2-log}/src/main/resources/assembly/etc/org.ops4j.pax.logging.cfg (100%) rename quickstarts/maven/{karaf-camel-log => karaf-camel-2-log}/src/main/resources/data/order1.xml (100%) rename quickstarts/maven/{karaf-camel-log => karaf-camel-2-log}/src/main/resources/data/order2.xml (100%) rename quickstarts/maven/{karaf-camel-log => karaf-camel-2-log}/src/main/resources/data/order3.xml (100%) rename quickstarts/maven/{karaf-camel-log => karaf-camel-2-log}/src/main/resources/data/order4.xml (100%) rename quickstarts/maven/{karaf-camel-log => karaf-camel-2-log}/src/main/resources/data/order5.xml (100%) rename quickstarts/maven/{karaf-camel-log => karaf-camel-3-log}/README.md (93%) create mode 100644 quickstarts/maven/karaf-camel-3-log/pom.xml create mode 100644 quickstarts/maven/karaf-camel-3-log/src/main/java/org/eclipse/jkube/quickstart/karaf/OrderGenerator.java create mode 100644 quickstarts/maven/karaf-camel-3-log/src/main/resources/OSGI-INF/blueprint/camel-log.xml create mode 100644 quickstarts/maven/karaf-camel-3-log/src/main/resources/assembly/etc/org.ops4j.pax.logging.cfg create mode 100644 quickstarts/maven/karaf-camel-3-log/src/main/resources/data/order1.xml create mode 100644 quickstarts/maven/karaf-camel-3-log/src/main/resources/data/order2.xml create mode 100644 quickstarts/maven/karaf-camel-3-log/src/main/resources/data/order3.xml create mode 100644 quickstarts/maven/karaf-camel-3-log/src/main/resources/data/order4.xml create mode 100644 quickstarts/maven/karaf-camel-3-log/src/main/resources/data/order5.xml diff --git a/quickstarts/maven/karaf-camel-2-log/README.md b/quickstarts/maven/karaf-camel-2-log/README.md new file mode 100644 index 0000000000..679b4fd194 --- /dev/null +++ b/quickstarts/maven/karaf-camel-2-log/README.md @@ -0,0 +1,61 @@ +--- +name: "Maven :: Karaf Camel 2 Log" +description: | + Simple Apache Camel 2 application on top of Apache Karaf that logs a series of messages to the Server log. + The application also generates and processes random orders using Camel routes. +--- +# Eclipse JKube Karaf Quickstart - Camel Log + +This quickstart shows a simple Apache Camel 2 application that logs a series of messages to the Server log and +generates and processes random orders. + +## Features + +### Camel Log + +A Camel route defined in [camel-log.xml](src/main/resources/OSGI-INF/blueprint/camel-log.xml) (``) +will log some greeting messages to the Server log every second. + +The format and contents of the log messages is controlled in [org.ops4j.pax.logging.cfg +](src/main/resources/assembly/etc/org.ops4j.pax.logging.cfg) (`log4j2.appender.hello.name=hello-stdout`). + + +### Order generation and processing + +Two Camel route defined in [camel-log.xml](src/main/resources/OSGI-INF/blueprint/camel-log.xml) +(`` & ``), generates and processes some fake orders +every 5 seconds. +- Orders will be generated in `${KARAF_HOME}/work/orders/input` +- Orders will be processed and moved to `${KARAF_HOME}/work/orders/processed` +- Both actions will be logged to the Server output using a different logger. + + +## Building + +The quickstart can be built with `mvn clean install`. + +This will generate an Apache Karaf assembly ready to be deployed or run locally ( `./target/assembly/bin/karaf run`). + +## Deploying to Kubernetes + +Make sure you have access to a K8s cluster. + +Deploy the application: +``` +mvn k8s:build k8s:resource k8s:apply +``` + +Once the process is finished, you can retrieve the logs with `mvn k8s:log`. This should print the log messages +from the previously described Camel routes. + +## Deploying to OpenShift + +Make sure you have access to an OpenShift cluster. + +Deploy the application: +``` +mvn oc:build oc:resource oc:apply +``` + +Once the process is finished, you can retrieve the logs with `mvn oc:log`. This should print the log messages +from the previously described Camel routes. diff --git a/quickstarts/maven/karaf-camel-log/pom.xml b/quickstarts/maven/karaf-camel-2-log/pom.xml similarity index 93% rename from quickstarts/maven/karaf-camel-log/pom.xml rename to quickstarts/maven/karaf-camel-2-log/pom.xml index 09ce9df463..7863dd1eda 100644 --- a/quickstarts/maven/karaf-camel-log/pom.xml +++ b/quickstarts/maven/karaf-camel-2-log/pom.xml @@ -19,13 +19,13 @@ 4.0.0 org.eclipse.jkube.quickstarts.maven - karaf-camel-log + karaf-camel-2-log 1.13.1 bundle - Eclipse JKube :: Quickstarts :: Maven :: Karaf Camel Log + Eclipse JKube :: Quickstarts :: Maven :: Karaf Camel 2 Log - Simple Apache Camel application on top of Apache Karaf that logs a series of messages to the Server log. + Simple Apache Camel 2 application on top of Apache Karaf that logs a series of messages to the Server log. The application also generates and processes random orders using Camel routes. @@ -33,8 +33,8 @@ 11 11 ${project.version} - 2.25.4 - 4.3.5 + 2.25.4 + 4.4.3 diff --git a/quickstarts/maven/karaf-camel-log/src/main/java/org/eclipse/jkube/quickstart/karaf/OrderGenerator.java b/quickstarts/maven/karaf-camel-2-log/src/main/java/org/eclipse/jkube/quickstart/karaf/OrderGenerator.java similarity index 100% rename from quickstarts/maven/karaf-camel-log/src/main/java/org/eclipse/jkube/quickstart/karaf/OrderGenerator.java rename to quickstarts/maven/karaf-camel-2-log/src/main/java/org/eclipse/jkube/quickstart/karaf/OrderGenerator.java diff --git a/quickstarts/maven/karaf-camel-log/src/main/resources/OSGI-INF/blueprint/camel-log.xml b/quickstarts/maven/karaf-camel-2-log/src/main/resources/OSGI-INF/blueprint/camel-log.xml similarity index 100% rename from quickstarts/maven/karaf-camel-log/src/main/resources/OSGI-INF/blueprint/camel-log.xml rename to quickstarts/maven/karaf-camel-2-log/src/main/resources/OSGI-INF/blueprint/camel-log.xml diff --git a/quickstarts/maven/karaf-camel-log/src/main/resources/assembly/etc/org.ops4j.pax.logging.cfg b/quickstarts/maven/karaf-camel-2-log/src/main/resources/assembly/etc/org.ops4j.pax.logging.cfg similarity index 100% rename from quickstarts/maven/karaf-camel-log/src/main/resources/assembly/etc/org.ops4j.pax.logging.cfg rename to quickstarts/maven/karaf-camel-2-log/src/main/resources/assembly/etc/org.ops4j.pax.logging.cfg diff --git a/quickstarts/maven/karaf-camel-log/src/main/resources/data/order1.xml b/quickstarts/maven/karaf-camel-2-log/src/main/resources/data/order1.xml similarity index 100% rename from quickstarts/maven/karaf-camel-log/src/main/resources/data/order1.xml rename to quickstarts/maven/karaf-camel-2-log/src/main/resources/data/order1.xml diff --git a/quickstarts/maven/karaf-camel-log/src/main/resources/data/order2.xml b/quickstarts/maven/karaf-camel-2-log/src/main/resources/data/order2.xml similarity index 100% rename from quickstarts/maven/karaf-camel-log/src/main/resources/data/order2.xml rename to quickstarts/maven/karaf-camel-2-log/src/main/resources/data/order2.xml diff --git a/quickstarts/maven/karaf-camel-log/src/main/resources/data/order3.xml b/quickstarts/maven/karaf-camel-2-log/src/main/resources/data/order3.xml similarity index 100% rename from quickstarts/maven/karaf-camel-log/src/main/resources/data/order3.xml rename to quickstarts/maven/karaf-camel-2-log/src/main/resources/data/order3.xml diff --git a/quickstarts/maven/karaf-camel-log/src/main/resources/data/order4.xml b/quickstarts/maven/karaf-camel-2-log/src/main/resources/data/order4.xml similarity index 100% rename from quickstarts/maven/karaf-camel-log/src/main/resources/data/order4.xml rename to quickstarts/maven/karaf-camel-2-log/src/main/resources/data/order4.xml diff --git a/quickstarts/maven/karaf-camel-log/src/main/resources/data/order5.xml b/quickstarts/maven/karaf-camel-2-log/src/main/resources/data/order5.xml similarity index 100% rename from quickstarts/maven/karaf-camel-log/src/main/resources/data/order5.xml rename to quickstarts/maven/karaf-camel-2-log/src/main/resources/data/order5.xml diff --git a/quickstarts/maven/karaf-camel-log/README.md b/quickstarts/maven/karaf-camel-3-log/README.md similarity index 93% rename from quickstarts/maven/karaf-camel-log/README.md rename to quickstarts/maven/karaf-camel-3-log/README.md index 07d561c2c2..fa6a1efbd1 100644 --- a/quickstarts/maven/karaf-camel-log/README.md +++ b/quickstarts/maven/karaf-camel-3-log/README.md @@ -1,12 +1,12 @@ --- -name: "Maven :: Karaf Camel Log" +name: "Maven :: Karaf Camel 3 Log" description: | Simple Apache Camel application on top of Apache Karaf that logs a series of messages to the Server log. The application also generates and processes random orders using Camel routes. --- # Eclipse JKube Karaf Quickstart - Camel Log -This quickstart shows a simple Apache Camel application that logs a series of messages to the Server log and +This quickstart shows a simple Apache Camel 3 application that logs a series of messages to the Server log and generates and processes random orders. ## Features diff --git a/quickstarts/maven/karaf-camel-3-log/pom.xml b/quickstarts/maven/karaf-camel-3-log/pom.xml new file mode 100644 index 0000000000..23b0c35681 --- /dev/null +++ b/quickstarts/maven/karaf-camel-3-log/pom.xml @@ -0,0 +1,164 @@ + + + + 4.0.0 + + org.eclipse.jkube.quickstarts.maven + karaf-camel-3-log + 1.13.1 + bundle + Eclipse JKube :: Quickstarts :: Maven :: Karaf Camel 3 Log + + + Simple Apache Camel 3 application on top of Apache Karaf that logs a series of messages to the Server log. + The application also generates and processes random orders using Camel routes. + + + + 11 + 11 + ${project.version} + 3.21.0 + 4.4.3 + + + + + org.apache.camel.karaf + apache-camel + ${camel.version} + features + xml + + + org.apache.camel.karaf + camel-core-osgi + ${camel.version} + + + org.apache.karaf.features + framework + ${karaf.version} + kar + + + org.apache.karaf.features + framework + ${karaf.version} + features + xml + runtime + + + org.apache.karaf.features + standard + ${karaf.version} + features + xml + + + + + + + src/main/resources + true + + + + + org.apache.felix + maven-bundle-plugin + true + + + + * + + + + + + + + org.apache.maven.plugins + maven-install-plugin + + + default-install + + install + + install + + + + + org.apache.karaf.tooling + karaf-maven-plugin + ${karaf.version} + true + + + karaf-assembly + + assembly + + install + + + + 11 + framework + true + false + false + + framework + jaas + log + shell + bundle + feature + system + scr + management + identity + aries-blueprint + camel-core + camel-blueprint + + + mvn:${project.groupId}/${project.artifactId}/${project.version};start-level=80 + + + + + org.eclipse.jkube + kubernetes-maven-plugin + ${jkube.version} + + + org.eclipse.jkube + openshift-maven-plugin + ${jkube.version} + + + + + diff --git a/quickstarts/maven/karaf-camel-3-log/src/main/java/org/eclipse/jkube/quickstart/karaf/OrderGenerator.java b/quickstarts/maven/karaf-camel-3-log/src/main/java/org/eclipse/jkube/quickstart/karaf/OrderGenerator.java new file mode 100644 index 0000000000..29b4c0dc2f --- /dev/null +++ b/quickstarts/maven/karaf-camel-3-log/src/main/java/org/eclipse/jkube/quickstart/karaf/OrderGenerator.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.quickstart.karaf; + +import org.apache.camel.CamelContext; + +import java.io.InputStream; +import java.util.Random; + +public class OrderGenerator { + private int count = 1; + private Random random = new Random(); + + public InputStream generateOrder(CamelContext camelContext) { + final int number = random.nextInt(5) + 1; + final String orderSource = String.format("data/order%s.xml", number); + return camelContext.getClassResolver().loadResourceAsStream(orderSource); + } + + public String generateFileName() { + return String.format("order%s.xml", count++); + } +} diff --git a/quickstarts/maven/karaf-camel-3-log/src/main/resources/OSGI-INF/blueprint/camel-log.xml b/quickstarts/maven/karaf-camel-3-log/src/main/resources/OSGI-INF/blueprint/camel-log.xml new file mode 100644 index 0000000000..a7b0b7f06c --- /dev/null +++ b/quickstarts/maven/karaf-camel-3-log/src/main/resources/OSGI-INF/blueprint/camel-log.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Hello from Camel! + + + + + + diff --git a/quickstarts/maven/karaf-camel-3-log/src/main/resources/assembly/etc/org.ops4j.pax.logging.cfg b/quickstarts/maven/karaf-camel-3-log/src/main/resources/assembly/etc/org.ops4j.pax.logging.cfg new file mode 100644 index 0000000000..e04c936fa2 --- /dev/null +++ b/quickstarts/maven/karaf-camel-3-log/src/main/resources/assembly/etc/org.ops4j.pax.logging.cfg @@ -0,0 +1,34 @@ +# +# Copyright (c) 2019 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at: +# +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Red Hat, Inc. - initial API and implementation +# + +log4j2.rootLogger.level=WARN +log4j2.rootLogger.appenderRef.Console.ref=global-stdout + +log4j2.logger.jkube.name=org.eclipse.jkube.quickstart.karaf +log4j2.logger.jkube.level=INFO + +log4j2.logger.jkube-hello.name=org.eclipse.jkube.quickstart.karaf.hello +log4j2.logger.jkube-hello.level=INFO +log4j2.logger.jkube-hello.additivity=false +log4j2.logger.jkube-hello.appenderRef.hello.ref=hello-stdout + +log4j2.appender.console.name=global-stdout +log4j2.appender.console.type=Console +log4j2.appender.console.layout.type=PatternLayout +log4j2.appender.console.layout.pattern=%d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n + +log4j2.appender.hello.name=hello-stdout +log4j2.appender.hello.type=Console +log4j2.appender.hello.layout.type=PatternLayout +log4j2.appender.hello.layout.pattern=>>> %highlight{%m}%n diff --git a/quickstarts/maven/karaf-camel-3-log/src/main/resources/data/order1.xml b/quickstarts/maven/karaf-camel-3-log/src/main/resources/data/order1.xml new file mode 100644 index 0000000000..1bd608c1f7 --- /dev/null +++ b/quickstarts/maven/karaf-camel-3-log/src/main/resources/data/order1.xml @@ -0,0 +1,41 @@ + + + + + + Antwerp Zoo + Antwerp + BE + + + 1985-10-25 + + + +
+ Bactrian Camel +
+ 1 +
+ +
+ Dromedary (Arabian Camel) +
+ 10 +
+
+
diff --git a/quickstarts/maven/karaf-camel-3-log/src/main/resources/data/order2.xml b/quickstarts/maven/karaf-camel-3-log/src/main/resources/data/order2.xml new file mode 100644 index 0000000000..f1745418e9 --- /dev/null +++ b/quickstarts/maven/karaf-camel-3-log/src/main/resources/data/order2.xml @@ -0,0 +1,41 @@ + + + + + + Bristol Zoo Gardens + Bristol + UK + + + 2015-10-21 + + + +
+ Wild bactrian camel +
+ 2 +
+ +
+ Camel +
+ 200 +
+
+
diff --git a/quickstarts/maven/karaf-camel-3-log/src/main/resources/data/order3.xml b/quickstarts/maven/karaf-camel-3-log/src/main/resources/data/order3.xml new file mode 100644 index 0000000000..8f8d895431 --- /dev/null +++ b/quickstarts/maven/karaf-camel-3-log/src/main/resources/data/order3.xml @@ -0,0 +1,41 @@ + + + + + + Columbus Zoo and Aquarium + Columbus + US + + + 1955-11-05 + + + +
+ Camel +
+ 100 +
+ +
+ Llama +
+ 1 +
+
+
diff --git a/quickstarts/maven/karaf-camel-3-log/src/main/resources/data/order4.xml b/quickstarts/maven/karaf-camel-3-log/src/main/resources/data/order4.xml new file mode 100644 index 0000000000..d7cc6e37d4 --- /dev/null +++ b/quickstarts/maven/karaf-camel-3-log/src/main/resources/data/order4.xml @@ -0,0 +1,41 @@ + + + + + + Dartmoor Zoological Park + Devon + UK + + + 1985-10-26 + + + +
+ Horse +
+ 1 +
+ +
+ Camel +
+ 337 +
+
+
diff --git a/quickstarts/maven/karaf-camel-3-log/src/main/resources/data/order5.xml b/quickstarts/maven/karaf-camel-3-log/src/main/resources/data/order5.xml new file mode 100644 index 0000000000..2cd7754170 --- /dev/null +++ b/quickstarts/maven/karaf-camel-3-log/src/main/resources/data/order5.xml @@ -0,0 +1,41 @@ + + + + + + Erie Zoo + Erie + US + + + 1955-11-12 + + + +
+ Dromedary (Arabian Camel) +
+ 13 +
+ +
+ Camel +
+ 37 +
+
+
From 5a9b0ff5b243dd2d9fa1a9de921c35cfe7b70ffd Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Mon, 17 Jul 2023 12:46:00 +0200 Subject: [PATCH 37/65] feat: MappingConfig supports defining apiVersion Signed-off-by: Marc Nuri --- .../it/fragments-custom-mapping/build.gradle | 5 + .../expected/kubernetes.yml | 18 ++++ .../expected/openshift.yml | 18 ++++ .../src/main/jkube/first-fl.yaml | 0 .../src/main/jkube/full.yaml | 2 + .../kit/config/resource/MappingConfig.java | 4 +- .../config/resource/MappingConfigTest.java | 36 ++++++- .../src/test/resources/mapping-config.json | 3 +- .../api/util/KubernetesResourceFragments.java | 95 +++++++++---------- .../util/KubernetesResourceFragmentsTest.java | 66 +++++++++---- .../custom2.yaml | 17 ++++ .../custom3.yaml | 17 ++++ .../hello-c1.yaml | 16 ++++ .../hello-c3.yaml | 13 +++ .../provided-api-version-c2.yaml | 16 ++++ .../generic/DependencyEnricherTest.java | 2 - .../service/DefaultResourceService.java | 2 - 17 files changed, 249 insertions(+), 81 deletions(-) create mode 100644 gradle-plugin/it/src/it/fragments-custom-mapping/src/main/jkube/first-fl.yaml create mode 100644 gradle-plugin/it/src/it/fragments-custom-mapping/src/main/jkube/full.yaml create mode 100644 jkube-kit/enricher/api/src/test/resources/kubernetes-resource-fragments/complete-directory-custom-mappings/custom2.yaml create mode 100644 jkube-kit/enricher/api/src/test/resources/kubernetes-resource-fragments/complete-directory-custom-mappings/custom3.yaml create mode 100644 jkube-kit/enricher/api/src/test/resources/kubernetes-resource-fragments/complete-directory-custom-mappings/hello-c1.yaml create mode 100644 jkube-kit/enricher/api/src/test/resources/kubernetes-resource-fragments/complete-directory-custom-mappings/hello-c3.yaml create mode 100644 jkube-kit/enricher/api/src/test/resources/kubernetes-resource-fragments/complete-directory-custom-mappings/provided-api-version-c2.yaml diff --git a/gradle-plugin/it/src/it/fragments-custom-mapping/build.gradle b/gradle-plugin/it/src/it/fragments-custom-mapping/build.gradle index c006d27f08..4a24a50e30 100644 --- a/gradle-plugin/it/src/it/fragments-custom-mapping/build.gradle +++ b/gradle-plugin/it/src/it/fragments-custom-mapping/build.gradle @@ -19,6 +19,11 @@ def extensionConfig = { kind = 'Template' filenameTypes = 'my_template, mtpl' } + mapping { + kind = 'Full' + apiVersion = 'full.example.com/v1' + filenameTypes = 'full, fl' + } } images { image { diff --git a/gradle-plugin/it/src/it/fragments-custom-mapping/expected/kubernetes.yml b/gradle-plugin/it/src/it/fragments-custom-mapping/expected/kubernetes.yml index 678cff76c7..e40e9878df 100644 --- a/gradle-plugin/it/src/it/fragments-custom-mapping/expected/kubernetes.yml +++ b/gradle-plugin/it/src/it/fragments-custom-mapping/expected/kubernetes.yml @@ -51,6 +51,15 @@ items: name: repository-fragments-custom-mapping securityContext: privileged: false + - apiVersion: full.example.com/v1 + kind: Full + metadata: + labels: + app: fragments-custom-mapping + provider: jkube + version: "@ignore@" + group: org.eclipse.jkube.integration.tests.gradle + name: first - apiVersion: my.unique.crd/v1alfa1 kind: Template metadata: @@ -60,6 +69,15 @@ items: version: "@ignore@" group: org.eclipse.jkube.integration.tests.gradle name: first + - apiVersion: full.example.com/v1 + kind: Full + metadata: + labels: + app: fragments-custom-mapping + provider: jkube + version: "@ignore@" + group: org.eclipse.jkube.integration.tests.gradle + name: second - apiVersion: my.unique.crd/v1alfa1 kind: Template metadata: diff --git a/gradle-plugin/it/src/it/fragments-custom-mapping/expected/openshift.yml b/gradle-plugin/it/src/it/fragments-custom-mapping/expected/openshift.yml index d9df0755d2..ee8fc5b320 100644 --- a/gradle-plugin/it/src/it/fragments-custom-mapping/expected/openshift.yml +++ b/gradle-plugin/it/src/it/fragments-custom-mapping/expected/openshift.yml @@ -62,6 +62,15 @@ items: kind: ImageStreamTag name: fragments-custom-mapping:latest type: ImageChange + - apiVersion: full.example.com/v1 + kind: Full + metadata: + labels: + app: fragments-custom-mapping + provider: jkube + version: "@ignore@" + group: org.eclipse.jkube.integration.tests.gradle + name: first - apiVersion: my.unique.crd/v1alfa1 kind: Template metadata: @@ -71,6 +80,15 @@ items: version: "@ignore@" group: org.eclipse.jkube.integration.tests.gradle name: first + - apiVersion: full.example.com/v1 + kind: Full + metadata: + labels: + app: fragments-custom-mapping + provider: jkube + version: "@ignore@" + group: org.eclipse.jkube.integration.tests.gradle + name: second - apiVersion: my.unique.crd/v1alfa1 kind: Template metadata: diff --git a/gradle-plugin/it/src/it/fragments-custom-mapping/src/main/jkube/first-fl.yaml b/gradle-plugin/it/src/it/fragments-custom-mapping/src/main/jkube/first-fl.yaml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gradle-plugin/it/src/it/fragments-custom-mapping/src/main/jkube/full.yaml b/gradle-plugin/it/src/it/fragments-custom-mapping/src/main/jkube/full.yaml new file mode 100644 index 0000000000..c1412a4f88 --- /dev/null +++ b/gradle-plugin/it/src/it/fragments-custom-mapping/src/main/jkube/full.yaml @@ -0,0 +1,2 @@ +metadata: + name: second diff --git a/jkube-kit/config/resource/src/main/java/org/eclipse/jkube/kit/config/resource/MappingConfig.java b/jkube-kit/config/resource/src/main/java/org/eclipse/jkube/kit/config/resource/MappingConfig.java index 8d2b4a6f31..933ae66d0c 100644 --- a/jkube-kit/config/resource/src/main/java/org/eclipse/jkube/kit/config/resource/MappingConfig.java +++ b/jkube-kit/config/resource/src/main/java/org/eclipse/jkube/kit/config/resource/MappingConfig.java @@ -27,7 +27,7 @@ public class MappingConfig { private String kind; - + private String apiVersion; private String filenameTypes; public String[] getFilenamesAsArray() { @@ -38,6 +38,6 @@ public String[] getFilenamesAsArray() { } public boolean isValid() { - return kind != null && filenameTypes != null && filenameTypes.length() > 0; + return kind != null && filenameTypes != null && filenameTypes.length() > 0; } } diff --git a/jkube-kit/config/resource/src/test/java/org/eclipse/jkube/kit/config/resource/MappingConfigTest.java b/jkube-kit/config/resource/src/test/java/org/eclipse/jkube/kit/config/resource/MappingConfigTest.java index 21e61070c1..2d5409d0c9 100644 --- a/jkube-kit/config/resource/src/test/java/org/eclipse/jkube/kit/config/resource/MappingConfigTest.java +++ b/jkube-kit/config/resource/src/test/java/org/eclipse/jkube/kit/config/resource/MappingConfigTest.java @@ -32,6 +32,7 @@ void rawDeserialization() throws IOException { // Then assertThat(result) .hasFieldOrPropertyWithValue("kind", "CronTab") + .hasFieldOrPropertyWithValue("apiVersion", "custom-cron-tab.example.com/v1") .hasFieldOrPropertyWithValue("filenameTypes", "crontab,cr"); } @@ -54,29 +55,54 @@ void getFilenamesAsArray_whenTypesPresent_thenReturnsArray() { } @Test - void isValid_withInvalidObject_shouldReturnFalse() { + void isValid_withMissingKind_shouldReturnFalse() { // Given MappingConfig config = MappingConfig.builder() - .build(); - + .apiVersion("custom-cron-tab.example.com/v1") + .filenameTypes("crontab,cr") + .build(); // When boolean result = config.isValid(); + // Then + assertThat(result).isFalse(); + } + @Test + void isValid_withMissingFileNameTypes_shouldReturnFalse() { + // Given + MappingConfig config = MappingConfig.builder() + .apiVersion("custom-cron-tab.example.com/v1") + .kind("Foo") + .build(); + // When + boolean result = config.isValid(); // Then assertThat(result).isFalse(); } @Test - void isValid_withValidObject_shouldReturnTrue() { + void isValid_withKindAndFileName_shouldReturnTrue() { // Given MappingConfig config = MappingConfig.builder() .kind("Foo") .filenameTypes("foos") .build(); - // When boolean result = config.isValid(); + // Then + assertThat(result).isTrue(); + } + @Test + void isValid_withKindAndApiVersionAndFileName_shouldReturnTrue() { + // Given + MappingConfig config = MappingConfig.builder() + .kind("Foo") + .apiVersion("custom-cron-tab.example.com/v1") + .filenameTypes("foos") + .build(); + // When + boolean result = config.isValid(); // Then assertThat(result).isTrue(); } diff --git a/jkube-kit/config/resource/src/test/resources/mapping-config.json b/jkube-kit/config/resource/src/test/resources/mapping-config.json index 38d8102971..ce1d09d3b0 100644 --- a/jkube-kit/config/resource/src/test/resources/mapping-config.json +++ b/jkube-kit/config/resource/src/test/resources/mapping-config.json @@ -1,4 +1,5 @@ { "kind": "CronTab", + "apiVersion": "custom-cron-tab.example.com/v1", "filenameTypes": "crontab,cr" -} \ No newline at end of file +} diff --git a/jkube-kit/enricher/api/src/main/java/org/eclipse/jkube/kit/enricher/api/util/KubernetesResourceFragments.java b/jkube-kit/enricher/api/src/main/java/org/eclipse/jkube/kit/enricher/api/util/KubernetesResourceFragments.java index 13b77da248..638147736f 100644 --- a/jkube-kit/enricher/api/src/main/java/org/eclipse/jkube/kit/enricher/api/util/KubernetesResourceFragments.java +++ b/jkube-kit/enricher/api/src/main/java/org/eclipse/jkube/kit/enricher/api/util/KubernetesResourceFragments.java @@ -20,11 +20,9 @@ import org.eclipse.jkube.kit.common.util.KindFilenameMapperUtil; import org.eclipse.jkube.kit.common.util.Serialization; import org.eclipse.jkube.kit.config.resource.MappingConfig; -import org.eclipse.jkube.kit.config.resource.ResourceVersioning; import java.io.File; import java.io.IOException; -import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -32,27 +30,39 @@ import java.util.Map; import java.util.Optional; import java.util.Set; -import java.util.function.BiConsumer; +import java.util.function.Consumer; import java.util.regex.Matcher; import static org.eclipse.jkube.kit.common.util.KubernetesHelper.FILENAME_PATTERN; +import static org.eclipse.jkube.kit.enricher.api.util.KubernetesResourceUtil.DEFAULT_RESOURCE_VERSIONING; public class KubernetesResourceFragments { - private static final Map FILENAME_TO_KIND_MAPPER = new HashMap<>(); + private static final Map FILENAME_TO_MAPPING_CONFIG_MAPPER = new HashMap<>(); private static final Map KIND_TO_FILENAME_MAPPER = new HashMap<>(); - private static final BiConsumer> KIND_FILENAME_MAPPER_UPDATER = (kind, fileNameTypes) -> { + private static final Consumer KIND_FILENAME_MAPPER_UPDATER = mappingConfig -> { + if (!mappingConfig.isValid()) { + throw new IllegalArgumentException(String.format("Invalid mapping for Kind %s and Filename Types %s", + mappingConfig.getKind(), mappingConfig.getFilenameTypes())); + } + final String[] fileNameTypes = mappingConfig.getFilenamesAsArray(); for (String filenameType : fileNameTypes) { - FILENAME_TO_KIND_MAPPER.put(filenameType, kind); + FILENAME_TO_MAPPING_CONFIG_MAPPER.put(filenameType.toLowerCase(), mappingConfig); } // In previous version, last one wins, so we do the same. - KIND_TO_FILENAME_MAPPER.put(kind, fileNameTypes.get(fileNameTypes.size() - 1)); + KIND_TO_FILENAME_MAPPER.put(mappingConfig.getKind(), fileNameTypes[fileNameTypes.length- 1]); }; static final Set EXCLUDED_RESOURCE_FILENAME_SUFFIXES = new HashSet<>(); static { EXCLUDED_RESOURCE_FILENAME_SUFFIXES.add(".helm.yaml"); EXCLUDED_RESOURCE_FILENAME_SUFFIXES.add(".helm.yml"); - KindFilenameMapperUtil.loadMappings().forEach(KIND_FILENAME_MAPPER_UPDATER); + KindFilenameMapperUtil.loadMappings() + .entrySet().stream() + .map(mc -> MappingConfig.builder() + .kind(mc.getKey()) + .filenameTypes(String.join(",", mc.getValue())) + .build()) + .forEach(KIND_FILENAME_MAPPER_UPDATER); } private KubernetesResourceFragments() { @@ -64,16 +74,7 @@ private KubernetesResourceFragments() { */ public static void updateKindFilenameMappings(List mappings) { if (mappings != null) { - final Map> mappingKindFilename = new HashMap<>(); - for (MappingConfig mappingConfig : mappings) { - if (mappingConfig.isValid()) { - mappingKindFilename.put(mappingConfig.getKind(), Arrays.asList(mappingConfig.getFilenamesAsArray())); - } else { - throw new IllegalArgumentException(String.format("Invalid mapping for Kind %s and Filename Types %s", - mappingConfig.getKind(), mappingConfig.getFilenameTypes())); - } - } - mappingKindFilename.forEach(KIND_FILENAME_MAPPER_UPDATER); + mappings.forEach(KIND_FILENAME_MAPPER_UPDATER); } } @@ -82,27 +83,22 @@ public static String getNameWithSuffix(String name, String kind) { return String.format("%s-%s", name.replace(".", "_"), suffix != null ? suffix : "cr"); } - /** * Read all Kubernetes resource fragments from a directory and create a {@link KubernetesListBuilder} which * can be adapted later. * - * @param apiVersions the api versions to use * @param defaultName the default name to use when none is given * @param resourceFiles files to add. * @return the list builder * @throws IOException in case file is not found */ - public static KubernetesListBuilder readResourceFragmentsFrom( - ResourceVersioning apiVersions, String defaultName, File... resourceFiles) - throws IOException { - + public static KubernetesListBuilder readResourceFragmentsFrom(String defaultName, File... resourceFiles) throws IOException { final KubernetesListBuilder builder = new KubernetesListBuilder(); if (resourceFiles != null) { for (File file : resourceFiles) { if (EXCLUDED_RESOURCE_FILENAME_SUFFIXES.stream() .noneMatch(s -> file.getName().toLowerCase(Locale.ROOT).endsWith(s))) { - builder.addToItems(getResource(apiVersions, file, defaultName)); + builder.addToItems(getResource(file, defaultName)); } } } @@ -119,15 +115,20 @@ public static KubernetesListBuilder readResourceFragmentsFrom( *
  • apiVersion - API version (given as parameter to this method)
  • * * - * @param apiVersions the API versions to add if not given. * @param file file to read. * @param appName resource name specifying resources belonging to this application * @return HasMetadata object for resource * @throws IOException in case file loading is failed */ - private static HasMetadata getResource( - ResourceVersioning apiVersions, File file, String appName) throws IOException { - final Map fragment = readAndEnrichFragment(apiVersions, file, appName); + private static HasMetadata getResource(File file, String appName) throws IOException { + final Map fragment = Optional.ofNullable(Serialization.unmarshal(file, new TypeReference>() {})) + .orElse(new HashMap<>()); + if (StringUtils.isBlank((String) fragment.get("apiVersion")) || + StringUtils.isBlank((String) fragment.get("kind")) || + StringUtils.isBlank((String) getOrInitMetadata(fragment).get("name"))) { + // Fragment is incomplete let's enrich the missing parts + enrichFragment(fragment, file, appName); + } try { return Serialization.convertValue(fragment, HasMetadata.class); } catch (ClassCastException exp) { @@ -136,19 +137,9 @@ private static HasMetadata getResource( } // Read fragment and add default values - private static Map readAndEnrichFragment( - ResourceVersioning apiVersions, File file, String defaultName) throws IOException { - final Map fragment = Optional.ofNullable(Serialization.unmarshal(file, new TypeReference>() {})) - .orElse(new HashMap<>()); + private static void enrichFragment(Map fragment, File file, String defaultName) { final Map metadata = getOrInitMetadata(fragment); - // Fragment is complete let's skip any additional processing - if (StringUtils.isNotBlank((String) fragment.get("apiVersion")) && - StringUtils.isNotBlank((String) fragment.get("kind")) && - StringUtils.isNotBlank((String) metadata.get("name"))) { - return fragment; - } - // Infer values final Matcher matcher = FILENAME_PATTERN.matcher(file.getName()); if (!matcher.matches()) { @@ -160,17 +151,17 @@ private static Map readAndEnrichFragment( // Kind boolean nameFromFileIsKind = false; + final MappingConfig mcFromType = typeFromFile == null ? null : FILENAME_TO_MAPPING_CONFIG_MAPPER.get(typeFromFile.toLowerCase()); + final MappingConfig mcFromName = FILENAME_TO_MAPPING_CONFIG_MAPPER.get(nameFromFile.toLowerCase()); if (fragment.get("kind") == null) { - final String kindFromType = typeFromFile == null ? null : FILENAME_TO_KIND_MAPPER.get(typeFromFile.toLowerCase()); - final String kindFromName = FILENAME_TO_KIND_MAPPER.get(nameFromFile.toLowerCase()); - if (kindFromType == null && kindFromName == null) { + if (mcFromType == null && mcFromName == null) { throw new IllegalArgumentException( "No type given as part of the file name (e.g. 'app-rc.yml') " + "and no 'kind' defined in resource descriptor " + file.getName() + - ".\nMust be one of: " + StringUtils.join(FILENAME_TO_KIND_MAPPER.keySet().iterator(), ", ")); + ".\nMust be one of: " + StringUtils.join(FILENAME_TO_MAPPING_CONFIG_MAPPER.keySet().iterator(), ", ")); } - nameFromFileIsKind = kindFromType == null; - fragment.put("kind", nameFromFileIsKind ? kindFromName : kindFromType); + nameFromFileIsKind = mcFromType == null; + fragment.put("kind", nameFromFileIsKind ? mcFromName.getKind() : mcFromType.getKind()); } // Name @@ -178,9 +169,15 @@ private static Map readAndEnrichFragment( nameFromFile : defaultName); // ApiVersion - fragment.putIfAbsent("apiVersion", apiVersions.getForKind((String)fragment.get("kind"))); - - return fragment; + final String apiVersion; + if (mcFromName != null && mcFromName.getApiVersion() != null) { + apiVersion = mcFromName.getApiVersion(); + } else if (mcFromType != null && mcFromType.getApiVersion() != null) { + apiVersion = mcFromType.getApiVersion(); + } else { + apiVersion = DEFAULT_RESOURCE_VERSIONING.getForKind((String)fragment.get("kind")); + } + fragment.putIfAbsent("apiVersion", apiVersion); } private static Map getOrInitMetadata(Map fragment) { diff --git a/jkube-kit/enricher/api/src/test/java/org/eclipse/jkube/kit/enricher/api/util/KubernetesResourceFragmentsTest.java b/jkube-kit/enricher/api/src/test/java/org/eclipse/jkube/kit/enricher/api/util/KubernetesResourceFragmentsTest.java index d044c48676..38435ef9e3 100644 --- a/jkube-kit/enricher/api/src/test/java/org/eclipse/jkube/kit/enricher/api/util/KubernetesResourceFragmentsTest.java +++ b/jkube-kit/enricher/api/src/test/java/org/eclipse/jkube/kit/enricher/api/util/KubernetesResourceFragmentsTest.java @@ -36,6 +36,7 @@ import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.nio.file.Path; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Objects; @@ -46,7 +47,6 @@ import static org.assertj.core.api.Assertions.tuple; import static org.eclipse.jkube.kit.enricher.api.util.KubernetesResourceFragments.getNameWithSuffix; import static org.eclipse.jkube.kit.enricher.api.util.KubernetesResourceFragments.readResourceFragmentsFrom; -import static org.eclipse.jkube.kit.enricher.api.util.KubernetesResourceUtil.DEFAULT_RESOURCE_VERSIONING; public class KubernetesResourceFragmentsTest { @@ -87,7 +87,7 @@ void withNonexistentMappingConfigs_thenShouldAddMappings(@TempDir Path tempDir) KubernetesResourceFragments.updateKindFilenameMappings(mappingConfigs); // Then assertThat(getNameWithSuffix("the-foo-tab", "FooTab")).isEqualTo("the-foo-tab-ft"); - assertThat(readResourceFragmentsFrom(DEFAULT_RESOURCE_VERSIONING, "app", fooTabYaml).buildItems()) + assertThat(readResourceFragmentsFrom("app", fooTabYaml).buildItems()) .singleElement() .hasFieldOrPropertyWithValue("kind", "FooTab"); } @@ -135,7 +135,7 @@ class ReadResourceFragmentsFrom { void withValidDirectory_shouldReadAllFragments() throws IOException { // When final KubernetesListBuilder result = KubernetesResourceFragments.readResourceFragmentsFrom( - DEFAULT_RESOURCE_VERSIONING, "pong", new File(fragmentsDir, "complete-directory") + "pong", new File(fragmentsDir, "complete-directory") .listFiles()); // Then assertThat(result.build().getItems()) @@ -148,6 +148,32 @@ void withValidDirectory_shouldReadAllFragments() throws IOException { ); } + @Test + @DisplayName("with valid directory and custom mappings, should read all files in the directory") + void withValidDirectoryAndCustomMappings_shouldReadAllFragments() throws IOException { + // Given + KubernetesResourceFragments.updateKindFilenameMappings(Arrays.asList( + MappingConfig.builder().kind("CustomOne").filenameTypes("c1").build(), + MappingConfig.builder().kind("CustomTwo").filenameTypes("c2,custom2").build(), + MappingConfig.builder().kind("CustomThree").apiVersion("custom.example.com/v1").filenameTypes("c3,custom3").build() + )); + // When + final KubernetesListBuilder result = KubernetesResourceFragments.readResourceFragmentsFrom( + "pong", new File(fragmentsDir, "complete-directory-custom-mappings") + .listFiles()); + // Then + assertThat(result.build().getItems()) + .hasSize(5) + .extracting("class", "apiVersion", "kind", "metadata.name") + .containsExactlyInAnyOrder( + tuple(GenericKubernetesResource.class, "v1", "CustomOne", "hello"), + tuple(GenericKubernetesResource.class, "v1", "CustomTwo", "the-custom-2"), + tuple(GenericKubernetesResource.class, "provided/v1alpha1", "CustomTwo", "provided-api-version"), + tuple(GenericKubernetesResource.class, "custom.example.com/v1", "CustomThree", "hello"), + tuple(GenericKubernetesResource.class, "custom.example.com/v1", "CustomThree", "the-custom-3") + ); + } + @Test @DisplayName("with directory containing excluded files, should read only the applicable files") void withExcludedFile_shouldNotIncludeExcludedFile(@TempDir Path resourceDir) throws IOException { @@ -162,7 +188,7 @@ void withExcludedFile_shouldNotIncludeExcludedFile(@TempDir Path resourceDir) th }; // When final KubernetesListBuilder result = KubernetesResourceFragments.readResourceFragmentsFrom( - DEFAULT_RESOURCE_VERSIONING, "pong", resourceFiles); + "pong", resourceFiles); // Then assertThat(result.buildItems()).hasSize(2) .extracting("additionalProperties.field") @@ -173,7 +199,7 @@ void withExcludedFile_shouldNotIncludeExcludedFile(@TempDir Path resourceDir) th void withYamlFileAndVersionKindNameFromFile_shouldReturnValidResource() throws IOException { // When final KubernetesListBuilder result = KubernetesResourceFragments.readResourceFragmentsFrom( - DEFAULT_RESOURCE_VERSIONING, "app", new File(fragmentsDir, "simple-rc.yaml")); + "app", new File(fragmentsDir, "simple-rc.yaml")); // Then assertThat(result.buildItems()) .singleElement() @@ -188,7 +214,7 @@ void withYamlFileAndVersionKindNameFromFile_shouldReturnValidResource() throws I void withJsonFileAndVersionKindNameFromFile_shouldReturnValidResource() throws IOException { // When final KubernetesListBuilder result = KubernetesResourceFragments.readResourceFragmentsFrom( - DEFAULT_RESOURCE_VERSIONING, "app", new File(fragmentsDir, "simple-rc.json")); + "app", new File(fragmentsDir, "simple-rc.json")); // Then assertThat(result.buildItems()) .singleElement() @@ -203,7 +229,7 @@ void withJsonFileAndVersionKindNameFromFile_shouldReturnValidResource() throws I void withEmptyFileAndNameAndKindInFileName_shouldReturnEmptyResource() throws IOException { // When final KubernetesListBuilder result = KubernetesResourceFragments.readResourceFragmentsFrom( - DEFAULT_RESOURCE_VERSIONING, "app", new File(fragmentsDir, "empty-file-svc.yml")); + "app", new File(fragmentsDir, "empty-file-svc.yml")); // Then assertThat(result.buildItems()) .singleElement() @@ -220,7 +246,7 @@ void invalidFilename() { final File resource = new File(fragmentsDir, "simple-rc.txt"); // When & Then assertThatIllegalArgumentException() - .isThrownBy(() -> KubernetesResourceFragments.readResourceFragmentsFrom(DEFAULT_RESOURCE_VERSIONING, "app", resource)) + .isThrownBy(() -> KubernetesResourceFragments.readResourceFragmentsFrom("app", resource)) .withMessage("Resource file name 'simple-rc.txt' does not match pattern -.(yaml|yml|json)"); } @@ -232,7 +258,7 @@ void withNoKindInferrableFromFileName_shouldThrowException() { final File resource = new File(fragmentsDir, "contains_no_kind.yml"); // When & Then assertThatIllegalArgumentException() - .isThrownBy(() -> KubernetesResourceFragments.readResourceFragmentsFrom(DEFAULT_RESOURCE_VERSIONING, "app", resource)) + .isThrownBy(() -> KubernetesResourceFragments.readResourceFragmentsFrom("app", resource)) .withMessageStartingWith("No type given as part of the file name (e.g. 'app-rc.yml') and no 'kind' defined in resource descriptor contains_no_kind.yml"); } @@ -243,7 +269,7 @@ void withInvalidResourceContent() { final File resource = new File(fragmentsDir, "invalid-metadata-pod.yaml"); // When & Then assertThatIllegalArgumentException() - .isThrownBy(() -> KubernetesResourceFragments.readResourceFragmentsFrom(DEFAULT_RESOURCE_VERSIONING, "app", resource)) + .isThrownBy(() -> KubernetesResourceFragments.readResourceFragmentsFrom("app", resource)) .withMessageStartingWith("Metadata is expected to be a Map, not a"); } @@ -254,7 +280,7 @@ void withNonExistentFile_shouldThrowException() { final File resource = new File(fragmentsDir, "I-Dont-EXIST.yaml"); // When & Then assertThatIOException() - .isThrownBy(() -> KubernetesResourceFragments.readResourceFragmentsFrom(DEFAULT_RESOURCE_VERSIONING, "app", resource)) + .isThrownBy(() -> KubernetesResourceFragments.readResourceFragmentsFrom("app", resource)) .withMessageContaining("I-Dont-EXIST.yaml") .isInstanceOf(NoSuchFileException.class); } @@ -264,7 +290,7 @@ void withNonExistentFile_shouldThrowException() { void withNameInFieldAndFilename_shouldBeNamedFromField() throws IOException { // When final KubernetesListBuilder result = KubernetesResourceFragments.readResourceFragmentsFrom( - DEFAULT_RESOURCE_VERSIONING, "app", new File(fragmentsDir, "named-svc.yaml")); + "app", new File(fragmentsDir, "named-svc.yaml")); // Then assertThat(result.buildItems()) .singleElement() @@ -279,7 +305,7 @@ void withNameInFieldAndFilename_shouldBeNamedFromField() throws IOException { void withNameInField_shouldBeamedFromField() throws IOException { // When final KubernetesListBuilder result = KubernetesResourceFragments.readResourceFragmentsFrom( - DEFAULT_RESOURCE_VERSIONING, "app", new File(fragmentsDir, "rc.yml")); + "app", new File(fragmentsDir, "rc.yml")); // Then assertThat(result.buildItems()) .singleElement() @@ -294,7 +320,7 @@ void withNameInField_shouldBeamedFromField() throws IOException { void withNoNameInFieldAndNoNameInFilename_shouldBeNamedFromDefaultName() throws IOException { // When final KubernetesListBuilder result = KubernetesResourceFragments.readResourceFragmentsFrom( - DEFAULT_RESOURCE_VERSIONING, "default-app", new File(fragmentsDir, "svc.yml")); + "default-app", new File(fragmentsDir, "svc.yml")); // Then assertThat(result.buildItems()) .singleElement() @@ -309,7 +335,7 @@ void withNoNameInFieldAndNoNameInFilename_shouldBeNamedFromDefaultName() throws void withKindInFieldAndNotInFilename_shouldGetKindFromValue() throws IOException { // When final KubernetesListBuilder result = KubernetesResourceFragments.readResourceFragmentsFrom( - DEFAULT_RESOURCE_VERSIONING, "app", new File(fragmentsDir, "contains_kind.yml")); + "app", new File(fragmentsDir, "contains_kind.yml")); // Then assertThat(result.buildItems()) .singleElement() @@ -323,7 +349,7 @@ void withKindInFieldAndNotInFilename_shouldGetKindFromValue() throws IOException void withKindFromFilename_shouldGetKindFromFilename() throws IOException { // When final KubernetesListBuilder result = KubernetesResourceFragments.readResourceFragmentsFrom( - DEFAULT_RESOURCE_VERSIONING, "app", new File(fragmentsDir, "job.yml")); + "app", new File(fragmentsDir, "job.yml")); // Then assertThat(result.buildItems()) .singleElement() @@ -338,7 +364,7 @@ void withKindFromFilename_shouldGetKindFromFilename() throws IOException { void withKindInFieldAndInFilename_shouldGetKindFromField() throws IOException { // When final KubernetesListBuilder result = KubernetesResourceFragments.readResourceFragmentsFrom( - DEFAULT_RESOURCE_VERSIONING, "app", new File(fragmentsDir, "override-kind-pod.yml")); + "app", new File(fragmentsDir, "override-kind-pod.yml")); // Then assertThat(result.buildItems()) .singleElement() @@ -352,7 +378,7 @@ void withKindInFieldAndInFilename_shouldGetKindFromField() throws IOException { void withValueInKindAndFilenameWithDashes_shouldGetKindFromValue() throws IOException { // When final KubernetesListBuilder result = KubernetesResourceFragments.readResourceFragmentsFrom( - DEFAULT_RESOURCE_VERSIONING, "app", new File(fragmentsDir, "file-name-with-dashes-kind-in-field.yml")); + "app", new File(fragmentsDir, "file-name-with-dashes-kind-in-field.yml")); // Then assertThat(result.buildItems()) .singleElement() @@ -366,7 +392,7 @@ void withValueInKindAndFilenameWithDashes_shouldGetKindFromValue() throws IOExce void withNetworkV1Ingress_shouldLoadNetworkV1Ingress() throws IOException { // When final KubernetesListBuilder result = KubernetesResourceFragments.readResourceFragmentsFrom( - DEFAULT_RESOURCE_VERSIONING, "app", new File(fragmentsDir, "network-v1-ingress.yml")); + "app", new File(fragmentsDir, "network-v1-ingress.yml")); // Then assertThat(result.buildItems()) .singleElement() @@ -381,7 +407,7 @@ void withNetworkV1Ingress_shouldLoadNetworkV1Ingress() throws IOException { void withNetworkPolicyV1_shouldLoadV1NetworkPolicy() throws Exception { // When final KubernetesListBuilder result = KubernetesResourceFragments.readResourceFragmentsFrom( - DEFAULT_RESOURCE_VERSIONING, "app", new File(fragmentsDir, "networking-v1-np.yml")); + "app", new File(fragmentsDir, "networking-v1-np.yml")); // Then assertThat(result.buildItems()) .singleElement() diff --git a/jkube-kit/enricher/api/src/test/resources/kubernetes-resource-fragments/complete-directory-custom-mappings/custom2.yaml b/jkube-kit/enricher/api/src/test/resources/kubernetes-resource-fragments/complete-directory-custom-mappings/custom2.yaml new file mode 100644 index 0000000000..8edc19062e --- /dev/null +++ b/jkube-kit/enricher/api/src/test/resources/kubernetes-resource-fragments/complete-directory-custom-mappings/custom2.yaml @@ -0,0 +1,17 @@ +# +# Copyright (c) 2019 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at: +# +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Red Hat, Inc. - initial API and implementation +# +metadata: + name: the-custom-2 +spec: + field: value diff --git a/jkube-kit/enricher/api/src/test/resources/kubernetes-resource-fragments/complete-directory-custom-mappings/custom3.yaml b/jkube-kit/enricher/api/src/test/resources/kubernetes-resource-fragments/complete-directory-custom-mappings/custom3.yaml new file mode 100644 index 0000000000..8a10dabcf3 --- /dev/null +++ b/jkube-kit/enricher/api/src/test/resources/kubernetes-resource-fragments/complete-directory-custom-mappings/custom3.yaml @@ -0,0 +1,17 @@ +# +# Copyright (c) 2019 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at: +# +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Red Hat, Inc. - initial API and implementation +# +metadata: + name: the-custom-3 +spec: + field: value diff --git a/jkube-kit/enricher/api/src/test/resources/kubernetes-resource-fragments/complete-directory-custom-mappings/hello-c1.yaml b/jkube-kit/enricher/api/src/test/resources/kubernetes-resource-fragments/complete-directory-custom-mappings/hello-c1.yaml new file mode 100644 index 0000000000..d0970188a2 --- /dev/null +++ b/jkube-kit/enricher/api/src/test/resources/kubernetes-resource-fragments/complete-directory-custom-mappings/hello-c1.yaml @@ -0,0 +1,16 @@ +# +# Copyright (c) 2019 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at: +# +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Red Hat, Inc. - initial API and implementation +# + +spec: + field: value diff --git a/jkube-kit/enricher/api/src/test/resources/kubernetes-resource-fragments/complete-directory-custom-mappings/hello-c3.yaml b/jkube-kit/enricher/api/src/test/resources/kubernetes-resource-fragments/complete-directory-custom-mappings/hello-c3.yaml new file mode 100644 index 0000000000..5d3be72c7a --- /dev/null +++ b/jkube-kit/enricher/api/src/test/resources/kubernetes-resource-fragments/complete-directory-custom-mappings/hello-c3.yaml @@ -0,0 +1,13 @@ +# +# Copyright (c) 2019 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at: +# +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Red Hat, Inc. - initial API and implementation +# diff --git a/jkube-kit/enricher/api/src/test/resources/kubernetes-resource-fragments/complete-directory-custom-mappings/provided-api-version-c2.yaml b/jkube-kit/enricher/api/src/test/resources/kubernetes-resource-fragments/complete-directory-custom-mappings/provided-api-version-c2.yaml new file mode 100644 index 0000000000..0de58a3170 --- /dev/null +++ b/jkube-kit/enricher/api/src/test/resources/kubernetes-resource-fragments/complete-directory-custom-mappings/provided-api-version-c2.yaml @@ -0,0 +1,16 @@ +# +# Copyright (c) 2019 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at: +# +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Red Hat, Inc. - initial API and implementation +# +apiVersion: provided/v1alpha1 +spec: + field: value diff --git a/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/DependencyEnricherTest.java b/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/DependencyEnricherTest.java index 0f470e8988..53f7e13eae 100644 --- a/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/DependencyEnricherTest.java +++ b/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/DependencyEnricherTest.java @@ -23,7 +23,6 @@ import org.eclipse.jkube.kit.enricher.api.JKubeEnricherContext; import org.eclipse.jkube.kit.enricher.api.model.KindAndName; import org.eclipse.jkube.kit.enricher.api.util.KubernetesResourceFragments; -import org.eclipse.jkube.kit.enricher.api.util.KubernetesResourceUtil; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -88,7 +87,6 @@ private KubernetesListBuilder createResourcesForTest() throws IOException, URISy * loading Kubernetes resources. */ return KubernetesResourceFragments.readResourceFragmentsFrom( - KubernetesResourceUtil.DEFAULT_RESOURCE_VERSIONING, "the-project", resourceList.toArray(new File[0])); } diff --git a/jkube-kit/resource/service/src/main/java/org/eclipse/jkube/kit/resource/service/DefaultResourceService.java b/jkube-kit/resource/service/src/main/java/org/eclipse/jkube/kit/resource/service/DefaultResourceService.java index 765b390138..a22c6bb83d 100644 --- a/jkube-kit/resource/service/src/main/java/org/eclipse/jkube/kit/resource/service/DefaultResourceService.java +++ b/jkube-kit/resource/service/src/main/java/org/eclipse/jkube/kit/resource/service/DefaultResourceService.java @@ -32,7 +32,6 @@ import org.eclipse.jkube.kit.config.resource.ResourceService; import org.eclipse.jkube.kit.config.resource.ResourceServiceConfig; import org.eclipse.jkube.kit.enricher.api.util.KubernetesResourceFragments; -import org.eclipse.jkube.kit.enricher.api.util.KubernetesResourceUtil; import org.eclipse.jkube.kit.profile.Profile; import org.eclipse.jkube.kit.profile.ProfileUtil; @@ -140,7 +139,6 @@ private List generateProfiledResourcesFromSubdirectories( private KubernetesListBuilder readResourceFragments(File[] resourceFiles) throws IOException { return KubernetesResourceFragments.readResourceFragmentsFrom( - KubernetesResourceUtil.DEFAULT_RESOURCE_VERSIONING, JKubeProjectUtil.createDefaultResourceName(resourceServiceConfig.getProject().getArtifactId()), resourceFiles); } From f894608bb8cc61bc1a4b1029beea6ef1e7f676f0 Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Mon, 3 Jul 2023 20:06:02 +0530 Subject: [PATCH 38/65] chore : Update README.md to have table of contents Signed-off-by: Rohan Kumar --- README.md | 135 +++++++++++++++++++++++++++++++------------- jkube-kit/README.md | 8 +++ 2 files changed, 104 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 63242b57a4..e3ef748de6 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ > Cloud-Native Java Applications without a hassle [![Circle CI](https://circleci.com/gh/eclipse/jkube/tree/master.svg?style=shield)](https://circleci.com/gh/eclipse/jkube/tree/master) -[![Integration Tests](https://github.com/eclipse/jkube/workflows/Integration%20Tests/badge.svg?branch=master)](https://github.com/eclipse/jkube/actions?query=branch%3Amaster) +[![E2E Tests](https://github.com/jkubeio/jkube-integration-tests/actions/workflows/e2e-tests.yml/badge.svg)](https://github.com/jkubeio/jkube-integration-tests/actions/workflows/e2e-tests.yml) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=jkubeio_jkube&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=jkubeio_jkube) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=jkubeio_jkube&metric=coverage)](https://sonarcloud.io/dashboard?id=jkubeio_jkube) [![Gitter](https://badges.gitter.im/eclipse/jkube.svg)](https://gitter.im/eclipse/jkube?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) @@ -15,12 +15,23 @@

    -## Rebranding Notice :loudspeaker: +## Contents +- [Introduction](#introduction) + - [Kubernetes Maven Plugin](#kubernetes-maven-plugin) + - [Kubernetes Gradle Plugin](#kubernetes-gradle-plugin) + - [OpenShift Maven Plugin](#openshift-maven-plugin) + - [OpenShift Gradle Plugin](#openshift-gradle-plugin) +- [Migrating from Fabric8 Maven Plugin to Kubernetes/OpenShift Maven Plugin](https://www.eclipse.org/jkube/docs/migration-guide) +- [Getting Started](#getting-started) + - [Maven Quickstarts](./quickstarts/maven) + - [Gradle Quickstarts](./quickstarts/gradle) + - [Hello World using Eclipse JKube](#hello-world-using-eclipse-jkube) + - [Troubleshooting](#troubleshooting) +- [Rebranding Notice](#rebranding-notice--loudspeaker-) +- [Contributing](https://www.eclipse.org/jkube/contributing/) +- [Add your organization to ADOPTERS](./ADOPTERS.md) +- [FAQs](https://www.eclipse.org/jkube/docs/kubernetes-maven-plugin/#faq) -This project is not an effort from scratch. It was earlier called -[Fabric8 Maven Plugin](https://github.com/fabric8io/fabric8-maven-plugin). -It is just refactored and rebranded version of the project targeted towards Java developers who are working on top of -Kubernetes. For more information about history, please see [REBRANDING.md](./REBRANDING.md) ## Introduction @@ -35,43 +46,81 @@ This project contains various building blocks for the Kubernetes Java developer ### Kubernetes Maven Plugin -[![Maven Central](https://img.shields.io/maven-central/v/org.eclipse.jkube/kubernetes-maven-plugin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.eclipse.jkube%22%20AND%20a:%22kubernetes-maven-plugin%22) -[![Documentation](https://img.shields.io/badge/plugin-documentation-lightgrey)](https://www.eclipse.org/jkube/docs/kubernetes-maven-plugin) - -[![Sample Demo KMP](./kubernetes-maven-plugin/kmp.png)](https://asciinema.org/a/335724) +- [![Maven Central](https://img.shields.io/maven-central/v/org.eclipse.jkube/kubernetes-maven-plugin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.eclipse.jkube%22%20AND%20a:%22kubernetes-maven-plugin%22) +- [![Documentation](https://img.shields.io/badge/plugin-documentation-lightgrey)](https://www.eclipse.org/jkube/docs/kubernetes-maven-plugin) +- Add to project: + ```xml + + org.eclipse.jkube + kubernetes-maven-plugin + ${jkube.version} + + ``` +- Run the JKube commands, for instance: + ```shell + mvn package k8s:build k8s:push k8s:resource k8s:apply + ``` +- :tv: Watch 2-minute demo on YouTube: + +[![KubernetesMavenPluginDemo](https://img.youtube.com/vi/FHz5q8ERtPk/0.jpg)](https://youtu.be/FHz5q8ERtPk) + + +### Kubernetes Gradle Plugin +- [![Maven Central](https://img.shields.io/maven-central/v/org.eclipse.jkube.kubernetes/org.eclipse.jkube.kubernetes.gradle.plugin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.eclipse.jkube.kubernetes%22%20AND%20a:%22org.eclipse.jkube.kubernetes.gradle.plugin%22) +- [![Documentation](https://img.shields.io/badge/plugin-documentation-lightgrey)](https://www.eclipse.org/jkube/docs/kubernetes-gradle-plugin/) +- Add to project: + ```groovy + plugins { + id "org.eclipse.jkube.kubernetes" version "${jKubeVersion}" + } + ``` +- Run the JKube commands, for instance: + ```shell + gradle build k8sBuild k8sPush k8sResource k8sApply + ``` +- :tv: Watch 2-minute demo on YouTube: + +[![KubernetesGradlePluginDemo](https://img.youtube.com/vi/TUYl2Vw8bnQ/0.jpg)](https://youtu.be/TUYl2Vw8bnQ) + +### OpenShift Gradle Plugin +- [![Maven Central](https://img.shields.io/maven-central/v/org.eclipse.jkube.openshift/org.eclipse.jkube.openshift.gradle.plugin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.eclipse.jkube.openshift%22%20AND%20a:%22org.eclipse.jkube.openshift.gradle.plugin%22) +- [![Documentation](https://img.shields.io/badge/plugin-documentation-lightgrey)](https://www.eclipse.org/jkube/docs/openshift-gradle-plugin/) +- Add to project: + ```groovy + plugins { + id "org.eclipse.jkube.openshift" version "${jKubeVersion}" + } + ``` +- Run the JKube commands, for instance: + ```shell + gradle build ocBuild ocResource ocApply + ``` +- :tv: Watch 2-minute demo on YouTube: + +[![OpenShiftGradlePluginDemo](https://img.youtube.com/vi/uMxEzLdqcik/0.jpg)](https://youtu.be/uMxEzLdqcik) ### OpenShift Maven Plugin -[![Maven Central](https://img.shields.io/maven-central/v/org.eclipse.jkube/openshift-maven-plugin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.eclipse.jkube%22%20AND%20a:%22openshift-maven-plugin%22) -[![Documentation](https://img.shields.io/badge/plugin-documentation-lightgrey)](https://www.eclipse.org/jkube/docs/openshift-maven-plugin) - -[![Sample Demo OMP](./openshift-maven-plugin/omp.png)](https://asciinema.org/a/335743) - -### JKube Kit - -JKube Kit is the core engine powering our Maven plugins. - -The main difference between Fabric8 Maven Plugin and JKube is the extraction and decoupling of the core components from -Maven. This enables other projects and frameworks to reuse all of JKube's functionality by exposing it through a public API. +- [![Maven Central](https://img.shields.io/maven-central/v/org.eclipse.jkube/openshift-maven-plugin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.eclipse.jkube%22%20AND%20a:%22openshift-maven-plugin%22) +- [![Documentation](https://img.shields.io/badge/plugin-documentation-lightgrey)](https://www.eclipse.org/jkube/docs/openshift-maven-plugin) +- Add to project: + ```xml + + org.eclipse.jkube + openshift-maven-plugin + ${jkube.version} + + ``` +- Run the JKube commands, for instance: + ```shell + mvn package oc:build oc:resource oc:apply + ``` +- :tv: Watch 2-minute demo on YouTube: + +[![OpenShiftMavenPluginDemo](https://img.youtube.com/vi/ZJzfD-bDxpc/0.jpg)](https://youtu.be/ZJzfD-bDxpc) - * **Generator** framework for automatically generating Docker images by examining project information.
    - [![Maven Central](https://img.shields.io/maven-central/v/org.eclipse.jkube/jkube-kit-generator-api.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.eclipse.jkube%22%20AND%20a:%22jkube-kit-generator-api%22) [![Javadocs](http://www.javadoc.io/badge/org.eclipse.jkube/jkube-kit-generator-api.svg?color=blue)](http://www.javadoc.io/doc/org.eclipse.jkube/jkube-kit-generator-api) - * **Enricher** framework for creating and enhancing Kubernetes and OpenShift resources.
    - [![Maven Central](https://img.shields.io/maven-central/v/org.eclipse.jkube/jkube-kit-enricher-api.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.eclipse.jkube%22%20AND%20a:%22jkube-kit-enricher-api%22) [![Javadocs](http://www.javadoc.io/badge/org.eclipse.jkube/jkube-kit-enricher-api.svg?color=blue)](http://www.javadoc.io/doc/org.eclipse.jkube/jkube-kit-enricher-api) - * **Profile** combining the configuration for generators and enrichers.
    - [![Maven Central](https://img.shields.io/maven-central/v/org.eclipse.jkube/jkube-kit-profiles.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.eclipse.jkube%22%20AND%20a:%22jkube-kit-profiles%22) [![Javadocs](http://www.javadoc.io/badge/org.eclipse.jkube/jkube-kit-profiles.svg?color=blue)](http://www.javadoc.io/doc/org.eclipse.jkube/jkube-kit-profiles) - * **Resource configuration** model objects for a simplified configuration of Kubernetes and OpenShift resources.
    - [![Maven Central](https://img.shields.io/maven-central/v/org.eclipse.jkube/jkube-kit-config-resource.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.eclipse.jkube%22%20AND%20a:%22jkube-kit-config-resource%22) [![Javadocs](http://www.javadoc.io/badge/org.eclipse.jkube/jkube-kit-config-resource.svg?color=blue)](http://www.javadoc.io/doc/org.eclipse.jkube/jkube-kit-config-resource) - * **Image configuration** model objects for modeling Docker image configuration as used in docker-maven-plugin.
    - [![Maven Central](https://img.shields.io/maven-central/v/org.eclipse.jkube/jkube-kit-config-image.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.eclipse.jkube%22%20AND%20a:%22jkube-kit-config-image%22) [![Javadocs](http://www.javadoc.io/badge/org.eclipse.jkube/jkube-kit-config-image.svg?color=blue)](http://www.javadoc.io/doc/org.eclipse.jkube/jkube-kit-config-image) - -Some thin adapter Maven specific modules like [jkube-kit-enricher-maven](enricher/maven/pom.xml) and -[jkube-kit-generator-maven](generator/maven/pom.xml) are provided as glue to get to the Maven specific build information - like the project's coordinates. ## Getting started - -Check out our [Maven quickstarts](https://github.com/eclipse/jkube/tree/master/quickstarts/maven) to see how JKube fits -with the Java framework of your choice.https://github.com/eclipse/jkube/tree/master/quickstarts/maven +You can take a look at our quickstarts in [quickstarts](./quickstarts) directory that contain sample maven and gradle projects using the latest version of jkube plugin. ### Hello World using Eclipse JKube @@ -107,7 +156,7 @@ $ mvn k8s:log [INFO] k8s: [NEW] helloworld-7c4665f464-xwskj status: Running ``` -## Troubleshooting +#### Troubleshooting If you experience problems using minikube that pod's status shows 'ImagePullBackOff' and not 'Completed' you must share the minikube's docker daemon environment with your shell with: ```shell script @@ -119,3 +168,11 @@ $ eval $(minikube docker-env -u) ```` If you don't want to type the command for every new terminal you open, you can add the command to your `.bash_profile` on mac or `.zshrc`. + +## Rebranding Notice :loudspeaker: + +This project is not an effort from scratch. It was earlier called +[Fabric8 Maven Plugin](https://github.com/fabric8io/fabric8-maven-plugin). +It is just refactored and rebranded version of the project targeted towards Java developers who are working on top of +Kubernetes. For more information about history, please see [REBRANDING.md](./REBRANDING.md) + diff --git a/jkube-kit/README.md b/jkube-kit/README.md index 238ffa85f4..0b4a516be4 100644 --- a/jkube-kit/README.md +++ b/jkube-kit/README.md @@ -1,5 +1,13 @@ ## JKube-Kit +JKube Kit is the core engine powering our Maven plugins. + +The main difference between Fabric8 Maven Plugin and JKube is the extraction and decoupling of the core components from +Maven. This enables other projects and frameworks to reuse all of JKube's functionality by exposing it through a public API. + +Some thin adapter Maven specific modules like [jkube-kit-enricher-maven](enricher/maven/pom.xml) and +[jkube-kit-generator-maven](generator/maven/pom.xml) are provided as glue to get to the Maven specific build information +like the project's coordinates. This project contains various building blocks for the JKube developer toolbox. Actually it contains the following abstractions which has been extracted from both projects: From bb8e9358f6b996b22efe7073b6774411e9081455 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Mon, 17 Jul 2023 15:52:28 +0200 Subject: [PATCH 39/65] doc: documentation for Kind/Filename mapping with apiVersion Signed-off-by: Marc Nuri --- CHANGELOG.md | 1 + .../inc/_kind-filename-type-mapping.adoc | 29 ---------- .../asciidoc/inc/examples/_fragments.adoc | 2 +- .../doc/src/main/asciidoc/index.adoc | 4 +- .../asciidoc/inc/mapping-config/_index.adoc | 55 +++++++++++++++++++ .../doc/src/main/asciidoc/inc/_appendix.adoc | 33 ----------- .../src/main/asciidoc/inc/_introduction.adoc | 2 +- .../doc/src/main/asciidoc/index.adoc | 5 +- 8 files changed, 62 insertions(+), 69 deletions(-) delete mode 100644 gradle-plugin/doc/src/main/asciidoc/inc/_kind-filename-type-mapping.adoc create mode 100644 jkube-kit/doc/src/main/asciidoc/inc/mapping-config/_index.adoc delete mode 100644 kubernetes-maven-plugin/doc/src/main/asciidoc/inc/_appendix.adoc diff --git a/CHANGELOG.md b/CHANGELOG.md index 21736adc46..74d8e6a857 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ Usage: * Fix #1929: Docker Image Name parsing fix * Fix #1985: Update outdated methods in Spring Boot CRD Maven Quickstart * Fix #2116: Remove user field from ImageName class +* Fix #2219: Kind/Filename mappings include optional apiVersion configuration * Fix #2224: Quarkus native base image read from properties (configurable) * Fix #2228: Quarkus native base image uses UBI 8.7 diff --git a/gradle-plugin/doc/src/main/asciidoc/inc/_kind-filename-type-mapping.adoc b/gradle-plugin/doc/src/main/asciidoc/inc/_kind-filename-type-mapping.adoc deleted file mode 100644 index e5c44fa931..0000000000 --- a/gradle-plugin/doc/src/main/asciidoc/inc/_kind-filename-type-mapping.adoc +++ /dev/null @@ -1,29 +0,0 @@ -[[kind-filename-mapping]] -= Kind/Filename Mapping - -[[appendix-kind-mapping]] -== Default Kind/Filename Mapping -include::{plugindir}/src/main/resources/META-INF/jkube/kind-filename-type-mapping-default.adoc[] - -[[custom-kind-mapping]] -== Custom Kind/Filename Mapping - -You can add your custom `Kind/Filename` mappings. -To do it you have two approaches: - -* Setting an environment variable or system property called `jkube.mapping` pointing out to a `.properties` files with pairs `=>filename1>, ` -By default if no environment variable nor system property is set, scan for a file located at classpath `/META-INF/jkube.kind-filename-type-mapping-default.properties`. - -* By embedding in task configuration the mapping: - -[source,groovy,indent=0,subs="verbatim,quotes,attributes"] ----- -kubernetes { - mappings { - mapping { - kind = "Var" - filenameTypes = "foo, bar" - } - } -} ----- \ No newline at end of file diff --git a/gradle-plugin/doc/src/main/asciidoc/inc/examples/_fragments.adoc b/gradle-plugin/doc/src/main/asciidoc/inc/examples/_fragments.adoc index aa5aa5edc5..a507dfc515 100644 --- a/gradle-plugin/doc/src/main/asciidoc/inc/examples/_fragments.adoc +++ b/gradle-plugin/doc/src/main/asciidoc/inc/examples/_fragments.adoc @@ -36,7 +36,7 @@ The resource fragments are in `src/main/jkube`. As you can see, there is no `metadata` section as would be expected for Kubernetes resources because it will be automatically added by the `{plugin}`. The object's `Kind`, if not given, is automatically derived from the filename. In this case, the `{plugin}` will create a `Deployment` because the file is called `deployment.yml`. Similar mappings between file names and resource type exist for each supported resource kind, the -complete list of which (along with associated abbreviations) can be found in the <>. +complete list of which (along with associated abbreviations) can be found in the <> section. Additionally, if you name your fragment using a name prefix followed by a dash and the mapped file name, the plugin will automatically use that name for your resource. So, for example, if you name your deployment fragment `myapp-deployment.yml`, the plugin will name your resource `myapp`. In the absence of such provided name for your resource, a name will be automatically derived from your project's metadata (in particular, its project `name` as specified in your `build.gradle`). diff --git a/gradle-plugin/doc/src/main/asciidoc/index.adoc b/gradle-plugin/doc/src/main/asciidoc/index.adoc index 070ccd3629..9b7ac1db8c 100644 --- a/gradle-plugin/doc/src/main/asciidoc/index.adoc +++ b/gradle-plugin/doc/src/main/asciidoc/index.adoc @@ -9,7 +9,7 @@ :toc-title: {plugin} :doctype: book :icons: font -:plugindir: ../../../../../kubernetes +:plugindir: {docdir}../../../../../kubernetes :kitdoc-path: {docdir}/../../../../../jkube-kit/doc/src/main/asciidoc :plugin-type: gradle :plugin-configuration-type: Groovy DSL @@ -41,6 +41,6 @@ include::inc/_registry.adoc[] include::inc/_authentication.adoc[] -include::inc/_kind-filename-type-mapping.adoc[] +include::{kitdoc-path}/inc/mapping-config/_index.adoc[] diff --git a/jkube-kit/doc/src/main/asciidoc/inc/mapping-config/_index.adoc b/jkube-kit/doc/src/main/asciidoc/inc/mapping-config/_index.adoc new file mode 100644 index 0000000000..68c88f5925 --- /dev/null +++ b/jkube-kit/doc/src/main/asciidoc/inc/mapping-config/_index.adoc @@ -0,0 +1,55 @@ +[[kind-filename-mapping]] += Kind/Filename Mapping + +[[default-kind-filename-mapping]] +== Default Kind/Filename Mapping + +include::{plugindir}/src/main/resources/META-INF/jkube/kind-filename-type-mapping-default.adoc[] + +[[custom-kind-mapping]] +== Custom Kind/Filename Mapping + +You can add your custom `Kind/Filename` mappings. +To do it you have two approaches: + +* Setting an environment variable or system property called `jkube.mapping` pointing out to a `.properties` files with pairs `=>, ` +By default if no environment variable nor system property is set, JKube looks for a file located at classpath `/META-INF/jkube.kind-filename-type-mapping-default.properties`. + +* By defining the Mapping in the plugin's configuration + +ifeval::["{plugin-type}" == "maven"] +[source,xml,indent=0,subs="verbatim,quotes,attributes"] +---- + + org.eclipse.jkube + {plugin} + + + + Var + foo, bar + api.example.com/v1 + + + + +---- +endif::[] + +ifeval::["{plugin-type}" == "gradle"] +[source,groovy,indent=0,subs="verbatim,quotes,attributes"] +---- +kubernetes { + mappings { + mapping { + kind = "Var" // <1> + filenameTypes = "foo, bar" // <2> + apiVersion = "api.example.com/v1" // <3> + } + } +} +---- +endif::[] +<1> The kind name (mandatory) +<2> The filename types (mandatory), a comma-separated list of filenames to map to the specified kind +<3> The apiVersion (optional) diff --git a/kubernetes-maven-plugin/doc/src/main/asciidoc/inc/_appendix.adoc b/kubernetes-maven-plugin/doc/src/main/asciidoc/inc/_appendix.adoc deleted file mode 100644 index efaeef4136..0000000000 --- a/kubernetes-maven-plugin/doc/src/main/asciidoc/inc/_appendix.adoc +++ /dev/null @@ -1,33 +0,0 @@ -[[appendix]] -= Appendix - -== Kind/Filename Type Mapping - -[[appendix-kind-mapping]] -include::{plugindir}/src/main/resources/META-INF/jkube/kind-filename-type-mapping-default.adoc[] - -== Custom Kind/Filename Mapping - -You can add your custom `Kind/Filename` mappings. -To do it you have two approaches: - -* Setting an environment variable or system property called `jkube.mapping` pointing out to a `.properties` files with pairs `=>filename1>, ` -By default if no environment variable nor system property is set, scan for a file located at classpath `/META-INF/jkube.kind-filename-type-mapping-default.properties`. - -* By embedding in MOJO configuration the mapping: - -[source,xml,indent=0,subs="verbatim,quotes,attributes"] ----- - - org.eclipse.jkube - {plugin} - - - - Var - foo, bar - - - - ----- \ No newline at end of file diff --git a/kubernetes-maven-plugin/doc/src/main/asciidoc/inc/_introduction.adoc b/kubernetes-maven-plugin/doc/src/main/asciidoc/inc/_introduction.adoc index db87b24d8e..5c98e6284f 100644 --- a/kubernetes-maven-plugin/doc/src/main/asciidoc/inc/_introduction.adoc +++ b/kubernetes-maven-plugin/doc/src/main/asciidoc/inc/_introduction.adoc @@ -391,7 +391,7 @@ The resource fragments are in `src/main/jkube`. As you can see, there is no `metadata` section as would be expected for Kubernetes resources because it will be automatically added by the `{plugin}`. The object's `Kind`, if not given, is automatically derived from the filename. In this case, the `{plugin}` will create a `Deployment` because the file is called `deployment.yml`. Similar mappings between file names and resource type exist for each supported resource kind, the -complete list of which (along with associated abbreviations) can be found in the <>. +complete list of which (along with associated abbreviations) can be found in the <> section. diff --git a/kubernetes-maven-plugin/doc/src/main/asciidoc/index.adoc b/kubernetes-maven-plugin/doc/src/main/asciidoc/index.adoc index 2d76d7a04f..c31ac1238e 100644 --- a/kubernetes-maven-plugin/doc/src/main/asciidoc/index.adoc +++ b/kubernetes-maven-plugin/doc/src/main/asciidoc/index.adoc @@ -10,7 +10,7 @@ Roland Huß, James Strachan; :toc-title: {plugin} :doctype: book :icons: font -:plugindir: ../../../../../plugin +:plugindir: {docdir}../../../../../plugin :kitdoc-path: {docdir}/../../../../../jkube-kit/doc/src/main/asciidoc :plugin-type: maven :plugin-configuration-type: XML @@ -45,5 +45,4 @@ include::inc/_integrations.adoc[] include::inc/_faq.adoc[] -include::inc/_appendix.adoc[] - +include::{kitdoc-path}/inc/mapping-config/_index.adoc[] From f0c3da83159ea507c990f84ed2f250bccfc55185 Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Thu, 6 Jul 2023 13:51:53 +0530 Subject: [PATCH 40/65] refactor (jkube-kit-spring-boot) : Move devtools utility methods out of SpringBootGenerator I see a lot of utility methods in SpringBootGenerator which are specific to spring boot devtools. Move these methods to a new utility SpringBootDevtoolsUtils class. Signed-off-by: Rohan Kumar --- .../kit/common/util/SpringBootUtilTest.java | 117 ---------- .../jkube/kit/common/util/SpringBootUtil.java | 8 + .../kit/common/util/SpringBootUtilTest.java | 156 +++++++++++++- .../util/springboot}/invalid-application.yml | 0 .../resources/application.properties | 1 + ...est-application-with-multiple-profiles.yml | 0 .../util/springboot}/test-application.yml | 0 .../springboot/SpringBootDevtoolsUtils.java | 192 +++++++++++++++++ .../generator/SpringBootGenerator.java | 198 ++--------------- .../SpringBootDevtoolsUtilsTest.java | 202 ++++++++++++++++++ .../application.properties | 2 +- 11 files changed, 572 insertions(+), 304 deletions(-) delete mode 100644 jkube-kit/common-maven/src/test/java/org/eclipse/jkube/kit/common/util/SpringBootUtilTest.java rename jkube-kit/{common-maven/src/test/resources/util => common/src/test/resources/util/springboot}/invalid-application.yml (100%) create mode 100644 jkube-kit/common/src/test/resources/util/springboot/resources/application.properties rename jkube-kit/{common-maven/src/test/resources/util => common/src/test/resources/util/springboot}/test-application-with-multiple-profiles.yml (100%) rename jkube-kit/{common-maven/src/test/resources/util => common/src/test/resources/util/springboot}/test-application.yml (100%) create mode 100644 jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/SpringBootDevtoolsUtils.java create mode 100644 jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/SpringBootDevtoolsUtilsTest.java diff --git a/jkube-kit/common-maven/src/test/java/org/eclipse/jkube/kit/common/util/SpringBootUtilTest.java b/jkube-kit/common-maven/src/test/java/org/eclipse/jkube/kit/common/util/SpringBootUtilTest.java deleted file mode 100644 index 5e7bb7e94b..0000000000 --- a/jkube-kit/common-maven/src/test/java/org/eclipse/jkube/kit/common/util/SpringBootUtilTest.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * Copyright (c) 2019 Red Hat, Inc. - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at: - * - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - */ -package org.eclipse.jkube.kit.common.util; - -import java.net.URL; -import java.util.Collections; -import java.util.Map; -import java.util.Properties; - -import org.eclipse.jkube.kit.common.JavaProject; -import org.eclipse.jkube.kit.common.Plugin; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.entry; -import static org.junit.jupiter.api.Assertions.assertThrows; - -/** - * Checking the behaviour of utility methods. - */ -class SpringBootUtilTest { - - @Test - void testYamlToPropertiesParsing() { - - Properties props = YamlUtil.getPropertiesFromYamlResource(SpringBootUtilTest.class.getResource("/util/test-application.yml")); - assertThat(props).isNotEmpty() - .contains( - entry("management.port", "8081"), - entry("spring.datasource.url", "jdbc:mysql://127.0.0.1:3306"), - entry("example.nested.items[0].value", "value0"), - entry("example.nested.items[1].value", "value1"), - entry("example.nested.items[2].elements[0].element[0].subelement", "sub0"), - entry("example.nested.items[2].elements[0].element[1].subelement", "sub1"), - entry("example.1", "integerKeyElement")); - } - - @Test - void testInvalidFileThrowsException() { - URL resource = SpringBootUtil.class.getResource("/util/invalid-application.yml"); - assertThrows(IllegalStateException.class, () -> YamlUtil.getPropertiesFromYamlResource(resource)); - } - - @Test - void testNonExistentYamlToPropertiesParsing() { - Properties props = YamlUtil.getPropertiesFromYamlResource(SpringBootUtilTest.class.getResource("/this-file-does-not-exist")); - assertThat(props).isNotNull().isEmpty(); - } - - @Test - void testMultipleProfilesParsing() { - Properties props = SpringBootUtil.getPropertiesFromApplicationYamlResource(null, getClass().getResource("/util/test-application-with-multiple-profiles.yml")); - - assertThat(props).isNotEmpty() - .contains( - entry("spring.application.name", "spring-boot-k8-recipes"), - entry("management.endpoints.enabled-by-default", "false"), - entry("management.endpoint.health.enabled", "true")) - .doesNotContainEntry("cloud.kubernetes.reload.enabled", null); - - props = SpringBootUtil.getPropertiesFromApplicationYamlResource("kubernetes", getClass().getResource("/util/test-application-with-multiple-profiles.yml")); - - assertThat(props) - .containsEntry("cloud.kubernetes.reload.enabled", "true") - .doesNotContain( - entry("cloud.kubernetes.reload.enabled", null), - entry("spring.application.name", null)); - } - - @Test - void getSpringBootPluginConfiguration_whenSpringBootMavenPluginPresent_thenReturnsPluginConfiguration() { - // Given - JavaProject javaProject = JavaProject.builder() - .plugin(Plugin.builder() - .groupId("org.springframework.boot") - .artifactId("spring-boot-maven-plugin") - .configuration(Collections.singletonMap("layout", "ZIP")) - .build()) - .build(); - - // When - Map configuration = SpringBootUtil.getSpringBootPluginConfiguration(javaProject); - - // Then - assertThat(configuration).isNotNull().containsEntry("layout", "ZIP"); - } - - @Test - void getSpringBootPluginConfiguration_whenSpringBootGradlePluginPresent_thenReturnsPluginConfiguration() { - // Given - JavaProject javaProject = JavaProject.builder() - .plugin(Plugin.builder() - .groupId("org.springframework.boot") - .artifactId("org.springframework.boot.gradle.plugin") - .configuration(Collections.singletonMap("mainClass", "com.example.ExampleApplication")) - .build()) - .build(); - - // When - Map configuration = SpringBootUtil.getSpringBootPluginConfiguration(javaProject); - - // Then - assertThat(configuration).isNotNull().containsEntry("mainClass", "com.example.ExampleApplication"); - } - -} diff --git a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/SpringBootUtil.java b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/SpringBootUtil.java index 944088c447..9235abd9ed 100644 --- a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/SpringBootUtil.java +++ b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/SpringBootUtil.java @@ -103,5 +103,13 @@ public static Map getSpringBootPluginConfiguration(JavaProject j } return Collections.emptyMap(); } + + public static boolean isSpringBootRepackage(JavaProject project) { + Plugin plugin = JKubeProjectUtil.getPlugin(project, SpringBootConfigurationHelper.SPRING_BOOT_MAVEN_PLUGIN_ARTIFACT_ID); + return Optional.ofNullable(plugin) + .map(Plugin::getExecutions) + .map(e -> e.contains("repackage")) + .orElse(false); + } } diff --git a/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/SpringBootUtilTest.java b/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/SpringBootUtilTest.java index 2dea533cb8..db67488029 100644 --- a/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/SpringBootUtilTest.java +++ b/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/SpringBootUtilTest.java @@ -16,18 +16,23 @@ import org.apache.commons.io.FileUtils; import org.eclipse.jkube.kit.common.Dependency; import org.eclipse.jkube.kit.common.JavaProject; +import org.eclipse.jkube.kit.common.Plugin; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.api.BeforeEach; import java.io.File; import java.io.IOException; +import java.net.URL; import java.net.URLClassLoader; import java.util.Arrays; import java.util.Collections; +import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.Properties; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.assertj.core.api.Assertions.assertThat; @@ -45,7 +50,7 @@ public void setUp() { @Test void testGetSpringBootApplicationProperties(@TempDir File temporaryFolder) throws IOException { //Given - File applicationProp = new File(getClass().getResource("/util/spring-boot-application.properties").getPath()); + File applicationProp = new File(Objects.requireNonNull(getClass().getResource("/util/spring-boot-application.properties")).getPath()); String springActiveProfile = null; File targetFolder = new File(temporaryFolder, "target"); File classesInTarget = new File(targetFolder, "classes"); @@ -110,4 +115,153 @@ void testGetSpringBootActiveProfileWhenNotNull() { void testGetSpringBootActiveProfileWhenNull() { assertThat(SpringBootUtil.getSpringBootActiveProfile(null)).isNull(); } + + @Test + void getSpringBootApplicationProperties_withCompileClassloader_shouldLoadProperties() { + // Given + JavaProject javaProject = JavaProject.builder() + .compileClassPathElement(Objects.requireNonNull(getClass().getResource("/util/springboot/resources")).getPath()) + .outputDirectory(new File("target")) + .build(); + URLClassLoader compileClassLoader = JKubeProjectUtil.getClassLoader(javaProject); + + // When + Properties properties = SpringBootUtil.getSpringBootApplicationProperties(compileClassLoader); + + // Then + assertThat(properties) + .containsEntry("server.port", "8081"); + } + + + @Test + void testYamlToPropertiesParsing() { + + Properties props = YamlUtil.getPropertiesFromYamlResource(getClass().getResource("/util/springboot/test-application.yml")); + assertThat(props).isNotEmpty() + .contains( + entry("management.port", "8081"), + entry("spring.datasource.url", "jdbc:mysql://127.0.0.1:3306"), + entry("example.nested.items[0].value", "value0"), + entry("example.nested.items[1].value", "value1"), + entry("example.nested.items[2].elements[0].element[0].subelement", "sub0"), + entry("example.nested.items[2].elements[0].element[1].subelement", "sub1"), + entry("example.1", "integerKeyElement")); + } + + @Test + void testInvalidFileThrowsException() { + URL resource = SpringBootUtil.class.getResource("/util/springboot/invalid-application.yml"); + assertThrows(IllegalStateException.class, () -> YamlUtil.getPropertiesFromYamlResource(resource)); + } + + @Test + void testNonExistentYamlToPropertiesParsing() { + Properties props = YamlUtil.getPropertiesFromYamlResource(getClass().getResource("/this-file-does-not-exist")); + assertThat(props).isNotNull().isEmpty(); + } + + @Test + void testMultipleProfilesParsing() { + Properties props = SpringBootUtil.getPropertiesFromApplicationYamlResource(null, getClass().getResource("/util/springboot/test-application-with-multiple-profiles.yml")); + + assertThat(props).isNotEmpty() + .contains( + entry("spring.application.name", "spring-boot-k8-recipes"), + entry("management.endpoints.enabled-by-default", "false"), + entry("management.endpoint.health.enabled", "true")) + .doesNotContainEntry("cloud.kubernetes.reload.enabled", null); + + props = SpringBootUtil.getPropertiesFromApplicationYamlResource("kubernetes", getClass().getResource("/util/springboot/test-application-with-multiple-profiles.yml")); + + assertThat(props) + .containsEntry("cloud.kubernetes.reload.enabled", "true") + .doesNotContain( + entry("cloud.kubernetes.reload.enabled", null), + entry("spring.application.name", null)); + } + + @Test + void getSpringBootPluginConfiguration_whenNothingPresent_thenReturnsEmptyMap() { + // Given + JavaProject javaProject = JavaProject.builder().build(); + + // When + Map configuration = SpringBootUtil.getSpringBootPluginConfiguration(javaProject); + + // Then + assertThat(configuration).isEmpty(); + } + + @Test + void getSpringBootPluginConfiguration_whenSpringBootMavenPluginPresent_thenReturnsPluginConfiguration() { + // Given + JavaProject javaProject = JavaProject.builder() + .plugin(Plugin.builder() + .groupId("org.springframework.boot") + .artifactId("spring-boot-maven-plugin") + .configuration(Collections.singletonMap("layout", "ZIP")) + .build()) + .build(); + + // When + Map configuration = SpringBootUtil.getSpringBootPluginConfiguration(javaProject); + + // Then + assertThat(configuration).isNotNull().containsEntry("layout", "ZIP"); + } + + @Test + void getSpringBootPluginConfiguration_whenSpringBootGradlePluginPresent_thenReturnsPluginConfiguration() { + // Given + JavaProject javaProject = JavaProject.builder() + .plugin(Plugin.builder() + .groupId("org.springframework.boot") + .artifactId("org.springframework.boot.gradle.plugin") + .configuration(Collections.singletonMap("mainClass", "com.example.ExampleApplication")) + .build()) + .build(); + + // When + Map configuration = SpringBootUtil.getSpringBootPluginConfiguration(javaProject); + + // Then + assertThat(configuration).isNotNull().containsEntry("mainClass", "com.example.ExampleApplication"); + } + + @Test + void isSpringBootRepackage_whenPluginHasRepackageExecution_thenReturnTrue() { + // Given + JavaProject javaProject = JavaProject.builder() + .plugin(Plugin.builder() + .groupId("org.springframework.boot") + .artifactId("spring-boot-maven-plugin") + .executions(Collections.singletonList("repackage")) + .build()) + .build(); + + // When + boolean result = SpringBootUtil.isSpringBootRepackage(javaProject); + + // Then + assertThat(result).isTrue(); + } + + @Test + void isSpringBootRepackage_whenNoExecution_thenReturnFalse() { + // Given + JavaProject javaProject = JavaProject.builder() + .plugin(Plugin.builder() + .groupId("org.springframework.boot") + .artifactId("spring-boot-maven-plugin") + .executions(Collections.emptyList()) + .build()) + .build(); + + // When + boolean result = SpringBootUtil.isSpringBootRepackage(javaProject); + + // Then + assertThat(result).isFalse(); + } } diff --git a/jkube-kit/common-maven/src/test/resources/util/invalid-application.yml b/jkube-kit/common/src/test/resources/util/springboot/invalid-application.yml similarity index 100% rename from jkube-kit/common-maven/src/test/resources/util/invalid-application.yml rename to jkube-kit/common/src/test/resources/util/springboot/invalid-application.yml diff --git a/jkube-kit/common/src/test/resources/util/springboot/resources/application.properties b/jkube-kit/common/src/test/resources/util/springboot/resources/application.properties new file mode 100644 index 0000000000..bafddced85 --- /dev/null +++ b/jkube-kit/common/src/test/resources/util/springboot/resources/application.properties @@ -0,0 +1 @@ +server.port=8081 \ No newline at end of file diff --git a/jkube-kit/common-maven/src/test/resources/util/test-application-with-multiple-profiles.yml b/jkube-kit/common/src/test/resources/util/springboot/test-application-with-multiple-profiles.yml similarity index 100% rename from jkube-kit/common-maven/src/test/resources/util/test-application-with-multiple-profiles.yml rename to jkube-kit/common/src/test/resources/util/springboot/test-application-with-multiple-profiles.yml diff --git a/jkube-kit/common-maven/src/test/resources/util/test-application.yml b/jkube-kit/common/src/test/resources/util/springboot/test-application.yml similarity index 100% rename from jkube-kit/common-maven/src/test/resources/util/test-application.yml rename to jkube-kit/common/src/test/resources/util/springboot/test-application.yml diff --git a/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/SpringBootDevtoolsUtils.java b/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/SpringBootDevtoolsUtils.java new file mode 100644 index 0000000000..7de2ca76ca --- /dev/null +++ b/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/SpringBootDevtoolsUtils.java @@ -0,0 +1,192 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.springboot; + +import com.google.common.base.Strings; +import org.apache.commons.io.FileUtils; +import org.eclipse.jkube.generator.javaexec.FatJarDetector; +import org.eclipse.jkube.kit.common.JavaProject; +import org.eclipse.jkube.kit.common.util.JKubeProjectUtil; +import org.eclipse.jkube.kit.common.util.SpringBootUtil; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.util.Collections; +import java.util.List; +import java.util.Properties; +import java.util.UUID; +import java.util.zip.CRC32; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; +import java.util.zip.ZipOutputStream; + +import static org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper.DEV_TOOLS_REMOTE_SECRET; +import static org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper.SPRING_BOOT_DEVTOOLS_ARTIFACT_ID; +import static org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper.SPRING_BOOT_GROUP_ID; + +public class SpringBootDevtoolsUtils { + private SpringBootDevtoolsUtils() { } + + public static boolean ensureSpringDevToolSecretToken(JavaProject project) { + Properties properties = SpringBootUtil.getSpringBootApplicationProperties( + SpringBootUtil.getSpringBootActiveProfile(project), + JKubeProjectUtil.getClassLoader(project)); + String remoteSecret = properties.getProperty(DEV_TOOLS_REMOTE_SECRET); + if (Strings.isNullOrEmpty(remoteSecret)) { + addSecretTokenToApplicationProperties(project); + return false; + } + return true; + } + + private static void addSecretTokenToApplicationProperties(JavaProject project) { + String newToken = UUID.randomUUID().toString(); + + // We always add to application.properties, even when an application.yml exists, since both + // files are evaluated by Spring Boot. + appendSecretTokenToFile(project, "target/classes/application.properties", newToken); + appendSecretTokenToFile(project, "src/main/resources/application.properties", newToken); + } + + private static void appendSecretTokenToFile(JavaProject project, String path, String token) { + File file = new File(project.getBaseDirectory(), path); + boolean dirCreated = file.getParentFile().mkdirs(); + if (!dirCreated) { + throw new IllegalStateException("Failure in creating directory " + file.getParentFile().getAbsolutePath()); + } + String text = String.format("%s" + + "# Remote secret added by jkube-kit-plugin\n" + + "%s=%s\n", + file.exists() ? "\n" : "", DEV_TOOLS_REMOTE_SECRET, token); + + try (FileWriter writer = new FileWriter(file, true)) { + writer.append(text); + } catch (IOException e) { + throw new IllegalStateException("Failed to append to file: " + file + ". " + e, e); + } + } + + public static void addDevToolsFilesToFatJar(JavaProject project, FatJarDetector.Result fatJarDetectResult) { + File target = getFatJarFile(fatJarDetectResult); + try { + File devToolsFile = getSpringBootDevToolsJar(project); + File applicationPropertiesFile = new File(project.getBaseDirectory(), "target/classes/application.properties"); + copyFilesToFatJar(Collections.singletonList(devToolsFile), Collections.singletonList(applicationPropertiesFile), target); + } catch (Exception e) { + throw new IllegalStateException("Failed to add devtools files to fat jar " + target + ". " + e, e); + } + } + + private static void copyFilesToFatJar(List libs, List classes, File target) throws IOException { + File tmpZip = File.createTempFile(target.getName(), null); + Files.delete(tmpZip.toPath()); + + // Using Apache commons rename, because renameTo has issues across file systems + FileUtils.moveFile(target, tmpZip); + + byte[] buffer = new byte[8192]; + try (ZipInputStream zin = new ZipInputStream(new FileInputStream(tmpZip)); + ZipOutputStream out = new ZipOutputStream(new FileOutputStream(target))) { + for (ZipEntry ze = zin.getNextEntry(); ze != null; ze = zin.getNextEntry()) { + if (matchesFatJarEntry(libs, ze.getName(), true) || matchesFatJarEntry(classes, ze.getName(), false)) { + continue; + } + out.putNextEntry(ze); + for(int read = zin.read(buffer); read > -1; read = zin.read(buffer)){ + out.write(buffer, 0, read); + } + out.closeEntry(); + } + + for (File lib : libs) { + try (InputStream in = new FileInputStream(lib)) { + out.putNextEntry(createZipEntry(lib, getFatJarFullPath(lib, true))); + for (int read = in.read(buffer); read > -1; read = in.read(buffer)) { + out.write(buffer, 0, read); + } + out.closeEntry(); + } + } + + for (File cls : classes) { + try (InputStream in = new FileInputStream(cls)) { + out.putNextEntry(createZipEntry(cls, getFatJarFullPath(cls, false))); + for (int read = in.read(buffer); read > -1; read = in.read(buffer)) { + out.write(buffer, 0, read); + } + out.closeEntry(); + } + } + } + Files.delete(tmpZip.toPath()); + } + + private static boolean matchesFatJarEntry(List fatJarEntries, String path, boolean lib) { + for (File e : fatJarEntries) { + String fullPath = getFatJarFullPath(e, lib); + if (fullPath.equals(path)) { + return true; + } + } + return false; + } + + private static String getFatJarFullPath(File file, boolean lib) { + if (lib) { + return "BOOT-INF/lib/" + file.getName(); + } + return "BOOT-INF/classes/" + file.getName(); + } + + private static ZipEntry createZipEntry(File file, String fullPath) throws IOException { + ZipEntry entry = new ZipEntry(fullPath); + + byte[] buffer = new byte[8192]; + int bytesRead = -1; + try (InputStream is = new FileInputStream(file)) { + CRC32 crc = new CRC32(); + int size = 0; + while ((bytesRead = is.read(buffer)) != -1) { + crc.update(buffer, 0, bytesRead); + size += bytesRead; + } + entry.setSize(size); + entry.setCompressedSize(size); + entry.setCrc(crc.getValue()); + entry.setMethod(ZipEntry.STORED); + return entry; + } + } + private static File getFatJarFile(FatJarDetector.Result fatJarDetectResult) { + if (fatJarDetectResult == null) { + throw new IllegalStateException("No fat jar built yet. Please ensure that the 'package' phase has run"); + } + return fatJarDetectResult.getArchiveFile(); + } + + private static File getSpringBootDevToolsJar(JavaProject project) { + String version = SpringBootUtil.getSpringBootDevToolsVersion(project) + .orElseThrow(() -> new IllegalStateException("Unable to find the spring-boot version")); + final File devToolsJar = JKubeProjectUtil.resolveArtifact(project, SPRING_BOOT_GROUP_ID, SPRING_BOOT_DEVTOOLS_ARTIFACT_ID, version, "jar"); + if (!devToolsJar.exists()) { + throw new IllegalArgumentException("devtools need to be included in repacked archive, please set to false in plugin configuration"); + } + return devToolsJar; + } +} diff --git a/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/SpringBootGenerator.java b/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/SpringBootGenerator.java index 0b574f880f..db981edc3c 100644 --- a/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/SpringBootGenerator.java +++ b/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/SpringBootGenerator.java @@ -13,44 +13,27 @@ */ package org.eclipse.jkube.springboot.generator; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.Properties; -import java.util.UUID; -import java.util.zip.CRC32; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; -import java.util.zip.ZipOutputStream; import org.eclipse.jkube.generator.api.GeneratorContext; import org.eclipse.jkube.generator.api.GeneratorMode; -import org.eclipse.jkube.generator.javaexec.FatJarDetector; import org.eclipse.jkube.generator.javaexec.JavaExecGenerator; import org.eclipse.jkube.kit.common.Configs; -import org.eclipse.jkube.kit.common.JavaProject; -import org.eclipse.jkube.kit.common.Plugin; import org.eclipse.jkube.kit.common.util.JKubeProjectUtil; import org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper; import org.eclipse.jkube.kit.common.util.SpringBootUtil; import org.eclipse.jkube.kit.config.image.ImageConfiguration; -import com.google.common.base.Strings; import lombok.AllArgsConstructor; import lombok.Getter; -import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import static org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper.DEV_TOOLS_REMOTE_SECRET; -import static org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper.SPRING_BOOT_DEVTOOLS_ARTIFACT_ID; -import static org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper.SPRING_BOOT_GROUP_ID; +import static org.eclipse.jkube.kit.common.util.SpringBootUtil.isSpringBootRepackage; +import static org.eclipse.jkube.springboot.SpringBootDevtoolsUtils.addDevToolsFilesToFatJar; +import static org.eclipse.jkube.springboot.SpringBootDevtoolsUtils.ensureSpringDevToolSecretToken; import static org.eclipse.jkube.springboot.generator.SpringBootGenerator.Config.COLOR; /** @@ -82,9 +65,13 @@ public boolean isApplicable(List configs) { @Override public List customize(List configs, boolean isPrePackagePhase) { if (getContext().getGeneratorMode() == GeneratorMode.WATCH) { - ensureSpringDevToolSecretToken(); - if (!isPrePackagePhase ) { - addDevToolsFilesToFatJar(); + boolean isDevtoolsSecretPresent = ensureSpringDevToolSecretToken(getProject()); + if (!isDevtoolsSecretPresent) { + log.verbose("Generating the spring devtools token in property: " + DEV_TOOLS_REMOTE_SECRET); + throw new IllegalStateException("No spring.devtools.remote.secret found in application.properties. Plugin has added it, please re-run goals"); + } + if (!isPrePackagePhase && isFatJar()) { + addDevToolsFilesToFatJar(getProject(), detectFatJar()); } } return super.customize(configs, isPrePackagePhase); @@ -118,11 +105,13 @@ protected List getExtraJavaOptions() { @Override protected boolean isFatJar() { - if (!hasMainClass() && isSpringBootRepackage()) { + if (!hasMainClass() && isSpringBootRepackage(getProject())) { + log.verbose("Using fat jar packaging as the spring boot plugin is using `repackage` goal execution"); return true; } return super.isFatJar(); } + @Override protected String getDefaultWebPort() { Properties properties = SpringBootUtil.getSpringBootApplicationProperties( @@ -131,165 +120,4 @@ protected String getDefaultWebPort() { SpringBootConfigurationHelper propertyHelper = new SpringBootConfigurationHelper(SpringBootUtil.getSpringBootVersion(getProject())); return properties.getProperty(propertyHelper.getServerPortPropertyKey(), super.getDefaultWebPort()); } - - // ============================================================================= - - private void ensureSpringDevToolSecretToken() { - Properties properties = SpringBootUtil.getSpringBootApplicationProperties( - SpringBootUtil.getSpringBootActiveProfile(getProject()), - JKubeProjectUtil.getClassLoader(getProject())); - String remoteSecret = properties.getProperty(DEV_TOOLS_REMOTE_SECRET); - if (Strings.isNullOrEmpty(remoteSecret)) { - addSecretTokenToApplicationProperties(); - throw new IllegalStateException("No spring.devtools.remote.secret found in application.properties. Plugin has added it, please re-run goals"); - } - } - - private void addDevToolsFilesToFatJar() { - if (isFatJar()) { - File target = getFatJarFile(); - try { - File devToolsFile = getSpringBootDevToolsJar(); - File applicationPropertiesFile = new File(getProject().getBaseDirectory(), "target/classes/application.properties"); - copyFilesToFatJar(Collections.singletonList(devToolsFile), Collections.singletonList(applicationPropertiesFile), target); - } catch (Exception e) { - throw new IllegalStateException("Failed to add devtools files to fat jar " + target + ". " + e, e); - } - } - } - - private File getFatJarFile() { - FatJarDetector.Result fatJarDetectResult = detectFatJar(); - if (fatJarDetectResult == null) { - throw new IllegalStateException("No fat jar built yet. Please ensure that the 'package' phase has run"); - } - return fatJarDetectResult.getArchiveFile(); - } - - private void copyFilesToFatJar(List libs, List classes, File target) throws IOException { - File tmpZip = File.createTempFile(target.getName(), null); - tmpZip.delete(); - - // Using Apache commons rename, because renameTo has issues across file systems - FileUtils.moveFile(target, tmpZip); - - byte[] buffer = new byte[8192]; - try (ZipInputStream zin = new ZipInputStream(new FileInputStream(tmpZip)); - ZipOutputStream out = new ZipOutputStream(new FileOutputStream(target))) { - for (ZipEntry ze = zin.getNextEntry(); ze != null; ze = zin.getNextEntry()) { - if (matchesFatJarEntry(libs, ze.getName(), true) || matchesFatJarEntry(classes, ze.getName(), false)) { - continue; - } - out.putNextEntry(ze); - for(int read = zin.read(buffer); read > -1; read = zin.read(buffer)){ - out.write(buffer, 0, read); - } - out.closeEntry(); - } - - for (File lib : libs) { - try (InputStream in = new FileInputStream(lib)) { - out.putNextEntry(createZipEntry(lib, getFatJarFullPath(lib, true))); - for (int read = in.read(buffer); read > -1; read = in.read(buffer)) { - out.write(buffer, 0, read); - } - out.closeEntry(); - } - } - - for (File cls : classes) { - try (InputStream in = new FileInputStream(cls)) { - out.putNextEntry(createZipEntry(cls, getFatJarFullPath(cls, false))); - for (int read = in.read(buffer); read > -1; read = in.read(buffer)) { - out.write(buffer, 0, read); - } - out.closeEntry(); - } - } - } - tmpZip.delete(); - } - - private boolean matchesFatJarEntry(List fatJarEntries, String path, boolean lib) { - for (File e : fatJarEntries) { - String fullPath = getFatJarFullPath(e, lib); - if (fullPath.equals(path)) { - return true; - } - } - return false; - } - - private String getFatJarFullPath(File file, boolean lib) { - if (lib) { - return "BOOT-INF/lib/" + file.getName(); - } - return "BOOT-INF/classes/" + file.getName(); - } - - private ZipEntry createZipEntry(File file, String fullPath) throws IOException { - ZipEntry entry = new ZipEntry(fullPath); - - byte[] buffer = new byte[8192]; - int bytesRead = -1; - try (InputStream is = new FileInputStream(file)) { - CRC32 crc = new CRC32(); - int size = 0; - while ((bytesRead = is.read(buffer)) != -1) { - crc.update(buffer, 0, bytesRead); - size += bytesRead; - } - entry.setSize(size); - entry.setCompressedSize(size); - entry.setCrc(crc.getValue()); - entry.setMethod(ZipEntry.STORED); - return entry; - } - } - - private void addSecretTokenToApplicationProperties() { - String newToken = UUID.randomUUID().toString(); - log.verbose("Generating the spring devtools token in property: " + DEV_TOOLS_REMOTE_SECRET); - - // We always add to application.properties, even when an application.yml exists, since both - // files are evaluated by Spring Boot. - appendSecretTokenToFile("target/classes/application.properties", newToken); - appendSecretTokenToFile("src/main/resources/application.properties", newToken); - } - - private void appendSecretTokenToFile(String path, String token) { - File file = new File(getProject().getBaseDirectory(), path); - file.getParentFile().mkdirs(); - String text = String.format("%s" + - "# Remote secret added by jkube-kit-plugin\n" + - "%s=%s\n", - file.exists() ? "\n" : "", DEV_TOOLS_REMOTE_SECRET, token); - - try (FileWriter writer = new FileWriter(file, true)) { - writer.append(text); - } catch (IOException e) { - throw new IllegalStateException("Failed to append to file: " + file + ". " + e, e); - } - } - - private boolean isSpringBootRepackage() { - JavaProject project = getProject(); - Plugin plugin = JKubeProjectUtil.getPlugin(project, SpringBootConfigurationHelper.SPRING_BOOT_MAVEN_PLUGIN_ARTIFACT_ID); - if (Optional.ofNullable(plugin).map(Plugin::getExecutions).map(e -> e.contains("repackage")).orElse(false)) { - log.verbose("Using fat jar packaging as the spring boot plugin is using `repackage` goal execution"); - return true; - } - return false; - } - - private File getSpringBootDevToolsJar() { - String version = SpringBootUtil.getSpringBootDevToolsVersion(getProject()) - .orElseThrow(() -> new IllegalStateException("Unable to find the spring-boot version")); - final File devToolsJar = JKubeProjectUtil.resolveArtifact(getProject(), SPRING_BOOT_GROUP_ID, SPRING_BOOT_DEVTOOLS_ARTIFACT_ID, version, "jar"); - if (!devToolsJar.exists()) { - throw new IllegalArgumentException("devtools need to be included in repacked archive, please set to false in plugin configuration"); - } - return devToolsJar; - } - } diff --git a/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/SpringBootDevtoolsUtilsTest.java b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/SpringBootDevtoolsUtilsTest.java new file mode 100644 index 0000000000..5487d97e9a --- /dev/null +++ b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/SpringBootDevtoolsUtilsTest.java @@ -0,0 +1,202 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.springboot; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Objects; +import java.util.jar.Attributes; +import java.util.jar.JarFile; +import java.util.jar.JarOutputStream; +import java.util.jar.Manifest; + +import org.eclipse.jkube.generator.javaexec.FatJarDetector; +import org.eclipse.jkube.kit.common.Dependency; +import org.eclipse.jkube.kit.common.JavaProject; +import org.eclipse.jkube.kit.common.KitLogger; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +class SpringBootDevtoolsUtilsTest { + private KitLogger kitLogger; + + @TempDir + private File temporaryFolder; + + @BeforeEach + void setup() { + kitLogger = spy(new KitLogger.SilentLogger()); + } + + @Test + void ensureSpringDevToolSecretToken_whenNoTokenFound_thenAppendTokenAndThrowException() throws IOException { + // Given + JavaProject javaProject = createSpringBootJavaProject(); + + // When + boolean result = SpringBootDevtoolsUtils.ensureSpringDevToolSecretToken(javaProject); + + // Then + assertThat(result).isFalse(); + Path srcApplicationProperties = temporaryFolder.toPath() + .resolve("src").resolve("main").resolve("resources").resolve("application.properties"); + Path targetApplicationProperties = temporaryFolder.toPath() + .resolve("target").resolve("classes").resolve("application.properties"); + assertThat(new String(Files.readAllBytes(srcApplicationProperties))) + .contains("# Remote secret added by jkube-kit-plugin") + .contains("spring.devtools.remote.secret="); + assertThat(new String(Files.readAllBytes(targetApplicationProperties))) + .contains("# Remote secret added by jkube-kit-plugin") + .contains("spring.devtools.remote.secret="); + } + + @Test + void ensureSpringDevToolSecretToken_whenTokenAlreadyPresent_thenDoNothing() { + // Given + JavaProject javaProject = createSpringBootJavaProject().toBuilder() + .compileClassPathElement(Objects.requireNonNull(getClass().getResource("/devtools-application-properties")).getPath()) + .build(); + + // When + boolean result = SpringBootDevtoolsUtils.ensureSpringDevToolSecretToken(javaProject); + + // Then + assertThat(result).isTrue(); + verify(kitLogger, times(0)).verbose(anyString()); + } + + @Test + void addDevToolsFilesToFatJar_whenNoFatJar_thenThrowException() { + // Given + JavaProject javaProject = createSpringBootJavaProject(); + + // When + Then + assertThatIllegalStateException() + .isThrownBy(() -> SpringBootDevtoolsUtils.addDevToolsFilesToFatJar(javaProject, null)) + .withMessage("No fat jar built yet. Please ensure that the 'package' phase has run"); + } + + @Test + void addDevToolsFilesToFatJar_whenFatJarButNoDevtools_thenThrowException() throws IOException { + // Given + File outputDir = new File(temporaryFolder, "target"); + File fatJar = new File(outputDir, "fat.jar"); + assertThat(outputDir.mkdir()).isTrue(); + assertThat(fatJar.createNewFile()).isTrue(); + JavaProject javaProject = createSpringBootJavaProject(); + FatJarDetector.Result fatJarDetectorResult = mock(FatJarDetector.Result.class); + when(fatJarDetectorResult.getArchiveFile()).thenReturn(fatJar); + + // When + assertThatIllegalStateException() + .isThrownBy(() -> SpringBootDevtoolsUtils.addDevToolsFilesToFatJar(javaProject, fatJarDetectorResult)) + .withMessageContaining("Cannot find artifact spring-boot-devtools-2.7.2.jar within the resolved resources"); + } + + @Test + void addDevToolsFilesToFatJar_whenFatJarButNoDevtoolsJarNotExist_thenThrowException() throws IOException { + // Given + File outputDir = new File(temporaryFolder, "target"); + File fatJar = new File(outputDir, "fat.jar"); + assertThat(outputDir.mkdir()).isTrue(); + assertThat(fatJar.createNewFile()).isTrue(); + FatJarDetector.Result fatJarDetectorResult = mock(FatJarDetector.Result.class); + when(fatJarDetectorResult.getArchiveFile()).thenReturn(fatJar); + JavaProject javaProject = createSpringBootJavaProject().toBuilder() + .dependency(Dependency.builder() + .groupId("org.springframework.boot") + .artifactId("spring-boot-devtools") + .version("2.7.2") + .type("jar") + .file(new File("i-dont-exist.jar")) + .build()) + .build(); + + // When + assertThatIllegalStateException() + .isThrownBy(() -> SpringBootDevtoolsUtils.addDevToolsFilesToFatJar(javaProject, fatJarDetectorResult)) + .withMessageContaining("devtools need to be included in repacked archive, please set to false in plugin configuration"); + } + + @Test + void addDevToolsFilesToFatJar_whenFatJar_thenFatJarUpdatedWithSpringBootDevtoolsJarAndApplicationProperties() throws IOException { + // Given + File outputDir = new File(temporaryFolder, "target"); + File outputClassesDir = new File(outputDir, "classes"); + File outputApplicationProperties = new File(outputClassesDir, "application.properties"); + File fatJar = new File(outputDir, "fat.jar"); + File devtoolsJar = new File(temporaryFolder, "spring-boot-devtools-2.7.2.jar"); + assertThat(outputDir.mkdir()).isTrue(); + assertThat(outputClassesDir.mkdir()).isTrue(); + assertThat(fatJar.createNewFile()).isTrue(); + assertThat(fatJar).isEmpty(); + createDummyJar(fatJar); + assertThat(devtoolsJar.createNewFile()).isTrue(); + assertThat(outputApplicationProperties.createNewFile()).isTrue(); + JavaProject javaProject = createSpringBootJavaProject().toBuilder() + .dependency(Dependency.builder() + .groupId("org.springframework.boot") + .artifactId("spring-boot-devtools") + .version("2.7.2") + .type("jar") + .file(devtoolsJar) + .build()) + .build(); + FatJarDetector.Result fatJarDetectorResult = mock(FatJarDetector.Result.class); + when(fatJarDetectorResult.getArchiveFile()).thenReturn(fatJar); + + // When + SpringBootDevtoolsUtils.addDevToolsFilesToFatJar(javaProject, fatJarDetectorResult); + + // When + Then + assertThat(fatJar).isNotEmpty(); + try (JarFile jarFile = new JarFile(fatJar)) { + assertThat(jarFile.getJarEntry("BOOT-INF/lib/spring-boot-devtools-2.7.2.jar")).isNotNull(); + assertThat(jarFile.getJarEntry("BOOT-INF/classes/application.properties")).isNotNull(); + } + } + + private JavaProject createSpringBootJavaProject() { + return JavaProject.builder() + .baseDirectory(temporaryFolder) + .outputDirectory(temporaryFolder.toPath().resolve("target").toFile()) + .dependency(Dependency.builder() + .groupId("org.springframework.boot") + .artifactId("spring-boot-web") + .version("2.7.2") + .build()) + .build(); + } + + private void createDummyJar(File jarFile) throws IOException { + Manifest manifest = new Manifest(); + manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0"); + manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, "org.example.Foo"); + JarOutputStream jarOutputStream = new JarOutputStream(Files.newOutputStream(jarFile.toPath()), manifest); + jarOutputStream.closeEntry(); + } +} diff --git a/jkube-kit/jkube-kit-spring-boot/src/test/resources/devtools-application-properties/application.properties b/jkube-kit/jkube-kit-spring-boot/src/test/resources/devtools-application-properties/application.properties index 51acd0c109..a9ce5ec549 100644 --- a/jkube-kit/jkube-kit-spring-boot/src/test/resources/devtools-application-properties/application.properties +++ b/jkube-kit/jkube-kit-spring-boot/src/test/resources/devtools-application-properties/application.properties @@ -1 +1 @@ -spring.devtools.remote.secret=some-secret \ No newline at end of file +spring.devtools.remote.secret=some-secret From e40255d7ac51901c94cdad0be47a8f75a7aca57d Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Tue, 18 Jul 2023 07:30:27 +0200 Subject: [PATCH 41/65] ci: codecov analysis with secret token Signed-off-by: Marc Nuri --- .jenkins/pipelines/sonar.Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.jenkins/pipelines/sonar.Jenkinsfile b/.jenkins/pipelines/sonar.Jenkinsfile index 41dd7968b6..a409288e94 100644 --- a/.jenkins/pipelines/sonar.Jenkinsfile +++ b/.jenkins/pipelines/sonar.Jenkinsfile @@ -24,7 +24,9 @@ pipeline { '-Dsonar.pullrequest.branch=${GIT_BRANCH} ' + '-Dsonar.pullrequest.base=master' // CodeCov - sh 'wget -O - https://codecov.io/bash | bash' + withCredentials([string(credentialsId: 'CODECOV_TOKEN', variable: 'CODECOV_TOKEN')]) { + sh 'wget -O - https://codecov.io/bash | bash -s -- -t $CODECOV_TOKEN' + } } } stage('Sonar (main)') { From 6db3af1ecdd7595e4411dccc0872fb4823909536 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Jul 2023 05:47:26 +0000 Subject: [PATCH 42/65] chore(deps): Bump maven-plugin-annotations from 3.6.0 to 3.9.0 Bumps [maven-plugin-annotations](https://github.com/apache/maven-plugin-tools) from 3.6.0 to 3.9.0. - [Release notes](https://github.com/apache/maven-plugin-tools/releases) - [Commits](https://github.com/apache/maven-plugin-tools/compare/maven-plugin-tools-3.6.0...maven-plugin-tools-3.9.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugin-tools:maven-plugin-annotations dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- jkube-kit/parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jkube-kit/parent/pom.xml b/jkube-kit/parent/pom.xml index c0689938b0..661f1f0795 100644 --- a/jkube-kit/parent/pom.xml +++ b/jkube-kit/parent/pom.xml @@ -52,7 +52,7 @@ 3.6.0 3.6.3 3.3.1 - 3.6.0 + 3.9.0 0.2.2 1.0.76 ${version.kubernetes-client} From 67f2824cac61c7c846d4435b7f6a2ef0896ffe48 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Jul 2023 05:35:53 +0000 Subject: [PATCH 43/65] chore(deps): Bump commons-io from 2.8.0 to 2.13.0 Bumps commons-io from 2.8.0 to 2.13.0. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1eced2c925..06ac7ccabd 100644 --- a/pom.xml +++ b/pom.xml @@ -91,7 +91,7 @@ 2.2.0 3.23.1 3.4.0 - 2.8.0 + 2.13.0 6.1.1 2.4.21 31.1-jre From 8078c48186e242e734bf3f0c38b3eeba9835b349 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Jul 2023 23:05:43 +0000 Subject: [PATCH 44/65] chore(deps): Bump version.junit5 from 5.9.2 to 5.9.3 Bumps `version.junit5` from 5.9.2 to 5.9.3. Updates `junit-jupiter-engine` from 5.9.2 to 5.9.3 - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.9.2...r5.9.3) Updates `junit-jupiter-params` from 5.9.2 to 5.9.3 - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.9.2...r5.9.3) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.junit.jupiter:junit-jupiter-params dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 06ac7ccabd..80bac9954d 100644 --- a/pom.xml +++ b/pom.xml @@ -99,7 +99,7 @@ 0.8.10 1.49 2.4.10 - 5.9.2 + 5.9.3 6.7.2 4.2 1.18.28 From cae7cef294f8935b1fd2c753c04ed997a9d36fb7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Jul 2023 23:55:18 +0000 Subject: [PATCH 45/65] chore(deps-dev): Bump assertj-core from 3.23.1 to 3.24.2 Bumps assertj-core from 3.23.1 to 3.24.2. --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 80bac9954d..87c5c8c5e4 100644 --- a/pom.xml +++ b/pom.xml @@ -89,7 +89,7 @@ UTF-8 2.2.2 2.2.0 - 3.23.1 + 3.24.2 3.4.0 2.13.0 6.1.1 From fdc0b310442892e6662c86f5ab8e5638e3ef14c3 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Thu, 20 Jul 2023 10:09:46 +0200 Subject: [PATCH 46/65] ci:fix: license check pipeline recurses into sub-projects Signed-off-by: Marc Nuri --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 87c5c8c5e4..7bb82dfd99 100644 --- a/pom.xml +++ b/pom.xml @@ -142,6 +142,7 @@ ${version.license-maven-plugin} true + true Red Hat, Inc. From 5da6068d7756784aef9569568ee80f98da97e296 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Thu, 20 Jul 2023 11:21:41 +0200 Subject: [PATCH 47/65] chore: update license headers to comply with updated license maven plugin config Signed-off-by: Marc Nuri --- gradle-plugin/it/src/it/autotls/build.gradle | 13 +++++++++++++ gradle-plugin/it/src/it/configmap/build.gradle | 13 +++++++++++++ .../configmap/src/main/java/zero/Application.java | 2 +- .../src/main/java/zero/HelloController.java | 2 +- gradle-plugin/it/src/it/controller/build.gradle | 13 +++++++++++++ gradle-plugin/it/src/it/debug-mode/build.gradle | 13 +++++++++++++ .../src/it/dependency-resources/settings.gradle | 13 +++++++++++++ .../it/src/it/dockerfile-simple/build.gradle | 13 +++++++++++++ gradle-plugin/it/src/it/expose/build.gradle | 13 +++++++++++++ .../src/it/extension-configuration/build.gradle | 13 +++++++++++++ .../src/it/fragments-custom-mapping/build.gradle | 13 +++++++++++++ .../src/main/jkube/first-fl.yaml | 14 ++++++++++++++ .../src/main/jkube/first-mtpl.yaml | 14 ++++++++++++++ .../src/main/jkube/full.yaml | 14 ++++++++++++++ .../src/main/jkube/second-my_template.yml | 14 ++++++++++++++ .../it/src/it/git-annotations/build.gradle | 13 +++++++++++++ .../groovy-dsl-container-resources/build.gradle | 13 +++++++++++++ .../it/src/it/groovy-dsl-image/build.gradle | 13 +++++++++++++ .../it/src/it/helidon-properties/build.gradle | 13 +++++++++++++ .../jkube/it/gradle/helidon/GreetResource.java | 2 +- .../jkube/it/gradle/helidon/GreetingProvider.java | 2 +- .../src/main/resources/META-INF/beans.xml | 15 +++++++++++++++ .../META-INF/microprofile-config.properties | 14 ++++++++++++++ gradle-plugin/it/src/it/helidon/build.gradle | 13 +++++++++++++ .../jkube/it/gradle/helidon/GreetResource.java | 2 +- .../jkube/it/gradle/helidon/GreetingProvider.java | 2 +- .../helidon/src/main/resources/META-INF/beans.xml | 15 +++++++++++++++ .../META-INF/microprofile-config.properties | 14 ++++++++++++++ gradle-plugin/it/src/it/helm-dsl/build.gradle | 13 +++++++++++++ .../it/src/it/helm-fragment-and-dsl/build.gradle | 13 +++++++++++++ .../src/main/jkube/Chart.helm.yaml | 14 ++++++++++++++ .../it/src/it/helm-fragment/build.gradle | 13 +++++++++++++ .../helm-fragment/src/main/jkube/Chart.helm.yaml | 14 ++++++++++++++ .../it/src/it/helm-properties/build.gradle | 13 +++++++++++++ .../it/src/it/helm-properties/gradle.properties | 14 ++++++++++++++ .../it/src/it/helm-zero-config/build.gradle | 13 +++++++++++++ .../it/src/it/imagechangetrigger/build.gradle | 13 +++++++++++++ .../it/src/it/imagepullpolicy/build.gradle | 13 +++++++++++++ gradle-plugin/it/src/it/ingress/build.gradle | 13 +++++++++++++ .../it/src/it/initcontainers/build.gradle | 13 +++++++++++++ .../it/src/it/java-options-env-merge/build.gradle | 13 +++++++++++++ gradle-plugin/it/src/it/metadata/build.gradle | 13 +++++++++++++ .../it/src/it/multi-environments/build.gradle | 13 +++++++++++++ .../it/src/it/multiple-services/build.gradle | 13 +++++++++++++ gradle-plugin/it/src/it/name/build.gradle | 13 +++++++++++++ gradle-plugin/it/src/it/namespace/build.gradle | 13 +++++++++++++ gradle-plugin/it/src/it/openliberty/build.gradle | 13 +++++++++++++ .../tests/gradle/openliberty/HelloController.java | 2 +- .../openliberty/OpenlibertyRestApplication.java | 2 +- .../src/it/probes-groovy-dsl-config/build.gradle | 13 +++++++++++++ .../ProbesGroovyDSLConfigResource.java | 2 +- .../ProbesGroovyDslConfigApplication.java | 2 +- .../it/src/it/project-label/build.gradle | 13 +++++++++++++ .../it/src/it/revisionhistory/build.gradle | 13 +++++++++++++ gradle-plugin/it/src/it/route/build.gradle | 13 +++++++++++++ gradle-plugin/it/src/it/secret-file/build.gradle | 13 +++++++++++++ .../it/src/it/security-hardening/build.gradle | 13 +++++++++++++ gradle-plugin/it/src/it/service/build.gradle | 13 +++++++++++++ .../it/src/it/serviceaccount/build.gradle | 13 +++++++++++++ .../build.gradle | 13 +++++++++++++ .../serviceaccounts-via-groovy-dsl/build.gradle | 13 +++++++++++++ gradle-plugin/it/src/it/simple/build.gradle | 13 +++++++++++++ .../it/src/it/smallrye-health/build.gradle | 13 +++++++++++++ .../it/src/it/smallrye-health/settings.gradle | 13 +++++++++++++ .../jkube/it/gradle/smallrye/HelloServlet.java | 2 +- .../smallrye/health/CDIBasedHealthCheck.java | 2 +- .../smallrye/health/CDIBasedLivenessCheck.java | 2 +- .../smallrye/health/CDIBasedReadinessCheck.java | 2 +- .../smallrye/health/CDIBasedStartupCheck.java | 2 +- .../src/it/spring-boot-with-fragment/build.gradle | 13 +++++++++++++ .../jkube/it/gradle/spring/boot/Application.java | 2 +- gradle-plugin/it/src/it/spring-boot/build.gradle | 13 +++++++++++++ .../jkube/it/gradle/spring/boot/Application.java | 2 +- .../it/src/it/triggersannotation/build.gradle | 13 +++++++++++++ gradle-plugin/it/src/it/vertx/build.gradle | 13 +++++++++++++ .../jkube/it/gradle/vertx/MainVerticle.java | 2 +- .../it/src/it/volume-permission/build.gradle | 13 +++++++++++++ .../jkube/gradle/plugin/tests/AutoTLSIT.java | 2 +- .../jkube/gradle/plugin/tests/ConfigMapIT.java | 2 +- .../jkube/gradle/plugin/tests/DebugModeIT.java | 2 +- .../gradle/plugin/tests/DefaultControllerIT.java | 2 +- .../gradle/plugin/tests/DefaultMetadataIT.java | 2 +- .../plugin/tests/DependencyResourcesIT.java | 2 +- .../gradle/plugin/tests/DockerfileSimpleIT.java | 2 +- .../jkube/gradle/plugin/tests/ExposeIT.java | 2 +- .../jkube/gradle/plugin/tests/FileSecretIT.java | 2 +- .../jkube/gradle/plugin/tests/FragmentsIT.java | 2 +- .../gradle/plugin/tests/GitAnnotationsIT.java | 2 +- .../tests/GroovyDSLContainerResourcesIT.java | 2 +- .../gradle/plugin/tests/GroovyDSLImageIT.java | 2 +- .../jkube/gradle/plugin/tests/HelidonIT.java | 2 +- .../gradle/plugin/tests/HelidonPropertiesIT.java | 2 +- .../eclipse/jkube/gradle/plugin/tests/HelmIT.java | 2 +- .../plugin/tests/ITGradleRunnerExtension.java | 2 +- .../gradle/plugin/tests/ImageChangeTriggerIT.java | 2 +- .../gradle/plugin/tests/ImagePullPolicyIT.java | 2 +- .../jkube/gradle/plugin/tests/IngressIT.java | 2 +- .../gradle/plugin/tests/InitContainersIT.java | 2 +- .../plugin/tests/JavaOptionsEnvMergeIT.java | 2 +- .../tests/KubernetesConfiguredControllerIT.java | 2 +- .../plugin/tests/KubernetesExtensionIT.java | 2 +- .../gradle/plugin/tests/MultiEnvironmentsIT.java | 2 +- .../gradle/plugin/tests/MultipleServicesIT.java | 2 +- .../eclipse/jkube/gradle/plugin/tests/NameIT.java | 2 +- .../jkube/gradle/plugin/tests/NamespaceIT.java | 2 +- .../jkube/gradle/plugin/tests/OpenLibertyIT.java | 2 +- .../tests/OpenShiftConfiguredControllerIT.java | 2 +- .../gradle/plugin/tests/ProbesGroovyDSLIT.java | 2 +- .../jkube/gradle/plugin/tests/ProjectLabelIT.java | 2 +- .../gradle/plugin/tests/ResourceValidationIT.java | 2 +- .../gradle/plugin/tests/RevisionHistoryIT.java | 2 +- .../jkube/gradle/plugin/tests/RouteIT.java | 2 +- .../gradle/plugin/tests/SecurityHardeningIT.java | 2 +- .../gradle/plugin/tests/ServiceAccountIT.java | 2 +- .../tests/ServiceAccountNameViaGroovyDSLIT.java | 2 +- .../jkube/gradle/plugin/tests/ServiceIT.java | 2 +- .../jkube/gradle/plugin/tests/SimpleIT.java | 2 +- .../jkube/gradle/plugin/tests/SmallRyeIT.java | 2 +- .../jkube/gradle/plugin/tests/SpringBootIT.java | 2 +- .../plugin/tests/SpringBootWithFragmentIT.java | 2 +- .../gradle/plugin/tests/TriggersAnnotationIT.java | 2 +- .../jkube/gradle/plugin/tests/VertxIT.java | 2 +- .../gradle/plugin/tests/VolumePermissionIT.java | 2 +- .../jkube/gradle/plugin/AbstractJKubePlugin.java | 2 +- .../eclipse/jkube/gradle/plugin/GradleLogger.java | 2 +- .../eclipse/jkube/gradle/plugin/GradleUtil.java | 2 +- .../eclipse/jkube/gradle/plugin/GroovyUtil.java | 2 +- .../eclipse/jkube/gradle/plugin/JKubePlugin.java | 2 +- .../jkube/gradle/plugin/KubernetesExtension.java | 2 +- .../jkube/gradle/plugin/KubernetesPlugin.java | 2 +- .../gradle/plugin/task/AbstractJKubeTask.java | 2 +- .../jkube/gradle/plugin/task/JKubeTask.java | 2 +- .../gradle/plugin/task/KubernetesApplyTask.java | 2 +- .../gradle/plugin/task/KubernetesBuildTask.java | 2 +- .../plugin/task/KubernetesConfigViewTask.java | 2 +- .../gradle/plugin/task/KubernetesDebugTask.java | 2 +- .../plugin/task/KubernetesHelmPushTask.java | 2 +- .../gradle/plugin/task/KubernetesHelmTask.java | 2 +- .../gradle/plugin/task/KubernetesJKubeTask.java | 2 +- .../gradle/plugin/task/KubernetesLogTask.java | 2 +- .../gradle/plugin/task/KubernetesPushTask.java | 2 +- .../plugin/task/KubernetesRemoteDevTask.java | 2 +- .../plugin/task/KubernetesResourceTask.java | 2 +- .../plugin/task/KubernetesUndeployTask.java | 2 +- .../gradle/plugin/task/KubernetesWatchTask.java | 2 +- .../jkube/gradle/plugin/task/TaskUtil.java | 2 +- .../jkube/gradle/plugin/GradleUtilTest.java | 2 +- .../jkube/gradle/plugin/GroovyUtilTest.java | 2 +- .../jkube/gradle/plugin/JKubePluginTest.java | 2 +- .../plugin/KubernetesExtensionPropertyTest.java | 2 +- .../gradle/plugin/KubernetesExtensionTest.java | 2 +- .../plugin/KubernetesPluginRegisterTaskTest.java | 2 +- .../jkube/gradle/plugin/KubernetesPluginTest.java | 2 +- .../gradle/plugin/TestKubernetesExtension.java | 2 +- .../plugin/task/KubernetesApplyTaskTest.java | 2 +- .../plugin/task/KubernetesBuildTaskTest.java | 2 +- .../plugin/task/KubernetesConfigViewTaskTest.java | 2 +- .../plugin/task/KubernetesDebugTaskTest.java | 2 +- .../plugin/task/KubernetesHelmPushTaskTest.java | 2 +- .../plugin/task/KubernetesHelmTaskTest.java | 2 +- .../gradle/plugin/task/KubernetesLogTaskTest.java | 2 +- .../plugin/task/KubernetesPushTaskTest.java | 2 +- .../plugin/task/KubernetesRemoteDevTaskTest.java | 2 +- .../plugin/task/KubernetesResourceTaskTest.java | 2 +- .../plugin/task/KubernetesUndeployTaskTest.java | 2 +- .../plugin/task/KubernetesWatchTaskTest.java | 2 +- .../plugin/task/TaskEnvironmentExtension.java | 2 +- .../jkube/gradle/plugin/task/TaskUtilTest.java | 2 +- .../jkube/gradle/plugin/OpenShiftExtension.java | 2 +- .../jkube/gradle/plugin/OpenShiftPlugin.java | 2 +- .../gradle/plugin/task/OpenShiftApplyTask.java | 2 +- .../gradle/plugin/task/OpenShiftBuildTask.java | 2 +- .../gradle/plugin/task/OpenShiftDebugTask.java | 2 +- .../gradle/plugin/task/OpenShiftHelmPushTask.java | 2 +- .../gradle/plugin/task/OpenShiftHelmTask.java | 2 +- .../gradle/plugin/task/OpenShiftJKubeTask.java | 2 +- .../gradle/plugin/task/OpenShiftPushTask.java | 2 +- .../plugin/task/OpenShiftRemoteDevTask.java | 2 +- .../gradle/plugin/task/OpenShiftResourceTask.java | 2 +- .../gradle/plugin/task/OpenShiftUndeployTask.java | 2 +- .../gradle/plugin/task/OpenShiftWatchTask.java | 2 +- .../plugin/OpenShiftExtensionPropertyTest.java | 2 +- .../gradle/plugin/OpenShiftExtensionTest.java | 2 +- .../plugin/OpenShiftPluginRegisterTaskTest.java | 2 +- .../jkube/gradle/plugin/OpenShiftPluginTest.java | 2 +- .../gradle/plugin/TestOpenShiftExtension.java | 2 +- .../plugin/task/OpenShiftApplyTaskTest.java | 2 +- .../plugin/task/OpenShiftBuildTaskTest.java | 2 +- .../plugin/task/OpenShiftDebugTaskTest.java | 2 +- .../plugin/task/OpenShiftHelmPushTaskTest.java | 2 +- .../gradle/plugin/task/OpenShiftHelmTaskTest.java | 2 +- .../gradle/plugin/task/OpenShiftPushTaskTest.java | 2 +- .../plugin/task/OpenShiftRemoteDevTaskTest.java | 2 +- .../plugin/task/OpenShiftResourceTaskTest.java | 2 +- .../plugin/task/OpenShiftUndeployTaskTest.java | 2 +- .../plugin/task/OpenShiftWatchTaskTest.java | 2 +- .../plugin/task/TaskEnvironmentExtension.java | 2 +- .../java/org/eclipse/jkube/api/JKubePlugin.java | 2 +- .../jkube/kit/build/api/RegistryContext.java | 2 +- .../build/api/assembly/ArchiverCustomizer.java | 2 +- .../api/assembly/AssemblyConfigurationSource.java | 2 +- .../api/assembly/AssemblyConfigurationUtils.java | 2 +- .../kit/build/api/assembly/AssemblyFiles.java | 2 +- .../kit/build/api/assembly/AssemblyManager.java | 2 +- .../jkube/kit/build/api/assembly/BuildDirs.java | 2 +- .../build/api/assembly/JKubeBuildTarArchiver.java | 2 +- .../jkube/kit/build/api/auth/AuthConfig.java | 2 +- .../jkube/kit/build/api/auth/RegistryAuth.java | 2 +- .../kit/build/api/auth/RegistryAuthConfig.java | 2 +- .../kit/build/api/auth/RegistryAuthHandler.java | 2 +- .../handler/FromConfigRegistryAuthHandler.java | 2 +- .../handler/OpenShiftRegistryAuthHandler.java | 2 +- .../SystemPropertyRegistryAuthHandler.java | 2 +- .../jkube/kit/build/api/helper/BuildUtil.java | 2 +- .../kit/build/api/helper/DockerFileUtil.java | 2 +- .../api/helper/KubernetesConfigAuthUtil.java | 2 +- .../jkube/kit/build/api/helper/RegistryUtil.java | 2 +- .../jkube/kit/build/api/model/Container.java | 2 +- .../kit/build/api/model/ContainerDetails.java | 2 +- .../build/api/model/ContainersListElement.java | 2 +- .../jkube/kit/build/api/model/ExecDetails.java | 2 +- .../jkube/kit/build/api/model/Network.java | 2 +- .../kit/build/api/model/NetworkCreateConfig.java | 2 +- .../kit/build/api/model/NetworksListElement.java | 2 +- .../jkube/kit/build/api/model/PortMapping.java | 2 +- .../kit/build/api/model/VolumeCreateConfig.java | 2 +- .../assembly/AssemblyConfigurationSourceTest.java | 2 +- .../assembly/AssemblyConfigurationUtilsTest.java | 2 +- ...AssemblyManagerCreateDockerTarArchiveTest.java | 2 +- .../build/api/assembly/AssemblyManagerTest.java | 2 +- ...rVerifyAssemblyReferencedInDockerfileTest.java | 2 +- .../kit/build/api/auth/RegistryAuthTest.java | 2 +- .../FromConfigRegistryAuthHandlerTest.java | 2 +- .../handler/OpenShiftRegistryAuthHandlerTest.java | 2 +- .../SystemPropertyRegistryAuthHandlerTest.java | 2 +- .../jkube/kit/build/api/helper/BuildUtilTest.java | 2 +- .../kit/build/api/helper/DockerFileUtilTest.java | 2 +- .../api/helper/KubernetesConfigAuthUtilTest.java | 2 +- .../jkube/kit/build/api/helper/PathTestUtil.java | 2 +- .../kit/build/api/helper/RegistryUtilTest.java | 2 +- .../eclipse/jkube/kit/build/core/GavLabel.java | 2 +- .../kit/build/service/docker/ArchiveService.java | 2 +- .../kit/build/service/docker/BuildService.java | 2 +- .../build/service/docker/ContainerTracker.java | 2 +- .../build/service/docker/DockerAccessFactory.java | 2 +- .../build/service/docker/DockerServiceHub.java | 2 +- .../kit/build/service/docker/ImagePullCache.java | 2 +- .../build/service/docker/ImagePullManager.java | 2 +- .../kit/build/service/docker/QueryService.java | 2 +- .../kit/build/service/docker/RegistryService.java | 2 +- .../kit/build/service/docker/RunService.java | 2 +- .../kit/build/service/docker/VolumeService.java | 2 +- .../kit/build/service/docker/WaitService.java | 2 +- .../kit/build/service/docker/WatchService.java | 2 +- .../build/service/docker/access/BuildOptions.java | 2 +- .../docker/access/ContainerCreateConfig.java | 2 +- .../docker/access/ContainerHostConfig.java | 2 +- .../docker/access/ContainerNetworkingConfig.java | 2 +- .../service/docker/access/CreateImageOptions.java | 2 +- .../build/service/docker/access/DockerAccess.java | 2 +- .../docker/access/DockerAccessException.java | 2 +- .../docker/access/DockerConnectionDetector.java | 2 +- .../service/docker/access/DockerMachine.java | 2 +- .../service/docker/access/ExecException.java | 2 +- .../build/service/docker/access/KeyStoreUtil.java | 2 +- .../build/service/docker/access/UrlBuilder.java | 2 +- .../access/chunked/BuildJsonResponseHandler.java | 2 +- .../access/chunked/EntityStreamReaderUtil.java | 2 +- .../chunked/PullOrPushResponseJsonHandler.java | 2 +- .../access/hc/ApacheHttpClientDelegate.java | 2 +- .../access/hc/DockerAccessWithHcClient.java | 2 +- .../hc/HcChunkedResponseHandlerWrapper.java | 2 +- .../docker/access/hc/http/HttpClientBuilder.java | 2 +- .../access/hc/http/HttpRequestException.java | 2 +- .../hc/unix/UnixConnectionSocketFactory.java | 2 +- .../service/docker/access/hc/unix/UnixSocket.java | 2 +- .../access/hc/unix/UnixSocketClientBuilder.java | 2 +- .../hc/util/AbstractNativeClientBuilder.java | 2 +- .../hc/util/AbstractNativeSocketFactory.java | 2 +- .../docker/access/hc/util/ClientBuilder.java | 2 +- .../service/docker/access/hc/win/NamedPipe.java | 2 +- .../access/hc/win/NamedPipeClientBuilder.java | 2 +- .../hc/win/NpipeConnectionSocketFactory.java | 2 +- .../docker/access/hc/win/NpipeSocketAddress.java | 2 +- .../docker/access/log/DefaultLogCallback.java | 2 +- .../service/docker/access/log/LogCallback.java | 2 +- .../service/docker/access/log/LogDispatcher.java | 2 +- .../service/docker/access/log/LogGetHandle.java | 2 +- .../service/docker/access/log/LogOutputSpec.java | 2 +- .../docker/access/log/LogOutputSpecFactory.java | 2 +- .../service/docker/access/log/LogRequestor.java | 2 +- .../docker/access/log/SharedPrintStream.java | 2 +- .../service/docker/auth/AuthConfigFactory.java | 2 +- .../docker/auth/CredentialHelperClient.java | 2 +- .../docker/auth/DockerRegistryAuthHandler.java | 2 +- .../docker/auth/ecr/AwsSdkAuthConfigFactory.java | 2 +- .../service/docker/auth/ecr/AwsSdkHelper.java | 2 +- .../build/service/docker/auth/ecr/AwsSigner4.java | 2 +- .../docker/auth/ecr/AwsSigner4Request.java | 2 +- .../service/docker/auth/ecr/EcrExtendedAuth.java | 2 +- .../docker/config/DockerMachineConfiguration.java | 2 +- .../docker/config/VolumeConfiguration.java | 2 +- .../config/handler/ExternalConfigHandler.java | 2 +- .../handler/ExternalConfigHandlerException.java | 2 +- .../config/handler/ImageConfigResolver.java | 2 +- .../docker/config/handler/property/ConfigKey.java | 2 +- .../handler/property/PropertyConfigHandler.java | 2 +- .../config/handler/property/PropertyMode.java | 2 +- .../handler/property/ValueCombinePolicy.java | 2 +- .../config/handler/property/ValueProvider.java | 2 +- .../service/docker/helper/AnsiLoggerFacade.java | 2 +- .../build/service/docker/helper/AutoPullMode.java | 2 +- .../build/service/docker/helper/ConfigHelper.java | 2 +- .../docker/helper/ContainerNamingUtil.java | 2 +- .../service/docker/helper/DockerPathUtil.java | 2 +- .../build/service/docker/helper/EnvCommand.java | 2 +- .../docker/helper/FormatParameterReplacer.java | 2 +- .../service/docker/helper/ImageNameFormatter.java | 2 +- .../service/docker/helper/LocalSocketUtil.java | 2 +- .../build/service/docker/helper/RequestUtil.java | 2 +- .../docker/helper/StartContainerExecutor.java | 2 +- .../service/docker/helper/StartOrderResolver.java | 2 +- .../service/docker/helper/SuffixFileFilter.java | 2 +- .../kit/build/service/docker/helper/Task.java | 2 +- .../build/service/docker/helper/Timestamp.java | 2 +- .../service/docker/helper/VolumeBindingUtil.java | 2 +- .../service/docker/wait/ExitCodeChecker.java | 2 +- .../service/docker/wait/HealthCheckChecker.java | 2 +- .../service/docker/wait/HttpPingChecker.java | 2 +- .../service/docker/wait/LogMatchCallback.java | 2 +- .../build/service/docker/wait/LogWaitChecker.java | 2 +- .../docker/wait/LogWaitCheckerCallback.java | 2 +- .../docker/wait/PreconditionFailedException.java | 2 +- .../build/service/docker/wait/TcpPortChecker.java | 2 +- .../build/service/docker/wait/WaitChecker.java | 2 +- .../service/docker/wait/WaitTimeoutException.java | 2 +- .../kit/build/service/docker/wait/WaitUtil.java | 2 +- .../build/service/docker/watch/CopyFilesTask.java | 2 +- .../kit/build/service/docker/watch/ExecTask.java | 2 +- .../build/service/docker/watch/WatchContext.java | 2 +- .../service/docker/watch/WatchException.java | 2 +- .../build/service/docker/BuildServiceTest.java | 2 +- .../service/docker/ImagePullManagerTest.java | 2 +- .../service/docker/RegistryServicePullIT.java | 2 +- .../service/docker/RegistryServicePushIT.java | 2 +- .../build/service/docker/RegistryServiceTest.java | 2 +- .../build/service/docker/WatchServiceTest.java | 2 +- .../service/docker/access/BuildConfigTest.java | 2 +- .../access/KeyStoreUtilLoadPrivateKeyTest.java | 2 +- .../service/docker/access/KeyStoreUtilTest.java | 2 +- .../access/hc/ApacheHttpClientDelegateTest.java | 2 +- .../hc/DockerAccessWithHcClientMockitoTest.java | 2 +- .../access/hc/DockerAccessWithHcClientTest.java | 2 +- .../hc/HcChunkedResponseHandlerWrapperTest.java | 2 +- .../docker/access/hc/unix/UnixSocketTest.java | 2 +- .../docker/auth/AuthConfigFactoryTest.java | 3 +-- .../docker/auth/CredentialHelperClientTest.java | 2 +- .../auth/ecr/AwsSdkAuthConfigFactoryTest.java | 2 +- .../docker/auth/ecr/AwsSigner4RequestTest.java | 2 +- .../auth/ecr/DockerRegistryAuthHandlerTest.java | 2 +- .../docker/auth/ecr/EcrExtendedAuthTest.java | 2 +- .../handler/RegistryServerConfigurationTest.java | 2 +- .../property/PropertyConfigHandlerTest.java | 2 +- .../docker/helper/AnsiLoggerFacadeTest.java | 2 +- .../service/docker/helper/AutoPullModeTest.java | 2 +- .../service/docker/helper/ConfigHelperTest.java | 2 +- .../docker/helper/ImageNameFormatterTest.java | 2 +- .../jkube/kit/service/jib/JibServiceUtil.java | 2 +- .../jkube/kit/service/jib/JibServiceUtilTest.java | 2 +- .../eclipse/jkube/kit/common/ResourceVerify.java | 2 +- .../java/org/eclipse/jkube/maven/it/Verify.java | 2 +- .../factory/NoSuchBeanDefinitionException.java | 2 +- .../jkube/kit/common/ResourceVerifyTest.java | 2 +- .../eclipse/jkube/kit/common/util/AnsiLogger.java | 2 +- .../common/util/MavenConfigurationExtractor.java | 2 +- .../eclipse/jkube/kit/common/util/MavenUtil.java | 2 +- .../kit/common/util/MojoExecutionService.java | 2 +- .../jkube/kit/common/util/MojoParameters.java | 2 +- .../kit/common/util/AnsiLoggerFallbackTest.java | 2 +- .../jkube/kit/common/util/AnsiLoggerTest.java | 2 +- .../util/MavenConfigurationExtractorTest.java | 2 +- .../jkube/kit/common/util/MavenUtilTest.java | 2 +- .../org/eclipse/jkube/kit/common/Arguments.java | 2 +- .../org/eclipse/jkube/kit/common/Assembly.java | 2 +- .../jkube/kit/common/AssemblyConfiguration.java | 2 +- .../eclipse/jkube/kit/common/AssemblyFile.java | 2 +- .../jkube/kit/common/AssemblyFileEntry.java | 2 +- .../eclipse/jkube/kit/common/AssemblyFileSet.java | 2 +- .../eclipse/jkube/kit/common/AssemblyMode.java | 2 +- .../org/eclipse/jkube/kit/common/Configs.java | 2 +- .../eclipse/jkube/kit/common/DebugConstants.java | 2 +- .../org/eclipse/jkube/kit/common/Dependency.java | 2 +- .../eclipse/jkube/kit/common/ExternalCommand.java | 2 +- .../kit/common/IngressControllerDetector.java | 2 +- .../jkube/kit/common/JKubeConfiguration.java | 2 +- .../jkube/kit/common/JKubeFileInterpolator.java | 2 +- .../org/eclipse/jkube/kit/common/JavaProject.java | 2 +- .../org/eclipse/jkube/kit/common/JsonFactory.java | 2 +- .../org/eclipse/jkube/kit/common/KitLogger.java | 2 +- .../org/eclipse/jkube/kit/common/Maintainer.java | 2 +- .../java/org/eclipse/jkube/kit/common/Named.java | 2 +- .../java/org/eclipse/jkube/kit/common/Plugin.java | 2 +- .../eclipse/jkube/kit/common/PrefixedLogger.java | 2 +- .../eclipse/jkube/kit/common/RegistryConfig.java | 2 +- .../kit/common/RegistryServerConfiguration.java | 2 +- .../jkube/kit/common/ResourceFileType.java | 2 +- .../org/eclipse/jkube/kit/common/TimeUtil.java | 2 +- .../kit/common/archive/ArchiveCompression.java | 2 +- .../kit/common/archive/AssemblyFileSetUtils.java | 2 +- .../kit/common/archive/AssemblyFileUtils.java | 2 +- .../kit/common/archive/JKubeTarArchiver.java | 2 +- .../jkube/kit/common/service/MigrateService.java | 2 +- .../eclipse/jkube/kit/common/util/AnsiUtil.java | 2 +- .../jkube/kit/common/util/AsciiDocParser.java | 2 +- .../eclipse/jkube/kit/common/util/AsyncUtil.java | 2 +- .../eclipse/jkube/kit/common/util/Base64Util.java | 2 +- .../kit/common/util/BuildReferenceDateUtil.java | 2 +- .../eclipse/jkube/kit/common/util/ClassUtil.java | 2 +- .../jkube/kit/common/util/CommandLine.java | 2 +- .../jkube/kit/common/util/DekorateUtil.java | 2 +- .../eclipse/jkube/kit/common/util/EnvUtil.java | 2 +- .../jkube/kit/common/util/Fabric8HttpUtil.java | 2 +- .../eclipse/jkube/kit/common/util/FileUtil.java | 2 +- .../eclipse/jkube/kit/common/util/GitUtil.java | 2 +- .../org/eclipse/jkube/kit/common/util/IoUtil.java | 2 +- .../jkube/kit/common/util/JKubeProjectUtil.java | 2 +- .../kit/common/util/KindFilenameMapperUtil.java | 2 +- .../jkube/kit/common/util/KubernetesHelper.java | 2 +- .../jkube/kit/common/util/LazyBuilder.java | 2 +- .../eclipse/jkube/kit/common/util/MapUtil.java | 2 +- .../jkube/kit/common/util/OpenshiftHelper.java | 2 +- .../kit/common/util/PluginServiceFactory.java | 2 +- .../eclipse/jkube/kit/common/util/PodHelper.java | 2 +- .../kit/common/util/ProjectClassLoaders.java | 2 +- .../kit/common/util/PropertiesMappingParser.java | 2 +- .../jkube/kit/common/util/PropertiesUtil.java | 2 +- .../jkube/kit/common/util/ResourceClassifier.java | 2 +- .../jkube/kit/common/util/ResourceUtil.java | 2 +- .../kit/common/util/SemanticVersionUtil.java | 2 +- .../jkube/kit/common/util/Serialization.java | 2 +- .../jkube/kit/common/util/Slf4jKitLogger.java | 2 +- .../util/SpringBootConfigurationHelper.java | 2 +- .../jkube/kit/common/util/SpringBootUtil.java | 2 +- .../jkube/kit/common/util/TemplateUtil.java | 2 +- .../jkube/kit/common/util/ThorntailUtil.java | 2 +- .../kit/common/util/UserConfigurationCompare.java | 2 +- .../jkube/kit/common/util/ValidationUtil.java | 2 +- .../eclipse/jkube/kit/common/util/XMLUtil.java | 2 +- .../eclipse/jkube/kit/common/util/YamlUtil.java | 2 +- .../util/validator/IgnorePortValidationRule.java | 2 +- .../validator/IgnoreResourceMemoryLimitRule.java | 2 +- .../common/util/validator/ResourceValidator.java | 2 +- .../kit/common/util/validator/ValidationRule.java | 2 +- .../eclipse/jkube/kit/common/ArgumentsTest.java | 2 +- .../kit/common/AssemblyConfigurationTest.java | 2 +- .../jkube/kit/common/ConfigsAsBooleanTest.java | 2 +- .../org/eclipse/jkube/kit/common/ConfigsTest.java | 2 +- .../jkube/kit/common/JKubeConfigurationTest.java | 2 +- .../kit/common/JKubeFileInterpolatorTest.java | 2 +- .../eclipse/jkube/kit/common/JavaProjectTest.java | 2 +- .../eclipse/jkube/kit/common/MaintainerTest.java | 2 +- .../jkube/kit/common/RegistryConfigTest.java | 2 +- .../jkube/kit/common/TestHttpStaticServer.java | 2 +- .../archive/AssemblyFileSetUtilsExcludesTest.java | 2 +- ...blyFileSetUtilsProcessAssemblyFileSetTest.java | 2 +- .../common/archive/AssemblyFileSetUtilsTest.java | 2 +- .../kit/common/archive/AssemblyFileUtilsTest.java | 2 +- .../kit/common/archive/JKubeTarArchiverTest.java | 2 +- .../kit/common/assertj/ArchiveAssertions.java | 2 +- .../jkube/kit/common/assertj/FileAssertions.java | 2 +- .../kit/common/service/MigrateServiceTest.java | 2 +- .../jkube/kit/common/util/AsciiDocParserTest.java | 2 +- .../jkube/kit/common/util/AsyncUtilTest.java | 2 +- .../jkube/kit/common/util/Base64UtilTest.java | 2 +- .../common/util/BuildReferenceDateUtilTest.java | 2 +- .../jkube/kit/common/util/ClassUtilTest.java | 2 +- .../jkube/kit/common/util/CommandlineTest.java | 2 +- .../jkube/kit/common/util/DekorateUtilTest.java | 2 +- .../jkube/kit/common/util/EnvUtilTest.java | 2 +- .../kit/common/util/Fabric8HttpUtilTest.java | 2 +- .../jkube/kit/common/util/FileUtilTest.java | 2 +- .../eclipse/jkube/kit/common/util/IoUtilTest.java | 2 +- .../kit/common/util/JKubeProjectUtilTest.java | 2 +- .../common/util/KindFilenameMapperUtilTest.java | 2 +- .../kit/common/util/KubernetesHelperTest.java | 2 +- .../jkube/kit/common/util/LazyBuilderTest.java | 2 +- .../jkube/kit/common/util/MapUtilTest.java | 2 +- .../common/util/OpenshiftHelperStatusTest.java | 2 +- .../kit/common/util/OpenshiftHelperTest.java | 2 +- .../PluginServiceFactoryNestedContextTest.java | 2 +- .../kit/common/util/PluginServiceFactoryTest.java | 2 +- .../jkube/kit/common/util/PodHelperTest.java | 2 +- .../kit/common/util/ProjectClassLoadersTest.java | 2 +- .../common/util/PropertiesMappingParserTest.java | 2 +- .../jkube/kit/common/util/PropertiesUtilTest.java | 2 +- .../jkube/kit/common/util/ResourceUtilTest.java | 2 +- .../kit/common/util/SemanticVersionUtilTest.java | 2 +- .../jkube/kit/common/util/SerializationTest.java | 2 +- .../jkube/kit/common/util/Slf4jKitLoggerTest.java | 2 +- .../util/SpringBootConfigurationHelperTest.java | 2 +- .../jkube/kit/common/util/SpringBootUtilTest.java | 2 +- .../jkube/kit/common/util/TemplateUtilTest.java | 2 +- .../kit/common/util/TestFabric8HttpResponse.java | 2 +- .../jkube/kit/common/util/ThorntailUtilTest.java | 2 +- .../common/util/UserConfigurationCompareTest.java | 2 +- .../jkube/kit/common/util/XMLUtilTest.java | 2 +- .../jkube/kit/common/util/YamlUtilTest.java | 2 +- .../kit/common/util/mainclass/one/sub/Bogus1.java | 2 +- .../kit/common/util/mainclass/one/sub/Bogus2.java | 2 +- .../kit/common/util/mainclass/one/sub/Bogus3.java | 2 +- .../common/util/mainclass/one/sub/OneMain.java | 2 +- .../kit/common/util/mainclass/two/OneMain.java | 2 +- .../two/another/sub/a/bit/deeper/TwoMain.java | 2 +- .../kit/common/util/mainclass/zero/Bogus.java | 2 +- .../util/validator/ResourceValidatorTest.java | 2 +- .../kit/config/image/ImageConfiguration.java | 2 +- .../eclipse/jkube/kit/config/image/ImageName.java | 2 +- .../jkube/kit/config/image/LogConfiguration.java | 2 +- .../jkube/kit/config/image/NetworkConfig.java | 2 +- .../jkube/kit/config/image/RestartPolicy.java | 2 +- .../kit/config/image/RunImageConfiguration.java | 2 +- .../kit/config/image/RunVolumeConfiguration.java | 2 +- .../jkube/kit/config/image/UlimitConfig.java | 2 +- .../jkube/kit/config/image/WaitConfiguration.java | 2 +- .../kit/config/image/WatchImageConfiguration.java | 2 +- .../eclipse/jkube/kit/config/image/WatchMode.java | 2 +- .../config/image/build/BuildConfiguration.java | 2 +- .../config/image/build/BuildImageSelectMode.java | 2 +- .../jkube/kit/config/image/build/CleanupMode.java | 2 +- .../kit/config/image/build/DockerFileBuilder.java | 2 +- .../kit/config/image/build/DockerFileKeyword.java | 2 +- .../kit/config/image/build/DockerFileOption.java | 2 +- .../image/build/HealthCheckConfiguration.java | 2 +- .../kit/config/image/build/HealthCheckMode.java | 2 +- .../kit/config/image/build/ImagePullPolicy.java | 2 +- .../config/image/build/JKubeBuildStrategy.java | 2 +- .../image/build/RegistryAuthConfiguration.java | 2 +- .../image/build/util/BuildLabelAnnotations.java | 2 +- .../kit/config/image/ImageConfigurationTest.java | 2 +- .../config/image/ImageNameFullNameParseTest.java | 2 +- .../jkube/kit/config/image/ImageNameTest.java | 2 +- .../image/build/BuildConfigurationTest.java | 2 +- .../kit/config/image/build/CleanupModeTest.java | 2 +- .../config/image/build/DockerFileBuilderTest.java | 2 +- .../config/image/build/HealthCheckConfigTest.java | 2 +- .../jkube/kit/config/access/ClusterAccess.java | 2 +- .../kit/config/access/ClusterConfiguration.java | 2 +- .../kit/config/resource/BuildRecreateMode.java | 2 +- .../jkube/kit/config/resource/ConfigMap.java | 2 +- .../jkube/kit/config/resource/ConfigMapEntry.java | 2 +- .../config/resource/ContainerResourcesConfig.java | 2 +- .../config/resource/ControllerResourceConfig.java | 2 +- .../kit/config/resource/EnricherManager.java | 2 +- .../kit/config/resource/GroupArtifactVersion.java | 2 +- .../jkube/kit/config/resource/IngressConfig.java | 2 +- .../kit/config/resource/IngressRuleConfig.java | 2 +- .../config/resource/IngressRulePathConfig.java | 2 +- .../resource/IngressRulePathResourceConfig.java | 2 +- .../kit/config/resource/IngressTlsConfig.java | 2 +- .../kit/config/resource/InitContainerConfig.java | 2 +- .../kit/config/resource/JKubeAnnotations.java | 2 +- .../jkube/kit/config/resource/MappingConfig.java | 2 +- .../jkube/kit/config/resource/MetaDataConfig.java | 2 +- .../jkube/kit/config/resource/MetricsConfig.java | 2 +- .../kit/config/resource/OpenShiftAnnotations.java | 2 +- .../jkube/kit/config/resource/PlatformMode.java | 2 +- .../jkube/kit/config/resource/ProbeConfig.java | 2 +- .../kit/config/resource/ProcessorConfig.java | 2 +- .../jkube/kit/config/resource/ResourceConfig.java | 2 +- .../kit/config/resource/ResourceService.java | 2 +- .../config/resource/ResourceServiceConfig.java | 2 +- .../kit/config/resource/ResourceVersioning.java | 2 +- .../jkube/kit/config/resource/RuntimeMode.java | 2 +- .../jkube/kit/config/resource/SecretConfig.java | 2 +- .../kit/config/resource/ServiceAccountConfig.java | 2 +- .../jkube/kit/config/resource/ServiceConfig.java | 2 +- .../kit/config/resource/ServiceProtocol.java | 2 +- .../jkube/kit/config/resource/VolumeConfig.java | 2 +- .../jkube/kit/config/resource/VolumeType.java | 2 +- .../kit/config/access/ClusterAccessTest.java | 2 +- .../config/access/ClusterConfigurationTest.java | 2 +- .../resource/ContainerResourcesConfigTest.java | 2 +- .../resource/ControllerResourceConfigTest.java | 2 +- .../kit/config/resource/IngressConfigTest.java | 2 +- .../config/resource/InitContainerConfigTest.java | 2 +- .../kit/config/resource/JKubeAnnotationsTest.java | 2 +- .../kit/config/resource/MappingConfigTest.java | 2 +- .../kit/config/resource/ProcessorConfigTest.java | 2 +- .../kit/config/resource/ResourceConfigTest.java | 2 +- .../config/resource/ResourceVersioningTest.java | 2 +- .../config/service/AbstractImageBuildService.java | 2 +- .../jkube/kit/config/service/ApplyService.java | 2 +- .../jkube/kit/config/service/BuildService.java | 2 +- .../kit/config/service/BuildServiceConfig.java | 2 +- .../kit/config/service/BuildServiceManager.java | 2 +- .../jkube/kit/config/service/DebugService.java | 2 +- .../kit/config/service/JKubeServiceException.java | 2 +- .../jkube/kit/config/service/JKubeServiceHub.java | 2 +- .../jkube/kit/config/service/PatchService.java | 2 +- .../jkube/kit/config/service/PodLogService.java | 2 +- .../kit/config/service/PortForwardService.java | 2 +- .../jkube/kit/config/service/UndeployService.java | 2 +- .../ContourIngressControllerDetector.java | 2 +- .../IngressControllerDetectorManager.java | 2 +- .../KongIngressControllerDetector.java | 2 +- .../NginxIngressControllerDetector.java | 2 +- .../OpenShiftIngressControllerDetector.java | 2 +- .../service/kubernetes/DockerBuildService.java | 2 +- .../service/kubernetes/JibBuildService.java | 2 +- .../service/kubernetes/KubernetesClientUtil.java | 2 +- .../kubernetes/KubernetesUndeployService.java | 2 +- .../service/openshift/ImageStreamService.java | 2 +- .../openshift/OpenShiftBuildServiceUtils.java | 2 +- .../service/openshift/OpenshiftBuildService.java | 2 +- .../openshift/OpenshiftUndeployService.java | 2 +- .../service/plugins/DefaultPluginService.java | 2 +- .../kit/config/service/plugins/PluginManager.java | 2 +- .../kit/config/service/plugins/PluginService.java | 2 +- .../service/portforward/PortForwardMonitor.java | 2 +- .../portforward/PortForwardPodWatcher.java | 2 +- .../service/portforward/PortForwardTask.java | 2 +- .../kit/config/service/ApplyServiceTest.java | 3 +-- .../kit/config/service/DebugServiceTest.java | 2 +- .../service/JKubeServiceHubBuildServiceTest.java | 2 +- .../kit/config/service/JKubeServiceHubTest.java | 2 +- .../kit/config/service/PatchServiceTest.java | 2 +- .../service/PortForwardServicePortOrderTest.java | 2 +- .../config/service/PortForwardServiceTest.java | 3 +-- .../ContourIngressControllerDetectorTest.java | 2 +- .../IngressControllerDetectorManagerTest.java | 2 +- .../KongIngressControllerDetectorTest.java | 2 +- .../NginxIngressControllerDetectorTest.java | 2 +- .../OpenShiftIngressControllerDetectorTest.java | 2 +- .../kubernetes/DockerBuildServiceTest.java | 2 +- .../JibBuildServiceBuildIntegrationTest.java | 2 +- .../JibBuildServiceGetApplicableRegistryTest.java | 2 +- .../service/kubernetes/JibBuildServiceTest.java | 2 +- .../kubernetes/KubernetesClientUtilTest.java | 2 +- .../kubernetes/KubernetesUndeployServiceTest.java | 3 +-- .../service/openshift/ImageStreamServiceTest.java | 2 +- .../openshift/OpenShiftBuildServiceTest.java | 2 +- .../openshift/OpenShiftBuildServiceUtilsTest.java | 2 +- .../OpenshiftBuildServiceIntegrationTest.java | 2 +- .../openshift/OpenshiftUndeployServiceTest.java | 2 +- .../openshift/WebServerEventCollector.java | 2 +- .../config/service/plugins/PluginManagerTest.java | 2 +- .../config/service/plugins/PluginServiceTest.java | 2 +- .../portforward/PortForwardMonitorTest.java | 2 +- .../portforward/PortForwardPodWatcherTest.java | 2 +- .../service/portforward/PortForwardTaskTest.java | 2 +- .../jkube/kit/enricher/api/BaseEnricher.java | 2 +- .../kit/enricher/api/DefaultEnricherManager.java | 2 +- .../eclipse/jkube/kit/enricher/api/Enricher.java | 2 +- .../jkube/kit/enricher/api/EnricherConfig.java | 2 +- .../jkube/kit/enricher/api/EnricherContext.java | 2 +- .../kit/enricher/api/JKubeEnricherContext.java | 2 +- .../jkube/kit/enricher/api/ServiceExposer.java | 2 +- .../kit/enricher/api/model/Configuration.java | 2 +- .../jkube/kit/enricher/api/model/Dependency.java | 2 +- .../jkube/kit/enricher/api/model/KindAndName.java | 2 +- .../jkube/kit/enricher/api/util/Constants.java | 2 +- .../jkube/kit/enricher/api/util/GoTimeUtil.java | 2 +- .../api/util/KubernetesResourceFragments.java | 2 +- .../enricher/api/util/KubernetesResourceUtil.java | 2 +- .../eclipse/jkube/kit/enricher/api/util/Misc.java | 2 +- .../kit/enricher/api/util/SecretConstants.java | 2 +- .../kit/enricher/api/visitor/MetadataVisitor.java | 2 +- .../kit/enricher/handler/ContainerHandler.java | 2 +- .../kit/enricher/handler/ControllerHandler.java | 2 +- .../handler/ControllerHandlerLazyBuilder.java | 2 +- .../kit/enricher/handler/CronJobHandler.java | 2 +- .../kit/enricher/handler/DaemonSetHandler.java | 2 +- .../enricher/handler/DeploymentConfigHandler.java | 2 +- .../kit/enricher/handler/DeploymentHandler.java | 2 +- .../jkube/kit/enricher/handler/HandlerHub.java | 2 +- .../jkube/kit/enricher/handler/JobHandler.java | 2 +- .../kit/enricher/handler/NamespaceHandler.java | 2 +- .../kit/enricher/handler/PodTemplateHandler.java | 2 +- .../jkube/kit/enricher/handler/ProbeHandler.java | 2 +- .../kit/enricher/handler/ProjectHandler.java | 2 +- .../kit/enricher/handler/ReplicaSetHandler.java | 2 +- .../handler/ReplicationControllerHandler.java | 2 +- .../kit/enricher/handler/ServiceHandler.java | 2 +- .../kit/enricher/handler/StatefulSetHandler.java | 2 +- .../api/BaseEnricherGetReplicaCountTest.java | 2 +- .../jkube/kit/enricher/api/BaseEnricherTest.java | 2 +- .../enricher/api/DefaultEnricherManagerTest.java | 2 +- .../kit/enricher/api/EnricherConfigTest.java | 2 +- .../enricher/api/JKubeEnricherContextTest.java | 2 +- .../kit/enricher/api/ServiceExposerTest.java | 2 +- .../kit/enricher/api/model/KindAndNameTest.java | 2 +- .../kit/enricher/api/util/GoTimeUtilTest.java | 2 +- .../api/util/KubernetesResourceFragmentsTest.java | 2 +- .../api/util/KubernetesResourceUtilTest.java | 2 +- .../enricher/api/visitor/MetadataVisitorTest.java | 2 +- .../enricher/handler/ContainerHandlerTest.java | 2 +- .../kit/enricher/handler/CronJobHandlerTest.java | 2 +- .../enricher/handler/DaemonSetHandlerTest.java | 2 +- .../handler/DeploymentConfigHandlerTest.java | 2 +- .../enricher/handler/DeploymentHandlerTest.java | 2 +- .../handler/HandlerHubControllerTest.java | 2 +- .../kit/enricher/handler/HandlerHubTest.java | 2 +- .../kit/enricher/handler/JobHandlerTest.java | 2 +- .../enricher/handler/PodTemplateHandlerTest.java | 2 +- .../enricher/handler/ProbeHandlerHTTPUrlTest.java | 2 +- .../kit/enricher/handler/ProbeHandlerTest.java | 2 +- .../enricher/handler/ReplicaSetHandlerTest.java | 2 +- .../handler/ReplicationControllerHandlerTest.java | 2 +- .../kit/enricher/handler/ServiceHandlerTest.java | 2 +- .../enricher/handler/StatefulSetHandlerTest.java | 2 +- .../jkube/enricher/generic/ConfigMapEnricher.java | 2 +- .../ContainerEnvJavaOptionsMergeEnricher.java | 2 +- .../ControllerViaPluginConfigurationEnricher.java | 2 +- .../jkube/enricher/generic/DebugEnricher.java | 2 +- .../generic/DefaultControllerEnricher.java | 2 +- .../enricher/generic/DefaultMetadataEnricher.java | 2 +- .../generic/DefaultNamespaceEnricher.java | 2 +- .../enricher/generic/DefaultServiceEnricher.java | 2 +- .../enricher/generic/DependencyEnricher.java | 2 +- .../generic/DockerRegistrySecretEnricher.java | 2 +- .../enricher/generic/FileDataSecretEnricher.java | 2 +- .../jkube/enricher/generic/GitEnricher.java | 2 +- .../jkube/enricher/generic/ImageEnricher.java | 2 +- .../enricher/generic/ImagePullPolicyEnricher.java | 2 +- .../jkube/enricher/generic/IngressEnricher.java | 2 +- .../generic/MavenIssueManagementEnricher.java | 2 +- .../jkube/enricher/generic/MavenScmEnricher.java | 2 +- .../jkube/enricher/generic/NameEnricher.java | 2 +- ...PersistentVolumeClaimStorageClassEnricher.java | 2 +- .../enricher/generic/PodAnnotationEnricher.java | 2 +- .../jkube/enricher/generic/PortNameEnricher.java | 2 +- .../enricher/generic/ProjectLabelEnricher.java | 2 +- .../enricher/generic/ReplicaCountEnricher.java | 2 +- .../enricher/generic/RevisionHistoryEnricher.java | 2 +- .../jkube/enricher/generic/SecretEnricher.java | 2 +- .../generic/SecurityHardeningEnricher.java | 2 +- .../enricher/generic/ServiceAccountEnricher.java | 2 +- .../generic/TriggersAnnotationEnricher.java | 2 +- .../generic/VolumePermissionEnricher.java | 2 +- .../ExtensionsV1beta1IngressConverter.java | 2 +- .../ingress/NetworkingV1IngressGenerator.java | 2 +- .../generic/openshift/AutoTLSEnricher.java | 2 +- .../openshift/DeploymentConfigEnricher.java | 2 +- .../openshift/ImageChangeTriggerEnricher.java | 2 +- .../generic/openshift/ProjectEnricher.java | 2 +- .../enricher/generic/openshift/RouteEnricher.java | 2 +- .../enricher/generic/ConfigMapEnricherTest.java | 2 +- .../generic/ContainerEnvJavaOptionsMergeTest.java | 2 +- .../ContainerEnvJavaOptionsMergeVisitorTest.java | 2 +- ...trollerViaPluginConfigurationEnricherTest.java | 2 +- .../jkube/enricher/generic/DebugEnricherTest.java | 2 +- .../DefaultControllerEnricherCreateTest.java | 2 +- .../generic/DefaultControllerEnricherTest.java | 2 +- .../generic/DefaultMetadataEnricherTest.java | 2 +- .../generic/DefaultNamespaceEnricherTest.java | 2 +- ...DefaultServiceEnricherAddMissingPartsTest.java | 2 +- ...DefaultServiceEnricherExternalServiceTest.java | 2 +- .../generic/DefaultServiceEnricherTest.java | 2 +- .../enricher/generic/DependencyEnricherTest.java | 2 +- .../generic/DockerRegistrySecretEnricherTest.java | 2 +- .../generic/FileDataSecretEnricherTest.java | 2 +- .../jkube/enricher/generic/GitEnricherTest.java | 2 +- .../jkube/enricher/generic/ImageEnricherTest.java | 2 +- .../generic/ImagePullPolicyEnricherTest.java | 2 +- .../generic/IngressEnricherBehavioralTest.java | 2 +- .../enricher/generic/IngressEnricherTest.java | 2 +- .../generic/MavenIssueManagementEnricherTest.java | 2 +- .../generic/MavenProjectEnricherTest.java | 2 +- .../enricher/generic/MavenScmEnricherTest.java | 2 +- .../jkube/enricher/generic/NameEnricherTest.java | 2 +- ...istentVolumeClaimStorageClassEnricherTest.java | 2 +- .../generic/PodAnnotationEnricherTest.java | 2 +- .../enricher/generic/PortNameEnricherTest.java | 2 +- .../generic/ProjectLabelEnricherTest.java | 2 +- .../generic/ReplicaCountEnricherTest.java | 2 +- .../generic/RevisionHistoryEnricherTest.java | 2 +- .../generic/SecurityHardeningEnricherTest.java | 2 +- .../generic/ServiceAccountEnricherTest.java | 2 +- .../generic/TriggersAnnotationEnricherTest.java | 2 +- .../generic/VolumePermissionEnricherTest.java | 2 +- .../ExtensionsV1Beta1IngressConverterTest.java | 2 +- .../ingress/NetworkingV1IngressGeneratorTest.java | 2 +- .../generic/openshift/AutoTLSEnricherTest.java | 2 +- .../openshift/DeploymentConfigEnricherTest.java | 2 +- .../openshift/ImageChangeTriggerEnricherTest.java | 2 +- .../generic/openshift/ProjectEnricherTest.java | 2 +- .../openshift/RouteEnricherBehavioralTest.java | 2 +- .../generic/openshift/RouteEnricherTest.java | 2 +- .../specific/AbstractHealthCheckEnricher.java | 2 +- .../specific/DockerHealthCheckEnricher.java | 2 +- .../specific/KarafHealthCheckEnricher.java | 2 +- .../kit/enricher/specific/PrometheusEnricher.java | 2 +- .../specific/ServiceDiscoveryEnricher.java | 2 +- .../specific/WebAppHealthCheckEnricher.java | 2 +- .../specific/AbstractHealthCheckEnricherTest.java | 2 +- .../specific/DockerHealthCheckEnricherTest.java | 2 +- .../enricher/specific/PrometheusEnricherTest.java | 2 +- .../specific/ServiceDiscoveryEnricherTest.java | 2 +- .../specific/WebAppHealthCheckEnricherTest.java | 2 +- .../jkube/generator/api/DefaultImageLookup.java | 2 +- .../eclipse/jkube/generator/api/FromSelector.java | 2 +- .../eclipse/jkube/generator/api/Generator.java | 2 +- .../jkube/generator/api/GeneratorConfig.java | 2 +- .../jkube/generator/api/GeneratorContext.java | 2 +- .../jkube/generator/api/GeneratorManager.java | 2 +- .../jkube/generator/api/GeneratorMode.java | 2 +- .../jkube/generator/api/PortsExtractor.java | 2 +- .../api/support/AbstractPortsExtractor.java | 2 +- .../generator/api/support/BaseGenerator.java | 2 +- .../jkube/generator/api/FromSelectorTest.java | 2 +- .../jkube/generator/api/GeneratorManagerTest.java | 2 +- .../api/support/AbstractPortsExtractorTest.java | 2 +- .../generator/api/support/BaseGeneratorTest.java | 2 +- .../jkube/generator/javaexec/FatJarDetector.java | 2 +- .../generator/javaexec/JavaExecGenerator.java | 2 +- .../generator/javaexec/MainClassDetector.java | 2 +- .../generator/javaexec/FatJarDetectorTest.java | 2 +- .../JavaExecGeneratorCustomPropertiesTest.java | 2 +- ...vaExecGeneratorMainClassDeterminationTest.java | 2 +- .../generator/javaexec/JavaExecGeneratorTest.java | 2 +- .../generator/javaexec/JavaRunGeneratorTest.java | 2 +- .../jkube/generator/karaf/KarafGenerator.java | 2 +- .../jkube/generator/karaf/KarafGeneratorTest.java | 2 +- .../jkube/generator/webapp/AppServerDetector.java | 2 +- .../jkube/generator/webapp/AppServerHandler.java | 2 +- .../jkube/generator/webapp/WebAppGenerator.java | 2 +- .../webapp/handler/AbstractAppServerHandler.java | 2 +- .../webapp/handler/CustomAppServerHandler.java | 2 +- .../webapp/handler/JettyAppSeverHandler.java | 2 +- .../webapp/handler/TomcatAppSeverHandler.java | 2 +- .../webapp/handler/WildFlyAppSeverHandler.java | 2 +- .../webapp/AppServerAutoDetectionTest.java | 2 +- .../generator/webapp/WebAppGeneratorTest.java | 2 +- .../webapp/handler/JettyAppServerHandlerTest.java | 2 +- .../handler/TomcatAppServerHandlerTest.java | 2 +- .../handler/WildFlyAppServerHandlerTest.java | 2 +- jkube-kit/jkube-kit-helidon/pom.xml | 15 +++++++++++++++ .../enricher/HelidonHealthCheckEnricher.java | 2 +- .../generator/AbstractHelidonNestedGenerator.java | 2 +- .../helidon/generator/HelidonNestedGenerator.java | 2 +- .../jkube/helidon/generator/NativeGenerator.java | 2 +- .../helidon/generator/StandardGenerator.java | 2 +- .../enricher/HelidonHealthCheckEnricherTest.java | 2 +- .../eclipse/jkube/micronaut/MicronautUtils.java | 2 +- .../enricher/MicronautHealthCheckEnricher.java | 2 +- .../micronaut/generator/MicronautGenerator.java | 2 +- ...cronautUtilsGetMicronautConfigurationTest.java | 2 +- .../jkube/micronaut/MicronautUtilsTest.java | 2 +- .../MicronautHealthCheckEnricherTest.java | 2 +- .../generator/MicronautGeneratorTest.java | 2 +- .../microprofile/MicroprofileHealthUtil.java | 2 +- .../AbstractMicroprofileHealthCheckEnricher.java | 2 +- .../microprofile/MicroprofileHealthUtilTest.java | 2 +- ...stractMicroprofileHealthCheckEnricherTest.java | 2 +- .../jkube/openliberty/OpenLibertyUtils.java | 2 +- .../enricher/OpenLibertyHealthCheckEnricher.java | 2 +- .../generator/OpenLibertyGenerator.java | 2 +- .../jkube/openliberty/OpenLibertyUtilsTest.java | 2 +- .../OpenLibertyHealthCheckEnricherTest.java | 2 +- .../OpenLibertyGeneratorIsApplicableTest.java | 2 +- .../generator/OpenLibertyGeneratorTest.java | 2 +- .../org/eclipse/jkube/quarkus/QuarkusUtils.java | 2 +- .../enricher/QuarkusHealthCheckEnricher.java | 2 +- .../generator/AbstractQuarkusNestedGenerator.java | 2 +- .../jkube/quarkus/generator/FastJarGenerator.java | 2 +- .../quarkus/generator/LegacyJarGenerator.java | 2 +- .../jkube/quarkus/generator/NativeGenerator.java | 2 +- .../jkube/quarkus/generator/QuarkusGenerator.java | 2 +- .../quarkus/generator/QuarkusNestedGenerator.java | 2 +- .../jkube/quarkus/generator/UberJarGenerator.java | 2 +- .../eclipse/jkube/quarkus/QuarkusUtilsTest.java | 2 +- .../enricher/QuarkusHealthCheckEnricherTest.java | 2 +- .../QuarkusGeneratorExposedPortsTest.java | 2 +- .../quarkus/generator/QuarkusGeneratorTest.java | 2 +- .../generator/QuarkusNestedGeneratorTest.java | 2 +- .../org/eclipse/jkube/smallrye/SmallRyeUtils.java | 2 +- .../enricher/SmallRyeHealthCheckEnricher.java | 2 +- .../eclipse/jkube/smallrye/SmallRyeUtilsTest.java | 2 +- .../enricher/SmallRyeHealthCheckEnricherTest.java | 2 +- .../jkube/springboot/SpringBootDevtoolsUtils.java | 2 +- .../enricher/SpringBootHealthCheckEnricher.java | 2 +- .../springboot/generator/SpringBootGenerator.java | 2 +- .../springboot/watcher/SpringBootWatcher.java | 2 +- .../springboot/SpringBootDevtoolsUtilsTest.java | 2 +- ...tSpringBootHealthCheckEnricherTestSupport.java | 2 +- .../SpringBoot1HealthCheckEnricherTest.java | 2 +- .../SpringBoot2HealthCheckEnricherTest.java | 2 +- .../SpringBootGeneratorIntegrationTest.java | 2 +- .../generator/SpringBootGeneratorTest.java | 2 +- .../watcher/SpringBootWatcherIntegrationTest.java | 2 +- .../springboot/watcher/SpringBootWatcherTest.java | 2 +- .../enricher/ThorntailV2HealthCheckEnricher.java | 2 +- .../v2/generator/ThorntailV2Generator.java | 2 +- .../ThorntailV2HealthCheckEnricherTest.java | 2 +- .../ThorntailV2GeneratorIsApplicableTest.java | 2 +- .../vertx/enricher/VertxHealthCheckEnricher.java | 2 +- .../eclipse/jkube/vertx/generator/Constants.java | 2 +- .../jkube/vertx/generator/VertxGenerator.java | 2 +- .../vertx/generator/VertxPortsExtractor.java | 2 +- .../enricher/VertxHealthCheckEnricherTest.java | 2 +- .../generator/VertxGeneratorIsApplicableTest.java | 2 +- .../jkube/vertx/generator/VertxGeneratorTest.java | 2 +- .../vertx/generator/VertxPortsExtractorTest.java | 2 +- .../jkube/wildfly/jar/WildflyJarUtils.java | 2 +- .../enricher/WildflyJARHealthCheckEnricher.java | 2 +- .../jar/generator/WildflyJARGenerator.java | 2 +- .../jkube/wildfly/jar/WildflyJarUtilsTest.java | 2 +- .../WildflyJARHealthCheckEnricherTest.java | 2 +- .../jar/generator/WildflyJARGeneratorTest.java | 2 +- .../org/eclipse/jkube/kit/profile/Profile.java | 2 +- .../eclipse/jkube/kit/profile/ProfileUtil.java | 2 +- .../jkube/kit/profile/ProfileUtilTest.java | 2 +- .../remotedev/KubernetesSshServiceForwarder.java | 2 +- .../eclipse/jkube/kit/remotedev/LocalService.java | 2 +- .../jkube/kit/remotedev/LocalServiceManager.java | 2 +- .../jkube/kit/remotedev/PortForwarder.java | 2 +- .../kit/remotedev/RemoteDevelopmentConfig.java | 2 +- .../kit/remotedev/RemoteDevelopmentContext.java | 2 +- .../kit/remotedev/RemoteDevelopmentService.java | 2 +- .../jkube/kit/remotedev/RemoteService.java | 2 +- .../KubernetesSshServiceForwarderTest.java | 2 +- .../kit/remotedev/LocalServiceManagerTest.java | 2 +- .../jkube/kit/remotedev/PortForwarderTest.java | 2 +- .../remotedev/RemoteDevelopmentServiceTest.java | 2 +- .../jkube/kit/remotedev/SshServerExtension.java | 2 +- .../helm/ArtifactoryHelmRepositoryUploader.java | 2 +- .../kit/resource/helm/BadUploadException.java | 2 +- .../eclipse/jkube/kit/resource/helm/Chart.java | 2 +- .../helm/ChartMuseumHelmRepositoryUploader.java | 2 +- .../kit/resource/helm/GeneratedChartListener.java | 2 +- .../jkube/kit/resource/helm/HelmConfig.java | 2 +- .../jkube/kit/resource/helm/HelmDependency.java | 2 +- .../jkube/kit/resource/helm/HelmParameter.java | 2 +- .../jkube/kit/resource/helm/HelmRepository.java | 2 +- .../helm/HelmRepositoryConnectionUtils.java | 2 +- .../jkube/kit/resource/helm/HelmService.java | 2 +- .../jkube/kit/resource/helm/HelmServiceUtil.java | 2 +- .../jkube/kit/resource/helm/HelmUploader.java | 2 +- .../kit/resource/helm/HelmUploaderManager.java | 2 +- .../helm/NexusHelmRepositoryUploader.java | 2 +- .../resource/helm/StandardRepositoryUploader.java | 2 +- .../jkube/kit/resource/helm/ChartTest.java | 2 +- .../jkube/kit/resource/helm/HelmConfigTest.java | 2 +- .../kit/resource/helm/HelmDependencyTest.java | 2 +- .../kit/resource/helm/HelmRepositoryTest.java | 2 +- .../jkube/kit/resource/helm/HelmServiceIT.java | 2 +- .../jkube/kit/resource/helm/HelmServiceTest.java | 2 +- .../kit/resource/helm/HelmServiceUploadIT.java | 2 +- .../kit/resource/helm/HelmServiceUtilTest.java | 2 +- .../resource/helm/HelmUploaderManagerTest.java | 2 +- .../resource/service/DefaultResourceService.java | 2 +- .../jkube/kit/resource/service/TemplateUtil.java | 2 +- .../jkube/kit/resource/service/WriteUtil.java | 2 +- .../service/DefaultResourceServiceTest.java | 2 +- .../kit/resource/service/TemplateUtilTest.java | 2 +- .../jkube/kit/resource/service/WriteUtilTest.java | 2 +- .../eclipse/jkube/watcher/api/BaseWatcher.java | 2 +- .../org/eclipse/jkube/watcher/api/Watcher.java | 2 +- .../eclipse/jkube/watcher/api/WatcherConfig.java | 2 +- .../eclipse/jkube/watcher/api/WatcherContext.java | 2 +- .../eclipse/jkube/watcher/api/WatcherManager.java | 2 +- .../jkube/watcher/api/WatcherManagerTest.java | 2 +- .../watcher/standard/DockerImageWatcher.java | 2 +- .../jkube/watcher/standard/ExecListenerLatch.java | 2 +- .../jkube/watcher/standard/PodExecutor.java | 2 +- .../DockerImageWatcherRestartContainerTest.java | 2 +- .../watcher/standard/DockerImageWatcherTest.java | 2 +- .../watcher/standard/ExecListenerLatchTest.java | 2 +- .../jkube/watcher/standard/PodExecutorTest.java | 2 +- .../configmap/src/main/java/zero/Application.java | 2 +- .../src/main/java/zero/HelloController.java | 2 +- .../it/src/it/configmap/verify.groovy | 2 +- .../java/io/vertx/example/SimpleWebVerticle.java | 2 +- .../it/src/it/custom-environment/verify.groovy | 2 +- .../it/src/it/custom-raw-resources/verify.groovy | 2 +- .../it/src/it/dependency-resources/verify.groovy | 2 +- .../it/deployment-strategy-type-919/verify.groovy | 2 +- .../it/src/it/docker-health-checks/verify.groovy | 2 +- .../src/main/java/zero/Application.java | 2 +- .../src/main/java/zero/HelloController.java | 2 +- .../it/src/it/env-metadata/verify.groovy | 2 +- .../it/src/it/fragments/verify.groovy | 2 +- .../it/src/it/helm-and-fragments/verify.groovy | 2 +- .../src/main/java/zero/Application.java | 2 +- .../it/src/it/ingress-xml-config/verify.groovy | 2 +- .../src/it/java-options-env-merge/verify.groovy | 2 +- .../it/metadata-labels-annotations/verify.groovy | 2 +- .../namespace/src/main/java/zero/Application.java | 2 +- .../it/src/it/namespace/verify.groovy | 2 +- .../src/main/java/probe/Application.java | 2 +- .../src/main/java/probe/HelloController.java | 2 +- .../it/src/it/probes-xml-config/verify.groovy | 2 +- .../it/src/it/raw-resources/verify.groovy | 2 +- .../maven/sample/spring/boot/Application.java | 2 +- .../it/src/it/registry-286/verify.groovy | 2 +- .../java/io/vertx/example/SimpleWebVerticle.java | 2 +- .../it/src/it/remote-resources/verify.groovy | 2 +- .../maven/sample/spring/boot/Application.java | 2 +- .../maven/sample/spring/boot/HelloController.java | 2 +- .../it/src/it/revisionhistory/verify.groovy | 2 +- .../src/main/java/hello/Application.java | 2 +- .../it/src/it/secret-config/verify.groovy | 2 +- .../sidecar/src/main/java/zero/Application.java | 2 +- .../src/main/java/zero/HelloController.java | 2 +- .../it/src/it/sidecar/verify.groovy | 2 +- .../src/main/java/zero/Application.java | 2 +- .../src/main/java/zero/HelloController.java | 2 +- .../src/it/simple-maven-issue-mgmt/verify.groovy | 2 +- .../src/main/java/zero/Application.java | 2 +- .../src/main/java/zero/HelloController.java | 2 +- .../it/src/it/simple-maven-scm/verify.groovy | 2 +- .../src/main/java/zero/Application.java | 2 +- .../src/main/java/zero/HelloController.java | 2 +- .../it/simple-with-route-flag-false/verify.groovy | 2 +- .../src/main/java/zero/Application.java | 2 +- .../src/main/java/zero/HelloController.java | 2 +- .../it/simple-with-route-flag-true/verify.groovy | 2 +- .../it/simple/src/main/java/zero/Application.java | 2 +- .../src/main/java/zero/HelloController.java | 2 +- .../it/src/it/simple/verify.groovy | 2 +- .../maven/sample/spring/boot/Application.java | 2 +- .../maven/sample/spring/boot/HelloController.java | 2 +- .../it/src/it/spring-boot/verify.groovy | 2 +- .../maven/sample/spring/boot/Application.java | 2 +- .../it/src/it/statefulset/verify.groovy | 2 +- .../maven/sample/vertx/HttpApplication.java | 2 +- .../it/src/it/vertx-default/verify.groovy | 2 +- .../maven/sample/vertx/HttpApplication.java | 2 +- .../it/src/it/vertx-health-check/verify.groovy | 2 +- .../java/io/vertx/example/SimpleWebVerticle.java | 2 +- .../it/src/it/vertx/verify.groovy | 2 +- .../verify.groovy | 2 +- .../verify.groovy | 2 +- .../it/src/it/xml-image-multilayer/verify.groovy | 2 +- .../it/src/it/xml-image/verify.groovy | 2 +- .../maven/plugin/mojo/KitLoggerProvider.java | 2 +- .../jkube/maven/plugin/mojo/ManifestProvider.java | 2 +- .../plugin/mojo/build/AbstractDockerMojo.java | 2 +- .../plugin/mojo/build/AbstractJKubeMojo.java | 2 +- .../jkube/maven/plugin/mojo/build/ApplyMojo.java | 2 +- .../jkube/maven/plugin/mojo/build/BuildMojo.java | 2 +- .../jkube/maven/plugin/mojo/build/HelmMojo.java | 2 +- .../maven/plugin/mojo/build/HelmPushMojo.java | 2 +- .../jkube/maven/plugin/mojo/build/PushMojo.java | 2 +- .../maven/plugin/mojo/build/ResourceMojo.java | 2 +- .../maven/plugin/mojo/develop/DebugMojo.java | 2 +- .../maven/plugin/mojo/develop/DeployMojo.java | 2 +- .../jkube/maven/plugin/mojo/develop/LogMojo.java | 2 +- .../maven/plugin/mojo/develop/RemoteDevMojo.java | 2 +- .../maven/plugin/mojo/develop/UndeployMojo.java | 2 +- .../maven/plugin/mojo/develop/WatchMojo.java | 2 +- .../jkube/maven/plugin/mojo/util/MigrateMojo.java | 2 +- .../mojo/GeneratedPluginDescriptorTest.java | 2 +- .../maven/plugin/mojo/build/ApplyMojoTest.java | 2 +- .../maven/plugin/mojo/build/BuildMojoTest.java | 2 +- .../plugin/mojo/build/HelmMojoPluginTest.java | 2 +- .../maven/plugin/mojo/build/HelmMojoTest.java | 2 +- .../maven/plugin/mojo/build/HelmPushMojoTest.java | 2 +- .../plugin/mojo/build/ResourceMojoPluginTest.java | 2 +- .../maven/plugin/mojo/build/ResourceMojoTest.java | 2 +- .../maven/plugin/mojo/build/SkipGoalsTest.java | 2 +- .../maven/plugin/mojo/develop/DebugMojoTest.java | 2 +- .../maven/plugin/mojo/develop/LogMojoTest.java | 2 +- .../plugin/mojo/develop/RemoteDevMojoTest.java | 2 +- .../plugin/mojo/develop/UndeployMojoTest.java | 2 +- .../maven/plugin/mojo/develop/WatchMojoTest.java | 2 +- .../configmap/src/main/java/zero/Application.java | 2 +- .../src/main/java/zero/HelloController.java | 2 +- .../it/src/it/configmap/verify.groovy | 2 +- .../java/io/vertx/example/SimpleWebVerticle.java | 2 +- .../it/src/it/custom-environment/verify.groovy | 2 +- .../it/src/it/custom-raw-resources/verify.groovy | 2 +- .../it/deployment-strategy-type-919/verify.groovy | 2 +- .../it/src/it/docker-health-checks/verify.groovy | 2 +- .../src/main/java/zero/Application.java | 2 +- .../src/main/java/zero/HelloController.java | 2 +- .../it/src/it/env-metadata/verify.groovy | 2 +- .../project/src/main/java/zero/Application.java | 2 +- .../it/src/it/project/verify.groovy | 2 +- .../it/src/it/raw-resources/verify.groovy | 2 +- .../maven/sample/spring/boot/Application.java | 2 +- .../it/src/it/registry-286/verify.groovy | 2 +- .../java/io/vertx/example/SimpleWebVerticle.java | 2 +- .../it/src/it/remote-resources/verify.groovy | 2 +- .../maven/sample/spring/boot/Application.java | 2 +- .../maven/sample/spring/boot/HelloController.java | 2 +- .../it/src/it/revisionhistory/verify.groovy | 2 +- .../src/main/java/hello/Application.java | 2 +- .../it/src/it/secret-config/verify.groovy | 2 +- .../sidecar/src/main/java/zero/Application.java | 2 +- .../src/main/java/zero/HelloController.java | 2 +- .../it/src/it/sidecar/verify.groovy | 2 +- .../src/main/java/zero/Application.java | 2 +- .../src/main/java/zero/HelloController.java | 2 +- .../src/it/simple-maven-issue-mgmt/verify.groovy | 2 +- .../src/main/java/zero/Application.java | 2 +- .../src/main/java/zero/HelloController.java | 2 +- .../it/src/it/simple-maven-scm/verify.groovy | 2 +- .../src/main/java/zero/Application.java | 2 +- .../src/main/java/zero/HelloController.java | 2 +- .../it/simple-with-route-flag-false/verify.groovy | 2 +- .../src/main/java/zero/Application.java | 2 +- .../src/main/java/zero/HelloController.java | 2 +- .../it/simple-with-route-flag-true/verify.groovy | 2 +- .../it/simple/src/main/java/zero/Application.java | 2 +- .../src/main/java/zero/HelloController.java | 2 +- .../it/src/it/simple/verify.groovy | 2 +- .../maven/sample/spring/boot/Application.java | 2 +- .../maven/sample/spring/boot/HelloController.java | 2 +- .../it/src/it/spring-boot/verify.groovy | 2 +- .../maven/sample/spring/boot/Application.java | 2 +- .../it/src/it/statefulset/verify.groovy | 2 +- .../maven/sample/vertx/HttpApplication.java | 2 +- .../it/src/it/vertx-default/verify.groovy | 2 +- .../maven/sample/vertx/HttpApplication.java | 2 +- .../it/src/it/vertx-health-check/verify.groovy | 2 +- .../java/io/vertx/example/SimpleWebVerticle.java | 2 +- .../it/src/it/vertx/verify.groovy | 2 +- .../verify.groovy | 2 +- .../verify.groovy | 2 +- .../jkube/maven/plugin/mojo/OpenShift.java | 2 +- .../plugin/mojo/build/OpenshiftApplyMojo.java | 2 +- .../plugin/mojo/build/OpenshiftBuildMojo.java | 2 +- .../plugin/mojo/build/OpenshiftHelmMojo.java | 2 +- .../plugin/mojo/build/OpenshiftHelmPushMojo.java | 2 +- .../plugin/mojo/build/OpenshiftPushMojo.java | 2 +- .../plugin/mojo/build/OpenshiftResourceMojo.java | 2 +- .../mojo/develop/OpenShiftRemoteDevMojo.java | 2 +- .../plugin/mojo/develop/OpenshiftDebugMojo.java | 2 +- .../plugin/mojo/develop/OpenshiftDeployMojo.java | 2 +- .../plugin/mojo/develop/OpenshiftLogMojo.java | 2 +- .../mojo/develop/OpenshiftUndeployMojo.java | 2 +- .../plugin/mojo/develop/OpenshiftWatchMojo.java | 2 +- .../plugin/mojo/util/OpenShiftMigrateMojo.java | 2 +- .../OpenShiftGeneratedPluginDescriptorTest.java | 2 +- .../mojo/build/OpenShiftResourceMojoTest.java | 2 +- .../mojo/develop/OpenShiftRemoteDevMojoTest.java | 2 +- .../mojo/develop/OpenshiftUndeployMojoTest.java | 2 +- 1138 files changed, 1873 insertions(+), 1082 deletions(-) diff --git a/gradle-plugin/it/src/it/autotls/build.gradle b/gradle-plugin/it/src/it/autotls/build.gradle index 09cee378d5..96be238029 100644 --- a/gradle-plugin/it/src/it/autotls/build.gradle +++ b/gradle-plugin/it/src/it/autotls/build.gradle @@ -1,3 +1,16 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ plugins { id 'org.eclipse.jkube.openshift' version "${jKubeVersion}" id 'java' diff --git a/gradle-plugin/it/src/it/configmap/build.gradle b/gradle-plugin/it/src/it/configmap/build.gradle index 4143d04231..a7d6327547 100644 --- a/gradle-plugin/it/src/it/configmap/build.gradle +++ b/gradle-plugin/it/src/it/configmap/build.gradle @@ -1,3 +1,16 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ plugins { id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}" id 'org.eclipse.jkube.openshift' version "${jKubeVersion}" diff --git a/gradle-plugin/it/src/it/configmap/src/main/java/zero/Application.java b/gradle-plugin/it/src/it/configmap/src/main/java/zero/Application.java index f02013c575..3f0b57dc14 100644 --- a/gradle-plugin/it/src/it/configmap/src/main/java/zero/Application.java +++ b/gradle-plugin/it/src/it/configmap/src/main/java/zero/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/gradle-plugin/it/src/it/configmap/src/main/java/zero/HelloController.java b/gradle-plugin/it/src/it/configmap/src/main/java/zero/HelloController.java index 638e2e6177..339bb95a7e 100644 --- a/gradle-plugin/it/src/it/configmap/src/main/java/zero/HelloController.java +++ b/gradle-plugin/it/src/it/configmap/src/main/java/zero/HelloController.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/gradle-plugin/it/src/it/controller/build.gradle b/gradle-plugin/it/src/it/controller/build.gradle index 07b1f5ead6..cb180fd1e9 100644 --- a/gradle-plugin/it/src/it/controller/build.gradle +++ b/gradle-plugin/it/src/it/controller/build.gradle @@ -1,3 +1,16 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ plugins { id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}" id 'org.eclipse.jkube.openshift' version "${jKubeVersion}" diff --git a/gradle-plugin/it/src/it/debug-mode/build.gradle b/gradle-plugin/it/src/it/debug-mode/build.gradle index 918506aa34..7393188d84 100644 --- a/gradle-plugin/it/src/it/debug-mode/build.gradle +++ b/gradle-plugin/it/src/it/debug-mode/build.gradle @@ -1,3 +1,16 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ plugins { id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}" id 'org.eclipse.jkube.openshift' version "${jKubeVersion}" diff --git a/gradle-plugin/it/src/it/dependency-resources/settings.gradle b/gradle-plugin/it/src/it/dependency-resources/settings.gradle index 0c7ac9aca5..c71a14ca4d 100644 --- a/gradle-plugin/it/src/it/dependency-resources/settings.gradle +++ b/gradle-plugin/it/src/it/dependency-resources/settings.gradle @@ -1,3 +1,16 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ rootProject.name = 'jkube-gradle-sample-dependency-resources' include 'dependency', 'dependent' diff --git a/gradle-plugin/it/src/it/dockerfile-simple/build.gradle b/gradle-plugin/it/src/it/dockerfile-simple/build.gradle index 20201e970b..c9f1ec408d 100644 --- a/gradle-plugin/it/src/it/dockerfile-simple/build.gradle +++ b/gradle-plugin/it/src/it/dockerfile-simple/build.gradle @@ -1,3 +1,16 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ plugins { id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}" id 'org.eclipse.jkube.openshift' version "${jKubeVersion}" diff --git a/gradle-plugin/it/src/it/expose/build.gradle b/gradle-plugin/it/src/it/expose/build.gradle index 5e5c2b6120..fcccfebabe 100644 --- a/gradle-plugin/it/src/it/expose/build.gradle +++ b/gradle-plugin/it/src/it/expose/build.gradle @@ -1,3 +1,16 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ plugins { id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}" id 'org.eclipse.jkube.openshift' version "${jKubeVersion}" diff --git a/gradle-plugin/it/src/it/extension-configuration/build.gradle b/gradle-plugin/it/src/it/extension-configuration/build.gradle index 4d328af017..69a7750db6 100644 --- a/gradle-plugin/it/src/it/extension-configuration/build.gradle +++ b/gradle-plugin/it/src/it/extension-configuration/build.gradle @@ -1,3 +1,16 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ plugins { id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}" id 'org.eclipse.jkube.openshift' version "${jKubeVersion}" diff --git a/gradle-plugin/it/src/it/fragments-custom-mapping/build.gradle b/gradle-plugin/it/src/it/fragments-custom-mapping/build.gradle index 4a24a50e30..15fb9645a2 100644 --- a/gradle-plugin/it/src/it/fragments-custom-mapping/build.gradle +++ b/gradle-plugin/it/src/it/fragments-custom-mapping/build.gradle @@ -1,3 +1,16 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ plugins { id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}" id 'org.eclipse.jkube.openshift' version "${jKubeVersion}" diff --git a/gradle-plugin/it/src/it/fragments-custom-mapping/src/main/jkube/first-fl.yaml b/gradle-plugin/it/src/it/fragments-custom-mapping/src/main/jkube/first-fl.yaml index e69de29bb2..80e95c2564 100644 --- a/gradle-plugin/it/src/it/fragments-custom-mapping/src/main/jkube/first-fl.yaml +++ b/gradle-plugin/it/src/it/fragments-custom-mapping/src/main/jkube/first-fl.yaml @@ -0,0 +1,14 @@ +# +# Copyright (c) 2019 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at: +# +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Red Hat, Inc. - initial API and implementation +# + diff --git a/gradle-plugin/it/src/it/fragments-custom-mapping/src/main/jkube/first-mtpl.yaml b/gradle-plugin/it/src/it/fragments-custom-mapping/src/main/jkube/first-mtpl.yaml index 26a7d8c759..0fa863d32e 100644 --- a/gradle-plugin/it/src/it/fragments-custom-mapping/src/main/jkube/first-mtpl.yaml +++ b/gradle-plugin/it/src/it/fragments-custom-mapping/src/main/jkube/first-mtpl.yaml @@ -1 +1,15 @@ +# +# Copyright (c) 2019 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at: +# +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Red Hat, Inc. - initial API and implementation +# + apiVersion: my.unique.crd/v1alfa1 diff --git a/gradle-plugin/it/src/it/fragments-custom-mapping/src/main/jkube/full.yaml b/gradle-plugin/it/src/it/fragments-custom-mapping/src/main/jkube/full.yaml index c1412a4f88..2f445c39ad 100644 --- a/gradle-plugin/it/src/it/fragments-custom-mapping/src/main/jkube/full.yaml +++ b/gradle-plugin/it/src/it/fragments-custom-mapping/src/main/jkube/full.yaml @@ -1,2 +1,16 @@ +# +# Copyright (c) 2019 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at: +# +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Red Hat, Inc. - initial API and implementation +# + metadata: name: second diff --git a/gradle-plugin/it/src/it/fragments-custom-mapping/src/main/jkube/second-my_template.yml b/gradle-plugin/it/src/it/fragments-custom-mapping/src/main/jkube/second-my_template.yml index 26a7d8c759..0fa863d32e 100644 --- a/gradle-plugin/it/src/it/fragments-custom-mapping/src/main/jkube/second-my_template.yml +++ b/gradle-plugin/it/src/it/fragments-custom-mapping/src/main/jkube/second-my_template.yml @@ -1 +1,15 @@ +# +# Copyright (c) 2019 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at: +# +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Red Hat, Inc. - initial API and implementation +# + apiVersion: my.unique.crd/v1alfa1 diff --git a/gradle-plugin/it/src/it/git-annotations/build.gradle b/gradle-plugin/it/src/it/git-annotations/build.gradle index a5d77e6327..de827308e3 100644 --- a/gradle-plugin/it/src/it/git-annotations/build.gradle +++ b/gradle-plugin/it/src/it/git-annotations/build.gradle @@ -1,3 +1,16 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ plugins { id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}" id 'org.eclipse.jkube.openshift' version "${jKubeVersion}" diff --git a/gradle-plugin/it/src/it/groovy-dsl-container-resources/build.gradle b/gradle-plugin/it/src/it/groovy-dsl-container-resources/build.gradle index c41999ef5a..58e86daa5c 100644 --- a/gradle-plugin/it/src/it/groovy-dsl-container-resources/build.gradle +++ b/gradle-plugin/it/src/it/groovy-dsl-container-resources/build.gradle @@ -1,3 +1,16 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ plugins { id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}" diff --git a/gradle-plugin/it/src/it/groovy-dsl-image/build.gradle b/gradle-plugin/it/src/it/groovy-dsl-image/build.gradle index 276d8cbf4e..3340ad3067 100644 --- a/gradle-plugin/it/src/it/groovy-dsl-image/build.gradle +++ b/gradle-plugin/it/src/it/groovy-dsl-image/build.gradle @@ -1,3 +1,16 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ plugins { id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}" diff --git a/gradle-plugin/it/src/it/helidon-properties/build.gradle b/gradle-plugin/it/src/it/helidon-properties/build.gradle index 1f84317aae..cac3aa7780 100644 --- a/gradle-plugin/it/src/it/helidon-properties/build.gradle +++ b/gradle-plugin/it/src/it/helidon-properties/build.gradle @@ -1,3 +1,16 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ plugins { id 'java' id 'org.kordamp.gradle.jandex' version '0.6.0' diff --git a/gradle-plugin/it/src/it/helidon-properties/src/main/java/org/eclipse/jkube/it/gradle/helidon/GreetResource.java b/gradle-plugin/it/src/it/helidon-properties/src/main/java/org/eclipse/jkube/it/gradle/helidon/GreetResource.java index 0551f6785d..46458360a2 100644 --- a/gradle-plugin/it/src/it/helidon-properties/src/main/java/org/eclipse/jkube/it/gradle/helidon/GreetResource.java +++ b/gradle-plugin/it/src/it/helidon-properties/src/main/java/org/eclipse/jkube/it/gradle/helidon/GreetResource.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/gradle-plugin/it/src/it/helidon-properties/src/main/java/org/eclipse/jkube/it/gradle/helidon/GreetingProvider.java b/gradle-plugin/it/src/it/helidon-properties/src/main/java/org/eclipse/jkube/it/gradle/helidon/GreetingProvider.java index aa70f3018a..59d340ac3a 100644 --- a/gradle-plugin/it/src/it/helidon-properties/src/main/java/org/eclipse/jkube/it/gradle/helidon/GreetingProvider.java +++ b/gradle-plugin/it/src/it/helidon-properties/src/main/java/org/eclipse/jkube/it/gradle/helidon/GreetingProvider.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/gradle-plugin/it/src/it/helidon-properties/src/main/resources/META-INF/beans.xml b/gradle-plugin/it/src/it/helidon-properties/src/main/resources/META-INF/beans.xml index 5d94aab5a2..7183e39eb2 100644 --- a/gradle-plugin/it/src/it/helidon-properties/src/main/resources/META-INF/beans.xml +++ b/gradle-plugin/it/src/it/helidon-properties/src/main/resources/META-INF/beans.xml @@ -1,4 +1,19 @@ + + + diff --git a/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/enricher/HelidonHealthCheckEnricher.java b/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/enricher/HelidonHealthCheckEnricher.java index a31d97912e..470e51501f 100644 --- a/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/enricher/HelidonHealthCheckEnricher.java +++ b/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/enricher/HelidonHealthCheckEnricher.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/generator/AbstractHelidonNestedGenerator.java b/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/generator/AbstractHelidonNestedGenerator.java index 0904993191..df5fd5b6ca 100644 --- a/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/generator/AbstractHelidonNestedGenerator.java +++ b/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/generator/AbstractHelidonNestedGenerator.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/generator/HelidonNestedGenerator.java b/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/generator/HelidonNestedGenerator.java index 75f2c030b8..eb8a231c32 100644 --- a/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/generator/HelidonNestedGenerator.java +++ b/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/generator/HelidonNestedGenerator.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/generator/NativeGenerator.java b/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/generator/NativeGenerator.java index 5fe29c79ba..7f4bd20946 100644 --- a/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/generator/NativeGenerator.java +++ b/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/generator/NativeGenerator.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/generator/StandardGenerator.java b/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/generator/StandardGenerator.java index 5c57229379..e6490b067f 100644 --- a/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/generator/StandardGenerator.java +++ b/jkube-kit/jkube-kit-helidon/src/main/java/org/eclipse/jkube/helidon/generator/StandardGenerator.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-helidon/src/test/java/org/eclipse/jkube/helidon/enricher/HelidonHealthCheckEnricherTest.java b/jkube-kit/jkube-kit-helidon/src/test/java/org/eclipse/jkube/helidon/enricher/HelidonHealthCheckEnricherTest.java index d91ab057a0..d914c0c167 100644 --- a/jkube-kit/jkube-kit-helidon/src/test/java/org/eclipse/jkube/helidon/enricher/HelidonHealthCheckEnricherTest.java +++ b/jkube-kit/jkube-kit-helidon/src/test/java/org/eclipse/jkube/helidon/enricher/HelidonHealthCheckEnricherTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-micronaut/src/main/java/org/eclipse/jkube/micronaut/MicronautUtils.java b/jkube-kit/jkube-kit-micronaut/src/main/java/org/eclipse/jkube/micronaut/MicronautUtils.java index 7c2c69f73c..4436174a18 100644 --- a/jkube-kit/jkube-kit-micronaut/src/main/java/org/eclipse/jkube/micronaut/MicronautUtils.java +++ b/jkube-kit/jkube-kit-micronaut/src/main/java/org/eclipse/jkube/micronaut/MicronautUtils.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-micronaut/src/main/java/org/eclipse/jkube/micronaut/enricher/MicronautHealthCheckEnricher.java b/jkube-kit/jkube-kit-micronaut/src/main/java/org/eclipse/jkube/micronaut/enricher/MicronautHealthCheckEnricher.java index a7fad52a04..e5f68d1383 100644 --- a/jkube-kit/jkube-kit-micronaut/src/main/java/org/eclipse/jkube/micronaut/enricher/MicronautHealthCheckEnricher.java +++ b/jkube-kit/jkube-kit-micronaut/src/main/java/org/eclipse/jkube/micronaut/enricher/MicronautHealthCheckEnricher.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-micronaut/src/main/java/org/eclipse/jkube/micronaut/generator/MicronautGenerator.java b/jkube-kit/jkube-kit-micronaut/src/main/java/org/eclipse/jkube/micronaut/generator/MicronautGenerator.java index d61d89f12a..1b0ade4639 100644 --- a/jkube-kit/jkube-kit-micronaut/src/main/java/org/eclipse/jkube/micronaut/generator/MicronautGenerator.java +++ b/jkube-kit/jkube-kit-micronaut/src/main/java/org/eclipse/jkube/micronaut/generator/MicronautGenerator.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-micronaut/src/test/java/org/eclipse/jkube/micronaut/MicronautUtilsGetMicronautConfigurationTest.java b/jkube-kit/jkube-kit-micronaut/src/test/java/org/eclipse/jkube/micronaut/MicronautUtilsGetMicronautConfigurationTest.java index 5380fdff82..0edbd797a5 100644 --- a/jkube-kit/jkube-kit-micronaut/src/test/java/org/eclipse/jkube/micronaut/MicronautUtilsGetMicronautConfigurationTest.java +++ b/jkube-kit/jkube-kit-micronaut/src/test/java/org/eclipse/jkube/micronaut/MicronautUtilsGetMicronautConfigurationTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-micronaut/src/test/java/org/eclipse/jkube/micronaut/MicronautUtilsTest.java b/jkube-kit/jkube-kit-micronaut/src/test/java/org/eclipse/jkube/micronaut/MicronautUtilsTest.java index d8e77e1955..e923773831 100644 --- a/jkube-kit/jkube-kit-micronaut/src/test/java/org/eclipse/jkube/micronaut/MicronautUtilsTest.java +++ b/jkube-kit/jkube-kit-micronaut/src/test/java/org/eclipse/jkube/micronaut/MicronautUtilsTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-micronaut/src/test/java/org/eclipse/jkube/micronaut/enricher/MicronautHealthCheckEnricherTest.java b/jkube-kit/jkube-kit-micronaut/src/test/java/org/eclipse/jkube/micronaut/enricher/MicronautHealthCheckEnricherTest.java index b64d09ce78..439002ac78 100644 --- a/jkube-kit/jkube-kit-micronaut/src/test/java/org/eclipse/jkube/micronaut/enricher/MicronautHealthCheckEnricherTest.java +++ b/jkube-kit/jkube-kit-micronaut/src/test/java/org/eclipse/jkube/micronaut/enricher/MicronautHealthCheckEnricherTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-micronaut/src/test/java/org/eclipse/jkube/micronaut/generator/MicronautGeneratorTest.java b/jkube-kit/jkube-kit-micronaut/src/test/java/org/eclipse/jkube/micronaut/generator/MicronautGeneratorTest.java index 1ebe01c405..531843d1f8 100644 --- a/jkube-kit/jkube-kit-micronaut/src/test/java/org/eclipse/jkube/micronaut/generator/MicronautGeneratorTest.java +++ b/jkube-kit/jkube-kit-micronaut/src/test/java/org/eclipse/jkube/micronaut/generator/MicronautGeneratorTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-microprofile/src/main/java/org/eclipse/jkube/microprofile/MicroprofileHealthUtil.java b/jkube-kit/jkube-kit-microprofile/src/main/java/org/eclipse/jkube/microprofile/MicroprofileHealthUtil.java index 8582ef8a8f..2d3f792c6b 100644 --- a/jkube-kit/jkube-kit-microprofile/src/main/java/org/eclipse/jkube/microprofile/MicroprofileHealthUtil.java +++ b/jkube-kit/jkube-kit-microprofile/src/main/java/org/eclipse/jkube/microprofile/MicroprofileHealthUtil.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-microprofile/src/main/java/org/eclipse/jkube/microprofile/enricher/AbstractMicroprofileHealthCheckEnricher.java b/jkube-kit/jkube-kit-microprofile/src/main/java/org/eclipse/jkube/microprofile/enricher/AbstractMicroprofileHealthCheckEnricher.java index 6a8ae7ccb3..feadcdda62 100644 --- a/jkube-kit/jkube-kit-microprofile/src/main/java/org/eclipse/jkube/microprofile/enricher/AbstractMicroprofileHealthCheckEnricher.java +++ b/jkube-kit/jkube-kit-microprofile/src/main/java/org/eclipse/jkube/microprofile/enricher/AbstractMicroprofileHealthCheckEnricher.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-microprofile/src/test/java/org/eclipse/jkube/microprofile/MicroprofileHealthUtilTest.java b/jkube-kit/jkube-kit-microprofile/src/test/java/org/eclipse/jkube/microprofile/MicroprofileHealthUtilTest.java index e60f65004f..a7a81061e6 100644 --- a/jkube-kit/jkube-kit-microprofile/src/test/java/org/eclipse/jkube/microprofile/MicroprofileHealthUtilTest.java +++ b/jkube-kit/jkube-kit-microprofile/src/test/java/org/eclipse/jkube/microprofile/MicroprofileHealthUtilTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-microprofile/src/test/java/org/eclipse/jkube/microprofile/enricher/AbstractMicroprofileHealthCheckEnricherTest.java b/jkube-kit/jkube-kit-microprofile/src/test/java/org/eclipse/jkube/microprofile/enricher/AbstractMicroprofileHealthCheckEnricherTest.java index 081ed5ac09..529b40e0e0 100644 --- a/jkube-kit/jkube-kit-microprofile/src/test/java/org/eclipse/jkube/microprofile/enricher/AbstractMicroprofileHealthCheckEnricherTest.java +++ b/jkube-kit/jkube-kit-microprofile/src/test/java/org/eclipse/jkube/microprofile/enricher/AbstractMicroprofileHealthCheckEnricherTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-openliberty/src/main/java/org/eclipse/jkube/openliberty/OpenLibertyUtils.java b/jkube-kit/jkube-kit-openliberty/src/main/java/org/eclipse/jkube/openliberty/OpenLibertyUtils.java index 89cfe9e7fe..d93bd19f9b 100644 --- a/jkube-kit/jkube-kit-openliberty/src/main/java/org/eclipse/jkube/openliberty/OpenLibertyUtils.java +++ b/jkube-kit/jkube-kit-openliberty/src/main/java/org/eclipse/jkube/openliberty/OpenLibertyUtils.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-openliberty/src/main/java/org/eclipse/jkube/openliberty/enricher/OpenLibertyHealthCheckEnricher.java b/jkube-kit/jkube-kit-openliberty/src/main/java/org/eclipse/jkube/openliberty/enricher/OpenLibertyHealthCheckEnricher.java index dd49fe805a..8a89f23759 100644 --- a/jkube-kit/jkube-kit-openliberty/src/main/java/org/eclipse/jkube/openliberty/enricher/OpenLibertyHealthCheckEnricher.java +++ b/jkube-kit/jkube-kit-openliberty/src/main/java/org/eclipse/jkube/openliberty/enricher/OpenLibertyHealthCheckEnricher.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-openliberty/src/main/java/org/eclipse/jkube/openliberty/generator/OpenLibertyGenerator.java b/jkube-kit/jkube-kit-openliberty/src/main/java/org/eclipse/jkube/openliberty/generator/OpenLibertyGenerator.java index 8e6ba2812e..9defeba947 100644 --- a/jkube-kit/jkube-kit-openliberty/src/main/java/org/eclipse/jkube/openliberty/generator/OpenLibertyGenerator.java +++ b/jkube-kit/jkube-kit-openliberty/src/main/java/org/eclipse/jkube/openliberty/generator/OpenLibertyGenerator.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-openliberty/src/test/java/org/eclipse/jkube/openliberty/OpenLibertyUtilsTest.java b/jkube-kit/jkube-kit-openliberty/src/test/java/org/eclipse/jkube/openliberty/OpenLibertyUtilsTest.java index 0b05d0b7f5..c66c66717f 100644 --- a/jkube-kit/jkube-kit-openliberty/src/test/java/org/eclipse/jkube/openliberty/OpenLibertyUtilsTest.java +++ b/jkube-kit/jkube-kit-openliberty/src/test/java/org/eclipse/jkube/openliberty/OpenLibertyUtilsTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-openliberty/src/test/java/org/eclipse/jkube/openliberty/enricher/OpenLibertyHealthCheckEnricherTest.java b/jkube-kit/jkube-kit-openliberty/src/test/java/org/eclipse/jkube/openliberty/enricher/OpenLibertyHealthCheckEnricherTest.java index fd2d1785c1..deb2a23de6 100644 --- a/jkube-kit/jkube-kit-openliberty/src/test/java/org/eclipse/jkube/openliberty/enricher/OpenLibertyHealthCheckEnricherTest.java +++ b/jkube-kit/jkube-kit-openliberty/src/test/java/org/eclipse/jkube/openliberty/enricher/OpenLibertyHealthCheckEnricherTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-openliberty/src/test/java/org/eclipse/jkube/openliberty/generator/OpenLibertyGeneratorIsApplicableTest.java b/jkube-kit/jkube-kit-openliberty/src/test/java/org/eclipse/jkube/openliberty/generator/OpenLibertyGeneratorIsApplicableTest.java index 7432658967..8c1c5ae87e 100644 --- a/jkube-kit/jkube-kit-openliberty/src/test/java/org/eclipse/jkube/openliberty/generator/OpenLibertyGeneratorIsApplicableTest.java +++ b/jkube-kit/jkube-kit-openliberty/src/test/java/org/eclipse/jkube/openliberty/generator/OpenLibertyGeneratorIsApplicableTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-openliberty/src/test/java/org/eclipse/jkube/openliberty/generator/OpenLibertyGeneratorTest.java b/jkube-kit/jkube-kit-openliberty/src/test/java/org/eclipse/jkube/openliberty/generator/OpenLibertyGeneratorTest.java index da1ceba6a8..c25c2feb95 100644 --- a/jkube-kit/jkube-kit-openliberty/src/test/java/org/eclipse/jkube/openliberty/generator/OpenLibertyGeneratorTest.java +++ b/jkube-kit/jkube-kit-openliberty/src/test/java/org/eclipse/jkube/openliberty/generator/OpenLibertyGeneratorTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/QuarkusUtils.java b/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/QuarkusUtils.java index ca088fd791..147bf7c41f 100644 --- a/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/QuarkusUtils.java +++ b/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/QuarkusUtils.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/enricher/QuarkusHealthCheckEnricher.java b/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/enricher/QuarkusHealthCheckEnricher.java index 5019d99936..b395d214c8 100644 --- a/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/enricher/QuarkusHealthCheckEnricher.java +++ b/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/enricher/QuarkusHealthCheckEnricher.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/AbstractQuarkusNestedGenerator.java b/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/AbstractQuarkusNestedGenerator.java index 5182cb23b5..f69b7820ea 100644 --- a/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/AbstractQuarkusNestedGenerator.java +++ b/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/AbstractQuarkusNestedGenerator.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/FastJarGenerator.java b/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/FastJarGenerator.java index b08b3b0ae5..389497b8ce 100644 --- a/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/FastJarGenerator.java +++ b/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/FastJarGenerator.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/LegacyJarGenerator.java b/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/LegacyJarGenerator.java index 95514e92eb..7e6e739cf1 100644 --- a/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/LegacyJarGenerator.java +++ b/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/LegacyJarGenerator.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/NativeGenerator.java b/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/NativeGenerator.java index 45689f05b0..8f0d9f0de7 100644 --- a/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/NativeGenerator.java +++ b/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/NativeGenerator.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/QuarkusGenerator.java b/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/QuarkusGenerator.java index f2e3c67bf5..d3171899f1 100644 --- a/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/QuarkusGenerator.java +++ b/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/QuarkusGenerator.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/QuarkusNestedGenerator.java b/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/QuarkusNestedGenerator.java index 273b91a728..483b239e9d 100644 --- a/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/QuarkusNestedGenerator.java +++ b/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/QuarkusNestedGenerator.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/UberJarGenerator.java b/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/UberJarGenerator.java index 419454981d..51af30a82e 100644 --- a/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/UberJarGenerator.java +++ b/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/generator/UberJarGenerator.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/QuarkusUtilsTest.java b/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/QuarkusUtilsTest.java index 50187d8ac4..c980e9e6b0 100644 --- a/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/QuarkusUtilsTest.java +++ b/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/QuarkusUtilsTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/enricher/QuarkusHealthCheckEnricherTest.java b/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/enricher/QuarkusHealthCheckEnricherTest.java index 01c186b627..c1186d8934 100644 --- a/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/enricher/QuarkusHealthCheckEnricherTest.java +++ b/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/enricher/QuarkusHealthCheckEnricherTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/generator/QuarkusGeneratorExposedPortsTest.java b/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/generator/QuarkusGeneratorExposedPortsTest.java index 0d520c20f1..a195a33b0b 100644 --- a/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/generator/QuarkusGeneratorExposedPortsTest.java +++ b/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/generator/QuarkusGeneratorExposedPortsTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/generator/QuarkusGeneratorTest.java b/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/generator/QuarkusGeneratorTest.java index 1241545134..38ef8df0fb 100644 --- a/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/generator/QuarkusGeneratorTest.java +++ b/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/generator/QuarkusGeneratorTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/generator/QuarkusNestedGeneratorTest.java b/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/generator/QuarkusNestedGeneratorTest.java index a6450d1ded..39663b37bf 100644 --- a/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/generator/QuarkusNestedGeneratorTest.java +++ b/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/generator/QuarkusNestedGeneratorTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-smallrye/src/main/java/org/eclipse/jkube/smallrye/SmallRyeUtils.java b/jkube-kit/jkube-kit-smallrye/src/main/java/org/eclipse/jkube/smallrye/SmallRyeUtils.java index 1998f45518..e9734526ed 100644 --- a/jkube-kit/jkube-kit-smallrye/src/main/java/org/eclipse/jkube/smallrye/SmallRyeUtils.java +++ b/jkube-kit/jkube-kit-smallrye/src/main/java/org/eclipse/jkube/smallrye/SmallRyeUtils.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-smallrye/src/main/java/org/eclipse/jkube/smallrye/enricher/SmallRyeHealthCheckEnricher.java b/jkube-kit/jkube-kit-smallrye/src/main/java/org/eclipse/jkube/smallrye/enricher/SmallRyeHealthCheckEnricher.java index e142f4c529..b2d9e1dba8 100644 --- a/jkube-kit/jkube-kit-smallrye/src/main/java/org/eclipse/jkube/smallrye/enricher/SmallRyeHealthCheckEnricher.java +++ b/jkube-kit/jkube-kit-smallrye/src/main/java/org/eclipse/jkube/smallrye/enricher/SmallRyeHealthCheckEnricher.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-smallrye/src/test/java/org/eclipse/jkube/smallrye/SmallRyeUtilsTest.java b/jkube-kit/jkube-kit-smallrye/src/test/java/org/eclipse/jkube/smallrye/SmallRyeUtilsTest.java index b96802ddb4..326fbda95f 100644 --- a/jkube-kit/jkube-kit-smallrye/src/test/java/org/eclipse/jkube/smallrye/SmallRyeUtilsTest.java +++ b/jkube-kit/jkube-kit-smallrye/src/test/java/org/eclipse/jkube/smallrye/SmallRyeUtilsTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-smallrye/src/test/java/org/eclipse/jkube/smallrye/enricher/SmallRyeHealthCheckEnricherTest.java b/jkube-kit/jkube-kit-smallrye/src/test/java/org/eclipse/jkube/smallrye/enricher/SmallRyeHealthCheckEnricherTest.java index 39c30f42a1..3747b40c24 100644 --- a/jkube-kit/jkube-kit-smallrye/src/test/java/org/eclipse/jkube/smallrye/enricher/SmallRyeHealthCheckEnricherTest.java +++ b/jkube-kit/jkube-kit-smallrye/src/test/java/org/eclipse/jkube/smallrye/enricher/SmallRyeHealthCheckEnricherTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/SpringBootDevtoolsUtils.java b/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/SpringBootDevtoolsUtils.java index 7de2ca76ca..b5a1323c83 100644 --- a/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/SpringBootDevtoolsUtils.java +++ b/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/SpringBootDevtoolsUtils.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/enricher/SpringBootHealthCheckEnricher.java b/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/enricher/SpringBootHealthCheckEnricher.java index 824339ba32..1ea40a2f19 100644 --- a/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/enricher/SpringBootHealthCheckEnricher.java +++ b/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/enricher/SpringBootHealthCheckEnricher.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/SpringBootGenerator.java b/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/SpringBootGenerator.java index db981edc3c..764ff8e099 100644 --- a/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/SpringBootGenerator.java +++ b/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/SpringBootGenerator.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/watcher/SpringBootWatcher.java b/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/watcher/SpringBootWatcher.java index 0652b4107a..68dad5249f 100644 --- a/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/watcher/SpringBootWatcher.java +++ b/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/watcher/SpringBootWatcher.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/SpringBootDevtoolsUtilsTest.java b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/SpringBootDevtoolsUtilsTest.java index 5487d97e9a..53fbb1eea4 100644 --- a/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/SpringBootDevtoolsUtilsTest.java +++ b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/SpringBootDevtoolsUtilsTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/enricher/AbstractSpringBootHealthCheckEnricherTestSupport.java b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/enricher/AbstractSpringBootHealthCheckEnricherTestSupport.java index 7046de780a..ee07e5bf2b 100644 --- a/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/enricher/AbstractSpringBootHealthCheckEnricherTestSupport.java +++ b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/enricher/AbstractSpringBootHealthCheckEnricherTestSupport.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/enricher/SpringBoot1HealthCheckEnricherTest.java b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/enricher/SpringBoot1HealthCheckEnricherTest.java index 3be22d5c40..c266a92005 100644 --- a/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/enricher/SpringBoot1HealthCheckEnricherTest.java +++ b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/enricher/SpringBoot1HealthCheckEnricherTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/enricher/SpringBoot2HealthCheckEnricherTest.java b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/enricher/SpringBoot2HealthCheckEnricherTest.java index 507f09777b..3e288cf607 100644 --- a/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/enricher/SpringBoot2HealthCheckEnricherTest.java +++ b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/enricher/SpringBoot2HealthCheckEnricherTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/generator/SpringBootGeneratorIntegrationTest.java b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/generator/SpringBootGeneratorIntegrationTest.java index 9b352f420a..60633943c3 100644 --- a/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/generator/SpringBootGeneratorIntegrationTest.java +++ b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/generator/SpringBootGeneratorIntegrationTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/generator/SpringBootGeneratorTest.java b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/generator/SpringBootGeneratorTest.java index 109b81a9d5..89d6a20a4c 100644 --- a/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/generator/SpringBootGeneratorTest.java +++ b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/generator/SpringBootGeneratorTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/watcher/SpringBootWatcherIntegrationTest.java b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/watcher/SpringBootWatcherIntegrationTest.java index d33857bc69..d0ca04bf21 100644 --- a/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/watcher/SpringBootWatcherIntegrationTest.java +++ b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/watcher/SpringBootWatcherIntegrationTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/watcher/SpringBootWatcherTest.java b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/watcher/SpringBootWatcherTest.java index aafe94839a..c7583fe33a 100644 --- a/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/watcher/SpringBootWatcherTest.java +++ b/jkube-kit/jkube-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/watcher/SpringBootWatcherTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-thorntail-v2/src/main/java/org/eclipse/jkube/thorntail/v2/enricher/ThorntailV2HealthCheckEnricher.java b/jkube-kit/jkube-kit-thorntail-v2/src/main/java/org/eclipse/jkube/thorntail/v2/enricher/ThorntailV2HealthCheckEnricher.java index 7f66999486..c85b4cc7b3 100644 --- a/jkube-kit/jkube-kit-thorntail-v2/src/main/java/org/eclipse/jkube/thorntail/v2/enricher/ThorntailV2HealthCheckEnricher.java +++ b/jkube-kit/jkube-kit-thorntail-v2/src/main/java/org/eclipse/jkube/thorntail/v2/enricher/ThorntailV2HealthCheckEnricher.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-thorntail-v2/src/main/java/org/eclipse/jkube/thorntail/v2/generator/ThorntailV2Generator.java b/jkube-kit/jkube-kit-thorntail-v2/src/main/java/org/eclipse/jkube/thorntail/v2/generator/ThorntailV2Generator.java index 9d5e730114..760b98fbca 100644 --- a/jkube-kit/jkube-kit-thorntail-v2/src/main/java/org/eclipse/jkube/thorntail/v2/generator/ThorntailV2Generator.java +++ b/jkube-kit/jkube-kit-thorntail-v2/src/main/java/org/eclipse/jkube/thorntail/v2/generator/ThorntailV2Generator.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-thorntail-v2/src/test/java/org/eclipse/jkube/thorntail/v2/enricher/ThorntailV2HealthCheckEnricherTest.java b/jkube-kit/jkube-kit-thorntail-v2/src/test/java/org/eclipse/jkube/thorntail/v2/enricher/ThorntailV2HealthCheckEnricherTest.java index 1a200ff0b6..868ded0487 100644 --- a/jkube-kit/jkube-kit-thorntail-v2/src/test/java/org/eclipse/jkube/thorntail/v2/enricher/ThorntailV2HealthCheckEnricherTest.java +++ b/jkube-kit/jkube-kit-thorntail-v2/src/test/java/org/eclipse/jkube/thorntail/v2/enricher/ThorntailV2HealthCheckEnricherTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-thorntail-v2/src/test/java/org/eclipse/jkube/thorntail/v2/generator/ThorntailV2GeneratorIsApplicableTest.java b/jkube-kit/jkube-kit-thorntail-v2/src/test/java/org/eclipse/jkube/thorntail/v2/generator/ThorntailV2GeneratorIsApplicableTest.java index 07ec4eec0a..227b62be75 100644 --- a/jkube-kit/jkube-kit-thorntail-v2/src/test/java/org/eclipse/jkube/thorntail/v2/generator/ThorntailV2GeneratorIsApplicableTest.java +++ b/jkube-kit/jkube-kit-thorntail-v2/src/test/java/org/eclipse/jkube/thorntail/v2/generator/ThorntailV2GeneratorIsApplicableTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-vertx/src/main/java/org/eclipse/jkube/vertx/enricher/VertxHealthCheckEnricher.java b/jkube-kit/jkube-kit-vertx/src/main/java/org/eclipse/jkube/vertx/enricher/VertxHealthCheckEnricher.java index 926ac99496..ed5bf9e772 100644 --- a/jkube-kit/jkube-kit-vertx/src/main/java/org/eclipse/jkube/vertx/enricher/VertxHealthCheckEnricher.java +++ b/jkube-kit/jkube-kit-vertx/src/main/java/org/eclipse/jkube/vertx/enricher/VertxHealthCheckEnricher.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-vertx/src/main/java/org/eclipse/jkube/vertx/generator/Constants.java b/jkube-kit/jkube-kit-vertx/src/main/java/org/eclipse/jkube/vertx/generator/Constants.java index a0a6b5cb43..4afd748ed9 100644 --- a/jkube-kit/jkube-kit-vertx/src/main/java/org/eclipse/jkube/vertx/generator/Constants.java +++ b/jkube-kit/jkube-kit-vertx/src/main/java/org/eclipse/jkube/vertx/generator/Constants.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-vertx/src/main/java/org/eclipse/jkube/vertx/generator/VertxGenerator.java b/jkube-kit/jkube-kit-vertx/src/main/java/org/eclipse/jkube/vertx/generator/VertxGenerator.java index 50aa73aa47..13e46f6339 100644 --- a/jkube-kit/jkube-kit-vertx/src/main/java/org/eclipse/jkube/vertx/generator/VertxGenerator.java +++ b/jkube-kit/jkube-kit-vertx/src/main/java/org/eclipse/jkube/vertx/generator/VertxGenerator.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-vertx/src/main/java/org/eclipse/jkube/vertx/generator/VertxPortsExtractor.java b/jkube-kit/jkube-kit-vertx/src/main/java/org/eclipse/jkube/vertx/generator/VertxPortsExtractor.java index b092e5447e..91d403bd57 100644 --- a/jkube-kit/jkube-kit-vertx/src/main/java/org/eclipse/jkube/vertx/generator/VertxPortsExtractor.java +++ b/jkube-kit/jkube-kit-vertx/src/main/java/org/eclipse/jkube/vertx/generator/VertxPortsExtractor.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-vertx/src/test/java/org/eclipse/jkube/vertx/enricher/VertxHealthCheckEnricherTest.java b/jkube-kit/jkube-kit-vertx/src/test/java/org/eclipse/jkube/vertx/enricher/VertxHealthCheckEnricherTest.java index eb70d95eb5..936b4d94eb 100644 --- a/jkube-kit/jkube-kit-vertx/src/test/java/org/eclipse/jkube/vertx/enricher/VertxHealthCheckEnricherTest.java +++ b/jkube-kit/jkube-kit-vertx/src/test/java/org/eclipse/jkube/vertx/enricher/VertxHealthCheckEnricherTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-vertx/src/test/java/org/eclipse/jkube/vertx/generator/VertxGeneratorIsApplicableTest.java b/jkube-kit/jkube-kit-vertx/src/test/java/org/eclipse/jkube/vertx/generator/VertxGeneratorIsApplicableTest.java index 420f7a7466..b4a575de21 100644 --- a/jkube-kit/jkube-kit-vertx/src/test/java/org/eclipse/jkube/vertx/generator/VertxGeneratorIsApplicableTest.java +++ b/jkube-kit/jkube-kit-vertx/src/test/java/org/eclipse/jkube/vertx/generator/VertxGeneratorIsApplicableTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-vertx/src/test/java/org/eclipse/jkube/vertx/generator/VertxGeneratorTest.java b/jkube-kit/jkube-kit-vertx/src/test/java/org/eclipse/jkube/vertx/generator/VertxGeneratorTest.java index 283a02f9fe..65daae976e 100644 --- a/jkube-kit/jkube-kit-vertx/src/test/java/org/eclipse/jkube/vertx/generator/VertxGeneratorTest.java +++ b/jkube-kit/jkube-kit-vertx/src/test/java/org/eclipse/jkube/vertx/generator/VertxGeneratorTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-vertx/src/test/java/org/eclipse/jkube/vertx/generator/VertxPortsExtractorTest.java b/jkube-kit/jkube-kit-vertx/src/test/java/org/eclipse/jkube/vertx/generator/VertxPortsExtractorTest.java index e633af88d6..40e4f11508 100644 --- a/jkube-kit/jkube-kit-vertx/src/test/java/org/eclipse/jkube/vertx/generator/VertxPortsExtractorTest.java +++ b/jkube-kit/jkube-kit-vertx/src/test/java/org/eclipse/jkube/vertx/generator/VertxPortsExtractorTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-wildfly-jar/src/main/java/org/eclipse/jkube/wildfly/jar/WildflyJarUtils.java b/jkube-kit/jkube-kit-wildfly-jar/src/main/java/org/eclipse/jkube/wildfly/jar/WildflyJarUtils.java index 06f8014c72..e1d44d4274 100644 --- a/jkube-kit/jkube-kit-wildfly-jar/src/main/java/org/eclipse/jkube/wildfly/jar/WildflyJarUtils.java +++ b/jkube-kit/jkube-kit-wildfly-jar/src/main/java/org/eclipse/jkube/wildfly/jar/WildflyJarUtils.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-wildfly-jar/src/main/java/org/eclipse/jkube/wildfly/jar/enricher/WildflyJARHealthCheckEnricher.java b/jkube-kit/jkube-kit-wildfly-jar/src/main/java/org/eclipse/jkube/wildfly/jar/enricher/WildflyJARHealthCheckEnricher.java index 119fe73655..0a9da88fe7 100644 --- a/jkube-kit/jkube-kit-wildfly-jar/src/main/java/org/eclipse/jkube/wildfly/jar/enricher/WildflyJARHealthCheckEnricher.java +++ b/jkube-kit/jkube-kit-wildfly-jar/src/main/java/org/eclipse/jkube/wildfly/jar/enricher/WildflyJARHealthCheckEnricher.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-wildfly-jar/src/main/java/org/eclipse/jkube/wildfly/jar/generator/WildflyJARGenerator.java b/jkube-kit/jkube-kit-wildfly-jar/src/main/java/org/eclipse/jkube/wildfly/jar/generator/WildflyJARGenerator.java index 69bb2e64ad..85ff74dbc2 100644 --- a/jkube-kit/jkube-kit-wildfly-jar/src/main/java/org/eclipse/jkube/wildfly/jar/generator/WildflyJARGenerator.java +++ b/jkube-kit/jkube-kit-wildfly-jar/src/main/java/org/eclipse/jkube/wildfly/jar/generator/WildflyJARGenerator.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-wildfly-jar/src/test/java/org/eclipse/jkube/wildfly/jar/WildflyJarUtilsTest.java b/jkube-kit/jkube-kit-wildfly-jar/src/test/java/org/eclipse/jkube/wildfly/jar/WildflyJarUtilsTest.java index ee9603ee07..3e115fbec0 100644 --- a/jkube-kit/jkube-kit-wildfly-jar/src/test/java/org/eclipse/jkube/wildfly/jar/WildflyJarUtilsTest.java +++ b/jkube-kit/jkube-kit-wildfly-jar/src/test/java/org/eclipse/jkube/wildfly/jar/WildflyJarUtilsTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-wildfly-jar/src/test/java/org/eclipse/jkube/wildfly/jar/enricher/WildflyJARHealthCheckEnricherTest.java b/jkube-kit/jkube-kit-wildfly-jar/src/test/java/org/eclipse/jkube/wildfly/jar/enricher/WildflyJARHealthCheckEnricherTest.java index 3fe5b8664e..df2dd17bb2 100644 --- a/jkube-kit/jkube-kit-wildfly-jar/src/test/java/org/eclipse/jkube/wildfly/jar/enricher/WildflyJARHealthCheckEnricherTest.java +++ b/jkube-kit/jkube-kit-wildfly-jar/src/test/java/org/eclipse/jkube/wildfly/jar/enricher/WildflyJARHealthCheckEnricherTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/jkube-kit-wildfly-jar/src/test/java/org/eclipse/jkube/wildfly/jar/generator/WildflyJARGeneratorTest.java b/jkube-kit/jkube-kit-wildfly-jar/src/test/java/org/eclipse/jkube/wildfly/jar/generator/WildflyJARGeneratorTest.java index 84f8b1a3ed..57d6725bb8 100644 --- a/jkube-kit/jkube-kit-wildfly-jar/src/test/java/org/eclipse/jkube/wildfly/jar/generator/WildflyJARGeneratorTest.java +++ b/jkube-kit/jkube-kit-wildfly-jar/src/test/java/org/eclipse/jkube/wildfly/jar/generator/WildflyJARGeneratorTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/profile/src/main/java/org/eclipse/jkube/kit/profile/Profile.java b/jkube-kit/profile/src/main/java/org/eclipse/jkube/kit/profile/Profile.java index 8028c265fb..de863de3c7 100644 --- a/jkube-kit/profile/src/main/java/org/eclipse/jkube/kit/profile/Profile.java +++ b/jkube-kit/profile/src/main/java/org/eclipse/jkube/kit/profile/Profile.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/profile/src/main/java/org/eclipse/jkube/kit/profile/ProfileUtil.java b/jkube-kit/profile/src/main/java/org/eclipse/jkube/kit/profile/ProfileUtil.java index 5de6ffabd1..27f78882dd 100644 --- a/jkube-kit/profile/src/main/java/org/eclipse/jkube/kit/profile/ProfileUtil.java +++ b/jkube-kit/profile/src/main/java/org/eclipse/jkube/kit/profile/ProfileUtil.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/profile/src/test/java/org/eclipse/jkube/kit/profile/ProfileUtilTest.java b/jkube-kit/profile/src/test/java/org/eclipse/jkube/kit/profile/ProfileUtilTest.java index ad74932a05..b4f6cd7ee8 100644 --- a/jkube-kit/profile/src/test/java/org/eclipse/jkube/kit/profile/ProfileUtilTest.java +++ b/jkube-kit/profile/src/test/java/org/eclipse/jkube/kit/profile/ProfileUtilTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/KubernetesSshServiceForwarder.java b/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/KubernetesSshServiceForwarder.java index 5d8b9c438c..448142bc9f 100644 --- a/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/KubernetesSshServiceForwarder.java +++ b/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/KubernetesSshServiceForwarder.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/LocalService.java b/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/LocalService.java index d26af80f74..2a7e6268d6 100644 --- a/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/LocalService.java +++ b/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/LocalService.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/LocalServiceManager.java b/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/LocalServiceManager.java index 7032f0e4c8..8bb2453b1f 100644 --- a/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/LocalServiceManager.java +++ b/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/LocalServiceManager.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/PortForwarder.java b/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/PortForwarder.java index 50263498e8..28bfec87b3 100644 --- a/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/PortForwarder.java +++ b/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/PortForwarder.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/RemoteDevelopmentConfig.java b/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/RemoteDevelopmentConfig.java index c06e2ec4e7..15304d30db 100644 --- a/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/RemoteDevelopmentConfig.java +++ b/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/RemoteDevelopmentConfig.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/RemoteDevelopmentContext.java b/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/RemoteDevelopmentContext.java index d8135dd368..cb9cc4b51a 100644 --- a/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/RemoteDevelopmentContext.java +++ b/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/RemoteDevelopmentContext.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/RemoteDevelopmentService.java b/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/RemoteDevelopmentService.java index ca0034753a..b4ca62f5a7 100644 --- a/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/RemoteDevelopmentService.java +++ b/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/RemoteDevelopmentService.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/RemoteService.java b/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/RemoteService.java index eece94b633..4093fd4e59 100644 --- a/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/RemoteService.java +++ b/jkube-kit/remote-dev/src/main/java/org/eclipse/jkube/kit/remotedev/RemoteService.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/remote-dev/src/test/java/org/eclipse/jkube/kit/remotedev/KubernetesSshServiceForwarderTest.java b/jkube-kit/remote-dev/src/test/java/org/eclipse/jkube/kit/remotedev/KubernetesSshServiceForwarderTest.java index 36bfd7a88f..7f28202467 100644 --- a/jkube-kit/remote-dev/src/test/java/org/eclipse/jkube/kit/remotedev/KubernetesSshServiceForwarderTest.java +++ b/jkube-kit/remote-dev/src/test/java/org/eclipse/jkube/kit/remotedev/KubernetesSshServiceForwarderTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/remote-dev/src/test/java/org/eclipse/jkube/kit/remotedev/LocalServiceManagerTest.java b/jkube-kit/remote-dev/src/test/java/org/eclipse/jkube/kit/remotedev/LocalServiceManagerTest.java index 84959f19c4..01b087e314 100644 --- a/jkube-kit/remote-dev/src/test/java/org/eclipse/jkube/kit/remotedev/LocalServiceManagerTest.java +++ b/jkube-kit/remote-dev/src/test/java/org/eclipse/jkube/kit/remotedev/LocalServiceManagerTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/remote-dev/src/test/java/org/eclipse/jkube/kit/remotedev/PortForwarderTest.java b/jkube-kit/remote-dev/src/test/java/org/eclipse/jkube/kit/remotedev/PortForwarderTest.java index a434456879..05b1fe48b1 100644 --- a/jkube-kit/remote-dev/src/test/java/org/eclipse/jkube/kit/remotedev/PortForwarderTest.java +++ b/jkube-kit/remote-dev/src/test/java/org/eclipse/jkube/kit/remotedev/PortForwarderTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/remote-dev/src/test/java/org/eclipse/jkube/kit/remotedev/RemoteDevelopmentServiceTest.java b/jkube-kit/remote-dev/src/test/java/org/eclipse/jkube/kit/remotedev/RemoteDevelopmentServiceTest.java index 6297f7a82c..2fc692e7ea 100644 --- a/jkube-kit/remote-dev/src/test/java/org/eclipse/jkube/kit/remotedev/RemoteDevelopmentServiceTest.java +++ b/jkube-kit/remote-dev/src/test/java/org/eclipse/jkube/kit/remotedev/RemoteDevelopmentServiceTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/remote-dev/src/test/java/org/eclipse/jkube/kit/remotedev/SshServerExtension.java b/jkube-kit/remote-dev/src/test/java/org/eclipse/jkube/kit/remotedev/SshServerExtension.java index 088de3a848..872c374a40 100644 --- a/jkube-kit/remote-dev/src/test/java/org/eclipse/jkube/kit/remotedev/SshServerExtension.java +++ b/jkube-kit/remote-dev/src/test/java/org/eclipse/jkube/kit/remotedev/SshServerExtension.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ArtifactoryHelmRepositoryUploader.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ArtifactoryHelmRepositoryUploader.java index 362bbeb367..25f44e9fc6 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ArtifactoryHelmRepositoryUploader.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ArtifactoryHelmRepositoryUploader.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/BadUploadException.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/BadUploadException.java index 52aa01b8aa..d863336e27 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/BadUploadException.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/BadUploadException.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/Chart.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/Chart.java index 60fc084a43..63bb15c824 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/Chart.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/Chart.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ChartMuseumHelmRepositoryUploader.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ChartMuseumHelmRepositoryUploader.java index 9906687bd6..38d40d3ef1 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ChartMuseumHelmRepositoryUploader.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ChartMuseumHelmRepositoryUploader.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/GeneratedChartListener.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/GeneratedChartListener.java index 39a9121cb0..97220a0754 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/GeneratedChartListener.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/GeneratedChartListener.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmConfig.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmConfig.java index f3e4982b75..89c54e6b5d 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmConfig.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmConfig.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmDependency.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmDependency.java index 5b2a5808ff..b850a3cf22 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmDependency.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmDependency.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmParameter.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmParameter.java index 238e15b87d..004d55ee3b 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmParameter.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmParameter.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmRepository.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmRepository.java index 9ffdd57b15..98e4f99b45 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmRepository.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmRepository.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmRepositoryConnectionUtils.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmRepositoryConnectionUtils.java index 21bac009ff..401c70d9f5 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmRepositoryConnectionUtils.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmRepositoryConnectionUtils.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmService.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmService.java index 97d5083f98..192c44c1e7 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmService.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmService.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUtil.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUtil.java index fd39450f58..ffcd047a49 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUtil.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUtil.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploader.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploader.java index 26b46b504b..c72d9845a8 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploader.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploader.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManager.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManager.java index 2d8d67b836..c10718d904 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManager.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManager.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/NexusHelmRepositoryUploader.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/NexusHelmRepositoryUploader.java index dd0cc4380b..be5e62fc96 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/NexusHelmRepositoryUploader.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/NexusHelmRepositoryUploader.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/StandardRepositoryUploader.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/StandardRepositoryUploader.java index e03bb4d203..0979d538da 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/StandardRepositoryUploader.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/StandardRepositoryUploader.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/ChartTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/ChartTest.java index 00122c3912..2a50cbbd5d 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/ChartTest.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/ChartTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmConfigTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmConfigTest.java index 9b425fa393..f0d9a30de4 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmConfigTest.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmConfigTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmDependencyTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmDependencyTest.java index 2993c9ed4f..b64c4f8b4f 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmDependencyTest.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmDependencyTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmRepositoryTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmRepositoryTest.java index bcdf392774..5fff4006dc 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmRepositoryTest.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmRepositoryTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceIT.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceIT.java index 4277416cfa..c7aee9a4b9 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceIT.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceIT.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceTest.java index e8b870edae..3cf3f68c09 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceTest.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUploadIT.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUploadIT.java index 449f387d75..aac06aa401 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUploadIT.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUploadIT.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUtilTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUtilTest.java index 683667bdee..1c6471f9d1 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUtilTest.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUtilTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManagerTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManagerTest.java index 4722612c15..8c22557bbb 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManagerTest.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManagerTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/service/src/main/java/org/eclipse/jkube/kit/resource/service/DefaultResourceService.java b/jkube-kit/resource/service/src/main/java/org/eclipse/jkube/kit/resource/service/DefaultResourceService.java index a22c6bb83d..36defc64ce 100644 --- a/jkube-kit/resource/service/src/main/java/org/eclipse/jkube/kit/resource/service/DefaultResourceService.java +++ b/jkube-kit/resource/service/src/main/java/org/eclipse/jkube/kit/resource/service/DefaultResourceService.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/service/src/main/java/org/eclipse/jkube/kit/resource/service/TemplateUtil.java b/jkube-kit/resource/service/src/main/java/org/eclipse/jkube/kit/resource/service/TemplateUtil.java index bc1808e720..319c440717 100644 --- a/jkube-kit/resource/service/src/main/java/org/eclipse/jkube/kit/resource/service/TemplateUtil.java +++ b/jkube-kit/resource/service/src/main/java/org/eclipse/jkube/kit/resource/service/TemplateUtil.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/service/src/main/java/org/eclipse/jkube/kit/resource/service/WriteUtil.java b/jkube-kit/resource/service/src/main/java/org/eclipse/jkube/kit/resource/service/WriteUtil.java index 242af7ed42..13824f1459 100644 --- a/jkube-kit/resource/service/src/main/java/org/eclipse/jkube/kit/resource/service/WriteUtil.java +++ b/jkube-kit/resource/service/src/main/java/org/eclipse/jkube/kit/resource/service/WriteUtil.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/service/src/test/java/org/eclipse/jkube/kit/resource/service/DefaultResourceServiceTest.java b/jkube-kit/resource/service/src/test/java/org/eclipse/jkube/kit/resource/service/DefaultResourceServiceTest.java index 6bb357233d..c2f8e74b8d 100644 --- a/jkube-kit/resource/service/src/test/java/org/eclipse/jkube/kit/resource/service/DefaultResourceServiceTest.java +++ b/jkube-kit/resource/service/src/test/java/org/eclipse/jkube/kit/resource/service/DefaultResourceServiceTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/service/src/test/java/org/eclipse/jkube/kit/resource/service/TemplateUtilTest.java b/jkube-kit/resource/service/src/test/java/org/eclipse/jkube/kit/resource/service/TemplateUtilTest.java index 5b8bbe1ee7..1fc717ef25 100644 --- a/jkube-kit/resource/service/src/test/java/org/eclipse/jkube/kit/resource/service/TemplateUtilTest.java +++ b/jkube-kit/resource/service/src/test/java/org/eclipse/jkube/kit/resource/service/TemplateUtilTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/service/src/test/java/org/eclipse/jkube/kit/resource/service/WriteUtilTest.java b/jkube-kit/resource/service/src/test/java/org/eclipse/jkube/kit/resource/service/WriteUtilTest.java index f6069859bf..c0fea32af9 100644 --- a/jkube-kit/resource/service/src/test/java/org/eclipse/jkube/kit/resource/service/WriteUtilTest.java +++ b/jkube-kit/resource/service/src/test/java/org/eclipse/jkube/kit/resource/service/WriteUtilTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/watcher/api/src/main/java/org/eclipse/jkube/watcher/api/BaseWatcher.java b/jkube-kit/watcher/api/src/main/java/org/eclipse/jkube/watcher/api/BaseWatcher.java index d393883200..0641492fc1 100644 --- a/jkube-kit/watcher/api/src/main/java/org/eclipse/jkube/watcher/api/BaseWatcher.java +++ b/jkube-kit/watcher/api/src/main/java/org/eclipse/jkube/watcher/api/BaseWatcher.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/watcher/api/src/main/java/org/eclipse/jkube/watcher/api/Watcher.java b/jkube-kit/watcher/api/src/main/java/org/eclipse/jkube/watcher/api/Watcher.java index 869dd3c3ac..e626221caa 100644 --- a/jkube-kit/watcher/api/src/main/java/org/eclipse/jkube/watcher/api/Watcher.java +++ b/jkube-kit/watcher/api/src/main/java/org/eclipse/jkube/watcher/api/Watcher.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/watcher/api/src/main/java/org/eclipse/jkube/watcher/api/WatcherConfig.java b/jkube-kit/watcher/api/src/main/java/org/eclipse/jkube/watcher/api/WatcherConfig.java index b59606b988..3adb833054 100644 --- a/jkube-kit/watcher/api/src/main/java/org/eclipse/jkube/watcher/api/WatcherConfig.java +++ b/jkube-kit/watcher/api/src/main/java/org/eclipse/jkube/watcher/api/WatcherConfig.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/watcher/api/src/main/java/org/eclipse/jkube/watcher/api/WatcherContext.java b/jkube-kit/watcher/api/src/main/java/org/eclipse/jkube/watcher/api/WatcherContext.java index bf37433c38..a9c3b9d93c 100644 --- a/jkube-kit/watcher/api/src/main/java/org/eclipse/jkube/watcher/api/WatcherContext.java +++ b/jkube-kit/watcher/api/src/main/java/org/eclipse/jkube/watcher/api/WatcherContext.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/watcher/api/src/main/java/org/eclipse/jkube/watcher/api/WatcherManager.java b/jkube-kit/watcher/api/src/main/java/org/eclipse/jkube/watcher/api/WatcherManager.java index 0127531ef8..01a244715e 100644 --- a/jkube-kit/watcher/api/src/main/java/org/eclipse/jkube/watcher/api/WatcherManager.java +++ b/jkube-kit/watcher/api/src/main/java/org/eclipse/jkube/watcher/api/WatcherManager.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/watcher/api/src/test/java/org/eclipse/jkube/watcher/api/WatcherManagerTest.java b/jkube-kit/watcher/api/src/test/java/org/eclipse/jkube/watcher/api/WatcherManagerTest.java index 51c531ba42..5f742e2722 100644 --- a/jkube-kit/watcher/api/src/test/java/org/eclipse/jkube/watcher/api/WatcherManagerTest.java +++ b/jkube-kit/watcher/api/src/test/java/org/eclipse/jkube/watcher/api/WatcherManagerTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/watcher/standard/src/main/java/org/eclipse/jkube/watcher/standard/DockerImageWatcher.java b/jkube-kit/watcher/standard/src/main/java/org/eclipse/jkube/watcher/standard/DockerImageWatcher.java index f89cc961ed..17eba41bd1 100644 --- a/jkube-kit/watcher/standard/src/main/java/org/eclipse/jkube/watcher/standard/DockerImageWatcher.java +++ b/jkube-kit/watcher/standard/src/main/java/org/eclipse/jkube/watcher/standard/DockerImageWatcher.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/watcher/standard/src/main/java/org/eclipse/jkube/watcher/standard/ExecListenerLatch.java b/jkube-kit/watcher/standard/src/main/java/org/eclipse/jkube/watcher/standard/ExecListenerLatch.java index 10e18fa1fe..b73f6ac32b 100644 --- a/jkube-kit/watcher/standard/src/main/java/org/eclipse/jkube/watcher/standard/ExecListenerLatch.java +++ b/jkube-kit/watcher/standard/src/main/java/org/eclipse/jkube/watcher/standard/ExecListenerLatch.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/watcher/standard/src/main/java/org/eclipse/jkube/watcher/standard/PodExecutor.java b/jkube-kit/watcher/standard/src/main/java/org/eclipse/jkube/watcher/standard/PodExecutor.java index f32b80e7cc..77b00941d1 100644 --- a/jkube-kit/watcher/standard/src/main/java/org/eclipse/jkube/watcher/standard/PodExecutor.java +++ b/jkube-kit/watcher/standard/src/main/java/org/eclipse/jkube/watcher/standard/PodExecutor.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/watcher/standard/src/test/java/org/eclipse/jkube/watcher/standard/DockerImageWatcherRestartContainerTest.java b/jkube-kit/watcher/standard/src/test/java/org/eclipse/jkube/watcher/standard/DockerImageWatcherRestartContainerTest.java index 8716649591..8ea8ee05ce 100644 --- a/jkube-kit/watcher/standard/src/test/java/org/eclipse/jkube/watcher/standard/DockerImageWatcherRestartContainerTest.java +++ b/jkube-kit/watcher/standard/src/test/java/org/eclipse/jkube/watcher/standard/DockerImageWatcherRestartContainerTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/watcher/standard/src/test/java/org/eclipse/jkube/watcher/standard/DockerImageWatcherTest.java b/jkube-kit/watcher/standard/src/test/java/org/eclipse/jkube/watcher/standard/DockerImageWatcherTest.java index 0368a74b90..3a1260c997 100644 --- a/jkube-kit/watcher/standard/src/test/java/org/eclipse/jkube/watcher/standard/DockerImageWatcherTest.java +++ b/jkube-kit/watcher/standard/src/test/java/org/eclipse/jkube/watcher/standard/DockerImageWatcherTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/watcher/standard/src/test/java/org/eclipse/jkube/watcher/standard/ExecListenerLatchTest.java b/jkube-kit/watcher/standard/src/test/java/org/eclipse/jkube/watcher/standard/ExecListenerLatchTest.java index 83d44241e0..acc52d17e0 100644 --- a/jkube-kit/watcher/standard/src/test/java/org/eclipse/jkube/watcher/standard/ExecListenerLatchTest.java +++ b/jkube-kit/watcher/standard/src/test/java/org/eclipse/jkube/watcher/standard/ExecListenerLatchTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/watcher/standard/src/test/java/org/eclipse/jkube/watcher/standard/PodExecutorTest.java b/jkube-kit/watcher/standard/src/test/java/org/eclipse/jkube/watcher/standard/PodExecutorTest.java index f4500f0fd8..83f60882f8 100644 --- a/jkube-kit/watcher/standard/src/test/java/org/eclipse/jkube/watcher/standard/PodExecutorTest.java +++ b/jkube-kit/watcher/standard/src/test/java/org/eclipse/jkube/watcher/standard/PodExecutorTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/configmap/src/main/java/zero/Application.java b/kubernetes-maven-plugin/it/src/it/configmap/src/main/java/zero/Application.java index 15176271d2..cb7f3f6414 100644 --- a/kubernetes-maven-plugin/it/src/it/configmap/src/main/java/zero/Application.java +++ b/kubernetes-maven-plugin/it/src/it/configmap/src/main/java/zero/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/configmap/src/main/java/zero/HelloController.java b/kubernetes-maven-plugin/it/src/it/configmap/src/main/java/zero/HelloController.java index f2e3183c5d..df1753a4e4 100644 --- a/kubernetes-maven-plugin/it/src/it/configmap/src/main/java/zero/HelloController.java +++ b/kubernetes-maven-plugin/it/src/it/configmap/src/main/java/zero/HelloController.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/configmap/verify.groovy b/kubernetes-maven-plugin/it/src/it/configmap/verify.groovy index 49df99b5d6..75b68b6f13 100644 --- a/kubernetes-maven-plugin/it/src/it/configmap/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/configmap/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/custom-environment/src/main/java/io/vertx/example/SimpleWebVerticle.java b/kubernetes-maven-plugin/it/src/it/custom-environment/src/main/java/io/vertx/example/SimpleWebVerticle.java index 88351a7b90..1dea5fccdf 100644 --- a/kubernetes-maven-plugin/it/src/it/custom-environment/src/main/java/io/vertx/example/SimpleWebVerticle.java +++ b/kubernetes-maven-plugin/it/src/it/custom-environment/src/main/java/io/vertx/example/SimpleWebVerticle.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/custom-environment/verify.groovy b/kubernetes-maven-plugin/it/src/it/custom-environment/verify.groovy index 4c8b31ca60..cdb72ef103 100644 --- a/kubernetes-maven-plugin/it/src/it/custom-environment/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/custom-environment/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/custom-raw-resources/verify.groovy b/kubernetes-maven-plugin/it/src/it/custom-raw-resources/verify.groovy index f9d854add8..611bd26fe3 100644 --- a/kubernetes-maven-plugin/it/src/it/custom-raw-resources/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/custom-raw-resources/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/dependency-resources/verify.groovy b/kubernetes-maven-plugin/it/src/it/dependency-resources/verify.groovy index 7e5e7fbd1b..9b7465fd0f 100644 --- a/kubernetes-maven-plugin/it/src/it/dependency-resources/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/dependency-resources/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/deployment-strategy-type-919/verify.groovy b/kubernetes-maven-plugin/it/src/it/deployment-strategy-type-919/verify.groovy index f1a2e45d39..b6fcd01ed5 100644 --- a/kubernetes-maven-plugin/it/src/it/deployment-strategy-type-919/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/deployment-strategy-type-919/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/docker-health-checks/verify.groovy b/kubernetes-maven-plugin/it/src/it/docker-health-checks/verify.groovy index 6a68fbd71a..0166ea6dc2 100644 --- a/kubernetes-maven-plugin/it/src/it/docker-health-checks/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/docker-health-checks/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/env-metadata/src/main/java/zero/Application.java b/kubernetes-maven-plugin/it/src/it/env-metadata/src/main/java/zero/Application.java index 15176271d2..cb7f3f6414 100644 --- a/kubernetes-maven-plugin/it/src/it/env-metadata/src/main/java/zero/Application.java +++ b/kubernetes-maven-plugin/it/src/it/env-metadata/src/main/java/zero/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/env-metadata/src/main/java/zero/HelloController.java b/kubernetes-maven-plugin/it/src/it/env-metadata/src/main/java/zero/HelloController.java index f2e3183c5d..df1753a4e4 100644 --- a/kubernetes-maven-plugin/it/src/it/env-metadata/src/main/java/zero/HelloController.java +++ b/kubernetes-maven-plugin/it/src/it/env-metadata/src/main/java/zero/HelloController.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/env-metadata/verify.groovy b/kubernetes-maven-plugin/it/src/it/env-metadata/verify.groovy index 6a68fbd71a..0166ea6dc2 100644 --- a/kubernetes-maven-plugin/it/src/it/env-metadata/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/env-metadata/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/fragments/verify.groovy b/kubernetes-maven-plugin/it/src/it/fragments/verify.groovy index 4d90677304..469881514f 100644 --- a/kubernetes-maven-plugin/it/src/it/fragments/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/fragments/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/helm-and-fragments/verify.groovy b/kubernetes-maven-plugin/it/src/it/helm-and-fragments/verify.groovy index 708ed41b48..439a3af126 100644 --- a/kubernetes-maven-plugin/it/src/it/helm-and-fragments/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/helm-and-fragments/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/ingress-xml-config/src/main/java/zero/Application.java b/kubernetes-maven-plugin/it/src/it/ingress-xml-config/src/main/java/zero/Application.java index 15176271d2..cb7f3f6414 100644 --- a/kubernetes-maven-plugin/it/src/it/ingress-xml-config/src/main/java/zero/Application.java +++ b/kubernetes-maven-plugin/it/src/it/ingress-xml-config/src/main/java/zero/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/ingress-xml-config/verify.groovy b/kubernetes-maven-plugin/it/src/it/ingress-xml-config/verify.groovy index 9ff3549c5a..05f5cf6df6 100644 --- a/kubernetes-maven-plugin/it/src/it/ingress-xml-config/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/ingress-xml-config/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/java-options-env-merge/verify.groovy b/kubernetes-maven-plugin/it/src/it/java-options-env-merge/verify.groovy index 8c33c45b21..87fb254ecc 100644 --- a/kubernetes-maven-plugin/it/src/it/java-options-env-merge/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/java-options-env-merge/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/metadata-labels-annotations/verify.groovy b/kubernetes-maven-plugin/it/src/it/metadata-labels-annotations/verify.groovy index 6a68fbd71a..0166ea6dc2 100644 --- a/kubernetes-maven-plugin/it/src/it/metadata-labels-annotations/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/metadata-labels-annotations/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/namespace/src/main/java/zero/Application.java b/kubernetes-maven-plugin/it/src/it/namespace/src/main/java/zero/Application.java index bfbc53ad89..370e6b6103 100644 --- a/kubernetes-maven-plugin/it/src/it/namespace/src/main/java/zero/Application.java +++ b/kubernetes-maven-plugin/it/src/it/namespace/src/main/java/zero/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/namespace/verify.groovy b/kubernetes-maven-plugin/it/src/it/namespace/verify.groovy index 0939d6d745..b7742ef68e 100644 --- a/kubernetes-maven-plugin/it/src/it/namespace/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/namespace/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/probes-xml-config/src/main/java/probe/Application.java b/kubernetes-maven-plugin/it/src/it/probes-xml-config/src/main/java/probe/Application.java index 15176271d2..cb7f3f6414 100644 --- a/kubernetes-maven-plugin/it/src/it/probes-xml-config/src/main/java/probe/Application.java +++ b/kubernetes-maven-plugin/it/src/it/probes-xml-config/src/main/java/probe/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/probes-xml-config/src/main/java/probe/HelloController.java b/kubernetes-maven-plugin/it/src/it/probes-xml-config/src/main/java/probe/HelloController.java index f2e3183c5d..df1753a4e4 100644 --- a/kubernetes-maven-plugin/it/src/it/probes-xml-config/src/main/java/probe/HelloController.java +++ b/kubernetes-maven-plugin/it/src/it/probes-xml-config/src/main/java/probe/HelloController.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/probes-xml-config/verify.groovy b/kubernetes-maven-plugin/it/src/it/probes-xml-config/verify.groovy index baf550699d..21bb953935 100644 --- a/kubernetes-maven-plugin/it/src/it/probes-xml-config/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/probes-xml-config/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/raw-resources/verify.groovy b/kubernetes-maven-plugin/it/src/it/raw-resources/verify.groovy index 4d90677304..469881514f 100644 --- a/kubernetes-maven-plugin/it/src/it/raw-resources/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/raw-resources/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/registry-286/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java b/kubernetes-maven-plugin/it/src/it/registry-286/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java index 70b07e455d..a7ce18b3e5 100644 --- a/kubernetes-maven-plugin/it/src/it/registry-286/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java +++ b/kubernetes-maven-plugin/it/src/it/registry-286/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/registry-286/verify.groovy b/kubernetes-maven-plugin/it/src/it/registry-286/verify.groovy index 4c8b31ca60..cdb72ef103 100644 --- a/kubernetes-maven-plugin/it/src/it/registry-286/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/registry-286/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/remote-resources/src/main/java/io/vertx/example/SimpleWebVerticle.java b/kubernetes-maven-plugin/it/src/it/remote-resources/src/main/java/io/vertx/example/SimpleWebVerticle.java index 88351a7b90..1dea5fccdf 100644 --- a/kubernetes-maven-plugin/it/src/it/remote-resources/src/main/java/io/vertx/example/SimpleWebVerticle.java +++ b/kubernetes-maven-plugin/it/src/it/remote-resources/src/main/java/io/vertx/example/SimpleWebVerticle.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/remote-resources/verify.groovy b/kubernetes-maven-plugin/it/src/it/remote-resources/verify.groovy index 3370cd801a..f542272740 100644 --- a/kubernetes-maven-plugin/it/src/it/remote-resources/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/remote-resources/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/revisionhistory/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java b/kubernetes-maven-plugin/it/src/it/revisionhistory/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java index ca965ece1c..ead1018db6 100644 --- a/kubernetes-maven-plugin/it/src/it/revisionhistory/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java +++ b/kubernetes-maven-plugin/it/src/it/revisionhistory/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/revisionhistory/src/main/java/io/fabric8/maven/sample/spring/boot/HelloController.java b/kubernetes-maven-plugin/it/src/it/revisionhistory/src/main/java/io/fabric8/maven/sample/spring/boot/HelloController.java index 4b37b8f49f..796a195deb 100644 --- a/kubernetes-maven-plugin/it/src/it/revisionhistory/src/main/java/io/fabric8/maven/sample/spring/boot/HelloController.java +++ b/kubernetes-maven-plugin/it/src/it/revisionhistory/src/main/java/io/fabric8/maven/sample/spring/boot/HelloController.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/revisionhistory/verify.groovy b/kubernetes-maven-plugin/it/src/it/revisionhistory/verify.groovy index 92d1c1142f..bac31614e5 100644 --- a/kubernetes-maven-plugin/it/src/it/revisionhistory/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/revisionhistory/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/secret-config/src/main/java/hello/Application.java b/kubernetes-maven-plugin/it/src/it/secret-config/src/main/java/hello/Application.java index 1d1b0b1bd1..4df192c3a9 100644 --- a/kubernetes-maven-plugin/it/src/it/secret-config/src/main/java/hello/Application.java +++ b/kubernetes-maven-plugin/it/src/it/secret-config/src/main/java/hello/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/secret-config/verify.groovy b/kubernetes-maven-plugin/it/src/it/secret-config/verify.groovy index b31644f7a1..c437d118ba 100644 --- a/kubernetes-maven-plugin/it/src/it/secret-config/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/secret-config/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/sidecar/src/main/java/zero/Application.java b/kubernetes-maven-plugin/it/src/it/sidecar/src/main/java/zero/Application.java index 15176271d2..cb7f3f6414 100644 --- a/kubernetes-maven-plugin/it/src/it/sidecar/src/main/java/zero/Application.java +++ b/kubernetes-maven-plugin/it/src/it/sidecar/src/main/java/zero/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/sidecar/src/main/java/zero/HelloController.java b/kubernetes-maven-plugin/it/src/it/sidecar/src/main/java/zero/HelloController.java index f2e3183c5d..df1753a4e4 100644 --- a/kubernetes-maven-plugin/it/src/it/sidecar/src/main/java/zero/HelloController.java +++ b/kubernetes-maven-plugin/it/src/it/sidecar/src/main/java/zero/HelloController.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/sidecar/verify.groovy b/kubernetes-maven-plugin/it/src/it/sidecar/verify.groovy index 4c8b31ca60..cdb72ef103 100644 --- a/kubernetes-maven-plugin/it/src/it/sidecar/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/sidecar/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/simple-maven-issue-mgmt/src/main/java/zero/Application.java b/kubernetes-maven-plugin/it/src/it/simple-maven-issue-mgmt/src/main/java/zero/Application.java index 15176271d2..cb7f3f6414 100644 --- a/kubernetes-maven-plugin/it/src/it/simple-maven-issue-mgmt/src/main/java/zero/Application.java +++ b/kubernetes-maven-plugin/it/src/it/simple-maven-issue-mgmt/src/main/java/zero/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/simple-maven-issue-mgmt/src/main/java/zero/HelloController.java b/kubernetes-maven-plugin/it/src/it/simple-maven-issue-mgmt/src/main/java/zero/HelloController.java index f2e3183c5d..df1753a4e4 100644 --- a/kubernetes-maven-plugin/it/src/it/simple-maven-issue-mgmt/src/main/java/zero/HelloController.java +++ b/kubernetes-maven-plugin/it/src/it/simple-maven-issue-mgmt/src/main/java/zero/HelloController.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/simple-maven-issue-mgmt/verify.groovy b/kubernetes-maven-plugin/it/src/it/simple-maven-issue-mgmt/verify.groovy index 6a68fbd71a..0166ea6dc2 100644 --- a/kubernetes-maven-plugin/it/src/it/simple-maven-issue-mgmt/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/simple-maven-issue-mgmt/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/simple-maven-scm/src/main/java/zero/Application.java b/kubernetes-maven-plugin/it/src/it/simple-maven-scm/src/main/java/zero/Application.java index 15176271d2..cb7f3f6414 100644 --- a/kubernetes-maven-plugin/it/src/it/simple-maven-scm/src/main/java/zero/Application.java +++ b/kubernetes-maven-plugin/it/src/it/simple-maven-scm/src/main/java/zero/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/simple-maven-scm/src/main/java/zero/HelloController.java b/kubernetes-maven-plugin/it/src/it/simple-maven-scm/src/main/java/zero/HelloController.java index f2e3183c5d..df1753a4e4 100644 --- a/kubernetes-maven-plugin/it/src/it/simple-maven-scm/src/main/java/zero/HelloController.java +++ b/kubernetes-maven-plugin/it/src/it/simple-maven-scm/src/main/java/zero/HelloController.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/simple-maven-scm/verify.groovy b/kubernetes-maven-plugin/it/src/it/simple-maven-scm/verify.groovy index 6a68fbd71a..0166ea6dc2 100644 --- a/kubernetes-maven-plugin/it/src/it/simple-maven-scm/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/simple-maven-scm/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-false/src/main/java/zero/Application.java b/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-false/src/main/java/zero/Application.java index 15176271d2..cb7f3f6414 100644 --- a/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-false/src/main/java/zero/Application.java +++ b/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-false/src/main/java/zero/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-false/src/main/java/zero/HelloController.java b/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-false/src/main/java/zero/HelloController.java index f2e3183c5d..df1753a4e4 100644 --- a/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-false/src/main/java/zero/HelloController.java +++ b/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-false/src/main/java/zero/HelloController.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-false/verify.groovy b/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-false/verify.groovy index 8546ba95df..8adacbb754 100644 --- a/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-false/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-false/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-true/src/main/java/zero/Application.java b/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-true/src/main/java/zero/Application.java index 15176271d2..cb7f3f6414 100644 --- a/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-true/src/main/java/zero/Application.java +++ b/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-true/src/main/java/zero/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-true/src/main/java/zero/HelloController.java b/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-true/src/main/java/zero/HelloController.java index f2e3183c5d..df1753a4e4 100644 --- a/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-true/src/main/java/zero/HelloController.java +++ b/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-true/src/main/java/zero/HelloController.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-true/verify.groovy b/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-true/verify.groovy index 8546ba95df..8adacbb754 100644 --- a/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-true/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/simple-with-route-flag-true/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/simple/src/main/java/zero/Application.java b/kubernetes-maven-plugin/it/src/it/simple/src/main/java/zero/Application.java index 15176271d2..cb7f3f6414 100644 --- a/kubernetes-maven-plugin/it/src/it/simple/src/main/java/zero/Application.java +++ b/kubernetes-maven-plugin/it/src/it/simple/src/main/java/zero/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/simple/src/main/java/zero/HelloController.java b/kubernetes-maven-plugin/it/src/it/simple/src/main/java/zero/HelloController.java index f2e3183c5d..df1753a4e4 100644 --- a/kubernetes-maven-plugin/it/src/it/simple/src/main/java/zero/HelloController.java +++ b/kubernetes-maven-plugin/it/src/it/simple/src/main/java/zero/HelloController.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/simple/verify.groovy b/kubernetes-maven-plugin/it/src/it/simple/verify.groovy index 00eff7ae61..6eb8ff0f9d 100644 --- a/kubernetes-maven-plugin/it/src/it/simple/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/simple/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/spring-boot/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java b/kubernetes-maven-plugin/it/src/it/spring-boot/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java index ca965ece1c..ead1018db6 100644 --- a/kubernetes-maven-plugin/it/src/it/spring-boot/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java +++ b/kubernetes-maven-plugin/it/src/it/spring-boot/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/spring-boot/src/main/java/io/fabric8/maven/sample/spring/boot/HelloController.java b/kubernetes-maven-plugin/it/src/it/spring-boot/src/main/java/io/fabric8/maven/sample/spring/boot/HelloController.java index 4b37b8f49f..796a195deb 100644 --- a/kubernetes-maven-plugin/it/src/it/spring-boot/src/main/java/io/fabric8/maven/sample/spring/boot/HelloController.java +++ b/kubernetes-maven-plugin/it/src/it/spring-boot/src/main/java/io/fabric8/maven/sample/spring/boot/HelloController.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/spring-boot/verify.groovy b/kubernetes-maven-plugin/it/src/it/spring-boot/verify.groovy index 87f553e23f..1f6a1cb514 100644 --- a/kubernetes-maven-plugin/it/src/it/spring-boot/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/spring-boot/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/statefulset/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java b/kubernetes-maven-plugin/it/src/it/statefulset/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java index 70b07e455d..a7ce18b3e5 100644 --- a/kubernetes-maven-plugin/it/src/it/statefulset/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java +++ b/kubernetes-maven-plugin/it/src/it/statefulset/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/statefulset/verify.groovy b/kubernetes-maven-plugin/it/src/it/statefulset/verify.groovy index 6a68fbd71a..0166ea6dc2 100644 --- a/kubernetes-maven-plugin/it/src/it/statefulset/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/statefulset/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/vertx-default/src/main/java/io/fabric8/maven/sample/vertx/HttpApplication.java b/kubernetes-maven-plugin/it/src/it/vertx-default/src/main/java/io/fabric8/maven/sample/vertx/HttpApplication.java index 37712d6e79..e10f7b7adc 100644 --- a/kubernetes-maven-plugin/it/src/it/vertx-default/src/main/java/io/fabric8/maven/sample/vertx/HttpApplication.java +++ b/kubernetes-maven-plugin/it/src/it/vertx-default/src/main/java/io/fabric8/maven/sample/vertx/HttpApplication.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/vertx-default/verify.groovy b/kubernetes-maven-plugin/it/src/it/vertx-default/verify.groovy index 4c8b31ca60..cdb72ef103 100644 --- a/kubernetes-maven-plugin/it/src/it/vertx-default/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/vertx-default/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/vertx-health-check/src/main/java/io/fabric8/maven/sample/vertx/HttpApplication.java b/kubernetes-maven-plugin/it/src/it/vertx-health-check/src/main/java/io/fabric8/maven/sample/vertx/HttpApplication.java index 37712d6e79..e10f7b7adc 100644 --- a/kubernetes-maven-plugin/it/src/it/vertx-health-check/src/main/java/io/fabric8/maven/sample/vertx/HttpApplication.java +++ b/kubernetes-maven-plugin/it/src/it/vertx-health-check/src/main/java/io/fabric8/maven/sample/vertx/HttpApplication.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/vertx-health-check/verify.groovy b/kubernetes-maven-plugin/it/src/it/vertx-health-check/verify.groovy index 92d1c1142f..bac31614e5 100644 --- a/kubernetes-maven-plugin/it/src/it/vertx-health-check/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/vertx-health-check/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/vertx/src/main/java/io/vertx/example/SimpleWebVerticle.java b/kubernetes-maven-plugin/it/src/it/vertx/src/main/java/io/vertx/example/SimpleWebVerticle.java index 88351a7b90..1dea5fccdf 100644 --- a/kubernetes-maven-plugin/it/src/it/vertx/src/main/java/io/vertx/example/SimpleWebVerticle.java +++ b/kubernetes-maven-plugin/it/src/it/vertx/src/main/java/io/vertx/example/SimpleWebVerticle.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/vertx/verify.groovy b/kubernetes-maven-plugin/it/src/it/vertx/verify.groovy index 4c8b31ca60..cdb72ef103 100644 --- a/kubernetes-maven-plugin/it/src/it/vertx/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/vertx/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/volume-enricher-custom-storage-class/verify.groovy b/kubernetes-maven-plugin/it/src/it/volume-enricher-custom-storage-class/verify.groovy index 25e143e7b7..006d98c339 100644 --- a/kubernetes-maven-plugin/it/src/it/volume-enricher-custom-storage-class/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/volume-enricher-custom-storage-class/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/volume-enricher-default-storage-class/verify.groovy b/kubernetes-maven-plugin/it/src/it/volume-enricher-default-storage-class/verify.groovy index 6a68fbd71a..0166ea6dc2 100644 --- a/kubernetes-maven-plugin/it/src/it/volume-enricher-default-storage-class/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/volume-enricher-default-storage-class/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/xml-image-multilayer/verify.groovy b/kubernetes-maven-plugin/it/src/it/xml-image-multilayer/verify.groovy index 772a430a91..7ebf3962ad 100644 --- a/kubernetes-maven-plugin/it/src/it/xml-image-multilayer/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/xml-image-multilayer/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/it/src/it/xml-image/verify.groovy b/kubernetes-maven-plugin/it/src/it/xml-image/verify.groovy index 8b4173e149..f82f706a9e 100644 --- a/kubernetes-maven-plugin/it/src/it/xml-image/verify.groovy +++ b/kubernetes-maven-plugin/it/src/it/xml-image/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/KitLoggerProvider.java b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/KitLoggerProvider.java index 13bbc056b3..50aaae808c 100644 --- a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/KitLoggerProvider.java +++ b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/KitLoggerProvider.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/ManifestProvider.java b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/ManifestProvider.java index 18ef81954a..935d75f19c 100644 --- a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/ManifestProvider.java +++ b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/ManifestProvider.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/AbstractDockerMojo.java b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/AbstractDockerMojo.java index f51e3a4930..b1e2a62968 100644 --- a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/AbstractDockerMojo.java +++ b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/AbstractDockerMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/AbstractJKubeMojo.java b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/AbstractJKubeMojo.java index 8c112ae4d8..d3643dd88f 100644 --- a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/AbstractJKubeMojo.java +++ b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/AbstractJKubeMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/ApplyMojo.java b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/ApplyMojo.java index e44a79fba3..20fe8a91bf 100644 --- a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/ApplyMojo.java +++ b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/ApplyMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/BuildMojo.java b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/BuildMojo.java index be452989a0..33281408a5 100644 --- a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/BuildMojo.java +++ b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/BuildMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/HelmMojo.java b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/HelmMojo.java index d4c3883674..e6440bc4a6 100644 --- a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/HelmMojo.java +++ b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/HelmMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/HelmPushMojo.java b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/HelmPushMojo.java index b23962fb4b..3dd7fbd99d 100644 --- a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/HelmPushMojo.java +++ b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/HelmPushMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/PushMojo.java b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/PushMojo.java index bf4d03df23..393be8ca53 100644 --- a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/PushMojo.java +++ b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/PushMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/ResourceMojo.java b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/ResourceMojo.java index 9499a4b86f..b40c44de24 100644 --- a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/ResourceMojo.java +++ b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/ResourceMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/DebugMojo.java b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/DebugMojo.java index 54de2d2853..fb10e61ec5 100644 --- a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/DebugMojo.java +++ b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/DebugMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/DeployMojo.java b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/DeployMojo.java index aa12734347..92d5f3d3de 100644 --- a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/DeployMojo.java +++ b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/DeployMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/LogMojo.java b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/LogMojo.java index b80ef42da8..8926401efa 100644 --- a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/LogMojo.java +++ b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/LogMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/RemoteDevMojo.java b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/RemoteDevMojo.java index 826350e9b6..430cff09c6 100644 --- a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/RemoteDevMojo.java +++ b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/RemoteDevMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/UndeployMojo.java b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/UndeployMojo.java index 8405f27e6f..9e8754ad9e 100644 --- a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/UndeployMojo.java +++ b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/UndeployMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/WatchMojo.java b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/WatchMojo.java index cde3c51559..5b25cb6763 100644 --- a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/WatchMojo.java +++ b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/WatchMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/util/MigrateMojo.java b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/util/MigrateMojo.java index 4ca18da8da..16698e796a 100644 --- a/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/util/MigrateMojo.java +++ b/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/util/MigrateMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/GeneratedPluginDescriptorTest.java b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/GeneratedPluginDescriptorTest.java index 241e82c049..00f093cf88 100644 --- a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/GeneratedPluginDescriptorTest.java +++ b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/GeneratedPluginDescriptorTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/ApplyMojoTest.java b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/ApplyMojoTest.java index 068101da12..47078d9f0d 100644 --- a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/ApplyMojoTest.java +++ b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/ApplyMojoTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/BuildMojoTest.java b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/BuildMojoTest.java index 2e0ae51e12..e1c9fbbf16 100644 --- a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/BuildMojoTest.java +++ b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/BuildMojoTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/HelmMojoPluginTest.java b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/HelmMojoPluginTest.java index 1ee69a7253..dcfc80401d 100644 --- a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/HelmMojoPluginTest.java +++ b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/HelmMojoPluginTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/HelmMojoTest.java b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/HelmMojoTest.java index 7c3e9e3d89..931c2150b2 100644 --- a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/HelmMojoTest.java +++ b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/HelmMojoTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/HelmPushMojoTest.java b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/HelmPushMojoTest.java index fb18800f71..8268795cc1 100644 --- a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/HelmPushMojoTest.java +++ b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/HelmPushMojoTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/ResourceMojoPluginTest.java b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/ResourceMojoPluginTest.java index a9c71a21ac..52a27c25b9 100644 --- a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/ResourceMojoPluginTest.java +++ b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/ResourceMojoPluginTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/ResourceMojoTest.java b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/ResourceMojoTest.java index b3003fb0d9..3f05436ba8 100644 --- a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/ResourceMojoTest.java +++ b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/ResourceMojoTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/SkipGoalsTest.java b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/SkipGoalsTest.java index bbd5a26eec..b206aa3f3c 100644 --- a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/SkipGoalsTest.java +++ b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/SkipGoalsTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/DebugMojoTest.java b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/DebugMojoTest.java index 3747bf6997..4cfdb209e2 100644 --- a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/DebugMojoTest.java +++ b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/DebugMojoTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/LogMojoTest.java b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/LogMojoTest.java index f6a65d6f38..2790ca1840 100644 --- a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/LogMojoTest.java +++ b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/LogMojoTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/RemoteDevMojoTest.java b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/RemoteDevMojoTest.java index 55fb937c1f..0220019b27 100644 --- a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/RemoteDevMojoTest.java +++ b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/RemoteDevMojoTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/UndeployMojoTest.java b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/UndeployMojoTest.java index 40a9ccb384..6dc76e6f0d 100644 --- a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/UndeployMojoTest.java +++ b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/UndeployMojoTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/WatchMojoTest.java b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/WatchMojoTest.java index bbfdaa02d6..da98723827 100644 --- a/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/WatchMojoTest.java +++ b/kubernetes-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/WatchMojoTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/configmap/src/main/java/zero/Application.java b/openshift-maven-plugin/it/src/it/configmap/src/main/java/zero/Application.java index 15176271d2..cb7f3f6414 100644 --- a/openshift-maven-plugin/it/src/it/configmap/src/main/java/zero/Application.java +++ b/openshift-maven-plugin/it/src/it/configmap/src/main/java/zero/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/configmap/src/main/java/zero/HelloController.java b/openshift-maven-plugin/it/src/it/configmap/src/main/java/zero/HelloController.java index f2e3183c5d..df1753a4e4 100644 --- a/openshift-maven-plugin/it/src/it/configmap/src/main/java/zero/HelloController.java +++ b/openshift-maven-plugin/it/src/it/configmap/src/main/java/zero/HelloController.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/configmap/verify.groovy b/openshift-maven-plugin/it/src/it/configmap/verify.groovy index 64eb3cbd2e..a68df2b070 100644 --- a/openshift-maven-plugin/it/src/it/configmap/verify.groovy +++ b/openshift-maven-plugin/it/src/it/configmap/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/custom-environment/src/main/java/io/vertx/example/SimpleWebVerticle.java b/openshift-maven-plugin/it/src/it/custom-environment/src/main/java/io/vertx/example/SimpleWebVerticle.java index 88351a7b90..1dea5fccdf 100644 --- a/openshift-maven-plugin/it/src/it/custom-environment/src/main/java/io/vertx/example/SimpleWebVerticle.java +++ b/openshift-maven-plugin/it/src/it/custom-environment/src/main/java/io/vertx/example/SimpleWebVerticle.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/custom-environment/verify.groovy b/openshift-maven-plugin/it/src/it/custom-environment/verify.groovy index c883195193..b9f7b0e8a8 100644 --- a/openshift-maven-plugin/it/src/it/custom-environment/verify.groovy +++ b/openshift-maven-plugin/it/src/it/custom-environment/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/custom-raw-resources/verify.groovy b/openshift-maven-plugin/it/src/it/custom-raw-resources/verify.groovy index 96c9641d61..8747ceee16 100644 --- a/openshift-maven-plugin/it/src/it/custom-raw-resources/verify.groovy +++ b/openshift-maven-plugin/it/src/it/custom-raw-resources/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/deployment-strategy-type-919/verify.groovy b/openshift-maven-plugin/it/src/it/deployment-strategy-type-919/verify.groovy index 4f0ca4ded8..80e12fb8bb 100644 --- a/openshift-maven-plugin/it/src/it/deployment-strategy-type-919/verify.groovy +++ b/openshift-maven-plugin/it/src/it/deployment-strategy-type-919/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/docker-health-checks/verify.groovy b/openshift-maven-plugin/it/src/it/docker-health-checks/verify.groovy index 4f0ca4ded8..80e12fb8bb 100644 --- a/openshift-maven-plugin/it/src/it/docker-health-checks/verify.groovy +++ b/openshift-maven-plugin/it/src/it/docker-health-checks/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/env-metadata/src/main/java/zero/Application.java b/openshift-maven-plugin/it/src/it/env-metadata/src/main/java/zero/Application.java index 15176271d2..cb7f3f6414 100644 --- a/openshift-maven-plugin/it/src/it/env-metadata/src/main/java/zero/Application.java +++ b/openshift-maven-plugin/it/src/it/env-metadata/src/main/java/zero/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/env-metadata/src/main/java/zero/HelloController.java b/openshift-maven-plugin/it/src/it/env-metadata/src/main/java/zero/HelloController.java index f2e3183c5d..df1753a4e4 100644 --- a/openshift-maven-plugin/it/src/it/env-metadata/src/main/java/zero/HelloController.java +++ b/openshift-maven-plugin/it/src/it/env-metadata/src/main/java/zero/HelloController.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/env-metadata/verify.groovy b/openshift-maven-plugin/it/src/it/env-metadata/verify.groovy index 4f0ca4ded8..80e12fb8bb 100644 --- a/openshift-maven-plugin/it/src/it/env-metadata/verify.groovy +++ b/openshift-maven-plugin/it/src/it/env-metadata/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/project/src/main/java/zero/Application.java b/openshift-maven-plugin/it/src/it/project/src/main/java/zero/Application.java index bfbc53ad89..370e6b6103 100644 --- a/openshift-maven-plugin/it/src/it/project/src/main/java/zero/Application.java +++ b/openshift-maven-plugin/it/src/it/project/src/main/java/zero/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/project/verify.groovy b/openshift-maven-plugin/it/src/it/project/verify.groovy index 538ead5807..9c8f85f81e 100644 --- a/openshift-maven-plugin/it/src/it/project/verify.groovy +++ b/openshift-maven-plugin/it/src/it/project/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/raw-resources/verify.groovy b/openshift-maven-plugin/it/src/it/raw-resources/verify.groovy index efa32cb1ef..3ebd889a8f 100644 --- a/openshift-maven-plugin/it/src/it/raw-resources/verify.groovy +++ b/openshift-maven-plugin/it/src/it/raw-resources/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/registry-286/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java b/openshift-maven-plugin/it/src/it/registry-286/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java index 70b07e455d..a7ce18b3e5 100644 --- a/openshift-maven-plugin/it/src/it/registry-286/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java +++ b/openshift-maven-plugin/it/src/it/registry-286/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/registry-286/verify.groovy b/openshift-maven-plugin/it/src/it/registry-286/verify.groovy index c883195193..b9f7b0e8a8 100644 --- a/openshift-maven-plugin/it/src/it/registry-286/verify.groovy +++ b/openshift-maven-plugin/it/src/it/registry-286/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/remote-resources/src/main/java/io/vertx/example/SimpleWebVerticle.java b/openshift-maven-plugin/it/src/it/remote-resources/src/main/java/io/vertx/example/SimpleWebVerticle.java index 88351a7b90..1dea5fccdf 100644 --- a/openshift-maven-plugin/it/src/it/remote-resources/src/main/java/io/vertx/example/SimpleWebVerticle.java +++ b/openshift-maven-plugin/it/src/it/remote-resources/src/main/java/io/vertx/example/SimpleWebVerticle.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/remote-resources/verify.groovy b/openshift-maven-plugin/it/src/it/remote-resources/verify.groovy index eb707f80f1..899f071688 100644 --- a/openshift-maven-plugin/it/src/it/remote-resources/verify.groovy +++ b/openshift-maven-plugin/it/src/it/remote-resources/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/revisionhistory/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java b/openshift-maven-plugin/it/src/it/revisionhistory/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java index ca965ece1c..ead1018db6 100644 --- a/openshift-maven-plugin/it/src/it/revisionhistory/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java +++ b/openshift-maven-plugin/it/src/it/revisionhistory/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/revisionhistory/src/main/java/io/fabric8/maven/sample/spring/boot/HelloController.java b/openshift-maven-plugin/it/src/it/revisionhistory/src/main/java/io/fabric8/maven/sample/spring/boot/HelloController.java index 4b37b8f49f..796a195deb 100644 --- a/openshift-maven-plugin/it/src/it/revisionhistory/src/main/java/io/fabric8/maven/sample/spring/boot/HelloController.java +++ b/openshift-maven-plugin/it/src/it/revisionhistory/src/main/java/io/fabric8/maven/sample/spring/boot/HelloController.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/revisionhistory/verify.groovy b/openshift-maven-plugin/it/src/it/revisionhistory/verify.groovy index dec19ec938..6c16290495 100644 --- a/openshift-maven-plugin/it/src/it/revisionhistory/verify.groovy +++ b/openshift-maven-plugin/it/src/it/revisionhistory/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/secret-config/src/main/java/hello/Application.java b/openshift-maven-plugin/it/src/it/secret-config/src/main/java/hello/Application.java index 1d1b0b1bd1..4df192c3a9 100644 --- a/openshift-maven-plugin/it/src/it/secret-config/src/main/java/hello/Application.java +++ b/openshift-maven-plugin/it/src/it/secret-config/src/main/java/hello/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/secret-config/verify.groovy b/openshift-maven-plugin/it/src/it/secret-config/verify.groovy index 89c39b4ff5..9c8a8f47ff 100644 --- a/openshift-maven-plugin/it/src/it/secret-config/verify.groovy +++ b/openshift-maven-plugin/it/src/it/secret-config/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/sidecar/src/main/java/zero/Application.java b/openshift-maven-plugin/it/src/it/sidecar/src/main/java/zero/Application.java index 15176271d2..cb7f3f6414 100644 --- a/openshift-maven-plugin/it/src/it/sidecar/src/main/java/zero/Application.java +++ b/openshift-maven-plugin/it/src/it/sidecar/src/main/java/zero/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/sidecar/src/main/java/zero/HelloController.java b/openshift-maven-plugin/it/src/it/sidecar/src/main/java/zero/HelloController.java index f2e3183c5d..df1753a4e4 100644 --- a/openshift-maven-plugin/it/src/it/sidecar/src/main/java/zero/HelloController.java +++ b/openshift-maven-plugin/it/src/it/sidecar/src/main/java/zero/HelloController.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/sidecar/verify.groovy b/openshift-maven-plugin/it/src/it/sidecar/verify.groovy index c883195193..b9f7b0e8a8 100644 --- a/openshift-maven-plugin/it/src/it/sidecar/verify.groovy +++ b/openshift-maven-plugin/it/src/it/sidecar/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/simple-maven-issue-mgmt/src/main/java/zero/Application.java b/openshift-maven-plugin/it/src/it/simple-maven-issue-mgmt/src/main/java/zero/Application.java index 15176271d2..cb7f3f6414 100644 --- a/openshift-maven-plugin/it/src/it/simple-maven-issue-mgmt/src/main/java/zero/Application.java +++ b/openshift-maven-plugin/it/src/it/simple-maven-issue-mgmt/src/main/java/zero/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/simple-maven-issue-mgmt/src/main/java/zero/HelloController.java b/openshift-maven-plugin/it/src/it/simple-maven-issue-mgmt/src/main/java/zero/HelloController.java index f2e3183c5d..df1753a4e4 100644 --- a/openshift-maven-plugin/it/src/it/simple-maven-issue-mgmt/src/main/java/zero/HelloController.java +++ b/openshift-maven-plugin/it/src/it/simple-maven-issue-mgmt/src/main/java/zero/HelloController.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/simple-maven-issue-mgmt/verify.groovy b/openshift-maven-plugin/it/src/it/simple-maven-issue-mgmt/verify.groovy index 4f0ca4ded8..80e12fb8bb 100644 --- a/openshift-maven-plugin/it/src/it/simple-maven-issue-mgmt/verify.groovy +++ b/openshift-maven-plugin/it/src/it/simple-maven-issue-mgmt/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/simple-maven-scm/src/main/java/zero/Application.java b/openshift-maven-plugin/it/src/it/simple-maven-scm/src/main/java/zero/Application.java index 15176271d2..cb7f3f6414 100644 --- a/openshift-maven-plugin/it/src/it/simple-maven-scm/src/main/java/zero/Application.java +++ b/openshift-maven-plugin/it/src/it/simple-maven-scm/src/main/java/zero/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/simple-maven-scm/src/main/java/zero/HelloController.java b/openshift-maven-plugin/it/src/it/simple-maven-scm/src/main/java/zero/HelloController.java index f2e3183c5d..df1753a4e4 100644 --- a/openshift-maven-plugin/it/src/it/simple-maven-scm/src/main/java/zero/HelloController.java +++ b/openshift-maven-plugin/it/src/it/simple-maven-scm/src/main/java/zero/HelloController.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/simple-maven-scm/verify.groovy b/openshift-maven-plugin/it/src/it/simple-maven-scm/verify.groovy index 4f0ca4ded8..80e12fb8bb 100644 --- a/openshift-maven-plugin/it/src/it/simple-maven-scm/verify.groovy +++ b/openshift-maven-plugin/it/src/it/simple-maven-scm/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/simple-with-route-flag-false/src/main/java/zero/Application.java b/openshift-maven-plugin/it/src/it/simple-with-route-flag-false/src/main/java/zero/Application.java index 15176271d2..cb7f3f6414 100644 --- a/openshift-maven-plugin/it/src/it/simple-with-route-flag-false/src/main/java/zero/Application.java +++ b/openshift-maven-plugin/it/src/it/simple-with-route-flag-false/src/main/java/zero/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/simple-with-route-flag-false/src/main/java/zero/HelloController.java b/openshift-maven-plugin/it/src/it/simple-with-route-flag-false/src/main/java/zero/HelloController.java index f2e3183c5d..df1753a4e4 100644 --- a/openshift-maven-plugin/it/src/it/simple-with-route-flag-false/src/main/java/zero/HelloController.java +++ b/openshift-maven-plugin/it/src/it/simple-with-route-flag-false/src/main/java/zero/HelloController.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/simple-with-route-flag-false/verify.groovy b/openshift-maven-plugin/it/src/it/simple-with-route-flag-false/verify.groovy index 21b4370b54..2a690bba48 100644 --- a/openshift-maven-plugin/it/src/it/simple-with-route-flag-false/verify.groovy +++ b/openshift-maven-plugin/it/src/it/simple-with-route-flag-false/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/simple-with-route-flag-true/src/main/java/zero/Application.java b/openshift-maven-plugin/it/src/it/simple-with-route-flag-true/src/main/java/zero/Application.java index 15176271d2..cb7f3f6414 100644 --- a/openshift-maven-plugin/it/src/it/simple-with-route-flag-true/src/main/java/zero/Application.java +++ b/openshift-maven-plugin/it/src/it/simple-with-route-flag-true/src/main/java/zero/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/simple-with-route-flag-true/src/main/java/zero/HelloController.java b/openshift-maven-plugin/it/src/it/simple-with-route-flag-true/src/main/java/zero/HelloController.java index f2e3183c5d..df1753a4e4 100644 --- a/openshift-maven-plugin/it/src/it/simple-with-route-flag-true/src/main/java/zero/HelloController.java +++ b/openshift-maven-plugin/it/src/it/simple-with-route-flag-true/src/main/java/zero/HelloController.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/simple-with-route-flag-true/verify.groovy b/openshift-maven-plugin/it/src/it/simple-with-route-flag-true/verify.groovy index 74b296d8a6..9fc29f819f 100644 --- a/openshift-maven-plugin/it/src/it/simple-with-route-flag-true/verify.groovy +++ b/openshift-maven-plugin/it/src/it/simple-with-route-flag-true/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/simple/src/main/java/zero/Application.java b/openshift-maven-plugin/it/src/it/simple/src/main/java/zero/Application.java index 15176271d2..cb7f3f6414 100644 --- a/openshift-maven-plugin/it/src/it/simple/src/main/java/zero/Application.java +++ b/openshift-maven-plugin/it/src/it/simple/src/main/java/zero/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/simple/src/main/java/zero/HelloController.java b/openshift-maven-plugin/it/src/it/simple/src/main/java/zero/HelloController.java index f2e3183c5d..df1753a4e4 100644 --- a/openshift-maven-plugin/it/src/it/simple/src/main/java/zero/HelloController.java +++ b/openshift-maven-plugin/it/src/it/simple/src/main/java/zero/HelloController.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/simple/verify.groovy b/openshift-maven-plugin/it/src/it/simple/verify.groovy index 4f0ca4ded8..80e12fb8bb 100644 --- a/openshift-maven-plugin/it/src/it/simple/verify.groovy +++ b/openshift-maven-plugin/it/src/it/simple/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/spring-boot/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java b/openshift-maven-plugin/it/src/it/spring-boot/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java index ca965ece1c..ead1018db6 100644 --- a/openshift-maven-plugin/it/src/it/spring-boot/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java +++ b/openshift-maven-plugin/it/src/it/spring-boot/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/spring-boot/src/main/java/io/fabric8/maven/sample/spring/boot/HelloController.java b/openshift-maven-plugin/it/src/it/spring-boot/src/main/java/io/fabric8/maven/sample/spring/boot/HelloController.java index 4b37b8f49f..796a195deb 100644 --- a/openshift-maven-plugin/it/src/it/spring-boot/src/main/java/io/fabric8/maven/sample/spring/boot/HelloController.java +++ b/openshift-maven-plugin/it/src/it/spring-boot/src/main/java/io/fabric8/maven/sample/spring/boot/HelloController.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/spring-boot/verify.groovy b/openshift-maven-plugin/it/src/it/spring-boot/verify.groovy index 1376d04850..90723e5a2b 100644 --- a/openshift-maven-plugin/it/src/it/spring-boot/verify.groovy +++ b/openshift-maven-plugin/it/src/it/spring-boot/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/statefulset/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java b/openshift-maven-plugin/it/src/it/statefulset/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java index 70b07e455d..a7ce18b3e5 100644 --- a/openshift-maven-plugin/it/src/it/statefulset/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java +++ b/openshift-maven-plugin/it/src/it/statefulset/src/main/java/io/fabric8/maven/sample/spring/boot/Application.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/statefulset/verify.groovy b/openshift-maven-plugin/it/src/it/statefulset/verify.groovy index 4f0ca4ded8..80e12fb8bb 100644 --- a/openshift-maven-plugin/it/src/it/statefulset/verify.groovy +++ b/openshift-maven-plugin/it/src/it/statefulset/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/vertx-default/src/main/java/io/fabric8/maven/sample/vertx/HttpApplication.java b/openshift-maven-plugin/it/src/it/vertx-default/src/main/java/io/fabric8/maven/sample/vertx/HttpApplication.java index 37712d6e79..e10f7b7adc 100644 --- a/openshift-maven-plugin/it/src/it/vertx-default/src/main/java/io/fabric8/maven/sample/vertx/HttpApplication.java +++ b/openshift-maven-plugin/it/src/it/vertx-default/src/main/java/io/fabric8/maven/sample/vertx/HttpApplication.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/vertx-default/verify.groovy b/openshift-maven-plugin/it/src/it/vertx-default/verify.groovy index c883195193..b9f7b0e8a8 100644 --- a/openshift-maven-plugin/it/src/it/vertx-default/verify.groovy +++ b/openshift-maven-plugin/it/src/it/vertx-default/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/vertx-health-check/src/main/java/io/fabric8/maven/sample/vertx/HttpApplication.java b/openshift-maven-plugin/it/src/it/vertx-health-check/src/main/java/io/fabric8/maven/sample/vertx/HttpApplication.java index 37712d6e79..e10f7b7adc 100644 --- a/openshift-maven-plugin/it/src/it/vertx-health-check/src/main/java/io/fabric8/maven/sample/vertx/HttpApplication.java +++ b/openshift-maven-plugin/it/src/it/vertx-health-check/src/main/java/io/fabric8/maven/sample/vertx/HttpApplication.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/vertx-health-check/verify.groovy b/openshift-maven-plugin/it/src/it/vertx-health-check/verify.groovy index dec19ec938..6c16290495 100644 --- a/openshift-maven-plugin/it/src/it/vertx-health-check/verify.groovy +++ b/openshift-maven-plugin/it/src/it/vertx-health-check/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/vertx/src/main/java/io/vertx/example/SimpleWebVerticle.java b/openshift-maven-plugin/it/src/it/vertx/src/main/java/io/vertx/example/SimpleWebVerticle.java index 88351a7b90..1dea5fccdf 100644 --- a/openshift-maven-plugin/it/src/it/vertx/src/main/java/io/vertx/example/SimpleWebVerticle.java +++ b/openshift-maven-plugin/it/src/it/vertx/src/main/java/io/vertx/example/SimpleWebVerticle.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/vertx/verify.groovy b/openshift-maven-plugin/it/src/it/vertx/verify.groovy index c883195193..b9f7b0e8a8 100644 --- a/openshift-maven-plugin/it/src/it/vertx/verify.groovy +++ b/openshift-maven-plugin/it/src/it/vertx/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/volume-enricher-custom-storage-class/verify.groovy b/openshift-maven-plugin/it/src/it/volume-enricher-custom-storage-class/verify.groovy index 64eb3cbd2e..a68df2b070 100644 --- a/openshift-maven-plugin/it/src/it/volume-enricher-custom-storage-class/verify.groovy +++ b/openshift-maven-plugin/it/src/it/volume-enricher-custom-storage-class/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/it/src/it/volume-enricher-default-storage-class/verify.groovy b/openshift-maven-plugin/it/src/it/volume-enricher-default-storage-class/verify.groovy index 4f0ca4ded8..80e12fb8bb 100644 --- a/openshift-maven-plugin/it/src/it/volume-enricher-default-storage-class/verify.groovy +++ b/openshift-maven-plugin/it/src/it/volume-enricher-default-storage-class/verify.groovy @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/OpenShift.java b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/OpenShift.java index 2c4bf89ec5..c0353330d5 100644 --- a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/OpenShift.java +++ b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/OpenShift.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftApplyMojo.java b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftApplyMojo.java index 9dba3818c1..a5e1371ee7 100644 --- a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftApplyMojo.java +++ b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftApplyMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftBuildMojo.java b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftBuildMojo.java index 43884068d1..0c9357139a 100644 --- a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftBuildMojo.java +++ b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftBuildMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftHelmMojo.java b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftHelmMojo.java index f0bd0bff74..1c9c3a1fee 100644 --- a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftHelmMojo.java +++ b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftHelmMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftHelmPushMojo.java b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftHelmPushMojo.java index 98476e7f0b..b52ddbb355 100644 --- a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftHelmPushMojo.java +++ b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftHelmPushMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftPushMojo.java b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftPushMojo.java index 8b3a65f799..3495915d01 100644 --- a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftPushMojo.java +++ b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftPushMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftResourceMojo.java b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftResourceMojo.java index a5546df6b2..6cae499d99 100644 --- a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftResourceMojo.java +++ b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenshiftResourceMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenShiftRemoteDevMojo.java b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenShiftRemoteDevMojo.java index 30d40eda11..fc92d60dd6 100644 --- a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenShiftRemoteDevMojo.java +++ b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenShiftRemoteDevMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftDebugMojo.java b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftDebugMojo.java index 4e83f6a9e4..4826f2469f 100644 --- a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftDebugMojo.java +++ b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftDebugMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftDeployMojo.java b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftDeployMojo.java index 31aab53e0a..4d0e0b40c4 100644 --- a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftDeployMojo.java +++ b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftDeployMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftLogMojo.java b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftLogMojo.java index 619eefa1c3..7e78bb1b16 100644 --- a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftLogMojo.java +++ b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftLogMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftUndeployMojo.java b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftUndeployMojo.java index 6df7e78490..2e14c1fd08 100644 --- a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftUndeployMojo.java +++ b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftUndeployMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftWatchMojo.java b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftWatchMojo.java index b94b18aaeb..f50e87c80c 100644 --- a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftWatchMojo.java +++ b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftWatchMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/util/OpenShiftMigrateMojo.java b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/util/OpenShiftMigrateMojo.java index fcb51337c2..e3b1e0597d 100644 --- a/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/util/OpenShiftMigrateMojo.java +++ b/openshift-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/util/OpenShiftMigrateMojo.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/OpenShiftGeneratedPluginDescriptorTest.java b/openshift-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/OpenShiftGeneratedPluginDescriptorTest.java index 9a350d2b3d..3cd55f80fe 100644 --- a/openshift-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/OpenShiftGeneratedPluginDescriptorTest.java +++ b/openshift-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/OpenShiftGeneratedPluginDescriptorTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenShiftResourceMojoTest.java b/openshift-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenShiftResourceMojoTest.java index 392f4d2f47..2b425f539f 100644 --- a/openshift-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenShiftResourceMojoTest.java +++ b/openshift-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/build/OpenShiftResourceMojoTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenShiftRemoteDevMojoTest.java b/openshift-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenShiftRemoteDevMojoTest.java index bf4e579ac1..6d9b580453 100644 --- a/openshift-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenShiftRemoteDevMojoTest.java +++ b/openshift-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenShiftRemoteDevMojoTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/openshift-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftUndeployMojoTest.java b/openshift-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftUndeployMojoTest.java index 1c079a66b1..ec9f175830 100644 --- a/openshift-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftUndeployMojoTest.java +++ b/openshift-maven-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/OpenshiftUndeployMojoTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 From ae60db8fb387786d67f349b92ae10f61739d8490 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Jul 2023 23:23:58 +0000 Subject: [PATCH 48/65] chore(deps): Bump com.networknt:json-schema-validator Bumps [com.networknt:json-schema-validator](https://github.com/networknt/json-schema-validator) from 1.0.76 to 1.0.86. - [Release notes](https://github.com/networknt/json-schema-validator/releases) - [Changelog](https://github.com/networknt/json-schema-validator/blob/master/CHANGELOG.md) - [Commits](https://github.com/networknt/json-schema-validator/compare/1.0.76...1.0.86) --- updated-dependencies: - dependency-name: com.networknt:json-schema-validator dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- jkube-kit/parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jkube-kit/parent/pom.xml b/jkube-kit/parent/pom.xml index 661f1f0795..0858444dfa 100644 --- a/jkube-kit/parent/pom.xml +++ b/jkube-kit/parent/pom.xml @@ -54,7 +54,7 @@ 3.3.1 3.9.0 0.2.2 - 1.0.76 + 1.0.86 ${version.kubernetes-client} 2.6.0 0.0.7 From 77bbc4477492c4c5b6ad25ad089174e62c80e9bd Mon Sep 17 00:00:00 2001 From: Prafful Rastogi <76156838+Prafful-Rastogi@users.noreply.github.com> Date: Mon, 24 Jul 2023 19:26:56 +0530 Subject: [PATCH 49/65] doc : Add documentation for using jkube snapshots (#2297) * doc : Add documentation for using jkube snapshots Signed-off-by: prafful-rastogi * doc : Add documentation for using jkube snapshots Signed-off-by: prafful-rastogi * doc : Add documentation for using jkube snapshots Signed-off-by: prafful-rastogi * doc : Add documentation for using jkube snapshots Signed-off-by: prafful-rastogi --------- Signed-off-by: prafful-rastogi --- README.md | 35 +++++++++++++-------- USING-SNAPSHOT-ARTIFACTS.md | 61 +++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 13 deletions(-) create mode 100644 USING-SNAPSHOT-ARTIFACTS.md diff --git a/README.md b/README.md index e3ef748de6..8fd087d765 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Eclipse JKube + > Cloud-Native Java Applications without a hassle [![Circle CI](https://circleci.com/gh/eclipse/jkube/tree/master.svg?style=shield)](https://circleci.com/gh/eclipse/jkube/tree/master) @@ -8,7 +9,6 @@ [![Gitter](https://badges.gitter.im/eclipse/jkube.svg)](https://gitter.im/eclipse/jkube?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Twitter](https://img.shields.io/twitter/follow/jkubeio?style=social)](https://twitter.com/jkubeio) -

    Eclipse JKube @@ -16,6 +16,7 @@

    ## Contents + - [Introduction](#introduction) - [Kubernetes Maven Plugin](#kubernetes-maven-plugin) - [Kubernetes Gradle Plugin](#kubernetes-gradle-plugin) @@ -29,10 +30,10 @@ - [Troubleshooting](#troubleshooting) - [Rebranding Notice](#rebranding-notice--loudspeaker-) - [Contributing](https://www.eclipse.org/jkube/contributing/) +- [How to use Eclipse JKube snapshot artifacts?](./USING-SNAPSHOT-ARTIFACTS.md) - [Add your organization to ADOPTERS](./ADOPTERS.md) - [FAQs](https://www.eclipse.org/jkube/docs/kubernetes-maven-plugin/#faq) - ## Introduction Eclipse JKube is a collection of plugins and libraries that are used for building container images using Docker, JIB or @@ -44,8 +45,8 @@ application cloud-native. Eclipse JKube also provides a set of tools such as watch, debug, log, etc. to improve your developer experience. This project contains various building blocks for the Kubernetes Java developer toolbox. - ### Kubernetes Maven Plugin + - [![Maven Central](https://img.shields.io/maven-central/v/org.eclipse.jkube/kubernetes-maven-plugin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.eclipse.jkube%22%20AND%20a:%22kubernetes-maven-plugin%22) - [![Documentation](https://img.shields.io/badge/plugin-documentation-lightgrey)](https://www.eclipse.org/jkube/docs/kubernetes-maven-plugin) - Add to project: @@ -64,8 +65,8 @@ This project contains various building blocks for the Kubernetes Java developer [![KubernetesMavenPluginDemo](https://img.youtube.com/vi/FHz5q8ERtPk/0.jpg)](https://youtu.be/FHz5q8ERtPk) - ### Kubernetes Gradle Plugin + - [![Maven Central](https://img.shields.io/maven-central/v/org.eclipse.jkube.kubernetes/org.eclipse.jkube.kubernetes.gradle.plugin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.eclipse.jkube.kubernetes%22%20AND%20a:%22org.eclipse.jkube.kubernetes.gradle.plugin%22) - [![Documentation](https://img.shields.io/badge/plugin-documentation-lightgrey)](https://www.eclipse.org/jkube/docs/kubernetes-gradle-plugin/) - Add to project: @@ -83,6 +84,7 @@ This project contains various building blocks for the Kubernetes Java developer [![KubernetesGradlePluginDemo](https://img.youtube.com/vi/TUYl2Vw8bnQ/0.jpg)](https://youtu.be/TUYl2Vw8bnQ) ### OpenShift Gradle Plugin + - [![Maven Central](https://img.shields.io/maven-central/v/org.eclipse.jkube.openshift/org.eclipse.jkube.openshift.gradle.plugin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.eclipse.jkube.openshift%22%20AND%20a:%22org.eclipse.jkube.openshift.gradle.plugin%22) - [![Documentation](https://img.shields.io/badge/plugin-documentation-lightgrey)](https://www.eclipse.org/jkube/docs/openshift-gradle-plugin/) - Add to project: @@ -100,6 +102,7 @@ This project contains various building blocks for the Kubernetes Java developer [![OpenShiftGradlePluginDemo](https://img.youtube.com/vi/uMxEzLdqcik/0.jpg)](https://youtu.be/uMxEzLdqcik) ### OpenShift Maven Plugin + - [![Maven Central](https://img.shields.io/maven-central/v/org.eclipse.jkube/openshift-maven-plugin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.eclipse.jkube%22%20AND%20a:%22openshift-maven-plugin%22) - [![Documentation](https://img.shields.io/badge/plugin-documentation-lightgrey)](https://www.eclipse.org/jkube/docs/openshift-maven-plugin) - Add to project: @@ -118,17 +121,18 @@ This project contains various building blocks for the Kubernetes Java developer [![OpenShiftMavenPluginDemo](https://img.youtube.com/vi/ZJzfD-bDxpc/0.jpg)](https://youtu.be/ZJzfD-bDxpc) - ## Getting started + You can take a look at our quickstarts in [quickstarts](./quickstarts) directory that contain sample maven and gradle projects using the latest version of jkube plugin. ### Hello World using Eclipse JKube - Clone repository and move to quickstart [helloworld](https://github.com/eclipse/jkube/tree/master/quickstarts/maven/hello-world) sample, build project and run JKube goals: + ```shell script -# 1. Clone repository -$ git clone git@github.com:eclipse/jkube.git - +# 1. Clone repository +$ git clone git@github.com:eclipse/jkube.git + # 2. Move to Hello World Quickstart folder $ cd jkube/quickstarts/maven/hello-world @@ -138,7 +142,9 @@ $ mvn clean install \ k8s:resource `# Generate Kubernetes Manifests` \ k8s:apply `# Apply generated Kubernetes Manifests onto Kubernetes` ``` + - Check created pod logs: + ```shell script # Using Kubectl $ kubectl get pods @@ -148,24 +154,28 @@ $ kubectl logs jkube-sample-helloworld-7c4665f464-xwskj Hello World! # Using JKube $ mvn k8s:log -[INFO] k8s: [NEW] helloworld-7c4665f464-xwskj status: Running +[INFO] k8s: [NEW] helloworld-7c4665f464-xwskj status: Running [INFO] k8s: [NEW] Tailing log of pod: helloworld-587dfff745-2kdpq [INFO] k8s: [NEW] Press Ctrl-C to stop tailing the log -[INFO] k8s: [NEW] +[INFO] k8s: [NEW] [INFO] k8s: Hello World! -[INFO] k8s: [NEW] helloworld-7c4665f464-xwskj status: Running +[INFO] k8s: [NEW] helloworld-7c4665f464-xwskj status: Running ``` #### Troubleshooting If you experience problems using minikube that pod's status shows 'ImagePullBackOff' and not 'Completed' you must share the minikube's docker daemon environment with your shell with: + ```shell script $ eval $(minikube docker-env) ``` + You can remove this from your shell again with: + ```shell script $ eval $(minikube docker-env -u) -```` +``` + If you don't want to type the command for every new terminal you open, you can add the command to your `.bash_profile` on mac or `.zshrc`. @@ -175,4 +185,3 @@ This project is not an effort from scratch. It was earlier called [Fabric8 Maven Plugin](https://github.com/fabric8io/fabric8-maven-plugin). It is just refactored and rebranded version of the project targeted towards Java developers who are working on top of Kubernetes. For more information about history, please see [REBRANDING.md](./REBRANDING.md) - diff --git a/USING-SNAPSHOT-ARTIFACTS.md b/USING-SNAPSHOT-ARTIFACTS.md new file mode 100644 index 0000000000..1c2bb95014 --- /dev/null +++ b/USING-SNAPSHOT-ARTIFACTS.md @@ -0,0 +1,61 @@ +# How to use Eclipse JKube snapshot artifacts? + +Artifacts are hosted at [JKube's Sonatype Snapshot repository](https://oss.sonatype.org/content/repositories/snapshots/org/eclipse/jkube/) + +Our [Jenkins Snapshot release pipeline](https://ci.eclipse.org/jkube/job/ReleasePipelines/job/ReleaseSnapshots/) updates SNAPSHOT artifacts every night. + +## Using SNAPSHOTs in Maven Project + +In order to use these artifacts, update your `pom.xml` with these: + +```xml + + + oss.sonatype.org + https://oss.sonatype.org/content/repositories/snapshots + + true + always + + + +``` + +You'd also need to update version of the plugin you're using to use a SNAPSHOT version instead of a stable version. Here is an example: + +```xml + + x.yz-SNAPSHOT + + + + + + org.eclipse.jkube + kubernetes-maven-plugin + ${jkube.version} + + + +``` + +## Using SNAPSHOTS in Gradle project + +In order to use these artifacts in Gradle project, update your `settings.gradle` pluginManagement section like this: + +```groovy +pluginManagement { + repositories { + maven { url "https://oss.sonatype.org/content/repositories/snapshots" } + } +} +``` + +You'd also need to update version of the plugin you're using to use a SNAPSHOT version instead of a stable version. Here is an example: + +```groovy +plugins { + id "org.eclipse.jkube.openshift" version "x.yz-SNAPSHOT" + id "org.eclipse.jkube.kubernetes" version "x.yz-SNAPSHOT" +} +``` From 42fb9763f69d4164a9e38bffac55bd7cba080252 Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Wed, 19 Jul 2023 13:30:16 +0530 Subject: [PATCH 50/65] refactor (jkube-kit-spring-boot) : Refactor SpringBootGenerator to use nested generator approach Refactor SpringBootGenerator to use nested generator approach used in Quarkus and Helidon generators. For now, only LegacyJarGenerator is added. Signed-off-by: Rohan Kumar --- .../AbstractSpringBootNestedGenerator.java | 45 +++++++++++++++ .../springboot/generator/FatJarGenerator.java | 23 ++++++++ .../generator/SpringBootGenerator.java | 37 +++++++++++++ .../generator/SpringBootNestedGenerator.java | 55 +++++++++++++++++++ 4 files changed, 160 insertions(+) create mode 100644 jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/AbstractSpringBootNestedGenerator.java create mode 100644 jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/FatJarGenerator.java create mode 100644 jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/SpringBootNestedGenerator.java diff --git a/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/AbstractSpringBootNestedGenerator.java b/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/AbstractSpringBootNestedGenerator.java new file mode 100644 index 0000000000..6cd1134d68 --- /dev/null +++ b/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/AbstractSpringBootNestedGenerator.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.springboot.generator; + +import org.eclipse.jkube.generator.api.GeneratorConfig; +import org.eclipse.jkube.generator.api.GeneratorContext; +import org.eclipse.jkube.generator.javaexec.JavaExecGenerator; +import org.eclipse.jkube.kit.common.JavaProject; + +public abstract class AbstractSpringBootNestedGenerator implements SpringBootNestedGenerator { + + private final GeneratorContext generatorContext; + private final GeneratorConfig generatorConfig; + + AbstractSpringBootNestedGenerator(GeneratorContext generatorContext, GeneratorConfig generatorConfig) { + this.generatorContext = generatorContext; + this.generatorConfig = generatorConfig; + } + + @Override + public final JavaProject getProject() { + return generatorContext.getProject(); + } + + @Override + public String getBuildWorkdir() { + return generatorConfig.get(JavaExecGenerator.Config.TARGET_DIR); + } + + @Override + public String getTargetDir() { + return generatorConfig.get(JavaExecGenerator.Config.TARGET_DIR); + } +} diff --git a/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/FatJarGenerator.java b/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/FatJarGenerator.java new file mode 100644 index 0000000000..392a80c194 --- /dev/null +++ b/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/FatJarGenerator.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.springboot.generator; + +import org.eclipse.jkube.generator.api.GeneratorConfig; +import org.eclipse.jkube.generator.api.GeneratorContext; + +public class FatJarGenerator extends AbstractSpringBootNestedGenerator { + public FatJarGenerator(GeneratorContext generatorContext, GeneratorConfig generatorConfig) { + super(generatorContext, generatorConfig); + } +} diff --git a/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/SpringBootGenerator.java b/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/SpringBootGenerator.java index 764ff8e099..c64e12dda0 100644 --- a/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/SpringBootGenerator.java +++ b/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/SpringBootGenerator.java @@ -15,11 +15,14 @@ import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Properties; import org.eclipse.jkube.generator.api.GeneratorContext; import org.eclipse.jkube.generator.api.GeneratorMode; import org.eclipse.jkube.generator.javaexec.JavaExecGenerator; +import org.eclipse.jkube.kit.common.Arguments; +import org.eclipse.jkube.kit.common.AssemblyConfiguration; import org.eclipse.jkube.kit.common.Configs; import org.eclipse.jkube.kit.common.util.JKubeProjectUtil; import org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper; @@ -51,8 +54,11 @@ public enum Config implements Configs.Config { protected String defaultValue; } + private final SpringBootNestedGenerator nestedGenerator; + public SpringBootGenerator(GeneratorContext context) { super(context, "spring-boot"); + nestedGenerator = SpringBootNestedGenerator.from(context, getGeneratorConfig()); } @Override @@ -120,4 +126,35 @@ protected String getDefaultWebPort() { SpringBootConfigurationHelper propertyHelper = new SpringBootConfigurationHelper(SpringBootUtil.getSpringBootVersion(getProject())); return properties.getProperty(propertyHelper.getServerPortPropertyKey(), super.getDefaultWebPort()); } + + @Override + protected AssemblyConfiguration createAssembly() { + return Optional.ofNullable(nestedGenerator.createAssemblyConfiguration()) + .orElse(super.createAssembly()); + } + + @Override + protected String getBuildWorkdir() { + return nestedGenerator.getBuildWorkdir(); + } + + @Override + protected String getFromAsConfigured() { + return Optional.ofNullable(super.getFromAsConfigured()).orElse(nestedGenerator.getFrom()); + } + + @Override + protected Arguments getBuildEntryPoint() { + return nestedGenerator.getBuildEntryPoint(); + } + + @Override + protected String getDefaultJolokiaPort() { + return nestedGenerator.getDefaultJolokiaPort(); + } + + @Override + protected String getDefaultPrometheusPort() { + return nestedGenerator.getDefaultPrometheusPort(); + } } diff --git a/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/SpringBootNestedGenerator.java b/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/SpringBootNestedGenerator.java new file mode 100644 index 0000000000..68b5c5f3e1 --- /dev/null +++ b/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/SpringBootNestedGenerator.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.springboot.generator; + +import org.eclipse.jkube.generator.api.GeneratorConfig; +import org.eclipse.jkube.generator.api.GeneratorContext; +import org.eclipse.jkube.kit.common.Arguments; +import org.eclipse.jkube.kit.common.AssemblyConfiguration; +import org.eclipse.jkube.kit.common.JavaProject; + +import static org.eclipse.jkube.generator.javaexec.JavaExecGenerator.JOLOKIA_PORT_DEFAULT; +import static org.eclipse.jkube.generator.javaexec.JavaExecGenerator.PROMETHEUS_PORT_DEFAULT; + +public interface SpringBootNestedGenerator { + JavaProject getProject(); + + default AssemblyConfiguration createAssemblyConfiguration() { + return null; + } + + default String getFrom() { + return null; + } + + default String getDefaultJolokiaPort() { + return JOLOKIA_PORT_DEFAULT; + } + + default String getDefaultPrometheusPort() { + return PROMETHEUS_PORT_DEFAULT; + } + + default Arguments getBuildEntryPoint() { + return null; + } + + String getBuildWorkdir(); + + String getTargetDir(); + + static SpringBootNestedGenerator from(GeneratorContext generatorContext, GeneratorConfig generatorConfig) { + return new FatJarGenerator(generatorContext, generatorConfig); + } +} From 58171ada0c937b3967aa7566e4539fcb525f2bf0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jul 2023 23:13:05 +0000 Subject: [PATCH 51/65] chore(deps): Bump actions/setup-java from 3.11.0 to 3.12.0 Bumps [actions/setup-java](https://github.com/actions/setup-java) from 3.11.0 to 3.12.0. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2...cd89f46ac9d01407894225f350157564c9c7cee2) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/license.yml | 2 +- .github/workflows/quickstarts.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/license.yml b/.github/workflows/license.yml index 99d73b355e..6467f9b11a 100644 --- a/.github/workflows/license.yml +++ b/.github/workflows/license.yml @@ -42,7 +42,7 @@ jobs: - name: Checkout uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - name: Setup Java 11 - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 + uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 with: java-version: '11' distribution: 'adopt' diff --git a/.github/workflows/quickstarts.yml b/.github/workflows/quickstarts.yml index fdc1def923..23615725e7 100644 --- a/.github/workflows/quickstarts.yml +++ b/.github/workflows/quickstarts.yml @@ -53,7 +53,7 @@ jobs: - name: Checkout uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - name: Setup Java 11 - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 + uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 with: java-version: '11' distribution: 'adopt' From 271a390a48c13ec66bf3cf225a64758cfddcdb19 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jul 2023 23:13:08 +0000 Subject: [PATCH 52/65] chore(deps): Bump step-security/harden-runner from 2.4.1 to 2.5.0 Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.4.1 to 2.5.0. - [Release notes](https://github.com/step-security/harden-runner/releases) - [Commits](https://github.com/step-security/harden-runner/compare/55d479fb1c5bcad5a4f9099a5d9f37c8857b2845...cba0d00b1fc9a034e1e642ea0f1103c282990604) --- updated-dependencies: - dependency-name: step-security/harden-runner dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/license.yml | 2 +- .github/workflows/quickstarts.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/license.yml b/.github/workflows/license.yml index 6467f9b11a..b363042676 100644 --- a/.github/workflows/license.yml +++ b/.github/workflows/license.yml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Harden Runner - uses: step-security/harden-runner@55d479fb1c5bcad5a4f9099a5d9f37c8857b2845 + uses: step-security/harden-runner@cba0d00b1fc9a034e1e642ea0f1103c282990604 with: disable-sudo: true egress-policy: block diff --git a/.github/workflows/quickstarts.yml b/.github/workflows/quickstarts.yml index 23615725e7..0211344b39 100644 --- a/.github/workflows/quickstarts.yml +++ b/.github/workflows/quickstarts.yml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Harden Runner - uses: step-security/harden-runner@55d479fb1c5bcad5a4f9099a5d9f37c8857b2845 + uses: step-security/harden-runner@cba0d00b1fc9a034e1e642ea0f1103c282990604 with: disable-sudo: true egress-policy: block From 1ffc921c99a345320ce2a59e2e8bf5bcb5469277 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Mon, 24 Jul 2023 16:05:06 +0200 Subject: [PATCH 53/65] deps: bump Kubernetes Client to 6.8.0 Signed-off-by: Marc Nuri --- CHANGELOG.md | 1 + .../enricher/api/visitor/MetadataVisitor.java | 63 +++++++------------ .../kit/enricher/handler/ServiceHandler.java | 2 +- .../enricher/generic/ConfigMapEnricher.java | 2 +- ...trollerViaPluginConfigurationEnricher.java | 4 +- .../generic/DefaultServiceEnricher.java | 6 +- .../jkube/enricher/generic/ImageEnricher.java | 26 ++++---- .../enricher/generic/SecretEnricher.java | 2 +- .../generic/ServiceAccountEnricher.java | 12 ++-- .../generic/ConfigMapEnricherTest.java | 12 ++-- .../DockerRegistrySecretEnricherTest.java | 8 +-- .../generic/FileDataSecretEnricherTest.java | 4 +- .../generic/PortNameEnricherTest.java | 2 +- .../generic/VolumePermissionEnricherTest.java | 6 +- .../enricher/VertxHealthCheckEnricher.java | 4 +- .../WildflyJARHealthCheckEnricherTest.java | 4 +- pom.xml | 2 +- 17 files changed, 73 insertions(+), 87 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74d8e6a857..bfe27853d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Usage: * Fix #2219: Kind/Filename mappings include optional apiVersion configuration * Fix #2224: Quarkus native base image read from properties (configurable) * Fix #2228: Quarkus native base image uses UBI 8.7 +* Fix #2302 Bump Kubernetes Client version to 6.8.0 ### 1.13.1 (2023-06-16) * Fix #2212: Bump Kubernetes Client version to 6.7.2 (fixes issues when trace-logging OpenShift builds -regression in 6.7.1-) diff --git a/jkube-kit/enricher/api/src/main/java/org/eclipse/jkube/kit/enricher/api/visitor/MetadataVisitor.java b/jkube-kit/enricher/api/src/main/java/org/eclipse/jkube/kit/enricher/api/visitor/MetadataVisitor.java index 7e1edf24f7..80b428f530 100644 --- a/jkube-kit/enricher/api/src/main/java/org/eclipse/jkube/kit/enricher/api/visitor/MetadataVisitor.java +++ b/jkube-kit/enricher/api/src/main/java/org/eclipse/jkube/kit/enricher/api/visitor/MetadataVisitor.java @@ -30,49 +30,34 @@ import io.fabric8.kubernetes.api.model.ObjectMetaFluent; import io.fabric8.kubernetes.api.model.PodTemplateSpecBuilder; import io.fabric8.kubernetes.api.model.PodTemplateSpecFluent; -import io.fabric8.kubernetes.api.model.PodTemplateSpecFluentImpl; import io.fabric8.kubernetes.api.model.ReplicationControllerBuilder; import io.fabric8.kubernetes.api.model.ReplicationControllerFluent; -import io.fabric8.kubernetes.api.model.ReplicationControllerFluentImpl; import io.fabric8.kubernetes.api.model.ServiceAccountBuilder; import io.fabric8.kubernetes.api.model.ServiceAccountFluent; -import io.fabric8.kubernetes.api.model.ServiceAccountFluentImpl; import io.fabric8.kubernetes.api.model.ServiceBuilder; import io.fabric8.kubernetes.api.model.ServiceFluent; -import io.fabric8.kubernetes.api.model.ServiceFluentImpl; import io.fabric8.kubernetes.api.model.apps.DaemonSetBuilder; import io.fabric8.kubernetes.api.model.apps.DaemonSetFluent; -import io.fabric8.kubernetes.api.model.apps.DaemonSetFluentImpl; import io.fabric8.kubernetes.api.model.apps.DeploymentBuilder; import io.fabric8.kubernetes.api.model.apps.DeploymentFluent; -import io.fabric8.kubernetes.api.model.apps.DeploymentFluentImpl; import io.fabric8.kubernetes.api.model.apps.ReplicaSetBuilder; import io.fabric8.kubernetes.api.model.apps.ReplicaSetFluent; -import io.fabric8.kubernetes.api.model.apps.ReplicaSetFluentImpl; import io.fabric8.kubernetes.api.model.apps.StatefulSetBuilder; import io.fabric8.kubernetes.api.model.apps.StatefulSetFluent; -import io.fabric8.kubernetes.api.model.apps.StatefulSetFluentImpl; import io.fabric8.kubernetes.api.model.batch.v1.JobBuilder; import io.fabric8.kubernetes.api.model.batch.v1.JobFluent; -import io.fabric8.kubernetes.api.model.batch.v1.JobFluentImpl; import io.fabric8.kubernetes.api.model.extensions.IngressBuilder; import io.fabric8.kubernetes.api.model.extensions.IngressFluent; -import io.fabric8.kubernetes.api.model.extensions.IngressFluentImpl; import io.fabric8.openshift.api.model.BuildBuilder; import io.fabric8.openshift.api.model.BuildConfigBuilder; import io.fabric8.openshift.api.model.BuildConfigFluent; -import io.fabric8.openshift.api.model.BuildConfigFluentImpl; import io.fabric8.openshift.api.model.BuildFluent; -import io.fabric8.openshift.api.model.BuildFluentImpl; import io.fabric8.openshift.api.model.DeploymentConfigBuilder; import io.fabric8.openshift.api.model.DeploymentConfigFluent; -import io.fabric8.openshift.api.model.DeploymentConfigFluentImpl; import io.fabric8.openshift.api.model.ImageStreamBuilder; import io.fabric8.openshift.api.model.ImageStreamFluent; -import io.fabric8.openshift.api.model.ImageStreamFluentImpl; import io.fabric8.openshift.api.model.RouteBuilder; import io.fabric8.openshift.api.model.RouteFluent; -import io.fabric8.openshift.api.model.RouteFluentImpl; import lombok.AllArgsConstructor; import static org.eclipse.jkube.kit.common.util.PropertiesUtil.toMap; @@ -146,7 +131,7 @@ public static MetadataVisitor deployment(ResourceConfig resou return new MetadataVisitor<>( DeploymentBuilder.class, getAnnotations(resourceConfig)::getDeployment, getLabels(resourceConfig)::getDeployment, - DeploymentFluentImpl::editOrNewMetadata, omf -> ((DeploymentFluent.MetadataNested) omf)::endMetadata); + DeploymentFluent::editOrNewMetadata, omf -> ((DeploymentFluent.MetadataNested) omf)::endMetadata); } public static MetadataVisitor extensionsDeployment( @@ -154,93 +139,93 @@ public static MetadataVisitor( io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder.class, getAnnotations(resourceConfig)::getDeployment, getLabels(resourceConfig)::getDeployment, - io.fabric8.kubernetes.api.model.extensions.DeploymentFluentImpl::editOrNewMetadata, - omf -> ((io.fabric8.kubernetes.api.model.extensions.DeploymentFluent.MetadataNested) omf)::endMetadata); + io.fabric8.kubernetes.api.model.extensions.DeploymentFluent::editOrNewMetadata, + omf -> ((io.fabric8.kubernetes.api.model.extensions.DeploymentFluent.MetadataNested) omf)::endMetadata); } public static MetadataVisitor deploymentConfig(ResourceConfig resourceConfig) { return new MetadataVisitor<>( DeploymentConfigBuilder.class, getAnnotations(resourceConfig)::getDeployment, getLabels(resourceConfig)::getDeployment, - DeploymentConfigFluentImpl::editOrNewMetadata, omf -> ((DeploymentConfigFluent.MetadataNested) omf)::endMetadata); + DeploymentConfigFluent::editOrNewMetadata, omf -> ((DeploymentConfigFluent.MetadataNested) omf)::endMetadata); } public static MetadataVisitor replicaSet(ResourceConfig resourceConfig) { return new MetadataVisitor<>( ReplicaSetBuilder.class, getAnnotations(resourceConfig)::getReplicaSet, getLabels(resourceConfig)::getReplicaSet, - ReplicaSetFluentImpl::editOrNewMetadata, omf -> ((ReplicaSetFluent.MetadataNested) omf)::endMetadata); + ReplicaSetFluent::editOrNewMetadata, omf -> ((ReplicaSetFluent.MetadataNested) omf)::endMetadata); } public static MetadataVisitor replicationController(ResourceConfig resourceConfig) { return new MetadataVisitor<>( ReplicationControllerBuilder.class, getAnnotations(resourceConfig)::getReplicaSet, getLabels(resourceConfig)::getReplicaSet, - ReplicationControllerFluentImpl::editOrNewMetadata, - omf -> ((ReplicationControllerFluent.MetadataNested) omf)::endMetadata); + ReplicationControllerFluent::editOrNewMetadata, + omf -> ((ReplicationControllerFluent.MetadataNested) omf)::endMetadata); } public static MetadataVisitor service(ResourceConfig resourceConfig) { return new MetadataVisitor<>( ServiceBuilder.class, getAnnotations(resourceConfig)::getService, getLabels(resourceConfig)::getService, - ServiceFluentImpl::editOrNewMetadata, omf -> ((ServiceFluent.MetadataNested) omf)::endMetadata); + ServiceFluent::editOrNewMetadata, omf -> ((ServiceFluent.MetadataNested) omf)::endMetadata); } public static MetadataVisitor podTemplateSpec(ResourceConfig resourceConfig) { return new MetadataVisitor<>( PodTemplateSpecBuilder.class, getAnnotations(resourceConfig)::getPod, getLabels(resourceConfig)::getPod, - PodTemplateSpecFluentImpl::editOrNewMetadata, omf -> ((PodTemplateSpecFluent.MetadataNested) omf)::endMetadata); + PodTemplateSpecFluent::editOrNewMetadata, omf -> ((PodTemplateSpecFluent.MetadataNested) omf)::endMetadata); } public static MetadataVisitor daemonSet(ResourceConfig resourceConfig) { return new MetadataVisitor<>( DaemonSetBuilder.class, getAnnotations(resourceConfig)::getAll, getLabels(resourceConfig)::getAll, - DaemonSetFluentImpl::editOrNewMetadata, omf -> ((DaemonSetFluent.MetadataNested) omf)::endMetadata); + DaemonSetFluent::editOrNewMetadata, omf -> ((DaemonSetFluent.MetadataNested) omf)::endMetadata); } public static MetadataVisitor statefulSet(ResourceConfig resourceConfig) { return new MetadataVisitor<>( StatefulSetBuilder.class, getAnnotations(resourceConfig)::getAll, getLabels(resourceConfig)::getAll, - StatefulSetFluentImpl::editOrNewMetadata, omf -> ((StatefulSetFluent.MetadataNested) omf)::endMetadata); + StatefulSetFluent::editOrNewMetadata, omf -> ((StatefulSetFluent.MetadataNested) omf)::endMetadata); } public static MetadataVisitor job(ResourceConfig resourceConfig) { return new MetadataVisitor<>( JobBuilder.class, getAnnotations(resourceConfig)::getAll, getLabels(resourceConfig)::getAll, - JobFluentImpl::editOrNewMetadata, omf -> ((JobFluent.MetadataNested) omf)::endMetadata); + JobFluent::editOrNewMetadata, omf -> ((JobFluent.MetadataNested) omf)::endMetadata); } public static MetadataVisitor imageStream(ResourceConfig resourceConfig) { return new MetadataVisitor<>( ImageStreamBuilder.class, getAnnotations(resourceConfig)::getAll, getLabels(resourceConfig)::getAll, - ImageStreamFluentImpl::editOrNewMetadata, omf -> ((ImageStreamFluent.MetadataNested) omf)::endMetadata); + ImageStreamFluent::editOrNewMetadata, omf -> ((ImageStreamFluent.MetadataNested) omf)::endMetadata); } public static MetadataVisitor buildConfig(ResourceConfig resourceConfig) { return new MetadataVisitor<>( BuildConfigBuilder.class, getAnnotations(resourceConfig)::getAll, getLabels(resourceConfig)::getAll, - BuildConfigFluentImpl::editOrNewMetadata, omf -> ((BuildConfigFluent.MetadataNested) omf)::endMetadata); + BuildConfigFluent::editOrNewMetadata, omf -> ((BuildConfigFluent.MetadataNested) omf)::endMetadata); } public static MetadataVisitor build(ResourceConfig resourceConfig) { return new MetadataVisitor<>( BuildBuilder.class, getAnnotations(resourceConfig)::getAll, getLabels(resourceConfig)::getAll, - BuildFluentImpl::editOrNewMetadata, omf -> ((BuildFluent.MetadataNested) omf)::endMetadata); + BuildFluent::editOrNewMetadata, omf -> ((BuildFluent.MetadataNested) omf)::endMetadata); } public static MetadataVisitor extensionsIngress(ResourceConfig resourceConfig) { return new MetadataVisitor<>( IngressBuilder.class, getAnnotations(resourceConfig)::getIngress, getLabels(resourceConfig)::getIngress, - IngressFluentImpl::editOrNewMetadata, omf -> ((IngressFluent.MetadataNested) omf)::endMetadata); + IngressFluent::editOrNewMetadata, omf -> ((IngressFluent.MetadataNested) omf)::endMetadata); } public static MetadataVisitor ingressV1beta1( @@ -248,8 +233,8 @@ public static MetadataVisitor( io.fabric8.kubernetes.api.model.networking.v1beta1.IngressBuilder.class, getAnnotations(resourceConfig)::getIngress, getLabels(resourceConfig)::getIngress, - io.fabric8.kubernetes.api.model.networking.v1beta1.IngressFluentImpl::editOrNewMetadata, - omf -> ((io.fabric8.kubernetes.api.model.networking.v1beta1.IngressFluent.MetadataNested) omf)::endMetadata); + io.fabric8.kubernetes.api.model.networking.v1beta1.IngressFluent::editOrNewMetadata, + omf -> ((io.fabric8.kubernetes.api.model.networking.v1beta1.IngressFluent.MetadataNested) omf)::endMetadata); } public static MetadataVisitor ingressV1( @@ -257,21 +242,21 @@ public static MetadataVisitor( io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder.class, getAnnotations(resourceConfig)::getIngress, getLabels(resourceConfig)::getIngress, - io.fabric8.kubernetes.api.model.networking.v1.IngressFluentImpl::editOrNewMetadata, - omf -> ((io.fabric8.kubernetes.api.model.networking.v1.IngressFluent.MetadataNested) omf)::endMetadata); + io.fabric8.kubernetes.api.model.networking.v1.IngressFluent::editOrNewMetadata, + omf -> ((io.fabric8.kubernetes.api.model.networking.v1.IngressFluent.MetadataNested) omf)::endMetadata); } public static MetadataVisitor serviceAccount(ResourceConfig resourceConfig) { return new MetadataVisitor<>( ServiceAccountBuilder.class, getAnnotations(resourceConfig)::getServiceAccount, getLabels(resourceConfig)::getServiceAccount, - ServiceAccountFluentImpl::editOrNewMetadata, omf -> ((ServiceAccountFluent.MetadataNested) omf)::endMetadata); + ServiceAccountFluent::editOrNewMetadata, omf -> ((ServiceAccountFluent.MetadataNested) omf)::endMetadata); } public static MetadataVisitor route(ResourceConfig resourceConfig) { - return new MetadataVisitor<>(RouteBuilder.class, + return new MetadataVisitor<>(RouteBuilder.class, getAnnotations(resourceConfig)::getRoute, getLabels(resourceConfig)::getRoute, - RouteFluentImpl::editOrNewMetadata, omf -> ((RouteFluent.MetadataNested) omf)::endMetadata); + RouteFluent::editOrNewMetadata, omf -> ((RouteFluent.MetadataNested) omf)::endMetadata); } -} \ No newline at end of file +} diff --git a/jkube-kit/enricher/api/src/main/java/org/eclipse/jkube/kit/enricher/handler/ServiceHandler.java b/jkube-kit/enricher/api/src/main/java/org/eclipse/jkube/kit/enricher/handler/ServiceHandler.java index 689691c0a8..cab4821c0d 100644 --- a/jkube-kit/enricher/api/src/main/java/org/eclipse/jkube/kit/enricher/handler/ServiceHandler.java +++ b/jkube-kit/enricher/api/src/main/java/org/eclipse/jkube/kit/enricher/handler/ServiceHandler.java @@ -47,7 +47,7 @@ public List getServices(List services) { .withLabels(getLabels(service)) .endMetadata(); - ServiceFluent.SpecNested serviceSpecBuilder = serviceBuilder.withNewSpec(); + ServiceFluent.SpecNested serviceSpecBuilder = serviceBuilder.withNewSpec(); List servicePorts = new ArrayList<>(); diff --git a/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/ConfigMapEnricher.java b/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/ConfigMapEnricher.java index 263ca34a74..ec0f4a6aec 100644 --- a/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/ConfigMapEnricher.java +++ b/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/ConfigMapEnricher.java @@ -111,7 +111,7 @@ private void addConfigMapFromResourceConfigurations(KubernetesListBuilder builde if ((configMap.getData() != null && !configMap.getData().isEmpty()) || (configMap.getBinaryData() != null && !configMap.getBinaryData().isEmpty())) { - builder.addToConfigMapItems(configMap); + builder.addToItems(configMap); } } catch (IOException e) { throw new IllegalArgumentException(e); diff --git a/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/ControllerViaPluginConfigurationEnricher.java b/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/ControllerViaPluginConfigurationEnricher.java index 8d71ee1e36..792fee2562 100644 --- a/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/ControllerViaPluginConfigurationEnricher.java +++ b/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/ControllerViaPluginConfigurationEnricher.java @@ -146,13 +146,13 @@ public void visit(PodSpecBuilder builder) { } private void mergeDeploymentSpec(DeploymentBuilder builder, DeploymentSpec spec) { - DeploymentFluent.SpecNested specBuilder = builder.editSpec(); + DeploymentFluent.SpecNested specBuilder = builder.editSpec(); KubernetesResourceUtil.mergeSimpleFields(specBuilder, spec); specBuilder.endSpec(); } private void mergeStatefulSetSpec(StatefulSetBuilder builder, StatefulSetSpec spec) { - StatefulSetFluent.SpecNested specBuilder = builder.editSpec(); + StatefulSetFluent.SpecNested specBuilder = builder.editSpec(); KubernetesResourceUtil.mergeSimpleFields(specBuilder, spec); specBuilder.endSpec(); } diff --git a/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/DefaultServiceEnricher.java b/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/DefaultServiceEnricher.java index a72e114a39..82504dc39f 100644 --- a/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/DefaultServiceEnricher.java +++ b/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/DefaultServiceEnricher.java @@ -162,7 +162,7 @@ public void visit(ServicePortBuilder portBuilder) { } private void addServices(KubernetesListBuilder builder, List services) { - builder.addToServiceItems(toArray(getContext().getHandlerHub().getServiceHandler().getServices(services))); + builder.addToItems(toArray(getContext().getHandlerHub().getServiceHandler().getServices(services))); } // convert list to array, never returns null. @@ -220,7 +220,7 @@ private Service getDefaultService() { .withName(serviceName) .withLabels(extractLabels()) .endMetadata(); - ServiceFluent.SpecNested specBuilder = builder.withNewSpec(); + ServiceFluent.SpecNested specBuilder = builder.withNewSpec(); if (!ports.isEmpty()) { specBuilder.withPorts(ports); } else if (Configs.asBoolean(getConfig(Config.HEADLESS))) { @@ -284,7 +284,7 @@ private void addDefaultService(KubernetesListBuilder builder, Service defaultSer log.info("Adding headless default service '%s'", defaultService.getMetadata().getName()); } - builder.addToServiceItems(defaultService); + builder.addToItems(defaultService); } // .................................................................................... diff --git a/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/ImageEnricher.java b/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/ImageEnricher.java index b3ff2651ca..400fb11d1b 100644 --- a/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/ImageEnricher.java +++ b/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/ImageEnricher.java @@ -116,9 +116,9 @@ private void ensureTemplateSpecsInReplicationControllers(KubernetesListBuilder b builder.accept(new TypedVisitor() { @Override public void visit(ReplicationControllerBuilder item) { - ReplicationControllerFluent.SpecNested spec = + ReplicationControllerFluent.SpecNested spec = item.buildSpec() == null ? item.withNewSpec() : item.editSpec(); - ReplicationControllerSpecFluent.TemplateNested> + ReplicationControllerSpecFluent.TemplateNested.SpecNested> template = spec.buildTemplate() == null ? spec.withNewTemplate() : spec.editTemplate(); template.endTemplate().endSpec(); @@ -130,9 +130,9 @@ private void ensureTemplateSpecsInRelicaSet(KubernetesListBuilder builder) { builder.accept(new TypedVisitor() { @Override public void visit(ReplicaSetBuilder item) { - ReplicaSetFluent.SpecNested spec = + ReplicaSetFluent.SpecNested spec = item.buildSpec() == null ? item.withNewSpec() : item.editSpec(); - ReplicaSetSpecFluent.TemplateNested> template = + ReplicaSetSpecFluent.TemplateNested.SpecNested> template = spec.buildTemplate() == null ? spec.withNewTemplate() : spec.editTemplate(); template.endTemplate().endSpec(); } @@ -143,9 +143,9 @@ private void ensureTemplateSpecsInDeployments(KubernetesListBuilder builder) { builder.accept(new TypedVisitor() { @Override public void visit(DeploymentBuilder item) { - DeploymentFluent.SpecNested spec = + DeploymentFluent.SpecNested spec = item.buildSpec() == null ? item.withNewSpec() : item.editSpec(); - DeploymentSpecFluent.TemplateNested> template = + DeploymentSpecFluent.TemplateNested.SpecNested> template = spec.buildTemplate() == null ? spec.withNewTemplate() : spec.editTemplate(); template.endTemplate().endSpec(); } @@ -156,9 +156,9 @@ private void ensureTemplateSpecsInDaemonSet(KubernetesListBuilder builder) { builder.accept(new TypedVisitor() { @Override public void visit(DaemonSetBuilder item) { - DaemonSetFluent.SpecNested spec = + DaemonSetFluent.SpecNested spec = item.buildSpec() == null ? item.withNewSpec() : item.editSpec(); - DaemonSetSpecFluent.TemplateNested> template = + DaemonSetSpecFluent.TemplateNested.SpecNested> template = spec.buildTemplate() == null ? spec.withNewTemplate() : spec.editTemplate(); template.endTemplate().endSpec(); } @@ -169,9 +169,9 @@ private void ensureTemplateSpecsInStatefulSet(KubernetesListBuilder builder) { builder.accept(new TypedVisitor() { @Override public void visit(StatefulSetBuilder item) { - StatefulSetFluent.SpecNested spec = + StatefulSetFluent.SpecNested spec = item.buildSpec() == null ? item.withNewSpec() : item.editSpec(); - StatefulSetSpecFluent.TemplateNested> template = + StatefulSetSpecFluent.TemplateNested.SpecNested> template = spec.buildTemplate() == null ? spec.withNewTemplate() : spec.editTemplate(); template.endTemplate().endSpec(); } @@ -182,9 +182,9 @@ private void ensureTemplateSpecsInDeploymentConfig(KubernetesListBuilder builder builder.accept(new TypedVisitor() { @Override public void visit(DeploymentConfigBuilder item) { - DeploymentConfigFluent.SpecNested spec = + DeploymentConfigFluent.SpecNested spec = item.buildSpec() == null ? item.withNewSpec() : item.editSpec(); - DeploymentConfigSpecFluent.TemplateNested> template = + DeploymentConfigSpecFluent.TemplateNested.SpecNested> template = spec.buildTemplate() == null ? spec.withNewTemplate() : spec.editTemplate(); template.endTemplate().endSpec(); } @@ -198,7 +198,7 @@ private void updateContainers(KubernetesListBuilder builder) { builder.accept(new TypedVisitor() { @Override public void visit(PodTemplateSpecBuilder templateBuilder) { - PodTemplateSpecFluent.SpecNested podSpec = + PodTemplateSpecFluent.SpecNested podSpec = templateBuilder.buildSpec() == null ? templateBuilder.withNewSpec() : templateBuilder.editSpec(); List containers = podSpec.buildContainers(); diff --git a/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/SecretEnricher.java b/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/SecretEnricher.java index fae0f14558..29045a06f9 100644 --- a/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/SecretEnricher.java +++ b/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/SecretEnricher.java @@ -122,7 +122,7 @@ private void addSecretsFromXmlConfiguration(KubernetesListBuilder builder) { Secret secret = new SecretBuilder().withData(data).withMetadata(metadata).withType(type).build(); if(!secretToIndexMap.containsKey(secretConfig.getName())) { - builder.addToSecretItems(i, secret); + builder.addToItems(i, secret); } } } diff --git a/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/ServiceAccountEnricher.java b/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/ServiceAccountEnricher.java index 5cc24bd05e..1dc26d0fef 100644 --- a/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/ServiceAccountEnricher.java +++ b/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/ServiceAccountEnricher.java @@ -67,12 +67,12 @@ public void create(PlatformMode mode, KubernetesListBuilder builder) { if (resourceConfig != null && StringUtils.isNotBlank(resourceConfig.getServiceAccount())) { deploymentToSaPair.put(JKubeProjectUtil.createDefaultResourceName(getContext().getGav().getSanitizedArtifactId()), resourceConfig.getServiceAccount()); } - builder.addAllToServiceAccountItems(createServiceAccountFromResourceConfig(resourceConfig)); - builder.addAllToServiceAccountItems(createServiceAccountsReferencedInDeployment(builder, deploymentToSaPair)); + builder.addAllToItems(createServiceAccountFromResourceConfig(resourceConfig)); + builder.addAllToItems(createServiceAccountsReferencedInDeployment(builder, deploymentToSaPair)); } - private List createServiceAccountFromResourceConfig(ResourceConfig resourceConfig) { - List serviceAccounts = new ArrayList<>(); + private List createServiceAccountFromResourceConfig(ResourceConfig resourceConfig) { + List serviceAccounts = new ArrayList<>(); if(resourceConfig != null && resourceConfig.getServiceAccounts() != null && !Boolean.parseBoolean(getConfig(Config.SKIP_CREATE))) { for(ServiceAccountConfig serviceAccountConfig : resourceConfig.getServiceAccounts()) { if(serviceAccountConfig.getName() != null) { @@ -83,8 +83,8 @@ private List createServiceAccountFromResourceConfig(ResourceConf return serviceAccounts; } - private List createServiceAccountsReferencedInDeployment(KubernetesListBuilder builder, Map deploymentToSaPair) { - List serviceAccounts = new ArrayList<>(); + private List createServiceAccountsReferencedInDeployment(KubernetesListBuilder builder, Map deploymentToSaPair) { + List serviceAccounts = new ArrayList<>(); builder.accept(new TypedVisitor() { @Override public void visit(DeploymentBuilder deploymentBuilder) { diff --git a/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/ConfigMapEnricherTest.java b/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/ConfigMapEnricherTest.java index ca7624f812..db1d5ed13d 100644 --- a/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/ConfigMapEnricherTest.java +++ b/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/ConfigMapEnricherTest.java @@ -49,7 +49,7 @@ void setUpExpectations() { void should_materialize_file_content_from_deprecated_annotation() { final ConfigMap baseConfigMap = createAnnotationConfigMap("test-application.properties", "src/test/resources/test-application.properties", "maven.jkube.io/cm/"); - final KubernetesListBuilder builder = new KubernetesListBuilder().addToConfigMapItems(baseConfigMap); + final KubernetesListBuilder builder = new KubernetesListBuilder().addToItems(baseConfigMap); new ConfigMapEnricher(context).create(PlatformMode.kubernetes, builder); final ConfigMap configMap = (ConfigMap) builder.buildFirstItem(); @@ -63,7 +63,7 @@ void should_materialize_file_content_from_deprecated_annotation() { @Test void should_materialize_dir_content_from_deprecated_annotation() { final ConfigMap baseConfigMap = createAnnotationConfigMap("test-dir", "src/test/resources/test-dir", "maven.jkube.io/cm/"); - final KubernetesListBuilder builder = new KubernetesListBuilder().addToConfigMapItems(baseConfigMap); + final KubernetesListBuilder builder = new KubernetesListBuilder().addToItems(baseConfigMap); new ConfigMapEnricher(context).create(PlatformMode.kubernetes, builder); final ConfigMap configMap = (ConfigMap) builder.buildFirstItem(); @@ -81,7 +81,7 @@ void should_materialize_dir_content_from_deprecated_annotation() { @Test void should_materialize_binary_file_content_from_deprecated_annotation() { final ConfigMap baseConfigMap = createAnnotationConfigMap("test.bin", "src/test/resources/test.bin", "maven.jkube.io/cm/"); - final KubernetesListBuilder builder = new KubernetesListBuilder().addToConfigMapItems(baseConfigMap); + final KubernetesListBuilder builder = new KubernetesListBuilder().addToItems(baseConfigMap); new ConfigMapEnricher(context).create(PlatformMode.kubernetes, builder); final ConfigMap configMap = (ConfigMap) builder.buildFirstItem(); @@ -97,7 +97,7 @@ void should_materialize_binary_file_content_from_deprecated_annotation() { void should_materialize_file_content_from_annotation() { final ConfigMap baseConfigMap = createAnnotationConfigMap("test-application.properties", "src/test/resources/test-application.properties", "jkube.eclipse.org/cm/"); - final KubernetesListBuilder builder = new KubernetesListBuilder().addToConfigMapItems(baseConfigMap); + final KubernetesListBuilder builder = new KubernetesListBuilder().addToItems(baseConfigMap); new ConfigMapEnricher(context).create(PlatformMode.kubernetes, builder); final ConfigMap configMap = (ConfigMap) builder.buildFirstItem(); @@ -111,7 +111,7 @@ void should_materialize_file_content_from_annotation() { @Test void should_materialize_dir_content_from_annotation() { final ConfigMap baseConfigMap = createAnnotationConfigMap("test-dir", "src/test/resources/test-dir", "jkube.eclipse.org/cm/"); - final KubernetesListBuilder builder = new KubernetesListBuilder().addToConfigMapItems(baseConfigMap); + final KubernetesListBuilder builder = new KubernetesListBuilder().addToItems(baseConfigMap); new ConfigMapEnricher(context).create(PlatformMode.kubernetes, builder); final ConfigMap configMap = (ConfigMap) builder.buildFirstItem(); @@ -129,7 +129,7 @@ void should_materialize_dir_content_from_annotation() { @Test void should_materialize_binary_file_content_from_annotation() { final ConfigMap baseConfigMap = createAnnotationConfigMap("test.bin", "src/test/resources/test.bin", "jkube.eclipse.org/cm/"); - final KubernetesListBuilder builder = new KubernetesListBuilder().addToConfigMapItems(baseConfigMap); + final KubernetesListBuilder builder = new KubernetesListBuilder().addToItems(baseConfigMap); new ConfigMapEnricher(context).create(PlatformMode.kubernetes, builder); final ConfigMap configMap = (ConfigMap) builder.buildFirstItem(); diff --git a/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/DockerRegistrySecretEnricherTest.java b/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/DockerRegistrySecretEnricherTest.java index d6da1adf10..18cc09359d 100644 --- a/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/DockerRegistrySecretEnricherTest.java +++ b/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/DockerRegistrySecretEnricherTest.java @@ -62,7 +62,7 @@ void dockerRegistry() { DockerRegistrySecretEnricher enricher = new DockerRegistrySecretEnricher(context); KubernetesListBuilder builder = new KubernetesListBuilder(); Secret secretEnriched = createBaseSecret(true, ANNOTATION); - builder.addToSecretItems(secretEnriched); + builder.addToItems(secretEnriched); enricher.create(PlatformMode.kubernetes, builder); secretEnriched = (Secret) builder.buildItem(0); @@ -84,7 +84,7 @@ void dockerRegistryWithDeprecatedAnnotation() { DockerRegistrySecretEnricher enricher = new DockerRegistrySecretEnricher(context); KubernetesListBuilder builder = new KubernetesListBuilder(); Secret secretEnriched = createBaseSecret(true, "maven.jkube.io/dockerServerId"); - builder.addToSecretItems(secretEnriched); + builder.addToItems(secretEnriched); enricher.create(PlatformMode.kubernetes, builder); secretEnriched = (Secret) builder.buildItem(0); @@ -107,7 +107,7 @@ void dockerRegistryWithBadKind() { KubernetesListBuilder builder = new KubernetesListBuilder(); Secret secret = createBaseSecret(true, ANNOTATION); secret.setKind("Secrets"); - builder.addToSecretItems(createBaseSecret(true, ANNOTATION)); + builder.addToItems(createBaseSecret(true, ANNOTATION)); KubernetesList expected = builder.build(); enricher.create(PlatformMode.kubernetes, builder); @@ -120,7 +120,7 @@ void dockerRegistryWithBadAnnotation() { KubernetesListBuilder builder = new KubernetesListBuilder(); Secret secret = createBaseSecret(true, ANNOTATION); secret.getMetadata().getAnnotations().put(ANNOTATION, "docker1.io"); - builder.addToSecretItems(createBaseSecret(true, ANNOTATION)); + builder.addToItems(createBaseSecret(true, ANNOTATION)); KubernetesList expected = builder.build(); diff --git a/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/FileDataSecretEnricherTest.java b/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/FileDataSecretEnricherTest.java index 1add363763..2807a0bb20 100644 --- a/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/FileDataSecretEnricherTest.java +++ b/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/FileDataSecretEnricherTest.java @@ -50,7 +50,7 @@ void shouldMaterializeFileContentFrom_deprecatedAnnotation() { final FileDataSecretEnricher fileDataSecretEnricher = new FileDataSecretEnricher(context); final KubernetesListBuilder builder = new KubernetesListBuilder(); - builder.addToSecretItems(createBaseSecret("maven.jkube.io/secret/")); + builder.addToItems(createBaseSecret("maven.jkube.io/secret/")); // When fileDataSecretEnricher.create(PlatformMode.kubernetes,builder); @@ -70,7 +70,7 @@ void shouldMaterializeFileContentFrom_Annotation() { // Given final FileDataSecretEnricher fileDataSecretEnricher = new FileDataSecretEnricher(context); final KubernetesListBuilder builder = new KubernetesListBuilder(); - builder.addToSecretItems(createBaseSecret("jkube.eclipse.org/secret/")); + builder.addToItems(createBaseSecret("jkube.eclipse.org/secret/")); // When fileDataSecretEnricher.create(PlatformMode.kubernetes,builder); diff --git a/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/PortNameEnricherTest.java b/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/PortNameEnricherTest.java index 71e07798f0..661412a9ca 100644 --- a/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/PortNameEnricherTest.java +++ b/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/PortNameEnricherTest.java @@ -104,6 +104,6 @@ private static KubernetesListBuilder initKubernetesList() { .endSpec() .endTemplate(); // @formatter:on - return new KubernetesListBuilder().addToPodTemplateItems(ptb.build()); + return new KubernetesListBuilder().addToItems(ptb.build()); } } diff --git a/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/VolumePermissionEnricherTest.java b/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/VolumePermissionEnricherTest.java index 450e40f4a3..a8a2dfbcee 100644 --- a/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/VolumePermissionEnricherTest.java +++ b/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/VolumePermissionEnricherTest.java @@ -82,7 +82,7 @@ void alreadyExistingInitContainer() { .withVolumeMounts(new VolumeMountBuilder().withName("vol-blub").withMountPath("blub").build()) .build(); ptb.editTemplate().editSpec().withInitContainers(Collections.singletonList(initContainer)).endSpec().endTemplate(); - KubernetesListBuilder klb = new KubernetesListBuilder().addToPodTemplateItems(ptb.build()); + KubernetesListBuilder klb = new KubernetesListBuilder().addToItems(ptb.build()); VolumePermissionEnricher enricher = new VolumePermissionEnricher(context); enricher.enrich(PlatformMode.kubernetes,klb); @@ -127,7 +127,7 @@ void adapt() { ptb = addVolume(ptb, vn); } - KubernetesListBuilder klb = new KubernetesListBuilder().addToPodTemplateItems(ptb.build()); + KubernetesListBuilder klb = new KubernetesListBuilder().addToItems(ptb.build()); enricher.enrich(PlatformMode.kubernetes,klb); @@ -173,7 +173,7 @@ void enrich_withResourcesEnabledInConfiguration_shouldAddRequestsLimitsToVolumeI VolumePermissionEnricher enricher = new VolumePermissionEnricher(context); KubernetesListBuilder kubernetesListBuilder = new KubernetesListBuilder(); - kubernetesListBuilder.addToPodTemplateItems(addVolume(createEmptyPodTemplate(), "volumeC").build()); + kubernetesListBuilder.addToItems(addVolume(createEmptyPodTemplate(), "volumeC").build()); // When enricher.enrich(PlatformMode.kubernetes, kubernetesListBuilder); diff --git a/jkube-kit/jkube-kit-vertx/src/main/java/org/eclipse/jkube/vertx/enricher/VertxHealthCheckEnricher.java b/jkube-kit/jkube-kit-vertx/src/main/java/org/eclipse/jkube/vertx/enricher/VertxHealthCheckEnricher.java index ed5bf9e772..8c447c91b9 100644 --- a/jkube-kit/jkube-kit-vertx/src/main/java/org/eclipse/jkube/vertx/enricher/VertxHealthCheckEnricher.java +++ b/jkube-kit/jkube-kit-vertx/src/main/java/org/eclipse/jkube/vertx/enricher/VertxHealthCheckEnricher.java @@ -208,7 +208,7 @@ private Probe discoverVertxHealthCheck(boolean readiness) { switch (type) { case "HTTP": - ProbeFluent.HttpGetNested http = builder.withNewHttpGet() + ProbeFluent.HttpGetNested http = builder.withNewHttpGet() .withScheme(scheme) .withPath(path); port.ifPresent(http::withNewPort); @@ -223,7 +223,7 @@ private Probe discoverVertxHealthCheck(boolean readiness) { http.endHttpGet(); break; case "TCP": - ProbeFluent.TcpSocketNested tcp = builder.withNewTcpSocket(); + ProbeFluent.TcpSocketNested tcp = builder.withNewTcpSocket(); port.ifPresent(tcp::withNewPort); portName.ifPresent(tcp::withNewPort); tcp.endTcpSocket(); diff --git a/jkube-kit/jkube-kit-wildfly-jar/src/test/java/org/eclipse/jkube/wildfly/jar/enricher/WildflyJARHealthCheckEnricherTest.java b/jkube-kit/jkube-kit-wildfly-jar/src/test/java/org/eclipse/jkube/wildfly/jar/enricher/WildflyJARHealthCheckEnricherTest.java index df2dd17bb2..01a190caf1 100644 --- a/jkube-kit/jkube-kit-wildfly-jar/src/test/java/org/eclipse/jkube/wildfly/jar/enricher/WildflyJARHealthCheckEnricherTest.java +++ b/jkube-kit/jkube-kit-wildfly-jar/src/test/java/org/eclipse/jkube/wildfly/jar/enricher/WildflyJARHealthCheckEnricherTest.java @@ -20,7 +20,7 @@ import java.util.List; import java.util.Map; -import io.fabric8.kubernetes.api.model.ContainerFluentImpl; +import io.fabric8.kubernetes.api.model.ContainerFluent; import org.eclipse.jkube.kit.common.Dependency; import org.eclipse.jkube.kit.common.JavaProject; import org.eclipse.jkube.kit.common.Plugin; @@ -281,7 +281,7 @@ public void visit(ContainerBuilder containerBuilder) { }); assertThat(containerBuilders).singleElement() - .extracting(ContainerFluentImpl::buildEnv).asList() + .extracting(ContainerFluent::buildEnv).asList() .singleElement() .hasFieldOrPropertyWithValue("name", "HOSTNAME") .extracting("valueFrom.fieldRef.fieldPath").isNotNull() diff --git a/pom.xml b/pom.xml index 7bb82dfd99..6652176b50 100644 --- a/pom.xml +++ b/pom.xml @@ -100,7 +100,7 @@ 1.49 2.4.10 5.9.3 - 6.7.2 + 6.8.0 4.2 1.18.28 1.18.20.0 From fcdcbdfd9d8611e15cb21eb5c3025d6e829c7d02 Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Wed, 26 Jul 2023 10:19:48 +0530 Subject: [PATCH 54/65] feat (jkube-kit/common) : Add workDir configuration option in ExternalCommand While executing a command, add a workDir configuration option so that command can be executed in directory other than current directory. Signed-off-by: Rohan Kumar --- .../jkube/kit/common/ExternalCommand.java | 9 +- .../jkube/kit/common/ExternalCommandTest.java | 89 +++++++++++++++++++ 2 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/ExternalCommandTest.java diff --git a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/ExternalCommand.java b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/ExternalCommand.java index 26f3716ce8..8bb2033c09 100644 --- a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/ExternalCommand.java +++ b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/ExternalCommand.java @@ -15,6 +15,7 @@ import java.io.BufferedReader; import java.io.BufferedWriter; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -35,13 +36,19 @@ */ public abstract class ExternalCommand { protected final KitLogger log; + private final File workDir; private final ExecutorService executor = Executors.newFixedThreadPool(2); private int statusCode; protected ExternalCommand(KitLogger log) { + this(log, null); + } + + protected ExternalCommand(KitLogger log, File dir) { this.log = log; + this.workDir = dir; } public void execute() throws IOException { @@ -109,7 +116,7 @@ private void inputStreamPump(OutputStream outputStream, String processInput) { private Process startProcess() throws IOException { try { - return Runtime.getRuntime().exec(getArgs()); + return Runtime.getRuntime().exec(getArgs(), null, workDir); } catch (IOException e) { throw new IOException(String.format("Failed to start '%s' : %s", getCommandAsString(), diff --git a/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/ExternalCommandTest.java b/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/ExternalCommandTest.java new file mode 100644 index 0000000000..2405ee3a08 --- /dev/null +++ b/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/ExternalCommandTest.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.common; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import java.io.File; +import java.io.IOException; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIOException; + +class ExternalCommandTest { + private final KitLogger kitLogger = new KitLogger.SilentLogger(); + + @Test + void execute_whenCommandCompletedSuccessfully_thenPrintResult() throws IOException { + // Given + TestCommand testCommand = new TestCommand(kitLogger, new String[] {"echo", "hello"}); + + // When + testCommand.execute(); + + // Then + assertThat(testCommand.getResult()).isEqualTo("hello"); + } + + @Test + void execute_whenCommandFailed_thenThrowException() { + // Given + TestCommand testCommand = new TestCommand(kitLogger, new String[] {"ls", "idontexist"}); + + // When + Then + assertThatIOException() + .isThrownBy(testCommand::execute) + .withMessage("Process 'ls idontexist' exited with status 2"); + } + + @Test + void execute_whenWorkDirProvided_thenUseWorkDir(@TempDir File temporaryFolder) throws IOException { + // Given + TestCommand testCommand = new TestCommand(kitLogger, new String[] {"touch", "foo"}, temporaryFolder); + + // When + testCommand.execute(); + + // Then + assertThat(new File(temporaryFolder, "foo")).exists(); + } + + + private static class TestCommand extends ExternalCommand { + private String result; + private final String[] args; + public TestCommand(KitLogger kitLogger, String[] args) { + this(kitLogger, args, null); + } + + public TestCommand(KitLogger kitLogger, String[] args, File dir) { + super(kitLogger, dir); + this.args = args; + } + + @Override + protected String[] getArgs() { + return args; + } + + @Override + protected void processLine(String line) { + result = line; + } + + public String getResult() { + return result; + } + } +} From 017fae949cad2e2ea08dc25ee23756601aec959b Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Thu, 27 Jul 2023 18:24:56 +0530 Subject: [PATCH 55/65] test (gradle-plugin/it) : Update integration test gradle distribution to v7.6.1 Signed-off-by: Rohan Kumar --- gradle-plugin/it/src/it/vertx/build.gradle | 19 +++++++++++++------ .../plugin/tests/ITGradleRunnerExtension.java | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/gradle-plugin/it/src/it/vertx/build.gradle b/gradle-plugin/it/src/it/vertx/build.gradle index 2380800c9f..f994b4603e 100644 --- a/gradle-plugin/it/src/it/vertx/build.gradle +++ b/gradle-plugin/it/src/it/vertx/build.gradle @@ -11,19 +11,22 @@ * Contributors: * Red Hat, Inc. - initial API and implementation */ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + plugins { id 'java' id 'application' id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}" id 'org.eclipse.jkube.openshift' version "${jKubeVersion}" - id 'io.vertx.vertx-plugin' version '1.3.0' + id("com.github.johnrengelman.shadow") version "7.1.2" } group = 'org.eclipse.jkube.integration.tests.gradle' version = '0.0.1-SNAPSHOT' sourceCompatibility = '11' -def vertxVersion = '4.2.2' +def vertxVersion = '4.4.4' def launcherClassName = 'io.vertx.core.Launcher' +def mainVerticleName = "org.eclipse.jkube.it.gradle.vertx.MainVerticle" repositories { mavenCentral() @@ -38,6 +41,14 @@ dependencies { implementation "io.vertx:vertx-web:$vertxVersion" } +shadowJar { + archiveClassifier.set("fat") + manifest { + attributes "Main-Verticle": mainVerticleName + } + mergeServiceFiles() +} + kubernetes { if (project.hasProperty('configMode') && project.getProperty('configMode').equals('enricherConfig')) { enricher { @@ -99,7 +110,3 @@ if (project.hasProperty('configMode') && project.getProperty('configMode').equal } } } - -vertx { - mainVerticle = 'org.eclipse.jkube.it.gradle.vertx.MainVerticle' -} diff --git a/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/ITGradleRunnerExtension.java b/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/ITGradleRunnerExtension.java index 21092fd92c..1c6449fa0b 100644 --- a/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/ITGradleRunnerExtension.java +++ b/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/ITGradleRunnerExtension.java @@ -31,7 +31,7 @@ public class ITGradleRunnerExtension implements BeforeEachCallback, AfterEachCal @Override public void beforeEach(ExtensionContext context) throws Exception { gradleRunner = GradleRunner.create() - .withGradleDistribution(new URI("https://services.gradle.org/distributions/gradle-6.9-bin.zip")) + .withGradleDistribution(new URI("https://services.gradle.org/distributions/gradle-7.6.1-bin.zip")) .withDebug(true) .withPluginClasspath(Arrays.stream(System.getProperty("java.class.path").split(File.pathSeparator)) .map(File::new).collect(Collectors.toList())); From 95800f5f840211be40c875416bc2f6a337c7e7d2 Mon Sep 17 00:00:00 2001 From: Anurag Rajawat Date: Fri, 28 Jul 2023 11:31:12 +0530 Subject: [PATCH 56/65] fix(gradle-plugin/k8s): Pick docker credentials from `~/.docker/config.json` file (#2290) Signed-off-by: Anurag Rajawat --- CHANGELOG.md | 1 + .../org/eclipse/jkube/gradle/plugin/KubernetesExtension.java | 2 +- .../jkube/gradle/plugin/KubernetesExtensionPropertyTest.java | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfe27853d4..4c7ebf7323 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Usage: * Fix #2219: Kind/Filename mappings include optional apiVersion configuration * Fix #2224: Quarkus native base image read from properties (configurable) * Fix #2228: Quarkus native base image uses UBI 8.7 +* Fix #2290: JKube is not picking docker credentials from `~/.docker/config.json` file * Fix #2302 Bump Kubernetes Client version to 6.8.0 ### 1.13.1 (2023-06-16) diff --git a/gradle-plugin/kubernetes/src/main/java/org/eclipse/jkube/gradle/plugin/KubernetesExtension.java b/gradle-plugin/kubernetes/src/main/java/org/eclipse/jkube/gradle/plugin/KubernetesExtension.java index efb5ed1f13..733ac53961 100644 --- a/gradle-plugin/kubernetes/src/main/java/org/eclipse/jkube/gradle/plugin/KubernetesExtension.java +++ b/gradle-plugin/kubernetes/src/main/java/org/eclipse/jkube/gradle/plugin/KubernetesExtension.java @@ -604,7 +604,7 @@ public boolean getForcePullOrDefault() { } public String getRegistryOrDefault() { - return getOrDefaultString("jkube.docker.registry", this::getRegistry, "docker.io"); + return getOrDefaultString("jkube.docker.registry", this::getRegistry, null); } public String getBuildRecreateOrDefault() { diff --git a/gradle-plugin/kubernetes/src/test/java/org/eclipse/jkube/gradle/plugin/KubernetesExtensionPropertyTest.java b/gradle-plugin/kubernetes/src/test/java/org/eclipse/jkube/gradle/plugin/KubernetesExtensionPropertyTest.java index 18bd4fbcd7..67d2007238 100644 --- a/gradle-plugin/kubernetes/src/test/java/org/eclipse/jkube/gradle/plugin/KubernetesExtensionPropertyTest.java +++ b/gradle-plugin/kubernetes/src/test/java/org/eclipse/jkube/gradle/plugin/KubernetesExtensionPropertyTest.java @@ -95,8 +95,8 @@ static Stream defaultValues() { arguments("getCertPathOrNull", null), arguments("getSkipMachineOrDefault", false), arguments("getForcePullOrDefault", false), - arguments("getRegistryOrDefault", "docker.io"), - arguments("getPullRegistryOrDefault", "docker.io"), + arguments("getRegistryOrDefault", null), + arguments("getPullRegistryOrDefault", null), arguments("getBuildSourceDirectoryOrDefault", "src/main/docker"), arguments("getBuildOutputDirectoryOrDefault", "build/docker"), arguments("getResourceSourceDirectoryOrDefault", BASE.toPath().resolve(Paths.get("src", "main", "jkube")).toFile()), From b915a7188a4c6c746751c4167ed7021ddb7c8bc0 Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Thu, 13 Jul 2023 23:06:08 +0530 Subject: [PATCH 57/65] feat (jkube-kit/resource/helm) : Support for Pushing Helm Charts to OCI (#2091) + Add OCIRepositoryUploader as an additional HelmUploader + Add OCI repository related helper classes in `org.eclipse.jkube.kit.resource.helm.oci` package Signed-off-by: Rohan Kumar --- jkube-kit/common/pom.xml | 6 + .../kit/common/util/Fabric8HttpUtil.java | 19 +- .../kit/common/util/Fabric8HttpUtilTest.java | 3 +- jkube-kit/parent/pom.xml | 8 + jkube-kit/resource/helm/pom.xml | 11 + .../ArtifactoryHelmRepositoryUploader.java | 6 +- .../ChartMuseumHelmRepositoryUploader.java | 6 +- .../kit/resource/helm/HelmRepository.java | 25 +- .../jkube/kit/resource/helm/HelmService.java | 3 +- .../resource/helm/HelmUploaderManager.java | 5 +- .../helm/NexusHelmRepositoryUploader.java | 6 +- .../resource/helm/OCIRepositoryUploader.java | 86 ++++++ .../helm/StandardRepositoryUploader.java | 24 +- .../kit/resource/helm/oci/OCIManifest.java | 37 +++ .../resource/helm/oci/OCIManifestLayer.java | 33 +++ .../resource/helm/oci/OCIRegistryClient.java | 188 ++++++++++++ .../helm/oci/OCIRegistryEndpoint.java | 57 ++++ .../helm/oci/OCIRegistryInterceptor.java | 166 +++++++++++ .../resources/META-INF/jkube/helm-uploaders | 3 +- .../resource/helm/HelmServiceUploadIT.java | 53 +++- .../helm/HelmUploaderManagerTest.java | 6 +- .../helm/OCIRepositoryUploaderTest.java | 105 +++++++ .../helm/TestMockResponseProvider.java | 39 +++ .../helm/oci/OCIManifestLayerTest.java | 68 +++++ .../resource/helm/oci/OCIManifestTest.java | 84 ++++++ .../helm/oci/OCIRegistryClientTest.java | 279 ++++++++++++++++++ .../helm/oci/OCIRegistryEndpointTest.java | 68 +++++ .../helm/oci/OCIRegistryInterceptorTest.java | 202 +++++++++++++ .../src/test/resources/test-oci-manifest.json | 13 + 29 files changed, 1541 insertions(+), 68 deletions(-) create mode 100644 jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/OCIRepositoryUploader.java create mode 100644 jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifest.java create mode 100644 jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestLayer.java create mode 100644 jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryClient.java create mode 100644 jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryEndpoint.java create mode 100644 jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryInterceptor.java create mode 100644 jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/OCIRepositoryUploaderTest.java create mode 100644 jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/TestMockResponseProvider.java create mode 100644 jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestLayerTest.java create mode 100644 jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestTest.java create mode 100644 jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryClientTest.java create mode 100644 jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryEndpointTest.java create mode 100644 jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryInterceptorTest.java create mode 100644 jkube-kit/resource/helm/src/test/resources/test-oci-manifest.json diff --git a/jkube-kit/common/pom.xml b/jkube-kit/common/pom.xml index c7c2afa7ab..b0006f326c 100644 --- a/jkube-kit/common/pom.xml +++ b/jkube-kit/common/pom.xml @@ -130,6 +130,12 @@ junit-jupiter-params test + + io.fabric8 + kubernetes-client-api + test-jar + test + io.fabric8 openshift-server-mock diff --git a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/Fabric8HttpUtil.java b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/Fabric8HttpUtil.java index 77679d186b..1e4ea399de 100644 --- a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/Fabric8HttpUtil.java +++ b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/Fabric8HttpUtil.java @@ -14,6 +14,7 @@ package org.eclipse.jkube.kit.common.util; import io.fabric8.kubernetes.client.http.HttpResponse; +import org.apache.commons.lang3.StringUtils; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; @@ -34,15 +35,17 @@ private Fabric8HttpUtil() { } * @param response Http Response of a particular request * @return map containing various components of header as key value pairs */ - public static Map extractAuthenticationChallengeIntoMap(HttpResponse response) { - String wwwAuthenticateHeader = response.header(WWW_AUTHENTICATE); - String[] wwwAuthenticateHeaders = wwwAuthenticateHeader.split(","); + public static Map extractAuthenticationChallengeIntoMap(HttpResponse response) { Map result = new HashMap<>(); - for (String challenge : wwwAuthenticateHeaders) { - if (challenge.contains("=")) { - String[] challengeParts = challenge.split("="); - if (challengeParts.length == 2) { - result.put(challengeParts[0], strip(challengeParts[1], "\"")); + String wwwAuthenticateHeader = response.header(WWW_AUTHENTICATE); + if (StringUtils.isNotBlank(wwwAuthenticateHeader)) { + String[] wwwAuthenticateHeaders = wwwAuthenticateHeader.split(","); + for (String challenge : wwwAuthenticateHeaders) { + if (challenge.contains("=")) { + String[] challengeParts = challenge.split("="); + if (challengeParts.length == 2) { + result.put(challengeParts[0], strip(challengeParts[1], "\"")); + } } } } diff --git a/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/Fabric8HttpUtilTest.java b/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/Fabric8HttpUtilTest.java index 964dd48cd4..26b31c499d 100644 --- a/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/Fabric8HttpUtilTest.java +++ b/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/Fabric8HttpUtilTest.java @@ -14,6 +14,7 @@ package org.eclipse.jkube.kit.common.util; import io.fabric8.kubernetes.client.http.HttpResponse; +import io.fabric8.kubernetes.client.http.TestHttpResponse; import org.junit.jupiter.api.Test; import java.io.UnsupportedEncodingException; @@ -53,7 +54,7 @@ void extractAuthenticationChallengeIntoMap_whenWwwHeaderProvided_thenParseDataIn String wwwAuthenticateValue = "Bearer realm=\"https://auth.example.com/token\",service=\"registry.example.com\",scope=\"repository:myuser/test-chart:pull\""; Map> responseHeaders = new HashMap<>(); responseHeaders.put("WWW-Authenticate", Collections.singletonList(wwwAuthenticateValue)); - HttpResponse response = new TestFabric8HttpResponse(HTTP_OK, responseHeaders, null, null); + HttpResponse response = new TestHttpResponse(responseHeaders).withCode(HTTP_OK); // When Map wwwAuthenticateAsMap = Fabric8HttpUtil.extractAuthenticationChallengeIntoMap(response); diff --git a/jkube-kit/parent/pom.xml b/jkube-kit/parent/pom.xml index 0858444dfa..f616821c40 100644 --- a/jkube-kit/parent/pom.xml +++ b/jkube-kit/parent/pom.xml @@ -677,6 +677,14 @@ + + io.fabric8 + kubernetes-client-api + test-jar + ${version.kubernetes-client} + test + + org.junit.jupiter junit-jupiter-engine diff --git a/jkube-kit/resource/helm/pom.xml b/jkube-kit/resource/helm/pom.xml index 0fd55c3f0f..a20c1385a3 100644 --- a/jkube-kit/resource/helm/pom.xml +++ b/jkube-kit/resource/helm/pom.xml @@ -38,6 +38,10 @@ org.projectlombok lombok + + commons-codec + commons-codec + org.apache.httpcomponents httpclient @@ -49,6 +53,13 @@ test test-jar + + io.fabric8 + kubernetes-client-api + test-jar + test + + org.junit.jupiter junit-jupiter-engine diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ArtifactoryHelmRepositoryUploader.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ArtifactoryHelmRepositoryUploader.java index 25f44e9fc6..fe903e9cb1 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ArtifactoryHelmRepositoryUploader.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ArtifactoryHelmRepositoryUploader.java @@ -13,14 +13,12 @@ */ package org.eclipse.jkube.kit.resource.helm; -import org.eclipse.jkube.kit.common.KitLogger; - import java.io.File; public class ArtifactoryHelmRepositoryUploader extends StandardRepositoryUploader { - public ArtifactoryHelmRepositoryUploader(KitLogger logger) { - super("PUT", logger, HelmRepository.HelmRepoType.ARTIFACTORY); + public ArtifactoryHelmRepositoryUploader() { + super("PUT", HelmRepository.HelmRepoType.ARTIFACTORY); } @Override diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ChartMuseumHelmRepositoryUploader.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ChartMuseumHelmRepositoryUploader.java index 38d40d3ef1..da9c6142e9 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ChartMuseumHelmRepositoryUploader.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/ChartMuseumHelmRepositoryUploader.java @@ -13,14 +13,12 @@ */ package org.eclipse.jkube.kit.resource.helm; -import org.eclipse.jkube.kit.common.KitLogger; - import java.io.File; public class ChartMuseumHelmRepositoryUploader extends StandardRepositoryUploader { - public ChartMuseumHelmRepositoryUploader(KitLogger logger) { - super("POST", logger, HelmRepository.HelmRepoType.CHARTMUSEUM); + public ChartMuseumHelmRepositoryUploader() { + super("POST", HelmRepository.HelmRepoType.CHARTMUSEUM); } @Override diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmRepository.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmRepository.java index 98e4f99b45..d1c19dc696 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmRepository.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmRepository.java @@ -20,9 +20,6 @@ import lombok.NoArgsConstructor; import lombok.Setter; -import java.io.File; -import java.io.IOException; -import java.net.HttpURLConnection; import java.util.Optional; @Builder(toBuilder = true) @@ -50,28 +47,14 @@ public void setType(String type) { } public enum HelmRepoType { - CHARTMUSEUM(HelmRepositoryConnectionUtils::getConnectionForUploadToChartMuseum), - ARTIFACTORY(HelmRepositoryConnectionUtils::getConnectionForUploadToArtifactory), - NEXUS(HelmRepositoryConnectionUtils::getConnectionForUploadToNexus); - - private final ConnectionCreator connectionCreator; - - HelmRepoType(ConnectionCreator connectionCreator) { - this.connectionCreator = connectionCreator; - } - - public HttpURLConnection createConnection(File file, HelmRepository repository) throws IOException { - return connectionCreator.createConnectionForUploadToArtifactory(file, repository); - } + CHARTMUSEUM, + ARTIFACTORY, + NEXUS, + OCI; public static HelmRepoType parseString(String repoType) { return Optional.ofNullable(repoType).map(String::toUpperCase).map(HelmRepoType::valueOf).orElse(null); } - - @FunctionalInterface - protected interface ConnectionCreator { - HttpURLConnection createConnectionForUploadToArtifactory(File file, HelmRepository repository) throws IOException; - } } @Override diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmService.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmService.java index 192c44c1e7..387bdce061 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmService.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmService.java @@ -159,8 +159,8 @@ public void uploadHelmChart(HelmConfig helm) throws BadUploadException, IOExcept private void uploadHelmChart(HelmConfig helmConfig, HelmRepository helmRepository) throws IOException, BadUploadException { + final HelmUploaderManager helmUploaderManager = new HelmUploaderManager(); for (HelmConfig.HelmType helmType : helmConfig.getTypes()) { - final HelmUploaderManager helmUploaderManager = new HelmUploaderManager(logger); logger.info("Uploading Helm Chart \"%s\" to %s", helmConfig.getChart(), helmRepository.getName()); logger.debug("OutputDir: %s", helmConfig.getOutputDir()); @@ -171,6 +171,7 @@ private void uploadHelmChart(HelmConfig helmConfig, HelmRepository helmRepositor helmConfig.getChart(), helmConfig.getVersion(), resolveHelmClassifier(helmConfig), helmConfig.getChartExtension())); helmUploaderManager.getHelmUploader(helmRepository.getType()).uploadSingle(tarballFile, helmRepository); + logger.info("Upload Successful"); } } diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManager.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManager.java index c10718d904..10de2933be 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManager.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManager.java @@ -13,7 +13,6 @@ */ package org.eclipse.jkube.kit.resource.helm; -import org.eclipse.jkube.kit.common.KitLogger; import org.eclipse.jkube.kit.common.util.PluginServiceFactory; import java.util.List; @@ -25,8 +24,8 @@ public class HelmUploaderManager { private final List helmUploaderList; - public HelmUploaderManager(KitLogger log) { - this.helmUploaderList = new PluginServiceFactory<>(log).createServiceObjects(SERVICE_PATHS); + public HelmUploaderManager() { + this.helmUploaderList = new PluginServiceFactory<>(null).createServiceObjects(SERVICE_PATHS); } public HelmUploader getHelmUploader(HelmRepository.HelmRepoType type) { diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/NexusHelmRepositoryUploader.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/NexusHelmRepositoryUploader.java index be5e62fc96..e221c0808e 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/NexusHelmRepositoryUploader.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/NexusHelmRepositoryUploader.java @@ -13,13 +13,11 @@ */ package org.eclipse.jkube.kit.resource.helm; -import org.eclipse.jkube.kit.common.KitLogger; - import java.io.File; public class NexusHelmRepositoryUploader extends StandardRepositoryUploader { - public NexusHelmRepositoryUploader(KitLogger logger) { - super("PUT", logger, HelmRepository.HelmRepoType.NEXUS); + public NexusHelmRepositoryUploader() { + super("PUT", HelmRepository.HelmRepoType.NEXUS); } @Override diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/OCIRepositoryUploader.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/OCIRepositoryUploader.java new file mode 100644 index 0000000000..23c87e807e --- /dev/null +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/OCIRepositoryUploader.java @@ -0,0 +1,86 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.resource.helm; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import io.fabric8.kubernetes.client.http.HttpClient; +import io.fabric8.kubernetes.client.utils.HttpClientUtils; +import io.fabric8.kubernetes.client.utils.Serialization; +import org.apache.commons.codec.digest.DigestUtils; +import org.eclipse.jkube.kit.resource.helm.oci.OCIRegistryClient; +import org.eclipse.jkube.kit.resource.helm.oci.OCIRegistryInterceptor; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.file.Files; + +public class OCIRepositoryUploader implements HelmUploader { + private static final ObjectMapper yamlObjectMapper = new ObjectMapper(new YAMLFactory()); + + @Override + public HelmRepository.HelmRepoType getType() { + return HelmRepository.HelmRepoType.OCI; + } + + @Override + public void uploadSingle(File file, HelmRepository repository) + throws IOException, BadUploadException { + Chart chartConfig = createChartMetadataFromGeneratedChartYamlFile(file); + HttpClient.Factory httpClientFactory = HttpClientUtils.getHttpClientFactory(); + try (HttpClient httpClient = httpClientFactory.newBuilder() + .addOrReplaceInterceptor(OCIRegistryInterceptor.NAME, new OCIRegistryInterceptor(httpClientFactory, repository)) + .build()) { + OCIRegistryClient oci = new OCIRegistryClient(repository, httpClient); + + uploadChartToOCIRegistry(oci, chartConfig, file); + } + } + + private void uploadChartToOCIRegistry(OCIRegistryClient oci, Chart chartConfig, File file) throws IOException, BadUploadException { + String chartMetadataContentPayload = Serialization.asJson(chartConfig); + String chartTarballBlobDigest = DigestUtils.sha256Hex(Files.newInputStream(file.toPath())); + String chartMetadataBlobDigest = DigestUtils.sha256Hex(chartMetadataContentPayload); + long chartMetadataPayloadSize = chartMetadataContentPayload.getBytes(Charset.defaultCharset()).length; + long chartTarballSize = file.length(); + + String chartTarballDockerContentDigest = uploadBlobIfNotExist(oci, chartConfig.getName(), chartTarballBlobDigest, chartTarballSize, null, file); + String chartConfigDockerContentDigest = uploadBlobIfNotExist(oci, chartConfig.getName(), chartMetadataBlobDigest, chartMetadataPayloadSize, chartMetadataContentPayload, null); + + oci.uploadOCIManifest(chartConfig.getName(), chartConfig.getVersion(), chartConfigDockerContentDigest, chartTarballDockerContentDigest, chartMetadataPayloadSize, chartTarballSize); + } + + private String uploadBlobIfNotExist(OCIRegistryClient oci, String chartName, String blob, long blobSize, String blobContentStr, File blobFile) throws IOException, BadUploadException { + boolean alreadyUploaded = oci.isLayerUploadedAlready(chartName, blob); + if (alreadyUploaded) { + return String.format("sha256:%s", blob); + } else { + return uploadBlob(oci, chartName, blob, blobSize, blobContentStr, blobFile); + } + } + + private String uploadBlob(OCIRegistryClient oci, String chartName, String blob, long blobSize, String blobContentStr, File blobFile) throws IOException, BadUploadException { + String uploadUrl = oci.initiateUploadProcess(chartName); + return oci.uploadBlob(uploadUrl, blob, blobSize, blobContentStr, blobFile); + } + + private Chart createChartMetadataFromGeneratedChartYamlFile(File chartFile) throws IOException { + File chartMetadataFile = new File(chartFile.getParentFile(), "Chart.yaml"); + if (chartMetadataFile.exists()) { + return yamlObjectMapper.readValue(chartMetadataFile, Chart.class); + } + throw new IllegalStateException("Could not found Chart.yaml file in " + chartMetadataFile.getPath()); + } +} \ No newline at end of file diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/StandardRepositoryUploader.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/StandardRepositoryUploader.java index 0979d538da..d89cabeaeb 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/StandardRepositoryUploader.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/StandardRepositoryUploader.java @@ -19,7 +19,6 @@ import io.fabric8.kubernetes.client.http.HttpResponse; import io.fabric8.kubernetes.client.utils.HttpClientUtils; import org.apache.commons.lang3.StringUtils; -import org.eclipse.jkube.kit.common.KitLogger; import org.eclipse.jkube.kit.common.util.Base64Util; import java.io.File; @@ -31,13 +30,11 @@ public abstract class StandardRepositoryUploader implements HelmUploader { private final String method; - private final KitLogger logger; private final HelmRepository.HelmRepoType type; private static final long HELM_UPLOAD_TIMEOUT_MINUTES = 30; - protected StandardRepositoryUploader(String method, KitLogger logger, HelmRepository.HelmRepoType type) { + protected StandardRepositoryUploader(String method, HelmRepository.HelmRepoType type) { this.method = method; - this.logger = logger; this.type = type; } @@ -53,12 +50,13 @@ public void uploadSingle(File file, HelmRepository repository) throws IOExceptio String uploadUrl = url(file, repository); try (HttpClient httpClient = HttpClientUtils.getHttpClientFactory().newBuilder().tag(new RequestConfigBuilder().withRequestRetryBackoffLimit(0).build()).build()) { - HttpRequest.Builder httpRequestBuilder = httpClient.newHttpRequestBuilder(); - httpRequestBuilder.uri(uploadUrl); - // At this point username and password are always populated since this is requirement in HelmService - httpRequestBuilder.header("Authorization", String.format("Basic %s", Base64Util.encodeToString(repository.getUsername() + ":" + repository.getPassword()))); - httpRequestBuilder.method(method, "application/gzip", Files.newInputStream(file.toPath()), file.length()); - HttpResponse response = get(httpClient.sendAsync(httpRequestBuilder.build(), byte[].class), Duration.ofMinutes(HELM_UPLOAD_TIMEOUT_MINUTES)); + HttpRequest httpRequest = httpClient.newHttpRequestBuilder() + .method(method, "application/gzip", Files.newInputStream(file.toPath()), file.length()) + // At this point username and password are always populated since this is requirement in HelmService + .header("Authorization", String.format("Basic %s", Base64Util.encodeToString(repository.getUsername() + ":" + repository.getPassword()))) + .uri(uploadUrl) + .build(); + HttpResponse response = get(httpClient.sendAsync(httpRequest, byte[].class), Duration.ofMinutes(HELM_UPLOAD_TIMEOUT_MINUTES)); handleHttpResponse(response); } } @@ -74,12 +72,6 @@ private void handleHttpResponse(HttpResponse response) throws BadUploadE responseStr = "No details provided"; } throw new BadUploadException(responseStr); - } else { - String message = Integer.toString(response.code()); - if (response.body() != null) { - message += " - " + new String(response.body()); - } - logger.info(message); } } diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifest.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifest.java new file mode 100644 index 0000000000..1d3023baab --- /dev/null +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifest.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.resource.helm.oci; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.Singular; + +import java.util.List; + +@Builder(toBuilder = true) +@AllArgsConstructor +@NoArgsConstructor +@Getter +@Setter +@EqualsAndHashCode +public class OCIManifest { + private int schemaVersion; + private OCIManifestLayer config; + @Singular + private List layers; +} diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestLayer.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestLayer.java new file mode 100644 index 0000000000..9793a5bc7b --- /dev/null +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestLayer.java @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.resource.helm.oci; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Builder(toBuilder = true) +@AllArgsConstructor +@NoArgsConstructor +@Getter +@Setter +@EqualsAndHashCode +public class OCIManifestLayer { + private String mediaType; + private String digest; + private long size; +} \ No newline at end of file diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryClient.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryClient.java new file mode 100644 index 0000000000..072dd622ec --- /dev/null +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryClient.java @@ -0,0 +1,188 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.resource.helm.oci; + +import io.fabric8.kubernetes.client.http.HttpClient; +import io.fabric8.kubernetes.client.http.HttpRequest; +import io.fabric8.kubernetes.client.http.HttpResponse; +import io.fabric8.kubernetes.client.utils.Serialization; +import io.fabric8.kubernetes.client.utils.URLUtils; +import org.apache.commons.lang3.StringUtils; +import org.eclipse.jkube.kit.resource.helm.BadUploadException; +import org.eclipse.jkube.kit.resource.helm.HelmRepository; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.time.Duration; +import java.util.Optional; + +import static java.net.HttpURLConnection.HTTP_ACCEPTED; +import static java.net.HttpURLConnection.HTTP_NOT_FOUND; +import static java.net.HttpURLConnection.HTTP_OK; +import static org.apache.commons.lang3.StringUtils.EMPTY; +import static org.eclipse.jkube.kit.common.util.AsyncUtil.get; + +public class OCIRegistryClient { + private static final String DOCKER_CONTENT_DIGEST = "Docker-Content-Digest"; + private static final String USER_AGENT = "EclipseJKube"; + private static final String OCI_IMAGE_MANIFEST_MEDIA_TYPE = "application/vnd.oci.image.manifest.v1+json"; + private static final String HELM_CONFIG_MEDIA_TYPE = "application/vnd.cncf.helm.config.v1+json"; + private static final String HELM_CHART_CONTENT_MEDIA_TYPE = "application/vnd.cncf.helm.chart.content.v1.tar+gzip"; + private static final String LOCATION_HEADER = "Location"; + private static final long OCI_UPLOAD_HTTP_REQUEST_TIMEOUT = 30; + private final HelmRepository repository; + private final OCIRegistryEndpoint ociRegistryEndpoint; + private final HttpClient httpClient; + + public OCIRegistryClient(HelmRepository repository, HttpClient httpClient) { + this.repository = repository; + this.ociRegistryEndpoint = new OCIRegistryEndpoint(repository.getUrl()); + this.httpClient = httpClient; + } + + public String getBaseUrl() throws MalformedURLException { + return ociRegistryEndpoint.getBaseUrl(); + } + + public String initiateUploadProcess(String chartName) throws IOException { + String uploadProcessInitiateUrl = ociRegistryEndpoint.getBlobUploadInitUrl(chartName); + HttpRequest httpRequest = createBaseOCIHttpRequest() + .post("application/json", EMPTY) + .uri(uploadProcessInitiateUrl) + .build(); + HttpResponse response = get(httpClient.sendAsync(httpRequest, byte[].class), Duration.ofMinutes(OCI_UPLOAD_HTTP_REQUEST_TIMEOUT)); + + int responseCode = response.code(); + if (responseCode != HTTP_ACCEPTED) { + throw new IllegalStateException("Failure in initiating upload request: " + response.message()); + } else { + String locationHeader = parseLocationHeaderFromResponse(response, ociRegistryEndpoint.getBaseUrl()); + if (StringUtils.isBlank(locationHeader)) { + throw new IllegalStateException(String.format("No %s header found in upload initiation response", LOCATION_HEADER)); + } + return locationHeader; + } + } + + public String uploadOCIManifest(String chartName, String chartVersion, String chartConfigDigest, String chartTarballDigest, long chartConfigPayloadSize, long chartTarballContentSize) throws IOException, BadUploadException { + String manifestUrl = ociRegistryEndpoint.getManifestUrl(chartName, chartVersion); + String manifestPayload = createChartManifestPayload(chartConfigDigest, chartTarballDigest, chartConfigPayloadSize, chartTarballContentSize); + InputStream requestBodyInputStream = new ByteArrayInputStream(manifestPayload.getBytes(StandardCharsets.UTF_8)); + long contentLength = manifestPayload.getBytes().length; + HttpRequest httpRequest = createBaseOCIHttpRequest() + .header("Host", new URL(repository.getUrl()).getHost()) + .uri(manifestUrl) + .method("PUT", OCI_IMAGE_MANIFEST_MEDIA_TYPE, requestBodyInputStream, contentLength) + .build(); + + HttpResponse response = get(httpClient.sendAsync(httpRequest, byte[].class), Duration.ofMinutes(OCI_UPLOAD_HTTP_REQUEST_TIMEOUT)); + + if (!response.isSuccessful()) { + handleFailure(response); + } + return extractDockerContentDigestFromResponseHeaders(response); + } + + public String uploadBlob(String uploadUrl, String blobDigest, long blobSize, String blobContentStr, File blobFile) throws IOException, BadUploadException { + uploadUrl = new URLUtils.URLBuilder(uploadUrl).addQueryParameter("digest", String.format("sha256:%s", blobDigest)).toString(); + InputStream blobContentInputStream = blobFile != null ? Files.newInputStream(blobFile.toPath()) : new ByteArrayInputStream(blobContentStr.getBytes()); + HttpRequest httpRequest = createBaseOCIHttpRequest() + .uri(uploadUrl) + .method("PUT", "application/octet-stream", blobContentInputStream, blobSize) + .build(); + HttpResponse response = get(httpClient.sendAsync(httpRequest, byte[].class), Duration.ofMinutes(OCI_UPLOAD_HTTP_REQUEST_TIMEOUT)); + + if (!response.isSuccessful()) { + handleFailure(response); + } + return extractDockerContentDigestFromResponseHeaders(response); + } + + public boolean isLayerUploadedAlready(String chartName, String digest) throws IOException { + String blobExistenceCheckUrl = ociRegistryEndpoint.getBlobUrl(chartName, digest); + HttpRequest httpRequest = createBaseOCIHttpRequest().uri(blobExistenceCheckUrl).build(); + HttpResponse response = get(httpClient.sendAsync(httpRequest, byte[].class), Duration.ofMinutes(OCI_UPLOAD_HTTP_REQUEST_TIMEOUT)); + + int responseCode = response.code(); + if (responseCode == HTTP_NOT_FOUND) { + return false; + } + return responseCode == HTTP_OK; + } + + private void handleFailure(HttpResponse response) throws BadUploadException { + int responseCode = response.code(); + String responseStr = Optional.ofNullable(response.body()) + .map(String::new) + .orElse(Optional.ofNullable(response.message()).orElse("No details provided")); + if (responseCode == HttpURLConnection.HTTP_BAD_REQUEST) { + throw new BadUploadException(responseStr); + } else { + throw new IllegalStateException("Received " + responseCode + " : " + responseStr); + } + } + + private String extractDockerContentDigestFromResponseHeaders(HttpResponse response) { + String dockerContentDigest = response.header(DOCKER_CONTENT_DIGEST); + if (StringUtils.isNotBlank(dockerContentDigest)) { + return dockerContentDigest; + } + throw new IllegalStateException("No " + DOCKER_CONTENT_DIGEST + " header found in upload response"); + } + + private HttpRequest.Builder createBaseOCIHttpRequest() { + HttpRequest.Builder httpRequestBuilder = httpClient.newHttpRequestBuilder(); + httpRequestBuilder.header("User-Agent", USER_AGENT); + return httpRequestBuilder; + } + + private String parseLocationHeaderFromResponse(HttpResponse response, String baseUrl) { + String locationHeader = response.header(LOCATION_HEADER); + + // Only path is returned via GitHub Container Registry + if (locationHeader != null && locationHeader.startsWith("/")) { + locationHeader = baseUrl + locationHeader; + } + return locationHeader; + } + + private String createChartManifestPayload(String chartConfigDigest, String chartTarballDigest, long chartConfigPayloadSize, + long chartTarballContentSize) { + OCIManifest manifest = createChartManifest(chartConfigDigest, chartTarballDigest, chartConfigPayloadSize, chartTarballContentSize); + return Serialization.asJson(manifest); + } + + private OCIManifest createChartManifest(String digest, String layerDigest, long chartConfigPayloadSize, long chartTarballContentSize) { + return OCIManifest.builder() + .schemaVersion(2) + .config(OCIManifestLayer.builder() + .mediaType(HELM_CONFIG_MEDIA_TYPE) + .digest(digest) + .size(chartConfigPayloadSize) + .build()) + .layer(OCIManifestLayer.builder() + .mediaType(HELM_CHART_CONTENT_MEDIA_TYPE) + .digest(layerDigest) + .size(chartTarballContentSize) + .build()) + .build(); + } +} \ No newline at end of file diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryEndpoint.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryEndpoint.java new file mode 100644 index 0000000000..791f012efb --- /dev/null +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryEndpoint.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.resource.helm.oci; + + +import org.apache.commons.lang3.StringUtils; + +import java.net.MalformedURLException; +import java.net.URL; + +public class OCIRegistryEndpoint { + private final String url; + + public OCIRegistryEndpoint(String baseUrl) { + this.url = StringUtils.removeEnd(baseUrl, "/"); + } + + public String getBlobUrl(String chartName, String digest) throws MalformedURLException { + return String.format("%s/%s/blobs/sha256:%s", getV2ApiUrl(), chartName, digest); + } + + public String getBlobUploadInitUrl(String chartName) throws MalformedURLException { + return String.format("%s/%s/blobs/uploads/", getV2ApiUrl(), chartName); + } + + public String getManifestUrl(String chartName, String version) throws MalformedURLException { + return String.format("%s/%s/manifests/%s", getV2ApiUrl(), chartName, version); + } + + public String getV2ApiUrl() throws MalformedURLException { + URL registryUrl = new URL(url); + + return String.format("%s/v2%s", getBaseUrl(), registryUrl.getPath()); + } + + public String getBaseUrl() throws MalformedURLException { + URL registryUrl = new URL(url); + + String portString = ""; + if (registryUrl.getPort() > 0) { + portString = String.format(":%d", registryUrl.getPort()); + } + + return String.format("%s://%s%s", registryUrl.getProtocol(), registryUrl.getHost(), portString); + } +} diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryInterceptor.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryInterceptor.java new file mode 100644 index 0000000000..d76f1e9e78 --- /dev/null +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryInterceptor.java @@ -0,0 +1,166 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.resource.helm.oci; + +import io.fabric8.kubernetes.client.http.BasicBuilder; +import io.fabric8.kubernetes.client.http.HttpClient; +import io.fabric8.kubernetes.client.http.HttpRequest; +import io.fabric8.kubernetes.client.http.HttpResponse; +import io.fabric8.kubernetes.client.http.Interceptor; +import io.fabric8.kubernetes.client.utils.Serialization; +import org.apache.commons.lang3.StringUtils; +import org.eclipse.jkube.kit.common.util.Base64Util; +import org.eclipse.jkube.kit.resource.helm.HelmRepository; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.HttpURLConnection; +import java.time.Duration; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; + +import static java.net.HttpURLConnection.HTTP_UNAUTHORIZED; +import static org.eclipse.jkube.kit.common.util.AsyncUtil.get; +import static org.eclipse.jkube.kit.common.util.Fabric8HttpUtil.extractAuthenticationChallengeIntoMap; +import static org.eclipse.jkube.kit.common.util.Fabric8HttpUtil.toFormData; + +public class OCIRegistryInterceptor implements Interceptor { + private static final String TOKEN_KEY = "token"; + private static final String ACCESS_TOKEN_KEY = "access_token"; + private static final long OCI_REGISTRY_AUTH_REQUEST_TIMEOUT_MINUTES = 1; + private static final String WWW_AUTHENTICATE = "WWW-Authenticate"; + public static final String NAME = "OCI_TOKEN"; + private static final String AUTHORIZATION = "Authorization"; + private static final String BEARER = "Bearer "; + + private final HelmRepository repository; + private final HttpClient httpClient; + private String accessToken; + + public OCIRegistryInterceptor(HttpClient.Factory httpClientFactory, HelmRepository helmRepository) { + this(httpClientFactory, helmRepository, null); + } + + OCIRegistryInterceptor(HttpClient.Factory httpClientFactory, HelmRepository helmRepository, String token) { + repository = helmRepository; + httpClient = httpClientFactory.newBuilder().build(); + accessToken = token; + } + + @Override + public void before(BasicBuilder headerBuilder, HttpRequest request, RequestTags tags) { + if (StringUtils.isNotBlank(accessToken)) { + headerBuilder.setHeader(AUTHORIZATION, BEARER + accessToken); + } + } + + @Override + public CompletableFuture afterFailure(BasicBuilder headerBuilder, HttpResponse response, RequestTags tags) { + if (response.code() == HTTP_UNAUTHORIZED) { + if (StringUtils.isBlank(response.header(WWW_AUTHENTICATE))) { + throw new IllegalStateException("Got 401 but no " + WWW_AUTHENTICATE + " found in response headers "); + } + return refreshToken(headerBuilder, response); + } + return CompletableFuture.completedFuture(false); + } + + private CompletableFuture refreshToken(BasicBuilder headerBuilder, HttpResponse response) { + try { + String updatedAccessToken = submitHttpRequestForAuthenticationChallenge(response); + if (StringUtils.isNotBlank(updatedAccessToken)) { + accessToken = updatedAccessToken; + headerBuilder.setHeader(AUTHORIZATION, BEARER + accessToken); + return CompletableFuture.completedFuture(true); + } + return CompletableFuture.completedFuture(false); + } catch (IOException e) { + throw new IllegalStateException("Failure while refreshing token from OCI registry: ", e); + } + } + + private String submitHttpRequestForAuthenticationChallenge(HttpResponse response) throws IOException { + Map authChallengeHeader = extractAuthenticationChallengeIntoMap(response); + String authenticationUrl = authChallengeHeader.get("Bearer realm"); + String scope = authChallengeHeader.get("scope"); + if (!scope.contains("push")) { + scope += ",push"; + } + String service = authChallengeHeader.get("service"); + + return submitGetRequest(authenticationUrl, scope, service); + } + + private String submitGetRequest(String url, String scope, String service) throws IOException { + String authUrlWithQueryParams = String.format("%s?service=%s&scope=%s", url, service, scope); + HttpRequest httpRequest = httpClient.newHttpRequestBuilder() + .header(AUTHORIZATION, String.format("Basic %s", Base64Util.encodeToString(repository.getUsername() + ":" + repository.getPassword()))) + .uri(authUrlWithQueryParams) + .build(); + HttpResponse response = get(httpClient.sendAsync(httpRequest, byte[].class), Duration.ofMinutes(OCI_REGISTRY_AUTH_REQUEST_TIMEOUT_MINUTES)); + + int responseCode = response.code(); + if (responseCode == HttpURLConnection.HTTP_OK) { + return parseAccessTokenFromResponse(new String(response.body())); + } else if (responseCode == HttpURLConnection.HTTP_BAD_METHOD) { // DockerHub uses post for authentication + return submitPostRequest(url, scope, service); + } + return null; + } + + private String submitPostRequest(String url, String scope, String service) throws IOException { + String postDataString = createPostFormDataForDockerAuth(scope, service); + HttpRequest httpRequest = httpClient.newHttpRequestBuilder() + .header("Content-Length", Integer.toString(postDataString.getBytes().length)) + .method("POST", "application/x-www-form-urlencoded", postDataString) + .uri(url) + .build(); + + HttpResponse response = get(httpClient.sendAsync(httpRequest, byte[].class), Duration.ofMinutes(OCI_REGISTRY_AUTH_REQUEST_TIMEOUT_MINUTES)); + if (response.isSuccessful()) { + return parseAccessTokenFromResponse(response.bodyString()); + } + return null; + } + + private String parseAccessTokenFromResponse(String responseBody) { + Map responseBodyObj = Serialization.unmarshal(responseBody, Map.class); + String tokenFound = null; + if (responseBodyObj.containsKey(TOKEN_KEY)) { + tokenFound = (String) responseBodyObj.get(TOKEN_KEY); + } + if (responseBodyObj.containsKey(ACCESS_TOKEN_KEY)) { + tokenFound = (String) responseBodyObj.get(ACCESS_TOKEN_KEY); + } + + if (StringUtils.isNotBlank(tokenFound)) { + return tokenFound; + } + return null; + } + + private String createPostFormDataForDockerAuth(String scope, String service) throws UnsupportedEncodingException { + Map postFormData = new HashMap<>(); + postFormData.put("grant_type", "password"); + postFormData.put("refresh_token", repository.getPassword()); + postFormData.put("service", service); + postFormData.put("scope", scope); + postFormData.put("client_id", "EclipseJKube"); + postFormData.put("username", repository.getUsername()); + postFormData.put("password", repository.getPassword()); + + return toFormData(postFormData); + } +} diff --git a/jkube-kit/resource/helm/src/main/resources/META-INF/jkube/helm-uploaders b/jkube-kit/resource/helm/src/main/resources/META-INF/jkube/helm-uploaders index 1c88bb86bf..fc2e844639 100644 --- a/jkube-kit/resource/helm/src/main/resources/META-INF/jkube/helm-uploaders +++ b/jkube-kit/resource/helm/src/main/resources/META-INF/jkube/helm-uploaders @@ -1,3 +1,4 @@ org.eclipse.jkube.kit.resource.helm.ArtifactoryHelmRepositoryUploader,100 org.eclipse.jkube.kit.resource.helm.ChartMuseumHelmRepositoryUploader,100 -org.eclipse.jkube.kit.resource.helm.NexusHelmRepositoryUploader,100 \ No newline at end of file +org.eclipse.jkube.kit.resource.helm.NexusHelmRepositoryUploader,100 +org.eclipse.jkube.kit.resource.helm.OCIRepositoryUploader,100 \ No newline at end of file diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUploadIT.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUploadIT.java index aac06aa401..15ede65773 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUploadIT.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUploadIT.java @@ -51,6 +51,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; +import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.spy; @@ -339,7 +340,7 @@ void withSuccessfulPutUpload_shouldLogSuccess(String repositoryType) throws Exce // When helmService.uploadHelmChart(helmConfig); // Then - verify(logger).info("201 - Upload successful"); + verify(logger).info("Upload Successful"); } @DisplayName("Logs success after successful POST request") @@ -355,7 +356,7 @@ void withSuccessfulPostUpload_shouldLogSuccess(String repositoryType) throws Exc // When helmService.uploadHelmChart(helmConfig); // Then - verify(logger).info("201 - Upload successful"); + verify(logger).info("Upload Successful"); } @DisplayName("Sends file in PUT request") @@ -422,6 +423,54 @@ void tgzExtensionHandling() throws Exception { } } + @DisplayName("OCI repository specifics") + @Nested + class OCI { + + @BeforeEach + void setUp() { + helmConfig.getSnapshotRepository().setType("OCI"); + } + + @Test + @DisplayName("Sends chart metadata file, tarball and manifest file in separate requests") + void withSuccessfulUpload_shouldUploadBlobsAndUpdateManifest() throws Exception { + // Given + helmConfig.setChartExtension("tar.gz"); + Files.write( + Paths.get(helmConfig.getOutputDir()).resolve("kubernetes") + .resolve("Helm-Chart-1337-SNAPSHOT.tar.gz"), + "I'm a tar.gz, not a .tgz".getBytes(StandardCharsets.UTF_8)); + Files.write(Paths.get(helmConfig.getOutputDir()).resolve("kubernetes").resolve("Chart.yaml"), + "---\napiVersion: v1\nname: test-chart\nversion: 0.0.1".getBytes(StandardCharsets.UTF_8)); + mockServer.expect().post() + .withPath("/v2/test-chart/blobs/uploads/") + .andReply(new TestMockResponseProvider(202, singletonMap("Location", "/v2/test-chart/blobs/upload/first-upload-endpoint"), null)) + .once(); + mockServer.expect().post() + .withPath("/v2/test-chart/blobs/uploads/") + .andReply(new TestMockResponseProvider(202, singletonMap("Location", "/v2/test-chart/blobs/upload/second-upload-endpoint"), null)) + .once(); + mockServer.expect().put() + .withPath("/v2/test-chart/blobs/upload/first-upload-endpoint?digest=sha256%3Ac7051faa2fb28d147b34070a6bce25eaf1ee6bb4ca3b47af5ee6148d50079154") + .andReply(new TestMockResponseProvider(200, singletonMap("Docker-Content-Digest", "dockerdigest1"), null)) + .once(); + mockServer.expect().put() + .withPath("/v2/test-chart/blobs/upload/second-upload-endpoint?digest=sha256%3A530abfbfb3897f927efcac9610a26e97c7455d2bf5a7a5b8be02e646f10a041f") + .andReply(new TestMockResponseProvider(200, singletonMap("Docker-Content-Digest", "dockerdigest2"), null)) + .once(); + mockServer.expect().put() + .withPath("/v2/test-chart/manifests/0.0.1") + .andReply(new TestMockResponseProvider(200, singletonMap("Docker-Content-Digest", "manifestdigest"), null)) + .once(); + // When + helmService.uploadHelmChart(helmConfig); + // Then + assertThat(mockServer.getLastRequest().getBody().readUtf8()) + .isEqualTo("{\"schemaVersion\":2,\"config\":{\"mediaType\":\"application/vnd.cncf.helm.config.v1+json\",\"digest\":\"dockerdigest2\",\"size\":57},\"layers\":[{\"mediaType\":\"application/vnd.cncf.helm.chart.content.v1.tar+gzip\",\"digest\":\"dockerdigest1\",\"size\":24}]}"); + } + } + private void expect(HttpMethod method, String path, ServerResponse response) { responses.computeIfAbsent( new SimpleRequest(method, path), diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManagerTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManagerTest.java index 8c22557bbb..651d127837 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManagerTest.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManagerTest.java @@ -13,7 +13,6 @@ */ package org.eclipse.jkube.kit.resource.helm; -import org.eclipse.jkube.kit.common.KitLogger; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -27,7 +26,8 @@ private static Stream testData() { return Stream.of( Arguments.of("ARTIFACTORY", ArtifactoryHelmRepositoryUploader.class), Arguments.of("NEXUS", NexusHelmRepositoryUploader.class), - Arguments.of("CHARTMUSEUM", ChartMuseumHelmRepositoryUploader.class) + Arguments.of("CHARTMUSEUM", ChartMuseumHelmRepositoryUploader.class), + Arguments.of("OCI", OCIRepositoryUploader.class) ); } @@ -35,7 +35,7 @@ private static Stream testData() { @MethodSource("testData") void getHelmUploader_whenValidHelmTypeProvided_thenReturnAppropriateUploader(HelmRepository.HelmRepoType type, Class helmUploaderType) { // Given - HelmUploaderManager helmUploaderManager = new HelmUploaderManager(new KitLogger.SilentLogger()); + HelmUploaderManager helmUploaderManager = new HelmUploaderManager(); // When HelmUploader helmUploader = helmUploaderManager.getHelmUploader(type); diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/OCIRepositoryUploaderTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/OCIRepositoryUploaderTest.java new file mode 100644 index 0000000000..152cb0fff9 --- /dev/null +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/OCIRepositoryUploaderTest.java @@ -0,0 +1,105 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.resource.helm; + +import org.apache.commons.io.FileUtils; +import org.eclipse.jkube.kit.resource.helm.oci.OCIRegistryClient; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.mockito.MockedConstruction; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.isNull; +import static org.mockito.Mockito.mockConstruction; +import static org.mockito.Mockito.when; + +class OCIRepositoryUploaderTest { + private OCIRepositoryUploader ociRepositoryUploader; + private HelmRepository helmRepository; + @TempDir + private File tempDir; + private File chartFile; + + @BeforeEach + void setUp() throws IOException { + helmRepository = HelmRepository.builder() + .url("https://r.example.com/myuser") + .username("myuser") + .build(); + ociRepositoryUploader = new OCIRepositoryUploader(); + File chartMetadataFile = new File(tempDir, "Chart.yaml"); + chartFile = new File(tempDir, "test-chart-0.0.1.tar.gz"); + assertThat(chartFile.createNewFile()).isTrue(); + assertThat(chartMetadataFile.createNewFile()).isTrue(); + FileUtils.write(chartMetadataFile, "---\napiVersion: v1\nname: test-chart\nversion: 0.0.1", Charset.defaultCharset()); + } + + @Test + void uploadSingle_whenChartBlobsAlreadyUploaded_thenLogPushSkip() throws BadUploadException, IOException { + try (MockedConstruction ociMockedConstruction = mockConstruction(OCIRegistryClient.class, (mock, ctx) -> { + when(mock.getBaseUrl()).thenReturn("https://r.example.com"); + when(mock.isLayerUploadedAlready(anyString(), anyString())).thenReturn(true); + when(mock.uploadOCIManifest(anyString(), anyString(), anyString(), anyString(), anyLong(), anyLong())).thenReturn("sha256:uploadmanifestdigest"); + })) { + // When + ociRepositoryUploader.uploadSingle(chartFile, helmRepository); + + // Then + assertThat(ociMockedConstruction.constructed()).hasSize(1); + } + } + + @Test + void uploadSingle_whenChartPushFailed_thenThrowException() { + try (MockedConstruction ignore = mockConstruction(OCIRegistryClient.class, (mock, ctx) -> { + when(mock.getBaseUrl()).thenReturn("https://r.example.com"); + when(mock.isLayerUploadedAlready(anyString(), anyString())).thenReturn(false); + when(mock.initiateUploadProcess(anyString())).thenReturn("https://r.example.com/v2/myuser/blobs/uploads/random-uuid?state=testing"); + when(mock.uploadBlob(anyString(), anyString(), anyLong(), anyString(), any())) + .thenThrow(new BadUploadException("invalid upload data")); + })) { + // When + assertThatExceptionOfType(BadUploadException.class) + .isThrownBy(() -> ociRepositoryUploader.uploadSingle(chartFile, helmRepository)) + .withMessage("invalid upload data"); + } + } + + @Test + void uploadSingle_whenChartSuccessfullyPushedToRegistry_thenLogDockerContentManifest() throws BadUploadException, IOException { + try (MockedConstruction ociMockedConstruction = mockConstruction(OCIRegistryClient.class, (mock, ctx) -> { + when(mock.getBaseUrl()).thenReturn("https://r.example.com"); + when(mock.isLayerUploadedAlready(anyString(), anyString())).thenReturn(false); + when(mock.initiateUploadProcess(anyString())).thenReturn("https://r.example.com/v2/myuser/blobs/uploads/random-uuid?state=testing"); + when(mock.uploadBlob(anyString(), anyString(), anyLong(), isNull(), any())).thenReturn("sha256:charttarballdigest"); + when(mock.uploadBlob(anyString(), anyString(), anyLong(), anyString(), isNull())).thenReturn("sha256:chartconfigdigest"); + when(mock.uploadOCIManifest(anyString(), anyString(), anyString(), anyString(), anyLong(), anyLong())).thenReturn("sha256:uploadmanifestdigest"); + })) { + // When + ociRepositoryUploader.uploadSingle(chartFile, helmRepository); + + // Then + assertThat(ociMockedConstruction.constructed()).hasSize(1); + } + } +} diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/TestMockResponseProvider.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/TestMockResponseProvider.java new file mode 100644 index 0000000000..ef6f0b26c0 --- /dev/null +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/TestMockResponseProvider.java @@ -0,0 +1,39 @@ +package org.eclipse.jkube.kit.resource.helm; + +import io.fabric8.mockwebserver.utils.ResponseProvider; +import okhttp3.Headers; +import okhttp3.mockwebserver.RecordedRequest; + +import java.util.Map; + +public class TestMockResponseProvider implements ResponseProvider { + private final int code; + private final Map headers; + private final Object body; + + public TestMockResponseProvider(int code, Map headers, Object body) { + this.code = code; + this.headers = headers; + this.body = body; + } + + @Override + public int getStatusCode(RecordedRequest recordedRequest) { + return code; + } + + @Override + public Headers getHeaders() { + return Headers.of(headers); + } + + @Override + public void setHeaders(Headers headers) { + + } + + @Override + public Object getBody(RecordedRequest recordedRequest) { + return body; + } +} diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestLayerTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestLayerTest.java new file mode 100644 index 0000000000..e5c7529bdd --- /dev/null +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestLayerTest.java @@ -0,0 +1,68 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.resource.helm.oci; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.Test; + +import java.io.IOException; + +import static org.assertj.core.api.Assertions.assertThat; + +class OCIManifestLayerTest { + @Test + void rawDeserialization() throws IOException { + // Given + final ObjectMapper mapper = new ObjectMapper(); + // When + final OCIManifestLayer layer = mapper.readValue( + "{\"size\":312,\"mediaType\": \"application/vnd.cncf.helm.config.v1+json\",\"digest\": \"sha256:0adb1aa9fee705698ee731ed26da27b0c2e15961d81d0616cfa38f134575f4e8\"}", + OCIManifestLayer.class); + // Then + assertOCIManifestLayer(layer); + } + + @Test + void builder() { + // Given + OCIManifestLayer.OCIManifestLayerBuilder layerBuilder = OCIManifestLayer.builder() + .size(312) + .mediaType("application/vnd.cncf.helm.config.v1+json") + .digest("sha256:0adb1aa9fee705698ee731ed26da27b0c2e15961d81d0616cfa38f134575f4e8"); + + // When + OCIManifestLayer layer = layerBuilder.build(); + + // Then + assertOCIManifestLayer(layer); + } + + private void assertOCIManifestLayer(OCIManifestLayer layer) { + assertThat(layer) + .hasFieldOrPropertyWithValue("size", 312L) + .hasFieldOrPropertyWithValue("mediaType", "application/vnd.cncf.helm.config.v1+json") + .hasFieldOrPropertyWithValue("digest", "sha256:0adb1aa9fee705698ee731ed26da27b0c2e15961d81d0616cfa38f134575f4e8"); + } + + @Test + void equalsAndHashCodeShouldMatch() { + // Given + OCIManifestLayer l1 = OCIManifestLayer.builder().digest("sha256:016b77128b6bdf63ce4000e38fc36dcb15dfd6feea2d244a2c797a2d4f75a2de").build(); + OCIManifestLayer l2 = OCIManifestLayer.builder().digest("sha256:016b77128b6bdf63ce4000e38fc36dcb15dfd6feea2d244a2c797a2d4f75a2de").build(); + // When + Then + assertThat(l1) + .isEqualTo(l2) + .hasSameHashCodeAs(l2); + } +} diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestTest.java new file mode 100644 index 0000000000..d17c4194fb --- /dev/null +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestTest.java @@ -0,0 +1,84 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.resource.helm.oci; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.assertj.core.api.InstanceOfAssertFactories; +import org.junit.jupiter.api.Test; + +import java.io.IOException; + +import static org.assertj.core.api.Assertions.assertThat; + +class OCIManifestTest { + @Test + void rawDeserialization() throws IOException { + // Given + final ObjectMapper mapper = new ObjectMapper(); + // When + final OCIManifest result = mapper.readValue( + getClass().getResourceAsStream("/test-oci-manifest.json"), + OCIManifest.class); + // Then + assertOCIManifest(result); + } + + @Test + void builder() { + // Given + OCIManifest.OCIManifestBuilder manifestBuilder = OCIManifest.builder() + .schemaVersion(2) + .config(OCIManifestLayer.builder() + .size(312) + .mediaType("application/vnd.cncf.helm.config.v1+json") + .digest("sha256:fe8b2f27ce12b302342d4a5da2b2945ab869c7acb9e1b718c5426d91ce38cfc4") + .build()) + .layer(OCIManifestLayer.builder() + .size(9272) + .mediaType("application/vnd.cncf.helm.chart.content.v1.tar+gzip") + .digest("sha256:fe8b2f27ce12b302342d4a5da2b2945ab869c7acb9e1b718c5426d91ce38cfc4") + .build()); + + // When + OCIManifest manifest = manifestBuilder.build(); + + // Then + assertOCIManifest(manifest); + } + + private void assertOCIManifest(OCIManifest manifest) { + assertThat(manifest) + .hasFieldOrPropertyWithValue("schemaVersion", 2) + .hasFieldOrPropertyWithValue("config.mediaType", "application/vnd.cncf.helm.config.v1+json") + .hasFieldOrPropertyWithValue("config.digest", "sha256:fe8b2f27ce12b302342d4a5da2b2945ab869c7acb9e1b718c5426d91ce38cfc4") + .hasFieldOrPropertyWithValue("config.size", 312L) + .extracting(OCIManifest::getLayers) + .asList() + .singleElement(InstanceOfAssertFactories.type(OCIManifestLayer.class)) + .hasFieldOrPropertyWithValue("size", 9272L) + .hasFieldOrPropertyWithValue("mediaType", "application/vnd.cncf.helm.chart.content.v1.tar+gzip") + .hasFieldOrPropertyWithValue("digest", "sha256:fe8b2f27ce12b302342d4a5da2b2945ab869c7acb9e1b718c5426d91ce38cfc4"); + } + + @Test + void equalsAndHashCodeShouldMatch() { + // Given + OCIManifest m1 = OCIManifest.builder().schemaVersion(2).build(); + OCIManifest m2 = OCIManifest.builder().schemaVersion(2).build(); + // When + Then + assertThat(m1) + .isEqualTo(m2) + .hasSameHashCodeAs(m2); + } +} diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryClientTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryClientTest.java new file mode 100644 index 0000000000..2c6e020f0a --- /dev/null +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryClientTest.java @@ -0,0 +1,279 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.resource.helm.oci; + +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.jkube.kit.resource.helm.BadUploadException; +import org.eclipse.jkube.kit.resource.helm.HelmRepository; +import org.eclipse.jkube.kit.resource.helm.TestMockResponseProvider; + +import io.fabric8.kubernetes.client.http.HttpClient; +import io.fabric8.kubernetes.client.utils.HttpClientUtils; +import io.fabric8.mockwebserver.DefaultMockServer; +import org.apache.http.HttpHeaders; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import static java.net.HttpURLConnection.HTTP_ACCEPTED; +import static java.net.HttpURLConnection.HTTP_BAD_REQUEST; +import static java.net.HttpURLConnection.HTTP_CREATED; +import static java.net.HttpURLConnection.HTTP_NOT_FOUND; +import static java.net.HttpURLConnection.HTTP_OK; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; + +class OCIRegistryClientTest { + private OCIRegistryClient oci; + private String chartName; + private String chartVersion; + private String chartTarballBlobDigest; + private String chartConfigBlobDigest; + private long chartConfigPayloadSizeInBytes; + private File chartFile; + private HttpClient httpClient; + private DefaultMockServer server; + @TempDir + File temporaryFolder; + + @BeforeEach + void setUp() throws IOException { + chartName = "test-chart"; + chartVersion = "0.0.1"; + chartConfigBlobDigest = "f2ab3e153f678e5f01062717a203f4ca47a556159bcbb1e8a3ec5d84b5dd7aef"; + chartTarballBlobDigest = "98c4987b6502c7eb8e29a8844e0e1f1d19a8925594f8271ae70f9a51412e737a"; + chartConfigPayloadSizeInBytes = 10; + chartFile = new File(temporaryFolder, "test-chart-0.0.1.tar.gz"); + Files.write(chartFile.toPath(), "helm-chart-content".getBytes(StandardCharsets.UTF_8)); + server = new DefaultMockServer(); + server.start(); + httpClient = HttpClientUtils.getHttpClientFactory().newBuilder().build(); + HelmRepository helmRepository = HelmRepository.builder() + .url(String.format("%s/myuser", getServerUrl())) + .build(); + oci = new OCIRegistryClient(helmRepository, httpClient); + } + + @AfterEach + void tearDown() { + server.shutdown(); + httpClient.close(); + } + + private String getServerUrl() { + return String.format("http://%s:%d", server.getHostName(), server.getPort()); + } + + @Test + void getBaseUrl_whenInvoked_shouldReturnRegistryUrl() throws MalformedURLException { + assertThat(oci.getBaseUrl()).isEqualTo(getServerUrl()); + } + + @Test + void initiateUploadProcess_whenRegistryResponseSuccessfulAndContainsLocation_thenReturnUploadUrl() throws IOException { + // Given + Map uploadResponseHeaders = new HashMap<>(); + String responseLocationHeader = getServerUrl() + "/v2/myuser/test-chart/blobs/uploads/17f1053c-fcd7-47a7-a34b-bbf23bbdf906?_state=uploadstate"; + uploadResponseHeaders.put(HttpHeaders.LOCATION, responseLocationHeader); + server.expect().post() + .withPath("/v2/myuser/test-chart/blobs/uploads/") + .andReply(new TestMockResponseProvider(HTTP_ACCEPTED, uploadResponseHeaders, null)) + .once(); + + // When + String uploadUrl = oci.initiateUploadProcess(chartName); + + // Then + assertThat(uploadUrl).isEqualTo(responseLocationHeader); + } + + @Test + void initiateUploadProcess_whenRegistryResponseSuccessfulButLocationHeaderContainsPathOnly_thenReturnUploadUrl() throws IOException { + // Given + Map uploadResponseHeaders = new HashMap<>(); + String responseLocationHeader = "/v2/myuser/test-chart/blobs/uploads/17f1053c-fcd7-47a7-a34b-bbf23bbdf906?_state=uploadstate"; + uploadResponseHeaders.put(HttpHeaders.LOCATION, responseLocationHeader); + server.expect().post() + .withPath("/v2/myuser/test-chart/blobs/uploads/") + .andReply(new TestMockResponseProvider(HTTP_ACCEPTED, uploadResponseHeaders, null)) + .once(); + + // When + String uploadUrl = oci.initiateUploadProcess(chartName); + + // Then + assertThat(uploadUrl).isEqualTo(String.format("http://%s:%d%s", server.getHostName(), server.getPort(), responseLocationHeader)); + } + + @Test + void initiateUploadProcess_whenRegistryResponseSuccessfulButNoHeader_thenThrowException() { + // Given + server.expect().post() + .withPath("/v2/myuser/test-chart/blobs/uploads/") + .andReturn(HTTP_ACCEPTED, "") + .once(); + + // When + Then + assertThatIllegalStateException() + .isThrownBy(() -> oci.initiateUploadProcess(chartName)) + .withMessage("No Location header found in upload initiation response"); + } + + @Test + void initiateUploadProcess_whenRegistryResponseFailure_thenThrowException() { + // Given + server.expect().post() + .withPath("/v2/myuser/test-chart/blobs/uploads/") + .andReturn(HTTP_NOT_FOUND, "") + .once(); + + // When + Then + assertThatIllegalStateException() + .isThrownBy(() -> oci.initiateUploadProcess(chartName)) + .withMessage("Failure in initiating upload request: Not Found"); + } + + @Test + void uploadOCIManifest_whenManifestSuccessfullyPushed_thenReturnDockerContentDigest() throws BadUploadException, IOException { + // Given + String responseDockerContentDigestHeader = "sha256:createdmanifestdigest"; + server.expect().put() + .withPath("/v2/myuser/test-chart/manifests/0.0.1") + .andReply(new TestMockResponseProvider(HTTP_CREATED, Collections.singletonMap("Docker-Content-Digest", responseDockerContentDigestHeader), null)) + .once(); + + // When + String dockerContentDigest = oci.uploadOCIManifest(chartName, chartVersion, chartConfigBlobDigest, chartTarballBlobDigest, chartConfigPayloadSizeInBytes, chartFile.length()); + + // Then + assertThat(dockerContentDigest).isEqualTo(responseDockerContentDigestHeader); + } + + @Test + void uploadOCIManifest_whenRegistryRejectedManifest_thenThrowException() { + // Given + server.expect().put() + .withPath("/v2/myuser/test-chart/manifests/0.0.1") + .andReply(new TestMockResponseProvider(HTTP_BAD_REQUEST, Collections.emptyMap(), "invalid manifest")) + .once(); + + // When + Then + assertThatExceptionOfType(BadUploadException.class) + .isThrownBy(() -> oci.uploadOCIManifest(chartName, chartVersion, chartConfigBlobDigest, chartTarballBlobDigest, chartConfigPayloadSizeInBytes, chartFile.length())) + .withMessage("invalid manifest"); + } + + @Test + void uploadOCIManifest_whenManifestSuccessfullyPushedButNoDockerContentDigest_thenThrowException() { + // Given + server.expect().put() + .withPath("/v2/myuser/test-chart/manifests/0.0.1") + .andReply(new TestMockResponseProvider(HTTP_CREATED, Collections.emptyMap(), null)) + .once(); + + // When + assertThatIllegalStateException() + .isThrownBy(() -> oci.uploadOCIManifest(chartName, chartVersion, chartConfigBlobDigest, chartTarballBlobDigest, chartConfigPayloadSizeInBytes, chartFile.length())) + .withMessage("No Docker-Content-Digest header found in upload response"); + } + + @Test + void uploadBlob_whenBlobSuccessfullyPushedToRegistry_thenReturnDockerContentDigest() throws BadUploadException, IOException { + // Given + String blobUploadUrl = getServerUrl() + "/v2/myuser/test-chart/blobs/uploads/17f1053c-fcd7-47a7-a34b-bbf23bbdf906?_state=XZnxHKS"; + Map responseHeaders = new HashMap<>(); + responseHeaders.put("Docker-Content-Digest", "sha256:016b77128b6bdf63ce4000e38fc36dcb15dfd6feea2d244a2c797a2d4f75a2de"); + server.expect().put() + .withPath("/v2/myuser/test-chart/blobs/uploads/17f1053c-fcd7-47a7-a34b-bbf23bbdf906?_state=XZnxHKS&digest=sha256%3A98c4987b6502c7eb8e29a8844e0e1f1d19a8925594f8271ae70f9a51412e737a") + .andReply(new TestMockResponseProvider(HTTP_CREATED, responseHeaders, null)) + .once(); + + // When + String dockerContentDigest = oci.uploadBlob(blobUploadUrl, chartTarballBlobDigest, chartFile.length(), null, chartFile); + + // Then + assertThat(dockerContentDigest) + .isEqualTo("sha256:016b77128b6bdf63ce4000e38fc36dcb15dfd6feea2d244a2c797a2d4f75a2de"); + } + + @Test + void uploadBlob_whenBlobRejectedByRegistry_thenThrowException() { + // Given + String blobUploadUrl = getServerUrl() + "/v2/myuser/test-chart/blobs/uploads/17f1053c-fcd7-47a7-a34b-bbf23bbdf906?_state=XZnxHKS"; + server.expect().put() + .withPath("/v2/myuser/test-chart/blobs/uploads/17f1053c-fcd7-47a7-a34b-bbf23bbdf906?_state=XZnxHKS&digest=sha256%3A98c4987b6502c7eb8e29a8844e0e1f1d19a8925594f8271ae70f9a51412e737a") + .andReply(new TestMockResponseProvider(HTTP_BAD_REQUEST, Collections.emptyMap(), "invalid data")) + .once(); + + // When + Then + assertThatExceptionOfType(BadUploadException.class) + .isThrownBy(() -> oci.uploadBlob(blobUploadUrl, chartTarballBlobDigest, chartFile.length(), null, chartFile)) + .withMessage("invalid data"); + } + + @Test + void uploadBlob_whenBlobSuccessfullyPushedToRegistryButNoDockerContentDigest_thenThrowException() throws BadUploadException, IOException { + // Given + String blobUploadUrl = getServerUrl() + "/v2/myuser/test-chart/blobs/uploads/17f1053c-fcd7-47a7-a34b-bbf23bbdf906?_state=XZnxHKS"; + server.expect().put() + .withPath("/v2/myuser/test-chart/blobs/uploads/17f1053c-fcd7-47a7-a34b-bbf23bbdf906?_state=XZnxHKS&digest=sha256%3A98c4987b6502c7eb8e29a8844e0e1f1d19a8925594f8271ae70f9a51412e737a") + .andReply(new TestMockResponseProvider(HTTP_CREATED, Collections.emptyMap(), null)) + .once(); + + // When + Then + assertThatIllegalStateException() + .isThrownBy(() -> oci.uploadBlob(blobUploadUrl, chartTarballBlobDigest, chartFile.length(), null, chartFile)) + .withMessage("No Docker-Content-Digest header found in upload response"); + } + + @Test + void isLayerUploadedAlready_whenRegistryReturns200_thenReturnTrue() throws IOException { + // Given + server.expect().get() + .withPath("/v2/myuser/test-chart/blobs/sha256:" + chartConfigBlobDigest) + .andReply(new TestMockResponseProvider(HTTP_OK, Collections.emptyMap(), null)) + .once(); + + // When + boolean result = oci.isLayerUploadedAlready(chartName, chartConfigBlobDigest); + + // Then + assertThat(result).isTrue(); + } + + @Test + void isLayerUploadedAlready_whenRegistryReturns404_thenReturnFalse() throws IOException { + // Given + server.expect().get() + .withPath("/v2/myuser/test-chart/blobs/sha256:" + chartConfigBlobDigest) + .andReply(new TestMockResponseProvider(HTTP_NOT_FOUND, Collections.emptyMap(), null)) + .once(); + + // When + boolean result = oci.isLayerUploadedAlready(chartName, chartConfigBlobDigest); + + // Then + assertThat(result).isFalse(); + } +} diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryEndpointTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryEndpointTest.java new file mode 100644 index 0000000000..4b55f1f55a --- /dev/null +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryEndpointTest.java @@ -0,0 +1,68 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.resource.helm.oci; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.net.MalformedURLException; + +import static org.assertj.core.api.Assertions.assertThat; + +class OCIRegistryEndpointTest { + private OCIRegistryEndpoint registryEndpoint; + + @BeforeEach + void setUp() { + this.registryEndpoint = new OCIRegistryEndpoint("https://r.example.com/myuser"); + } + + @Test + void getBaseUrl_whenInvoked_shouldReturnBaseUrl() throws MalformedURLException { + assertThat(registryEndpoint.getBaseUrl()).isEqualTo("https://r.example.com"); + } + + @Test + void getBaseUrl_whenInvokedWithRegistrySpecifyingPort_thenShouldReturnBaseUrlAsExpected() throws MalformedURLException { + // Given + this.registryEndpoint = new OCIRegistryEndpoint("http://localhost:5000/myuser"); + + // When + String url = registryEndpoint.getBaseUrl(); + + // Then + assertThat(url).isEqualTo("http://localhost:5000"); + } + + @Test + void getV2ApiUrl_whenInvoked_shouldReturnV2Url() throws MalformedURLException { + assertThat(registryEndpoint.getV2ApiUrl()).isEqualTo("https://r.example.com/v2/myuser"); + } + + @Test + void getBlobUploadInitUrl_whenInvoked_shouldReturnBlobUploadInitUrl() throws MalformedURLException { + assertThat(registryEndpoint.getBlobUploadInitUrl("test-chart")).isEqualTo("https://r.example.com/v2/myuser/test-chart/blobs/uploads/"); + } + + @Test + void getManifestUrl_whenInvoked_shouldReturnManifestUrl() throws MalformedURLException { + assertThat(registryEndpoint.getManifestUrl("test-chart", "0.0.1")).isEqualTo("https://r.example.com/v2/myuser/test-chart/manifests/0.0.1"); + } + + @Test + void getBlobUrl_whenInvoked_shouldReturnBlobUrl() throws MalformedURLException { + assertThat(registryEndpoint.getBlobUrl("test-chart", "7ed393daf1ffc94803c08ffcbecb798fa58e786bebffbab02da5458f68d0ecb0")) + .isEqualTo("https://r.example.com/v2/myuser/test-chart/blobs/sha256:7ed393daf1ffc94803c08ffcbecb798fa58e786bebffbab02da5458f68d0ecb0"); + } +} diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryInterceptorTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryInterceptorTest.java new file mode 100644 index 0000000000..c98ae75437 --- /dev/null +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryInterceptorTest.java @@ -0,0 +1,202 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.resource.helm.oci; + +import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; + +import io.fabric8.kubernetes.client.http.HttpClient; +import org.eclipse.jkube.kit.resource.helm.HelmRepository; + +import io.fabric8.kubernetes.client.http.HttpRequest; +import io.fabric8.kubernetes.client.http.HttpResponse; +import io.fabric8.kubernetes.client.http.TestHttpResponse; +import io.fabric8.kubernetes.client.utils.HttpClientUtils; +import io.fabric8.mockwebserver.DefaultMockServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.apache.http.HttpHeaders; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; + +import static java.net.HttpURLConnection.HTTP_BAD_METHOD; +import static java.net.HttpURLConnection.HTTP_NOT_FOUND; +import static java.net.HttpURLConnection.HTTP_OK; +import static java.net.HttpURLConnection.HTTP_UNAUTHORIZED; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +class OCIRegistryInterceptorTest { + private OCIRegistryInterceptor ociRegistryInterceptor; + private DefaultMockServer server; + private String authUrl; + private HttpClient.Factory httpClientFactory; + private HelmRepository helmRepository; + + @BeforeEach + void setUp() { + server = new DefaultMockServer(); + server.start(); + httpClientFactory = HttpClientUtils.getHttpClientFactory(); + helmRepository = HelmRepository.builder() + .username("myuser") + .password("secret") + .build(); + ociRegistryInterceptor = new OCIRegistryInterceptor(httpClientFactory, helmRepository); + authUrl = String.format("http://%s:%d/token", server.getHostName(), server.getPort()); + } + + @AfterEach + void tearDown() { + server.shutdown(); + } + + @Test + void before_whenAccessTokenSetAndResponseDoesNotContainAuthorizationHeader_thenAddHeader() { + // Given + HttpRequest.Builder builder = mock(HttpRequest.Builder.class, Mockito.RETURNS_SELF); + ociRegistryInterceptor = new OCIRegistryInterceptor(httpClientFactory, helmRepository, "some-access-token"); + + // When + ociRegistryInterceptor.before(builder, null, null); + + // Then + verify(builder).setHeader("Authorization", "Bearer some-access-token"); + } + + @Test + void afterFailure_whenResponseCodeNot401_thenReturnFalse() { + // Given + HttpRequest.Builder builder = mock(HttpRequest.Builder.class, Mockito.RETURNS_SELF); + HttpResponse response = new TestHttpResponse().withCode(HTTP_NOT_FOUND); + + // When + Then + assertThat(ociRegistryInterceptor.afterFailure(builder, response, null)).isCompletedWithValue(false); + } + + @Test + void afterFailure_whenResponseHasNoWwwHeader_thenThrowException() { + // Given + HttpRequest.Builder builder = mock(HttpRequest.Builder.class, Mockito.RETURNS_SELF); + HttpResponse response = new TestHttpResponse().withCode(HTTP_UNAUTHORIZED); + + // When + assertThatIllegalStateException() + .isThrownBy(() -> ociRegistryInterceptor.afterFailure(builder, response, null)) + .withMessage("Got 401 but no WWW-Authenticate found in response headers "); + } + + @Test + void afterFailure_whenAuthCallFails_thenReturnFalse() { + server.expect().get() + .withPath("/token?service=localhost&scope=repository:myuser/test-chart:pull,push") + .andReturn(HTTP_UNAUTHORIZED, "{\"message\":\"unauthorized\"}") + .once(); + String service = "localhost"; + String wwwHeader = createWwwHeader(authUrl, service); + Map> unAuthorizedResponseHeaders = Collections.singletonMap(HttpHeaders.WWW_AUTHENTICATE, Collections.singletonList(wwwHeader)); + HttpRequest.Builder builder = mock(HttpRequest.Builder.class, Mockito.RETURNS_SELF); + HttpResponse response = new TestHttpResponse(unAuthorizedResponseHeaders).withCode(HTTP_UNAUTHORIZED); + + // When + CompletableFuture result = ociRegistryInterceptor.afterFailure(builder, response, null); + + // Then + assertThat(result).isCompletedWithValue(false); + verify(builder, times(0)).setHeader(anyString(), anyString()); + } + + @Test + void afterFailure_whenUnauthenticated_thenShouldAuthenticateWithGetAndFetchAccessToken() throws IOException { + server.expect().get() + .withPath("/token?service=localhost&scope=repository:myuser/test-chart:pull,push") + .andReturn(HTTP_OK, "{\"token\":\"mytoken\"}") + .once(); + String service = "localhost"; + String wwwHeader = createWwwHeader(authUrl, service); + Map> unAuthorizedResponseHeaders = Collections.singletonMap(HttpHeaders.WWW_AUTHENTICATE, Collections.singletonList(wwwHeader)); + HttpRequest.Builder builder = mock(HttpRequest.Builder.class, Mockito.RETURNS_SELF); + HttpResponse response = new TestHttpResponse(unAuthorizedResponseHeaders).withCode(HTTP_UNAUTHORIZED); + + // When + CompletableFuture result = ociRegistryInterceptor.afterFailure(builder, response, null); + + // Then + assertThat(result).isCompletedWithValue(true); + verify(builder).setHeader("Authorization", "Bearer mytoken"); + } + + @Test + void afterFailure_whenGetNotAllowedAndPostAlsoFails_thenReturnFalse() { + server.expect().get() + .withPath("/token?service=localhost&scope=repository:myuser/test-chart:pull,push") + .andReturn(HTTP_BAD_METHOD, "") + .once(); + server.expect().post() + .withPath("/token") + .andReturn(HTTP_OK, "{\"message\":\"unauthorized\"}") + .once(); + String service = "localhost"; + String wwwHeader = createWwwHeader(authUrl, service); + Map> unAuthorizedResponseHeaders = Collections.singletonMap(HttpHeaders.WWW_AUTHENTICATE, Collections.singletonList(wwwHeader)); + HttpRequest.Builder builder = mock(HttpRequest.Builder.class, Mockito.RETURNS_SELF); + HttpResponse response = new TestHttpResponse(unAuthorizedResponseHeaders).withCode(HTTP_UNAUTHORIZED); + + // When + CompletableFuture result = ociRegistryInterceptor.afterFailure(builder, response, null); + + // Then + assertThat(result).isCompletedWithValue(false); + verify(builder, times(0)).setHeader(anyString(), anyString()); + } + + @Test + void afterFailure_whenGetNotAllowed_thenShouldAuthenticateWithPostAndFetchAccessToken() throws InterruptedException { + server.expect().get() + .withPath("/token?service=localhost&scope=repository:myuser/test-chart:pull,push") + .andReturn(HTTP_BAD_METHOD, "") + .once(); + server.expect().post() + .withPath("/token") + .andReturn(HTTP_OK, "{\"token\":\"mytoken\"}") + .once(); + String service = "localhost"; + String wwwHeader = createWwwHeader(authUrl, service); + Map> unAuthorizedResponseHeaders = Collections.singletonMap(HttpHeaders.WWW_AUTHENTICATE, Collections.singletonList(wwwHeader)); + HttpRequest.Builder builder = mock(HttpRequest.Builder.class, Mockito.RETURNS_SELF); + HttpResponse response = new TestHttpResponse(unAuthorizedResponseHeaders).withCode(HTTP_UNAUTHORIZED); + + // When + CompletableFuture result = ociRegistryInterceptor.afterFailure(builder, response, null); + + // Then + assertThat(result).isCompletedWithValue(true); + verify(builder).setHeader("Authorization", "Bearer mytoken"); + RecordedRequest request = server.getLastRequest(); + assertThat(request.getBody().readUtf8()) + .isEqualTo("refresh_token=secret&password=secret&grant_type=password&service=localhost&scope=repository%3Amyuser%2Ftest-chart%3Apull%2Cpush&client_id=EclipseJKube&username=myuser"); + } + + private String createWwwHeader(String authUrl, String service) { + return String.format("Bearer realm=\"%s\",service=\"%s\",scope=\"repository:%s/%s:pull\"", authUrl, service, "myuser", "test-chart"); + } +} diff --git a/jkube-kit/resource/helm/src/test/resources/test-oci-manifest.json b/jkube-kit/resource/helm/src/test/resources/test-oci-manifest.json new file mode 100644 index 0000000000..ffb2ba29f8 --- /dev/null +++ b/jkube-kit/resource/helm/src/test/resources/test-oci-manifest.json @@ -0,0 +1,13 @@ +{ + "schemaVersion": 2, + "config": { + "mediaType": "application/vnd.cncf.helm.config.v1+json", + "digest": "sha256:fe8b2f27ce12b302342d4a5da2b2945ab869c7acb9e1b718c5426d91ce38cfc4", + "size": 312 + }, + "layers": [{ + "mediaType": "application/vnd.cncf.helm.chart.content.v1.tar+gzip", + "digest": "sha256:fe8b2f27ce12b302342d4a5da2b2945ab869c7acb9e1b718c5426d91ce38cfc4", + "size": 9272 + }] +} \ No newline at end of file From 1d10117d64387b1eb385f37c7dd6997c21ef6afe Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Tue, 1 Aug 2023 11:09:48 +0200 Subject: [PATCH 58/65] review:refactor: helm OCI chart upload Signed-off-by: Marc Nuri --- .../jkube/kit/resource/helm/HelmService.java | 2 +- .../resource/helm/OCIRepositoryUploader.java | 86 ---- .../kit/resource/helm/oci/OCIManifest.java | 2 +- .../resource/helm/oci/OCIManifestLayer.java | 23 +- .../resource/helm/oci/OCIRegistryClient.java | 178 ++++---- .../helm/oci/OCIRegistryEndpoint.java | 52 +-- .../helm/oci/OCIRegistryInterceptor.java | 6 +- .../helm/oci/OCIRepositoryUploader.java | 64 +++ .../resources/META-INF/jkube/helm-uploaders | 2 +- .../resource/helm/HelmServiceUploadIT.java | 22 +- .../helm/HelmUploaderManagerTest.java | 1 + .../helm/OCIRepositoryUploaderTest.java | 105 ----- .../helm/TestMockResponseProvider.java | 13 + .../helm/oci/OCIManifestLayerTest.java | 2 +- .../resource/helm/oci/OCIManifestTest.java | 2 +- .../helm/oci/OCIRegistryClientTest.java | 382 ++++++++---------- .../helm/oci/OCIRegistryEndpointTest.java | 54 ++- .../helm/oci/OCIRegistryInterceptorTest.java | 2 +- .../helm/oci/OCIRepositoryUploaderTest.java | 41 ++ 19 files changed, 481 insertions(+), 558 deletions(-) delete mode 100644 jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/OCIRepositoryUploader.java create mode 100644 jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRepositoryUploader.java delete mode 100644 jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/OCIRepositoryUploaderTest.java create mode 100644 jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRepositoryUploaderTest.java diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmService.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmService.java index 387bdce061..3a0b2fcd92 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmService.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmService.java @@ -66,7 +66,7 @@ public class HelmService { private static final String YAML_EXTENSION = ".yaml"; private static final String CHART_API_VERSION = "v1"; - private static final String CHART_FILENAME = "Chart" + YAML_EXTENSION; + public static final String CHART_FILENAME = "Chart" + YAML_EXTENSION; private static final String VALUES_FILENAME = "values" + YAML_EXTENSION; private static final String CHART_FRAGMENT_REGEX = "^chart\\.helm\\.(?yaml|yml|json)$"; diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/OCIRepositoryUploader.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/OCIRepositoryUploader.java deleted file mode 100644 index 23c87e807e..0000000000 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/OCIRepositoryUploader.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Copyright (c) 2019 Red Hat, Inc. - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at: - * - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - */ -package org.eclipse.jkube.kit.resource.helm; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import io.fabric8.kubernetes.client.http.HttpClient; -import io.fabric8.kubernetes.client.utils.HttpClientUtils; -import io.fabric8.kubernetes.client.utils.Serialization; -import org.apache.commons.codec.digest.DigestUtils; -import org.eclipse.jkube.kit.resource.helm.oci.OCIRegistryClient; -import org.eclipse.jkube.kit.resource.helm.oci.OCIRegistryInterceptor; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.Charset; -import java.nio.file.Files; - -public class OCIRepositoryUploader implements HelmUploader { - private static final ObjectMapper yamlObjectMapper = new ObjectMapper(new YAMLFactory()); - - @Override - public HelmRepository.HelmRepoType getType() { - return HelmRepository.HelmRepoType.OCI; - } - - @Override - public void uploadSingle(File file, HelmRepository repository) - throws IOException, BadUploadException { - Chart chartConfig = createChartMetadataFromGeneratedChartYamlFile(file); - HttpClient.Factory httpClientFactory = HttpClientUtils.getHttpClientFactory(); - try (HttpClient httpClient = httpClientFactory.newBuilder() - .addOrReplaceInterceptor(OCIRegistryInterceptor.NAME, new OCIRegistryInterceptor(httpClientFactory, repository)) - .build()) { - OCIRegistryClient oci = new OCIRegistryClient(repository, httpClient); - - uploadChartToOCIRegistry(oci, chartConfig, file); - } - } - - private void uploadChartToOCIRegistry(OCIRegistryClient oci, Chart chartConfig, File file) throws IOException, BadUploadException { - String chartMetadataContentPayload = Serialization.asJson(chartConfig); - String chartTarballBlobDigest = DigestUtils.sha256Hex(Files.newInputStream(file.toPath())); - String chartMetadataBlobDigest = DigestUtils.sha256Hex(chartMetadataContentPayload); - long chartMetadataPayloadSize = chartMetadataContentPayload.getBytes(Charset.defaultCharset()).length; - long chartTarballSize = file.length(); - - String chartTarballDockerContentDigest = uploadBlobIfNotExist(oci, chartConfig.getName(), chartTarballBlobDigest, chartTarballSize, null, file); - String chartConfigDockerContentDigest = uploadBlobIfNotExist(oci, chartConfig.getName(), chartMetadataBlobDigest, chartMetadataPayloadSize, chartMetadataContentPayload, null); - - oci.uploadOCIManifest(chartConfig.getName(), chartConfig.getVersion(), chartConfigDockerContentDigest, chartTarballDockerContentDigest, chartMetadataPayloadSize, chartTarballSize); - } - - private String uploadBlobIfNotExist(OCIRegistryClient oci, String chartName, String blob, long blobSize, String blobContentStr, File blobFile) throws IOException, BadUploadException { - boolean alreadyUploaded = oci.isLayerUploadedAlready(chartName, blob); - if (alreadyUploaded) { - return String.format("sha256:%s", blob); - } else { - return uploadBlob(oci, chartName, blob, blobSize, blobContentStr, blobFile); - } - } - - private String uploadBlob(OCIRegistryClient oci, String chartName, String blob, long blobSize, String blobContentStr, File blobFile) throws IOException, BadUploadException { - String uploadUrl = oci.initiateUploadProcess(chartName); - return oci.uploadBlob(uploadUrl, blob, blobSize, blobContentStr, blobFile); - } - - private Chart createChartMetadataFromGeneratedChartYamlFile(File chartFile) throws IOException { - File chartMetadataFile = new File(chartFile.getParentFile(), "Chart.yaml"); - if (chartMetadataFile.exists()) { - return yamlObjectMapper.readValue(chartMetadataFile, Chart.class); - } - throw new IllegalStateException("Could not found Chart.yaml file in " + chartMetadataFile.getPath()); - } -} \ No newline at end of file diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifest.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifest.java index 1d3023baab..2f5ab8715b 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifest.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestLayer.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestLayer.java index 9793a5bc7b..c6d4801b88 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestLayer.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestLayer.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -18,16 +18,31 @@ import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.Setter; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.io.input.CountingInputStream; + +import java.io.IOException; @Builder(toBuilder = true) @AllArgsConstructor @NoArgsConstructor @Getter -@Setter @EqualsAndHashCode public class OCIManifestLayer { + private String mediaType; private String digest; private long size; -} \ No newline at end of file + + public static OCIManifestLayer from(CountingInputStream blobStream) throws IOException { + blobStream.mark(Integer.MAX_VALUE); + final String digest = "sha256:" + DigestUtils.sha256Hex(blobStream); + final long size = blobStream.getByteCount(); + blobStream.reset(); + blobStream.resetByteCount(); + return OCIManifestLayer.builder() + .digest(digest) + .size(size) + .build(); + } +} diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryClient.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryClient.java index 072dd622ec..c6c3807267 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryClient.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryClient.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -16,26 +16,22 @@ import io.fabric8.kubernetes.client.http.HttpClient; import io.fabric8.kubernetes.client.http.HttpRequest; import io.fabric8.kubernetes.client.http.HttpResponse; -import io.fabric8.kubernetes.client.utils.Serialization; import io.fabric8.kubernetes.client.utils.URLUtils; +import org.apache.commons.io.input.CountingInputStream; import org.apache.commons.lang3.StringUtils; +import org.eclipse.jkube.kit.common.util.Serialization; import org.eclipse.jkube.kit.resource.helm.BadUploadException; +import org.eclipse.jkube.kit.resource.helm.Chart; import org.eclipse.jkube.kit.resource.helm.HelmRepository; import java.io.ByteArrayInputStream; -import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; import java.nio.charset.StandardCharsets; -import java.nio.file.Files; import java.time.Duration; import java.util.Optional; import static java.net.HttpURLConnection.HTTP_ACCEPTED; -import static java.net.HttpURLConnection.HTTP_NOT_FOUND; import static java.net.HttpURLConnection.HTTP_OK; import static org.apache.commons.lang3.StringUtils.EMPTY; import static org.eclipse.jkube.kit.common.util.AsyncUtil.get; @@ -48,33 +44,60 @@ public class OCIRegistryClient { private static final String HELM_CHART_CONTENT_MEDIA_TYPE = "application/vnd.cncf.helm.chart.content.v1.tar+gzip"; private static final String LOCATION_HEADER = "Location"; private static final long OCI_UPLOAD_HTTP_REQUEST_TIMEOUT = 30; - private final HelmRepository repository; private final OCIRegistryEndpoint ociRegistryEndpoint; private final HttpClient httpClient; public OCIRegistryClient(HelmRepository repository, HttpClient httpClient) { - this.repository = repository; - this.ociRegistryEndpoint = new OCIRegistryEndpoint(repository.getUrl()); + this.ociRegistryEndpoint = new OCIRegistryEndpoint(repository); this.httpClient = httpClient; } - public String getBaseUrl() throws MalformedURLException { - return ociRegistryEndpoint.getBaseUrl(); + public void uploadOCIManifest(Chart chart, OCIManifestLayer chartConfig, OCIManifestLayer chartTarball) throws IOException, BadUploadException { + final byte[] manifestPayload = createChartManifestPayload(chartConfig, chartTarball) + .getBytes(StandardCharsets.UTF_8); + try (InputStream requestBodyInputStream = new ByteArrayInputStream(manifestPayload)) { + HttpRequest httpRequest = newRequest() + .uri(ociRegistryEndpoint.getManifestUrl(chart)) + .method("PUT", OCI_IMAGE_MANIFEST_MEDIA_TYPE, requestBodyInputStream, manifestPayload.length) + .build(); + HttpResponse response = get(httpClient.sendAsync(httpRequest, byte[].class), Duration.ofMinutes(OCI_UPLOAD_HTTP_REQUEST_TIMEOUT)); + if (!response.isSuccessful()) { + handleFailure(response); + } + extractDockerContentDigestFromResponseHeaders(response); + } } - public String initiateUploadProcess(String chartName) throws IOException { - String uploadProcessInitiateUrl = ociRegistryEndpoint.getBlobUploadInitUrl(chartName); - HttpRequest httpRequest = createBaseOCIHttpRequest() - .post("application/json", EMPTY) - .uri(uploadProcessInitiateUrl) - .build(); + public OCIManifestLayer uploadBlobIfNotUploadedYet(Chart chart, InputStream inputStream) throws IOException, BadUploadException { + try (CountingInputStream blobStream = new CountingInputStream(inputStream)) { + final OCIManifestLayer ociBlob = OCIManifestLayer.from(blobStream); + if (isLayerUploadedAlready(chart, ociBlob)) { + return ociBlob; + } + final String uploadUrl = initiateUploadProcess(chart); + return uploadBlob(uploadUrl, blobStream); + } + } + + private boolean isLayerUploadedAlready(Chart chart, OCIManifestLayer blob) { + HttpRequest httpRequest = newRequest() + .uri(ociRegistryEndpoint.getBlobUrl(chart, blob)).build(); + HttpResponse response = get(httpClient.sendAsync(httpRequest, byte[].class), Duration.ofMinutes(OCI_UPLOAD_HTTP_REQUEST_TIMEOUT)); + return response.code() == HTTP_OK; + } + + private String initiateUploadProcess(Chart chart) { + HttpRequest httpRequest = newRequest() + .uri(ociRegistryEndpoint.getBlobUploadInitUrl(chart)) + .post("application/json", EMPTY) + .build(); HttpResponse response = get(httpClient.sendAsync(httpRequest, byte[].class), Duration.ofMinutes(OCI_UPLOAD_HTTP_REQUEST_TIMEOUT)); - int responseCode = response.code(); + final int responseCode = response.code(); if (responseCode != HTTP_ACCEPTED) { throw new IllegalStateException("Failure in initiating upload request: " + response.message()); } else { - String locationHeader = parseLocationHeaderFromResponse(response, ociRegistryEndpoint.getBaseUrl()); + String locationHeader = parseLocationHeaderFromResponse(response); if (StringUtils.isBlank(locationHeader)) { throw new IllegalStateException(String.format("No %s header found in upload initiation response", LOCATION_HEADER)); } @@ -82,107 +105,60 @@ public String initiateUploadProcess(String chartName) throws IOException { } } - public String uploadOCIManifest(String chartName, String chartVersion, String chartConfigDigest, String chartTarballDigest, long chartConfigPayloadSize, long chartTarballContentSize) throws IOException, BadUploadException { - String manifestUrl = ociRegistryEndpoint.getManifestUrl(chartName, chartVersion); - String manifestPayload = createChartManifestPayload(chartConfigDigest, chartTarballDigest, chartConfigPayloadSize, chartTarballContentSize); - InputStream requestBodyInputStream = new ByteArrayInputStream(manifestPayload.getBytes(StandardCharsets.UTF_8)); - long contentLength = manifestPayload.getBytes().length; - HttpRequest httpRequest = createBaseOCIHttpRequest() - .header("Host", new URL(repository.getUrl()).getHost()) - .uri(manifestUrl) - .method("PUT", OCI_IMAGE_MANIFEST_MEDIA_TYPE, requestBodyInputStream, contentLength) + private OCIManifestLayer uploadBlob(String uploadUrl, CountingInputStream blobStream) throws IOException, BadUploadException { + final OCIManifestLayer ociBlob = OCIManifestLayer.from(blobStream); + HttpRequest httpRequest = newRequest() + .url(new URLUtils.URLBuilder(uploadUrl).addQueryParameter("digest", ociBlob.getDigest()).build()) + .method("PUT", "application/octet-stream", blobStream, ociBlob.getSize()) .build(); - HttpResponse response = get(httpClient.sendAsync(httpRequest, byte[].class), Duration.ofMinutes(OCI_UPLOAD_HTTP_REQUEST_TIMEOUT)); if (!response.isSuccessful()) { handleFailure(response); } - return extractDockerContentDigestFromResponseHeaders(response); + final String dockerContentDigest = extractDockerContentDigestFromResponseHeaders(response); + if (!ociBlob.getDigest().equals(dockerContentDigest)) { + throw new BadUploadException(String.format("Digest mismatch. Expected %s, got %s", ociBlob.getDigest(), dockerContentDigest)); + } + return ociBlob; } - public String uploadBlob(String uploadUrl, String blobDigest, long blobSize, String blobContentStr, File blobFile) throws IOException, BadUploadException { - uploadUrl = new URLUtils.URLBuilder(uploadUrl).addQueryParameter("digest", String.format("sha256:%s", blobDigest)).toString(); - InputStream blobContentInputStream = blobFile != null ? Files.newInputStream(blobFile.toPath()) : new ByteArrayInputStream(blobContentStr.getBytes()); - HttpRequest httpRequest = createBaseOCIHttpRequest() - .uri(uploadUrl) - .method("PUT", "application/octet-stream", blobContentInputStream, blobSize) - .build(); - HttpResponse response = get(httpClient.sendAsync(httpRequest, byte[].class), Duration.ofMinutes(OCI_UPLOAD_HTTP_REQUEST_TIMEOUT)); - - if (!response.isSuccessful()) { - handleFailure(response); - } - return extractDockerContentDigestFromResponseHeaders(response); + private HttpRequest.Builder newRequest() { + return httpClient.newHttpRequestBuilder() + .header("Host", ociRegistryEndpoint.getBaseUrl().getHost() + ":" + ociRegistryEndpoint.getBaseUrl().getPort()) + .header("User-Agent", USER_AGENT); } - public boolean isLayerUploadedAlready(String chartName, String digest) throws IOException { - String blobExistenceCheckUrl = ociRegistryEndpoint.getBlobUrl(chartName, digest); - HttpRequest httpRequest = createBaseOCIHttpRequest().uri(blobExistenceCheckUrl).build(); - HttpResponse response = get(httpClient.sendAsync(httpRequest, byte[].class), Duration.ofMinutes(OCI_UPLOAD_HTTP_REQUEST_TIMEOUT)); + private String parseLocationHeaderFromResponse(HttpResponse response) { + String locationHeader = response.header(LOCATION_HEADER); - int responseCode = response.code(); - if (responseCode == HTTP_NOT_FOUND) { - return false; + // Only path is returned via GitHub Container Registry + if (locationHeader != null && locationHeader.startsWith("/")) { + locationHeader = ociRegistryEndpoint.getBaseUrl() + locationHeader; } - return responseCode == HTTP_OK; + return locationHeader; } - private void handleFailure(HttpResponse response) throws BadUploadException { - int responseCode = response.code(); + private static void handleFailure(HttpResponse response) throws BadUploadException { String responseStr = Optional.ofNullable(response.body()) - .map(String::new) - .orElse(Optional.ofNullable(response.message()).orElse("No details provided")); - if (responseCode == HttpURLConnection.HTTP_BAD_REQUEST) { - throw new BadUploadException(responseStr); - } else { - throw new IllegalStateException("Received " + responseCode + " : " + responseStr); - } + .map(String::new) + .orElse(Optional.ofNullable(response.message()).orElse("No details provided")); + throw new BadUploadException(response.code() + ": " + responseStr); } - private String extractDockerContentDigestFromResponseHeaders(HttpResponse response) { + private static String extractDockerContentDigestFromResponseHeaders(HttpResponse response) throws BadUploadException { String dockerContentDigest = response.header(DOCKER_CONTENT_DIGEST); if (StringUtils.isNotBlank(dockerContentDigest)) { return dockerContentDigest; } - throw new IllegalStateException("No " + DOCKER_CONTENT_DIGEST + " header found in upload response"); - } - - private HttpRequest.Builder createBaseOCIHttpRequest() { - HttpRequest.Builder httpRequestBuilder = httpClient.newHttpRequestBuilder(); - httpRequestBuilder.header("User-Agent", USER_AGENT); - return httpRequestBuilder; + throw new BadUploadException("No " + DOCKER_CONTENT_DIGEST + " header found in upload response"); } - private String parseLocationHeaderFromResponse(HttpResponse response, String baseUrl) { - String locationHeader = response.header(LOCATION_HEADER); - - // Only path is returned via GitHub Container Registry - if (locationHeader != null && locationHeader.startsWith("/")) { - locationHeader = baseUrl + locationHeader; - } - return locationHeader; - } - - private String createChartManifestPayload(String chartConfigDigest, String chartTarballDigest, long chartConfigPayloadSize, - long chartTarballContentSize) { - OCIManifest manifest = createChartManifest(chartConfigDigest, chartTarballDigest, chartConfigPayloadSize, chartTarballContentSize); - return Serialization.asJson(manifest); - } - - private OCIManifest createChartManifest(String digest, String layerDigest, long chartConfigPayloadSize, long chartTarballContentSize) { - return OCIManifest.builder() - .schemaVersion(2) - .config(OCIManifestLayer.builder() - .mediaType(HELM_CONFIG_MEDIA_TYPE) - .digest(digest) - .size(chartConfigPayloadSize) - .build()) - .layer(OCIManifestLayer.builder() - .mediaType(HELM_CHART_CONTENT_MEDIA_TYPE) - .digest(layerDigest) - .size(chartTarballContentSize) - .build()) - .build(); + private static String createChartManifestPayload(OCIManifestLayer chartConfig, OCIManifestLayer chartTarball) { + return Serialization.asJson(OCIManifest.builder() + .schemaVersion(2) + .config(chartConfig.toBuilder().mediaType(HELM_CONFIG_MEDIA_TYPE).build()) + .layer(chartTarball.toBuilder().mediaType(HELM_CHART_CONTENT_MEDIA_TYPE).build()) + .build()); } -} \ No newline at end of file +} diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryEndpoint.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryEndpoint.java index 791f012efb..486b752607 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryEndpoint.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryEndpoint.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -15,43 +15,45 @@ import org.apache.commons.lang3.StringUtils; +import org.eclipse.jkube.kit.resource.helm.Chart; +import org.eclipse.jkube.kit.resource.helm.HelmRepository; -import java.net.MalformedURLException; -import java.net.URL; +import java.net.URI; +import java.util.HashMap; +import java.util.Map; public class OCIRegistryEndpoint { - private final String url; - public OCIRegistryEndpoint(String baseUrl) { - this.url = StringUtils.removeEnd(baseUrl, "/"); + private static final Map PROTOCOL_MAPPER = new HashMap<>(); + static { + PROTOCOL_MAPPER.put("oci", "http"); + PROTOCOL_MAPPER.put("ocis", "https"); } - public String getBlobUrl(String chartName, String digest) throws MalformedURLException { - return String.format("%s/%s/blobs/sha256:%s", getV2ApiUrl(), chartName, digest); - } + private final URI baseUrl; + private final URI apiV2Url; - public String getBlobUploadInitUrl(String chartName) throws MalformedURLException { - return String.format("%s/%s/blobs/uploads/", getV2ApiUrl(), chartName); + public OCIRegistryEndpoint(HelmRepository repository) { + final URI repositoryUri = URI.create(StringUtils.removeEnd(repository.getUrl(), "/")); + this.baseUrl = URI.create(PROTOCOL_MAPPER.getOrDefault(repositoryUri.getScheme(), repositoryUri.getScheme()) + "://" + + repositoryUri.getHost() + + (repositoryUri.getPort() > 0 ? ":" + repositoryUri.getPort() : "")); + this.apiV2Url = URI.create(baseUrl + "/v2" + repositoryUri.getPath()); } - public String getManifestUrl(String chartName, String version) throws MalformedURLException { - return String.format("%s/%s/manifests/%s", getV2ApiUrl(), chartName, version); + public String getBlobUrl(Chart chart, OCIManifestLayer blob) { + return String.format("%s/%s/blobs/%s", apiV2Url, chart.getName(), blob.getDigest()); } - public String getV2ApiUrl() throws MalformedURLException { - URL registryUrl = new URL(url); - - return String.format("%s/v2%s", getBaseUrl(), registryUrl.getPath()); + public String getBlobUploadInitUrl(Chart chart) { + return String.format("%s/%s/blobs/uploads/", apiV2Url, chart.getName()); } - public String getBaseUrl() throws MalformedURLException { - URL registryUrl = new URL(url); - - String portString = ""; - if (registryUrl.getPort() > 0) { - portString = String.format(":%d", registryUrl.getPort()); - } + public String getManifestUrl(Chart chart) { + return String.format("%s/%s/manifests/%s", apiV2Url, chart.getName(), chart.getVersion()); + } - return String.format("%s://%s%s", registryUrl.getProtocol(), registryUrl.getHost(), portString); + public URI getBaseUrl() { + return baseUrl; } } diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryInterceptor.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryInterceptor.java index d76f1e9e78..4da153ea10 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryInterceptor.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryInterceptor.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -18,9 +18,9 @@ import io.fabric8.kubernetes.client.http.HttpRequest; import io.fabric8.kubernetes.client.http.HttpResponse; import io.fabric8.kubernetes.client.http.Interceptor; -import io.fabric8.kubernetes.client.utils.Serialization; import org.apache.commons.lang3.StringUtils; import org.eclipse.jkube.kit.common.util.Base64Util; +import org.eclipse.jkube.kit.common.util.Serialization; import org.eclipse.jkube.kit.resource.helm.HelmRepository; import java.io.IOException; @@ -65,7 +65,7 @@ public void before(BasicBuilder headerBuilder, HttpRequest request, RequestTags headerBuilder.setHeader(AUTHORIZATION, BEARER + accessToken); } } - + @Override public CompletableFuture afterFailure(BasicBuilder headerBuilder, HttpResponse response, RequestTags tags) { if (response.code() == HTTP_UNAUTHORIZED) { diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRepositoryUploader.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRepositoryUploader.java new file mode 100644 index 0000000000..8878565145 --- /dev/null +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRepositoryUploader.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.resource.helm.oci; + +import io.fabric8.kubernetes.client.http.HttpClient; +import io.fabric8.kubernetes.client.utils.HttpClientUtils; +import org.eclipse.jkube.kit.common.util.Serialization; +import org.eclipse.jkube.kit.resource.helm.BadUploadException; +import org.eclipse.jkube.kit.resource.helm.Chart; +import org.eclipse.jkube.kit.resource.helm.HelmRepository; +import org.eclipse.jkube.kit.resource.helm.HelmUploader; + +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; + +import static org.eclipse.jkube.kit.resource.helm.HelmService.CHART_FILENAME; + +public class OCIRepositoryUploader implements HelmUploader { + + @Override + public HelmRepository.HelmRepoType getType() { + return HelmRepository.HelmRepoType.OCI; + } + + @Override + public void uploadSingle(File file, HelmRepository repository) + throws IOException, BadUploadException { + HttpClient.Factory httpClientFactory = HttpClientUtils.getHttpClientFactory(); + try (HttpClient httpClient = httpClientFactory.newBuilder() + .addOrReplaceInterceptor(OCIRegistryInterceptor.NAME, new OCIRegistryInterceptor(httpClientFactory, repository)) + .build() + ) { + final Chart chart = readGeneratedChartYamlFile(file); + final byte[] chartYamlBytes = Serialization.asJson(chart).getBytes(StandardCharsets.UTF_8); + final OCIRegistryClient oci = new OCIRegistryClient(repository, httpClient); + final OCIManifestLayer chartConfig = oci.uploadBlobIfNotUploadedYet(chart, new ByteArrayInputStream(chartYamlBytes)); + final OCIManifestLayer chartTarball = oci.uploadBlobIfNotUploadedYet(chart, new BufferedInputStream(Files.newInputStream(file.toPath()))); + oci.uploadOCIManifest(chart, chartConfig, chartTarball); + } + } + + private static Chart readGeneratedChartYamlFile(File chartArchive) throws IOException { + File chartMetadataFile = new File(chartArchive.getParentFile(), CHART_FILENAME); + if (chartMetadataFile.exists()) { + return Serialization.unmarshal(chartMetadataFile, Chart.class); + } + throw new IllegalStateException("Could not find Chart.yaml file in " + chartArchive.getParentFile()); + } +} diff --git a/jkube-kit/resource/helm/src/main/resources/META-INF/jkube/helm-uploaders b/jkube-kit/resource/helm/src/main/resources/META-INF/jkube/helm-uploaders index fc2e844639..c978f612bb 100644 --- a/jkube-kit/resource/helm/src/main/resources/META-INF/jkube/helm-uploaders +++ b/jkube-kit/resource/helm/src/main/resources/META-INF/jkube/helm-uploaders @@ -1,4 +1,4 @@ org.eclipse.jkube.kit.resource.helm.ArtifactoryHelmRepositoryUploader,100 org.eclipse.jkube.kit.resource.helm.ChartMuseumHelmRepositoryUploader,100 org.eclipse.jkube.kit.resource.helm.NexusHelmRepositoryUploader,100 -org.eclipse.jkube.kit.resource.helm.OCIRepositoryUploader,100 \ No newline at end of file +org.eclipse.jkube.kit.resource.helm.oci.OCIRepositoryUploader,100 diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUploadIT.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUploadIT.java index 15ede65773..08012a395c 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUploadIT.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmServiceUploadIT.java @@ -452,12 +452,12 @@ void withSuccessfulUpload_shouldUploadBlobsAndUpdateManifest() throws Exception .andReply(new TestMockResponseProvider(202, singletonMap("Location", "/v2/test-chart/blobs/upload/second-upload-endpoint"), null)) .once(); mockServer.expect().put() - .withPath("/v2/test-chart/blobs/upload/first-upload-endpoint?digest=sha256%3Ac7051faa2fb28d147b34070a6bce25eaf1ee6bb4ca3b47af5ee6148d50079154") - .andReply(new TestMockResponseProvider(200, singletonMap("Docker-Content-Digest", "dockerdigest1"), null)) + .withPath("/v2/test-chart/blobs/upload/first-upload-endpoint?digest=sha256%3Abe0152670c8a31981ab17af598592ce91417c8be8700e708e4613739ec563031") + .andReply(new TestMockResponseProvider(200, singletonMap("Docker-Content-Digest", "sha256:be0152670c8a31981ab17af598592ce91417c8be8700e708e4613739ec563031"), null)) .once(); mockServer.expect().put() - .withPath("/v2/test-chart/blobs/upload/second-upload-endpoint?digest=sha256%3A530abfbfb3897f927efcac9610a26e97c7455d2bf5a7a5b8be02e646f10a041f") - .andReply(new TestMockResponseProvider(200, singletonMap("Docker-Content-Digest", "dockerdigest2"), null)) + .withPath("/v2/test-chart/blobs/upload/second-upload-endpoint?digest=sha256%3Ac7051faa2fb28d147b34070a6bce25eaf1ee6bb4ca3b47af5ee6148d50079154") + .andReply(new TestMockResponseProvider(200, singletonMap("Docker-Content-Digest", "sha256:c7051faa2fb28d147b34070a6bce25eaf1ee6bb4ca3b47af5ee6148d50079154"), null)) .once(); mockServer.expect().put() .withPath("/v2/test-chart/manifests/0.0.1") @@ -467,7 +467,19 @@ void withSuccessfulUpload_shouldUploadBlobsAndUpdateManifest() throws Exception helmService.uploadHelmChart(helmConfig); // Then assertThat(mockServer.getLastRequest().getBody().readUtf8()) - .isEqualTo("{\"schemaVersion\":2,\"config\":{\"mediaType\":\"application/vnd.cncf.helm.config.v1+json\",\"digest\":\"dockerdigest2\",\"size\":57},\"layers\":[{\"mediaType\":\"application/vnd.cncf.helm.chart.content.v1.tar+gzip\",\"digest\":\"dockerdigest1\",\"size\":24}]}"); + .isEqualTo("{\n" + + " \"schemaVersion\" : 2,\n" + + " \"config\" : {\n" + + " \"mediaType\" : \"application/vnd.cncf.helm.config.v1+json\",\n" + + " \"digest\" : \"sha256:be0152670c8a31981ab17af598592ce91417c8be8700e708e4613739ec563031\",\n" + + " \"size\" : 73\n" + + " },\n" + + " \"layers\" : [ {\n" + + " \"mediaType\" : \"application/vnd.cncf.helm.chart.content.v1.tar+gzip\",\n" + + " \"digest\" : \"sha256:c7051faa2fb28d147b34070a6bce25eaf1ee6bb4ca3b47af5ee6148d50079154\",\n" + + " \"size\" : 24\n" + + " } ]\n" + + "}"); } } diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManagerTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManagerTest.java index 651d127837..8040037e90 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManagerTest.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmUploaderManagerTest.java @@ -13,6 +13,7 @@ */ package org.eclipse.jkube.kit.resource.helm; +import org.eclipse.jkube.kit.resource.helm.oci.OCIRepositoryUploader; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/OCIRepositoryUploaderTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/OCIRepositoryUploaderTest.java deleted file mode 100644 index 152cb0fff9..0000000000 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/OCIRepositoryUploaderTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Copyright (c) 2019 Red Hat, Inc. - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at: - * - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - */ -package org.eclipse.jkube.kit.resource.helm; - -import org.apache.commons.io.FileUtils; -import org.eclipse.jkube.kit.resource.helm.oci.OCIRegistryClient; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; -import org.mockito.MockedConstruction; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.Charset; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.isNull; -import static org.mockito.Mockito.mockConstruction; -import static org.mockito.Mockito.when; - -class OCIRepositoryUploaderTest { - private OCIRepositoryUploader ociRepositoryUploader; - private HelmRepository helmRepository; - @TempDir - private File tempDir; - private File chartFile; - - @BeforeEach - void setUp() throws IOException { - helmRepository = HelmRepository.builder() - .url("https://r.example.com/myuser") - .username("myuser") - .build(); - ociRepositoryUploader = new OCIRepositoryUploader(); - File chartMetadataFile = new File(tempDir, "Chart.yaml"); - chartFile = new File(tempDir, "test-chart-0.0.1.tar.gz"); - assertThat(chartFile.createNewFile()).isTrue(); - assertThat(chartMetadataFile.createNewFile()).isTrue(); - FileUtils.write(chartMetadataFile, "---\napiVersion: v1\nname: test-chart\nversion: 0.0.1", Charset.defaultCharset()); - } - - @Test - void uploadSingle_whenChartBlobsAlreadyUploaded_thenLogPushSkip() throws BadUploadException, IOException { - try (MockedConstruction ociMockedConstruction = mockConstruction(OCIRegistryClient.class, (mock, ctx) -> { - when(mock.getBaseUrl()).thenReturn("https://r.example.com"); - when(mock.isLayerUploadedAlready(anyString(), anyString())).thenReturn(true); - when(mock.uploadOCIManifest(anyString(), anyString(), anyString(), anyString(), anyLong(), anyLong())).thenReturn("sha256:uploadmanifestdigest"); - })) { - // When - ociRepositoryUploader.uploadSingle(chartFile, helmRepository); - - // Then - assertThat(ociMockedConstruction.constructed()).hasSize(1); - } - } - - @Test - void uploadSingle_whenChartPushFailed_thenThrowException() { - try (MockedConstruction ignore = mockConstruction(OCIRegistryClient.class, (mock, ctx) -> { - when(mock.getBaseUrl()).thenReturn("https://r.example.com"); - when(mock.isLayerUploadedAlready(anyString(), anyString())).thenReturn(false); - when(mock.initiateUploadProcess(anyString())).thenReturn("https://r.example.com/v2/myuser/blobs/uploads/random-uuid?state=testing"); - when(mock.uploadBlob(anyString(), anyString(), anyLong(), anyString(), any())) - .thenThrow(new BadUploadException("invalid upload data")); - })) { - // When - assertThatExceptionOfType(BadUploadException.class) - .isThrownBy(() -> ociRepositoryUploader.uploadSingle(chartFile, helmRepository)) - .withMessage("invalid upload data"); - } - } - - @Test - void uploadSingle_whenChartSuccessfullyPushedToRegistry_thenLogDockerContentManifest() throws BadUploadException, IOException { - try (MockedConstruction ociMockedConstruction = mockConstruction(OCIRegistryClient.class, (mock, ctx) -> { - when(mock.getBaseUrl()).thenReturn("https://r.example.com"); - when(mock.isLayerUploadedAlready(anyString(), anyString())).thenReturn(false); - when(mock.initiateUploadProcess(anyString())).thenReturn("https://r.example.com/v2/myuser/blobs/uploads/random-uuid?state=testing"); - when(mock.uploadBlob(anyString(), anyString(), anyLong(), isNull(), any())).thenReturn("sha256:charttarballdigest"); - when(mock.uploadBlob(anyString(), anyString(), anyLong(), anyString(), isNull())).thenReturn("sha256:chartconfigdigest"); - when(mock.uploadOCIManifest(anyString(), anyString(), anyString(), anyString(), anyLong(), anyLong())).thenReturn("sha256:uploadmanifestdigest"); - })) { - // When - ociRepositoryUploader.uploadSingle(chartFile, helmRepository); - - // Then - assertThat(ociMockedConstruction.constructed()).hasSize(1); - } - } -} diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/TestMockResponseProvider.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/TestMockResponseProvider.java index ef6f0b26c0..e60a68f055 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/TestMockResponseProvider.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/TestMockResponseProvider.java @@ -1,3 +1,16 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ package org.eclipse.jkube.kit.resource.helm; import io.fabric8.mockwebserver.utils.ResponseProvider; diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestLayerTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestLayerTest.java index e5c7529bdd..1c4b9a2794 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestLayerTest.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestLayerTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestTest.java index d17c4194fb..51cde2d40e 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestTest.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIManifestTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryClientTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryClientTest.java index 2c6e020f0a..656315a5a3 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryClientTest.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryClientTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -13,45 +13,41 @@ */ package org.eclipse.jkube.kit.resource.helm.oci; +import java.io.BufferedInputStream; import java.io.File; import java.io.IOException; -import java.net.MalformedURLException; +import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.Collections; -import java.util.HashMap; -import java.util.Map; import org.eclipse.jkube.kit.resource.helm.BadUploadException; +import org.eclipse.jkube.kit.resource.helm.Chart; import org.eclipse.jkube.kit.resource.helm.HelmRepository; import org.eclipse.jkube.kit.resource.helm.TestMockResponseProvider; import io.fabric8.kubernetes.client.http.HttpClient; import io.fabric8.kubernetes.client.utils.HttpClientUtils; import io.fabric8.mockwebserver.DefaultMockServer; -import org.apache.http.HttpHeaders; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -import static java.net.HttpURLConnection.HTTP_ACCEPTED; -import static java.net.HttpURLConnection.HTTP_BAD_REQUEST; -import static java.net.HttpURLConnection.HTTP_CREATED; -import static java.net.HttpURLConnection.HTTP_NOT_FOUND; -import static java.net.HttpURLConnection.HTTP_OK; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; +import static org.assertj.core.api.Assertions.assertThatNoException; +import static org.assertj.core.api.Assertions.assertThatThrownBy; class OCIRegistryClientTest { private OCIRegistryClient oci; - private String chartName; - private String chartVersion; - private String chartTarballBlobDigest; - private String chartConfigBlobDigest; - private long chartConfigPayloadSizeInBytes; - private File chartFile; + private Chart chart; + private OCIManifestLayer chartConfigBlob; + private OCIManifestLayer chartTarballBlob; + private InputStream chartTarballStream; private HttpClient httpClient; private DefaultMockServer server; @TempDir @@ -59,18 +55,22 @@ class OCIRegistryClientTest { @BeforeEach void setUp() throws IOException { - chartName = "test-chart"; - chartVersion = "0.0.1"; - chartConfigBlobDigest = "f2ab3e153f678e5f01062717a203f4ca47a556159bcbb1e8a3ec5d84b5dd7aef"; - chartTarballBlobDigest = "98c4987b6502c7eb8e29a8844e0e1f1d19a8925594f8271ae70f9a51412e737a"; - chartConfigPayloadSizeInBytes = 10; - chartFile = new File(temporaryFolder, "test-chart-0.0.1.tar.gz"); - Files.write(chartFile.toPath(), "helm-chart-content".getBytes(StandardCharsets.UTF_8)); + chart = Chart.builder().name("test-chart").version("0.0.1").build(); + chartConfigBlob = OCIManifestLayer.builder() + .digest("sha256:f2ab3e153f678e5f01062717a203f4ca47a556159bcbb1e8a3ec5d84b5dd7aef") + .size(10L) + .build(); + chartTarballBlob = OCIManifestLayer.builder() + .digest("sha256:2ede29ddc2914a307eb3402a3db9f65d63bca95a27cd8f300e1c13538a667778") + .build(); + final File chartTarball = new File(temporaryFolder, "test-chart-0.0.1.tar.gz"); + Files.write(chartTarball.toPath(), "helm-chart-content".getBytes(StandardCharsets.UTF_8)); + chartTarballStream = new BufferedInputStream(Files.newInputStream(chartTarball.toPath())); server = new DefaultMockServer(); server.start(); httpClient = HttpClientUtils.getHttpClientFactory().newBuilder().build(); HelmRepository helmRepository = HelmRepository.builder() - .url(String.format("%s/myuser", getServerUrl())) + .url(server.url("/my-registry")) .build(); oci = new OCIRegistryClient(helmRepository, httpClient); } @@ -81,199 +81,173 @@ void tearDown() { httpClient.close(); } - private String getServerUrl() { - return String.format("http://%s:%d", server.getHostName(), server.getPort()); - } - - @Test - void getBaseUrl_whenInvoked_shouldReturnRegistryUrl() throws MalformedURLException { - assertThat(oci.getBaseUrl()).isEqualTo(getServerUrl()); - } + @Nested + @DisplayName("uploadBlobIfNotUploadedYet") + class UploadBlobIfNotUploadedYet { - @Test - void initiateUploadProcess_whenRegistryResponseSuccessfulAndContainsLocation_thenReturnUploadUrl() throws IOException { - // Given - Map uploadResponseHeaders = new HashMap<>(); - String responseLocationHeader = getServerUrl() + "/v2/myuser/test-chart/blobs/uploads/17f1053c-fcd7-47a7-a34b-bbf23bbdf906?_state=uploadstate"; - uploadResponseHeaders.put(HttpHeaders.LOCATION, responseLocationHeader); - server.expect().post() - .withPath("/v2/myuser/test-chart/blobs/uploads/") - .andReply(new TestMockResponseProvider(HTTP_ACCEPTED, uploadResponseHeaders, null)) + @Test + void withExistentLayer_skipsUpload() throws Exception { + // Given + server.expect().get() + .withPath("/v2/my-registry/test-chart/blobs/sha256:2ede29ddc2914a307eb3402a3db9f65d63bca95a27cd8f300e1c13538a667778") + .andReturn(200, null) .once(); - - // When - String uploadUrl = oci.initiateUploadProcess(chartName); - - // Then - assertThat(uploadUrl).isEqualTo(responseLocationHeader); - } - - @Test - void initiateUploadProcess_whenRegistryResponseSuccessfulButLocationHeaderContainsPathOnly_thenReturnUploadUrl() throws IOException { - // Given - Map uploadResponseHeaders = new HashMap<>(); - String responseLocationHeader = "/v2/myuser/test-chart/blobs/uploads/17f1053c-fcd7-47a7-a34b-bbf23bbdf906?_state=uploadstate"; - uploadResponseHeaders.put(HttpHeaders.LOCATION, responseLocationHeader); - server.expect().post() - .withPath("/v2/myuser/test-chart/blobs/uploads/") - .andReply(new TestMockResponseProvider(HTTP_ACCEPTED, uploadResponseHeaders, null)) + // When + final OCIManifestLayer result = oci.uploadBlobIfNotUploadedYet(chart, chartTarballStream); + // Then + assertThat(server.getRequestCount()).isEqualTo(1); + assertThat(result) + .hasFieldOrPropertyWithValue("digest", "sha256:2ede29ddc2914a307eb3402a3db9f65d63bca95a27cd8f300e1c13538a667778") + .hasFieldOrPropertyWithValue("size", 18L); + } + + @Test + void withExistentCorruptLayer_performsUpload() throws Exception { + // Given + server.expect().get() + .withPath("/v2/my-registry/test-chart/blobs/sha256:2ede29ddc2914a307eb3402a3db9f65d63bca95a27cd8f300e1c13538a667778") + .andReply(new TestMockResponseProvider(410, Collections.emptyMap(), null)) + .always(); + server.expect().post() + .withPath("/v2/my-registry/test-chart/blobs/uploads/") + .andReply(new TestMockResponseProvider(202, + Collections.singletonMap("Location", "/v2/my-registry/test-chart/blobs/uploads/location"), null)) .once(); - - // When - String uploadUrl = oci.initiateUploadProcess(chartName); - - // Then - assertThat(uploadUrl).isEqualTo(String.format("http://%s:%d%s", server.getHostName(), server.getPort(), responseLocationHeader)); - } - - @Test - void initiateUploadProcess_whenRegistryResponseSuccessfulButNoHeader_thenThrowException() { - // Given - server.expect().post() - .withPath("/v2/myuser/test-chart/blobs/uploads/") - .andReturn(HTTP_ACCEPTED, "") + server.expect().put() + .withPath("/v2/my-registry/test-chart/blobs/uploads/location?digest=sha256%3A2ede29ddc2914a307eb3402a3db9f65d63bca95a27cd8f300e1c13538a667778") + .andReply(new TestMockResponseProvider(201, + Collections.singletonMap("Docker-Content-Digest", "sha256:2ede29ddc2914a307eb3402a3db9f65d63bca95a27cd8f300e1c13538a667778"), null)) .once(); - - // When + Then - assertThatIllegalStateException() - .isThrownBy(() -> oci.initiateUploadProcess(chartName)) + // When + final OCIManifestLayer result = oci.uploadBlobIfNotUploadedYet(chart, chartTarballStream); + // Then + assertThat(server.getRequestCount()).isGreaterThan(1); + assertThat(result) + .hasFieldOrPropertyWithValue("digest", "sha256:2ede29ddc2914a307eb3402a3db9f65d63bca95a27cd8f300e1c13538a667778") + .hasFieldOrPropertyWithValue("size", 18L); + } + + @Test + void withUploadLocationMissing_throwsException() { + // Given + server.expect().post() + .withPath("/v2/my-registry/test-chart/blobs/uploads/") + .andReturn(202, "") + .once(); + // When + Then + assertThatIllegalStateException() + .isThrownBy(() -> oci.uploadBlobIfNotUploadedYet(chart, chartTarballStream)) .withMessage("No Location header found in upload initiation response"); - } - - @Test - void initiateUploadProcess_whenRegistryResponseFailure_thenThrowException() { - // Given - server.expect().post() - .withPath("/v2/myuser/test-chart/blobs/uploads/") - .andReturn(HTTP_NOT_FOUND, "") + } + + @Test + void withUploadLocationNotAccepted_throwsException() { + // Given + server.expect().post() + .withPath("/v2/my-registry/test-chart/blobs/uploads/") + .andReturn(418, "") .once(); - - // When + Then - assertThatIllegalStateException() - .isThrownBy(() -> oci.initiateUploadProcess(chartName)) - .withMessage("Failure in initiating upload request: Not Found"); - } - - @Test - void uploadOCIManifest_whenManifestSuccessfullyPushed_thenReturnDockerContentDigest() throws BadUploadException, IOException { - // Given - String responseDockerContentDigestHeader = "sha256:createdmanifestdigest"; - server.expect().put() - .withPath("/v2/myuser/test-chart/manifests/0.0.1") - .andReply(new TestMockResponseProvider(HTTP_CREATED, Collections.singletonMap("Docker-Content-Digest", responseDockerContentDigestHeader), null)) + // When + Then + assertThatIllegalStateException() + .isThrownBy(() -> oci.uploadBlobIfNotUploadedYet(chart, chartTarballStream)) + .withMessage("Failure in initiating upload request: I'm a Teapot"); + } + + @Test + void withUploadFailure_throwsException() { + // Given + server.expect().post() + .withPath("/v2/my-registry/test-chart/blobs/uploads/") + .andReply(new TestMockResponseProvider(202, + Collections.singletonMap("Location", "/v2/my-registry/test-chart/blobs/uploads/location"), null)) .once(); - - // When - String dockerContentDigest = oci.uploadOCIManifest(chartName, chartVersion, chartConfigBlobDigest, chartTarballBlobDigest, chartConfigPayloadSizeInBytes, chartFile.length()); - - // Then - assertThat(dockerContentDigest).isEqualTo(responseDockerContentDigestHeader); - } - - @Test - void uploadOCIManifest_whenRegistryRejectedManifest_thenThrowException() { - // Given - server.expect().put() - .withPath("/v2/myuser/test-chart/manifests/0.0.1") - .andReply(new TestMockResponseProvider(HTTP_BAD_REQUEST, Collections.emptyMap(), "invalid manifest")) + server.expect().put() + .withPath("/v2/my-registry/test-chart/blobs/uploads/location?digest=sha256%3A2ede29ddc2914a307eb3402a3db9f65d63bca95a27cd8f300e1c13538a667778") + .andReturn(400, "invalid data") .once(); - - // When + Then - assertThatExceptionOfType(BadUploadException.class) - .isThrownBy(() -> oci.uploadOCIManifest(chartName, chartVersion, chartConfigBlobDigest, chartTarballBlobDigest, chartConfigPayloadSizeInBytes, chartFile.length())) - .withMessage("invalid manifest"); - } - - @Test - void uploadOCIManifest_whenManifestSuccessfullyPushedButNoDockerContentDigest_thenThrowException() { - // Given - server.expect().put() - .withPath("/v2/myuser/test-chart/manifests/0.0.1") - .andReply(new TestMockResponseProvider(HTTP_CREATED, Collections.emptyMap(), null)) + // When + Then + assertThatThrownBy(() -> oci.uploadBlobIfNotUploadedYet(chart, chartTarballStream)) + .isInstanceOf(BadUploadException.class) + .hasMessage("400: invalid data"); + } + + @Test + void withDockerDigestMissing_throwsException() { + // Given + server.expect().post() + .withPath("/v2/my-registry/test-chart/blobs/uploads/") + .andReply(new TestMockResponseProvider(202, + Collections.singletonMap("Location", "/v2/my-registry/test-chart/blobs/uploads/location"), null)) .once(); - - // When - assertThatIllegalStateException() - .isThrownBy(() -> oci.uploadOCIManifest(chartName, chartVersion, chartConfigBlobDigest, chartTarballBlobDigest, chartConfigPayloadSizeInBytes, chartFile.length())) - .withMessage("No Docker-Content-Digest header found in upload response"); - } - - @Test - void uploadBlob_whenBlobSuccessfullyPushedToRegistry_thenReturnDockerContentDigest() throws BadUploadException, IOException { - // Given - String blobUploadUrl = getServerUrl() + "/v2/myuser/test-chart/blobs/uploads/17f1053c-fcd7-47a7-a34b-bbf23bbdf906?_state=XZnxHKS"; - Map responseHeaders = new HashMap<>(); - responseHeaders.put("Docker-Content-Digest", "sha256:016b77128b6bdf63ce4000e38fc36dcb15dfd6feea2d244a2c797a2d4f75a2de"); - server.expect().put() - .withPath("/v2/myuser/test-chart/blobs/uploads/17f1053c-fcd7-47a7-a34b-bbf23bbdf906?_state=XZnxHKS&digest=sha256%3A98c4987b6502c7eb8e29a8844e0e1f1d19a8925594f8271ae70f9a51412e737a") - .andReply(new TestMockResponseProvider(HTTP_CREATED, responseHeaders, null)) + server.expect().put() + .withPath("/v2/my-registry/test-chart/blobs/uploads/location?digest=sha256%3A2ede29ddc2914a307eb3402a3db9f65d63bca95a27cd8f300e1c13538a667778") + .andReturn(201, null) .once(); - - // When - String dockerContentDigest = oci.uploadBlob(blobUploadUrl, chartTarballBlobDigest, chartFile.length(), null, chartFile); - - // Then - assertThat(dockerContentDigest) - .isEqualTo("sha256:016b77128b6bdf63ce4000e38fc36dcb15dfd6feea2d244a2c797a2d4f75a2de"); - } - - @Test - void uploadBlob_whenBlobRejectedByRegistry_thenThrowException() { - // Given - String blobUploadUrl = getServerUrl() + "/v2/myuser/test-chart/blobs/uploads/17f1053c-fcd7-47a7-a34b-bbf23bbdf906?_state=XZnxHKS"; - server.expect().put() - .withPath("/v2/myuser/test-chart/blobs/uploads/17f1053c-fcd7-47a7-a34b-bbf23bbdf906?_state=XZnxHKS&digest=sha256%3A98c4987b6502c7eb8e29a8844e0e1f1d19a8925594f8271ae70f9a51412e737a") - .andReply(new TestMockResponseProvider(HTTP_BAD_REQUEST, Collections.emptyMap(), "invalid data")) + // When + Then + assertThatThrownBy(() -> oci.uploadBlobIfNotUploadedYet(chart, chartTarballStream)) + .isInstanceOf(BadUploadException.class) + .hasMessage("No Docker-Content-Digest header found in upload response"); + } + + @Test + void withDockerDigestMismatch_throwsException() { + // Given + server.expect().post() + .withPath("/v2/my-registry/test-chart/blobs/uploads/") + .andReply(new TestMockResponseProvider(202, + Collections.singletonMap("Location", "/v2/my-registry/test-chart/blobs/uploads/location"), null)) .once(); - - // When + Then - assertThatExceptionOfType(BadUploadException.class) - .isThrownBy(() -> oci.uploadBlob(blobUploadUrl, chartTarballBlobDigest, chartFile.length(), null, chartFile)) - .withMessage("invalid data"); - } - - @Test - void uploadBlob_whenBlobSuccessfullyPushedToRegistryButNoDockerContentDigest_thenThrowException() throws BadUploadException, IOException { - // Given - String blobUploadUrl = getServerUrl() + "/v2/myuser/test-chart/blobs/uploads/17f1053c-fcd7-47a7-a34b-bbf23bbdf906?_state=XZnxHKS"; - server.expect().put() - .withPath("/v2/myuser/test-chart/blobs/uploads/17f1053c-fcd7-47a7-a34b-bbf23bbdf906?_state=XZnxHKS&digest=sha256%3A98c4987b6502c7eb8e29a8844e0e1f1d19a8925594f8271ae70f9a51412e737a") - .andReply(new TestMockResponseProvider(HTTP_CREATED, Collections.emptyMap(), null)) + server.expect().put() + .withPath("/v2/my-registry/test-chart/blobs/uploads/location?digest=sha256%3A2ede29ddc2914a307eb3402a3db9f65d63bca95a27cd8f300e1c13538a667778") + .andReply(new TestMockResponseProvider(201, + Collections.singletonMap("Docker-Content-Digest", "sha256:different"), null)) .once(); - - // When + Then - assertThatIllegalStateException() - .isThrownBy(() -> oci.uploadBlob(blobUploadUrl, chartTarballBlobDigest, chartFile.length(), null, chartFile)) - .withMessage("No Docker-Content-Digest header found in upload response"); - } - - @Test - void isLayerUploadedAlready_whenRegistryReturns200_thenReturnTrue() throws IOException { - // Given - server.expect().get() - .withPath("/v2/myuser/test-chart/blobs/sha256:" + chartConfigBlobDigest) - .andReply(new TestMockResponseProvider(HTTP_OK, Collections.emptyMap(), null)) + // When + Then + assertThatThrownBy(() -> oci.uploadBlobIfNotUploadedYet(chart, chartTarballStream)) + .isInstanceOf(BadUploadException.class) + .hasMessage("Digest mismatch. Expected sha256:2ede29ddc2914a307eb3402a3db9f65d63bca95a27cd8f300e1c13538a667778, got sha256:different"); + } + } + + @Nested + @DisplayName("uploadOCIManifest") + class UploadOCIManifest { + @Test + void withSuccessfulResponse() { + // Given + String responseDockerContentDigestHeader = "sha256:createdmanifestdigest"; + server.expect().put() + .withPath("/v2/my-registry/test-chart/manifests/0.0.1") + .andReply(new TestMockResponseProvider(201, Collections.singletonMap("Docker-Content-Digest", responseDockerContentDigestHeader), null)) .once(); - - // When - boolean result = oci.isLayerUploadedAlready(chartName, chartConfigBlobDigest); - - // Then - assertThat(result).isTrue(); - } - - @Test - void isLayerUploadedAlready_whenRegistryReturns404_thenReturnFalse() throws IOException { - // Given - server.expect().get() - .withPath("/v2/myuser/test-chart/blobs/sha256:" + chartConfigBlobDigest) - .andReply(new TestMockResponseProvider(HTTP_NOT_FOUND, Collections.emptyMap(), null)) + // When + Then + assertThatNoException().isThrownBy(() -> oci.uploadOCIManifest(chart, chartConfigBlob, chartTarballBlob)); + } + + @Test + void withErrorResponse_throwsException() { + // Given + server.expect().put() + .withPath("/v2/my-registry/test-chart/manifests/0.0.1") + .andReturn(400, "invalid manifest") .once(); - - // When - boolean result = oci.isLayerUploadedAlready(chartName, chartConfigBlobDigest); - - // Then - assertThat(result).isFalse(); + // When + Then + assertThatExceptionOfType(BadUploadException.class) + .isThrownBy(() -> oci.uploadOCIManifest(chart, chartConfigBlob, chartTarballBlob)) + .withMessage("400: invalid manifest"); + } + + @Test + void withDockerDigestMissing_throwsException() { + // Given + server.expect().put() + .withPath("/v2/my-registry/test-chart/manifests/0.0.1") + .andReturn(201, null) + .once(); + // When + Then + assertThatExceptionOfType(BadUploadException.class) + .isThrownBy(() -> oci.uploadOCIManifest(chart, chartConfigBlob, chartTarballBlob)) + .withMessage("No Docker-Content-Digest header found in upload response"); + } } } diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryEndpointTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryEndpointTest.java index 4b55f1f55a..d57506727a 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryEndpointTest.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryEndpointTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -13,10 +13,12 @@ */ package org.eclipse.jkube.kit.resource.helm.oci; +import org.eclipse.jkube.kit.resource.helm.Chart; +import org.eclipse.jkube.kit.resource.helm.HelmRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import java.net.MalformedURLException; +import java.net.URI; import static org.assertj.core.api.Assertions.assertThat; @@ -25,44 +27,58 @@ class OCIRegistryEndpointTest { @BeforeEach void setUp() { - this.registryEndpoint = new OCIRegistryEndpoint("https://r.example.com/myuser"); + this.registryEndpoint = new OCIRegistryEndpoint(HelmRepository.builder().url("https://r.example.com/myuser").build()); } @Test - void getBaseUrl_whenInvoked_shouldReturnBaseUrl() throws MalformedURLException { - assertThat(registryEndpoint.getBaseUrl()).isEqualTo("https://r.example.com"); + void getBaseUrl_withOciProtocol() { + assertThat(new OCIRegistryEndpoint(HelmRepository.builder().url("oci://r.example.com/myuser").build())) + .extracting(OCIRegistryEndpoint::getBaseUrl) + .isEqualTo(URI.create("http://r.example.com")); } @Test - void getBaseUrl_whenInvokedWithRegistrySpecifyingPort_thenShouldReturnBaseUrlAsExpected() throws MalformedURLException { + void getBaseUrl_withOcisProtocol() { + assertThat(new OCIRegistryEndpoint(HelmRepository.builder().url("ocis://r.example.com/myuser").build())) + .extracting(OCIRegistryEndpoint::getBaseUrl) + .isEqualTo(URI.create("https://r.example.com")); + } + + @Test + void getBaseUrl_whenInvoked_shouldReturnBaseUrl() { + assertThat(registryEndpoint.getBaseUrl()).isEqualTo(URI.create("https://r.example.com")); + } + + @Test + void getBaseUrl_whenInvokedWithRegistrySpecifyingPort_thenShouldReturnBaseUrlAsExpected() { // Given - this.registryEndpoint = new OCIRegistryEndpoint("http://localhost:5000/myuser"); + this.registryEndpoint = new OCIRegistryEndpoint(HelmRepository.builder().url("http://localhost:5000/myuser").build()); // When - String url = registryEndpoint.getBaseUrl(); + String url = registryEndpoint.getBaseUrl().toString(); // Then assertThat(url).isEqualTo("http://localhost:5000"); } @Test - void getV2ApiUrl_whenInvoked_shouldReturnV2Url() throws MalformedURLException { - assertThat(registryEndpoint.getV2ApiUrl()).isEqualTo("https://r.example.com/v2/myuser"); - } - - @Test - void getBlobUploadInitUrl_whenInvoked_shouldReturnBlobUploadInitUrl() throws MalformedURLException { - assertThat(registryEndpoint.getBlobUploadInitUrl("test-chart")).isEqualTo("https://r.example.com/v2/myuser/test-chart/blobs/uploads/"); + void getBlobUploadInitUrl_whenInvoked_shouldReturnBlobUploadInitUrl() { + assertThat(registryEndpoint.getBlobUploadInitUrl(Chart.builder().name("test-chart").build())) + .isEqualTo("https://r.example.com/v2/myuser/test-chart/blobs/uploads/"); } @Test - void getManifestUrl_whenInvoked_shouldReturnManifestUrl() throws MalformedURLException { - assertThat(registryEndpoint.getManifestUrl("test-chart", "0.0.1")).isEqualTo("https://r.example.com/v2/myuser/test-chart/manifests/0.0.1"); + void getManifestUrl_whenInvoked_shouldReturnManifestUrl() { + assertThat(registryEndpoint.getManifestUrl(Chart.builder().name("test-chart").version("0.0.1").build())) + .isEqualTo("https://r.example.com/v2/myuser/test-chart/manifests/0.0.1"); } @Test - void getBlobUrl_whenInvoked_shouldReturnBlobUrl() throws MalformedURLException { - assertThat(registryEndpoint.getBlobUrl("test-chart", "7ed393daf1ffc94803c08ffcbecb798fa58e786bebffbab02da5458f68d0ecb0")) + void getBlobUrl_whenInvoked_shouldReturnBlobUrl() { + final String result = registryEndpoint.getBlobUrl( + Chart.builder().name("test-chart").build(), + OCIManifestLayer.builder().digest("sha256:7ed393daf1ffc94803c08ffcbecb798fa58e786bebffbab02da5458f68d0ecb0").build()); + assertThat(result) .isEqualTo("https://r.example.com/v2/myuser/test-chart/blobs/sha256:7ed393daf1ffc94803c08ffcbecb798fa58e786bebffbab02da5458f68d0ecb0"); } } diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryInterceptorTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryInterceptorTest.java index c98ae75437..4938bfcc30 100644 --- a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryInterceptorTest.java +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRegistryInterceptorTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2019 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRepositoryUploaderTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRepositoryUploaderTest.java new file mode 100644 index 0000000000..675ccb8d6c --- /dev/null +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/oci/OCIRepositoryUploaderTest.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.resource.helm.oci; + +import org.eclipse.jkube.kit.resource.helm.HelmRepository; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; + +class OCIRepositoryUploaderTest { + + @Test + void withMissingChart_throwsException(@TempDir Path tempDir) throws IOException { + // Given + final File chartFile = Files.createDirectory(tempDir.resolve("helm")) + .resolve("missing-chart-0.0.1.tar.gz").toFile(); + final HelmRepository repository = HelmRepository.builder().build(); + // When + Then + assertThatIllegalStateException() + .isThrownBy(() -> new OCIRepositoryUploader().uploadSingle(chartFile, repository)) + .withMessageStartingWith("Could not find Chart.yaml file in ") + .withMessageEndingWith("helm"); + } +} From c4e00b11c6c7008ced6f56e1ff84c3005e70865b Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Thu, 3 Aug 2023 15:19:44 +0200 Subject: [PATCH 59/65] test: bump Gradle IT Spring Boot dependency Signed-off-by: Marc Nuri --- gradle-plugin/it/src/it/configmap/build.gradle | 6 +++--- .../it/src/it/probes-groovy-dsl-config/build.gradle | 6 +++--- gradle-plugin/it/src/it/simple/build.gradle | 2 -- .../it/src/it/spring-boot-with-fragment/build.gradle | 4 ++-- gradle-plugin/it/src/it/spring-boot/build.gradle | 4 ++-- .../org/eclipse/jkube/gradle/plugin/tests/ConfigMapIT.java | 2 +- .../org/eclipse/jkube/gradle/plugin/tests/SimpleIT.java | 2 +- 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/gradle-plugin/it/src/it/configmap/build.gradle b/gradle-plugin/it/src/it/configmap/build.gradle index a7d6327547..b45491f1e9 100644 --- a/gradle-plugin/it/src/it/configmap/build.gradle +++ b/gradle-plugin/it/src/it/configmap/build.gradle @@ -14,8 +14,8 @@ plugins { id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}" id 'org.eclipse.jkube.openshift' version "${jKubeVersion}" - id 'org.springframework.boot' version '2.5.2' - id 'io.spring.dependency-management' version '1.0.11.RELEASE' + id 'org.springframework.boot' version '2.7.14' + id 'io.spring.dependency-management' version '1.0.15.RELEASE' id 'java' } @@ -59,4 +59,4 @@ openshift { }] } } -} \ No newline at end of file +} diff --git a/gradle-plugin/it/src/it/probes-groovy-dsl-config/build.gradle b/gradle-plugin/it/src/it/probes-groovy-dsl-config/build.gradle index 501c6d2c81..053a4afd5e 100644 --- a/gradle-plugin/it/src/it/probes-groovy-dsl-config/build.gradle +++ b/gradle-plugin/it/src/it/probes-groovy-dsl-config/build.gradle @@ -12,8 +12,8 @@ * Red Hat, Inc. - initial API and implementation */ plugins { - id 'org.springframework.boot' version '2.6.6' - id 'io.spring.dependency-management' version '1.0.11.RELEASE' + id 'org.springframework.boot' version '2.7.14' + id 'io.spring.dependency-management' version '1.0.15.RELEASE' id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}" id 'org.eclipse.jkube.openshift' version "${jKubeVersion}" id 'java' @@ -98,4 +98,4 @@ openshift { } } } -} \ No newline at end of file +} diff --git a/gradle-plugin/it/src/it/simple/build.gradle b/gradle-plugin/it/src/it/simple/build.gradle index b5ecfb6909..504481fba3 100644 --- a/gradle-plugin/it/src/it/simple/build.gradle +++ b/gradle-plugin/it/src/it/simple/build.gradle @@ -14,8 +14,6 @@ plugins { id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}" id 'org.eclipse.jkube.openshift' version "${jKubeVersion}" - id 'org.springframework.boot' version '2.5.2' - id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' } diff --git a/gradle-plugin/it/src/it/spring-boot-with-fragment/build.gradle b/gradle-plugin/it/src/it/spring-boot-with-fragment/build.gradle index e02633b81a..297a0b621a 100644 --- a/gradle-plugin/it/src/it/spring-boot-with-fragment/build.gradle +++ b/gradle-plugin/it/src/it/spring-boot-with-fragment/build.gradle @@ -14,8 +14,8 @@ plugins { id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}" id 'org.eclipse.jkube.openshift' version "${jKubeVersion}" - id 'org.springframework.boot' version '2.5.2' - id 'io.spring.dependency-management' version '1.0.11.RELEASE' + id 'org.springframework.boot' version '2.7.14' + id 'io.spring.dependency-management' version '1.0.15.RELEASE' id 'java' } diff --git a/gradle-plugin/it/src/it/spring-boot/build.gradle b/gradle-plugin/it/src/it/spring-boot/build.gradle index 2e3b4ac523..e17b0ac661 100644 --- a/gradle-plugin/it/src/it/spring-boot/build.gradle +++ b/gradle-plugin/it/src/it/spring-boot/build.gradle @@ -14,8 +14,8 @@ plugins { id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}" id 'org.eclipse.jkube.openshift' version "${jKubeVersion}" - id 'org.springframework.boot' version '2.5.2' - id 'io.spring.dependency-management' version '1.0.11.RELEASE' + id 'org.springframework.boot' version '2.7.14' + id 'io.spring.dependency-management' version '1.0.15.RELEASE' id 'java' } diff --git a/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/ConfigMapIT.java b/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/ConfigMapIT.java index 949d7833af..6012ad8619 100644 --- a/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/ConfigMapIT.java +++ b/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/ConfigMapIT.java @@ -25,7 +25,7 @@ class ConfigMapIT { @RegisterExtension - private final ITGradleRunnerExtension gradleRunner = new ITGradleRunnerExtension(); + final ITGradleRunnerExtension gradleRunner = new ITGradleRunnerExtension(); @Test void k8sResource_whenRun_generatesK8sManifestsContainingConfigMap() throws IOException, ParseException { diff --git a/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/SimpleIT.java b/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/SimpleIT.java index 9b08daa9ba..353d2e1d4a 100644 --- a/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/SimpleIT.java +++ b/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/SimpleIT.java @@ -22,7 +22,7 @@ class SimpleIT { @RegisterExtension - private final ITGradleRunnerExtension gradleRunner = new ITGradleRunnerExtension(); + final ITGradleRunnerExtension gradleRunner = new ITGradleRunnerExtension(); @Test void tasks_containsKubernetesAndOpenShiftTasks() { From edd44d90d52a013f33d22cd38f682b59facef53b Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Thu, 3 Aug 2023 16:11:52 +0200 Subject: [PATCH 60/65] fix: gradle tasks work on Gradle v8.2.1 Signed-off-by: Marc Nuri --- CHANGELOG.md | 1 + .../jkube/gradle/plugin/tests/HelidonIT.java | 2 +- .../jkube/gradle/plugin/tests/SmallRyeIT.java | 2 +- .../jkube/gradle/plugin/GradleUtil.java | 15 +++- .../jkube/gradle/plugin/GradleUtilTest.java | 70 ++++++++++++++++++- 5 files changed, 83 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c7ebf7323..f1c8ea3811 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ Usage: * Fix #2224: Quarkus native base image read from properties (configurable) * Fix #2228: Quarkus native base image uses UBI 8.7 * Fix #2290: JKube is not picking docker credentials from `~/.docker/config.json` file +* Fix #2299: Gradle v8.x compatibility * Fix #2302 Bump Kubernetes Client version to 6.8.0 ### 1.13.1 (2023-06-16) diff --git a/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/HelidonIT.java b/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/HelidonIT.java index 35ec043867..bde5fe8a7a 100644 --- a/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/HelidonIT.java +++ b/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/HelidonIT.java @@ -25,7 +25,7 @@ class HelidonIT { @RegisterExtension - private final ITGradleRunnerExtension gradleRunner = new ITGradleRunnerExtension(); + final ITGradleRunnerExtension gradleRunner = new ITGradleRunnerExtension(); @Test void k8sResource_whenRun_generatesK8sManifestsWithProbes() throws IOException, ParseException { diff --git a/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/SmallRyeIT.java b/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/SmallRyeIT.java index 7c9c340ecf..c89fd47755 100644 --- a/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/SmallRyeIT.java +++ b/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/SmallRyeIT.java @@ -25,7 +25,7 @@ class SmallRyeIT { @RegisterExtension - private final ITGradleRunnerExtension gradleRunner = new ITGradleRunnerExtension(); + final ITGradleRunnerExtension gradleRunner = new ITGradleRunnerExtension(); @Test void k8sResource_whenRun_generatesK8sManifestsWithProbes() throws IOException, ParseException { diff --git a/gradle-plugin/kubernetes/src/main/java/org/eclipse/jkube/gradle/plugin/GradleUtil.java b/gradle-plugin/kubernetes/src/main/java/org/eclipse/jkube/gradle/plugin/GradleUtil.java index 98008e65e0..4825680af8 100644 --- a/gradle-plugin/kubernetes/src/main/java/org/eclipse/jkube/gradle/plugin/GradleUtil.java +++ b/gradle-plugin/kubernetes/src/main/java/org/eclipse/jkube/gradle/plugin/GradleUtil.java @@ -48,6 +48,7 @@ import org.gradle.api.artifacts.result.ResolvedDependencyResult; import org.gradle.api.attributes.Attribute; import org.gradle.api.file.FileCollection; +import org.gradle.api.internal.GeneratedSubclasses; import org.gradle.api.plugins.JavaPluginConvention; import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSetContainer; @@ -76,8 +77,7 @@ public static JavaProject convertGradleProject(Project gradleProject) { .dependenciesWithTransitive(extractDependenciesWithTransitive(gradleProject)) // .localRepositoryBaseDirectory(gradleProject.) .plugins(extractPlugins(gradleProject)) - .gradlePlugins(new ArrayList<>(gradleProject.getPlugins()).stream() - .map(Object::getClass).map(Class::getName).collect(Collectors.toList())) + .gradlePlugins(extractGradlePlugins(gradleProject)) // // .site(gradleProject.) // .organizationName(gradleProject.) @@ -151,6 +151,14 @@ private static List extractPlugins(Project gradleProject) { .collect(Collectors.toList()); } + private static List extractGradlePlugins(Project gradleProject) { + final List ret = new ArrayList<>(); + for (org.gradle.api.Plugin plugin : gradleProject.getPlugins()) { + ret.add(GeneratedSubclasses.unpackType(plugin).getName()); + } + return ret; + } + private static SourceSetContainer extractSourceSets(Project gradleProject) { return gradleProject.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets(); } @@ -197,7 +205,8 @@ private static File findArtifact(Project gradleProject) { static boolean canBeResolved(Configuration configuration) { boolean isDeprecatedForResolving = configuration instanceof DeprecatableConfiguration - && ((DeprecatableConfiguration) configuration).getResolutionAlternatives() != null; + && ((DeprecatableConfiguration) configuration).getResolutionAlternatives() != null + && !((DeprecatableConfiguration) configuration).getResolutionAlternatives().isEmpty(); return configuration.isCanBeResolved() && !isDeprecatedForResolving; } diff --git a/gradle-plugin/kubernetes/src/test/java/org/eclipse/jkube/gradle/plugin/GradleUtilTest.java b/gradle-plugin/kubernetes/src/test/java/org/eclipse/jkube/gradle/plugin/GradleUtilTest.java index 4e640f4322..6e1cde0395 100644 --- a/gradle-plugin/kubernetes/src/test/java/org/eclipse/jkube/gradle/plugin/GradleUtilTest.java +++ b/gradle-plugin/kubernetes/src/test/java/org/eclipse/jkube/gradle/plugin/GradleUtilTest.java @@ -18,9 +18,11 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Objects; @@ -32,6 +34,7 @@ import org.eclipse.jkube.kit.common.JavaProject; +import org.gradle.api.Plugin; import org.gradle.api.Project; import org.gradle.api.UnknownDomainObjectException; import org.gradle.api.artifacts.Configuration; @@ -40,9 +43,12 @@ import org.gradle.api.artifacts.component.ComponentIdentifier; import org.gradle.api.artifacts.result.ResolvedArtifactResult; import org.gradle.api.artifacts.result.ResolvedDependencyResult; +import org.gradle.api.internal.GeneratedSubclass; import org.gradle.api.internal.plugins.DefaultPluginContainer; import org.gradle.api.internal.provider.DefaultProvider; +import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPluginConvention; +import org.gradle.api.plugins.PluginContainer; import org.gradle.internal.deprecation.DeprecatableConfiguration; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -189,6 +195,25 @@ void extractPlugins_withMultipleAndBuildScriptDuplicateDependencies_shouldReturn ); } + @Test + void extractGradlePlugins_withMultipleAndSomePacked() { + // Given + final Iterator> pluginIterator = Arrays.asList( + new KubernetesPlugin(), + new GeneratedPlugin() + ).iterator(); + final PluginContainer pc = mock(PluginContainer.class); + when(project.getPlugins()).thenReturn(pc); + when(pc.iterator()).thenAnswer(i -> pluginIterator); + // When + final JavaProject result = convertGradleProject(project); + // Then + assertThat(result.getGradlePlugins()).containsExactlyInAnyOrder( + "org.eclipse.jkube.gradle.plugin.KubernetesPlugin", + "org.gradle.api.plugins.JavaPlugin" + ); + } + /** * Some plugins might modify the ConfigurationContainer collection while we traverse it. * @@ -297,11 +322,23 @@ void findArtifact_withMultipleArchiveFiles_shouldReturnJavaArchiveOnly() throws assertThat(result.getArtifact()).isNotNull().hasName("final-artifact.jar"); } + @Test + void canBeResolved_withCanBeResolvedFalse_shouldReturnFalse() { + // Given + final DeprecatableConfiguration c = mock(DeprecatableConfiguration.class); + when(c.isCanBeResolved()).thenReturn(false); + // When + final boolean result = canBeResolved(c); + // Then + assertThat(result).isFalse(); + } + @Test void canBeResolved_withDeprecatedAndResolutionAlternatives_shouldReturnFalse() { // Given final DeprecatableConfiguration c = mock(DeprecatableConfiguration.class); - when(c.getResolutionAlternatives()).thenReturn(Collections.emptyList()); + when(c.isCanBeResolved()).thenReturn(true); + when(c.getResolutionAlternatives()).thenReturn(Collections.singletonList("Alternative")); // When final boolean result = canBeResolved(c); // Then @@ -309,7 +346,7 @@ void canBeResolved_withDeprecatedAndResolutionAlternatives_shouldReturnFalse() { } @Test - void canBeResolved_DeprecatedAndNullResolutionAlternativesAndResolvable_shouldReturnTrue() { + void canBeResolved_withDeprecatedAndNullResolutionAlternativesAndResolvable_shouldReturnTrue() { // Given final DeprecatableConfiguration c = mock(DeprecatableConfiguration.class); when(c.isCanBeResolved()).thenReturn(true); @@ -320,6 +357,18 @@ void canBeResolved_DeprecatedAndNullResolutionAlternativesAndResolvable_shouldRe assertThat(result).isTrue(); } + @Test + void canBeResolved_withDeprecatedAndEmptyResolutionAlternatives_shouldReturnFalse() { + // Given + final DeprecatableConfiguration c = mock(DeprecatableConfiguration.class); + when(c.isCanBeResolved()).thenReturn(true); + when(c.getResolutionAlternatives()).thenReturn(Collections.emptyList()); + // When + final boolean result = canBeResolved(c); + // Then + assertThat(result).isTrue(); + } + private static Function configurationDependencyMock() { return s -> { final Configuration c = mock(Configuration.class, RETURNS_DEEP_STUBS); @@ -375,4 +424,21 @@ public int hashCode() { return Objects.hash(id); } } + private static final class GeneratedPlugin implements Plugin, GeneratedSubclass { + + @Override + public void apply(Project target) { + // NO-OP + } + + @Override + public Class publicType() { + return JavaPlugin.class; + } + + @Override + public boolean hasUsefulDisplayName() { + return false; + } + } } From c51b51a4076fc9a1c3a411eba721cd37c27362a7 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Fri, 4 Aug 2023 08:17:00 +0200 Subject: [PATCH 61/65] test: gradle integration tests run on Gradle 8.2.1 Signed-off-by: Marc Nuri --- .../jkube/gradle/plugin/tests/ITGradleRunnerExtension.java | 2 +- .../jkube/gradle/plugin/tests/KubernetesExtensionIT.java | 4 ++-- .../jkube/gradle/plugin/task/KubernetesConfigViewTask.java | 4 ++-- .../gradle/plugin/task/KubernetesConfigViewTaskTest.java | 4 ++-- .../java/org/eclipse/jkube/kit/common/util/Serialization.java | 4 ++++ 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/ITGradleRunnerExtension.java b/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/ITGradleRunnerExtension.java index 1c6449fa0b..d4916c8b7d 100644 --- a/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/ITGradleRunnerExtension.java +++ b/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/ITGradleRunnerExtension.java @@ -31,7 +31,7 @@ public class ITGradleRunnerExtension implements BeforeEachCallback, AfterEachCal @Override public void beforeEach(ExtensionContext context) throws Exception { gradleRunner = GradleRunner.create() - .withGradleDistribution(new URI("https://services.gradle.org/distributions/gradle-7.6.1-bin.zip")) + .withGradleDistribution(new URI("https://services.gradle.org/distributions/gradle-8.2.1-bin.zip")) .withDebug(true) .withPluginClasspath(Arrays.stream(System.getProperty("java.class.path").split(File.pathSeparator)) .map(File::new).collect(Collectors.toList())); diff --git a/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/KubernetesExtensionIT.java b/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/KubernetesExtensionIT.java index 855812bb3a..b0afbfcda5 100644 --- a/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/KubernetesExtensionIT.java +++ b/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/KubernetesExtensionIT.java @@ -26,7 +26,7 @@ class KubernetesExtensionIT { @RegisterExtension - private final ITGradleRunnerExtension gradleRunner = new ITGradleRunnerExtension(); + final ITGradleRunnerExtension gradleRunner = new ITGradleRunnerExtension(); @Test void k8sConfigView_containsAFullyDeserializedConfiguration() throws IOException, ParseException { @@ -37,7 +37,7 @@ void k8sConfigView_containsAFullyDeserializedConfiguration() throws IOException, // Then final String output = result.getOutput(); ResourceVerify.verifyResourceDescriptors( - output.substring(output.indexOf("---"), output.indexOf("BUILD SUCCESSFUL in")), + output.substring(output.indexOf("---"), output.lastIndexOf("---")), FileUtils.readFileToString(gradleRunner.resolveFile("expected", "expected-config.yml"), StandardCharsets.UTF_8), false); } diff --git a/gradle-plugin/kubernetes/src/main/java/org/eclipse/jkube/gradle/plugin/task/KubernetesConfigViewTask.java b/gradle-plugin/kubernetes/src/main/java/org/eclipse/jkube/gradle/plugin/task/KubernetesConfigViewTask.java index 047e9d0b48..13887af6dc 100644 --- a/gradle-plugin/kubernetes/src/main/java/org/eclipse/jkube/gradle/plugin/task/KubernetesConfigViewTask.java +++ b/gradle-plugin/kubernetes/src/main/java/org/eclipse/jkube/gradle/plugin/task/KubernetesConfigViewTask.java @@ -55,7 +55,7 @@ public void run() { for (Method method : KubernetesExtension.class.getMethods()) { if (method.getParameters().length == 0 && Property.class.isAssignableFrom(method.getReturnType())) { effectiveConfig.put(CaseUtils.toCamelCase(method.getName().replaceFirst("^get", ""), false), - ((Property) method.invoke(kubernetesExtension)).getOrElse(null)); + ((Property) method.invoke(kubernetesExtension)).getOrElse(null)); } } for (Field field : KubernetesExtension.class.getDeclaredFields()) { @@ -63,7 +63,7 @@ public void run() { effectiveConfig.put(field.getName(), field.get(kubernetesExtension)); } } - kitLogger.info("%n%s", MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(effectiveConfig)); + kitLogger.info("%n%s%n---", MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(effectiveConfig)); } catch (InvocationTargetException | IllegalAccessException | JsonProcessingException ex) { kitLogger.error("Error when reading configuration: %s", ex.getMessage()); } diff --git a/gradle-plugin/kubernetes/src/test/java/org/eclipse/jkube/gradle/plugin/task/KubernetesConfigViewTaskTest.java b/gradle-plugin/kubernetes/src/test/java/org/eclipse/jkube/gradle/plugin/task/KubernetesConfigViewTaskTest.java index dcc53398ae..08a33473c4 100644 --- a/gradle-plugin/kubernetes/src/test/java/org/eclipse/jkube/gradle/plugin/task/KubernetesConfigViewTaskTest.java +++ b/gradle-plugin/kubernetes/src/test/java/org/eclipse/jkube/gradle/plugin/task/KubernetesConfigViewTaskTest.java @@ -30,7 +30,7 @@ class KubernetesConfigViewTaskTest { @RegisterExtension - private final TaskEnvironmentExtension taskEnvironment = new TaskEnvironmentExtension(); + final TaskEnvironmentExtension taskEnvironment = new TaskEnvironmentExtension(); private TestKubernetesExtension extension; @@ -52,4 +52,4 @@ void runTask_withManualSettings_shouldLogThem() { verify(taskEnvironment.logger, times(1)) .lifecycle(matches("k8s: \n---\noffline: true\nbuildStrategy: \"s2i\"")); } -} \ No newline at end of file +} diff --git a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/Serialization.java b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/Serialization.java index f31eff6dbb..af4aab61a5 100644 --- a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/Serialization.java +++ b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/Serialization.java @@ -109,6 +109,10 @@ public static String asJson(Object object) { return KUBERNETES_SERIALIZATION.asJson(object); } + public static String asYaml(Object object) { + return KUBERNETES_SERIALIZATION.asYaml(object); + } + public static void saveJson(File resultFile, Object value) throws IOException { JSON_MAPPER.writeValue(resultFile, value); } From 49d6284ffe08650a86a1133385e00e9611069873 Mon Sep 17 00:00:00 2001 From: prafful-rastogi Date: Tue, 25 Jul 2023 16:25:28 +0530 Subject: [PATCH 62/65] doc : FAQ now displayed in Gradle Plugin documentation (#2296) Signed-off-by: prafful-rastogi --- .../doc/src/main/asciidoc/index.adoc | 2 +- .../doc/src/main/asciidoc/inc/_faq.adoc | 58 ++++++++++++------- .../doc/src/main/asciidoc/index.adoc | 2 +- 3 files changed, 40 insertions(+), 22 deletions(-) rename {kubernetes-maven-plugin => jkube-kit}/doc/src/main/asciidoc/inc/_faq.adoc (79%) diff --git a/gradle-plugin/doc/src/main/asciidoc/index.adoc b/gradle-plugin/doc/src/main/asciidoc/index.adoc index 9b7ac1db8c..092008cec2 100644 --- a/gradle-plugin/doc/src/main/asciidoc/index.adoc +++ b/gradle-plugin/doc/src/main/asciidoc/index.adoc @@ -43,4 +43,4 @@ include::inc/_authentication.adoc[] include::{kitdoc-path}/inc/mapping-config/_index.adoc[] - +include::{kitdoc-path}/inc/_faq.adoc[] \ No newline at end of file diff --git a/kubernetes-maven-plugin/doc/src/main/asciidoc/inc/_faq.adoc b/jkube-kit/doc/src/main/asciidoc/inc/_faq.adoc similarity index 79% rename from kubernetes-maven-plugin/doc/src/main/asciidoc/inc/_faq.adoc rename to jkube-kit/doc/src/main/asciidoc/inc/_faq.adoc index b9b0f3cb0c..780fe57074 100644 --- a/kubernetes-maven-plugin/doc/src/main/asciidoc/inc/_faq.adoc +++ b/jkube-kit/doc/src/main/asciidoc/inc/_faq.adoc @@ -126,34 +126,28 @@ Where the above defines the `PersistentVolumeClaim` called `foo` which is then m `Ingress` you need to enable `jkube.createExternalUrls` property to `true` and `jkube.domain` property to desired host suffix, it would be appended to your service name for host value. -You can also provide a host for it in XML config like this: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +You can also provide a host for it in properties like this: +[source,properties,indent=0,subs="verbatim,quotes,attributes"] ---- - - - - - true - example.com - - +jkube.createExternalUrls=true +jkube.domain=example.com ---- -You can find an example in our link:https://github.com/eclipse/jkube/tree/master/quickstarts/maven/spring-boot[spring-boot] +ifeval::["{plugin-type}" == "maven"] +You can find an example in our link: https://github.com/eclipse/jkube/tree/master/quickstarts/maven/spring-boot[spring-boot] quickstart in `kubernetes-with-ingress` profile. +endif::[] === How do I build the image with Podman instead of Docker? - +ifeval::["{plugin-type}" == "maven"] When invoking <> with only Podman installed, the following error appears: +endif::[] +ifeval::["{plugin-type}" == "gradle"] +When invoking <> with only Podman installed, the following error appears: +endif::[] ---- -[INFO] ------------------------------------------------------------------------ -[INFO] BUILD FAILURE -[INFO] ------------------------------------------------------------------------ -[INFO] Total time: 2.045 s -[INFO] Finished at: 2021-10-07T11:02:15+02:00 -[INFO] ------------------------------------------------------------------------ -[ERROR] Failed to execute goal org.eclipse.jkube:kubernetes-maven-plugin:1.4.0:build (default-cli) on project live-stream-question: Execution default-cli of goal org.eclipse.jkube:kubernetes-maven-plugin:1.4.0:build failed: No given, no DOCKER_HOST environment variable, no read/writable '/var/run/docker.sock' or '//./pipe/docker_engine' and no external provider like Docker machine configured -> [Help 1] +No given, no DOCKER_HOST environment variable, no read/writable '/var/run/docker.sock' or '//./pipe/docker_engine' and no external provider like Docker machine configured -> [Help 1] ---- By default, JKube is relying on the Docker REST API `/var/run/docker.sock` to build Docker images. Using Podman even with the Docker CLI emulation won't work as it is just a CLI wrapper and does not provide any Docker REST API. @@ -168,7 +162,9 @@ podman system service --time=0 unix:/run/user/$(id -u)/podman/podman.sock & If you want to configure image name generated by Eclipse JKube which is `%g/%a:%l` by default(see <>). It will depend upon what mode you're using in Eclipse JKube: - If you're using <>, which means you depend on Eclipse JKube <> to generate an opinionated image, you will be able to do it using `jkube.generator.name` maven property. -- If you're providing <>, image name would be picked from `` tag like in this example: +- If you're providing <>, image name would be picked from `name` tag like in this example: + +ifeval::["{plugin-type}" == "maven"] [source,xml,indent=0,subs="verbatim,quotes,attributes"] ---- @@ -179,4 +175,26 @@ If you want to configure image name generated by Eclipse JKube which is `%g/%a:% ---- +endif::[] + +ifeval::["{plugin-type}" == "gradle"] +[source,groovy,indent=0,subs="verbatim,quotes,attributes"] +---- +{pluginExtension} { + images { + image { + name = "myusername/myimagename:latest" + build { + from = "openjdk:latest" + cmd { + exec = ["java", "-jar", "${project.name}-${project.version}.jar"] + } + } + } + } +} +---- +endif::[] + + - If you're using <>, you can configure image name via `jkube.image.name` or `jkube.generator.name` flags diff --git a/kubernetes-maven-plugin/doc/src/main/asciidoc/index.adoc b/kubernetes-maven-plugin/doc/src/main/asciidoc/index.adoc index c31ac1238e..5fc7af9768 100644 --- a/kubernetes-maven-plugin/doc/src/main/asciidoc/index.adoc +++ b/kubernetes-maven-plugin/doc/src/main/asciidoc/index.adoc @@ -43,6 +43,6 @@ include::inc/_authentication.adoc[] include::inc/_volumes.adoc[] include::inc/_integrations.adoc[] -include::inc/_faq.adoc[] +include::{kitdoc-path}/inc/_faq.adoc[] include::{kitdoc-path}/inc/mapping-config/_index.adoc[] From 3a97cf8c9100b5171cbe898fbc4b9ef02f429ea4 Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Wed, 26 Jul 2023 20:27:08 +0530 Subject: [PATCH 63/65] doc (jkube-kit/doc) : Update FAQ to have maven and gradle sections for Ingress generation + Fix broken link for JKube images in environment variables/system property FAQs + Add separate section for maven and gradle configuration for showcasing Ingress generation Signed-off-by: Rohan Kumar --- jkube-kit/doc/src/main/asciidoc/inc/_faq.adoc | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/jkube-kit/doc/src/main/asciidoc/inc/_faq.adoc b/jkube-kit/doc/src/main/asciidoc/inc/_faq.adoc index 780fe57074..5a6ff40c9a 100644 --- a/jkube-kit/doc/src/main/asciidoc/inc/_faq.adoc +++ b/jkube-kit/doc/src/main/asciidoc/inc/_faq.adoc @@ -20,13 +20,13 @@ spec: The above will generate an environment variable `$FOO` of value `bar` -For a full list of the environments used in java base images, https://hub.docker.com/r/jkube.java-jboss-openjdk8-jdk[see this list] +For a full list of the environments used in java base images, https://github.com/jkubeio/jkube-images#available-imagesk[see this list] === How do I define a system property? The simplest way is to add system properties to the `JAVA_OPTIONS` environment variable. -For a full list of the environments used in java base images, https://hub.docker.com/r/jkube.java-jboss-openjdk8-jdk[see this list] +For a full list of the environments used in java base images, https://github.com/jkubeio/jkube-images#available-images[see this list] e.g. add a `src/main/jkube/deployment.yml` file to your project containing something like: @@ -126,12 +126,29 @@ Where the above defines the `PersistentVolumeClaim` called `foo` which is then m `Ingress` you need to enable `jkube.createExternalUrls` property to `true` and `jkube.domain` property to desired host suffix, it would be appended to your service name for host value. -You can also provide a host for it in properties like this: +ifeval::["{plugin-type}" == "maven"] +You can also provide a host for it in XML config like this: +[source,xml,indent=0,subs="verbatim,quotes,attributes"] +---- + + + + + true + example.com + + +---- +endif::[] + +ifeval::["{plugin-type}" == "gradle"] +You can also provide a host for it in `gradle.properties` file like this: [source,properties,indent=0,subs="verbatim,quotes,attributes"] ---- jkube.createExternalUrls=true jkube.domain=example.com ---- +endif::[] ifeval::["{plugin-type}" == "maven"] You can find an example in our link: https://github.com/eclipse/jkube/tree/master/quickstarts/maven/spring-boot[spring-boot] From ba86499db136707fe56debb87ce285f6078a8384 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Mon, 7 Aug 2023 07:25:56 +0200 Subject: [PATCH 64/65] fix: project website url is now based on eclipse.dev/jkube Moved from eclipse.org/jkube https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/issues/3069 Signed-off-by: Marc Nuri --- .github/ISSUE_TEMPLATE/bug_report.yml | 4 ++-- .github/ISSUE_TEMPLATE/enhancement.yml | 6 +++--- .github/ISSUE_TEMPLATE/task.yml | 6 +++--- .github/pull_request_template.md | 2 +- CONTRIBUTING.md | 4 ++-- MIGRATION-GUIDE.md | 4 ++-- README.md | 16 ++++++++-------- .../service/docker/auth/AuthConfigFactory.java | 2 +- .../jkube/kit/common/util/MavenUtilTest.java | 4 ++-- .../kit/common/util/KubernetesHelper.java | 2 +- .../generator/webapp/WebAppGenerator.java | 4 ++-- kubernetes-maven-plugin/README.md | 17 ++++++++++------- openshift-maven-plugin/README.md | 18 +++++++++++------- .../ibm-javaee8-webprofile-liberty/README.md | 2 +- scripts/changelog.sh | 2 +- 15 files changed, 50 insertions(+), 43 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 8b5dcbb3aa..9fd9b85bd0 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -27,8 +27,8 @@ body: Useful Links: - - 📄 Documentation: https://www.eclipse.org/jkube/docs/ - - 📝 Contributing: https://www.eclipse.org/jkube/contributing + - 📄 Documentation: https://www.eclipse.dev/jkube/docs/ + - 📝 Contributing: https://www.eclipse.dev/jkube/contributing/ - type: textarea diff --git a/.github/ISSUE_TEMPLATE/enhancement.yml b/.github/ISSUE_TEMPLATE/enhancement.yml index bed101ee60..f184919d7a 100644 --- a/.github/ISSUE_TEMPLATE/enhancement.yml +++ b/.github/ISSUE_TEMPLATE/enhancement.yml @@ -27,12 +27,12 @@ body: Useful Links: - - 📄 Documentation: https://www.eclipse.org/jkube/docs/ - - 📝 Contributing: https://www.eclipse.org/jkube/contributing + - 📄 Documentation: https://www.eclipse.dev/jkube/docs/ + - 📝 Contributing: https://www.eclipse.dev/jkube/contributing/ - type: dropdown - id: component + id: component attributes: label: Component description: Component diff --git a/.github/ISSUE_TEMPLATE/task.yml b/.github/ISSUE_TEMPLATE/task.yml index 1a068f1e07..f1bb632852 100644 --- a/.github/ISSUE_TEMPLATE/task.yml +++ b/.github/ISSUE_TEMPLATE/task.yml @@ -27,11 +27,11 @@ body: Useful Links: - - 📄 Documentation: https://www.eclipse.org/jkube/docs/ - - 📝 Contributing: https://www.eclipse.org/jkube/contributing + - 📄 Documentation: https://www.eclipse.dev/jkube/docs/ + - 📝 Contributing: https://www.eclipse.dev/jkube/contributing/ - type: dropdown - id: component + id: component attributes: label: Component description: Component diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index d4efcd82c1..76b23d759f 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -18,7 +18,7 @@ What types of changes does your code introduce? Put an `x` in all the boxes that test, version modification, documentation, etc.) ## Checklist - - [ ] I have read the [contributing guidelines](https://www.eclipse.org/jkube/contributing) + - [ ] I have read the [contributing guidelines](https://www.eclipse.dev/jkube/contributing) - [ ] I signed-off my commit with a user that has signed the [Eclipse Contributor Agreement](https://www.eclipse.org/legal/ECA.php) - [ ] My code follows the style guidelines of this project - [ ] I Keep It Small and Simple: The smaller the PR is, the easier it is to review and have it merged diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7649e0dc4e..d50c863e93 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,8 +1,8 @@ ## How to Contribute For information related to contributing to Eclipse JKube, please check out the -[Contributing](https://www.eclipse.org/jkube/contributing) -section at the [Eclipse JKube](https://www.eclipse.org/jkube/) site. +[Contributing](https://www.eclipse.dev/jkube/contributing) +section at the [Eclipse JKube](https://www.eclipse.dev/jkube/) site. ## Legal diff --git a/MIGRATION-GUIDE.md b/MIGRATION-GUIDE.md index bc9505ee81..558aac34fa 100644 --- a/MIGRATION-GUIDE.md +++ b/MIGRATION-GUIDE.md @@ -1,5 +1,5 @@ # Migration Guide for projects using Fabric8 Maven Plugin to Eclipse JKube For information related to migrating from Fabric8 Maven Plugin to Eclipse JKube, please check out the -[Migration Guide](https://www.eclipse.org/jkube/docs/migration-guide/) -section of the documentation at the [Eclipse JKube](https://www.eclipse.org/jkube/) site. \ No newline at end of file +[Migration Guide](https://www.eclipse.dev/jkube/docs/migration-guide/) +section of the documentation at the [Eclipse JKube](https://www.eclipse.dev/jkube/) site. diff --git a/README.md b/README.md index 8fd087d765..9d04057dee 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ [![Twitter](https://img.shields.io/twitter/follow/jkubeio?style=social)](https://twitter.com/jkubeio)

    - + Eclipse JKube

    @@ -22,17 +22,17 @@ - [Kubernetes Gradle Plugin](#kubernetes-gradle-plugin) - [OpenShift Maven Plugin](#openshift-maven-plugin) - [OpenShift Gradle Plugin](#openshift-gradle-plugin) -- [Migrating from Fabric8 Maven Plugin to Kubernetes/OpenShift Maven Plugin](https://www.eclipse.org/jkube/docs/migration-guide) +- [Migrating from Fabric8 Maven Plugin to Kubernetes/OpenShift Maven Plugin](https://www.eclipse.dev/jkube/docs/migration-guide) - [Getting Started](#getting-started) - [Maven Quickstarts](./quickstarts/maven) - [Gradle Quickstarts](./quickstarts/gradle) - [Hello World using Eclipse JKube](#hello-world-using-eclipse-jkube) - [Troubleshooting](#troubleshooting) - [Rebranding Notice](#rebranding-notice--loudspeaker-) -- [Contributing](https://www.eclipse.org/jkube/contributing/) +- [Contributing](https://www.eclipse.dev/jkube/contributing/) - [How to use Eclipse JKube snapshot artifacts?](./USING-SNAPSHOT-ARTIFACTS.md) - [Add your organization to ADOPTERS](./ADOPTERS.md) -- [FAQs](https://www.eclipse.org/jkube/docs/kubernetes-maven-plugin/#faq) +- [FAQs](https://www.eclipse.dev/jkube/docs/kubernetes-maven-plugin/#faq) ## Introduction @@ -48,7 +48,7 @@ This project contains various building blocks for the Kubernetes Java developer ### Kubernetes Maven Plugin - [![Maven Central](https://img.shields.io/maven-central/v/org.eclipse.jkube/kubernetes-maven-plugin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.eclipse.jkube%22%20AND%20a:%22kubernetes-maven-plugin%22) -- [![Documentation](https://img.shields.io/badge/plugin-documentation-lightgrey)](https://www.eclipse.org/jkube/docs/kubernetes-maven-plugin) +- [![Documentation](https://img.shields.io/badge/plugin-documentation-lightgrey)](https://www.eclipse.dev/jkube/docs/kubernetes-maven-plugin) - Add to project: ```xml @@ -68,7 +68,7 @@ This project contains various building blocks for the Kubernetes Java developer ### Kubernetes Gradle Plugin - [![Maven Central](https://img.shields.io/maven-central/v/org.eclipse.jkube.kubernetes/org.eclipse.jkube.kubernetes.gradle.plugin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.eclipse.jkube.kubernetes%22%20AND%20a:%22org.eclipse.jkube.kubernetes.gradle.plugin%22) -- [![Documentation](https://img.shields.io/badge/plugin-documentation-lightgrey)](https://www.eclipse.org/jkube/docs/kubernetes-gradle-plugin/) +- [![Documentation](https://img.shields.io/badge/plugin-documentation-lightgrey)](https://www.eclipse.dev/jkube/docs/kubernetes-gradle-plugin/) - Add to project: ```groovy plugins { @@ -86,7 +86,7 @@ This project contains various building blocks for the Kubernetes Java developer ### OpenShift Gradle Plugin - [![Maven Central](https://img.shields.io/maven-central/v/org.eclipse.jkube.openshift/org.eclipse.jkube.openshift.gradle.plugin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.eclipse.jkube.openshift%22%20AND%20a:%22org.eclipse.jkube.openshift.gradle.plugin%22) -- [![Documentation](https://img.shields.io/badge/plugin-documentation-lightgrey)](https://www.eclipse.org/jkube/docs/openshift-gradle-plugin/) +- [![Documentation](https://img.shields.io/badge/plugin-documentation-lightgrey)](https://www.eclipse.dev/jkube/docs/openshift-gradle-plugin/) - Add to project: ```groovy plugins { @@ -104,7 +104,7 @@ This project contains various building blocks for the Kubernetes Java developer ### OpenShift Maven Plugin - [![Maven Central](https://img.shields.io/maven-central/v/org.eclipse.jkube/openshift-maven-plugin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.eclipse.jkube%22%20AND%20a:%22openshift-maven-plugin%22) -- [![Documentation](https://img.shields.io/badge/plugin-documentation-lightgrey)](https://www.eclipse.org/jkube/docs/openshift-maven-plugin) +- [![Documentation](https://img.shields.io/badge/plugin-documentation-lightgrey)](https://www.eclipse.dev/jkube/docs/openshift-maven-plugin) - Add to project: ```xml diff --git a/jkube-kit/build/service/docker/src/main/java/org/eclipse/jkube/kit/build/service/docker/auth/AuthConfigFactory.java b/jkube-kit/build/service/docker/src/main/java/org/eclipse/jkube/kit/build/service/docker/auth/AuthConfigFactory.java index b09bbf8b22..71dae12309 100644 --- a/jkube-kit/build/service/docker/src/main/java/org/eclipse/jkube/kit/build/service/docker/auth/AuthConfigFactory.java +++ b/jkube-kit/build/service/docker/src/main/java/org/eclipse/jkube/kit/build/service/docker/auth/AuthConfigFactory.java @@ -539,7 +539,7 @@ private static AuthConfig getAuthConfigViaAwsSdk(AwsSdkHelper awsSdkHelper, KitL if (!credProviderPresent) { log.info("It appears that you're using AWS ECR." + " Consider integrating the AWS SDK in order to make use of common AWS authentication mechanisms," + - " see https://www.eclipse.org/jkube/docs/kubernetes-maven-plugin#extended-authentication"); + " see https://www.eclipse.dev/jkube/docs/kubernetes-maven-plugin#extended-authentication"); return null; } return new AwsSdkAuthConfigFactory(log, awsSdkHelper).createAuthConfig(); diff --git a/jkube-kit/common-maven/src/test/java/org/eclipse/jkube/kit/common/util/MavenUtilTest.java b/jkube-kit/common-maven/src/test/java/org/eclipse/jkube/kit/common/util/MavenUtilTest.java index dd02ff4ed3..cf160bb14f 100644 --- a/jkube-kit/common-maven/src/test/java/org/eclipse/jkube/kit/common/util/MavenUtilTest.java +++ b/jkube-kit/common-maven/src/test/java/org/eclipse/jkube/kit/common/util/MavenUtilTest.java @@ -87,7 +87,7 @@ void testJKubeProjectConversion() throws DependencyResolutionRequiredException { assertThat(project.getDescription()).isEqualTo("test description"); assertThat(project.getOutputDirectory()).hasName("target"); assertThat(project.getBuildDirectory()).hasName("."); - assertThat(project.getDocumentationUrl()).isEqualTo("https://www.eclipse.org/jkube/"); + assertThat(project.getDocumentationUrl()).isEqualTo("https://www.eclipse.dev/jkube/"); assertThat(mavenProject.getCompileClasspathElements()).hasSize(1); assertThat(mavenProject.getCompileClasspathElements()).first().isEqualTo("./target"); assertThat(project.getProperties()).contains(entry("foo", "bar")); @@ -178,7 +178,7 @@ private MavenProject getMavenProject() { mavenProject.setBuild(build); DistributionManagement distributionManagement = new DistributionManagement(); Site site = new Site(); - site.setUrl("https://www.eclipse.org/jkube/"); + site.setUrl("https://www.eclipse.dev/jkube/"); distributionManagement.setSite(site); mavenProject.setDistributionManagement(distributionManagement); mavenProject.setUrl("https://projects.eclipse.org/projects/ecd.jkube"); diff --git a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/KubernetesHelper.java b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/KubernetesHelper.java index d59d91f7a9..165289782e 100644 --- a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/KubernetesHelper.java +++ b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/KubernetesHelper.java @@ -359,7 +359,7 @@ public static void handleKubernetesClientException(KubernetesClientException e, if (cause instanceof UnknownHostException) { logger.error( "Could not connect to kubernetes cluster!"); logger.error("Have you started a local cluster or connected to a remote cluster via `kubectl`?"); - logger.info("For more help see: https://www.eclipse.org/jkube/docs/#getting-started"); + logger.info("For more help see: https://www.eclipse.dev/jkube/docs/#getting-started"); logger.error( "Connection error: %s", cause); String message = "Could not connect to kubernetes cluster. Have you started a local cluster or connected to a remote cluster via `kubectl`? Error: " + cause; diff --git a/jkube-kit/generator/webapp/src/main/java/org/eclipse/jkube/generator/webapp/WebAppGenerator.java b/jkube-kit/generator/webapp/src/main/java/org/eclipse/jkube/generator/webapp/WebAppGenerator.java index 10d41cda5a..1e0388641e 100644 --- a/jkube-kit/generator/webapp/src/main/java/org/eclipse/jkube/generator/webapp/WebAppGenerator.java +++ b/jkube-kit/generator/webapp/src/main/java/org/eclipse/jkube/generator/webapp/WebAppGenerator.java @@ -102,7 +102,7 @@ public List customize(List configs, bool ) { throw new IllegalArgumentException("S2I not yet supported for the webapp-generator. Use " + "-Djkube.build.strategy=docker for OpenShift mode. Please refer to the reference manual at " + - "https://www.eclipse.org/jkube/docs for details about build modes."); + "https://www.eclipse.dev/jkube/docs for details about build modes."); } @@ -186,7 +186,7 @@ public static Map extractEnvVariables(String envConfigValue) { private AssemblyConfiguration createAssembly(AppServerHandler handler) { final File sourceFile = Objects.requireNonNull(JKubeProjectUtil.getFinalOutputArtifact(getProject()), - "Final output artifact file was not detected. The project may have not been built. HINT: try to compile and package your application prior to running the container image build task."); + "Final output artifact file was not detected. The project may have not been built. HINT: try to compile and package your application prior to running the container image build task."); final String targetFilename; final String extension = FilenameUtils.getExtension(sourceFile.getName()); final String path = getConfig(Config.PATH); diff --git a/kubernetes-maven-plugin/README.md b/kubernetes-maven-plugin/README.md index 490c18e27e..49600e1aef 100644 --- a/kubernetes-maven-plugin/README.md +++ b/kubernetes-maven-plugin/README.md @@ -21,13 +21,16 @@ To enable kubernetes maven plugin on your project just add this to the plugins s ``` -| Goal | Description | -| --------------------------------------------- | ------------------------------------- | -| [`k8s:resource`](https://www.eclipse.org/jkube/docs/kubernetes-maven-plugin#k8s:resource) | Create Kubernetes resource descriptors | -| [`k8s:build`](https://www.eclipse.org/jkube/docs/kubernetes-maven-plugin#k8s:build) | Build Docker images | -| [`k8s:push`](https://www.eclipse.org/jkube/docs/kubernetes-maven-plugin#k8s:push) | Push Docker images to a registry | -| [`k8s:deploy`](https://www.eclipse.org/jkube/docs/kubernetes-maven-plugin#k8s:deploy) | Deploy Kubernetes resource objects to a cluster | -| [`k8s:watch`](https://www.eclipse.org/jkube/docs/kubernetes-maven-plugin#k8s:watch) | Watch for doing rebuilds and restarts | +| Goal | Description | +|-------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------| +| [`k8s:resource`](https://www.eclipse.dev/jkube/docs/kubernetes-maven-plugin#jkube:resource) | Create Kubernetes resource descriptors | +| [`k8s:build`](https://www.eclipse.dev/jkube/docs/kubernetes-maven-plugin#jkube:build) | Build Docker images | +| [`k8s:push`](https://www.eclipse.dev/jkube/docs/kubernetes-maven-plugin#jkube:push) | Push Docker images to a registry | +| [`k8s:deploy`](https://www.eclipse.dev/jkube/docs/kubernetes-maven-plugin#jkube:deploy) | Deploy Kubernetes resource objects to a cluster | +| [`k8s:helm`](https://www.eclipse.dev/jkube/docs/kubernetes-maven-plugin#jkube:helm) | Generate Helm charts for your application | +| [`k8s:helm-push`](https://www.eclipse.dev/jkube/docs/kubernetes-maven-plugin#jkube:helm-push) | Push generated Helm Charts to remote repository | +| [`k8s:remote-dev`](https://www.eclipse.dev/jkube/docs/kubernetes-maven-plugin#jkube:remote-dev) | Run and debug code in your local machine while connected to services available in your cluster | +| [`k8s:watch`](https://www.eclipse.dev/jkube/docs/kubernetes-maven-plugin#jkube:watch) | Watch for doing rebuilds and restarts | ### Features diff --git a/openshift-maven-plugin/README.md b/openshift-maven-plugin/README.md index 20f66ff1ea..811aabedb9 100644 --- a/openshift-maven-plugin/README.md +++ b/openshift-maven-plugin/README.md @@ -21,13 +21,17 @@ To enable OpenShift maven plugin on your project just add this to the plugins se ``` -| Goal | Description | -| --------------------------------------------- | ------------------------------------- | -| [`oc:resource`](https://www.eclipse.org/jkube/docs/openshift-maven-plugin#oc:resource) | Create OpenShift resource descriptors | -| [`oc:build`](https://www.eclipse.org/jkube/docs/openshift-maven-plugin#oc:build) | Build Docker images | -| [`oc:push`](https://www.eclipse.org/jkube/docs/openshift-maven-plugin#oc:push) | Push Docker images to a registry | -| [`oc:deploy`](https://www.eclipse.org/jkube/docs/openshift-maven-plugin#oc:deploy) | Deploy OpenShift resource objects to a cluster | -| [`oc:watch`](https://www.eclipse.org/jkube/docs/openshift-maven-plugin#oc:watch) | Watch for doing rebuilds and restarts | +| Goal | Description | +|-----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------| +| [`oc:resource`](https://www.eclipse.dev/jkube/docs/openshift-maven-plugin#jkube:resource) | Create Kubernetes resource descriptors | +| [`oc:build`](https://www.eclipse.dev/jkube/docs/openshift-maven-plugin#jkube:build) | Build Docker images | +| [`oc:push`](https://www.eclipse.dev/jkube/docs/openshift-maven-plugin#jkube:push) | Push Docker images to a registry | +| [`oc:deploy`](https://www.eclipse.dev/jkube/docs/openshift-maven-plugin#jkube:deploy) | Deploy Kubernetes resource objects to a cluster | +| [`oc:helm`](https://www.eclipse.dev/jkube/docs/openshift-maven-plugin#jkube:helm) | Generate Helm charts for your application | +| [`oc:helm-push`](https://www.eclipse.dev/jkube/docs/openshift-maven-plugin#jkube:helm-push) | Push generated Helm Charts to remote repository | +| [`oc:remote-dev`](https://www.eclipse.dev/jkube/docs/openshift-maven-plugin#jkube:remote-dev) | Run and debug code in your local machine while connected to services available in your cluster | +| [`oc:watch`](https://www.eclipse.dev/jkube/docs/openshift-maven-plugin#jkube:watch) | Watch for doing rebuilds and restarts | + ### Features diff --git a/quickstarts/maven/ibm-javaee8-webprofile-liberty/README.md b/quickstarts/maven/ibm-javaee8-webprofile-liberty/README.md index 878ee57730..13c494071a 100644 --- a/quickstarts/maven/ibm-javaee8-webprofile-liberty/README.md +++ b/quickstarts/maven/ibm-javaee8-webprofile-liberty/README.md @@ -198,5 +198,5 @@ Server was started ``` [openliberty]: http://openliberty.io/ -[k-m-p]: https://www.eclipse.org/jkube +[k-m-p]: https://www.eclipse.dev/jkube [minikube]: https://github.com/kubernetes/minikube diff --git a/scripts/changelog.sh b/scripts/changelog.sh index 0a2f492af6..3cb6494076 100755 --- a/scripts/changelog.sh +++ b/scripts/changelog.sh @@ -116,7 +116,7 @@ function emailTemplate() { lines+="$numberedChangelog\n\n" lines+="Your feedback is highly appreciated, you can provide it by replying to the mailing list or through the usual channels. $githubLinkId $gitterLinkId\n\n" lines+="[1] https://repo1.maven.org/maven2/org/eclipse/jkube/kubernetes-maven-plugin/$1/\n" - lines+="[2] https://www.eclipse.org/jkube/docs/migration-guide/\n" + lines+="[2] https://www.eclipse.dev/jkube/docs/migration-guide/\n" lines+="$changelogLinks\n" lines+="$githubLinkId https://github.com/eclipse/jkube\n" lines+="$gitterLinkId https://gitter.im/eclipse/jkube\n" From 7b51ea78844076987975601214fccfac78625f22 Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Mon, 31 Jul 2023 13:38:55 +0530 Subject: [PATCH 65/65] fix (jkube-kit/build/service/jib) : JibServiceUtil should push additional tags in single request (#2293) We are doing separate push requests for each additional tag provided in build configuration. Use only single push request and rely on in built jib's Containerizer.withAdditionalTag method Signed-off-by: Rohan Kumar --- CHANGELOG.md | 1 + .../jkube/kit/service/jib/JibServiceUtil.java | 29 ++-- .../kit/service/jib/JibServiceUtilTest.java | 139 ++++++++++++++++++ 3 files changed, 157 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1c8ea3811..e4fc4a2a5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ Usage: * Fix #2224: Quarkus native base image read from properties (configurable) * Fix #2228: Quarkus native base image uses UBI 8.7 * Fix #2290: JKube is not picking docker credentials from `~/.docker/config.json` file +* Fix #2293: JibServiceUtil pushes separate images for additional tags specified in build configuration * Fix #2299: Gradle v8.x compatibility * Fix #2302 Bump Kubernetes Client version to 6.8.0 diff --git a/jkube-kit/build/service/jib/src/main/java/org/eclipse/jkube/kit/service/jib/JibServiceUtil.java b/jkube-kit/build/service/jib/src/main/java/org/eclipse/jkube/kit/service/jib/JibServiceUtil.java index 5b182b81de..22ed48df79 100644 --- a/jkube-kit/build/service/jib/src/main/java/org/eclipse/jkube/kit/service/jib/JibServiceUtil.java +++ b/jkube-kit/build/service/jib/src/main/java/org/eclipse/jkube/kit/service/jib/JibServiceUtil.java @@ -141,14 +141,11 @@ public static String getFullImageName(ImageConfiguration imageConfiguration, Str * @param log Logger */ public static void jibPush(ImageConfiguration imageConfiguration, Credential pushCredentials, File tarArchive, KitLogger log) { - BuildConfiguration buildImageConfiguration = imageConfiguration.getBuildConfiguration(); String imageName = getFullImageName(imageConfiguration, null); + List additionalTags = imageConfiguration.getBuildConfiguration().getTags(); try { - for (String tag : getAllImageTags(buildImageConfiguration.getTags(), imageName)) { - String imageNameWithTag = getFullImageName(imageConfiguration, tag); - log.info("Pushing image: %s", imageNameWithTag); - pushImage(TarImage.at(tarArchive.toPath()), imageNameWithTag, pushCredentials, log); - } + log.info("Pushing image: %s", imageName); + pushImage(TarImage.at(tarArchive.toPath()), additionalTags, imageName, pushCredentials, log); } catch (IllegalStateException e) { log.error("Exception occurred while pushing the image: %s", imageConfiguration.getName()); throw new IllegalStateException(e.getMessage(), e); @@ -158,12 +155,12 @@ public static void jibPush(ImageConfiguration imageConfiguration, Credential pus } } - private static void pushImage(TarImage baseImage, String targetImageName, Credential credential, KitLogger logger) + private static void pushImage(TarImage baseImage, List additionalTags, String targetImageName, Credential credential, KitLogger logger) throws InterruptedException { final ExecutorService jibBuildExecutor = Executors.newCachedThreadPool(); try { - submitPushToJib(baseImage, getRegistryImage(targetImageName, credential), jibBuildExecutor, logger); + submitPushToJib(baseImage, getRegistryImage(targetImageName, credential), additionalTags, jibBuildExecutor, logger); } catch (RegistryException | CacheDirectoryCreationException | InvalidImageReferenceException | IOException | ExecutionException e) { logger.error("Exception occurred while pushing the image: %s, %s", targetImageName, e.getMessage()); throw new IllegalStateException(e.getMessage(), e); @@ -220,13 +217,21 @@ static Set getAllImageTags(List tags, String imageName) { return tagSet; } - private static void submitPushToJib(TarImage baseImage, RegistryImage targetImage, ExecutorService jibBuildExecutor, KitLogger logger) throws InterruptedException, ExecutionException, RegistryException, CacheDirectoryCreationException, IOException { - Jib.from(baseImage).setCreationTime(Instant.now()).containerize(Containerizer.to(targetImage) + private static void submitPushToJib(TarImage baseImage, RegistryImage targetImage, List additionalTags, ExecutorService jibBuildExecutor, KitLogger logger) throws InterruptedException, ExecutionException, RegistryException, CacheDirectoryCreationException, IOException { + Jib.from(baseImage).setCreationTime(Instant.now()).containerize(createJibContainerizer(targetImage, additionalTags, jibBuildExecutor, logger)); + logUpdateFinished(); + } + + private static Containerizer createJibContainerizer(RegistryImage targetImage, List additionalTags, ExecutorService jibBuildExecutor, KitLogger logger) { + Containerizer containerizer = Containerizer.to(targetImage) .setAllowInsecureRegistries(true) .setExecutorService(jibBuildExecutor) .addEventHandler(LogEvent.class, log(logger)) - .addEventHandler(ProgressEvent.class, new ProgressEventHandler(logUpdate()))); - logUpdateFinished(); + .addEventHandler(ProgressEvent.class, new ProgressEventHandler(logUpdate())); + if (additionalTags != null) { + additionalTags.forEach(containerizer::withAdditionalTag); + } + return containerizer; } private static RegistryImage getRegistryImage(String targetImage, Credential credential) throws InvalidImageReferenceException { diff --git a/jkube-kit/build/service/jib/src/test/java/org/eclipse/jkube/kit/service/jib/JibServiceUtilTest.java b/jkube-kit/build/service/jib/src/test/java/org/eclipse/jkube/kit/service/jib/JibServiceUtilTest.java index d850e447eb..eb0990f440 100644 --- a/jkube-kit/build/service/jib/src/test/java/org/eclipse/jkube/kit/service/jib/JibServiceUtilTest.java +++ b/jkube-kit/build/service/jib/src/test/java/org/eclipse/jkube/kit/service/jib/JibServiceUtilTest.java @@ -22,7 +22,16 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import com.google.cloud.tools.jib.api.CacheDirectoryCreationException; +import com.google.cloud.tools.jib.api.Containerizer; +import com.google.cloud.tools.jib.api.Credential; +import com.google.cloud.tools.jib.api.Jib; +import com.google.cloud.tools.jib.api.RegistryException; +import com.google.cloud.tools.jib.api.RegistryImage; +import com.google.cloud.tools.jib.api.TarImage; import org.eclipse.jkube.kit.build.api.assembly.BuildDirs; import org.eclipse.jkube.kit.common.Assembly; import org.eclipse.jkube.kit.common.AssemblyConfiguration; @@ -30,6 +39,7 @@ import org.eclipse.jkube.kit.common.AssemblyFileEntry; import org.eclipse.jkube.kit.common.JKubeConfiguration; import org.eclipse.jkube.kit.common.JavaProject; +import org.eclipse.jkube.kit.common.KitLogger; import org.eclipse.jkube.kit.config.image.ImageConfiguration; import org.eclipse.jkube.kit.common.Arguments; import org.eclipse.jkube.kit.config.image.build.BuildConfiguration; @@ -39,18 +49,32 @@ import com.google.cloud.tools.jib.api.buildplan.FileEntriesLayer; import com.google.cloud.tools.jib.api.buildplan.ImageFormat; import com.google.cloud.tools.jib.api.buildplan.Port; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; import org.mockito.MockedConstruction; +import org.mockito.MockedStatic; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.eclipse.jkube.kit.service.jib.JibServiceUtil.containerFromImageConfiguration; import static org.mockito.Answers.RETURNS_SELF; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mockConstructionWithAnswer; +import static org.mockito.Mockito.mockStatic; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; class JibServiceUtilTest { + private KitLogger kitLogger; + + @BeforeEach + void setUp() { + kitLogger = new KitLogger.SilentLogger(); + } @Test void testGetBaseImageWithNullBuildConfig() { @@ -172,6 +196,121 @@ void layers_withMultipleLayers_shouldReturnTransformedLayers(@TempDir File tempo .containsExactly("layer-1", "", "jkube-generated-layer-final-artifact"); } + @Test + void buildContainer_whenBuildSuccessful_thenDelegateToJibContainerize() throws InterruptedException, CacheDirectoryCreationException, IOException, ExecutionException, RegistryException { + try (MockedStatic containerizerMockedStatic = mockStatic(Containerizer.class)) { + // Given + JibContainerBuilder jibContainerBuilder = mock(JibContainerBuilder.class, RETURNS_SELF); + Containerizer containerizer = mock(Containerizer.class, RETURNS_SELF); + TarImage tarImage = TarImage.at(new File("docker-build.tar").toPath()); + containerizerMockedStatic.when(() -> Containerizer.to(tarImage)).thenReturn(containerizer); + + // When + JibServiceUtil.buildContainer(jibContainerBuilder, tarImage, kitLogger); + + // Then + verify(containerizer).setAllowInsecureRegistries(true); + verify(containerizer).setExecutorService(any(ExecutorService.class)); + verify(containerizer, times(2)).addEventHandler(any(), any()); + verify(jibContainerBuilder).containerize(containerizer); + } + } + + @Test + void buildContainer_whenBuildFailure_thenThrowException() throws InterruptedException, CacheDirectoryCreationException, IOException, ExecutionException, RegistryException { + try (MockedStatic containerizerMockedStatic = mockStatic(Containerizer.class)) { + // Given + JibContainerBuilder jibContainerBuilder = mock(JibContainerBuilder.class, RETURNS_SELF); + Containerizer containerizer = mock(Containerizer.class, RETURNS_SELF); + TarImage tarImage = TarImage.at(new File("docker-build.tar").toPath()); + containerizerMockedStatic.when(() -> Containerizer.to(tarImage)).thenReturn(containerizer); + when(jibContainerBuilder.containerize(containerizer)).thenThrow(new RegistryException("Unable to pull base image")); + + // When + assertThatIllegalStateException() + .isThrownBy(() -> JibServiceUtil.buildContainer(jibContainerBuilder, tarImage, kitLogger)) + .withMessageContaining("Unable to pull base image"); + + // Then + verify(containerizer).setAllowInsecureRegistries(true); + verify(containerizer).setExecutorService(any(ExecutorService.class)); + verify(containerizer, times(2)).addEventHandler(any(), any()); + verify(jibContainerBuilder).containerize(containerizer); + } + } + + @Test + void jibPush_whenPushFailed_thenThrowException() throws CacheDirectoryCreationException, IOException, ExecutionException, InterruptedException, RegistryException { + try (MockedStatic containerizerMockedStatic = mockStatic(Containerizer.class); + MockedStatic jibMockedStatic = mockStatic(Jib.class)) { + // Given + JibContainerBuilder jibContainerBuilder = mock(JibContainerBuilder.class, RETURNS_SELF); + Containerizer containerizer = mock(Containerizer.class, RETURNS_SELF); + jibMockedStatic.when(() -> Jib.from(any(TarImage.class))).thenReturn(jibContainerBuilder); + containerizerMockedStatic.when(() -> Containerizer.to(any(RegistryImage.class))).thenReturn(containerizer); + when(jibContainerBuilder.containerize(containerizer)).thenThrow(new RegistryException("Unauthorized")); + ImageConfiguration imageConfiguration = getSampleImageConfiguration(); + Credential credential = Credential.from("testuser", "secret"); + File tarArchive = new File("docker-build.tar"); + + // When + Then + assertThatIllegalStateException() + .isThrownBy(() -> JibServiceUtil.jibPush(imageConfiguration, credential, tarArchive, kitLogger)) + .withMessage("Unauthorized"); + } + } + + @Test + void jibPush_whenNoTagsInBuildConfig_thenNoAdditionalTagsAddedToContainerizer() throws CacheDirectoryCreationException, IOException, ExecutionException, InterruptedException, RegistryException { + try (MockedStatic containerizerMockedStatic = mockStatic(Containerizer.class); + MockedStatic jibMockedStatic = mockStatic(Jib.class)) { + // Given + JibContainerBuilder jibContainerBuilder = mock(JibContainerBuilder.class, RETURNS_SELF); + Containerizer containerizer = mock(Containerizer.class, RETURNS_SELF); + jibMockedStatic.when(() -> Jib.from(any(TarImage.class))).thenReturn(jibContainerBuilder); + containerizerMockedStatic.when(() -> Containerizer.to(any(RegistryImage.class))).thenReturn(containerizer); + ImageConfiguration imageConfiguration = getSampleImageConfiguration(); + Credential credential = Credential.from("testuser", "secret"); + File tarArchive = new File("docker-build.tar"); + + // When + JibServiceUtil.jibPush(imageConfiguration, credential, tarArchive, kitLogger); + + // Then + verify(containerizer, times(0)).withAdditionalTag(anyString()); + verify(jibContainerBuilder).containerize(containerizer); + } + } + + @Test + void jibPush_whenAdditionalTagsInBuildConfig_thenAdditionalTagsAddedToContainerizer() throws CacheDirectoryCreationException, IOException, ExecutionException, InterruptedException, RegistryException { + try (MockedStatic containerizerMockedStatic = mockStatic(Containerizer.class); + MockedStatic jibMockedStatic = mockStatic(Jib.class)) { + // Given + JibContainerBuilder jibContainerBuilder = mock(JibContainerBuilder.class, RETURNS_SELF); + Containerizer containerizer = mock(Containerizer.class, RETURNS_SELF); + jibMockedStatic.when(() -> Jib.from(any(TarImage.class))).thenReturn(jibContainerBuilder); + containerizerMockedStatic.when(() -> Containerizer.to(any(RegistryImage.class))).thenReturn(containerizer); + ImageConfiguration imageConfiguration = getSampleImageConfiguration(); + imageConfiguration = imageConfiguration.toBuilder() + .build(imageConfiguration.getBuild().toBuilder() + .tags(Arrays.asList("t1", "t2", "t3")) + .build()) + .build(); + Credential credential = Credential.from("testuser", "secret"); + File tarArchive = new File("docker-build.tar"); + + // When + JibServiceUtil.jibPush(imageConfiguration, credential, tarArchive, kitLogger); + + // Then + verify(containerizer).withAdditionalTag("t1"); + verify(containerizer).withAdditionalTag("t2"); + verify(containerizer).withAdditionalTag("t3"); + verify(jibContainerBuilder).containerize(containerizer); + } + } + private ImageConfiguration getSampleImageConfiguration() { return ImageConfiguration.builder() .name("test/test-project")