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: openshift-model-monitoring generated from OpenAPI schemas #6368

Closed
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ generate-openapi-classes:
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

# Legacy generation of the model: TODO: remove
.PHONY: generate-model-legacy
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 @@ -24,7 +24,6 @@ ABSOLUTE_BASEDIR=$(realpath "$BASEDIR")
declare -a modules=(
"openshift-model-hive"
"openshift-model-installer"
"openshift-model-monitoring"
"openshift-model-tuned"
"openshift-model-whereabouts"
"openshift-model-storageversionmigrator"
Expand Down
12 changes: 6 additions & 6 deletions kubernetes-model-generator/kubernetes-model-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@
io.fabric8.kubernetes.api.model.storage,
io.fabric8.kubernetes.api.model.storage.v1beta1,
io.fabric8.openshift.api.model;resolution:=optional,
io.fabric8.openshift.api.model.clusterautoscaling.v1;resolution:=optional,
io.fabric8.openshift.api.model.clusterautoscaling.v1beta1;resolution:=optional,
io.fabric8.openshift.api.model.autoscaling.v1;resolution:=optional,
io.fabric8.openshift.api.model.autoscaling.v1beta1;resolution:=optional,
io.fabric8.openshift.api.model.runtime;resolution:=optional,
io.fabric8.openshift.api.model.console.v1;resolution:=optional,
io.fabric8.openshift.api.model.console.v1alpha1;resolution:=optional,
io.fabric8.openshift.api.model.monitoring.v1;resolution:=optional,
io.fabric8.openshift.api.model.monitoring.v1alpha1;resolution:=optional,
io.fabric8.openshift.api.model.monitoring.v1beta1;resolution:=optional,
io.fabric8.openshift.api.model.operator;resolution:=optional,
io.fabric8.openshift.api.model.operator.v1;resolution:=optional,
io.fabric8.openshift.api.model.operator.v1alpha1;resolution:=optional,
Expand All @@ -86,7 +86,7 @@
io.fabric8.openshift.api.model.operatorhub.v1;resolution:=optional,
io.fabric8.openshift.api.model.operatorhub.v1alpha1;resolution:=optional,
io.fabric8.openshift.api.model.operatorhub.lifecyclemanager.v1;resolution:=optional,
io.fabric8.openshift.api.model.machineconfig.v1;resolution:=optional,
io.fabric8.openshift.api.model.machineconfiguration.v1;resolution:=optional,
io.fabric8.openshift.api.model.machine.v1beta1;resolution:=optional,
io.fabric8.openshift.api.model.tuned.v1;resolution:=optional,
io.fabric8.openshift.api.model.whereabouts.v1alpha1;resolution:=optional,
Expand All @@ -106,9 +106,9 @@
</osgi.private>
<osgi.require-capability>
osgi.extender;
filter:="(osgi.extender=osgi.serviceloader.processor)",
filter:="(osgi.extender=osgi.serviceloader.processor)",
osgi.serviceloader;
filter:="(osgi.serviceloader=io.fabric8.kubernetes.api.model.KubernetesResource)";
filter:="(osgi.serviceloader=io.fabric8.kubernetes.api.model.KubernetesResource)";
cardinality:=multiple
</osgi.require-capability>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,23 @@ public class SchemaUtils {

private static final Set<String> PROTECTED_WORDS = new HashSet<>(Arrays.asList(
"abstract",
"class",
"continue",
"default",
"enum",
"class",
"for",
"import",
"int",
"package",
"private",
"for",
"return",
"package"));
"short",
"static"));

private static final Map<String, String> MAPPED_WORDS = new LinkedHashMap<>();
static {
MAPPED_WORDS.put("class", "clazz");
}

private final GeneratorSettings settings;

Expand Down Expand Up @@ -355,15 +362,20 @@ public static String removeDashes(String variable) {

public static String sanitizeVariable(String variable) {
final String sanitized = uncapitalize(removeDashes(variable));
return PROTECTED_WORDS.contains(sanitized) ? "_" + sanitized : sanitized;
final String mapped = MAPPED_WORDS.getOrDefault(sanitized, sanitized);
return PROTECTED_WORDS.contains(mapped) ? "_" + mapped : mapped;
}

public static String getterName(String variable) {
return "get".concat(capitalize(removeDashes(variable)));
final String property = removeDashes(variable);
final String mapped = MAPPED_WORDS.getOrDefault(property, property);
return "get".concat(capitalize(mapped));
}

public static String setterName(String variable) {
return "set".concat(capitalize(removeDashes(variable)));
final String property = removeDashes(variable);
final String mapped = MAPPED_WORDS.getOrDefault(property, property);
return "set".concat(capitalize(mapped));
}

public Map<String, Schema<?>> extractComponentSchemas() {
Expand Down
27 changes: 0 additions & 27 deletions kubernetes-model-generator/openshift-model-monitoring/Makefile

This file was deleted.

This file was deleted.

43 changes: 20 additions & 23 deletions kubernetes-model-generator/openshift-model-monitoring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,37 +43,34 @@
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-core</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-common</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>
<com.coreos.monitoring>io.fabric8.openshift.api.model.monitoring</com.coreos.monitoring>
</packageMappings>
<includeGenerationRegexes>
<includeGenerationRegex>^com\.coreos\.monitoring\.v1\..*$</includeGenerationRegex>
<includeGenerationRegex>^com\.coreos\.monitoring\.v1beta1\..*$</includeGenerationRegex>
</includeGenerationRegexes>
<refToJavaTypeMappings>
<io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelectorRequirement_v2>io.fabric8.kubernetes.api.model.LabelSelectorRequirement</io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelectorRequirement_v2>
</refToJavaTypeMappings>
</settings>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
Loading
Loading