Skip to content

Commit 310ef6e

Browse files
committed
Rename volumemount -> configtree
Closes gh-22941
1 parent 5579f9d commit 310ef6e

File tree

11 files changed

+87
-87
lines changed

11 files changed

+87
-87
lines changed

spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ Locations will be processed in the order that they are defined, with later impor
675675
[TIP]
676676
====
677677
Spring Boot includes pluggable API that allows various different location addresses to be supported.
678-
By default you can import Java Properties, YAML and volume mounts.
678+
By default you can import Java Properties, YAML and "`<<boot-features-external-config-files-configtree, configuration trees>>`".
679679
680680
Third-party jars can offer support for additional technologies (there's no requirement for files to be local).
681681
For example, you can imagine config data being from external stores such as Consul, Apache ZooKeeper or Netflix Archaius.
@@ -685,8 +685,8 @@ If you want to support your own locations, see the `ConfigDataLocationResolver`
685685

686686

687687

688-
[[boot-features-external-config-files-voumemounts]]
689-
==== Using Volume Mount Properties
688+
[[boot-features-external-config-files-configtree]]
689+
==== Using Configuration Trees
690690
When running applications on a cloud platform (such as Kubernetes) you often need to read config values that the platform supplies.
691691
It's not uncommon to use environment variables for such purposes, but this can have drawbacks, especially if the value is supposed to be kept secret.
692692

@@ -696,10 +696,10 @@ For example, Kubernetes can volume mount both https://kubernetes.io/docs/tasks/c
696696
There are two common volume mount patterns that can be use:
697697

698698
. A single file contains a complete set of properties (usually written as YAML).
699-
. Multiple files are written to a directory with the filename becoming the '`key`' and the contents becoming the '`value`'.
699+
. Multiple files are written to a directory tree, with the filename becoming the '`key`' and the contents becoming the '`value`'.
700700

701701
For the first case, you can import the YAML or Properties file directly using `spring.config.import` as described <<boot-features-external-config-files-importing,above>>.
702-
For the second case, you need to use the `volumemount:` prefix so that Spring Boot knows it needs to expose all the files as properties.
702+
For the second case, you need to use the `configtree:` prefix so that Spring Boot knows it needs to expose all the files as properties.
703703

704704
As an example, let's imagine that Kubernetes has mounted the following volume:
705705

@@ -718,12 +718,12 @@ To import these properties, you can add the following to your `application.prope
718718

719719
[source,properties,indent=0]
720720
----
721-
spring.config.import=volumemount:/etc/config
721+
spring.config.import=configtree:/etc/config
722722
----
723723

724724
You can then access or inject `myapp.username` and `myapp.password` properties from the `Environment` in the usual way.
725725

726-
TIP: Volume mounted values can be bound to both string `String` and `byte[]` types depending on the contents expected.
726+
TIP: Configuration tree values can be bound to both string `String` and `byte[]` types depending on the contents expected.
727727

728728

729729

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@
2020
import java.nio.file.Path;
2121
import java.util.Collections;
2222

23-
import org.springframework.boot.env.VolumeMountDirectoryPropertySource;
23+
import org.springframework.boot.env.ConfigTreePropertySource;
2424

2525
/**
26-
* {@link ConfigDataLoader} for directory locations mounted as volumes.
26+
* {@link ConfigDataLoader} for config tree locations.
2727
*
2828
* @author Madhura Bhave
2929
* @author Phillip Webb
3030
*/
31-
class VolumeMountConfigDataLoader implements ConfigDataLoader<VolumeMountConfigDataLocation> {
31+
class ConfigTreeConfigDataLoader implements ConfigDataLoader<ConfigTreeConfigDataLocation> {
3232

3333
@Override
34-
public ConfigData load(VolumeMountConfigDataLocation location) throws IOException {
34+
public ConfigData load(ConfigTreeConfigDataLocation location) throws IOException {
3535
Path path = location.getPath();
36-
String name = "Volume mount config '" + path + "'";
37-
VolumeMountDirectoryPropertySource source = new VolumeMountDirectoryPropertySource(name, path);
36+
String name = "Config tree '" + path + "'";
37+
ConfigTreePropertySource source = new ConfigTreePropertySource(name, path);
3838
return new ConfigData(Collections.singletonList(source));
3939
}
4040

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,21 @@
2020
import java.nio.file.Paths;
2121
import java.util.Objects;
2222

23+
import org.springframework.boot.env.ConfigTreePropertySource;
2324
import org.springframework.util.Assert;
2425

2526
/**
26-
* {@link ConfigDataLocation} backed by a directory mounted as a volume.
27+
* {@link ConfigDataLocation} backed by a config tree directory.
2728
*
2829
* @author Madhura Bhave
2930
* @author Phillip Webb
31+
* @see ConfigTreePropertySource
3032
*/
31-
class VolumeMountConfigDataLocation extends ConfigDataLocation {
33+
class ConfigTreeConfigDataLocation extends ConfigDataLocation {
3234

3335
private final Path path;
3436

35-
VolumeMountConfigDataLocation(String path) {
37+
ConfigTreeConfigDataLocation(String path) {
3638
Assert.notNull(path, "Path must not be null");
3739
this.path = Paths.get(path).toAbsolutePath();
3840
}
@@ -49,7 +51,7 @@ public boolean equals(Object obj) {
4951
if (obj == null || getClass() != obj.getClass()) {
5052
return false;
5153
}
52-
VolumeMountConfigDataLocation other = (VolumeMountConfigDataLocation) obj;
54+
ConfigTreeConfigDataLocation other = (ConfigTreeConfigDataLocation) obj;
5355
return Objects.equals(this.path, other.path);
5456
}
5557

@@ -60,7 +62,7 @@ public int hashCode() {
6062

6163
@Override
6264
public String toString() {
63-
return "volume mount [" + this.path + "]";
65+
return "config tree [" + this.path + "]";
6466
}
6567

6668
}
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,23 @@
2020
import java.util.List;
2121

2222
/**
23-
* {@link ConfigDataLocationResolver} for volume mounted locations such as Kubernetes
24-
* ConfigMaps and Secrets.
23+
* {@link ConfigDataLocationResolver} for config tree locations.
2524
*
2625
* @author Madhura Bhave
2726
* @author Phillip Webb
2827
*/
29-
class VolumeMountConfigDataLocationResolver implements ConfigDataLocationResolver<VolumeMountConfigDataLocation> {
28+
class ConfigTreeConfigDataLocationResolver implements ConfigDataLocationResolver<ConfigTreeConfigDataLocation> {
3029

31-
private static final String PREFIX = "volumemount:";
30+
private static final String PREFIX = "configtree:";
3231

3332
@Override
3433
public boolean isResolvable(ConfigDataLocationResolverContext context, String location) {
3534
return location.startsWith(PREFIX);
3635
}
3736

3837
@Override
39-
public List<VolumeMountConfigDataLocation> resolve(ConfigDataLocationResolverContext context, String location) {
40-
VolumeMountConfigDataLocation resolved = new VolumeMountConfigDataLocation(location.substring(PREFIX.length()));
38+
public List<ConfigTreeConfigDataLocation> resolve(ConfigDataLocationResolverContext context, String location) {
39+
ConfigTreeConfigDataLocation resolved = new ConfigTreeConfigDataLocation(location.substring(PREFIX.length()));
4140
return Collections.singletonList(resolved);
4241
}
4342

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@
4646
import org.springframework.util.StringUtils;
4747

4848
/**
49-
* {@link PropertySource} backed by a directory that contains files for each value. The
50-
* {@link PropertySource} will recursively scan a given source directory and expose a
49+
* {@link PropertySource} backed by a directory tree that contains files for each value.
50+
* The {@link PropertySource} will recursively scan a given source directory and expose a
5151
* property for each file found. The property name will be the filename, and the property
5252
* value will be the contents of the file.
5353
* <p>
5454
* Directories are only scanned when the source is first created. The directory is not
5555
* monitored for updates, so files should not be added or removed. However, the contents
5656
* of a file can be updated as long as the property source was created with a
57-
* {@link Option#ALWAYS_READ} option. Nested folders are included in the source, but with
58-
* a {@code '.'} rather than {@code '/'} used as the path separator.
57+
* {@link Option#ALWAYS_READ} option. Nested directories are included in the source, but
58+
* with a {@code '.'} rather than {@code '/'} used as the path separator.
5959
* <p>
6060
* Property values are returned as {@link Value} instances which allows them to be treated
6161
* either as an {@link InputStreamSource} or as a {@link CharSequence}. In addition, if
@@ -69,7 +69,7 @@
6969
* @author Phillip Webb
7070
* @since 2.4.0
7171
*/
72-
public class VolumeMountDirectoryPropertySource extends EnumerablePropertySource<Path> implements OriginLookup<String> {
72+
public class ConfigTreePropertySource extends EnumerablePropertySource<Path> implements OriginLookup<String> {
7373

7474
private static final int MAX_DEPTH = 100;
7575

@@ -80,25 +80,25 @@ public class VolumeMountDirectoryPropertySource extends EnumerablePropertySource
8080
private final Set<Option> options;
8181

8282
/**
83-
* Create a new {@link VolumeMountDirectoryPropertySource} instance.
83+
* Create a new {@link ConfigTreePropertySource} instance.
8484
* @param name the name of the property source
8585
* @param sourceDirectory the underlying source directory
8686
*/
87-
public VolumeMountDirectoryPropertySource(String name, Path sourceDirectory) {
87+
public ConfigTreePropertySource(String name, Path sourceDirectory) {
8888
this(name, sourceDirectory, EnumSet.noneOf(Option.class));
8989
}
9090

9191
/**
92-
* Create a new {@link VolumeMountDirectoryPropertySource} instance.
92+
* Create a new {@link ConfigTreePropertySource} instance.
9393
* @param name the name of the property source
9494
* @param sourceDirectory the underlying source directory
9595
* @param options the property source options
9696
*/
97-
public VolumeMountDirectoryPropertySource(String name, Path sourceDirectory, Option... options) {
97+
public ConfigTreePropertySource(String name, Path sourceDirectory, Option... options) {
9898
this(name, sourceDirectory, EnumSet.copyOf(Arrays.asList(options)));
9999
}
100100

101-
private VolumeMountDirectoryPropertySource(String name, Path sourceDirectory, Set<Option> options) {
101+
private ConfigTreePropertySource(String name, Path sourceDirectory, Set<Option> options) {
102102
super(name, sourceDirectory);
103103
Assert.isTrue(Files.exists(sourceDirectory), () -> "Directory '" + sourceDirectory + "' does not exist");
104104
Assert.isTrue(Files.isDirectory(sourceDirectory), () -> "File '" + sourceDirectory + "' is not a directory");

spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@
894894
"value": "classpath:"
895895
},
896896
{
897-
"value": "volumemount:"
897+
"value": "configtree:"
898898
}
899899
],
900900
"providers": [

spring-boot-project/spring-boot/src/main/resources/META-INF/spring.factories

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ org.springframework.boot.env.YamlPropertySourceLoader
55

66
# ConfigData Location Resolvers
77
org.springframework.boot.context.config.ConfigDataLocationResolver=\
8-
org.springframework.boot.context.config.ResourceConfigDataLocationResolver,\
9-
org.springframework.boot.context.config.VolumeMountConfigDataLocationResolver
8+
org.springframework.boot.context.config.ConfigTreeConfigDataLocationResolver,\
9+
org.springframework.boot.context.config.ResourceConfigDataLocationResolver
1010

1111
# ConfigData Loaders
1212
org.springframework.boot.context.config.ConfigDataLoader=\
13-
org.springframework.boot.context.config.ResourceConfigDataLoader,\
14-
org.springframework.boot.context.config.VolumeMountConfigDataLoader
13+
org.springframework.boot.context.config.ConfigTreeConfigDataLoader,\
14+
org.springframework.boot.context.config.ResourceConfigDataLoader
1515

1616
# Run Listeners
1717
org.springframework.boot.SpringApplicationRunListener=\
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
import static org.assertj.core.api.Assertions.assertThat;
3131

3232
/**
33-
* Tests for {@link VolumeMountConfigDataLoader}.
33+
* Tests for {@link ConfigTreeConfigDataLoader}.
3434
*
3535
* @author Madhura Bhave
3636
* @author Phillip Webb
3737
*/
38-
public class VolumeMountConfigDataLoaderTests {
38+
public class ConfigTreeConfigDataLoaderTests {
3939

40-
private VolumeMountConfigDataLoader loader = new VolumeMountConfigDataLoader();
40+
private ConfigTreeConfigDataLoader loader = new ConfigTreeConfigDataLoader();
4141

4242
@TempDir
4343
Path directory;
@@ -47,11 +47,11 @@ void loadReturnsConfigDataWithPropertySource() throws IOException {
4747
File file = this.directory.resolve("hello").toFile();
4848
file.getParentFile().mkdirs();
4949
FileCopyUtils.copy("world".getBytes(StandardCharsets.UTF_8), file);
50-
VolumeMountConfigDataLocation location = new VolumeMountConfigDataLocation(this.directory.toString());
50+
ConfigTreeConfigDataLocation location = new ConfigTreeConfigDataLocation(this.directory.toString());
5151
ConfigData configData = this.loader.load(location);
5252
assertThat(configData.getPropertySources().size()).isEqualTo(1);
5353
PropertySource<?> source = configData.getPropertySources().get(0);
54-
assertThat(source.getName()).isEqualTo("Volume mount config '" + this.directory.toString() + "'");
54+
assertThat(source.getName()).isEqualTo("Config tree '" + this.directory.toString() + "'");
5555
assertThat(source.getProperty("hello").toString()).isEqualTo("world");
5656
}
5757

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@
2525
import static org.mockito.Mockito.mock;
2626

2727
/**
28-
* Tests for {@link VolumeMountConfigDataLocationResolver}.
28+
* Tests for {@link ConfigTreeConfigDataLocationResolver}.
2929
*
3030
* @author Madhura Bhave
3131
* @author Phillip Webb
3232
*/
33-
class VolumeMountConfigDataLocationResolverTests {
33+
class ConfigTreeConfigDataLocationResolverTests {
3434

35-
private VolumeMountConfigDataLocationResolver resolver = new VolumeMountConfigDataLocationResolver();
35+
private ConfigTreeConfigDataLocationResolver resolver = new ConfigTreeConfigDataLocationResolver();
3636

3737
private ConfigDataLocationResolverContext context = mock(ConfigDataLocationResolverContext.class);
3838

3939
@Test
4040
void isResolvableWhenPrefixMatchesReturnsTrue() {
41-
assertThat(this.resolver.isResolvable(this.context, "volumemount:/etc/config")).isTrue();
41+
assertThat(this.resolver.isResolvable(this.context, "configtree:/etc/config")).isTrue();
4242
}
4343

4444
@Test
@@ -49,10 +49,10 @@ void isResolvableWhenPrefixDoesNotMatchReturnsFalse() {
4949

5050
@Test
5151
void resolveReturnsConfigVolumeMountLocation() {
52-
List<VolumeMountConfigDataLocation> locations = this.resolver.resolve(this.context, "volumemount:/etc/config");
52+
List<ConfigTreeConfigDataLocation> locations = this.resolver.resolve(this.context, "configtree:/etc/config");
5353
assertThat(locations.size()).isEqualTo(1);
5454
assertThat(locations).extracting(Object::toString)
55-
.containsExactly("volume mount [" + new File("/etc/config").getAbsolutePath() + "]");
55+
.containsExactly("config tree [" + new File("/etc/config").getAbsolutePath() + "]");
5656
}
5757

5858
}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,37 +24,37 @@
2424
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
2525

2626
/**
27-
* Tests for {@link VolumeMountConfigDataLocation}.
27+
* Tests for {@link ConfigTreeConfigDataLocation}.
2828
*
2929
* @author Madhura Bhave
3030
* @author Phillip Webb
3131
*/
32-
public class VolumeMountConfigDataLocationTests {
32+
public class ConfigTreeConfigDataLocationTests {
3333

3434
@Test
3535
void constructorWhenPathIsNullThrowsException() {
36-
assertThatIllegalArgumentException().isThrownBy(() -> new VolumeMountConfigDataLocation(null))
36+
assertThatIllegalArgumentException().isThrownBy(() -> new ConfigTreeConfigDataLocation(null))
3737
.withMessage("Path must not be null");
3838
}
3939

4040
@Test
4141
void equalsWhenPathIsTheSameReturnsTrue() {
42-
VolumeMountConfigDataLocation location = new VolumeMountConfigDataLocation("/etc/config");
43-
VolumeMountConfigDataLocation other = new VolumeMountConfigDataLocation("/etc/config");
42+
ConfigTreeConfigDataLocation location = new ConfigTreeConfigDataLocation("/etc/config");
43+
ConfigTreeConfigDataLocation other = new ConfigTreeConfigDataLocation("/etc/config");
4444
assertThat(location).isEqualTo(other);
4545
}
4646

4747
@Test
4848
void equalsWhenPathIsDifferentReturnsFalse() {
49-
VolumeMountConfigDataLocation location = new VolumeMountConfigDataLocation("/etc/config");
50-
VolumeMountConfigDataLocation other = new VolumeMountConfigDataLocation("other-location");
49+
ConfigTreeConfigDataLocation location = new ConfigTreeConfigDataLocation("/etc/config");
50+
ConfigTreeConfigDataLocation other = new ConfigTreeConfigDataLocation("other-location");
5151
assertThat(location).isNotEqualTo(other);
5252
}
5353

5454
@Test
5555
void toStringReturnsDescriptiveString() {
56-
VolumeMountConfigDataLocation location = new VolumeMountConfigDataLocation("/etc/config");
57-
assertThat(location.toString()).isEqualTo("volume mount [" + new File("/etc/config").getAbsolutePath() + "]");
56+
ConfigTreeConfigDataLocation location = new ConfigTreeConfigDataLocation("/etc/config");
57+
assertThat(location.toString()).isEqualTo("config tree [" + new File("/etc/config").getAbsolutePath() + "]");
5858
}
5959

6060
}

0 commit comments

Comments
 (0)