Search in sources :

Example 1 with LogConfiguration

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;
}
Also used : LogConfiguration(io.fabric8.maven.docker.config.LogConfiguration) RunImageConfiguration(io.fabric8.maven.docker.config.RunImageConfiguration)

Example 2 with LogConfiguration

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);
}
Also used : ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) RunImageConfiguration(io.fabric8.maven.docker.config.RunImageConfiguration) LogConfiguration(io.fabric8.maven.docker.config.LogConfiguration) RunImageConfiguration(io.fabric8.maven.docker.config.RunImageConfiguration)

Example 3 with LogConfiguration

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;
}
Also used : JSONObject(org.json.JSONObject) LogConfiguration(io.fabric8.maven.docker.config.LogConfiguration) Map(java.util.Map)

Example 4 with LogConfiguration

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();
}
Also used : LogConfiguration(io.fabric8.maven.docker.config.LogConfiguration)

Example 5 with LogConfiguration

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);
}
Also used : LogConfiguration(io.fabric8.maven.docker.config.LogConfiguration) Test(org.junit.Test)

Aggregations

LogConfiguration (io.fabric8.maven.docker.config.LogConfiguration)5 RunImageConfiguration (io.fabric8.maven.docker.config.RunImageConfiguration)2 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)1 Map (java.util.Map)1 JSONObject (org.json.JSONObject)1 Test (org.junit.Test)1