Search in sources :

Example 1 with MavenArtifact

use of io.strimzi.api.kafka.model.connect.build.MavenArtifact in project strimzi-kafka-operator by strimzi.

the class KafkaConnectDockerfile method addPlugin.

/**
 * Adds a particular connector plugin to the container image. It will go through the individual artifacts and add
 * them one by one depending on their type.
 *
 * @param writer    Writer for printing the Docker commands
 * @param plugin    A single plugin which should be added to the new container image
 */
private void addPlugin(PrintWriter writer, Plugin plugin) {
    printSectionHeader(writer, "Connector plugin " + plugin.getName());
    String connectorPath = BASE_PLUGIN_PATH + plugin.getName();
    for (Artifact art : plugin.getArtifacts()) {
        if (art instanceof JarArtifact) {
            addJarArtifact(writer, connectorPath, (JarArtifact) art);
        } else if (art instanceof TgzArtifact) {
            addTgzArtifact(writer, connectorPath, (TgzArtifact) art);
        } else if (art instanceof ZipArtifact) {
            addZipArtifact(writer, connectorPath, (ZipArtifact) art);
        } else if (art instanceof MavenArtifact) {
            addMavenArtifact(writer, plugin.getName(), (MavenArtifact) art);
        } else if (art instanceof OtherArtifact) {
            addOtherArtifact(writer, connectorPath, (OtherArtifact) art);
        } else {
            throw new RuntimeException("Unexpected artifact type " + art.getType());
        }
    }
}
Also used : ZipArtifact(io.strimzi.api.kafka.model.connect.build.ZipArtifact) OtherArtifact(io.strimzi.api.kafka.model.connect.build.OtherArtifact) JarArtifact(io.strimzi.api.kafka.model.connect.build.JarArtifact) TgzArtifact(io.strimzi.api.kafka.model.connect.build.TgzArtifact) MavenArtifact(io.strimzi.api.kafka.model.connect.build.MavenArtifact) Artifact(io.strimzi.api.kafka.model.connect.build.Artifact) DownloadableArtifact(io.strimzi.api.kafka.model.connect.build.DownloadableArtifact) ZipArtifact(io.strimzi.api.kafka.model.connect.build.ZipArtifact) OtherArtifact(io.strimzi.api.kafka.model.connect.build.OtherArtifact) TgzArtifact(io.strimzi.api.kafka.model.connect.build.TgzArtifact) MavenArtifact(io.strimzi.api.kafka.model.connect.build.MavenArtifact) JarArtifact(io.strimzi.api.kafka.model.connect.build.JarArtifact)

Example 2 with MavenArtifact

use of io.strimzi.api.kafka.model.connect.build.MavenArtifact in project strimzi by strimzi.

the class KafkaConnectDockerfile method addPlugin.

/**
 * Adds a particular connector plugin to the container image. It will go through the individual artifacts and add
 * them one by one depending on their type.
 *
 * @param writer    Writer for printing the Docker commands
 * @param plugin    A single plugin which should be added to the new container image
 */
private void addPlugin(PrintWriter writer, Plugin plugin) {
    printSectionHeader(writer, "Connector plugin " + plugin.getName());
    String connectorPath = BASE_PLUGIN_PATH + plugin.getName();
    for (Artifact art : plugin.getArtifacts()) {
        if (art instanceof JarArtifact) {
            addJarArtifact(writer, connectorPath, (JarArtifact) art);
        } else if (art instanceof TgzArtifact) {
            addTgzArtifact(writer, connectorPath, (TgzArtifact) art);
        } else if (art instanceof ZipArtifact) {
            addZipArtifact(writer, connectorPath, (ZipArtifact) art);
        } else if (art instanceof MavenArtifact) {
            addMavenArtifact(writer, plugin.getName(), (MavenArtifact) art);
        } else if (art instanceof OtherArtifact) {
            addOtherArtifact(writer, connectorPath, (OtherArtifact) art);
        } else {
            throw new RuntimeException("Unexpected artifact type " + art.getType());
        }
    }
}
Also used : ZipArtifact(io.strimzi.api.kafka.model.connect.build.ZipArtifact) OtherArtifact(io.strimzi.api.kafka.model.connect.build.OtherArtifact) JarArtifact(io.strimzi.api.kafka.model.connect.build.JarArtifact) TgzArtifact(io.strimzi.api.kafka.model.connect.build.TgzArtifact) MavenArtifact(io.strimzi.api.kafka.model.connect.build.MavenArtifact) Artifact(io.strimzi.api.kafka.model.connect.build.Artifact) DownloadableArtifact(io.strimzi.api.kafka.model.connect.build.DownloadableArtifact) ZipArtifact(io.strimzi.api.kafka.model.connect.build.ZipArtifact) OtherArtifact(io.strimzi.api.kafka.model.connect.build.OtherArtifact) TgzArtifact(io.strimzi.api.kafka.model.connect.build.TgzArtifact) MavenArtifact(io.strimzi.api.kafka.model.connect.build.MavenArtifact) JarArtifact(io.strimzi.api.kafka.model.connect.build.JarArtifact)

Example 3 with MavenArtifact

use of io.strimzi.api.kafka.model.connect.build.MavenArtifact in project strimzi by strimzi.

the class KafkaConnectDockerfileTest method testMavenDockerfile.

@ParallelTest
public void testMavenDockerfile() {
    JarArtifact jar = new JarArtifactBuilder().withUrl("http://url.com/ar.jar").build();
    MavenArtifact mvn1 = new MavenArtifactBuilder().withGroup("g1").withArtifact("a1").withVersion("v1").build();
    MavenArtifact mvn2 = new MavenArtifactBuilder().withGroup("g2").withArtifact("a2").withVersion("v2").build();
    Build connectBuild = new BuildBuilder().withPlugins(new PluginBuilder().withName("my-connector-plugin").withArtifacts(jar, mvn1, mvn2).build(), new PluginBuilder().withName("other-connector-plugin").withArtifacts(jar).build()).build();
    KafkaConnectDockerfile df = new KafkaConnectDockerfile("myImage:latest", connectBuild);
    assertThat(df.getDockerfile(), is("##############################\n" + "##############################\n" + "# This file is automatically generated by the Strimzi Cluster Operator\n" + "# Any changes to this file will be ignored and overwritten!\n" + "##############################\n" + "##############################\n" + "\n" + "FROM quay.io/strimzi/maven-builder:latest AS downloadArtifacts\n" + "RUN 'curl' '-L' '--create-dirs' '--output' '/tmp/my-connector-plugin/64cebd9c/pom.xml' 'https://repo1.maven.org/maven2/g1/a1/v1/a1-v1.pom' \\\n" + "      && 'mvn' 'dependency:copy-dependencies' '-DoutputDirectory=/tmp/artifacts/my-connector-plugin/64cebd9c' '-f' '/tmp/my-connector-plugin/64cebd9c/pom.xml' \\\n" + "      && 'curl' '-L' '--create-dirs' '--output' '/tmp/artifacts/my-connector-plugin/64cebd9c/a1-v1.jar' 'https://repo1.maven.org/maven2/g1/a1/v1/a1-v1.jar'\n" + "\n" + "RUN 'curl' '-L' '--create-dirs' '--output' '/tmp/my-connector-plugin/9983060e/pom.xml' 'https://repo1.maven.org/maven2/g2/a2/v2/a2-v2.pom' \\\n" + "      && 'mvn' 'dependency:copy-dependencies' '-DoutputDirectory=/tmp/artifacts/my-connector-plugin/9983060e' '-f' '/tmp/my-connector-plugin/9983060e/pom.xml' \\\n" + "      && 'curl' '-L' '--create-dirs' '--output' '/tmp/artifacts/my-connector-plugin/9983060e/a2-v2.jar' 'https://repo1.maven.org/maven2/g2/a2/v2/a2-v2.jar'\n" + "\n" + "FROM myImage:latest\n" + "\n" + "USER root:root\n" + "\n" + "##########\n" + "# Connector plugin my-connector-plugin\n" + "##########\n" + "RUN 'mkdir' '-p' '/opt/kafka/plugins/my-connector-plugin/9bb2fd11' \\\n" + "      && 'curl' '-L' '--output' '/opt/kafka/plugins/my-connector-plugin/9bb2fd11/9bb2fd11.jar' 'http://url.com/ar.jar'\n" + "\n" + "COPY --from=downloadArtifacts '/tmp/artifacts/my-connector-plugin/64cebd9c' '/opt/kafka/plugins/my-connector-plugin/64cebd9c'\n" + "\n" + "COPY --from=downloadArtifacts '/tmp/artifacts/my-connector-plugin/9983060e' '/opt/kafka/plugins/my-connector-plugin/9983060e'\n" + "\n" + "##########\n" + "# Connector plugin other-connector-plugin\n" + "##########\n" + "RUN 'mkdir' '-p' '/opt/kafka/plugins/other-connector-plugin/9bb2fd11' \\\n" + "      && 'curl' '-L' '--output' '/opt/kafka/plugins/other-connector-plugin/9bb2fd11/9bb2fd11.jar' 'http://url.com/ar.jar'\n" + "\n" + "USER 1001\n" + "\n"));
}
Also used : Build(io.strimzi.api.kafka.model.connect.build.Build) JarArtifact(io.strimzi.api.kafka.model.connect.build.JarArtifact) MavenArtifact(io.strimzi.api.kafka.model.connect.build.MavenArtifact) PluginBuilder(io.strimzi.api.kafka.model.connect.build.PluginBuilder) JarArtifactBuilder(io.strimzi.api.kafka.model.connect.build.JarArtifactBuilder) MavenArtifactBuilder(io.strimzi.api.kafka.model.connect.build.MavenArtifactBuilder) BuildBuilder(io.strimzi.api.kafka.model.connect.build.BuildBuilder) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 4 with MavenArtifact

use of io.strimzi.api.kafka.model.connect.build.MavenArtifact in project strimzi-kafka-operator by strimzi.

the class KafkaConnectDockerfileTest method testMavenDockerfile.

@ParallelTest
public void testMavenDockerfile() {
    JarArtifact jar = new JarArtifactBuilder().withUrl("http://url.com/ar.jar").build();
    MavenArtifact mvn1 = new MavenArtifactBuilder().withGroup("g1").withArtifact("a1").withVersion("v1").build();
    MavenArtifact mvn2 = new MavenArtifactBuilder().withGroup("g2").withArtifact("a2").withVersion("v2").build();
    Build connectBuild = new BuildBuilder().withPlugins(new PluginBuilder().withName("my-connector-plugin").withArtifacts(jar, mvn1, mvn2).build(), new PluginBuilder().withName("other-connector-plugin").withArtifacts(jar).build()).build();
    KafkaConnectDockerfile df = new KafkaConnectDockerfile("myImage:latest", connectBuild);
    assertThat(df.getDockerfile(), is("##############################\n" + "##############################\n" + "# This file is automatically generated by the Strimzi Cluster Operator\n" + "# Any changes to this file will be ignored and overwritten!\n" + "##############################\n" + "##############################\n" + "\n" + "FROM quay.io/strimzi/maven-builder:latest AS downloadArtifacts\n" + "RUN 'curl' '-L' '--create-dirs' '--output' '/tmp/my-connector-plugin/64cebd9c/pom.xml' 'https://repo1.maven.org/maven2/g1/a1/v1/a1-v1.pom' \\\n" + "      && 'mvn' 'dependency:copy-dependencies' '-DoutputDirectory=/tmp/artifacts/my-connector-plugin/64cebd9c' '-f' '/tmp/my-connector-plugin/64cebd9c/pom.xml' \\\n" + "      && 'curl' '-L' '--create-dirs' '--output' '/tmp/artifacts/my-connector-plugin/64cebd9c/a1-v1.jar' 'https://repo1.maven.org/maven2/g1/a1/v1/a1-v1.jar'\n" + "\n" + "RUN 'curl' '-L' '--create-dirs' '--output' '/tmp/my-connector-plugin/9983060e/pom.xml' 'https://repo1.maven.org/maven2/g2/a2/v2/a2-v2.pom' \\\n" + "      && 'mvn' 'dependency:copy-dependencies' '-DoutputDirectory=/tmp/artifacts/my-connector-plugin/9983060e' '-f' '/tmp/my-connector-plugin/9983060e/pom.xml' \\\n" + "      && 'curl' '-L' '--create-dirs' '--output' '/tmp/artifacts/my-connector-plugin/9983060e/a2-v2.jar' 'https://repo1.maven.org/maven2/g2/a2/v2/a2-v2.jar'\n" + "\n" + "FROM myImage:latest\n" + "\n" + "USER root:root\n" + "\n" + "##########\n" + "# Connector plugin my-connector-plugin\n" + "##########\n" + "RUN 'mkdir' '-p' '/opt/kafka/plugins/my-connector-plugin/9bb2fd11' \\\n" + "      && 'curl' '-L' '--output' '/opt/kafka/plugins/my-connector-plugin/9bb2fd11/9bb2fd11.jar' 'http://url.com/ar.jar'\n" + "\n" + "COPY --from=downloadArtifacts '/tmp/artifacts/my-connector-plugin/64cebd9c' '/opt/kafka/plugins/my-connector-plugin/64cebd9c'\n" + "\n" + "COPY --from=downloadArtifacts '/tmp/artifacts/my-connector-plugin/9983060e' '/opt/kafka/plugins/my-connector-plugin/9983060e'\n" + "\n" + "##########\n" + "# Connector plugin other-connector-plugin\n" + "##########\n" + "RUN 'mkdir' '-p' '/opt/kafka/plugins/other-connector-plugin/9bb2fd11' \\\n" + "      && 'curl' '-L' '--output' '/opt/kafka/plugins/other-connector-plugin/9bb2fd11/9bb2fd11.jar' 'http://url.com/ar.jar'\n" + "\n" + "USER 1001\n" + "\n"));
}
Also used : Build(io.strimzi.api.kafka.model.connect.build.Build) JarArtifact(io.strimzi.api.kafka.model.connect.build.JarArtifact) MavenArtifact(io.strimzi.api.kafka.model.connect.build.MavenArtifact) PluginBuilder(io.strimzi.api.kafka.model.connect.build.PluginBuilder) JarArtifactBuilder(io.strimzi.api.kafka.model.connect.build.JarArtifactBuilder) MavenArtifactBuilder(io.strimzi.api.kafka.model.connect.build.MavenArtifactBuilder) BuildBuilder(io.strimzi.api.kafka.model.connect.build.BuildBuilder) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Aggregations

JarArtifact (io.strimzi.api.kafka.model.connect.build.JarArtifact)4 MavenArtifact (io.strimzi.api.kafka.model.connect.build.MavenArtifact)4 Artifact (io.strimzi.api.kafka.model.connect.build.Artifact)2 Build (io.strimzi.api.kafka.model.connect.build.Build)2 BuildBuilder (io.strimzi.api.kafka.model.connect.build.BuildBuilder)2 DownloadableArtifact (io.strimzi.api.kafka.model.connect.build.DownloadableArtifact)2 JarArtifactBuilder (io.strimzi.api.kafka.model.connect.build.JarArtifactBuilder)2 MavenArtifactBuilder (io.strimzi.api.kafka.model.connect.build.MavenArtifactBuilder)2 OtherArtifact (io.strimzi.api.kafka.model.connect.build.OtherArtifact)2 PluginBuilder (io.strimzi.api.kafka.model.connect.build.PluginBuilder)2 TgzArtifact (io.strimzi.api.kafka.model.connect.build.TgzArtifact)2 ZipArtifact (io.strimzi.api.kafka.model.connect.build.ZipArtifact)2 ParallelTest (io.strimzi.test.annotations.ParallelTest)2