Revisit InfluxDB configuration structure
This commit removes the `client` namespace for InfluxDB as the component that is created is `InfluxDB`, not `InfluxDBClient` or something. This aligns with all the other url/user/password properties Spring Boot provides already See gh-9066
This commit is contained in:
parent
4a6b34e725
commit
540dca7bdd
|
|
@ -48,14 +48,13 @@ public class InfluxDbAutoConfiguration {
|
|||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnProperty("spring.influx.client.url")
|
||||
@ConditionalOnProperty("spring.influx.url")
|
||||
public InfluxDB influxDb() {
|
||||
InfluxDbProperties.Client client = this.properties.getClient();
|
||||
if (Strings.isNullOrEmpty(client.getUser())) {
|
||||
return InfluxDBFactory.connect(client.getUrl());
|
||||
if (Strings.isNullOrEmpty(this.properties.getUser())) {
|
||||
return InfluxDBFactory.connect(this.properties.getUrl());
|
||||
}
|
||||
return InfluxDBFactory.connect(client.getUrl(), client.getUser(),
|
||||
client.getPassword());
|
||||
return InfluxDBFactory.connect(this.properties.getUrl(), this.properties.getUser(),
|
||||
this.properties.getPassword());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,14 +28,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
|||
@ConfigurationProperties(prefix = "spring.influx")
|
||||
public class InfluxDbProperties {
|
||||
|
||||
private final Client client = new Client();
|
||||
|
||||
public Client getClient() {
|
||||
return this.client;
|
||||
}
|
||||
|
||||
public static class Client {
|
||||
|
||||
/**
|
||||
* Url of the InfluxDB instance to connect to.
|
||||
*/
|
||||
|
|
@ -75,6 +67,4 @@ public class InfluxDbProperties {
|
|||
this.password = password;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,22 +43,22 @@ public class InfluxDbAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void clientRequiresUrl() {
|
||||
public void influxDbRequiresUrl() {
|
||||
load();
|
||||
assertThat(this.context.getBeansOfType(InfluxDB.class)).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clientCanBeCustomized() {
|
||||
load("spring.influx.client.url=http://localhost",
|
||||
"spring.influx.client.password:password",
|
||||
"spring.influx.client.user:user");
|
||||
public void influxDbCanBeCustomized() {
|
||||
load("spring.influx.url=http://localhost",
|
||||
"spring.influx.password:password",
|
||||
"spring.influx.user:user");
|
||||
assertThat(this.context.getBeansOfType(InfluxDB.class)).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clientCanBeCreatedWithoutCredentials() {
|
||||
load("spring.influx.client.url=http://localhost");
|
||||
public void influxDbCanBeCreatedWithoutCredentials() {
|
||||
load("spring.influx.url=http://localhost");
|
||||
assertThat(this.context.getBeansOfType(InfluxDB.class)).hasSize(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -715,9 +715,9 @@ content into your application; rather pick only the properties that you need.
|
|||
spring.h2.console.settings.web-allow-others=false # Enable remote access.
|
||||
|
||||
# InfluxDB ({sc-spring-boot-autoconfigure}/influx/InfluxProperties.{sc-ext}[InfluxProperties])
|
||||
spring.influx.client.password= # Login password.
|
||||
spring.influx.client.url= # Url of the InfluxDB instance to connect to.
|
||||
spring.influx.client.user= # Login user.
|
||||
spring.influx.password= # Login password.
|
||||
spring.influx.url= # Url of the InfluxDB instance to connect to.
|
||||
spring.influx.user= # Login user.
|
||||
|
||||
# JOOQ ({sc-spring-boot-autoconfigure}/jooq/JooqAutoConfiguration.{sc-ext}[JooqAutoConfiguration])
|
||||
spring.jooq.sql-dialect= # Sql dialect to use, auto-detected by default.
|
||||
|
|
|
|||
Loading…
Reference in New Issue