Search in sources :

Example 6 with ImageName

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

the class UrlBuilderTest method getImage.

@Test
public void getImage() throws URISyntaxException {
    UrlBuilder builder = new UrlBuilder("", "1.0");
    assertEquals(new URI("/1.0/images/n1%3Alatest/get"), new URI(builder.getImage(new ImageName("n1:latest"))));
}
Also used : ImageName(io.fabric8.maven.docker.util.ImageName) UrlBuilder(io.fabric8.maven.docker.access.UrlBuilder) Test(org.junit.Test)

Example 7 with ImageName

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

the class BuildMojo method executeInternal.

@Override
protected void executeInternal(ServiceHub hub) throws DockerAccessException, MojoExecutionException {
    if (skipBuild) {
        return;
    }
    List<ImageConfiguration> resolvedImages = getResolvedImages();
    if (resolvedImages.isEmpty()) {
        // No Configuration found, so build one up dynamically.
        if (imageName == null) {
            /*
                 * Image name defaults to:
                 *     `${project.groupId}/${project.artifactId}:${project.version}`
                 */
            imageName = project.getGroupId() + "/" + project.getArtifactId() + ":" + project.getVersion();
        }
        ImageConfiguration aDefaultImageConfig = ImageConfiguration.getDefaultImageConfiguration(imageName, project.getBasedir().getAbsolutePath());
        processImageConfig(hub, aDefaultImageConfig);
        return;
    } else {
        // Iterate over all the ImageConfigurations and process one by one
        for (ImageConfiguration imageConfig : resolvedImages) {
            processImageConfig(hub, imageConfig);
        }
    }
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration)

Example 8 with ImageName

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

the class SaveMojo method getFileName.

private String getFileName(String iName) throws MojoExecutionException {
    String configuredFileName = getConfiguredFileName();
    if (configuredFileName != null) {
        return configuredFileName;
    }
    if (saveAlias != null) {
        return completeCalculatedFileName(saveAlias + "-" + project.getVersion() + "." + STANDARD_ARCHIVE_COMPRESSION.getFileSuffix());
    }
    ImageName imageName = new ImageName(iName);
    return completeCalculatedFileName(imageName.getSimpleName() + "-" + imageName.getTag()) + "." + STANDARD_ARCHIVE_COMPRESSION.getFileSuffix();
}
Also used : ImageName(io.fabric8.maven.docker.util.ImageName)

Example 9 with ImageName

use of io.fabric8.maven.docker.util.ImageName in project ballerina by ballerina-lang.

the class TestUtils method deleteDockerImage.

public static void deleteDockerImage(String imageName) {
    if (!imageName.contains(":")) {
        imageName += ":" + Constants.IMAGE_VERSION_LATEST;
    }
    DockerClient client = new io.fabric8.docker.client.DefaultDockerClient();
    List<ImageDelete> imageDeleteList = client.image().withName(imageName).delete().force().andPrune(false);
    for (ImageDelete imageDelete : imageDeleteList) {
        imageDelete.getDeleted();
        imageDelete.getUntagged();
    }
}
Also used : ImageDelete(io.fabric8.docker.api.model.ImageDelete) DockerClient(io.fabric8.docker.client.DockerClient)

Example 10 with ImageName

use of io.fabric8.maven.docker.util.ImageName in project ballerina by ballerina-lang.

the class DefaultBallerinaDockerClient method buildImage.

/*
    Execute a Docker image build using Fabric8 DSL.
     */
private void buildImage(String dockerEnv, String imageName, Path tmpDir, String buildArgs) throws InterruptedException, IOException {
    DockerClient client = getDockerClient(dockerEnv);
    OutputHandle buildHandle = client.image().build().withRepositoryName(imageName).withNoCache().alwaysRemovingIntermediate().withBuildArgs(buildArgs).usingListener(new DockerBuilderEventListener()).fromFolder(tmpDir.toString());
    buildDone.await();
    buildHandle.close();
    client.close();
}
Also used : DockerClient(io.fabric8.docker.client.DockerClient) BallerinaDockerClient(org.ballerinalang.containers.docker.BallerinaDockerClient) OutputHandle(io.fabric8.docker.dsl.OutputHandle)

Aggregations

ImageName (io.fabric8.maven.docker.util.ImageName)13 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)5 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)5 Test (org.junit.Test)5 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)4 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)4 File (java.io.File)4 DockerClient (io.fabric8.docker.client.DockerClient)3 Container (io.fabric8.kubernetes.api.model.Container)3 PodSpec (io.fabric8.kubernetes.api.model.PodSpec)3 DockerAccessException (io.fabric8.maven.docker.access.DockerAccessException)3 UrlBuilder (io.fabric8.maven.docker.access.UrlBuilder)3 IOException (java.io.IOException)3 Controller (io.fabric8.kubernetes.api.Controller)2 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)2 ReplicationController (io.fabric8.kubernetes.api.model.ReplicationController)2 Deployment (io.fabric8.kubernetes.api.model.extensions.Deployment)2 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2