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

refactor: kubernetes-model-core generated from OpenAPI schemas #6164

Merged
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
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,21 @@ generate-openapi:
cd kubernetes-model-generator/openapi/generator && go build
./kubernetes-model-generator/openapi/generator/generator ./kubernetes-model-generator/openapi/schemas

.PHONY: generate-openapi-classes
generate-openapi-classes:
# TODO: Do for all modules once they've all been migrated
# cd kubernetes-model-generator && mvn -Pgenerate clean install
cd kubernetes-model-generator/kubernetes-model-common && mvn clean install
cd kubernetes-model-generator/openapi/maven-plugin && mvn clean verify
cd kubernetes-model-generator/kubernetes-model-core && mvn -Pgenerate clean install

# Legacy generation of the model: TODO: remove
.PHONY: generate-model-legacy
generate-model-legacy:
cd kubernetes-model-generator && ./generateModel.sh

.PHONY: generate-model
generate-model: generate-openapi generate-model-legacy
generate-model: generate-openapi generate-openapi-classes generate-model-legacy

.PHONY: sonar
sonar:
Expand Down
1 change: 0 additions & 1 deletion kubernetes-model-generator/generateModel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ ABSOLUTE_BASEDIR=$(realpath "$BASEDIR")

# Array for all existing modules
declare -a modules=(
"kubernetes-model-core"
"kubernetes-model-rbac"
"kubernetes-model-admissionregistration"
"kubernetes-model-apiextensions"
Expand Down
27 changes: 0 additions & 27 deletions kubernetes-model-generator/kubernetes-model-core/Makefile

This file was deleted.

This file was deleted.

82 changes: 22 additions & 60 deletions kubernetes-model-generator/kubernetes-model-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,74 +130,36 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>attach-artifacts</id>
<configuration>
<skipAttach>false</skipAttach>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>generate</id>
<build>
<plugins>
<plugin>
<groupId>org.jsonschema2pojo</groupId>
<artifactId>jsonschema2pojo-maven-plugin</artifactId>
<configuration>
<customAnnotator>io.fabric8.kubernetes.jsonschema2pojo.KubernetesCoreTypeAnnotator</customAnnotator>
<groupId>io.fabric8</groupId>
<artifactId>openapi-model-generator-maven-plugin</artifactId>
<configuration >
<settings combine.self="append">
<addBuildableReferences>false</addBuildableReferences>
<schemas>
<schema>${project.basedir}/../openapi/schemas/kubernetes-1.30.0.json</schema>
<schema>${project.basedir}/../openapi/schemas/api-machinery-extra.json</schema>
<schema>${project.basedir}/../openapi/schemas/admission-registration.json</schema>
</schemas>
<packageMappings combine.self="append">
<io.k8s.client-go.tools.clientcmd.api.v1>io.fabric8.kubernetes.api.model</io.k8s.client-go.tools.clientcmd.api.v1>
<io.k8s.kube-aggregator.pkg.apis.apiregistration.v1>io.fabric8.kubernetes.api.model</io.k8s.kube-aggregator.pkg.apis.apiregistration.v1>
</packageMappings>
<skipGenerationRegexes>
<skipGenerationRegex>^io\.k8s\.apimachinery\.pkg\.runtime\.RawExtension$</skipGenerationRegex>
</skipGenerationRegexes>
<includeGenerationRegexes>
<includeGenerationRegex>^io\.k8s\.api\.core\..*$</includeGenerationRegex>
<includeGenerationRegex>^io\.k8s\.apimachinery\..*$</includeGenerationRegex>
</includeGenerationRegexes>
</settings>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<target>
<echo>Removing the duplicate generated class</echo>
<delete
file="${generate.targetDirectory}/io/fabric8/kubernetes/api/model/Duration.java"
verbose="true" />
<delete
file="${generate.targetDirectory}/io/fabric8/kubernetes/api/model/HasMetadata.java"
verbose="true" />
<delete
file="${generate.targetDirectory}/io/fabric8/kubernetes/api/model/IntOrString.java"
verbose="true" />
<delete
file="${generate.targetDirectory}/io/fabric8/kubernetes/api/model/Quantity.java"
verbose="true" />
<delete
file="${generate.targetDirectory}/io/fabric8/kubernetes/api/model/KubernetesResource.java"
verbose="true" />
<delete
file="${generate.targetDirectory}/io/fabric8/kubernetes/api/model/KubernetesList.java"
verbose="true" />
<delete verbose="true">
<fileset dir="${generate.targetDirectory}">
<include name="*.java" />
</fileset>
</delete>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.fabric8.kubernetes.api.builder.Editable;
import io.fabric8.kubernetes.model.annotation.Group;
import io.fabric8.kubernetes.model.annotation.Version;
import io.sundr.builder.annotations.Buildable;
import io.sundr.transform.annotations.TemplateTransformation;
import io.sundr.transform.annotations.TemplateTransformations;
Expand All @@ -39,6 +41,8 @@
@TemplateTransformations({
@TemplateTransformation(value = "/manifest.vm", outputPath = "META-INF/services/io.fabric8.kubernetes.api.model.KubernetesResource", gather = true)
})
@Version("v1")
@Group("")
@Generated("jsonschema2pojo")
public class APIResourceList implements Editable<APIResourceListBuilder> , KubernetesResource
{
Expand Down
Loading
Loading