diff --git a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClient.java b/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClient.java index 60a128f096..33580b439a 100644 --- a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClient.java +++ b/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClient.java @@ -42,17 +42,6 @@ public class KubernetesDiscoveryClient implements DiscoveryClient { private final String discoveryServerUrl; - @Deprecated(forRemoval = true) - public KubernetesDiscoveryClient(RestTemplate rest, KubernetesDiscoveryClientProperties properties) { - if (!StringUtils.hasText(properties.getDiscoveryServerUrl())) { - throw new DiscoveryServerUrlInvalidException(); - } - this.rest = rest; - this.emptyNamespaces = properties.getNamespaces().isEmpty(); - this.namespaces = properties.getNamespaces(); - this.discoveryServerUrl = properties.getDiscoveryServerUrl(); - } - KubernetesDiscoveryClient(RestTemplate rest, KubernetesDiscoveryProperties kubernetesDiscoveryProperties) { if (!StringUtils.hasText(kubernetesDiscoveryProperties.discoveryServerUrl())) { throw new DiscoveryServerUrlInvalidException(); diff --git a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClientAutoConfiguration.java b/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClientAutoConfiguration.java deleted file mode 100644 index cf558be02f..0000000000 --- a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClientAutoConfiguration.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2013-2021 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.kubernetes.discovery; - -import org.springframework.beans.factory.InitializingBean; -import org.springframework.boot.actuate.health.HealthIndicator; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnCloudPlatform; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass; -import org.springframework.boot.cloud.CloudPlatform; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.web.client.RestTemplateBuilder; -import org.springframework.cloud.client.ConditionalOnDiscoveryEnabled; -import org.springframework.cloud.client.ConditionalOnDiscoveryHealthIndicatorEnabled; -import org.springframework.cloud.client.ConditionalOnReactiveDiscoveryEnabled; -import org.springframework.cloud.client.discovery.DiscoveryClient; -import org.springframework.cloud.client.discovery.ReactiveDiscoveryClient; -import org.springframework.cloud.client.discovery.event.InstanceRegisteredEvent; -import org.springframework.cloud.client.discovery.health.DiscoveryClientHealthIndicatorProperties; -import org.springframework.cloud.client.discovery.health.reactive.ReactiveDiscoveryClientHealthIndicator; -import org.springframework.cloud.kubernetes.commons.discovery.ConditionalOnKubernetesDiscoveryEnabled; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.reactive.function.client.WebClient; - -/** - * @author Ryan Baxter - * @deprecated in favor of {@link KubernetesDiscoveryClientBlockingAutoConfiguration} and - * {@link KubernetesDiscoveryClientReactiveAutoConfiguration} - */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnDiscoveryEnabled -@ConditionalOnCloudPlatform(CloudPlatform.KUBERNETES) -@ConditionalOnKubernetesDiscoveryEnabled -@EnableConfigurationProperties({ DiscoveryClientHealthIndicatorProperties.class, - KubernetesDiscoveryClientProperties.class }) -@Deprecated(forRemoval = true) -public class KubernetesDiscoveryClientAutoConfiguration { - - @Configuration(proxyBeanMethods = false) - public static class Servlet { - - @Bean - @ConditionalOnMissingClass("org.springframework.web.reactive.function.client.WebClient") - @ConditionalOnMissingBean(RestTemplate.class) - public RestTemplate restTemplate() { - return new RestTemplateBuilder().build(); - } - - @Bean - @ConditionalOnMissingClass("org.springframework.web.reactive.function.client.WebClient") - public DiscoveryClient kubernetesDiscoveryClient(RestTemplate restTemplate, - KubernetesDiscoveryClientProperties properties) { - return new KubernetesDiscoveryClient(restTemplate, properties); - } - - @Bean - @ConditionalOnClass({ HealthIndicator.class }) - @ConditionalOnDiscoveryHealthIndicatorEnabled - public InitializingBean indicatorInitializer(ApplicationEventPublisher applicationEventPublisher, - ApplicationContext applicationContext) { - return () -> applicationEventPublisher - .publishEvent(new InstanceRegisteredEvent<>(applicationContext.getId(), null)); - - } - - } - - @Configuration(proxyBeanMethods = false) - @ConditionalOnReactiveDiscoveryEnabled - public static class Reactive { - - @Bean - @ConditionalOnClass(name = { "org.springframework.web.reactive.function.client.WebClient" }) - @ConditionalOnMissingBean(WebClient.Builder.class) - public WebClient.Builder webClientBuilder() { - return WebClient.builder(); - } - - @Bean - @ConditionalOnClass(name = { "org.springframework.web.reactive.function.client.WebClient" }) - public ReactiveDiscoveryClient kubernetesReactiveDiscoveryClient(WebClient.Builder webClientBuilder, - KubernetesDiscoveryClientProperties properties) { - return new KubernetesReactiveDiscoveryClient(webClientBuilder, properties); - } - - @Bean - @ConditionalOnClass(name = "org.springframework.boot.actuate.health.ReactiveHealthIndicator") - @ConditionalOnDiscoveryHealthIndicatorEnabled - public ReactiveDiscoveryClientHealthIndicator kubernetesReactiveDiscoveryClientHealthIndicator( - KubernetesReactiveDiscoveryClient client, DiscoveryClientHealthIndicatorProperties properties, - ApplicationContext applicationContext) { - ReactiveDiscoveryClientHealthIndicator healthIndicator = new ReactiveDiscoveryClientHealthIndicator(client, - properties); - InstanceRegisteredEvent event = new InstanceRegisteredEvent(applicationContext.getId(), null); - healthIndicator.onApplicationEvent(event); - return healthIndicator; - } - - } - -} diff --git a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClientProperties.java b/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClientProperties.java deleted file mode 100644 index c93de0d1e9..0000000000 --- a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClientProperties.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2013-2021 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.kubernetes.discovery; - -import java.util.Set; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * @author Ryan Baxter - * @deprecated use - * {@link org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryProperties} - * instead. - */ -@Deprecated(forRemoval = true) -@ConfigurationProperties("spring.cloud.kubernetes.discovery") -public class KubernetesDiscoveryClientProperties { - - private String discoveryServerUrl; - - private boolean enabled = true; - - /** - * If set then only the services and endpoints matching these namespaces will be - * fetched from the Kubernetes API server. - */ - private Set namespaces = Set.of(); - - public String getDiscoveryServerUrl() { - return discoveryServerUrl; - } - - public void setDiscoveryServerUrl(String discoveryServerUrl) { - this.discoveryServerUrl = discoveryServerUrl; - } - - public boolean isEnabled() { - return enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - Set getNamespaces() { - return namespaces; - } - - void setNamespaces(Set namespaces) { - this.namespaces = namespaces; - } - -} diff --git a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesReactiveDiscoveryClient.java b/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesReactiveDiscoveryClient.java index b5fd31bcbd..b3ff5bf042 100644 --- a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesReactiveDiscoveryClient.java +++ b/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesReactiveDiscoveryClient.java @@ -34,15 +34,6 @@ public class KubernetesReactiveDiscoveryClient implements ReactiveDiscoveryClien private final WebClient webClient; - @Deprecated(forRemoval = true) - public KubernetesReactiveDiscoveryClient(WebClient.Builder webClientBuilder, - KubernetesDiscoveryClientProperties properties) { - if (!StringUtils.hasText(properties.getDiscoveryServerUrl())) { - throw new DiscoveryServerUrlInvalidException(); - } - webClient = webClientBuilder.baseUrl(properties.getDiscoveryServerUrl()).build(); - } - KubernetesReactiveDiscoveryClient(WebClient.Builder webClientBuilder, KubernetesDiscoveryProperties properties) { if (!StringUtils.hasText(properties.discoveryServerUrl())) { throw new DiscoveryServerUrlInvalidException(); diff --git a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesServiceInstance.java b/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesServiceInstance.java deleted file mode 100644 index 370d8c0210..0000000000 --- a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesServiceInstance.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright 2013-2021 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.kubernetes.discovery; - -import java.net.URI; -import java.util.Map; -import java.util.Objects; - -import org.springframework.cloud.client.ServiceInstance; - -/** - * @author Ryan Baxter - */ -@Deprecated(forRemoval = true) -public class KubernetesServiceInstance implements ServiceInstance { - - private String instanceId; - - private String serviceId; - - private String host; - - private int port; - - private boolean secure; - - private URI uri; - - private Map metadata; - - private String scheme; - - private String namespace; - - public KubernetesServiceInstance() { - } - - public KubernetesServiceInstance(String instanceId, String serviceId, String host, int port, boolean secure, - URI uri, Map metadata, String scheme, String namespace) { - this.instanceId = instanceId; - this.serviceId = serviceId; - this.host = host; - this.port = port; - this.secure = secure; - this.uri = uri; - this.metadata = metadata; - this.scheme = scheme; - this.namespace = namespace; - } - - @Override - public String getInstanceId() { - return instanceId; - } - - @Override - public String getServiceId() { - return serviceId; - } - - @Override - public String getHost() { - return host; - } - - @Override - public int getPort() { - return port; - } - - @Override - public boolean isSecure() { - return secure; - } - - @Override - public URI getUri() { - return uri; - } - - @Override - public Map getMetadata() { - return metadata; - } - - public void setInstanceId(String instanceId) { - this.instanceId = instanceId; - } - - public void setServiceId(String serviceId) { - this.serviceId = serviceId; - } - - public void setHost(String host) { - this.host = host; - } - - public void setPort(int port) { - this.port = port; - } - - public void setSecure(boolean secure) { - this.secure = secure; - } - - public void setUri(URI uri) { - this.uri = uri; - } - - public void setMetadata(Map metadata) { - this.metadata = metadata; - } - - public void setScheme(String scheme) { - this.scheme = scheme; - } - - public String getNamespace() { - return namespace; - } - - public void setNamespace(String namespace) { - this.namespace = namespace; - } - - @Override - public String getScheme() { - return scheme; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - KubernetesServiceInstance that = (KubernetesServiceInstance) o; - return getPort() == that.getPort() && isSecure() == that.isSecure() - && Objects.equals(getInstanceId(), that.getInstanceId()) - && Objects.equals(getServiceId(), that.getServiceId()) && Objects.equals(getHost(), that.getHost()) - && Objects.equals(getUri(), that.getUri()) && Objects.equals(getMetadata(), that.getMetadata()) - && Objects.equals(getScheme(), that.getScheme()) && Objects.equals(getNamespace(), that.getNamespace()); - } - - @Override - public int hashCode() { - return Objects.hash(getInstanceId(), getServiceId(), getHost(), getPort(), isSecure(), getUri(), getMetadata(), - getScheme(), getNamespace()); - } - -} diff --git a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/Service.java b/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/Service.java deleted file mode 100644 index 43c97c87f7..0000000000 --- a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/Service.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2013-2021 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.kubernetes.discovery; - -import java.util.List; - -/** - * @author Ryan Baxter - */ -@Deprecated(forRemoval = true) -public class Service { - - private String name; - - private List serviceInstances = List.of(); - - public Service() { - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public List getServiceInstances() { - return serviceInstances; - } - - public void setServiceInstances(List serviceInstances) { - this.serviceInstances = serviceInstances; - } - -} diff --git a/spring-cloud-kubernetes-discovery/src/test/java/org/springframework/cloud/kubernetes/discovery/KubernetesReactiveDiscoveryClientTests.java b/spring-cloud-kubernetes-discovery/src/test/java/org/springframework/cloud/kubernetes/discovery/KubernetesReactiveDiscoveryClientTests.java index 7f267cd87b..a8826e7fd2 100644 --- a/spring-cloud-kubernetes-discovery/src/test/java/org/springframework/cloud/kubernetes/discovery/KubernetesReactiveDiscoveryClientTests.java +++ b/spring-cloud-kubernetes-discovery/src/test/java/org/springframework/cloud/kubernetes/discovery/KubernetesReactiveDiscoveryClientTests.java @@ -107,7 +107,6 @@ static void beforeAll() { @Test void getInstances() { - KubernetesDiscoveryProperties properties = new KubernetesDiscoveryProperties(true, true, Set.of(), true, 60, false, null, Set.of(), Map.of(), null, KubernetesDiscoveryProperties.Metadata.DEFAULT, 0, false, false, wireMockServer.baseUrl());