forked from eclipse-jkube/jkube
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix (jkube-kit) : Generate yaml files for different environments (ecl…
…ipse-jkube#1218) Modify ResourceServiceConfig to recieve a list of files as resourceDirs instead of receiving a single resourceDir. Resource fragments in these files can be combined while generating resources. Signed-off-by: Rohan Kumar <rohaan@redhat.com>
- Loading branch information
1 parent
81a8b28
commit 213d59c
Showing
44 changed files
with
562 additions
and
77 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
plugins { | ||
id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}" | ||
id 'org.eclipse.jkube.openshift' version "${jKubeVersion}" | ||
id 'java' | ||
} | ||
|
||
group = 'org.eclipse.jkube.integration.tests.gradle' | ||
version = '0.0.1-SNAPSHOT' | ||
sourceCompatibility = '11' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
kubernetes { | ||
offline = true | ||
} | ||
|
||
openshift { | ||
offline = true | ||
} |
15 changes: 15 additions & 0 deletions
15
gradle-plugin/it/src/it/multi-environments/expected/common/kubernetes.yml
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,15 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: List | ||
items: | ||
- apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
labels: | ||
app: multi-environments | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: common | ||
data: | ||
type: common |
15 changes: 15 additions & 0 deletions
15
gradle-plugin/it/src/it/multi-environments/expected/common/openshift.yml
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,15 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: List | ||
items: | ||
- apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
labels: | ||
app: multi-environments | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: common | ||
data: | ||
type: common |
26 changes: 26 additions & 0 deletions
26
gradle-plugin/it/src/it/multi-environments/expected/commonanddev/kubernetes.yml
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,26 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: List | ||
items: | ||
- apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
labels: | ||
app: multi-environments | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: common | ||
data: | ||
type: common | ||
- apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
labels: | ||
app: multi-environments | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: dev | ||
data: | ||
type: dev |
26 changes: 26 additions & 0 deletions
26
gradle-plugin/it/src/it/multi-environments/expected/commonanddev/openshift.yml
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,26 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: List | ||
items: | ||
- apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
labels: | ||
app: multi-environments | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: common | ||
data: | ||
type: common | ||
- apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
labels: | ||
app: multi-environments | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: dev | ||
data: | ||
type: dev |
26 changes: 26 additions & 0 deletions
26
gradle-plugin/it/src/it/multi-environments/expected/commonandprod/kubernetes.yml
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,26 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: List | ||
items: | ||
- apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
labels: | ||
app: multi-environments | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: common | ||
data: | ||
type: common | ||
- apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
labels: | ||
app: multi-environments | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: prod | ||
data: | ||
type: prod |
26 changes: 26 additions & 0 deletions
26
gradle-plugin/it/src/it/multi-environments/expected/commonandprod/openshift.yml
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,26 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: List | ||
items: | ||
- apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
labels: | ||
app: multi-environments | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: common | ||
data: | ||
type: common | ||
- apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
labels: | ||
app: multi-environments | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: prod | ||
data: | ||
type: prod |
15 changes: 15 additions & 0 deletions
15
gradle-plugin/it/src/it/multi-environments/expected/dev/kubernetes.yml
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,15 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: List | ||
items: | ||
- apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
labels: | ||
app: multi-environments | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: dev | ||
data: | ||
type: dev |
15 changes: 15 additions & 0 deletions
15
gradle-plugin/it/src/it/multi-environments/expected/dev/openshift.yml
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,15 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: List | ||
items: | ||
- apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
labels: | ||
app: multi-environments | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: dev | ||
data: | ||
type: dev |
15 changes: 15 additions & 0 deletions
15
gradle-plugin/it/src/it/multi-environments/expected/prod/kubernetes.yml
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,15 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: List | ||
items: | ||
- apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
labels: | ||
app: multi-environments | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: prod | ||
data: | ||
type: prod |
15 changes: 15 additions & 0 deletions
15
gradle-plugin/it/src/it/multi-environments/expected/prod/openshift.yml
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,15 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: List | ||
items: | ||
- apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
labels: | ||
app: multi-environments | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: prod | ||
data: | ||
type: prod |
16 changes: 16 additions & 0 deletions
16
gradle-plugin/it/src/it/multi-environments/src/main/jkube/common/common-configmap.yml
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 | ||
# | ||
|
||
data: | ||
type: common |
16 changes: 16 additions & 0 deletions
16
gradle-plugin/it/src/it/multi-environments/src/main/jkube/dev/dev-configmap.yml
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 | ||
# | ||
|
||
data: | ||
type: dev |
16 changes: 16 additions & 0 deletions
16
gradle-plugin/it/src/it/multi-environments/src/main/jkube/prod/prod-configmap.yml
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 | ||
# | ||
|
||
data: | ||
type: prod |
74 changes: 74 additions & 0 deletions
74
...le-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/MultiEnvironmentsIT.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,74 @@ | ||
/** | ||
* Copyright (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.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
|
||
import java.io.IOException; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
|
||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
|
||
@RunWith(Parameterized.class) | ||
public class MultiEnvironmentsIT { | ||
@Rule | ||
public final ITGradleRunner gradleRunner = new ITGradleRunner(); | ||
|
||
@Parameterized.Parameters(name = "environment {0}") | ||
public static Collection<Object[]> data() { | ||
return Arrays.asList( | ||
new Object[] { "common" }, | ||
new Object[] { "dev" }, | ||
new Object[] { "prod" }, | ||
new Object[] { "common,dev"}, | ||
new Object[] { "common,prod"} | ||
); | ||
} | ||
|
||
@Parameterized.Parameter | ||
public String environment; | ||
|
||
@Test | ||
public void k8sResource_whenRun_generatesK8sManifestsContainingConfigMap() throws IOException, ParseException { | ||
// When | ||
final BuildResult result = gradleRunner.withITProject("multi-environments") | ||
.withArguments("build", "-Pjkube.environment=" + environment, "k8sResource", "--stacktrace") | ||
.build(); | ||
// Then | ||
ResourceVerify.verifyResourceDescriptors(gradleRunner.resolveDefaultKubernetesResourceFile(), | ||
gradleRunner.resolveFile("expected", environment.replace(",", "and"), "kubernetes.yml")); | ||
assertThat(result).extracting(BuildResult::getOutput).asString() | ||
.contains("Running in Kubernetes mode"); | ||
} | ||
|
||
@Test | ||
public void ocResource_whenRun_generatesOpenShiftManifestsContainingConfigMap() throws IOException, ParseException { | ||
// When | ||
final BuildResult result = gradleRunner.withITProject("multi-environments") | ||
.withArguments("build", "-Pjkube.environment=" + environment, "ocResource", "--stacktrace") | ||
.build(); | ||
// Then | ||
ResourceVerify.verifyResourceDescriptors(gradleRunner.resolveDefaultOpenShiftResourceFile(), | ||
gradleRunner.resolveFile("expected", environment.replace(",", "and"), "openshift.yml")); | ||
assertThat(result).extracting(BuildResult::getOutput).asString() | ||
.contains("Running in OpenShift mode"); | ||
} | ||
} |
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.