Search in sources :

Example 61 with Builder

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

the class ContainerTrackerTest method getImageConfiguration.

private ImageConfiguration getImageConfiguration(String name, String alias, int shutdown, int kill, String preStop, boolean breakOnError) {
    WaitConfiguration waitConfig = null;
    if (shutdown != 0 && kill != 0) {
        WaitConfiguration.Builder builder = new WaitConfiguration.Builder().shutdown(shutdown).kill(kill);
        if (preStop != null) {
            builder.preStop(preStop);
            builder.breakOnError(breakOnError);
        }
        waitConfig = builder.build();
    }
    return new ImageConfiguration.Builder().name(name).alias(alias).runConfig(new RunImageConfiguration.Builder().wait(waitConfig).build()).build();
}
Also used : WaitConfiguration(io.fabric8.maven.docker.config.WaitConfiguration)

Example 62 with Builder

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

the class CopyConfigurationTest method copyOfNull.

@Test
public void copyOfNull() {
    final CopyConfiguration copy = new Builder(null).build();
    assertEntries(copy, null);
    assertEntriesAsProperties(copy, null);
}
Also used : Builder(io.fabric8.maven.docker.config.CopyConfiguration.Builder) Test(org.junit.Test)

Example 63 with Builder

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

the class CopyConfigurationTest method copyOfNotNull.

@Test
public void copyOfNotNull() {
    final List<Entry> expected = entries();
    final CopyConfiguration original = new Builder().entries(expected).build();
    final CopyConfiguration copy = new Builder(original).build();
    assertEntries(copy, expected);
    assertEntriesAsProperties(copy, expected);
}
Also used : Entry(io.fabric8.maven.docker.config.CopyConfiguration.Entry) Builder(io.fabric8.maven.docker.config.CopyConfiguration.Builder) Test(org.junit.Test)

Example 64 with Builder

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

the class DockerAssemblyManager method createDockerTarArchive.

/**
 * Create an docker tar archive from the given configuration which can be send to the Docker host for
 * creating the image.
 *
 * @param imageName Name of the image to create (used for creating build directories)
 * @param params Mojos parameters (used for finding the directories)
 * @param buildConfig configuration for how to build the image
 * @param log Logger used to display warning if permissions are to be normalized
 * @param finalCustomizer finalCustomizer to be applied to the tar archive
 * @return file holding the path to the created assembly tar file
 * @throws MojoExecutionException
 */
public File createDockerTarArchive(String imageName, final MojoParameters params, final BuildImageConfiguration buildConfig, Logger log, ArchiverCustomizer finalCustomizer) throws MojoExecutionException {
    final BuildDirs buildDirs = createBuildDirs(imageName, params);
    final List<AssemblyConfiguration> assemblyConfigurations = buildConfig.getAssemblyConfigurations();
    final List<ArchiverCustomizer> archiveCustomizers = new ArrayList<>();
    // Build up assembly. In dockerfile mode this must be added explicitly in the Dockerfile with an ADD
    if (hasAssemblyConfiguration(assemblyConfigurations)) {
        createAssemblyArchives(assemblyConfigurations, params, buildDirs);
    }
    try {
        if (buildConfig.isDockerFileMode()) {
            // Use specified docker directory which must include a Dockerfile.
            final File dockerFile = buildConfig.getAbsoluteDockerFilePath(params);
            if (!dockerFile.exists()) {
                throw new MojoExecutionException("Configured Dockerfile \"" + buildConfig.getDockerFile() + "\" (resolved to \"" + dockerFile + "\") doesn't exist");
            }
            FixedStringSearchInterpolator interpolator = DockerFileUtil.createInterpolator(params, buildConfig.getFilter());
            verifyGivenDockerfile(dockerFile, buildConfig, interpolator, log);
            interpolateDockerfile(dockerFile, buildDirs, interpolator);
            // User dedicated Dockerfile from extra directory
            archiveCustomizers.add(new ArchiverCustomizer() {

                @Override
                public TarArchiver customize(TarArchiver archiver) throws IOException {
                    DefaultFileSet fileSet = DefaultFileSet.fileSet(buildConfig.getAbsoluteContextDirPath(params));
                    addDockerIncludesExcludesIfPresent(fileSet, params);
                    // Exclude non-interpolated dockerfile from source tree
                    // Interpolated Dockerfile is already added as it was created into the output directory when
                    // using dir dir mode
                    excludeDockerfile(fileSet, dockerFile);
                    // directly to docker.tar (as the output builddir is not picked up in archive mode)
                    if (isArchive(assemblyConfigurations)) {
                        String name = dockerFile.getName();
                        archiver.addFile(new File(buildDirs.getOutputDirectory(), name), name);
                    }
                    archiver.addFileSet(fileSet);
                    return archiver;
                }
            });
        } else {
            // Create custom docker file in output dir
            DockerFileBuilder builder = createDockerFileBuilder(buildConfig, assemblyConfigurations);
            builder.write(buildDirs.getOutputDirectory());
            // Add own Dockerfile
            final File dockerFile = new File(buildDirs.getOutputDirectory(), DOCKERFILE_NAME);
            archiveCustomizers.add(new ArchiverCustomizer() {

                @Override
                public TarArchiver customize(TarArchiver archiver) throws IOException {
                    archiver.addFile(dockerFile, DOCKERFILE_NAME);
                    return archiver;
                }
            });
        }
        // If required make all files in the assembly executable
        if (assemblyConfigurations.stream().anyMatch(assemblyConfig -> assemblyConfig.getPermissions() == AssemblyConfiguration.PermissionMode.exec || assemblyConfig.getPermissions() == AssemblyConfiguration.PermissionMode.auto && EnvUtil.isWindows())) {
            archiveCustomizers.add(new AllFilesExecCustomizer(log));
        }
        if (finalCustomizer != null) {
            archiveCustomizers.add(finalCustomizer);
        }
        return createBuildTarBall(buildDirs, archiveCustomizers, assemblyConfigurations, buildConfig.getCompression());
    } catch (IOException e) {
        throw new MojoExecutionException(String.format("Cannot create %s in %s", DOCKERFILE_NAME, buildDirs.getOutputDirectory()), e);
    }
}
Also used : FixedStringSearchInterpolator(org.codehaus.plexus.interpolation.fixed.FixedStringSearchInterpolator) DefaultFileSet(org.codehaus.plexus.archiver.util.DefaultFileSet) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) TarArchiver(org.codehaus.plexus.archiver.tar.TarArchiver) AssemblyConfiguration(io.fabric8.maven.docker.config.AssemblyConfiguration) File(java.io.File)

Example 65 with Builder

use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project syndesis-qe by syndesisio.

the class Syndesis method makeSyndesisContext.

private CustomResourceDefinitionContext makeSyndesisContext(String version) {
    CustomResourceDefinition syndesisCrd = getCrd();
    CustomResourceDefinitionContext.Builder builder = new CustomResourceDefinitionContext.Builder().withGroup(syndesisCrd.getSpec().getGroup()).withPlural(syndesisCrd.getSpec().getNames().getPlural()).withScope(syndesisCrd.getSpec().getScope()).withVersion(version);
    return builder.build();
}
Also used : CustomResourceDefinitionContext(io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext) CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinition)

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