Skip to content

Commit

Permalink
Don't ignore invalid config in quarkus.container-image.name
Browse files Browse the repository at this point in the history
Fixes: #33552
  • Loading branch information
geoand committed May 23, 2023
1 parent 60a73e1 commit 3b4b4b7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
4 changes: 2 additions & 2 deletions extensions/container-image/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
<artifactId>quarkus-container-image</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class ContainerImageConfig {
*/
@ConfigItem(defaultValue = "${quarkus.application.name:unset}")
@ConvertWith(TrimmedStringConverter.class)
public Optional<String> name;
public String name;

/**
* The tag of the container image. If not set defaults to the application version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ public void publishImageInfo(ApplicationInfoBuildItem app,
}

String effectiveName = containerImageCustomName.map(ContainerImageCustomNameBuildItem::getName)
.or(() -> containerImageConfig.name)
.orElse(app.getName());
.orElse(containerImageConfig.name);
String repository = (containerImageConfig.getEffectiveGroup().map(s -> s + "/").orElse("")) + effectiveName;
if (!ImageReference.isValidRepository(repository)) {
throw new IllegalArgumentException("The supplied combination of container-image group '"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.quarkus.container.image.deployment;

import static org.junit.jupiter.api.Assertions.fail;

import java.util.NoSuchElementException;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;

public class InvalidConfigInNameTest {

@RegisterExtension
static QuarkusUnitTest runner = new QuarkusUnitTest()
.setExpectedException(NoSuchElementException.class)
.withEmptyApplication()
.overrideConfigKey("quarkus.container-image.build", "true")
.overrideConfigKey("quarkus.container-image.name", "test-${foo.bar}");

@Test
void shouldThrow() {
fail("Should not be run");
}
}

0 comments on commit 3b4b4b7

Please sign in to comment.