@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2021 the original author or authors.
|
||||
* Copyright 2013-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -52,8 +52,21 @@ public class DiscoveryServerController {
|
||||
return reactiveDiscoveryClient.getInstances(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* use the "appInstanceNonDeprecated" instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
@GetMapping("/app/{name}/{instanceId}")
|
||||
public Mono<ServiceInstance> appInstance(@PathVariable String name, @PathVariable String instanceId) {
|
||||
return innerAppInstance(name, instanceId);
|
||||
}
|
||||
|
||||
@GetMapping("/apps/{name}/{instanceId}")
|
||||
Mono<ServiceInstance> appInstanceNonDeprecated(@PathVariable String name, @PathVariable String instanceId) {
|
||||
return innerAppInstance(name, instanceId);
|
||||
}
|
||||
|
||||
private Mono<ServiceInstance> innerAppInstance(String name, String instanceId) {
|
||||
return reactiveDiscoveryClient.getInstances(name)
|
||||
.filter(serviceInstance -> serviceInstance.getInstanceId().equals(instanceId)).singleOrEmpty();
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class DiscoveryServerIntegrationInstanceEndpointTest {
|
||||
private WebTestClient webTestClient;
|
||||
|
||||
@Test
|
||||
void instance() {
|
||||
void instanceDeprecated() {
|
||||
Map<String, String> metadata = new HashMap<>();
|
||||
metadata.put("spring", "true");
|
||||
metadata.put("port.http", "8080");
|
||||
@@ -91,6 +91,24 @@ class DiscoveryServerIntegrationInstanceEndpointTest {
|
||||
.isEqualTo(kubernetesServiceInstance);
|
||||
}
|
||||
|
||||
@Test
|
||||
void instance() {
|
||||
Map<String, String> metadata = new HashMap<>();
|
||||
metadata.put("spring", "true");
|
||||
metadata.put("port.http", "8080");
|
||||
metadata.put("k8s_namespace", "namespace");
|
||||
metadata.put("type", "ClusterIP");
|
||||
metadata.put("k8s", "true");
|
||||
|
||||
DefaultKubernetesServiceInstance kubernetesServiceInstance = new DefaultKubernetesServiceInstance(
|
||||
TEST_ENDPOINTS.getSubsets().get(0).getAddresses().get(0).getTargetRef().getUid(),
|
||||
TEST_SERVICE.getMetadata().getName(), TEST_ENDPOINTS.getSubsets().get(0).getAddresses().get(0).getIp(),
|
||||
TEST_ENDPOINTS.getSubsets().get(0).getPorts().get(0).getPort(), metadata, false,
|
||||
TEST_SERVICE.getMetadata().getNamespace(), null);
|
||||
webTestClient.get().uri("/apps/test-svc-3/uid2").exchange().expectBody(DefaultKubernetesServiceInstance.class)
|
||||
.isEqualTo(kubernetesServiceInstance);
|
||||
}
|
||||
|
||||
@TestConfiguration
|
||||
static class TestConfig {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user