Search in sources :

Example 1 with AnsiLogger

use of io.fabric8.maven.docker.util.AnsiLogger in project docker-maven-plugin by fabric8io.

the class DockerMachineIT method testLaunchDockerMachine.

@Test
public void testLaunchDockerMachine() throws Exception {
    DockerMachineConfiguration mc = new DockerMachineConfiguration("default", "true");
    DockerMachine de = new DockerMachine(new AnsiLogger(new SystemStreamLog(), true, true), mc);
    Assert.assertTrue(de.getConnectionParameter(null) != null);
}
Also used : DockerMachine(io.fabric8.maven.docker.access.DockerMachine) SystemStreamLog(org.apache.maven.plugin.logging.SystemStreamLog) DockerMachineConfiguration(io.fabric8.maven.docker.config.DockerMachineConfiguration) AnsiLogger(io.fabric8.maven.docker.util.AnsiLogger) Test(org.junit.Test)

Example 2 with AnsiLogger

use of io.fabric8.maven.docker.util.AnsiLogger in project docker-maven-plugin by fabric8io.

the class DockerAssemblyManagerTest method assemblyFiles.

@Test
public void assemblyFiles(@Injectable final MojoParameters mojoParams, @Injectable final MavenProject project, @Injectable final Assembly assembly) throws AssemblyFormattingException, ArchiveCreationException, InvalidAssemblerConfigurationException, MojoExecutionException, AssemblyReadException, IllegalAccessException {
    ReflectionUtils.setVariableValueInObject(assemblyManager, "trackArchiver", trackArchiver);
    new Expectations() {

        {
            mojoParams.getOutputDirectory();
            result = "target/";
            times = 3;
            mojoParams.getProject();
            project.getBasedir();
            result = ".";
            assemblyReader.readAssemblies((AssemblerConfigurationSource) any);
            result = Arrays.asList(assembly);
        }
    };
    BuildImageConfiguration buildConfig = createBuildConfig();
    assemblyManager.getAssemblyFiles("testImage", buildConfig, mojoParams, new AnsiLogger(new SystemStreamLog(), true, true));
}
Also used : Expectations(mockit.Expectations) SystemStreamLog(org.apache.maven.plugin.logging.SystemStreamLog) AnsiLogger(io.fabric8.maven.docker.util.AnsiLogger) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Test(org.junit.Test)

Example 3 with AnsiLogger

use of io.fabric8.maven.docker.util.AnsiLogger in project docker-maven-plugin by fabric8io.

the class MappingTrackArchiverTest method setup.

@Before
public void setup() throws IllegalAccessException {
    archiver = new MappingTrackArchiver();
    archiver.init(new AnsiLogger(new SystemStreamLog(), false, false), "maven");
}
Also used : SystemStreamLog(org.apache.maven.plugin.logging.SystemStreamLog) AnsiLogger(io.fabric8.maven.docker.util.AnsiLogger) Before(org.junit.Before)

Example 4 with AnsiLogger

use of io.fabric8.maven.docker.util.AnsiLogger in project docker-maven-plugin by fabric8io.

the class ConfigHelperTest method filter.

@Test
public void filter() throws Exception {
    List<ImageConfiguration> configs = Arrays.asList(new ImageConfiguration.Builder().name("test").build());
    CatchingLog logCatcher = new CatchingLog();
    List<ImageConfiguration> result = ConfigHelper.resolveImages(new AnsiLogger(logCatcher, true, true), configs, createResolver(), "bla", createCustomizer());
    assertEquals(0, result.size());
    assertTrue(resolverCalled);
    assertTrue(customizerCalled);
    assertTrue(logCatcher.getWarnMessage().contains("test"));
    assertTrue(logCatcher.getWarnMessage().contains("bla"));
}
Also used : AnsiLogger(io.fabric8.maven.docker.util.AnsiLogger) Test(org.junit.Test)

Example 5 with AnsiLogger

use of io.fabric8.maven.docker.util.AnsiLogger 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

AnsiLogger (io.fabric8.maven.docker.util.AnsiLogger)5 Test (org.junit.Test)4 SystemStreamLog (org.apache.maven.plugin.logging.SystemStreamLog)3 DependencyResolver (io.fabric8.arquillian.kubernetes.DependencyResolver)1 Session (io.fabric8.arquillian.kubernetes.Session)1 AnsiLogger (io.fabric8.arquillian.kubernetes.log.AnsiLogger)1 DockerAccess (io.fabric8.maven.docker.access.DockerAccess)1 DockerAccessException (io.fabric8.maven.docker.access.DockerAccessException)1 DockerMachine (io.fabric8.maven.docker.access.DockerMachine)1 ExecException (io.fabric8.maven.docker.access.ExecException)1 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)1 DockerMachineConfiguration (io.fabric8.maven.docker.config.DockerMachineConfiguration)1 LogOutputSpecFactory (io.fabric8.maven.docker.log.LogOutputSpecFactory)1 DockerAccessFactory (io.fabric8.maven.docker.service.DockerAccessFactory)1 ServiceHub (io.fabric8.maven.docker.service.ServiceHub)1 Expectations (mockit.Expectations)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 Before (org.junit.Before)1