diff --git a/fullstack-helm-client/src/main/java/com/hedera/fullstack/helm/client/HelmClient.java b/fullstack-helm-client/src/main/java/com/hedera/fullstack/helm/client/HelmClient.java index 1305d8cfd..ef5f175e8 100644 --- a/fullstack-helm-client/src/main/java/com/hedera/fullstack/helm/client/HelmClient.java +++ b/fullstack-helm-client/src/main/java/com/hedera/fullstack/helm/client/HelmClient.java @@ -104,10 +104,10 @@ default Release installChart(String releaseName, Chart chart) { /** * Executes the Helm CLI {@code list} sub-command and returns the list of releases. - * + * @param allNamespaces if {@code true}, list releases across all namespaces. * @return the list of releases. */ - List listReleases(); + List listReleases(boolean allNamespaces); /** * Executes the Helm CLI {@code dependency update} sub-command and updates the dependencies of the specified Helm diff --git a/fullstack-helm-client/src/main/java/com/hedera/fullstack/helm/client/impl/DefaultHelmClient.java b/fullstack-helm-client/src/main/java/com/hedera/fullstack/helm/client/impl/DefaultHelmClient.java index e10ed8026..4984dfed0 100644 --- a/fullstack-helm-client/src/main/java/com/hedera/fullstack/helm/client/impl/DefaultHelmClient.java +++ b/fullstack-helm-client/src/main/java/com/hedera/fullstack/helm/client/impl/DefaultHelmClient.java @@ -156,8 +156,8 @@ public void testChart(final String releaseName, final TestChartOptions options) } @Override - public List listReleases() { - return executeAsList(new ReleaseListRequest(), ReleaseItem.class); + public List listReleases(boolean allNamespaces) { + return executeAsList(new ReleaseListRequest(allNamespaces), ReleaseItem.class); } @Override diff --git a/fullstack-helm-client/src/main/java/com/hedera/fullstack/helm/client/proxy/request/release/ReleaseListRequest.java b/fullstack-helm-client/src/main/java/com/hedera/fullstack/helm/client/proxy/request/release/ReleaseListRequest.java index 27847d26f..fd256149e 100644 --- a/fullstack-helm-client/src/main/java/com/hedera/fullstack/helm/client/proxy/request/release/ReleaseListRequest.java +++ b/fullstack-helm-client/src/main/java/com/hedera/fullstack/helm/client/proxy/request/release/ReleaseListRequest.java @@ -19,11 +19,15 @@ import com.hedera.fullstack.helm.client.execution.HelmExecutionBuilder; import com.hedera.fullstack.helm.client.proxy.request.HelmRequest; -public record ReleaseListRequest() implements HelmRequest { +public record ReleaseListRequest(boolean allNamespaces) implements HelmRequest { @Override public void apply(HelmExecutionBuilder builder) { builder.argument("output", "json"); + if (allNamespaces) { + builder.flag("--all-namespaces"); + } + builder.subcommands("list"); } } diff --git a/fullstack-helm-client/src/test/java/com/hedera/fullstack/helm/client/test/HelmClientTest.java b/fullstack-helm-client/src/test/java/com/hedera/fullstack/helm/client/test/HelmClientTest.java index d6aa7f880..61cc6169d 100644 --- a/fullstack-helm-client/src/test/java/com/hedera/fullstack/helm/client/test/HelmClientTest.java +++ b/fullstack-helm-client/src/test/java/com/hedera/fullstack/helm/client/test/HelmClientTest.java @@ -191,10 +191,31 @@ void testInstallChartCommand(final LoggingOutput loggingOutput) { try { suppressExceptions(() -> helmClient.uninstallChart(HAPROXY_RELEASE_NAME)); - Release release = helmClient.installChart(HAPROXY_RELEASE_NAME, HAPROXY_CHART); - List releaseItems = helmClient.listReleases(); + final Release release = helmClient.installChart(HAPROXY_RELEASE_NAME, HAPROXY_CHART); + + // verify the returned release object + assertThat(release).isNotNull(); + assertThat(release.name()).isEqualTo(HAPROXY_RELEASE_NAME); + assertThat(release.info().description()).isEqualTo("Install complete"); + assertThat(release.info().status()).isEqualTo("deployed"); + + // verify the release through the helm list command using the namespace of the helm client + final List specificNamespaceReleaseItems = helmClient.listReleases(false); + assertThat(specificNamespaceReleaseItems).isNotNull().isNotEmpty(); + final ReleaseItem specificNamespaceReleaseItem = specificNamespaceReleaseItems.stream() + .filter(item -> item.name().equals(HAPROXY_RELEASE_NAME)) + .findFirst() + .orElse(null); + assertThat(specificNamespaceReleaseItem).isNotNull(); + assertThat(specificNamespaceReleaseItem.name()).isEqualTo(HAPROXY_RELEASE_NAME); + assertThat(specificNamespaceReleaseItem.namespace()).isEqualTo(NAMESPACE); + assertThat(specificNamespaceReleaseItem.status()).isEqualTo("deployed"); + HelmClient defaultHelmClient = HelmClient.defaultClient(); + + // verify the release through the helm list command using the default namespace specifying --all-namespaces + final List releaseItems = defaultHelmClient.listReleases(true); assertThat(releaseItems).isNotNull().isNotEmpty(); - ReleaseItem releaseItem = releaseItems.stream() + final ReleaseItem releaseItem = releaseItems.stream() .filter(item -> item.name().equals(HAPROXY_RELEASE_NAME)) .findFirst() .orElse(null); @@ -202,10 +223,6 @@ void testInstallChartCommand(final LoggingOutput loggingOutput) { assertThat(releaseItem.name()).isEqualTo(HAPROXY_RELEASE_NAME); assertThat(releaseItem.namespace()).isEqualTo(NAMESPACE); assertThat(releaseItem.status()).isEqualTo("deployed"); - assertThat(release).isNotNull(); - assertThat(release.name()).isEqualTo(HAPROXY_RELEASE_NAME); - assertThat(release.info().description()).isEqualTo("Install complete"); - assertThat(release.info().status()).isEqualTo("deployed"); } finally { suppressExceptions(() -> helmClient.uninstallChart(HAPROXY_RELEASE_NAME)); }