Search in sources :

Example 1 with LogConfiguration

use of org.eclipse.jkube.kit.config.image.LogConfiguration in project jkube by eclipse.

the class LogOutputSpecFactory method extractLogConfiguration.

private LogConfiguration extractLogConfiguration(ImageConfiguration imageConfiguration) {
    RunImageConfiguration runConfig = imageConfiguration.getRunConfiguration();
    LogConfiguration logConfig = null;
    if (runConfig != null) {
        logConfig = runConfig.getLog();
    }
    if (logConfig == null) {
        logConfig = LogConfiguration.DEFAULT;
    }
    return logConfig;
}
Also used : LogConfiguration(org.eclipse.jkube.kit.config.image.LogConfiguration) RunImageConfiguration(org.eclipse.jkube.kit.config.image.RunImageConfiguration)

Example 2 with LogConfiguration

use of org.eclipse.jkube.kit.config.image.LogConfiguration in project jkube by eclipse.

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.addProperty("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.addProperty(logOpt.getKey(), logOpt.getValue());
                }
                logConfigJson.add("Config", config);
            }
            startConfig.add("LogConfig", logConfigJson);
        }
    }
    return this;
}
Also used : JsonObject(com.google.gson.JsonObject) LogConfiguration(org.eclipse.jkube.kit.config.image.LogConfiguration) Map(java.util.Map)

Example 3 with LogConfiguration

use of org.eclipse.jkube.kit.config.image.LogConfiguration in project jkube by eclipse.

the class PropertyConfigHandlerTest method validateRunConfiguration.

protected void validateRunConfiguration(RunImageConfiguration runConfig) {
    assertEquals(a("/foo", "/tmp:/tmp"), runConfig.getVolumeConfiguration().getBind());
    assertEquals(a("CAP"), runConfig.getCapAdd());
    assertEquals(a("CAP"), runConfig.getCapDrop());
    assertEquals(a("seccomp=unconfined"), runConfig.getSecurityOpts());
    assertEquals("command.sh", runConfig.getCmd().getShell());
    assertEquals(a("8.8.8.8"), runConfig.getDns());
    assertEquals("host", runConfig.getNetworkingConfig().getStandardMode(null));
    assertEquals(a("example.com"), runConfig.getDnsSearch());
    assertEquals("domain.com", runConfig.getDomainname());
    assertEquals("entrypoint.sh", runConfig.getEntrypoint().getShell());
    assertEquals(a("localhost:127.0.0.1"), runConfig.getExtraHosts());
    assertEquals("subdomain", runConfig.getHostname());
    assertEquals(a("redis"), runConfig.getLinks());
    assertEquals((Long) 1L, runConfig.getMemory());
    assertEquals((Long) 1L, runConfig.getMemorySwap());
    assertEquals((Long) 1000000000L, runConfig.getCpus());
    assertEquals((Long) 1L, runConfig.getCpuShares());
    assertEquals("0,1", runConfig.getCpuSet());
    assertEquals("/tmp/envProps.txt", runConfig.getEnvPropertyFile());
    assertEquals("/tmp/props.txt", runConfig.getPortPropertyFile());
    assertEquals("8081:8080", runConfig.getPorts().get(0));
    assertEquals(true, runConfig.getPrivileged());
    assertEquals("tomcat", runConfig.getUser());
    assertEquals(a("from"), runConfig.getVolumeConfiguration().getFrom());
    assertEquals("foo", runConfig.getWorkingDir());
    assertNotNull(runConfig.getUlimits());
    assertEquals(4, runConfig.getUlimits().size());
    assertUlimitEquals(ulimit("memlock", 10, 10), runConfig.getUlimits().get(0));
    assertUlimitEquals(ulimit("memlock", null, -1), runConfig.getUlimits().get(1));
    assertUlimitEquals(ulimit("memlock", 1024, null), runConfig.getUlimits().get(2));
    assertUlimitEquals(ulimit("memlock", 2048, null), runConfig.getUlimits().get(3));
    assertEquals("/var/lib/mysql:10m", runConfig.getTmpfs().get(0));
    assertEquals(1, runConfig.getTmpfs().size());
    assertEquals("Never", runConfig.getImagePullPolicy());
    assertEquals(true, runConfig.getReadOnly());
    assertEquals(true, runConfig.getAutoRemove());
    validateEnv(runConfig.getEnv());
    // not sure it's worth it to implement 'equals/hashcode' for these
    RestartPolicy policy = runConfig.getRestartPolicy();
    assertEquals("on-failure", policy.getName());
    assertEquals(1, policy.getRetry());
    WaitConfiguration wait = runConfig.getWait();
    assertEquals("http://foo.com", wait.getUrl());
    assertEquals("pattern", wait.getLog());
    assertEquals("post_start_command", wait.getExec().getPostStart());
    assertEquals("pre_stop_command", wait.getExec().getPreStop());
    assertTrue(wait.getExec().isBreakOnError());
    assertEquals(5, wait.getTime().intValue());
    assertTrue(wait.getHealthy());
    assertEquals(0, wait.getExit().intValue());
    LogConfiguration config = runConfig.getLog();
    assertEquals("green", config.getColor());
    assertTrue(config.isEnabled());
    assertEquals("SRV", config.getPrefix());
    assertEquals("iso8601", config.getDate());
    assertEquals("json", config.getDriver().getName());
    assertEquals(2, config.getDriver().getOpts().size());
    assertEquals("1024", config.getDriver().getOpts().get("max-size"));
    assertEquals("10", config.getDriver().getOpts().get("max-file"));
}
Also used : WaitConfiguration(org.eclipse.jkube.kit.config.image.WaitConfiguration) RestartPolicy(org.eclipse.jkube.kit.config.image.RestartPolicy) LogConfiguration(org.eclipse.jkube.kit.config.image.LogConfiguration)

Example 4 with LogConfiguration

use of org.eclipse.jkube.kit.config.image.LogConfiguration in project jkube by eclipse.

the class LogOutputSpecFactory method createSpec.

// ================================================================================================
public LogOutputSpec createSpec(String containerId, ImageConfiguration imageConfiguration) {
    LogOutputSpec.LogOutputSpecBuilder builder = LogOutputSpec.builder();
    LogConfiguration logConfig = extractLogConfiguration(imageConfiguration);
    addLogFormat(builder, logConfig);
    addPrefix(builder, logConfig.getPrefix(), imageConfiguration, containerId);
    builder.file(logConfig.getFileLocation()).useColor(useColor).logStdout(logStdout).colorString(logConfig.getColor());
    return builder.build();
}
Also used : LogConfiguration(org.eclipse.jkube.kit.config.image.LogConfiguration)

Aggregations

LogConfiguration (org.eclipse.jkube.kit.config.image.LogConfiguration)4 JsonObject (com.google.gson.JsonObject)1 Map (java.util.Map)1 RestartPolicy (org.eclipse.jkube.kit.config.image.RestartPolicy)1 RunImageConfiguration (org.eclipse.jkube.kit.config.image.RunImageConfiguration)1 WaitConfiguration (org.eclipse.jkube.kit.config.image.WaitConfiguration)1