Skip to content

Commit

Permalink
ENG-5458 added atheoas link to resolve plugin variables
Browse files Browse the repository at this point in the history
  • Loading branch information
firegloves committed Feb 12, 2024
1 parent 6a1c124 commit 64b90b9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -101,7 +101,7 @@ public ResponseEntity<EntityModel<Ingress>> getPluginIngress(@PathVariable("name
}

@GetMapping(path = "/resolve", produces = {APPLICATION_JSON_VALUE, HAL_JSON_VALUE})
public ResponseEntity<CollectionModel<PluginVariable>> resolvePluginVariable(@RequestParam("variableName") final List<String> variableNames,
public CollectionModel<PluginVariable> resolvePluginVariable(@RequestParam("variableName") final List<String> variableNames,
@RequestParam(value = "namespace", required = false) String namespace) {

if (StringUtils.isEmpty(namespace)) {
Expand All @@ -111,7 +111,7 @@ public ResponseEntity<CollectionModel<PluginVariable>> resolvePluginVariable(@Re
}

final List<PluginVariable> 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})
Expand Down Expand Up @@ -214,6 +214,8 @@ private void addCollectionLinks(CollectionModel<EntityModel<EntandoPlugin>> 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"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 64b90b9

Please sign in to comment.