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 a5ffbb8 commit 36c24aa
Show file tree
Hide file tree
Showing 315 changed files with 13,350 additions and 9,963 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
29 changes: 27 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,39 @@ 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.
From the remaining types some of them have been moved to more appropriate modules.
- [openshift/api: clean up openshift-sdn references in the API](https://github.com/openshift/api/pull/1981)

The removed types include:
- ClusterNetwork (`OpenShiftClient.clusterNetworks`)
- EgressNetworkPolicy (`OpenShiftClient.egressNetworkPolicies`)
- HostSubnet (`OpenShiftClient.hostSubnets`)
- NetNamespace (`OpenShiftClient.netNamespaces`)

The moved types include:
- Config (io.fabric8.openshift.api.model.miscellaneous.imageregistry.operator.v1.Config) (`openshift-model-operator`)
- EgressRouter (`openshift-model-operator`)
- HelmChartRepository (`openshift-model-miscellaneous`)
- OperatorPKI (`openshift-model-operator`)
- ProjectHelmChartRepository (`openshift-model-miscellaneous`)

## 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
1 change: 1 addition & 0 deletions kubernetes-model-generator/openapi/generator/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.22.0

require (
github.com/getkin/kin-openapi v0.125.0
github.com/openshift/api v0.0.0-20240911192208-3e5de946111c
k8s.io/api v0.30.2
k8s.io/apiextensions-apiserver v0.30.2
k8s.io/apimachinery v0.30.2
Expand Down
2 changes: 2 additions & 0 deletions kubernetes-model-generator/openapi/generator/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/openshift/api v0.0.0-20240911192208-3e5de946111c h1:46hH/7XmmaPmeJWTyrzh8TRB6I7TCwzJdxxWeyK8blM=
github.com/openshift/api v0.0.0-20240911192208-3e5de946111c/go.mod h1:OOh6Qopf21pSzqNVCB5gomomBXb8o5sGKZxG2KNpaXM=
github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s=
github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down
11 changes: 11 additions & 0 deletions kubernetes-model-generator/openapi/generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ package main

import (
"github.com/getkin/kin-openapi/openapi3"
openshiftauthorizationv1 "github.com/openshift/api/authorization/v1"
openshiftsecurityv1 "github.com/openshift/api/security/v1"
admissionV1 "k8s.io/api/admission/v1"
admissionV1Beta1 "k8s.io/api/admission/v1beta1"
admissionregistrationV1 "k8s.io/api/admissionregistration/v1"
Expand Down Expand Up @@ -134,6 +136,15 @@ func main() {
reflect.TypeOf(metricsV1Beta1.PodMetricsList{}): {true, metricsV1Beta1.SchemeGroupVersion.String(), "pods", true},
reflect.TypeOf(metricsV1Beta1.PodMetrics{}): {false, metricsV1Beta1.SchemeGroupVersion.String(), "pods", true},
}, "metrics"),
NewTypeSchema([]reflect.Type{
reflect.TypeOf(openshiftauthorizationv1.SubjectAccessReviewResponse{}),
reflect.TypeOf(openshiftauthorizationv1.ResourceAccessReviewResponse{}),
}, "openshift-authorization"),
// OpenAPI spec contains incomplete information for SecurityContextConstraints (only nested inline until certain level)
NewPathSchema(map[reflect.Type]ApiVersion{
reflect.TypeOf(openshiftsecurityv1.SecurityContextConstraintsList{}): {true, openshiftsecurityv1.GroupVersion.String(), "securitycontextconstraints", false},
reflect.TypeOf(openshiftsecurityv1.SecurityContextConstraints{}): {false, openshiftsecurityv1.GroupVersion.String(), "securitycontextconstraints", false},
}, "openshift-security"),
}
generate(schemas, targetDirectory)
}
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")
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"components":{"schemas":{"com.github.openshift.api.authorization.v1.ResourceAccessReviewResponse":{"properties":{"apiVersion":{"type":"string"},"evalutionError":{"type":"string"},"groups":{"items":{"type":"string"},"type":"array"},"kind":{"type":"string"},"namespace":{"type":"string"},"users":{"items":{"type":"string"},"type":"array"}},"type":"object"},"com.github.openshift.api.authorization.v1.SubjectAccessReviewResponse":{"properties":{"allowed":{"type":"boolean"},"apiVersion":{"type":"string"},"evaluationError":{"type":"string"},"kind":{"type":"string"},"namespace":{"type":"string"},"reason":{"type":"string"}},"type":"object"}}},"info":{"title":"openshift-authorization","version":"0.0.0"},"openapi":"3.0.0","paths":{}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"components":{"schemas":{"com.github.openshift.api.security.v1.AllowedFlexVolume":{"properties":{"driver":{"type":"string"}},"type":"object"},"com.github.openshift.api.security.v1.FSGroupStrategyOptions":{"properties":{"ranges":{"items":{"$ref":"#/components/schemas/com.github.openshift.api.security.v1.IDRange"},"type":"array"},"type":{"type":"string"}},"type":"object"},"com.github.openshift.api.security.v1.IDRange":{"properties":{"max":{"format":"int64","type":"integer"},"min":{"format":"int64","type":"integer"}},"type":"object"},"com.github.openshift.api.security.v1.RunAsUserStrategyOptions":{"properties":{"type":{"type":"string"},"uid":{"format":"int64","type":"integer"},"uidRangeMax":{"format":"int64","type":"integer"},"uidRangeMin":{"format":"int64","type":"integer"}},"type":"object"},"com.github.openshift.api.security.v1.SELinuxContextStrategyOptions":{"properties":{"seLinuxOptions":{"$ref":"#/components/schemas/io.k8s.api.core.v1.SELinuxOptions"},"type":{"type":"string"}},"type":"object"},"com.github.openshift.api.security.v1.SecurityContextConstraints":{"properties":{"allowHostDirVolumePlugin":{"type":"boolean"},"allowHostIPC":{"type":"boolean"},"allowHostNetwork":{"type":"boolean"},"allowHostPID":{"type":"boolean"},"allowHostPorts":{"type":"boolean"},"allowPrivilegeEscalation":{"type":"boolean"},"allowPrivilegedContainer":{"type":"boolean"},"allowedCapabilities":{"items":{"type":"string"},"type":"array"},"allowedFlexVolumes":{"items":{"$ref":"#/components/schemas/com.github.openshift.api.security.v1.AllowedFlexVolume"},"type":"array"},"allowedUnsafeSysctls":{"items":{"type":"string"},"type":"array"},"apiVersion":{"type":"string"},"defaultAddCapabilities":{"items":{"type":"string"},"type":"array"},"defaultAllowPrivilegeEscalation":{"type":"boolean"},"forbiddenSysctls":{"items":{"type":"string"},"type":"array"},"fsGroup":{"$ref":"#/components/schemas/com.github.openshift.api.security.v1.FSGroupStrategyOptions"},"groups":{"items":{"type":"string"},"type":"array"},"kind":{"type":"string"},"metadata":{"$ref":"#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta"},"priority":{"format":"int32","type":"integer"},"readOnlyRootFilesystem":{"type":"boolean"},"requiredDropCapabilities":{"items":{"type":"string"},"type":"array"},"runAsUser":{"$ref":"#/components/schemas/com.github.openshift.api.security.v1.RunAsUserStrategyOptions"},"seLinuxContext":{"$ref":"#/components/schemas/com.github.openshift.api.security.v1.SELinuxContextStrategyOptions"},"seccompProfiles":{"items":{"type":"string"},"type":"array"},"supplementalGroups":{"$ref":"#/components/schemas/com.github.openshift.api.security.v1.SupplementalGroupsStrategyOptions"},"userNamespaceLevel":{"type":"string"},"users":{"items":{"type":"string"},"type":"array"},"volumes":{"items":{"type":"string"},"type":"array"}},"type":"object"},"com.github.openshift.api.security.v1.SecurityContextConstraintsList":{"properties":{"apiVersion":{"type":"string"},"items":{"items":{"$ref":"#/components/schemas/com.github.openshift.api.security.v1.SecurityContextConstraints"},"type":"array"},"kind":{"type":"string"},"metadata":{"$ref":"#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta"}},"type":"object"},"com.github.openshift.api.security.v1.SupplementalGroupsStrategyOptions":{"properties":{"ranges":{"items":{"$ref":"#/components/schemas/com.github.openshift.api.security.v1.IDRange"},"type":"array"},"type":{"type":"string"}},"type":"object"},"io.k8s.api.core.v1.SELinuxOptions":{"properties":{"level":{"type":"string"},"role":{"type":"string"},"type":{"type":"string"},"user":{"type":"string"}},"type":"object"},"io.k8s.apimachinery.pkg.apis.meta.v1.FieldsV1":{"properties":{"-":{"type":"string"}},"type":"object"},"io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta":{"properties":{"continue":{"type":"string"},"remainingItemCount":{"format":"int64","type":"integer"},"resourceVersion":{"type":"string"},"selfLink":{"type":"string"}},"type":"object"},"io.k8s.apimachinery.pkg.apis.meta.v1.ManagedFieldsEntry":{"properties":{"apiVersion":{"type":"string"},"fieldsType":{"type":"string"},"fieldsV1":{"$ref":"#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.FieldsV1"},"manager":{"type":"string"},"operation":{"type":"string"},"subresource":{"type":"string"},"time":{"$ref":"#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.Time"}},"type":"object"},"io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta":{"properties":{"annotations":{"additionalProperties":{"type":"string"},"type":"object"},"creationTimestamp":{"$ref":"#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.Time"},"deletionGracePeriodSeconds":{"format":"int64","type":"integer"},"deletionTimestamp":{"$ref":"#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.Time"},"finalizers":{"items":{"type":"string"},"type":"array"},"generateName":{"type":"string"},"generation":{"format":"int64","type":"integer"},"labels":{"additionalProperties":{"type":"string"},"type":"object"},"managedFields":{"items":{"$ref":"#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.ManagedFieldsEntry"},"type":"array"},"name":{"type":"string"},"namespace":{"type":"string"},"ownerReferences":{"items":{"$ref":"#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference"},"type":"array"},"resourceVersion":{"type":"string"},"selfLink":{"type":"string"},"uid":{"type":"string"}},"type":"object"},"io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference":{"properties":{"apiVersion":{"type":"string"},"blockOwnerDeletion":{"type":"boolean"},"controller":{"type":"boolean"},"kind":{"type":"string"},"name":{"type":"string"},"uid":{"type":"string"}},"type":"object"},"io.k8s.apimachinery.pkg.apis.meta.v1.Time":{"properties":{"Time":{"type":"string"}},"type":"object"}}},"info":{"title":"openshift-security","version":"0.0.0"},"openapi":"3.0.0","paths":{"/apis/security.openshift.io/v1/securitycontextconstraints":{"get":{"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/com.github.openshift.api.security.v1.SecurityContextConstraintsList"}}},"description":"OK"},"default":{"description":""}},"x-kubernetes-group-version-kind":{"group":"security.openshift.io","kind":"SecurityContextConstraintsList","version":"v1"}}},"/apis/security.openshift.io/v1/securitycontextconstraints/{name}":{"get":{"parameters":[{"in":"path","name":"name","required":true}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/com.github.openshift.api.security.v1.SecurityContextConstraints"}}},"description":"OK"},"default":{"description":""}},"x-kubernetes-group-version-kind":{"group":"security.openshift.io","kind":"SecurityContextConstraints","version":"v1"}}}}}
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.

Loading

0 comments on commit 36c24aa

Please sign in to comment.