-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
.../java/io/quarkus/it/kubernetes/KubernetesWithEnvFromConfigMapWithPrefixBehaviorsTest.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,66 @@ | ||
package io.quarkus.it.kubernetes; | ||
|
||
import io.fabric8.kubernetes.api.model.ConfigMapEnvSource; | ||
import io.fabric8.kubernetes.api.model.EnvFromSource; | ||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.fabric8.kubernetes.api.model.apps.Deployment; | ||
import io.quarkus.test.ProdBuildResults; | ||
import io.quarkus.test.ProdModeTestResults; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class KubernetesWithEnvFromConfigMapWithPrefixBehaviorsTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.withApplicationRoot((jar) -> jar.addClasses(GreetingResource.class)) | ||
.setApplicationName("env-from-config-map-with-prefix-behaviors") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.withConfigurationResource("kubernetes-with-env-from-config-map-with-prefix-behaviors.properties"); | ||
|
||
@ProdBuildResults | ||
private ProdModeTestResults prodModeTestResults; | ||
|
||
@Test | ||
public void assertGeneratedResources() throws IOException { | ||
Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes"); | ||
assertThat(kubernetesDir) | ||
.isDirectoryContaining(p -> p.getFileName().endsWith("kubernetes.json")) | ||
.isDirectoryContaining(p -> p.getFileName().endsWith("kubernetes.yml")); | ||
List<HasMetadata> kubernetesList = DeserializationUtil | ||
.deserializeAsList(kubernetesDir.resolve("kubernetes.yml")); | ||
assertThat(kubernetesList.get(0)).isInstanceOfSatisfying(Deployment.class, d -> { | ||
assertThat(d.getMetadata()).satisfies(m -> { | ||
assertThat(m.getName()).isEqualTo("env-from-config-map-with-prefix-behaviors"); | ||
}); | ||
|
||
assertThat(d.getSpec()).satisfies(deploymentSpec -> { | ||
assertThat(deploymentSpec.getTemplate()).satisfies(t -> { | ||
assertThat(t.getSpec()).satisfies(podSpec -> { | ||
assertThat(podSpec.getContainers()).singleElement().satisfies(container -> { | ||
|
||
assertThat(container.getEnvFrom()).containsExactlyInAnyOrder( | ||
new EnvFromSource( | ||
new ConfigMapEnvSource("another", true), "QUARKUS", null | ||
), | ||
new EnvFromSource( | ||
new ConfigMapEnvSource("without", true), null, null | ||
), | ||
new EnvFromSource( | ||
new ConfigMapEnvSource("configmap", true), "HELLO", null | ||
) | ||
); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
...est/java/io/quarkus/it/kubernetes/KubernetesWithEnvFromSecretWithPrefixBehaviorsTest.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,66 @@ | ||
package io.quarkus.it.kubernetes; | ||
|
||
import io.fabric8.kubernetes.api.model.ConfigMapEnvSource; | ||
import io.fabric8.kubernetes.api.model.EnvFromSource; | ||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.fabric8.kubernetes.api.model.SecretEnvSource; | ||
import io.fabric8.kubernetes.api.model.apps.Deployment; | ||
import io.quarkus.test.ProdBuildResults; | ||
import io.quarkus.test.ProdModeTestResults; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
import org.hamcrest.Matchers; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class KubernetesWithEnvFromSecretWithPrefixBehaviorsTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.withApplicationRoot((jar) -> jar.addClasses(GreetingResource.class)) | ||
.setApplicationName("env-from-secret-with-prefix") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.withConfigurationResource("kubernetes-with-env-from-secret-with-prefix-behaviors.properties"); | ||
|
||
@ProdBuildResults | ||
private ProdModeTestResults prodModeTestResults; | ||
|
||
@Test | ||
public void assertGeneratedResources() throws IOException { | ||
Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes"); | ||
assertThat(kubernetesDir) | ||
.isDirectoryContaining(p -> p.getFileName().endsWith("kubernetes.json")) | ||
.isDirectoryContaining(p -> p.getFileName().endsWith("kubernetes.yml")); | ||
List<HasMetadata> kubernetesList = DeserializationUtil | ||
.deserializeAsList(kubernetesDir.resolve("kubernetes.yml")); | ||
assertThat(kubernetesList.get(0)).isInstanceOfSatisfying(Deployment.class, d -> { | ||
assertThat(d.getMetadata()).satisfies(m -> { | ||
assertThat(m.getName()).isEqualTo("env-from-secret-with-prefix-behaviors"); | ||
}); | ||
|
||
assertThat(d.getSpec()).satisfies(deploymentSpec -> { | ||
assertThat(deploymentSpec.getTemplate()).satisfies(t -> { | ||
assertThat(t.getSpec()).satisfies(podSpec -> { | ||
assertThat(podSpec.getContainers()).singleElement().satisfies(container -> { | ||
assertThat(container.getEnvFrom()).containsExactlyInAnyOrder( | ||
new EnvFromSource( | ||
null, "QUARKUS", new SecretEnvSource("another", true) | ||
), | ||
new EnvFromSource( | ||
null, "HELLO", new SecretEnvSource("secrets", true) | ||
), | ||
new EnvFromSource( | ||
null, null, new SecretEnvSource("without", true) | ||
)); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ay/src/test/resources/kubernetes-with-env-from-configmap-with-prefix-behaviors.properties
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 @@ | ||
quarkus.kubernetes.configmaps.secrets=configmap[PREFIX],another[QUARKUS][ANOTHER],configmap[HELLO],without |
1 change: 1 addition & 0 deletions
1
...d-way/src/test/resources/kubernetes-with-env-from-secret-with-prefix-behaviors.properties
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 @@ | ||
quarkus.kubernetes.env.secrets=secrets[PREFIX],another[QUARKUS][ANOTHER],secrets[HELLO],without |