Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @Buildable annotation to all model classes for generating the Builder classes #49

Merged
merged 9 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .azure/templates/jobs/build_java.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ jobs:
- template: '../steps/prerequisites/install_java.yaml'
parameters:
JDK_VERSION: $(jdk_version)
# Build the Java code without tests
katheris marked this conversation as resolved.
Show resolved Hide resolved
- bash: "make java_install"
displayName: "Build Java code"
env:
MVN_ARGS: "-DskipTests -e -V -B"
- bash: "make spotbugs"
displayName: "Run Spotbugs"
env:
Expand All @@ -38,7 +43,7 @@ jobs:
displayName: "Check for uncommitted files"
# We have to TAR the target directory to maintain the permissions of
# the files which would otherwise change when downloading the artifact
- bash: tar -cvpf target.tar ./target
- bash: tar -cvpf target.tar ./operator/target
displayName: "Tar the target directory"
- publish: $(System.DefaultWorkingDirectory)/target.tar
artifact: Binary
Expand Down
2 changes: 2 additions & 0 deletions .checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@
* To suppress warning we do not want for the whole project
* To suppress file-level warnings
In all other cases, you should use the annotations on the methods or classes affected by it. -->
<suppress checks=".*"
files="io[/\\]strimzi[/\\]kafka[/\\]access[/\\]model[/\\].*(Builder|Fluent|FluentImpl)\.java"/>
</suppressions>
3 changes: 3 additions & 0 deletions .spotbugs/spotbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@
<Match>
<Bug pattern="EI_EXPOSE_REP2"/>
</Match>
<Match>
<Class name="~io\.strimzi\.kafka\.access\.model\..+(Builder|Fluent|FluentImpl)(\$.*)?" />
</Match>
</FindBugsFilter>
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ WORKDIR ${STRIMZI_HOME}
#####
# Add Kafka Access Operator
#####
COPY target/kafka-access-operator-${access_operator_version}/kafka-access-operator-${access_operator_version} ./
COPY operator/target/operator-${access_operator_version} ./

#####
# Add Tini
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ clean: java_clean

.PHONY: crd_install
crd_install:
$(CP) ./target/classes/META-INF/fabric8/kafkaaccesses.access.strimzi.io-v1.yml ./packaging/install/040-Crd-kafkaaccess.yaml
$(CP) ./api/target/classes/META-INF/fabric8/kafkaaccesses.access.strimzi.io-v1.yml ./packaging/install/040-Crd-kafkaaccess.yaml
yq eval -i '.metadata.labels."servicebinding.io/provisioned-service"="true"' ./packaging/install/040-Crd-kafkaaccess.yaml

.PHONY: next_version
Expand Down
82 changes: 82 additions & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.strimzi.kafka.access</groupId>
<artifactId>kafka-access-operator</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>

<artifactId>api</artifactId>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<javadoc.fail.on.warnings>false</javadoc.fail.on.warnings>
</properties>

<dependencies>
<dependency>
<groupId>io.javaoperatorsdk</groupId>
<artifactId>operator-framework-core</artifactId>
<exclusions>
<exclusion>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-httpclient-okhttp</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-httpclient-jdk</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client-api</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-core</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-common</artifactId>
</dependency>
<!-- Required to generate CRD file -->
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>crd-generator-apt</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.strimzi</groupId>
<artifactId>api</artifactId>
<exclusions>
<exclusion>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
*/
package io.strimzi.kafka.access.model;

import io.strimzi.api.kafka.model.Constants;
import io.sundr.builder.annotations.Buildable;

/**
* The status class for keeping the state of service binding status
*/
@Buildable(
editableEnabled = false,
builderPackage = Constants.FABRIC8_KUBERNETES_API
)
public class BindingStatus {

private String name;
Expand All @@ -20,10 +27,10 @@ public BindingStatus() {
/**
* Constructor
*
* @param secretName The Kubernetes secret name
* @param name The Kubernetes secret name
*/
public BindingStatus(final String secretName) {
this.setName(secretName);
public BindingStatus(final String name) {
this.setName(name);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import io.fabric8.kubernetes.model.annotation.Group;
import io.fabric8.kubernetes.model.annotation.ShortNames;
import io.fabric8.kubernetes.model.annotation.Version;
import io.strimzi.api.kafka.model.Constants;
import io.sundr.builder.annotations.Buildable;
import io.sundr.builder.annotations.BuildableReference;

import java.io.Serial;

Expand All @@ -18,6 +21,11 @@
@Group("access.strimzi.io")
@Version("v1alpha1")
@ShortNames("ka")
@Buildable(
editableEnabled = false,
builderPackage = Constants.FABRIC8_KUBERNETES_API,
refs = {@BuildableReference(CustomResource.class)}
)
public class KafkaAccess extends CustomResource<KafkaAccessSpec, KafkaAccessStatus> implements Namespaced {
@Serial
private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@
package io.strimzi.kafka.access.model;

import io.fabric8.generator.annotation.Required;
import io.strimzi.api.kafka.model.Constants;
import io.sundr.builder.annotations.Buildable;

/**
* The spec model of the KafkaAccess resource
*/
@Buildable(
editableEnabled = false,
builderPackage = Constants.FABRIC8_KUBERNETES_API
)
public class KafkaAccessSpec {

@Required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@
package io.strimzi.kafka.access.model;

import io.javaoperatorsdk.operator.api.ObservedGenerationAwareStatus;
import io.strimzi.api.kafka.model.Constants;
import io.strimzi.api.kafka.model.status.Condition;
import io.strimzi.kafka.access.internal.StatusUtils;
import io.sundr.builder.annotations.Buildable;

import java.util.ArrayList;
import java.util.List;

/**
* The status model of the KafkaAccess resource
*/
@Buildable(
editableEnabled = false,
builderPackage = Constants.FABRIC8_KUBERNETES_API
)
public class KafkaAccessStatus extends ObservedGenerationAwareStatus {

private BindingStatus binding;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@
package io.strimzi.kafka.access.model;

import io.fabric8.generator.annotation.Required;
import io.strimzi.api.kafka.model.Constants;
import io.sundr.builder.annotations.Buildable;

/**
* The Kafka reference. Keeps state for a Kafka resource of Strimzi Kafka Operator
*/
@Buildable(
editableEnabled = false,
builderPackage = Constants.FABRIC8_KUBERNETES_API
)
public class KafkaReference {

@Required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@
package io.strimzi.kafka.access.model;

import io.fabric8.generator.annotation.Required;
import io.strimzi.api.kafka.model.Constants;
import io.sundr.builder.annotations.Buildable;

/**
* The Kafka user reference, which keeps state for a KafkaUser resource of Strimzi Kafka Operator
*/
@Buildable(
editableEnabled = false,
builderPackage = Constants.FABRIC8_KUBERNETES_API
)
public class KafkaUserReference {

@Required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
* Copyright Strimzi authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.strimzi.kafka.access.internal;
package internal;

import java.util.ArrayList;
import java.util.List;

import io.strimzi.api.kafka.model.status.Condition;
import io.strimzi.api.kafka.model.status.ConditionBuilder;
import io.strimzi.kafka.access.internal.StatusUtils;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

Expand Down
Loading