use of io.fabric8.maven.docker.config.LogConfiguration in project docker-maven-plugin by fabric8io.
the class LogOutputSpecFactory method extractLogConfiguration.
private LogConfiguration extractLogConfiguration(ImageConfiguration imageConfiguration) {
RunImageConfiguration runConfig = imageConfiguration.getRunConfiguration();
LogConfiguration logConfig = null;
if (runConfig != null) {
logConfig = runConfig.getLogConfiguration();
}
if (logConfig == null) {
logConfig = LogConfiguration.DEFAULT;
}
return logConfig;
}
use of io.fabric8.maven.docker.config.LogConfiguration in project docker-maven-plugin by fabric8io.
the class LogOutputSpecFactoryTest method createSpec.
private LogOutputSpec createSpec(String prefix) {
LogOutputSpecFactory factory = new LogOutputSpecFactory(false, false, null);
LogConfiguration logConfig = new LogConfiguration.Builder().prefix(prefix).build();
RunImageConfiguration runConfig = new RunImageConfiguration.Builder().log(logConfig).build();
ImageConfiguration imageConfiguration = new ImageConfiguration.Builder().alias(ALIAS).name(NAME).runConfig(runConfig).build();
return factory.createSpec(CONTAINER_ID, imageConfiguration);
}
use of io.fabric8.maven.docker.config.LogConfiguration in project docker-maven-plugin by fabric8io.
the class ContainerHostConfig method logConfig.
public ContainerHostConfig logConfig(LogConfiguration logConfig) {
if (logConfig != null) {
LogConfiguration.LogDriver logDriver = logConfig.getDriver();
if (logDriver != null) {
JSONObject logConfigJson = new JSONObject();
logConfigJson.put("Type", logDriver.getName());
Map<String, String> opts = logDriver.getOpts();
if (opts != null && opts.size() > 0) {
JSONObject config = new JSONObject();
for (Map.Entry<String, String> logOpt : opts.entrySet()) {
config.put(logOpt.getKey(), logOpt.getValue());
}
logConfigJson.put("Config", config);
}
startConfig.put("LogConfig", logConfigJson);
}
}
return this;
}
use of io.fabric8.maven.docker.config.LogConfiguration in project docker-maven-plugin by fabric8io.
the class LogOutputSpecFactory method createSpec.
// ================================================================================================
public LogOutputSpec createSpec(String containerId, ImageConfiguration imageConfiguration) {
LogOutputSpec.Builder builder = new LogOutputSpec.Builder();
LogConfiguration logConfig = extractLogConfiguration(imageConfiguration);
addLogFormat(builder, logConfig);
addPrefix(builder, logConfig.getPrefix(), imageConfiguration, containerId);
builder.file(logConfig.getFileLocation()).useColor(useColor).logStdout(logStdout).color(logConfig.getColor());
return builder.build();
}
use of io.fabric8.maven.docker.config.LogConfiguration in project docker-maven-plugin by fabric8io.
the class ContainerHostConfigTest method testLogConfig.
@Test
public void testLogConfig() throws Exception {
ContainerHostConfig hc = new ContainerHostConfig();
Map<String, String> opts = new HashMap<>();
opts.put("gelf-address", "udp://10.0.0.1:12201");
opts.put("labels", "label1,label2");
LogConfiguration logConfig = new LogConfiguration.Builder().logDriverName("gelf").logDriverOpts(opts).build();
hc.logConfig(logConfig);
JSONAssert.assertEquals("{LogConfig:{Config:{gelf-address:\"udp://10.0.0.1:12201\",labels:\"label1,label2\"},Type:gelf}}", (JSONObject) hc.toJsonObject(), false);
}
Aggregations