-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify config data code a bit (CAN ONLY GO IN THE NEXT MAJOR RELEASE) #1189
base: main
Are you sure you want to change the base?
Changes from 4 commits
251002b
fedeb17
aded605
004f95b
10168be
dc811cf
3dfe77d
619c8d0
12ca211
a91c1e1
be2e809
1c84e33
e6f357c
1319fe7
ce3f543
9424c2e
bd1d38d
cddd550
1e266af
f8d34f2
31d2fb8
212da95
2e7e421
fa9fd09
2150c47
428372d
9ca883d
22f3f51
bb44f4b
9714f2c
4e6ebf1
0f9cb3d
b7304fd
6e60174
78c5575
8e6edff
5eb5c51
cdcc4b7
48f7cb0
94faf4e
8a18085
d19b997
a6b2ca8
3e53dd4
3ed982a
b43ed66
e4cab39
2823660
ba4cab0
a88fe82
bbc6e30
ab5796b
80c100c
4763bdc
970c875
edcc996
82d5f2f
2b56337
dcbc5de
d48d61f
db8d950
ae31faf
dfca45b
34648eb
1eacf6c
c77b86a
0e9f1ad
5c244f5
6810e8f
dc62bbc
5d5ea38
f31d741
8de4b9c
7715ca5
40c4514
67d1cc4
622cc94
78734c1
c2ad21e
1d853d2
5e985c5
c982060
8a42c15
6a07b13
e9077e2
fc06861
5a7695a
d23f582
8a5243c
b4b7bf4
4636bc8
b65a7d4
e13bcd3
cbf83c4
ccf2cf4
7eeb454
0515920
565679c
3a86923
f92960b
3dd0260
85e5e49
a36b287
8d4c395
0327416
c998899
1408d44
b479c3f
2925ee1
0340ca5
71e28ba
2caa179
af7cdbb
af3a12b
f5a27dc
494454a
cc54bc1
add0f67
9772622
df2d07e
02f6bc6
1029ecc
b6a4b45
51999ad
00a559d
de460ea
882f9c1
6c9071e
d3428ef
09c10bb
3615396
98cde54
116c199
9463a05
f1447cd
07d99a5
14b165b
82f21f0
3ce8fac
41eaa8d
d7a2b33
4f89298
ee1031d
1b1c164
f6707d5
cd61725
9930c7d
ca071e3
0043006
e7384a8
4e292ec
a2f496c
3129276
f04ed58
1c90fc2
fa0888a
ab680d1
32e3556
4023ca3
cca5bed
7ed7f5d
3be81b7
dd710ec
4fdd06a
bf61054
81efd8f
f059697
013cc6a
13ff3b3
5bd3f88
88021bb
dcf4e62
a600c69
3f1a180
3d22d02
85ca441
65acfe6
5526b50
0c131b5
af8a8ee
9c74e14
3529141
b5477a7
a410606
8c38ece
dcb8fb4
73e9765
1a3a4d9
926d2b0
02737d4
37c0ba2
24defb8
14c9780
719ccbc
5784dfa
397d9af
ecf13b8
658a5f6
4eb0e3c
256332d
d64dd18
2861ea5
93c95cb
9fffd36
a84bef6
a7000eb
219289f
ab12e1d
b32e8a0
2ddaca9
8ee9390
698a120
bdf347b
e3e6334
152f6bf
a279c0c
f6e608e
6a51e1a
a02efb2
5864ab1
d872393
e690faf
b178548
56d4b40
554112b
ae40722
af673ba
7c98947
9740bef
9dd5bbf
82b51e5
f9330c3
e3ca2f8
ffb7e19
f96a8fa
2847f75
a1fd41a
7468875
c416eea
6099d1f
7c5a312
ed2080b
d4bd1a6
66f929c
0355d7a
5dc9c06
bf0cc39
725d227
f342faf
ec3930e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright 2013-2023 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.commons.config.configdata; | ||
|
||
import org.springframework.boot.ConfigurableBootstrapContext; | ||
import org.springframework.boot.context.config.ConfigDataLocationResolverContext; | ||
import org.springframework.cloud.kubernetes.commons.KubernetesClientProperties; | ||
import org.springframework.cloud.kubernetes.commons.config.ConfigMapConfigProperties; | ||
import org.springframework.cloud.kubernetes.commons.config.SecretsConfigProperties; | ||
|
||
import static org.springframework.cloud.kubernetes.commons.config.ConfigUtils.registerSingle; | ||
|
||
public record ConfigDataProperties(KubernetesClientProperties clientProperties, | ||
ConfigMapConfigProperties configMapProperties, SecretsConfigProperties secretsProperties) { | ||
|
||
static Registrar of(ConfigDataLocationResolverContext context) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the idea here is once you call |
||
Properties all = Properties.of(context); | ||
return () -> { | ||
registerProperties(context, all.clientProperties(), all.configMapProperties(), | ||
all.secretsConfigProperties()); | ||
return new ConfigDataProperties(all.clientProperties(), all.configMapProperties(), | ||
all.secretsConfigProperties()); | ||
}; | ||
} | ||
|
||
private static void registerProperties(ConfigDataLocationResolverContext resolverContext, | ||
KubernetesClientProperties clientProperties, ConfigMapConfigProperties configMapProperties, | ||
SecretsConfigProperties secretsProperties) { | ||
|
||
ConfigurableBootstrapContext bootstrapContext = resolverContext.getBootstrapContext(); | ||
registerSingle(bootstrapContext, KubernetesClientProperties.class, clientProperties, | ||
"configDataKubernetesClientProperties"); | ||
|
||
registerSingle(bootstrapContext, ConfigMapConfigProperties.class, configMapProperties, | ||
"configDataConfigMapConfigProperties"); | ||
|
||
registerSingle(bootstrapContext, SecretsConfigProperties.class, secretsProperties, | ||
"configDataSecretsConfigProperties"); | ||
} | ||
|
||
@FunctionalInterface | ||
interface Registrar { | ||
|
||
ConfigDataProperties register(); | ||
|
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done two things here:
instance
that is passed is null, so that it slightly simplifies callers.!bootstrapContext.isRegistered(cls)
. We were already doing that viaregsiterIfAbsent
, but than we were callingaddCloseListener
, no matter if it was registered or not. Not a big deal, but this is cleaner, imo.