Search in sources :

Example 56 with Builder

use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project docker-maven-plugin by fabric8io.

the class UrlBuilderTest method deleteImage.

@Test
public void deleteImage() throws URISyntaxException {
    UrlBuilder builder = new UrlBuilder("", "1.0");
    assertEquals(new URI("/1.0/images/n1?force=0"), new URI(builder.deleteImage("n1", false)));
}
Also used : UrlBuilder(io.fabric8.maven.docker.access.UrlBuilder) Test(org.junit.Test)

Example 57 with Builder

use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project docker-maven-plugin by fabric8io.

the class UrlBuilderTest method loadImage.

@Test
public void loadImage() throws URISyntaxException {
    UrlBuilder builder = new UrlBuilder("", "1.0");
    assertEquals(new URI("/1.0/images/load"), new URI(builder.loadImage()));
}
Also used : UrlBuilder(io.fabric8.maven.docker.access.UrlBuilder) Test(org.junit.Test)

Example 58 with Builder

use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project docker-maven-plugin by fabric8io.

the class JibBuildService method build.

public void build(String jibImageFormat, ImageConfiguration imageConfig, RegistryService.RegistryConfig registryConfig) throws MojoExecutionException {
    try {
        log.info("[[B]]JIB[[B]] image build started");
        if (imageConfig.getBuildConfiguration().isDockerFileMode()) {
            throw new MojoExecutionException("Dockerfile mode is not supported with JIB build strategy");
        }
        prependRegistry(imageConfig, mojoParameters.getProject().getProperties().getProperty(PUSH_REGISTRY));
        BuildDirs buildDirs = new BuildDirs(imageConfig.getName(), mojoParameters);
        final Credential pullRegistryCredential = getRegistryCredentials(registryConfig, false, imageConfig, log);
        final JibContainerBuilder containerBuilder = containerFromImageConfiguration(jibImageFormat, imageConfig, pullRegistryCredential);
        File dockerTarArchive = getAssemblyTarArchive(imageConfig, serviceHub, mojoParameters, log);
        for (AssemblyConfiguration assemblyConfiguration : imageConfig.getBuildConfiguration().getAssemblyConfigurations()) {
            // TODO: Improve Assembly Manager so that the effective assemblyFileEntries computed can be properly shared
            // the call to DockerAssemblyManager.getInstance().createDockerTarArchive should not be necessary,
            // files should be added using the AssemblyFileEntry list. DockerAssemblyManager, should provide
            // a common way to achieve this so that both the tar builder and any other builder could get a hold of
            // archive customizers, file entries, etc.
            AssemblyFiles assemblyFiles = serviceHub.getDockerAssemblyManager().getAssemblyFiles(imageConfig.getName(), assemblyConfiguration, mojoParameters, log);
            final Map<File, AssemblyFiles.Entry> files = assemblyFiles.getUpdatedEntriesAndRefresh().stream().collect(Collectors.toMap(AssemblyFiles.Entry::getDestFile, Function.identity(), (oldV, newV) -> newV));
            JibServiceUtil.copyToContainer(containerBuilder, buildDirs.getOutputDirectory(), buildDirs.getOutputDirectory().getAbsolutePath(), files);
        }
        JibServiceUtil.buildContainer(containerBuilder, TarImage.at(dockerTarArchive.toPath()).named(imageConfig.getName()), log);
        log.info(" %s successfully built", dockerTarArchive.getAbsolutePath());
    } catch (Exception ex) {
        throw new MojoExecutionException("Error when building JIB image", ex);
    }
}
Also used : Arrays(java.util.Arrays) JibContainerBuilder(com.google.cloud.tools.jib.api.JibContainerBuilder) AssemblyConfiguration(io.fabric8.maven.docker.config.AssemblyConfiguration) ImageName(io.fabric8.maven.docker.util.ImageName) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) Logger(io.fabric8.maven.docker.util.Logger) Function(java.util.function.Function) Credential(com.google.cloud.tools.jib.api.Credential) JibServiceUtil(io.fabric8.maven.docker.util.JibServiceUtil) BuildDirs(io.fabric8.maven.docker.assembly.BuildDirs) Map(java.util.Map) AuthConfig(io.fabric8.maven.docker.access.AuthConfig) AuthConfigFactory(io.fabric8.maven.docker.util.AuthConfigFactory) Collection(java.util.Collection) JibServiceUtil.containerFromImageConfiguration(io.fabric8.maven.docker.util.JibServiceUtil.containerFromImageConfiguration) TarImage(com.google.cloud.tools.jib.api.TarImage) MojoParameters(io.fabric8.maven.docker.util.MojoParameters) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Collectors(java.util.stream.Collectors) File(java.io.File) List(java.util.List) ArchiveCompression(io.fabric8.maven.docker.config.ArchiveCompression) JibServiceUtil.getBaseImage(io.fabric8.maven.docker.util.JibServiceUtil.getBaseImage) EnvUtil(io.fabric8.maven.docker.util.EnvUtil) AssemblyFiles(io.fabric8.maven.docker.assembly.AssemblyFiles) Credential(com.google.cloud.tools.jib.api.Credential) AssemblyConfiguration(io.fabric8.maven.docker.config.AssemblyConfiguration) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) AssemblyFiles(io.fabric8.maven.docker.assembly.AssemblyFiles) JibContainerBuilder(com.google.cloud.tools.jib.api.JibContainerBuilder) BuildDirs(io.fabric8.maven.docker.assembly.BuildDirs) File(java.io.File) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException)

Example 59 with Builder

use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project docker-maven-plugin by fabric8io.

the class DockerComposeServiceWrapper method getVolumeConfig.

RunVolumeConfiguration getVolumeConfig() {
    RunVolumeConfiguration.Builder builder = new RunVolumeConfiguration.Builder();
    List<String> volumes = asList("volumes");
    boolean added = false;
    if (volumes.size() > 0) {
        builder.bind(volumes);
        added = true;
    }
    List<String> volumesFrom = asList("volumes_from");
    if (volumesFrom.size() > 0) {
        builder.from(volumesFrom);
        added = true;
    }
    if (added) {
        RunVolumeConfiguration configuration = builder.build();
        VolumeBindingUtil.resolveRelativeVolumeBindings(baseDir, configuration);
        return configuration;
    }
    return null;
}
Also used : RunVolumeConfiguration(io.fabric8.maven.docker.config.RunVolumeConfiguration)

Example 60 with Builder

use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project docker-maven-plugin by fabric8io.

the class DockerAssemblyManagerTest method testShellIsSet.

@Test
public void testShellIsSet() {
    BuildImageConfiguration buildConfig = new BuildImageConfiguration.Builder().shell(new Arguments.Builder().withShell("/bin/sh echo hello").build()).build();
    DockerFileBuilder builder = assemblyManager.createDockerFileBuilder(buildConfig, buildConfig.getAssemblyConfigurations());
    String content = builder.content();
    assertTrue(content.contains("SHELL [\"/bin/sh\",\"echo\",\"hello\"]"));
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)60 ProfileBuilder (io.fabric8.api.ProfileBuilder)34 Profile (io.fabric8.api.Profile)33 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)27 FabricService (io.fabric8.api.FabricService)24 InputStream (java.io.InputStream)21 Deployment (org.jboss.arquillian.container.test.api.Deployment)21 OSGiManifestBuilder (org.jboss.osgi.metadata.OSGiManifestBuilder)21 Asset (org.jboss.shrinkwrap.api.asset.Asset)21 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)21 ServiceTracker (org.osgi.util.tracker.ServiceTracker)20 HashMap (java.util.HashMap)19 Map (java.util.Map)19 Logger (org.slf4j.Logger)19 CommandSupport (io.fabric8.itests.support.CommandSupport)18 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)17 ServiceLocator (io.fabric8.api.gravia.ServiceLocator)16 IOException (java.io.IOException)16 Action (org.apache.felix.gogo.commands.Action)16 AbstractCommand (org.apache.felix.gogo.commands.basic.AbstractCommand)16