Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 26 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ The more common usage of the library is opt-in automatic Spring Boot configurati
* Adds a `PropertySource` with binding-specific Spring Boot configuration properties.

## Auto-Configurations
Each auto-configuration is triggered by the type of binding. Each auto-configuration can be disabled using a System Property specific to that type and defaults to enable. Auto-configuration is disabled by default and can be enabled by setting the `org.springframework.cloud.bindings.boot.enable` System Property to `true`.
Each auto-configuration is triggered by the type of binding. Each auto-configuration can be disabled using a System Property specific to that type and defaults to enable. Auto-configuration is disabled by default and can be enabled by setting the `org.springframework.cloud.bindings.boot.enabled` System Property to `true`.

`{<key>}` indicates that the value is the contents of the secret with the given key.

> **_NOTE:_** Legacy property key suffix `*.enable` is supported but deprecated in favor of `*.enabled`.

### ActiveMQ Artemis
Type: `artemis`
Disable Property: `org.springframework.cloud.bindings.boot.artemis.enable`
Disable Property: `org.springframework.cloud.bindings.boot.artemis.enabled`

#### Properties

Expand Down Expand Up @@ -70,7 +72,7 @@ Disable Property: `org.springframework.cloud.bindings.boot.artemis.enable`

### Cassandra
Type: `cassandra`
Disable Property: `org.springframework.cloud.bindings.boot.cassandra.enable`
Disable Property: `org.springframework.cloud.bindings.boot.cassandra.enabled`

#### Properties

Expand All @@ -91,7 +93,7 @@ Disable Property: `org.springframework.cloud.bindings.boot.cassandra.enable`

### Couchbase
Type: `couchbase`
Disable Property: `org.springframework.cloud.bindings.boot.couchbase.enable`
Disable Property: `org.springframework.cloud.bindings.boot.couchbase.enabled`

#### Properties

Expand All @@ -104,7 +106,7 @@ Disable Property: `org.springframework.cloud.bindings.boot.couchbase.enable`

### DB2 RDBMS
Type: `db2`
Disable Property: `org.springframework.cloud.bindings.boot.db2.enable`
Disable Property: `org.springframework.cloud.bindings.boot.db2.enabled`

| Property | Value |
| ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -119,7 +121,7 @@ Disable Property: `org.springframework.cloud.bindings.boot.db2.enable`

### Elasticsearch
Type: `elasticsearch`
Disable Property: `org.springframework.cloud.bindings.boot.elasticsearch.enable`
Disable Property: `org.springframework.cloud.bindings.boot.elasticsearch.enabled`

#### Properties

Expand All @@ -131,7 +133,7 @@ Disable Property: `org.springframework.cloud.bindings.boot.elasticsearch.enable`

### Kafka
Type: `kafka`
Disable Property: `org.springframework.cloud.bindings.boot.kafka.enable`
Disable Property: `org.springframework.cloud.bindings.boot.kafka.enabled`

| Property | Value |
| ----------------------------------------- | ------------------------------ |
Expand All @@ -142,7 +144,7 @@ Disable Property: `org.springframework.cloud.bindings.boot.kafka.enable`

### LDAP
Type: `ldap`
Disable Property: `org.springframework.cloud.bindings.boot.ldap.enable`
Disable Property: `org.springframework.cloud.bindings.boot.ldap.enabled`

| Property | Value |
| ---------------------- | ------------ |
Expand All @@ -153,7 +155,7 @@ Disable Property: `org.springframework.cloud.bindings.boot.ldap.enable`

### MongoDB
Type: `mongodb`
Disable Property: `org.springframework.cloud.bindings.boot.mongodb.enable`
Disable Property: `org.springframework.cloud.bindings.boot.mongodb.enabled`

| Property | Value |
| --------------------------------------------- | --------------------------- |
Expand All @@ -168,7 +170,7 @@ Disable Property: `org.springframework.cloud.bindings.boot.mongodb.enable`

### MySQL RDBMS
Type: `mysql`
Disable Property: `org.springframework.cloud.bindings.boot.mysql.enable`
Disable Property: `org.springframework.cloud.bindings.boot.mysql.enabled`

| Property | Value |
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
Expand All @@ -184,7 +186,7 @@ Disable Property: `org.springframework.cloud.bindings.boot.mysql.enable`

### Neo4J
Type: `neo4j`
Disable Property: `org.springframework.cloud.bindings.boot.neo4j.enable`
Disable Property: `org.springframework.cloud.bindings.boot.neo4j.enabled`

#### Properties

Expand All @@ -196,7 +198,7 @@ Disable Property: `org.springframework.cloud.bindings.boot.neo4j.enable`

### Oracle RDBMS
Type: `oracle`
Disable Property: `org.springframework.cloud.bindings.boot.oracle.enable`
Disable Property: `org.springframework.cloud.bindings.boot.oracle.enabled`

| Property | Value |
| ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -210,7 +212,7 @@ Disable Property: `org.springframework.cloud.bindings.boot.oracle.enable`

### PostgreSQL RDBMS
Type: `postgresql`
Disable Property: `org.springframework.cloud.bindings.boot.postgresql.enable`
Disable Property: `org.springframework.cloud.bindings.boot.postgresql.enabled`

| Property | Value |
| ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -224,7 +226,7 @@ Disable Property: `org.springframework.cloud.bindings.boot.postgresql.enable`

### RabbitMQ
Type: `rabbitmq`
Disable Property: `org.springframework.cloud.bindings.boot.rabbitmq.enable`
Disable Property: `org.springframework.cloud.bindings.boot.rabbitmq.enabled`

| Property | Value |
| ------------------------------ | ---------------- |
Expand All @@ -237,7 +239,7 @@ Disable Property: `org.springframework.cloud.bindings.boot.rabbitmq.enable`

### Redis
Type: `redis`
Disable Property: `org.springframework.cloud.bindings.boot.redis.enable`
Disable Property: `org.springframework.cloud.bindings.boot.redis.enabled`

#### Properties

Expand All @@ -257,7 +259,7 @@ Disable Property: `org.springframework.cloud.bindings.boot.redis.enable`

### SAP Hana
Type: `hana`
Disable Property: `org.springframework.cloud.bindings.boot.hana.enable`
Disable Property: `org.springframework.cloud.bindings.boot.hana.enabled`

| Property | Value |
| ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -271,7 +273,7 @@ Disable Property: `org.springframework.cloud.bindings.boot.hana.enable`

## SCS Config Server
Type: `config`
Disable Property: `org.springframework.cloud.bindings.boot.config.enable`
Disable Property: `org.springframework.cloud.bindings.boot.config.enabled`

| Property | Value |
|------------------------------------------------------|--------------------------------------------------------|
Expand All @@ -292,7 +294,7 @@ Disable Property: `org.springframework.cloud.bindings.boot.config.enable`
## SCS Eureka

Type: `eureka`
Disable Property: `org.springframework.cloud.bindings.boot.eureka.enable`
Disable Property: `org.springframework.cloud.bindings.boot.eureka.enabled`

| Property | Value |
|------------------------------------------|--------------------------------------------------------------------|
Expand All @@ -317,7 +319,7 @@ Disable Property: `org.springframework.cloud.bindings.boot.eureka.enable`

## Spring Security OAuth2
Type: `oauth2`
Disable Property: `org.springframework.cloud.bindings.boot.oauth2.enable`
Disable Property: `org.springframework.cloud.bindings.boot.oauth2.enabled`

| Property | Value |
| ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -339,7 +341,7 @@ Disable Property: `org.springframework.cloud.bindings.boot.oauth2.enable`

### SQLServer RDBMS
Type: `sqlserver`
Disable Property: `org.springframework.cloud.bindings.boot.sqlserver.enable`
Disable Property: `org.springframework.cloud.bindings.boot.sqlserver.enabled`

| Property | Value |
| ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -354,7 +356,7 @@ Disable Property: `org.springframework.cloud.bindings.boot.sqlserver.enable`

### Vault
Type: `vault`
Disable Property: `org.springframework.cloud.bindings.boot.vault.enable`
Disable Property: `org.springframework.cloud.bindings.boot.vault.enabled`

Any Provider:

Expand Down Expand Up @@ -455,7 +457,7 @@ If `{authentication-method}` is equal to `token`:
### Wavefront

Type: `wavefront`
Disable Property: `org.springframework.cloud.bindings.boot.wavefront.enable`
Disable Property: `org.springframework.cloud.bindings.boot.wavefront.enabled`

| Property | Value |
| ----------------------------------------------- | ------------- |
Expand Down Expand Up @@ -489,7 +491,7 @@ public final class MyServiceBindingsPropertiesProcessor implements BindingsPrope

@Override
public void process(Environment environment, Bindings bindings, Map<String, Object> properties) {
if (!environment.getProperty("com.example.bindings.myservice.enable", Boolean.class, true)) {
if (!environment.getProperty("com.example.bindings.myservice.enabled", Boolean.class, true)) {
return;
}
List<Binding> myBindings = bindings.filterBindings(TYPE);
Expand All @@ -505,7 +507,7 @@ public final class MyServiceBindingsPropertiesProcessor implements BindingsPrope

These lines from the above example allow users to set `com.example.bindings.myservice.enable=false` to disable the processor entirely:
```
if (!environment.getProperty("com.example.bindings.myservice.enable", Boolean.class, true)) {
if (!environment.getProperty("com.example.bindings.myservice.enabled", Boolean.class, true)) {
return;
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@

final class Guards {

static final String CONFIGURATION_KEY_PREFIX = "org.springframework.cloud.bindings.boot.";

static boolean isGlobalEnabled(Environment environment) {
return environment.getProperty("org.springframework.cloud.bindings.boot.enable", Boolean.class, true);
return environment.getProperty(CONFIGURATION_KEY_PREFIX + "enable", Boolean.class,
environment.getProperty(CONFIGURATION_KEY_PREFIX + "enabled", Boolean.class, true));
}

static boolean isTypeEnabled(Environment environment, String type) {
return environment.getProperty(
String.format("org.springframework.cloud.bindings.boot.%s.enable", type),
Boolean.class, true);
return environment.getProperty(String.format(CONFIGURATION_KEY_PREFIX + "%s.enable", type), Boolean.class,
environment.getProperty(String.format(CONFIGURATION_KEY_PREFIX + "%s.enabled", type), Boolean.class, true));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void testSb3() {
@Test
@DisplayName("can be disabled")
void disabled() {
environment.setProperty("org.springframework.cloud.bindings.boot.artemis.enable", "false");
environment.setProperty("org.springframework.cloud.bindings.boot.artemis.enabled", "false");

new ArtemisBindingsPropertiesProcessor().process(environment, bindingsSpringBoot3, properties);
assertThat(properties).isEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class BindingFlattenedEnvironmentPostProcessorTest {
private final SpringApplication application = new SpringApplication();

private final MockEnvironment environment = new MockEnvironment()
.withProperty("org.springframework.cloud.bindings.boot.enable", "true");
.withProperty("org.springframework.cloud.bindings.boot.enabled", "true");

@Test
@DisplayName("is disabled by default")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class BindingSpecificEnvironmentPostProcessorTest {
private final SpringApplication application = new SpringApplication();

private final MockEnvironment environment = new MockEnvironment()
.withProperty("org.springframework.cloud.bindings.boot.enable", "true");
.withProperty("org.springframework.cloud.bindings.boot.enabled", "true");

@Test
@DisplayName("is disabled by default")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void testSb3() {
@Test
@DisplayName("can be disabled")
void disabled() {
environment.setProperty("org.springframework.cloud.bindings.boot.cassandra.enable", "false");
environment.setProperty("org.springframework.cloud.bindings.boot.cassandra.enabled", "false");

new CassandraBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties).isEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void whenEnabled() {
@Test
@DisplayName("can be disabled")
void whenDisabled() {
environment.setProperty("org.springframework.cloud.bindings.boot.config.enable", "false");
environment.setProperty("org.springframework.cloud.bindings.boot.config.enabled", "false");

new ConfigServerBindingsPropertiesProcessor().process(environment, bindings, properties);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void testSb3() {
@Test
@DisplayName("can be disabled")
void disabled() {
environment.setProperty("org.springframework.cloud.bindings.boot.couchbase.enable", "false");
environment.setProperty("org.springframework.cloud.bindings.boot.couchbase.enabled", "false");

new CouchbaseBindingsPropertiesProcessor().process(environment, bindingsSpringBoot3, properties);
assertThat(properties).isEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void disabled() {
Bindings bindings = new Bindings(
new Binding("test-name", Paths.get("test-path"), secret)
);
environment.setProperty("org.springframework.cloud.bindings.boot.db2.enable", "false");
environment.setProperty("org.springframework.cloud.bindings.boot.db2.enabled", "false");

new Db2BindingsPropertiesProcessor().process(environment, bindings, properties);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void testSb3() {
@Test
@DisplayName("can be disabled")
void disabled() {
environment.setProperty("org.springframework.cloud.bindings.boot.elasticsearch.enable", "false");
environment.setProperty("org.springframework.cloud.bindings.boot.elasticsearch.enabled", "false");

new ElasticsearchBindingsPropertiesProcessor().process(environment, bindingsSpringBoot3, properties);
assertThat(properties).isEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void doesNotOverridePreferIpAddressInKubernetes() {
@Test
@DisplayName("can be disabled")
void disabled() {
environment.setProperty("org.springframework.cloud.bindings.boot.eureka.enable", "false");
environment.setProperty("org.springframework.cloud.bindings.boot.eureka.enabled", "false");

new KafkaBindingsPropertiesProcessor().process(environment, bindings, properties);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,33 @@ void unset() {
}

@Test
@DisplayName("returns the set value of true")
@DisplayName("returns the set enable value of true")
void setTrue() {
environment.setProperty("org.springframework.cloud.bindings.boot.enable", "true");
assertThat(isGlobalEnabled(environment)).isTrue();
}

@Test
@DisplayName("returns the set value of false")
@DisplayName("returns the set enable value of false")
void setFalse() {
environment.setProperty("org.springframework.cloud.bindings.boot.enable", "false");
assertThat(isGlobalEnabled(environment)).isFalse();
}

@Test
@DisplayName("returns the set enabled value of true")
void setEnabledTrue() {
environment.setProperty("org.springframework.cloud.bindings.boot.enabled", "true");
assertThat(isGlobalEnabled(environment)).isTrue();
}

@Test
@DisplayName("returns the set enabled value of false")
void setEnabledFalse() {
environment.setProperty("org.springframework.cloud.bindings.boot.enabled", "false");
assertThat(isGlobalEnabled(environment)).isFalse();
}

}

@Nested
Expand All @@ -69,19 +83,34 @@ void unset() {
}

@Test
@DisplayName("returns the set value of true")
@DisplayName("returns the set enable value of true")
void setTrue() {
environment.setProperty("org.springframework.cloud.bindings.boot.test.enable", "true");
assertThat(isTypeEnabled(environment, "Test")).isTrue();
}

@Test
@DisplayName("returns the set value of false")
@DisplayName("returns the set enable value of false")
void setFalse() {
environment.setProperty("org.springframework.cloud.bindings.boot.test.enable", "false");
assertThat(isTypeEnabled(environment, "test")).isFalse();
}


@Test
@DisplayName("returns the set enabled value of true")
void setEnabledTrue() {
environment.setProperty("org.springframework.cloud.bindings.boot.test.enabled", "true");
assertThat(isTypeEnabled(environment, "Test")).isTrue();
}

@Test
@DisplayName("returns the set enabled value of false")
void setEnabledFalse() {
environment.setProperty("org.springframework.cloud.bindings.boot.test.enabled", "false");
assertThat(isTypeEnabled(environment, "test")).isFalse();
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void test() {
@Test
@DisplayName("can be disabled")
void disabled() {
environment.setProperty("org.springframework.cloud.bindings.boot.kafka.enable", "false");
environment.setProperty("org.springframework.cloud.bindings.boot.kafka.enabled", "false");

new KafkaBindingsPropertiesProcessor().process(environment, bindings, properties);

Expand Down
Loading