Skip to content

Commit

Permalink
refactor: openshift-model & openshift-mode-miscellaneous generated fr…
Browse files Browse the repository at this point in the history
…om OpenAPI schemas

Signed-off-by: Marc Nuri <[email protected]>
  • Loading branch information
manusa committed Sep 17, 2024
1 parent cc33729 commit 4f1b908
Show file tree
Hide file tree
Showing 289 changed files with 12,709 additions and 10,147 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ generate-openapi-classes:
cd kubernetes-model-generator/kubernetes-model-resource && mvn -Pgenerate clean install
cd kubernetes-model-generator/kubernetes-model-kustomize && mvn -Pgenerate clean install
cd kubernetes-model-generator/openshift-model-config && mvn -Pgenerate clean install
cd kubernetes-model-generator/openshift-model && mvn -Pgenerate clean install
cd kubernetes-model-generator/openshift-model-operator && mvn -Pgenerate clean install
cd kubernetes-model-generator/openshift-model-miscellaneous && mvn -Pgenerate clean install

# Legacy generation of the model: TODO: remove
.PHONY: generate-model-legacy
Expand Down
21 changes: 19 additions & 2 deletions doc/MIGRATION-v7.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
- [Apache Felix SCR Annotations removed](#apache-felix-scr-annotations)
- [Model Changes](#model-changes)
- [kubernetes-model artifact removed](#kubernetes-model-artifact-removed)
- [Moved packages](#model-changes-moved-packages)
- [Service Catalog removed (operator.openshift.io)](#service-catalog-removed)
- [Removed deprecated types for network.openshift.io (OpenShift-SDN-only)](#openshift-network-removed)
- [Deprecations and Removals](#deprecations-and-removals)
- [Service Catalog API removed](#service-catalog)
- [Service Catalog API (extension) removed](#service-catalog-extension)


> [!NOTE]
Expand Down Expand Up @@ -37,16 +39,31 @@ The Maven artifact `io.fabric8:kubernetes-model` has been removed from the proje
This artifact was just an aggregator of _some_ of the Kubernetes model artifacts and had no specific purpose.
It is no longer published, the `io.fabric8:kubernetes-client-api` or `io.fabric8:kubernetes-openshift-uberjar` artifacts should be used instead.

### Moved packages <a href="#model-changes-moved-packages" id="model-changes-moved-packages"/>

Some of the types and packages have been moved to more suiting modules and package names.

### Service Catalog removed (operator.openshift.io) <a href="#service-catalog-removed" id="service-catalog-removed"/>

The operator.openshift.io APIs have been deprecated since OpenShift 4.1.
The model types and DSL entry points for these APIs have been removed from the OpenShift client.
- [openshift/api: remove the service catalog crds](https://github.com/openshift/api/pull/596)
- [OpenShift Container Platform 4.1 release notes](https://docs.openshift.com/container-platform/4.1/release_notes/ocp-4-1-release-notes.html#ocp-4-1-service-broker-service-catalog-deprecation)

### Removed deprecated types for network.openshift.io (OpenShift-SDN-only) <a href="#openshift-network-removed" id="openshift-network-removed" />

Some of the types in the `network.openshift.io` API group have been removed.
Some of the remaining types can be found in the `openshift-model-miscellaneous` module.
- [openshift/api: clean up openshift-sdn references in the API](https://github.com/openshift/api/pull/1981)

The removed types include:
- ClusterNetwork
- EgressNetworkPolicy
- NetNamespace

## Deprecations and Removals <a href="#deprecations-and-removals" id="deprecations-and-removals"/>

### Service Catalog API removed <a href="#service-catalog" id="service-catalog"/>
### Service Catalog API (extension) removed <a href="#service-catalog-extension" id="service-catalog-extension"/>

The Service Catalog API extension has been removed.
The upstream project has been archived since May 6, 2022.
Expand Down
2 changes: 0 additions & 2 deletions kubernetes-model-generator/generateModel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ ABSOLUTE_BASEDIR=$(realpath "$BASEDIR")

# Array for all existing modules
declare -a modules=(
"openshift-model"
"openshift-model-operatorhub"
"openshift-model-console"
"openshift-model-clusterautoscaling"
"openshift-model-hive"
"openshift-model-machine"
"openshift-model-installer"
"openshift-model-machineconfig"
"openshift-model-miscellaneous"
"openshift-model-monitoring"
"openshift-model-tuned"
"openshift-model-whereabouts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,13 @@ private void processTemplate(TemplateContext ret) {
if (ret.getApiVersion() != null) {
ret.addImport("io.fabric8.kubernetes.model.annotation.Version");
ret.put("version", ret.getApiVersion().getVersion());
ret.addImport("io.fabric8.kubernetes.model.annotation.Group");
ret.put("group", ret.getApiVersion().getGroup());
// TODO: we might want to generify this logic for other annotations and imports
if (Objects.equals("Group", ret.getClassSimpleName())) {
ret.put("group", "@io.fabric8.kubernetes.model.annotation.Group(\"" + ret.getApiVersion().getGroup() + "\")");
} else {
ret.addImport("io.fabric8.kubernetes.model.annotation.Group");
ret.put("group", "@Group(\"" + ret.getApiVersion().getGroup() + "\")");
}
ret.addImport("io.sundr.transform.annotations.TemplateTransformation");
ret.addImport("io.sundr.transform.annotations.TemplateTransformations");
ret.put("kubernetesResourceClass", settings.getKubernetesResourceClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@ void put(String key, Object value) {
Map<String, Schema> getSchemaProperties() {
return classSchema.getProperties() == null ? Collections.emptyMap() : classSchema.getProperties();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public class SchemaUtils {
"io.fabric8.kubernetes.api.model.apiextensions.v1.JSONSchemaPropsOrStringArraySerDe.Deserializer.class");
JAVA_CLASS_DESERIALIZER_MAP.put("io.fabric8.kubernetes.api.model.apiextensions.v1beta1.JSONSchemaPropsOrStringArray",
"io.fabric8.kubernetes.api.model.apiextensions.v1beta1.JSONSchemaPropsOrStringArraySerDe.Deserializer.class");
JAVA_CLASS_DESERIALIZER_MAP.put("io.fabric8.openshift.api.model.Template",
"io.fabric8.openshift.api.model.TemplateDeserializer.class");
}

private static final Map<String, String> REF_SERIALIZER_MAP = Collections.emptyMap();// new LinkedHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@
@Version("{{.}}")
{{/version}}
{{#group}}
@Group("{{.}}")
{{.}}
{{/group}}
@Generated("jsonschema2pojo")
4 changes: 4 additions & 0 deletions kubernetes-model-generator/openshift-model-hive/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
<groupId>io.fabric8</groupId>
<artifactId>openshift-model</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>openshift-model-config</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
Expand Down
27 changes: 0 additions & 27 deletions kubernetes-model-generator/openshift-model-miscellaneous/Makefile

This file was deleted.

This file was deleted.

56 changes: 25 additions & 31 deletions kubernetes-model-generator/openshift-model-miscellaneous/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,50 +43,44 @@
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-core</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-common</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>openshift-model</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>openshift-model-operator</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</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>
<groupId>io.fabric8</groupId>
<artifactId>openapi-model-generator-maven-plugin</artifactId>
<configuration >
<settings combine.self="append">
<schemas>
<schema>${openapi.schema.openshift-latest}</schema>
</schemas>
<packageMappings combine.self="append">
<io.k8s.api>io.fabric8.kubernetes.api.model</io.k8s.api>
<io.openshift>io.fabric8.openshift.api.model.miscellaneous</io.openshift>
<io.cncf.cni.k8s>io.fabric8.openshift.api.model.miscellaneous.cncf.cni</io.cncf.cni.k8s>
<io.metal3>io.fabric8.openshift.api.model.miscellaneous.metal3</io.metal3>
<io.x-k8s.cluster.infrastructure.v1beta1>io.fabric8.openshift.api.model.miscellaneous.metal3.v1beta1</io.x-k8s.cluster.infrastructure.v1beta1>
</packageMappings>
<includeGenerationRegexes>
<includeGenerationRegex>^io\.cncf\.cni\.k8s\..*$</includeGenerationRegex>
<includeGenerationRegex>^io\.x\-k8s\.cluster\.infrastructure\.v1beta1\..*$</includeGenerationRegex>
<includeGenerationRegex>^io\.metal3\..*$</includeGenerationRegex>
<includeGenerationRegex>^io\.openshift\.apiserver\..*$</includeGenerationRegex>
<includeGenerationRegex>^io\.openshift\.cloudcredential\..*$</includeGenerationRegex>
<includeGenerationRegex>^io\.openshift\.helm\..*$</includeGenerationRegex>
<includeGenerationRegex>^io\.openshift\.network\..*$</includeGenerationRegex>
</includeGenerationRegexes>
</settings>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
Loading

0 comments on commit 4f1b908

Please sign in to comment.