Skip to content

Commit

Permalink
chore: updated makefile rules for schema generation
Browse files Browse the repository at this point in the history
Explicit model generation is no longer needed

Signed-off-by: Marc Nuri <[email protected]>
  • Loading branch information
manusa committed Oct 4, 2024
1 parent 63766b5 commit 73087a0
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
java-version: '8'
distribution: 'temurin'
- name: Install Kubernetes Client
run: ./mvnw ${MAVEN_ARGS} clean install -DskipTests -Djacoco.skip=true
run: make quickly MAVEN_ARGS="${MAVEN_ARGS}"

minikube_baremetal:
name: Baremetal K8S
Expand Down
63 changes: 19 additions & 44 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
# limitations under the License.
#

MAVEN_OPTIONS ?=
.DEFAULT_GOAL := quickly
MAVEN_ARGS ?=
override MAVEN_ARGS += -T 1C
OPENAPI_DIR=$(realpath ./kubernetes-model-generator/openapi)
OPENAPI_GENERATOR_DIR=$(OPENAPI_DIR)/generator
OPENAPI_GENERATOR_BINARY_NAME=generator
Expand All @@ -23,7 +25,7 @@ OPENAPI_SCHEMAS_DIR=$(OPENAPI_DIR)/schemas

.PHONY: clean-java
clean-java:
mvn $(MAVEN_OPTIONS) clean
mvn $(MAVEN_ARGS) clean

.PHONY: clean
clean: clean-java
Expand All @@ -38,47 +40,7 @@ openapi-generate-schema:

.PHONY: openapi-generate-java-classes
openapi-generate-java-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
cd kubernetes-model-generator/kubernetes-model-rbac && mvn -Pgenerate clean install
cd kubernetes-model-generator/kubernetes-model-admissionregistration && mvn -Pgenerate clean install
cd kubernetes-model-generator/kubernetes-model-apiextensions && mvn -Pgenerate clean install
cd kubernetes-model-generator/kubernetes-model-apps && mvn -Pgenerate clean install
cd kubernetes-model-generator/kubernetes-model-autoscaling && mvn -Pgenerate clean install
cd kubernetes-model-generator/kubernetes-model-batch && mvn -Pgenerate clean install
cd kubernetes-model-generator/kubernetes-model-certificates && mvn -Pgenerate clean install
cd kubernetes-model-generator/kubernetes-model-coordination && mvn -Pgenerate clean install
cd kubernetes-model-generator/kubernetes-model-discovery && mvn -Pgenerate clean install
cd kubernetes-model-generator/kubernetes-model-events && mvn -Pgenerate clean install
cd kubernetes-model-generator/kubernetes-model-extensions && mvn -Pgenerate clean install
cd kubernetes-model-generator/kubernetes-model-flowcontrol && mvn -Pgenerate clean install
cd kubernetes-model-generator/kubernetes-model-gatewayapi && mvn -Pgenerate clean install
cd kubernetes-model-generator/kubernetes-model-networking && mvn -Pgenerate clean install
cd kubernetes-model-generator/kubernetes-model-metrics && mvn -Pgenerate clean install
cd kubernetes-model-generator/kubernetes-model-node && mvn -Pgenerate clean install
cd kubernetes-model-generator/kubernetes-model-policy && mvn -Pgenerate clean install
cd kubernetes-model-generator/kubernetes-model-scheduling && mvn -Pgenerate clean install
cd kubernetes-model-generator/kubernetes-model-storageclass && mvn -Pgenerate clean install
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
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
cd kubernetes-model-generator/openshift-model-machine && mvn -Pgenerate clean install
cd kubernetes-model-generator/openshift-model-machineconfiguration && mvn -Pgenerate clean install
cd kubernetes-model-generator/openshift-model-monitoring && mvn -Pgenerate clean install
cd kubernetes-model-generator/openshift-model-tuned && mvn -Pgenerate clean install
cd kubernetes-model-generator/openshift-model-whereabouts && mvn -Pgenerate clean install
cd kubernetes-model-generator/openshift-model-storageversionmigrator && mvn -Pgenerate clean install
cd kubernetes-model-generator/openshift-model-hive && mvn -Pgenerate clean install
cd kubernetes-model-generator/openshift-model-installer && mvn -Pgenerate clean install
cd kubernetes-model-generator && mvn $(MAVEN_ARGS) -Pgenerate clean install

# Legacy generation of the model: TODO: remove
.PHONY: generate-model-legacy
Expand All @@ -90,4 +52,17 @@ generate-model: openapi-generate-schema openapi-generate-java-classes generate-m

.PHONY: sonar
sonar:
mvn $(MAVEN_OPTIONS) clean install sonar:sonar -Psonar
mvn $(MAVEN_ARGS) clean install -Psonar
mvn $(MAVEN_ARGS) sonar:sonar -Psonar

.PHONY: format-license
format-license:
mvn $(MAVEN_ARGS) -N license:format

.PHONY: format-java
format-java:
mvn $(MAVEN_ARGS) spotless:apply -Pitests

.PHONY:
quickly: clean
mvn $(MAVEN_ARGS) install -DskipTests -Djacoco.skip=true
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var openApiRun = func(cobraCmd *cobra.Command, args []string) {
openshiftclusternetworkoperatorv1.GroupVersion.String(),
openshiftclusternodetuningoperatorv1.SchemeGroupVersion.String(),
openshifthivev1.SchemeGroupVersion.String(),
"install.openshift.io/" + openshiftinstallerv1.InstallConfigVersion + "(" + strings.Join(openshiftinstallerv1.PlatformNames, ",") + ")",
"install.openshift.io/" + openshiftinstallerv1.InstallConfigVersion + " (" + strings.Join(openshiftinstallerv1.PlatformNames, ", ") + ")",
operatorframeworkv1alpha1.SchemeGroupVersion.String(),
operatorframeworkv1.GroupVersion.String(),
prometheusoperatorv1.SchemeGroupVersion.String(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,23 @@ func (g *GoGenerator) Generate() error {
//
// Allows to override the default kube-openapi generators.apiTypeFilterFunc with our own (see KubernetesFilterFunc).
func (g *GoGenerator) KubernetesTargets(context *generator.Context) []generator.Target {
// Non-deterministic bug-fix
// ScopeType is sometimes considered enum and others isn't. Force it to be non enum to avoid issues
scopeType := context.Universe.Type(types.Name{Package: "k8s.io/api/admissionregistration/v1", Name: "ScopeType"})
originalComments := scopeType.CommentLines
scopeType.CommentLines = make([]string, 0)
for _, comment := range originalComments {
if comment != "+enum" {
scopeType.CommentLines = append(scopeType.CommentLines, comment)
}
}

// Create a map of all the input packages for performance (queried later on)
g.inputPkgs = make(map[string]bool)
for _, inputPackage := range context.Inputs {
g.inputPkgs[inputPackage] = true
}

// Replace original Filter function with something that includes all Kubernetes Object types regardless of the comment tag
openApiGenTargets := generators.GetTargets(context, &g.Args)
for _, target := range openApiGenTargets {
Expand Down
45 changes: 10 additions & 35 deletions kubernetes-model-generator/openapi/schemas/openshift-generated.json
Original file line number Diff line number Diff line change
Expand Up @@ -20653,13 +20653,8 @@
"x-kubernetes-list-type": "atomic"
},
"scope": {
"description": "scope specifies the scope of this rule. Valid values are \"Cluster\", \"Namespaced\", and \"*\" \"Cluster\" means that only cluster-scoped resources will match this rule. Namespace API objects are cluster-scoped. \"Namespaced\" means that only namespaced resources will match this rule. \"*\" means that there are no scope restrictions. Subresources match the scope of their parent resource. Default is \"*\".\n\n\nPossible enum values:\n - `\"*\"` means that all scopes are included.\n - `\"Cluster\"` means that scope is limited to cluster-scoped objects. Namespace objects are cluster-scoped.\n - `\"Namespaced\"` means that scope is limited to namespaced objects.",
"type": "string",
"enum": [
"*",
"Cluster",
"Namespaced"
]
"description": "scope specifies the scope of this rule. Valid values are \"Cluster\", \"Namespaced\", and \"*\" \"Cluster\" means that only cluster-scoped resources will match this rule. Namespace API objects are cluster-scoped. \"Namespaced\" means that only namespaced resources will match this rule. \"*\" means that there are no scope restrictions. Subresources match the scope of their parent resource. Default is \"*\".",
"type": "string"
}
},
"x-fabric8-info": {
Expand Down Expand Up @@ -20755,13 +20750,8 @@
"x-kubernetes-list-type": "atomic"
},
"scope": {
"description": "scope specifies the scope of this rule. Valid values are \"Cluster\", \"Namespaced\", and \"*\" \"Cluster\" means that only cluster-scoped resources will match this rule. Namespace API objects are cluster-scoped. \"Namespaced\" means that only namespaced resources will match this rule. \"*\" means that there are no scope restrictions. Subresources match the scope of their parent resource. Default is \"*\".\n\n\nPossible enum values:\n - `\"*\"` means that all scopes are included.\n - `\"Cluster\"` means that scope is limited to cluster-scoped objects. Namespace objects are cluster-scoped.\n - `\"Namespaced\"` means that scope is limited to namespaced objects.",
"type": "string",
"enum": [
"*",
"Cluster",
"Namespaced"
]
"description": "scope specifies the scope of this rule. Valid values are \"Cluster\", \"Namespaced\", and \"*\" \"Cluster\" means that only cluster-scoped resources will match this rule. Namespace API objects are cluster-scoped. \"Namespaced\" means that only namespaced resources will match this rule. \"*\" means that there are no scope restrictions. Subresources match the scope of their parent resource. Default is \"*\".",
"type": "string"
}
},
"x-fabric8-info": {
Expand Down Expand Up @@ -20820,13 +20810,8 @@
"x-kubernetes-list-type": "atomic"
},
"scope": {
"description": "scope specifies the scope of this rule. Valid values are \"Cluster\", \"Namespaced\", and \"*\" \"Cluster\" means that only cluster-scoped resources will match this rule. Namespace API objects are cluster-scoped. \"Namespaced\" means that only namespaced resources will match this rule. \"*\" means that there are no scope restrictions. Subresources match the scope of their parent resource. Default is \"*\".\n\n\nPossible enum values:\n - `\"*\"` means that all scopes are included.\n - `\"Cluster\"` means that scope is limited to cluster-scoped objects. Namespace objects are cluster-scoped.\n - `\"Namespaced\"` means that scope is limited to namespaced objects.",
"type": "string",
"enum": [
"*",
"Cluster",
"Namespaced"
]
"description": "scope specifies the scope of this rule. Valid values are \"Cluster\", \"Namespaced\", and \"*\" \"Cluster\" means that only cluster-scoped resources will match this rule. Namespace API objects are cluster-scoped. \"Namespaced\" means that only namespaced resources will match this rule. \"*\" means that there are no scope restrictions. Subresources match the scope of their parent resource. Default is \"*\".",
"type": "string"
}
},
"x-fabric8-info": {
Expand Down Expand Up @@ -21633,13 +21618,8 @@
"x-kubernetes-list-type": "atomic"
},
"scope": {
"description": "scope specifies the scope of this rule. Valid values are \"Cluster\", \"Namespaced\", and \"*\" \"Cluster\" means that only cluster-scoped resources will match this rule. Namespace API objects are cluster-scoped. \"Namespaced\" means that only namespaced resources will match this rule. \"*\" means that there are no scope restrictions. Subresources match the scope of their parent resource. Default is \"*\".\n\n\nPossible enum values:\n - `\"*\"` means that all scopes are included.\n - `\"Cluster\"` means that scope is limited to cluster-scoped objects. Namespace objects are cluster-scoped.\n - `\"Namespaced\"` means that scope is limited to namespaced objects.",
"type": "string",
"enum": [
"*",
"Cluster",
"Namespaced"
]
"description": "scope specifies the scope of this rule. Valid values are \"Cluster\", \"Namespaced\", and \"*\" \"Cluster\" means that only cluster-scoped resources will match this rule. Namespace API objects are cluster-scoped. \"Namespaced\" means that only namespaced resources will match this rule. \"*\" means that there are no scope restrictions. Subresources match the scope of their parent resource. Default is \"*\".",
"type": "string"
}
},
"x-fabric8-info": {
Expand Down Expand Up @@ -22425,13 +22405,8 @@
"x-kubernetes-list-type": "atomic"
},
"scope": {
"description": "scope specifies the scope of this rule. Valid values are \"Cluster\", \"Namespaced\", and \"*\" \"Cluster\" means that only cluster-scoped resources will match this rule. Namespace API objects are cluster-scoped. \"Namespaced\" means that only namespaced resources will match this rule. \"*\" means that there are no scope restrictions. Subresources match the scope of their parent resource. Default is \"*\".\n\n\nPossible enum values:\n - `\"*\"` means that all scopes are included.\n - `\"Cluster\"` means that scope is limited to cluster-scoped objects. Namespace objects are cluster-scoped.\n - `\"Namespaced\"` means that scope is limited to namespaced objects.",
"type": "string",
"enum": [
"*",
"Cluster",
"Namespaced"
]
"description": "scope specifies the scope of this rule. Valid values are \"Cluster\", \"Namespaced\", and \"*\" \"Cluster\" means that only cluster-scoped resources will match this rule. Namespace API objects are cluster-scoped. \"Namespaced\" means that only namespaced resources will match this rule. \"*\" means that there are no scope restrictions. Subresources match the scope of their parent resource. Default is \"*\".",
"type": "string"
}
},
"x-fabric8-info": {
Expand Down

0 comments on commit 73087a0

Please sign in to comment.