fabric8io / kubernetes-client

Java client for Kubernetes & OpenShift
http://fabric8.io
Apache License 2.0
3.4k stars 1.46k forks source link

fabric8 generator cli and maven plugin returning different java method names #5955

Closed fhalde closed 1 month ago

fhalde commented 5 months ago

Describe the bug

We are trying to generate Java classes for the following CRD https://github.com/strimzi/strimzi-kafka-operator/blob/affc1968742a8ab1121d23a64c9247ca5c477a32/install/cluster-operator/041-Crd-kafkaconnect.yaml

We set extraAnnotations configuration to generate the fluent builder pattern. Here is what we are noticing

This CRD has a template field. With the CLI, the builder has correct withTemplate & endTemplate methods However, with the maven plugin, the builder seems to have withTemplate & endKafkaconnectspecTemplate method

What could be the reason?

Fabric8 Kubernetes Client version

6.12.1

Steps to reproduce

Generate the java sources using both the cli and maven fabric8 generator plugin e.g. cli

jbang io.fabric8:java-generator-cli:6.12.1 --target="." -add-extra-annotations -always-preserve-unknown --source=kafkaconnects.yaml

Expected behavior

We expected the plugin & the cli to work the same way

Runtime

minikube

Kubernetes API Server version

1.25.3@latest

Environment

Linux, macOS

Fabric8 Kubernetes Client Logs

No response

Additional context

No response

shawkins commented 5 months ago

endKafkaconnectspecTemplate

That is a sundrio bug. We'll need to pickup another release to correct that.

fhalde commented 5 months ago

thanks, why would it work fine with the cli though which is also making use of sundrio?

shawkins commented 5 months ago

You must be picking up a different version of sundio that way.

matteriben commented 5 months ago

I'm not able to reproduce this using the maven plugin. Check which version of sundrio you're using.

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <version>1</version>
  <properties>
    <kubernetes-client.version>6.12.1</kubernetes-client.version>
    <sundrio.version>0.103.1</sundrio.version>
    <lombok.version>1.18.32</lombok.version>
  </properties>
  <dependencies>
    <dependency>
      <groupId>io.fabric8</groupId>
      <artifactId>kubernetes-client</artifactId>
      <version>${kubernetes-client.version}</version>
    </dependency>
    <dependency>
      <groupId>io.fabric8</groupId>
      <artifactId>generator-annotations</artifactId>
      <version>${kubernetes-client.version}</version>
    </dependency>
    <!-- extraAnnotations requires these additional dependencies -->
    <dependency>
      <groupId>io.sundr</groupId>
      <artifactId>builder-annotations</artifactId>
      <version>${sundrio.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <version>${lombok.version}</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>io.fabric8</groupId>
        <artifactId>java-generator-maven-plugin</artifactId>
        <version>${kubernetes-client.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <source>041-Crd-kafkaconnect.yaml</source>
          <alwaysPreserveUnknown>true</alwaysPreserveUnknown>
          <extraAnnotations>true</extraAnnotations>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
stale[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!