3636class HelmTest {
3737 private static final String ENV_VAR_KUBECONFIG = "KUBECONFIG" ;
3838
39- /// Must match `quarkus.kubernetes.name`.
40- private static final String CONTAINER_NAME = "postgresql-operator" ;
41-
4239 /// The Pod and Container list fields that the chart exposes as free-form Helm values.
4340 private static final List <String > LIST_VALUES = List .of (
4441 "imagePullSecrets" ,
@@ -57,16 +54,20 @@ class HelmTest {
5754 );
5855
5956 private final String chartName ;
57+ /// Dekorate uses this value for the Deployment name and for the container name.
58+ private final String kubernetesName ;
6059 private final String rootValuesAlias ;
6160 private final KubernetesClient kubernetesClient ;
6261
6362 HelmTest (
6463 KubernetesClient kubernetesClient ,
6564 @ ConfigProperty (name = "quarkus.helm.name" ) String chartName ,
65+ @ ConfigProperty (name = "quarkus.kubernetes.name" ) String kubernetesName ,
6666 @ ConfigProperty (name = "quarkus.helm.values-root-alias" , defaultValue = "app" ) String rootValuesAlias
6767 ) {
6868 this .kubernetesClient = kubernetesClient ;
6969 this .chartName = chartName ;
70+ this .kubernetesName = kubernetesName ;
7071 this .rootValuesAlias = rootValuesAlias ;
7172 }
7273
@@ -238,7 +239,7 @@ void helmInstall_createsDeployment() throws IOException {
238239 assertThat (podSpec .getContainers ())
239240 .singleElement ()
240241 .satisfies (container -> {
241- assertThat (container .getName ()).isEqualTo (CONTAINER_NAME );
242+ assertThat (container .getName ()).isEqualTo (kubernetesName );
242243 assertThat (container .getVolumeMounts ()).isEmpty ();
243244 });
244245 });
@@ -275,7 +276,7 @@ void helmInstall_createsDeployment() throws IOException {
275276 @ Test
276277 @ DisplayName ("When the chart is rendered with volumes, the deployment should mount them" )
277278 void helmTemplate_rendersVolumes () throws IOException {
278- // given
279+ // given
279280 var chartPath = chartPath ();
280281
281282 assertThat (chartPath )
@@ -311,17 +312,24 @@ void helmTemplate_rendersVolumes() throws IOException {
311312 .withFailMessage ("Helm template failed, see the logged error output" )
312313 .isZero ();
313314
314- var deployment = kubernetesClient .load (new ByteArrayInputStream (
315+ var deployments = kubernetesClient .load (new ByteArrayInputStream (
315316 renderedOutput .toString ().getBytes (StandardCharsets .UTF_8 )
316317 ))
317318 .items ()
318319 .stream ()
319320 .filter (Deployment .class ::isInstance )
320321 .map (Deployment .class ::cast )
321- .findFirst ()
322- .orElseThrow (() -> new AssertionError (
323- "The rendered chart contains no Deployment:%n%s" .formatted (renderedOutput )
324- ));
322+ .toList ();
323+
324+ assertThat (deployments )
325+ .withFailMessage ("The rendered chart must contain exactly one Deployment:%n%s" , renderedOutput )
326+ .hasSize (1 );
327+
328+ var deployment = deployments .getFirst ();
329+
330+ // The baseline `kubernetes.yml` must name the Deployment `quarkus.kubernetes.name`.
331+ // Dekorate keeps a different name as a second Deployment.
332+ assertThat (deployment .getMetadata ().getName ()).isEqualTo (kubernetesName );
325333
326334 var podSpec = deployment .getSpec ().getTemplate ().getSpec ();
327335
@@ -349,7 +357,7 @@ void helmTemplate_rendersVolumes() throws IOException {
349357 assertThat (podSpec .getContainers ())
350358 .singleElement ()
351359 .satisfies (container -> {
352- assertThat (container .getName ()).isEqualTo (CONTAINER_NAME );
360+ assertThat (container .getName ()).isEqualTo (kubernetesName );
353361 assertThat (container .getVolumeMounts ())
354362 .extracting (VolumeMount ::getMountPath )
355363 .containsExactly ("/mnt/secrets" , "/mnt/aws" );
@@ -366,7 +374,8 @@ private Path chartPath() {
366374 }
367375
368376 private static Path createTempValuesWithVolumes () throws IOException {
369- var values = """
377+ var values =
378+ """
370379 app:
371380 image: postgresql-operator:test
372381 imagePullSecrets:
0 commit comments