Merge pull request #3915 from fabriciocolombo/liquibase
* pr/3915: Add Liquibase labels and parameters properties
This commit is contained in:
commit
9128f2b902
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2015 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.
|
||||
|
|
@ -100,6 +100,8 @@ public class LiquibaseAutoConfiguration {
|
|||
liquibase.setDefaultSchema(this.properties.getDefaultSchema());
|
||||
liquibase.setDropFirst(this.properties.isDropFirst());
|
||||
liquibase.setShouldRun(this.properties.isEnabled());
|
||||
liquibase.setLabels(this.properties.getLabels());
|
||||
liquibase.setChangeLogParameters(this.properties.getParameters());
|
||||
return liquibase;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2015 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.
|
||||
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.liquibase;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
|
@ -78,6 +80,16 @@ public class LiquibaseProperties {
|
|||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* Comma-separated list of runtime labels to use.
|
||||
*/
|
||||
private String labels;
|
||||
|
||||
/**
|
||||
* Change log parameters.
|
||||
*/
|
||||
private Map<String, String> parameters;
|
||||
|
||||
public String getChangeLog() {
|
||||
return this.changeLog;
|
||||
}
|
||||
|
|
@ -150,4 +162,20 @@ public class LiquibaseProperties {
|
|||
this.url = url;
|
||||
}
|
||||
|
||||
public String getLabels() {
|
||||
return this.labels;
|
||||
}
|
||||
|
||||
public void setLabels(String labels) {
|
||||
this.labels = labels;
|
||||
}
|
||||
|
||||
public Map<String, String> getParameters() {
|
||||
return this.parameters;
|
||||
}
|
||||
|
||||
public void setParameters(Map<String, String> parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2015 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.
|
||||
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.liquibase;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
|
|
@ -167,4 +169,31 @@ public class LiquibaseAutoConfigurationTests {
|
|||
assertThat(log, instanceOf(CommonsLoggingLiquibaseLogger.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOverrideLabels() throws Exception {
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"liquibase.labels:test, production");
|
||||
this.context.register(EmbeddedDataSourceConfiguration.class,
|
||||
LiquibaseAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
SpringLiquibase liquibase = this.context.getBean(SpringLiquibase.class);
|
||||
assertEquals("test, production", liquibase.getLabels());
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testOverrideParameters() throws Exception {
|
||||
EnvironmentTestUtils.addEnvironment(this.context, "liquibase.parameters.foo:bar");
|
||||
this.context.register(EmbeddedDataSourceConfiguration.class,
|
||||
LiquibaseAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
SpringLiquibase liquibase = this.context.getBean(SpringLiquibase.class);
|
||||
Map<String, String> parameters = (Map<String, String>) ReflectionTestUtils
|
||||
.getField(liquibase, "parameters");
|
||||
assertTrue(parameters.containsKey("foo"));
|
||||
assertEquals("bar", parameters.get("foo"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -472,12 +472,14 @@ content into your application; rather pick only the properties that you need.
|
|||
liquibase.change-log=classpath:/db/changelog/db.changelog-master.yaml
|
||||
liquibase.check-change-log-location=true # check the change log location exists
|
||||
liquibase.contexts= # runtime contexts to use
|
||||
liquibase.labels= # runtime labels to use
|
||||
liquibase.default-schema= # default database schema to use
|
||||
liquibase.drop-first=false
|
||||
liquibase.enabled=true
|
||||
liquibase.url= # specific JDBC url (if not set the default datasource is used)
|
||||
liquibase.user= # user name for liquibase.url
|
||||
liquibase.password= # password for liquibase.url
|
||||
liquibase.parameters= # change log parameters
|
||||
|
||||
# JMX
|
||||
spring.jmx.default-domain= # JMX domain name
|
||||
|
|
|
|||
Loading…
Reference in New Issue