Redis Binding

This change expands the Redis bindings to handle more properties.

[resolves #7]

Signed-off-by: Ben Hale <bhale@vmware.com>
This commit is contained in:
Ben Hale
2020-05-11 16:06:18 -07:00
parent 888b855f78
commit 2b4b1da636
3 changed files with 36 additions and 4 deletions

View File

@@ -112,9 +112,17 @@ Disable Property: `org.springframework.cloud.bindings.boot.redis.enable`
| Property | Value
| -------- | -----
| `spring.datasource.host` | `{secret.host}`
| `spring.datasource.password` | `{secret.password}`
| `spring.datasource.port` | `{secret.port}`
| `spring.redis.client-name` | `{secret.client-name}`
| `spring.redis.cluster.max-redirects` | `{secret.cluster.max-redirects}`
| `spring.redis.cluster.nodes` | `{secret.cluster-nodes}`
| `spring.redis.database` | `{secret.database}`
| `spring.redis.host` | `{secret.host}`
| `spring.redis.password` | `{secret.password}`
| `spring.redis.port` | `{secret.port}`
| `spring.redis.sentinel.master` | `{secret.sentinel.master}`
| `spring.redis.sentinel.nodes` | `{secret.sentinel.nodes}`
| `spring.redis.ssl` | `{secret.ssl}`
| `spring.redis.url` | `{secret.url}`
### Oracle RDBMS
Kind: `SQLServer`

View File

@@ -43,9 +43,17 @@ public final class RedisBindingsPropertiesProcessor implements BindingsPropertie
bindings.filterBindings(KIND).forEach(binding -> {
MapMapper map = new MapMapper(binding.getSecret(), properties);
map.from("client-name").to("spring.redis.client-name");
map.from("cluster.max-redirects").to("spring.redis.cluster.max-redirects");
map.from("cluster.nodes").to("spring.redis.cluster.nodes");
map.from("database").to("spring.redis.database");
map.from("host").to("spring.redis.host");
map.from("password").to("spring.redis.password");
map.from("port").to("spring.redis.port");
map.from("sentinel.master").to("spring.redis.sentinel.master");
map.from("sentinel.nodes").to("spring.redis.sentinel.nodes");
map.from("ssl").to("spring.redis.ssl");
map.from("url").to("spring.redis.url");
});
}

View File

@@ -37,9 +37,17 @@ final class RedisBindingsPropertiesProcessorTest {
new Binding("test-name", Paths.get("test-path"),
Collections.singletonMap("kind", KIND),
new FluentMap()
.withEntry("client-name", "test-client-name")
.withEntry("cluster.max-redirects", "test-cluster-max-redirects")
.withEntry("cluster.nodes", "test-cluster-nodes")
.withEntry("database", "test-database")
.withEntry("host", "test-host")
.withEntry("password", "test-password")
.withEntry("port", "test-port")
.withEntry("sentinel.master", "test-sentinel-master")
.withEntry("sentinel.nodes", "test-sentinel-nodes")
.withEntry("ssl", "test-ssl")
.withEntry("url", "test-url")
)
);
@@ -52,9 +60,17 @@ final class RedisBindingsPropertiesProcessorTest {
void test() {
new RedisBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties)
.containsEntry("spring.redis.client-name", "test-client-name")
.containsEntry("spring.redis.cluster.max-redirects", "test-cluster-max-redirects")
.containsEntry("spring.redis.cluster.nodes", "test-cluster-nodes")
.containsEntry("spring.redis.database", "test-database")
.containsEntry("spring.redis.host", "test-host")
.containsEntry("spring.redis.password", "test-password")
.containsEntry("spring.redis.port", "test-port");
.containsEntry("spring.redis.port", "test-port")
.containsEntry("spring.redis.sentinel.master", "test-sentinel-master")
.containsEntry("spring.redis.sentinel.nodes", "test-sentinel-nodes")
.containsEntry("spring.redis.ssl", "test-ssl")
.containsEntry("spring.redis.url", "test-url");
}
@Test