Search in sources :

Example 1 with Artifact

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

the class KafkaConnectDockerfileTest method testNoUrlWhenRequired.

@ParallelTest
public void testNoUrlWhenRequired() {
    Artifact tgzArtifact = new TgzArtifactBuilder().build();
    Artifact jarArtifact = new JarArtifactBuilder().build();
    Artifact zipArtifact = new ZipArtifactBuilder().build();
    Artifact otherArtifact = new OtherArtifactBuilder().build();
    Build connectBuildTgz = new BuildBuilder().withPlugins(new PluginBuilder().withName("my-connector-plugin").withArtifacts(singletonList(tgzArtifact)).build()).build();
    Throwable e = assertThrows(InvalidConfigurationException.class, () -> new KafkaConnectDockerfile("myImage:latest", connectBuildTgz));
    assertThat(e.getMessage(), is("`tgz` artifact is missing a URL."));
    Build connectBuildZip = new BuildBuilder().withPlugins(new PluginBuilder().withName("my-connector-plugin").withArtifacts(singletonList(zipArtifact)).build()).build();
    e = assertThrows(InvalidConfigurationException.class, () -> new KafkaConnectDockerfile("myImage:latest", connectBuildZip));
    assertThat(e.getMessage(), is("`zip` artifact is missing a URL."));
    Build connectBuildJar = new BuildBuilder().withPlugins(new PluginBuilder().withName("my-connector-plugin").withArtifacts(singletonList(jarArtifact)).build()).build();
    e = assertThrows(InvalidConfigurationException.class, () -> new KafkaConnectDockerfile("myImage:latest", connectBuildJar));
    assertThat(e.getMessage(), is("`jar` artifact is missing a URL."));
    Build connectBuildOther = new BuildBuilder().withPlugins(new PluginBuilder().withName("my-connector-plugin").withArtifacts(singletonList(otherArtifact)).build()).build();
    e = assertThrows(InvalidConfigurationException.class, () -> new KafkaConnectDockerfile("myImage:latest", connectBuildOther));
    assertThat(e.getMessage(), is("`other` artifact is missing a URL."));
}
Also used : ZipArtifactBuilder(io.strimzi.api.kafka.model.connect.build.ZipArtifactBuilder) Build(io.strimzi.api.kafka.model.connect.build.Build) TgzArtifactBuilder(io.strimzi.api.kafka.model.connect.build.TgzArtifactBuilder) PluginBuilder(io.strimzi.api.kafka.model.connect.build.PluginBuilder) Artifact(io.strimzi.api.kafka.model.connect.build.Artifact) ZipArtifact(io.strimzi.api.kafka.model.connect.build.ZipArtifact) OtherArtifact(io.strimzi.api.kafka.model.connect.build.OtherArtifact) MavenArtifact(io.strimzi.api.kafka.model.connect.build.MavenArtifact) JarArtifact(io.strimzi.api.kafka.model.connect.build.JarArtifact) OtherArtifactBuilder(io.strimzi.api.kafka.model.connect.build.OtherArtifactBuilder) JarArtifactBuilder(io.strimzi.api.kafka.model.connect.build.JarArtifactBuilder) BuildBuilder(io.strimzi.api.kafka.model.connect.build.BuildBuilder) InvalidConfigurationException(io.strimzi.operator.common.InvalidConfigurationException) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 2 with Artifact

use of io.strimzi.api.kafka.model.connect.build.Artifact 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 3 with Artifact

use of io.strimzi.api.kafka.model.connect.build.Artifact 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 4 with Artifact

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

the class KafkaConnectDockerfileTest method testNoUrlWhenRequired.

@ParallelTest
public void testNoUrlWhenRequired() {
    Artifact tgzArtifact = new TgzArtifactBuilder().build();
    Artifact jarArtifact = new JarArtifactBuilder().build();
    Artifact zipArtifact = new ZipArtifactBuilder().build();
    Artifact otherArtifact = new OtherArtifactBuilder().build();
    Build connectBuildTgz = new BuildBuilder().withPlugins(new PluginBuilder().withName("my-connector-plugin").withArtifacts(singletonList(tgzArtifact)).build()).build();
    Throwable e = assertThrows(InvalidConfigurationException.class, () -> new KafkaConnectDockerfile("myImage:latest", connectBuildTgz));
    assertThat(e.getMessage(), is("`tgz` artifact is missing a URL."));
    Build connectBuildZip = new BuildBuilder().withPlugins(new PluginBuilder().withName("my-connector-plugin").withArtifacts(singletonList(zipArtifact)).build()).build();
    e = assertThrows(InvalidConfigurationException.class, () -> new KafkaConnectDockerfile("myImage:latest", connectBuildZip));
    assertThat(e.getMessage(), is("`zip` artifact is missing a URL."));
    Build connectBuildJar = new BuildBuilder().withPlugins(new PluginBuilder().withName("my-connector-plugin").withArtifacts(singletonList(jarArtifact)).build()).build();
    e = assertThrows(InvalidConfigurationException.class, () -> new KafkaConnectDockerfile("myImage:latest", connectBuildJar));
    assertThat(e.getMessage(), is("`jar` artifact is missing a URL."));
    Build connectBuildOther = new BuildBuilder().withPlugins(new PluginBuilder().withName("my-connector-plugin").withArtifacts(singletonList(otherArtifact)).build()).build();
    e = assertThrows(InvalidConfigurationException.class, () -> new KafkaConnectDockerfile("myImage:latest", connectBuildOther));
    assertThat(e.getMessage(), is("`other` artifact is missing a URL."));
}
Also used : ZipArtifactBuilder(io.strimzi.api.kafka.model.connect.build.ZipArtifactBuilder) Build(io.strimzi.api.kafka.model.connect.build.Build) TgzArtifactBuilder(io.strimzi.api.kafka.model.connect.build.TgzArtifactBuilder) PluginBuilder(io.strimzi.api.kafka.model.connect.build.PluginBuilder) Artifact(io.strimzi.api.kafka.model.connect.build.Artifact) ZipArtifact(io.strimzi.api.kafka.model.connect.build.ZipArtifact) OtherArtifact(io.strimzi.api.kafka.model.connect.build.OtherArtifact) MavenArtifact(io.strimzi.api.kafka.model.connect.build.MavenArtifact) JarArtifact(io.strimzi.api.kafka.model.connect.build.JarArtifact) OtherArtifactBuilder(io.strimzi.api.kafka.model.connect.build.OtherArtifactBuilder) JarArtifactBuilder(io.strimzi.api.kafka.model.connect.build.JarArtifactBuilder) BuildBuilder(io.strimzi.api.kafka.model.connect.build.BuildBuilder) InvalidConfigurationException(io.strimzi.operator.common.InvalidConfigurationException) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Aggregations

Artifact (io.strimzi.api.kafka.model.connect.build.Artifact)4 JarArtifact (io.strimzi.api.kafka.model.connect.build.JarArtifact)4 MavenArtifact (io.strimzi.api.kafka.model.connect.build.MavenArtifact)4 OtherArtifact (io.strimzi.api.kafka.model.connect.build.OtherArtifact)4 ZipArtifact (io.strimzi.api.kafka.model.connect.build.ZipArtifact)4 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 OtherArtifactBuilder (io.strimzi.api.kafka.model.connect.build.OtherArtifactBuilder)2 PluginBuilder (io.strimzi.api.kafka.model.connect.build.PluginBuilder)2 TgzArtifact (io.strimzi.api.kafka.model.connect.build.TgzArtifact)2 TgzArtifactBuilder (io.strimzi.api.kafka.model.connect.build.TgzArtifactBuilder)2 ZipArtifactBuilder (io.strimzi.api.kafka.model.connect.build.ZipArtifactBuilder)2 InvalidConfigurationException (io.strimzi.operator.common.InvalidConfigurationException)2 ParallelTest (io.strimzi.test.annotations.ParallelTest)2