io.fabric8.maven.docker.config.LogConfiguration Maven / Gradle / Ivy
package io.fabric8.maven.docker.config;
import java.io.Serializable;
import java.util.Map;
import org.apache.maven.plugins.annotations.Parameter;
/**
* @author roland
* @since 12.10.14
*/
public class LogConfiguration implements Serializable {
public static final LogConfiguration DEFAULT = new LogConfiguration(false, null, null, null, null, null);
@Parameter(defaultValue = "true")
private Boolean enabled;
@Parameter
private String prefix;
@Parameter
private String date;
@Parameter
private String color;
@Parameter
private String file;
@Parameter
private LogDriver driver;
public LogConfiguration() {}
private LogConfiguration(Boolean enabled, String prefix, String color, String date, String file, LogDriver driver) {
this.enabled = enabled;
this.prefix = prefix;
this.date = date;
this.color = color;
this.file = file;
this.driver = driver;
}
public String getPrefix() {
return prefix;
}
public String getDate() {
return date;
}
public String getColor() {
return color;
}
public Boolean isEnabled() {
return enabled;
}
public String getFileLocation() {
return file;
}
public LogDriver getDriver() {
return driver;
}
// =======================================================================================
public static class LogDriver implements Serializable {
/** @parameter */
private String name;
/** @parameter */
private Map opts;
public LogDriver() {};
private LogDriver(String name, Map opts) {
this.name = name;
this.opts = opts;
}
public String getName() {
return name;
}
public Map getOpts() {
return opts;
}
}
// =============================================================================
public static class Builder {
private Boolean enabled = true;
private String prefix, date, color, file;
private Map driverOpts;
private String driverName;
public Builder enabled(boolean enabled) {
this.enabled = enabled;
return this;
}
public Builder prefix(String prefix) {
this.prefix = prefix;
return this;
}
public Builder date(String date) {
this.date = date;
return this;
}
public Builder color(String color) {
this.color = color;
return this;
}
public Builder file(String file) {
this.file = file;
return this;
}
public Builder logDriverName(String logDriver) {
this.driverName = logDriver;
return this;
}
public Builder logDriverOpts(Map logOpts) {
this.driverOpts = logOpts;
return this;
}
/**
* Returns true if all options (except enabled) are null, used to decide value of enabled.
*
* @return
*/
public boolean isBlank() {
return prefix == null && date == null && color == null && file == null && driverName == null && driverOpts == null;
}
public LogConfiguration build() {
return new LogConfiguration(enabled, prefix, color, date, file,
driverName != null ? new LogDriver(driverName,driverOpts) : null);
}
}
}