use of io.strimzi.api.kafka.model.connect.build.PluginBuilder in project strimzi by strimzi.
the class KafkaConnectBuildTest method testValidKanikoOptions.
@ParallelTest
public void testValidKanikoOptions() {
List<String> expectedArgs = new ArrayList<>(defaultArgs);
expectedArgs.add("--reproducible");
expectedArgs.add("--single-snapshot");
expectedArgs.add("--log-format=json");
KafkaConnect kc = new KafkaConnectBuilder().withNewMetadata().withName(cluster).withNamespace(namespace).endMetadata().withNewSpec().withBootstrapServers("my-kafka:9092").withNewBuild().withNewDockerOutput().withImage("my-image:latest").withPushSecret("my-docker-credentials").withAdditionalKanikoOptions("--reproducible", "--single-snapshot", "--log-format=json").endDockerOutput().withPlugins(new PluginBuilder().withName("my-connector").withArtifacts(jarArtifactWithChecksum).build(), new PluginBuilder().withName("my-connector2").withArtifacts(jarArtifactNoChecksum).build()).endBuild().endSpec().build();
KafkaConnectBuild build = KafkaConnectBuild.fromCrd(new Reconciliation("test", kc.getKind(), kc.getMetadata().getNamespace(), kc.getMetadata().getName()), kc, VERSIONS);
Pod pod = build.generateBuilderPod(true, ImagePullPolicy.IFNOTPRESENT, null, null);
assertThat(pod.getSpec().getContainers().get(0).getArgs(), is(expectedArgs));
}
use of io.strimzi.api.kafka.model.connect.build.PluginBuilder in project strimzi by strimzi.
the class KafkaConnectBuildTest method testInvalidKanikoOptions.
@ParallelTest
public void testInvalidKanikoOptions() {
KafkaConnect kc = new KafkaConnectBuilder().withNewMetadata().withName(cluster).withNamespace(namespace).endMetadata().withNewSpec().withBootstrapServers("my-kafka:9092").withNewBuild().withNewDockerOutput().withImage("my-image:latest").withPushSecret("my-docker-credentials").withAdditionalKanikoOptions("--reproducible", "--reproducible-something", "--build-arg", "--single-snapshot", "--digest-file=/dev/null", "--log-format=json").endDockerOutput().withPlugins(new PluginBuilder().withName("my-connector").withArtifacts(jarArtifactWithChecksum).build(), new PluginBuilder().withName("my-connector2").withArtifacts(jarArtifactNoChecksum).build()).endBuild().endSpec().build();
InvalidResourceException e = assertThrows(InvalidResourceException.class, () -> KafkaConnectBuild.fromCrd(new Reconciliation("test", kc.getKind(), kc.getMetadata().getNamespace(), kc.getMetadata().getName()), kc, VERSIONS));
assertThat(e.getMessage(), containsString(".spec.build.additionalKanikoOptions contains forbidden options: [--reproducible-something, --build-arg, --digest-file]"));
}
use of io.strimzi.api.kafka.model.connect.build.PluginBuilder in project strimzi by strimzi.
the class KafkaConnectDockerfileTest method testNoChecksumTgzArtifact.
@ParallelTest
public void testNoChecksumTgzArtifact() {
Build connectBuild = new BuildBuilder().withPlugins(new PluginBuilder().withName("my-connector-plugin").withArtifacts(tgzArtifactNoChecksum).build()).build();
KafkaConnectDockerfile df = new KafkaConnectDockerfile("myImage:latest", connectBuild);
assertThat(df.getDockerfile(), isEquivalent("FROM myImage:latest", "USER root:root", "RUN 'mkdir' '-p' '/opt/kafka/plugins/my-connector-plugin/6718766b' \\", " && 'curl' '-L' '--output' '/opt/kafka/plugins/my-connector-plugin/6718766b.tgz' 'https://mydomain.tld/my.tgz' \\", " && 'tar' 'xvfz' '/opt/kafka/plugins/my-connector-plugin/6718766b.tgz' '-C' '/opt/kafka/plugins/my-connector-plugin/6718766b' \\", " && 'rm' '-vf' '/opt/kafka/plugins/my-connector-plugin/6718766b.tgz'", "USER 1001"));
}
use of io.strimzi.api.kafka.model.connect.build.PluginBuilder in project strimzi by strimzi.
the class KafkaConnectDockerfileTest method testChecksumOtherArtifact.
@ParallelTest
public void testChecksumOtherArtifact() {
Build connectBuild = new BuildBuilder().withPlugins(new PluginBuilder().withName("my-connector-plugin").withArtifacts(otherArtifactWithChecksum).build()).build();
KafkaConnectDockerfile df = new KafkaConnectDockerfile("myImage:latest", connectBuild);
assertThat(df.getDockerfile(), isEquivalent("FROM myImage:latest", "USER root:root", "RUN 'mkdir' '-p' '/opt/kafka/plugins/my-connector-plugin/2e6fee06' \\", " && 'curl' '-L' '--output' '/opt/kafka/plugins/my-connector-plugin/2e6fee06/my2.so' 'https://mydomain.tld/download?artifactId=1874' \\", " && 'echo' 'sha-512-checksum /opt/kafka/plugins/my-connector-plugin/2e6fee06/my2.so' > '/opt/kafka/plugins/my-connector-plugin/2e6fee06/my2.so.sha512' \\", " && 'sha512sum' '--check' '/opt/kafka/plugins/my-connector-plugin/2e6fee06/my2.so.sha512' \\", " && 'rm' '-f' '/opt/kafka/plugins/my-connector-plugin/2e6fee06/my2.so.sha512'", "USER 1001"));
}
use of io.strimzi.api.kafka.model.connect.build.PluginBuilder in project strimzi by strimzi.
the class KafkaConnectDockerfileTest method testChecksumOtherArtifactWithoutName.
@ParallelTest
public void testChecksumOtherArtifactWithoutName() {
Build connectBuild = new BuildBuilder().withPlugins(new PluginBuilder().withName("my-connector-plugin").withArtifacts(otherArtifactWithChecksumWithoutName).build()).build();
KafkaConnectDockerfile df = new KafkaConnectDockerfile("myImage:latest", connectBuild);
assertThat(df.getDockerfile(), isEquivalent("FROM myImage:latest", "USER root:root", "RUN 'mkdir' '-p' '/opt/kafka/plugins/my-connector-plugin/2e6fee06' \\", " && 'curl' '-L' '--output' '/opt/kafka/plugins/my-connector-plugin/2e6fee06/2e6fee06' 'https://mydomain.tld/download?artifactId=1874' \\", " && 'echo' 'sha-512-checksum /opt/kafka/plugins/my-connector-plugin/2e6fee06/2e6fee06' > '/opt/kafka/plugins/my-connector-plugin/2e6fee06/2e6fee06.sha512' \\", " && 'sha512sum' '--check' '/opt/kafka/plugins/my-connector-plugin/2e6fee06/2e6fee06.sha512' \\", " && 'rm' '-f' '/opt/kafka/plugins/my-connector-plugin/2e6fee06/2e6fee06.sha512'", "USER 1001"));
}
Aggregations