diff --git a/src/main/java/org/entando/kubernetes/controller/EntandoPluginController.java b/src/main/java/org/entando/kubernetes/controller/EntandoPluginController.java index 4987573..fe0238f 100644 --- a/src/main/java/org/entando/kubernetes/controller/EntandoPluginController.java +++ b/src/main/java/org/entando/kubernetes/controller/EntandoPluginController.java @@ -16,8 +16,8 @@ import org.apache.commons.lang3.StringUtils; import org.entando.kubernetes.exception.BadRequestExceptionFactory; import org.entando.kubernetes.exception.NotFoundExceptionFactory; -import org.entando.kubernetes.model.common.EntandoMultiTenancy; import org.entando.kubernetes.model.PluginVariable; +import org.entando.kubernetes.model.common.EntandoMultiTenancy; import org.entando.kubernetes.model.link.EntandoAppPluginLink; import org.entando.kubernetes.model.plugin.EntandoPlugin; import org.entando.kubernetes.model.response.PluginConfiguration; @@ -101,7 +101,7 @@ public ResponseEntity> getPluginIngress(@PathVariable("name } @GetMapping(path = "/resolve", produces = {APPLICATION_JSON_VALUE, HAL_JSON_VALUE}) - public ResponseEntity> resolvePluginVariable(@RequestParam("variableName") final List variableNames, + public CollectionModel resolvePluginVariable(@RequestParam("variableName") final List variableNames, @RequestParam(value = "namespace", required = false) String namespace) { if (StringUtils.isEmpty(namespace)) { @@ -111,7 +111,7 @@ public ResponseEntity> resolvePluginVariable(@Re } final List pluginVariables = pluginService.resolvePluginVariables(variableNames, namespace); - return ResponseEntity.ok(new CollectionModel<>(pluginVariables)); + return CollectionModel.of(pluginVariables); } @DeleteMapping(path = "/{name}", produces = {APPLICATION_JSON_VALUE, HAL_JSON_VALUE}) @@ -214,6 +214,8 @@ private void addCollectionLinks(CollectionModel> coll "delete-plugin-ingress-path")); collection.add(linkTo(methodOn(EntandoPluginController.class).createOrReplace(null)).withRel( "create-or-replace-plugin")); + collection.add(linkTo(methodOn(EntandoPluginController.class).resolvePluginVariable(null, null)).withRel( + "resolve-variables")); collection.add(linkTo(methodOn(EntandoPluginController.class).getPluginConfiguration(null, null)) .withRel("plugin-configuration")); } diff --git a/src/main/java/org/entando/kubernetes/service/EntandoPluginService.java b/src/main/java/org/entando/kubernetes/service/EntandoPluginService.java index ec7cc11..66e15c2 100644 --- a/src/main/java/org/entando/kubernetes/service/EntandoPluginService.java +++ b/src/main/java/org/entando/kubernetes/service/EntandoPluginService.java @@ -15,7 +15,6 @@ import io.fabric8.kubernetes.client.dsl.Resource; import io.fabric8.kubernetes.client.dsl.RollableScalableResource; import io.fabric8.zjsonpatch.internal.guava.Strings; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; @@ -24,7 +23,6 @@ import lombok.extern.slf4j.Slf4j; import org.entando.kubernetes.exception.NotFoundExceptionFactory; import org.entando.kubernetes.model.PluginVariable; -import org.entando.kubernetes.exception.NotFoundExceptionFactory; import org.entando.kubernetes.model.namespace.ObservedNamespaces; import org.entando.kubernetes.model.plugin.EntandoPlugin; import org.entando.kubernetes.model.plugin.EntandoPluginBuilder; diff --git a/src/test/java/org/entando/kubernetes/controller/EntandoPluginControllerTest.java b/src/test/java/org/entando/kubernetes/controller/EntandoPluginControllerTest.java index 2d5c1c5..96bb839 100644 --- a/src/test/java/org/entando/kubernetes/controller/EntandoPluginControllerTest.java +++ b/src/test/java/org/entando/kubernetes/controller/EntandoPluginControllerTest.java @@ -154,7 +154,8 @@ void shouldReturnCollectionLinks() throws Exception { assertThat(cl).isNotEmpty(); assertThat(cl.stream().map(Link::getRel).map(LinkRelation::value).collect(Collectors.toList())) .containsExactlyInAnyOrder("plugin", "plugins-in-namespace", "plugin-links", - "delete-plugin-ingress-path", "create-or-replace-plugin", "plugin-configuration"); + "delete-plugin-ingress-path", "create-or-replace-plugin", "plugin-configuration", + "resolve-variables"); assertThat(cl.stream().filter(link -> !link.getRel().value().equals("create-or-replace-plugin")) .allMatch(Link::isTemplated)).isTrue(); assertThat(cl.getLink(LinkRelation.of("create-or-replace-plugin")).get().isTemplated()).isFalse();