Polishing.

Convert spaces to tabs. Deprecate VaultPostgreSqlProperties and VaultMySqlProperties. Convert database integration test to use MySQL. Slightly reword reference documentation.

Upgrade lombok to 1.16.18 to use onMethod_ attributes.

Original pull request: gh-170.
Related ticket: gh-169.
This commit is contained in:
Mark Paluch
2017-10-27 11:38:08 +02:00
parent 9da5e83dc9
commit 08d2a2e4c3
7 changed files with 204 additions and 52 deletions

View File

@@ -31,9 +31,10 @@ import org.springframework.vault.core.util.PropertyTransformer;
/**
* Bootstrap configuration providing support for the Database secret backends such as
* MySQL, PostreSQL, Apache Cassandra and MongoDB.
* Database, Apache Cassandra and MongoDB.
*
* @author Mark Paluch
* @author Per Abich
*/
@Configuration
@EnableConfigurationProperties({ VaultMySqlProperties.class,
@@ -51,8 +52,8 @@ public class VaultConfigDatabaseBootstrapConfiguration {
* {@link SecretBackendMetadataFactory} for Database integration using
* {@link DatabaseSecretProperties}.
*/
public static class DatabaseSecretBackendMetadataFactory
implements SecretBackendMetadataFactory<DatabaseSecretProperties> {
public static class DatabaseSecretBackendMetadataFactory implements
SecretBackendMetadataFactory<DatabaseSecretProperties> {
@Override
public SecretBackendMetadata createMetadata(
@@ -75,16 +76,15 @@ public class VaultConfigDatabaseBootstrapConfiguration {
* @param properties must not be {@literal null}.
* @return the {@link SecretBackendMetadata}
*/
static SecretBackendMetadata forDatabase(
final DatabaseSecretProperties properties) {
static SecretBackendMetadata forDatabase(final DatabaseSecretProperties properties) {
Assert.notNull(properties, "DatabaseSecretProperties must not be null");
final PropertyNameTransformer transformer = new PropertyNameTransformer();
transformer.addKeyTransformation("username",
properties.getUsernameProperty());
transformer.addKeyTransformation("password",
properties.getPasswordProperty());
transformer
.addKeyTransformation("username", properties.getUsernameProperty());
transformer
.addKeyTransformation("password", properties.getPasswordProperty());
return new SecretBackendMetadata() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2017 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.
@@ -15,47 +15,49 @@
*/
package org.springframework.cloud.vault.config.databases;
import javax.validation.constraints.NotEmpty;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotEmpty;
/**
* Configuration properties for Vault using the Database integration.
*
* @author Per Abich
* @since 2.0
*/
@ConfigurationProperties("spring.cloud.vault.database")
@Data
@Validated
public class VaultDatabaseProperties implements DatabaseSecretProperties {
/**
* Enable database backend usage.
*/
private boolean enabled = false;
/**
* Enable database backend usage.
*/
private boolean enabled = false;
/**
* Role name for credentials.
*/
private String role;
/**
* Role name for credentials.
*/
private String role;
/**
* Database backend path.
*/
@NotEmpty
private String backend = "database";
/**
* Database backend path.
*/
@NotEmpty
private String backend = "database";
/**
* Target property for the obtained username.
*/
@NotEmpty
private String usernameProperty = "spring.datasource.username";
/**
* Target property for the obtained username.
*/
@NotEmpty
private String usernameProperty = "spring.datasource.username";
/**
* Target property for the obtained password.
*/
@NotEmpty
private String passwordProperty = "spring.datasource.password";
/**
* Target property for the obtained password.
*/
@NotEmpty
private String passwordProperty = "spring.datasource.password";
}

View File

@@ -18,8 +18,10 @@ package org.springframework.cloud.vault.config.databases;
import javax.validation.constraints.NotEmpty;
import lombok.Data;
import lombok.Getter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
import org.springframework.cloud.vault.config.VaultSecretBackendDescriptor;
import org.springframework.validation.annotation.Validated;
@@ -27,21 +29,25 @@ import org.springframework.validation.annotation.Validated;
* Configuration properties for Vault using the MySQL integration.
*
* @author Mark Paluch
* @deprecated since 2.0. Use {@link VaultDatabaseProperties}.
*/
@ConfigurationProperties("spring.cloud.vault.mysql")
@Data
@Validated
@Deprecated
public class VaultMySqlProperties implements DatabaseSecretProperties,
VaultSecretBackendDescriptor {
/**
* Enable mysql backend usage.
*/
@Getter(onMethod_ = { @DeprecatedConfigurationProperty(reason = "Use spring.cloud.vault.database") })
private boolean enabled = false;
/**
* Role name for credentials.
*/
@Getter(onMethod_ = { @DeprecatedConfigurationProperty(reason = "Use spring.cloud.vault.database") })
private String role;
/**

View File

@@ -15,30 +15,38 @@
*/
package org.springframework.cloud.vault.config.databases;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotEmpty;
import lombok.Data;
import lombok.Getter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
import org.springframework.validation.annotation.Validated;
/**
* Configuration properties for Vault using the PostgreSQL integration.
*
* @author Mark Paluch
* @deprecated since 2.0. Use {@link VaultDatabaseProperties}.
*/
@ConfigurationProperties("spring.cloud.vault.postgresql")
@Data
@Validated
@Deprecated
public class VaultPostgreSqlProperties implements DatabaseSecretProperties {
/**
* Enable postgresql backend usage.
*/
@Deprecated
@Getter(onMethod_ = { @DeprecatedConfigurationProperty(reason = "Use spring.cloud.vault.database") })
private boolean enabled = false;
/**
* Role name for credentials.
*/
@Getter(onMethod_ = { @DeprecatedConfigurationProperty(reason = "Use spring.cloud.vault.database") })
private String role;
/**