Skip to content

Commit

Permalink
Support maven-coords based connector build (strimzi#5407)
Browse files Browse the repository at this point in the history
* Support maven-coords based connector build

Signed-off-by: Stanislav Knot <sknot@redhat.com>

* multistage build

Signed-off-by: Stanislav Knot <sknot@redhat.com>

* refactor

Signed-off-by: Stanislav Knot <sknot@redhat.com>

* fix test

Signed-off-by: Stanislav Knot <sknot@redhat.com>

* configurable maven image

Signed-off-by: Stanislav Knot <sknot@redhat.com>

* checksums

Signed-off-by: Stanislav Knot <sknot@redhat.com>

* addressing comments

Signed-off-by: Stanislav Knot <sknot@redhat.com>

* rename folder

Signed-off-by: Stanislav Knot <sknot@redhat.com>

* review comments

Signed-off-by: Stanislav Knot <sknot@redhat.com>

* review comments

Signed-off-by: Stanislav Knot <sknot@redhat.com>

* download jar in pre-stage

Signed-off-by: Stanislav Knot <sknot@redhat.com>

* spotbugs

Signed-off-by: Stanislav Knot <sknot@redhat.com>

* another review

Signed-off-by: Stanislav Knot <sknot@redhat.com>

* Tom B. code

Signed-off-by: Stanislav Knot <sknot@redhat.com>

* more comments

Signed-off-by: Stanislav Knot <sknot@redhat.com>

* review comments

Signed-off-by: Stanislav Knot <sknot@redhat.com>

* PR review

Signed-off-by: Stanislav Knot <sknot@redhat.com>

* rebase

Signed-off-by: Stanislav Knot <sknot@redhat.com>

* readme

Signed-off-by: Stanislav Knot <sknot@redhat.com>

* Maven plugins (strimzi#7)

* wip

Signed-off-by: Tom Bentley <tbentley@redhat.com>

* Refactor

Signed-off-by: Tom Bentley <tbentley@redhat.com>

* A little more quoting

Signed-off-by: Tom Bentley <tbentley@redhat.com>
Signed-off-by: Stanislav Knot <sknot@redhat.com>

* Tom's tweaks

Signed-off-by: Stanislav Knot <sknot@redhat.com>

Co-authored-by: Tom Bentley <tombentley@users.noreply.github.com>
  • Loading branch information
sknot-rh and tombentley authored Sep 8, 2021
1 parent 32be8cb commit 14b0dc4
Show file tree
Hide file tree
Showing 19 changed files with 637 additions and 177 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Expose JMX port on Zookeeper nodes via a headless service.
* Allow configuring labels and annotations for JMX authentication secrets
* Enable Cruise Control anomaly.detection configurations
* Add support for building connector images from the Maven coordinates

### Changes, deprecations and removals

Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ release_version:
$(FIND) ./packaging/install -name '*.yaml' -type f -exec $(SED) -i '/[0-9.]\+=quay.io\/strimzi\/kafka[a-zA-Z0-9_.-]\?\+:[a-zA-Z0-9_.-]\+-kafka-[0-9.]\+"\?/s/:[a-zA-Z0-9_.-]\+-kafka-\([0-9.]\+\)/:$(RELEASE_VERSION)-kafka-\1/g' {} \;
$(FIND) ./packaging/install -name '*.yaml' -type f -exec $(SED) -i '/value: "\?quay.io\/strimzi\/jmxtrans:[a-zA-Z0-9_.-]\+"\?/s/quay.io\/strimzi\/jmxtrans:[a-zA-Z0-9_.-]\+/quay.io\/strimzi\/jmxtrans:$(RELEASE_VERSION)/g' {} \;
$(FIND) ./packaging/install -name '*.yaml' -type f -exec $(SED) -i '/value: "\?quay.io\/strimzi\/kaniko-executor:[a-zA-Z0-9_.-]\+"\?/s/quay.io\/strimzi\/kaniko-executor:[a-zA-Z0-9_.-]\+/quay.io\/strimzi\/kaniko-executor:$(RELEASE_VERSION)/g' {} \;
$(FIND) ./packaging/install -name '*.yaml' -type f -exec $(SED) -i '/value: "\?quay.io\/strimzi\/maven-builder:[a-zA-Z0-9_.-]\+"\?/s/quay.io\/strimzi\/maven-builder:[a-zA-Z0-9_.-]\+/quay.io\/strimzi\/maven-builder:$(RELEASE_VERSION)/g' {} \;
# Set Kafka Bridge version to its own version
$(FIND) ./packaging/install -name '*.yaml' -type f -exec $(SED) -i '/value: "\?quay.io\/strimzi\/kafka-bridge:[a-zA-Z0-9_.-]\+"\?/s/quay.io\/strimzi\/kafka-bridge:[a-zA-Z0-9_.-]\+/quay.io\/strimzi\/kafka-bridge:$(BRIDGE_VERSION)/g' {} \;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
@JsonSubTypes.Type(value = JarArtifact.class, name = Artifact.TYPE_JAR),
@JsonSubTypes.Type(value = TgzArtifact.class, name = Artifact.TYPE_TGZ),
@JsonSubTypes.Type(value = ZipArtifact.class, name = Artifact.TYPE_ZIP),
@JsonSubTypes.Type(value = MavenArtifact.class, name = Artifact.TYPE_MVN),
@JsonSubTypes.Type(value = OtherArtifact.class, name = Artifact.TYPE_OTHER)
}
)
Expand All @@ -39,12 +40,13 @@ public abstract class Artifact implements UnknownPropertyPreserving, Serializabl
public static final String TYPE_JAR = "jar";
public static final String TYPE_TGZ = "tgz";
public static final String TYPE_ZIP = "zip";
public static final String TYPE_MVN = "maven";
public static final String TYPE_OTHER = "other";

private Map<String, Object> additionalProperties = new HashMap<>(0);

@Description("Artifact type. " +
"Currently, the supported artifact types are `tgz`, `jar`, and `zip`.")
"Currently, the supported artifact types are `tgz`, `jar`, `zip` and `maven`.")
public abstract String getType();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package io.strimzi.api.kafka.model.connect.build;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.strimzi.api.kafka.model.Constants;
import io.strimzi.crdgenerator.annotations.Description;
import io.strimzi.crdgenerator.annotations.Pattern;
Expand All @@ -30,8 +29,8 @@ public abstract class DownloadableArtifact extends Artifact {
@Description("URL of the artifact which will be downloaded. " +
"Strimzi does not do any security scanning of the downloaded artifacts. " +
"For security reasons, you should first verify the artifacts manually and configure the checksum verification to make sure the same artifact is used in the automated build. " +
"Required.")
@JsonProperty(required = true)
"Required for `jar`, `zip`, `tgz` and `other` artifacts. " +
"Not applicable to the `maven` artifact type.")
@Pattern("^(https?|ftp)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]")
public String getUrl() {
return url;
Expand All @@ -44,7 +43,8 @@ public void setUrl(String url) {
@Description("SHA512 checksum of the artifact. " +
"Optional. " +
"If specified, the checksum will be verified while building the new container. " +
"If not specified, the downloaded artifact will not be verified.")
"If not specified, the downloaded artifact will not be verified. " +
"Not applicable to the `maven` artifact type. ")
@JsonInclude(JsonInclude.Include.NON_NULL)
public String getSha512sum() {
return sha512sum;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright Strimzi authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.strimzi.api.kafka.model.connect.build;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import io.strimzi.api.kafka.model.Constants;
import io.strimzi.crdgenerator.annotations.Description;
import io.sundr.builder.annotations.Buildable;
import io.vertx.core.cli.annotations.DefaultValue;
import lombok.EqualsAndHashCode;

/**
* Maven artifact represents an artifact which is downloaded from Maven repository
*/
@Buildable(
editableEnabled = false,
builderPackage = Constants.FABRIC8_KUBERNETES_API
)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({ "repository", "group", "artifact", "version" })
@EqualsAndHashCode
public class MavenArtifact extends Artifact {
private static final long serialVersionUID = 1L;
public static final String DEFAULT_REPOSITORY = "https://repo1.maven.org/maven2/";

private String group;
private String artifact;
private String version;
private String repository;

@Description("Must be `" + TYPE_MVN + "`")
@JsonInclude(JsonInclude.Include.NON_NULL)
@Override
public String getType() {
return TYPE_MVN;
}

@Description("Maven group id. Applicable to the `maven` artifact type only.")
public String getGroup() {
return group;
}

public void setGroup(String group) {
this.group = group;
}

@Description("Maven artifact id. Applicable to the `maven` artifact type only.")
public String getArtifact() {
return artifact;
}

public void setArtifact(String artifact) {
this.artifact = artifact;
}

@Description("Maven version number. Applicable to the `maven` artifact type only.")
public String getVersion() {
return version;
}

public void setVersion(String version) {
this.version = version;
}

@Description("Maven repository to download the artifact from. Applicable to the `maven` artifact type only.")
@DefaultValue("https://repo1.maven.org/maven2/")
public String getRepository() {
return repository;
}

public void setRepository(String repository) {
this.repository = repository;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class ClusterOperatorConfig {
public static final String STRIMZI_DEFAULT_KAFKA_BRIDGE_IMAGE = "STRIMZI_DEFAULT_KAFKA_BRIDGE_IMAGE";
public static final String STRIMZI_DEFAULT_CRUISE_CONTROL_IMAGE = "STRIMZI_DEFAULT_CRUISE_CONTROL_IMAGE";
public static final String STRIMZI_DEFAULT_KANIKO_EXECUTOR_IMAGE = "STRIMZI_DEFAULT_KANIKO_EXECUTOR_IMAGE";
public static final String STRIMZI_DEFAULT_MAVEN_BUILDER = "STRIMZI_DEFAULT_MAVEN_BUILDER";

public static final long DEFAULT_FULL_RECONCILIATION_INTERVAL_MS = 120_000;
public static final long DEFAULT_OPERATION_TIMEOUT_MS = 300_000;
Expand Down
Loading

0 comments on commit 14b0dc4

Please sign in to comment.