|
32 | 32 | import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider; |
33 | 33 | import org.springframework.cloud.kubernetes.commons.config.ConfigUtils; |
34 | 34 | import org.springframework.cloud.kubernetes.commons.config.MultipleSourcesContainer; |
35 | | -import org.springframework.cloud.kubernetes.commons.config.NamespaceResolutionFailedException; |
36 | 35 | import org.springframework.cloud.kubernetes.commons.config.StrippedSourceContainer; |
37 | 36 | import org.springframework.cloud.kubernetes.commons.config.reload.ConfigReloadProperties; |
38 | 37 | import org.springframework.core.env.Environment; |
39 | | -import org.springframework.util.StringUtils; |
| 38 | + |
| 39 | +import static org.springframework.cloud.kubernetes.client.KubernetesClientUtils.getApplicationNamespace; |
40 | 40 |
|
41 | 41 | /** |
42 | 42 | * @author Ryan Baxter |
@@ -65,44 +65,6 @@ public static Set<String> namespaces(KubernetesNamespaceProvider provider, Confi |
65 | 65 | return namespaces; |
66 | 66 | } |
67 | 67 |
|
68 | | - /** |
69 | | - * this method does the namespace resolution for both config map and secrets |
70 | | - * implementations. It tries these places to find the namespace: |
71 | | - * |
72 | | - * <pre> |
73 | | - * 1. from a normalized source (which can be null) |
74 | | - * 2. from a property 'spring.cloud.kubernetes.client.namespace', if such is present |
75 | | - * 3. from a String residing in a file denoted by `spring.cloud.kubernetes.client.serviceAccountNamespacePath` |
76 | | - * property, if such is present |
77 | | - * 4. from a String residing in `/var/run/secrets/kubernetes.io/serviceaccount/namespace` file, |
78 | | - * if such is present (kubernetes default path) |
79 | | - * </pre> |
80 | | - * |
81 | | - * If any of the above fail, we throw a NamespaceResolutionFailedException. |
82 | | - * @param namespace normalized namespace |
83 | | - * @param configurationTarget Config Map/Secret |
84 | | - * @param provider the provider which computes the namespace |
85 | | - * @return application namespace |
86 | | - * @throws NamespaceResolutionFailedException when namespace could not be resolved |
87 | | - */ |
88 | | - static String getApplicationNamespace(String namespace, String configurationTarget, |
89 | | - KubernetesNamespaceProvider provider) { |
90 | | - if (StringUtils.hasText(namespace)) { |
91 | | - LOG.debug(configurationTarget + " namespace : " + namespace); |
92 | | - return namespace; |
93 | | - } |
94 | | - |
95 | | - if (provider != null) { |
96 | | - String providerNamespace = provider.getNamespace(); |
97 | | - if (StringUtils.hasText(providerNamespace)) { |
98 | | - LOG.debug(configurationTarget + " namespace from provider : " + namespace); |
99 | | - return providerNamespace; |
100 | | - } |
101 | | - } |
102 | | - |
103 | | - throw new NamespaceResolutionFailedException("unresolved namespace"); |
104 | | - } |
105 | | - |
106 | 68 | /** |
107 | 69 | * <pre> |
108 | 70 | * 1. read all secrets in the provided namespace |
|
0 commit comments