Skip to content

Commit

Permalink
refactor: k8s name/version don't def to image
Browse files Browse the repository at this point in the history
  • Loading branch information
iocanel committed May 31, 2023
1 parent 071a89c commit 4974bd9
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public class KnativeConfig implements PlatformConfiguration {
* The name of the application. This value will be used for naming Kubernetes
* resources like: - Deployment - Service and so on ...
*/
@ConfigItem(defaultValue = "${quarkus.container-image.name}")
@ConfigItem
Optional<String> name;

/**
* The version of the application.
*/
@ConfigItem(defaultValue = "${quarkus.container-image.tag}")
@ConfigItem
Optional<String> version;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ public enum DeploymentResourceKind {
* The name of the application. This value will be used for naming Kubernetes
* resources like: - Deployment - Service and so on ...
*/
@ConfigItem(defaultValue = "${quarkus.container-image.name}")
@ConfigItem
Optional<String> name;

/**
* The version of the application.
*/
@ConfigItem(defaultValue = "${quarkus.container-image.tag}")
@ConfigItem
Optional<String> version;
/**
* The kind of the deployment resource to use.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ public static enum DeploymentResourceKind {
* The name of the application. This value will be used for naming Kubernetes
* resources like: 'Deployment', 'Service' and so on...
*/
@ConfigItem(defaultValue = "${quarkus.container-image.name}")
@ConfigItem
Optional<String> name;

/**
* The version of the application.
*/
@ConfigItem(defaultValue = "${quarkus.container-image.tag}")
@ConfigItem
Optional<String> version;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
public class KubernetesWithDefaultApplicationVersionTest {

private static final String APP_NAME = "kubernetes-with-default-application-version";
private static final String EXPECTED_VERSION = "latest";
private static final String EXPECTED_LABEL_VERSION = "<<unset>>";
private static final String EXPECTED_CONTAINER_IMAGE_VERSION = "latest";

@RegisterExtension
static final QuarkusProdModeTest config = new QuarkusProdModeTest()
Expand All @@ -46,15 +47,15 @@ public void assertGeneratedResources() throws IOException {
assertThat(d.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo(APP_NAME);
assertThat(m.getLabels()).contains(entry("app.kubernetes.io/name", APP_NAME),
entry("app.kubernetes.io/version", EXPECTED_VERSION));
entry("app.kubernetes.io/version", EXPECTED_LABEL_VERSION));
});

assertThat(d.getSpec()).satisfies(deploymentSpec -> {
assertThat(deploymentSpec.getTemplate()).satisfies(t -> {
assertThat(t.getSpec()).satisfies(podSpec -> {
assertThat(podSpec.getContainers()).singleElement().satisfies(container -> {
// then, we should use `latest` and not `<< unset >>` which gives an exception.
assertThat(container.getImage()).endsWith(APP_NAME + ":" + EXPECTED_VERSION);
assertThat(container.getImage()).endsWith(APP_NAME + ":" + EXPECTED_CONTAINER_IMAGE_VERSION);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public class KubernetesWithHealthAndJibTest {
.setApplicationVersion("0.1-SNAPSHOT")
.setRun(true)
.setLogFileName("k8s.log")
.withConfigurationResource("kubernetes-with-health-and-jib.properties")
.overrideConfigKey("quarkus.http.port", "9000")
.overrideConfigKey("quarkus.container-image.name", "with-health-and-jib")
.setForcedDependencies(List.of(
Dependency.of("io.quarkus", "quarkus-smallrye-health", Version.getVersion()),
Dependency.of("io.quarkus", "quarkus-container-image-jib", Version.getVersion())));
Expand All @@ -45,7 +46,7 @@ public void assertGeneratedResources() throws IOException {
.deserializeAsList(kubernetesDir.resolve("kubernetes.yml"));
assertThat(kubernetesList.get(0)).isInstanceOfSatisfying(Deployment.class, d -> {
assertThat(d.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo("with-health-and-jib");
assertThat(m.getName()).isEqualTo("health-and-jib");
});

assertThat(d.getSpec()).satisfies(deploymentSpec -> {
Expand Down

This file was deleted.

0 comments on commit 4974bd9

Please sign in to comment.