Search in sources :

Example 1 with LogOutputSpecFactory

use of io.fabric8.maven.docker.log.LogOutputSpecFactory 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 2 with LogOutputSpecFactory

use of io.fabric8.maven.docker.log.LogOutputSpecFactory in project docker-maven-plugin by fabric8io.

the class RunServiceTest method setup.

@Before
public void setup() {
    tracker = new ContainerTracker();
    properties = new Properties();
    LogOutputSpecFactory logOutputSpecFactory = new LogOutputSpecFactory(true, true, null);
    runService = new RunService(docker, queryService, tracker, logOutputSpecFactory, log);
}
Also used : LogOutputSpecFactory(io.fabric8.maven.docker.log.LogOutputSpecFactory) Before(org.junit.Before)

Example 3 with LogOutputSpecFactory

use of io.fabric8.maven.docker.log.LogOutputSpecFactory in project docker-maven-plugin by fabric8io.

the class AbstractDockerMojo method execute.

/**
 * Entry point for this plugin. It will set up the helper class and then calls
 * {@link #executeInternal(ServiceHub)}
 * which must be implemented by subclass.
 *
 * @throws MojoExecutionException
 * @throws MojoFailureException
 */
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    if (!skip) {
        log = new AnsiLogger(getLog(), useColor, verbose, !settings.getInteractiveMode(), getLogPrefix());
        authConfigFactory.setLog(log);
        LogOutputSpecFactory logSpecFactory = new LogOutputSpecFactory(useColor, logStdout, logDate);
        ConfigHelper.validateExternalPropertyActivation(project, images);
        // The 'real' images configuration to use (configured images + externally resolved images)
        this.minimalApiVersion = initImageConfiguration(getBuildTimestamp());
        DockerAccess access = null;
        try {
            if (isDockerAccessRequired()) {
                DockerAccessFactory.DockerAccessContext dockerAccessContext = getDockerAccessContext();
                access = dockerAccessFactory.createDockerAccess(dockerAccessContext);
            }
            ServiceHub serviceHub = serviceHubFactory.createServiceHub(project, session, access, log, logSpecFactory);
            executeInternal(serviceHub);
        } catch (DockerAccessException | ExecException exp) {
            logException(exp);
            throw new MojoExecutionException(log.errorMessage(exp.getMessage()), exp);
        } catch (MojoExecutionException exp) {
            logException(exp);
            throw exp;
        } finally {
            if (access != null) {
                access.shutdown();
            }
        }
    }
}
Also used : DockerAccess(io.fabric8.maven.docker.access.DockerAccess) LogOutputSpecFactory(io.fabric8.maven.docker.log.LogOutputSpecFactory) ServiceHub(io.fabric8.maven.docker.service.ServiceHub) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) DockerAccessException(io.fabric8.maven.docker.access.DockerAccessException) ExecException(io.fabric8.maven.docker.access.ExecException) AnsiLogger(io.fabric8.maven.docker.util.AnsiLogger) DockerAccessFactory(io.fabric8.maven.docker.service.DockerAccessFactory)

Aggregations

LogOutputSpecFactory (io.fabric8.maven.docker.log.LogOutputSpecFactory)2 DockerAccess (io.fabric8.maven.docker.access.DockerAccess)1 DockerAccessException (io.fabric8.maven.docker.access.DockerAccessException)1 ExecException (io.fabric8.maven.docker.access.ExecException)1 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)1 LogConfiguration (io.fabric8.maven.docker.config.LogConfiguration)1 RunImageConfiguration (io.fabric8.maven.docker.config.RunImageConfiguration)1 DockerAccessFactory (io.fabric8.maven.docker.service.DockerAccessFactory)1 ServiceHub (io.fabric8.maven.docker.service.ServiceHub)1 AnsiLogger (io.fabric8.maven.docker.util.AnsiLogger)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 Before (org.junit.Before)1