Skip to content

Commit

Permalink
refactor: openshift-model-clusterautoscaling generated from OpenAPI s…
Browse files Browse the repository at this point in the history
…chemas

Signed-off-by: Marc Nuri <marc@marcnuri.com>
  • Loading branch information
manusa authored Sep 23, 2024
1 parent d881c0e commit c102bb6
Show file tree
Hide file tree
Showing 43 changed files with 424 additions and 762 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ generate-openapi-classes:
cd kubernetes-model-generator/openshift-model-miscellaneous && mvn -Pgenerate clean install
cd kubernetes-model-generator/openshift-model-operatorhub && mvn -Pgenerate clean install
cd kubernetes-model-generator/openshift-model-console && mvn -Pgenerate clean install
cd kubernetes-model-generator/openshift-model-autoscaling && mvn -Pgenerate clean install

# Legacy generation of the model: TODO: remove
.PHONY: generate-model-legacy
Expand Down
14 changes: 14 additions & 0 deletions doc/MIGRATION-v7.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- [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)
- [Renamed clusterautoscaling to autoscaling](#openshift-clusterautoscaling-to-autoscaling)
- [Deprecations and Removals](#deprecations-and-removals)
- [Service Catalog API (extension) removed](#service-catalog-extension)

Expand All @@ -32,6 +33,11 @@ annotations, you need to switch to [Official OSGi Component annotations](https:/

## Model Changes <a href="#model-changes" id="model-changes"/>

The way we generate the Kubernetes model types/classes has changed.
We've moved from a reflection-based approach from the Go types, to a mixed approach leveraging the OpenAPI schemas that are publicly available.

This change has had several impacts on the generated classes, including:

### kubernetes-model artifact removed <a href="#kubernetes-model-artifact-removed" id="kubernetes-model-artifact-removed"/>

The Maven artifact `io.fabric8:kubernetes-model` has been removed from the project and is no longer published.
Expand Down Expand Up @@ -69,6 +75,14 @@ The moved types include:
- OperatorPKI (`openshift-model-operator`)
- ProjectHelmChartRepository (`openshift-model-miscellaneous`)

### Renamed clusterautoscaling to autoscaling <a href="#openshift-clusterautoscaling-to-autoscaling" id="openshift-clusterautoscaling-to-autoscaling" />

The module `openshift-model-clusterautoscaling` has been renamed to `openshift-model-autoscaling` to match the API group name.

The package has also been renamed from `io.fabric8.openshift.api.model.clusterautoscaling` to `io.fabric8.openshift.api.model.autoscaling`.

The OpenShiftClient DSL entry-point has also been renamed from `OpenShiftClient.clusterAutoscaling()` to `OpenShiftClient.openShiftAutoscaling()`.

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

### Service Catalog API (extension) removed <a href="#service-catalog-extension" id="service-catalog-extension"/>
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=(
"openshift-model-clusterautoscaling"
"openshift-model-hive"
"openshift-model-machine"
"openshift-model-installer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
<version>7.0-SNAPSHOT</version>
</parent>

<artifactId>openshift-model-clusterautoscaling</artifactId>
<artifactId>openshift-model-autoscaling</artifactId>
<packaging>bundle</packaging>
<name>Fabric8 :: OpenShift Cluster Autoscaler Operator Model</name>

<properties>
<clone-kube>true</clone-kube>
<osgi.import>*</osgi.import>
<osgi.export>
io.fabric8.openshift.api.model.clusterautoscaling**,
io.fabric8.openshift.api.model.autoscaling**,
</osgi.export>
</properties>

Expand All @@ -43,41 +43,30 @@
<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>
</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.autoscaling>io.fabric8.openshift.api.model.autoscaling</io.openshift.autoscaling>
</packageMappings>
<includeGenerationRegexes>
<includeGenerationRegex>^io\.openshift\.autoscaling\..*$</includeGenerationRegex>
</includeGenerationRegexes>
</settings>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

package io.fabric8.openshift.api.model.clusterautoscaling.v1;
package io.fabric8.openshift.api.model.autoscaling.v1;

import java.util.LinkedHashMap;
import java.util.Map;
Expand All @@ -17,6 +17,7 @@
import io.fabric8.kubernetes.api.model.IntOrString;
import io.fabric8.kubernetes.api.model.LabelSelector;
import io.fabric8.kubernetes.api.model.LocalObjectReference;
import io.fabric8.kubernetes.api.model.ObjectMeta;
import io.fabric8.kubernetes.api.model.ObjectReference;
import io.fabric8.kubernetes.api.model.PersistentVolumeClaim;
import io.fabric8.kubernetes.api.model.PodTemplateSpec;
Expand Down Expand Up @@ -47,7 +48,7 @@
""
})
@Buildable(editableEnabled = false, validationEnabled = false, generateBuilderPackage = false, lazyCollectionInitEnabled = false, builderPackage = "io.fabric8.kubernetes.api.builder", refs = {
@BuildableReference(io.fabric8.kubernetes.api.model.ObjectMeta.class),
@BuildableReference(ObjectMeta.class),
@BuildableReference(LabelSelector.class),
@BuildableReference(Container.class),
@BuildableReference(PodTemplateSpec.class),
Expand Down Expand Up @@ -81,11 +82,12 @@ public class ClusterAutoscaler implements Editable<ClusterAutoscalerBuilder> , H
@JsonProperty("kind")
private String kind = "ClusterAutoscaler";
@JsonProperty("metadata")
private io.fabric8.kubernetes.api.model.ObjectMeta metadata;
private ObjectMeta metadata;
@JsonProperty("spec")
private ClusterAutoscalerSpec spec;
@JsonProperty("status")
private ClusterAutoscalerStatus status;
@JsonDeserialize(using = io.fabric8.kubernetes.internal.KubernetesDeserializer.class)
private Object status;
@JsonIgnore
private Map<String, Object> additionalProperties = new LinkedHashMap<String, Object>();

Expand All @@ -96,7 +98,7 @@ public class ClusterAutoscaler implements Editable<ClusterAutoscalerBuilder> , H
public ClusterAutoscaler() {
}

public ClusterAutoscaler(String apiVersion, String kind, io.fabric8.kubernetes.api.model.ObjectMeta metadata, ClusterAutoscalerSpec spec, ClusterAutoscalerStatus status) {
public ClusterAutoscaler(String apiVersion, String kind, ObjectMeta metadata, ClusterAutoscalerSpec spec, Object status) {
super();
this.apiVersion = apiVersion;
this.kind = kind;
Expand Down Expand Up @@ -146,12 +148,12 @@ public void setKind(String kind) {
}

@JsonProperty("metadata")
public io.fabric8.kubernetes.api.model.ObjectMeta getMetadata() {
public ObjectMeta getMetadata() {
return metadata;
}

@JsonProperty("metadata")
public void setMetadata(io.fabric8.kubernetes.api.model.ObjectMeta metadata) {
public void setMetadata(ObjectMeta metadata) {
this.metadata = metadata;
}

Expand All @@ -166,12 +168,13 @@ public void setSpec(ClusterAutoscalerSpec spec) {
}

@JsonProperty("status")
public ClusterAutoscalerStatus getStatus() {
public Object getStatus() {
return status;
}

@JsonProperty("status")
public void setStatus(ClusterAutoscalerStatus status) {
@JsonDeserialize(using = io.fabric8.kubernetes.internal.KubernetesDeserializer.class)
public void setStatus(Object status) {
this.status = status;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

package io.fabric8.openshift.api.model.clusterautoscaling.v1;
package io.fabric8.openshift.api.model.autoscaling.v1;

import java.util.ArrayList;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -67,7 +67,7 @@
@Version("v1")
@Group("autoscaling.openshift.io")
@Generated("jsonschema2pojo")
public class ClusterAutoscalerList implements Editable<ClusterAutoscalerListBuilder> , KubernetesResource, KubernetesResourceList<io.fabric8.openshift.api.model.clusterautoscaling.v1.ClusterAutoscaler>
public class ClusterAutoscalerList implements Editable<ClusterAutoscalerListBuilder> , KubernetesResource, KubernetesResourceList<io.fabric8.openshift.api.model.autoscaling.v1.ClusterAutoscaler>
{

/**
Expand All @@ -79,7 +79,7 @@ public class ClusterAutoscalerList implements Editable<ClusterAutoscalerListBuil
private String apiVersion = "autoscaling.openshift.io/v1";
@JsonProperty("items")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<io.fabric8.openshift.api.model.clusterautoscaling.v1.ClusterAutoscaler> items = new ArrayList<>();
private List<io.fabric8.openshift.api.model.autoscaling.v1.ClusterAutoscaler> items = new ArrayList<>();
/**
*
* (Required)
Expand All @@ -99,7 +99,7 @@ public class ClusterAutoscalerList implements Editable<ClusterAutoscalerListBuil
public ClusterAutoscalerList() {
}

public ClusterAutoscalerList(String apiVersion, List<io.fabric8.openshift.api.model.clusterautoscaling.v1.ClusterAutoscaler> items, String kind, ListMeta metadata) {
public ClusterAutoscalerList(String apiVersion, List<io.fabric8.openshift.api.model.autoscaling.v1.ClusterAutoscaler> items, String kind, ListMeta metadata) {
super();
this.apiVersion = apiVersion;
this.items = items;
Expand Down Expand Up @@ -129,12 +129,12 @@ public void setApiVersion(String apiVersion) {

@JsonProperty("items")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public List<io.fabric8.openshift.api.model.clusterautoscaling.v1.ClusterAutoscaler> getItems() {
public List<io.fabric8.openshift.api.model.autoscaling.v1.ClusterAutoscaler> getItems() {
return items;
}

@JsonProperty("items")
public void setItems(List<io.fabric8.openshift.api.model.clusterautoscaling.v1.ClusterAutoscaler> items) {
public void setItems(List<io.fabric8.openshift.api.model.autoscaling.v1.ClusterAutoscaler> items) {
this.items = items;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

package io.fabric8.openshift.api.model.clusterautoscaling.v1;
package io.fabric8.openshift.api.model.autoscaling.v1;

import java.util.ArrayList;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -35,6 +35,7 @@
@JsonPropertyOrder({
"balanceSimilarNodeGroups",
"balancingIgnoredLabels",
"expanders",
"ignoreDaemonsetsUtilization",
"logVerbosity",
"maxNodeProvisionTime",
Expand Down Expand Up @@ -70,6 +71,9 @@ public class ClusterAutoscalerSpec implements Editable<ClusterAutoscalerSpecBuil
@JsonProperty("balancingIgnoredLabels")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<String> balancingIgnoredLabels = new ArrayList<>();
@JsonProperty("expanders")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<String> expanders = new ArrayList<>();
@JsonProperty("ignoreDaemonsetsUtilization")
private Boolean ignoreDaemonsetsUtilization;
@JsonProperty("logVerbosity")
Expand All @@ -81,9 +85,9 @@ public class ClusterAutoscalerSpec implements Editable<ClusterAutoscalerSpecBuil
@JsonProperty("podPriorityThreshold")
private Integer podPriorityThreshold;
@JsonProperty("resourceLimits")
private ResourceLimits resourceLimits;
private ClusterAutoscalerSpecResourceLimits resourceLimits;
@JsonProperty("scaleDown")
private ScaleDownConfig scaleDown;
private ClusterAutoscalerSpecScaleDown scaleDown;
@JsonProperty("skipNodesWithLocalStorage")
private Boolean skipNodesWithLocalStorage;
@JsonIgnore
Expand All @@ -96,10 +100,11 @@ public class ClusterAutoscalerSpec implements Editable<ClusterAutoscalerSpecBuil
public ClusterAutoscalerSpec() {
}

public ClusterAutoscalerSpec(Boolean balanceSimilarNodeGroups, List<String> balancingIgnoredLabels, Boolean ignoreDaemonsetsUtilization, Integer logVerbosity, String maxNodeProvisionTime, Integer maxPodGracePeriod, Integer podPriorityThreshold, ResourceLimits resourceLimits, ScaleDownConfig scaleDown, Boolean skipNodesWithLocalStorage) {
public ClusterAutoscalerSpec(Boolean balanceSimilarNodeGroups, List<String> balancingIgnoredLabels, List<String> expanders, Boolean ignoreDaemonsetsUtilization, Integer logVerbosity, String maxNodeProvisionTime, Integer maxPodGracePeriod, Integer podPriorityThreshold, ClusterAutoscalerSpecResourceLimits resourceLimits, ClusterAutoscalerSpecScaleDown scaleDown, Boolean skipNodesWithLocalStorage) {
super();
this.balanceSimilarNodeGroups = balanceSimilarNodeGroups;
this.balancingIgnoredLabels = balancingIgnoredLabels;
this.expanders = expanders;
this.ignoreDaemonsetsUtilization = ignoreDaemonsetsUtilization;
this.logVerbosity = logVerbosity;
this.maxNodeProvisionTime = maxNodeProvisionTime;
Expand Down Expand Up @@ -131,6 +136,17 @@ public void setBalancingIgnoredLabels(List<String> balancingIgnoredLabels) {
this.balancingIgnoredLabels = balancingIgnoredLabels;
}

@JsonProperty("expanders")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public List<String> getExpanders() {
return expanders;
}

@JsonProperty("expanders")
public void setExpanders(List<String> expanders) {
this.expanders = expanders;
}

@JsonProperty("ignoreDaemonsetsUtilization")
public Boolean getIgnoreDaemonsetsUtilization() {
return ignoreDaemonsetsUtilization;
Expand Down Expand Up @@ -182,22 +198,22 @@ public void setPodPriorityThreshold(Integer podPriorityThreshold) {
}

@JsonProperty("resourceLimits")
public ResourceLimits getResourceLimits() {
public ClusterAutoscalerSpecResourceLimits getResourceLimits() {
return resourceLimits;
}

@JsonProperty("resourceLimits")
public void setResourceLimits(ResourceLimits resourceLimits) {
public void setResourceLimits(ClusterAutoscalerSpecResourceLimits resourceLimits) {
this.resourceLimits = resourceLimits;
}

@JsonProperty("scaleDown")
public ScaleDownConfig getScaleDown() {
public ClusterAutoscalerSpecScaleDown getScaleDown() {
return scaleDown;
}

@JsonProperty("scaleDown")
public void setScaleDown(ScaleDownConfig scaleDown) {
public void setScaleDown(ClusterAutoscalerSpecScaleDown scaleDown) {
this.scaleDown = scaleDown;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

package io.fabric8.openshift.api.model.clusterautoscaling.v1;
package io.fabric8.openshift.api.model.autoscaling.v1;

import java.util.LinkedHashMap;
import java.util.Map;
Expand Down Expand Up @@ -52,7 +52,7 @@
@BuildableReference(PersistentVolumeClaim.class)
})
@Generated("jsonschema2pojo")
public class ResourceRange implements Editable<ResourceRangeBuilder> , KubernetesResource
public class ClusterAutoscalerSpecRLCores implements Editable<ClusterAutoscalerSpecRLCoresBuilder> , KubernetesResource
{

@JsonProperty("max")
Expand All @@ -66,10 +66,10 @@ public class ResourceRange implements Editable<ResourceRangeBuilder> , Kubernete
* No args constructor for use in serialization
*
*/
public ResourceRange() {
public ClusterAutoscalerSpecRLCores() {
}

public ResourceRange(Integer max, Integer min) {
public ClusterAutoscalerSpecRLCores(Integer max, Integer min) {
super();
this.max = max;
this.min = min;
Expand All @@ -96,12 +96,12 @@ public void setMin(Integer min) {
}

@JsonIgnore
public ResourceRangeBuilder edit() {
return new ResourceRangeBuilder(this);
public ClusterAutoscalerSpecRLCoresBuilder edit() {
return new ClusterAutoscalerSpecRLCoresBuilder(this);
}

@JsonIgnore
public ResourceRangeBuilder toBuilder() {
public ClusterAutoscalerSpecRLCoresBuilder toBuilder() {
return edit();
}

Expand Down
Loading

0 comments on commit c102bb6

Please sign in to comment.