-
Notifications
You must be signed in to change notification settings - Fork 542
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor (jkube-kit) : Move Dockerfile opinionated ImageConfig logic …
…from `ConfigHelper.initImageConfiguration` to a dedicated generator (#2802) * refactor (jkube-kit) : Move Dockerfile opinionated ImageConfig logic from `ConfigHelper.initImageConfiguration` to a dedicated generator + ConfigHelper modifies the provided set of ImageConfigurations when it detects a `Dockerfile` in project root directory. This is actually a feature called Simple Dockerfile Mode. However, this mutation of ImageConfiguration from within `initImageConfiguration` does not look appropriate. It can be moved to a dedicated generator that will get activated when `Dockerfile` is present in project base directory. + Add a new generator SimpleDockerfileGenerator, it adds a simple ImageConfiguration with Dockerfile configured in build and adds it to existing set of ImageConfigurations. + Remove check from BaseGenerator to skip generation if it's simple Dockerfile mode Move it to SimpleDockerfileGenerator.isApplicable instead * review: IT for gradle and maven plugin precedence
- Loading branch information
1 parent
8c5e126
commit 5931629
Showing
46 changed files
with
1,131 additions
and
270 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
gradle-plugin/it/src/it/dockerfile-simple-generator-precedence-kubernetes/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
# | ||
|
||
FROM busybox:latest | ||
EXPOSE 9080 |
33 changes: 33 additions & 0 deletions
33
gradle-plugin/it/src/it/dockerfile-simple-generator-precedence-kubernetes/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
*/ | ||
plugins { | ||
id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}" | ||
id 'org.springframework.boot' version '2.7.17' | ||
id 'io.spring.dependency-management' version '1.0.15.RELEASE' | ||
id 'java' | ||
} | ||
|
||
group = 'org.eclipse.jkube.integration.tests.gradle' | ||
version = '0.0.1-SNAPSHOT' | ||
sourceCompatibility = '11' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
def extensionConfig = { | ||
offline = true | ||
} | ||
|
||
kubernetes(extensionConfig) |
16 changes: 16 additions & 0 deletions
16
gradle-plugin/it/src/it/dockerfile-simple-generator-precedence-openshift/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
# | ||
|
||
FROM busybox:latest | ||
EXPOSE 9080 |
33 changes: 33 additions & 0 deletions
33
gradle-plugin/it/src/it/dockerfile-simple-generator-precedence-openshift/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
*/ | ||
plugins { | ||
id 'org.eclipse.jkube.openshift' version "${jKubeVersion}" | ||
id 'org.springframework.boot' version '2.7.17' | ||
id 'io.spring.dependency-management' version '1.0.15.RELEASE' | ||
id 'java' | ||
} | ||
|
||
group = 'org.eclipse.jkube.integration.tests.gradle' | ||
version = '0.0.1-SNAPSHOT' | ||
sourceCompatibility = '11' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
def extensionConfig = { | ||
offline = true | ||
} | ||
|
||
openshift(extensionConfig) |
59 changes: 59 additions & 0 deletions
59
...est/java/org/eclipse/jkube/gradle/plugin/tests/DockerfileSimpleExtensionPrecedenceIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (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 org.gradle.testkit.runner.BuildResult; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import java.io.File; | ||
import java.util.stream.Collectors; | ||
|
||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
|
||
class DockerfileSimpleExtensionPrecedenceIT { | ||
|
||
|
||
@RegisterExtension | ||
private final ITGradleRunnerExtension gradleRunner = new ITGradleRunnerExtension(); | ||
|
||
@Test | ||
void k8sResource_whenRun_generatesK8sManifests() { | ||
// Remove kubernetes-gradle-plugin from classpath to avoid using its profiles-default.yml | ||
gradleRunner.withPluginClassPath(gradleRunner.pluginClassPath().stream() | ||
.filter(f -> !f.getAbsolutePath().contains("gradle-plugin" + File.separator + "openshift")) | ||
.collect(Collectors.toList()) | ||
); | ||
// When | ||
final BuildResult result = gradleRunner | ||
.withITProject("dockerfile-simple-generator-precedence-kubernetes") | ||
.withArguments("k8sResource", "--stacktrace") | ||
.build(); | ||
// Then | ||
assertThat(result).extracting(BuildResult::getOutput).asString() | ||
.contains("Running generator dockerfile-simple"); | ||
} | ||
|
||
@Test | ||
void ocResource_whenRun_generatesOpenShiftManifests() { | ||
// When | ||
final BuildResult result = gradleRunner | ||
.withITProject("dockerfile-simple-generator-precedence-openshift") | ||
.withArguments("ocResource") | ||
.build(); | ||
// Then | ||
assertThat(result).extracting(BuildResult::getOutput).asString() | ||
.contains("Running generator dockerfile-simple"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.