This is an automated email from the ASF dual-hosted git repository.

gyfora pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/flink-kubernetes-operator.git


The following commit(s) were added to refs/heads/main by this push:
     new 410a0a32 [FLINK-30705] Fix CR ref gen to use JsonProperty annotation 
values
410a0a32 is described below

commit 410a0a327fa68e0744938d0c658caaa95d44f597
Author: Zsombor Chikan <[email protected]>
AuthorDate: Sat Jan 21 20:26:46 2023 +0100

    [FLINK-30705] Fix CR ref gen to use JsonProperty annotation values
---
 docs/content/docs/custom-resource/reference.md     | 14 +++++------
 .../operator/api/docs/CrdReferenceDoclet.java      | 27 ++++++++++++++++++++--
 2 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/docs/content/docs/custom-resource/reference.md 
b/docs/content/docs/custom-resource/reference.md
index eaf4076c..7c27192a 100644
--- a/docs/content/docs/custom-resource/reference.md
+++ b/docs/content/docs/custom-resource/reference.md
@@ -130,8 +130,8 @@ This page serves as a full reference for FlinkDeployment 
custom resource definit
 
 | Value | Docs |
 | ----- | ---- |
-| RUNNING | Job is expected to be processing data. |
-| SUSPENDED | Processing is suspended with the intention of continuing later. |
+| running | Job is expected to be processing data. |
+| suspended | Processing is suspended with the intention of continuing later. |
 
 ### KubernetesDeploymentMode
 **Class**: 
org.apache.flink.kubernetes.operator.api.spec.KubernetesDeploymentMode
@@ -140,8 +140,8 @@ This page serves as a full reference for FlinkDeployment 
custom resource definit
 
 | Value | Docs |
 | ----- | ---- |
-| NATIVE | Deploys Flink using Flinks native Kubernetes support. Only 
supported for newer versions of Flink |
-| STANDALONE | Deploys Flink on-top of kubernetes in standalone mode. |
+| native | Deploys Flink using Flinks native Kubernetes support. Only 
supported for newer versions of Flink |
+| standalone | Deploys Flink on-top of kubernetes in standalone mode. |
 
 ### Resource
 **Class**: org.apache.flink.kubernetes.operator.api.spec.Resource
@@ -171,9 +171,9 @@ This page serves as a full reference for FlinkDeployment 
custom resource definit
 
 | Value | Docs |
 | ----- | ---- |
-| SAVEPOINT | Job is upgraded by first taking a savepoint of the running job, 
shutting it down and restoring from the savepoint. |
-| LAST_STATE | Job is upgraded using any latest checkpoint or savepoint 
available. |
-| STATELESS | Job is upgraded with empty state. |
+| savepoint | Job is upgraded by first taking a savepoint of the running job, 
shutting it down and restoring from the savepoint. |
+| last-state | Job is upgraded using any latest checkpoint or savepoint 
available. |
+| stateless | Job is upgraded with empty state. |
 
 ## Status
 
diff --git 
a/flink-kubernetes-operator-api/src/main/java/org/apache/flink/kubernetes/operator/api/docs/CrdReferenceDoclet.java
 
b/flink-kubernetes-operator-api/src/main/java/org/apache/flink/kubernetes/operator/api/docs/CrdReferenceDoclet.java
index 2a684fd2..21c819ed 100644
--- 
a/flink-kubernetes-operator-api/src/main/java/org/apache/flink/kubernetes/operator/api/docs/CrdReferenceDoclet.java
+++ 
b/flink-kubernetes-operator-api/src/main/java/org/apache/flink/kubernetes/operator/api/docs/CrdReferenceDoclet.java
@@ -17,6 +17,7 @@
 
 package org.apache.flink.kubernetes.operator.api.docs;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
 import com.sun.source.doctree.DocCommentTree;
 import com.sun.source.util.DocTrees;
 import jdk.javadoc.doclet.Doclet;
@@ -25,6 +26,7 @@ import jdk.javadoc.doclet.Reporter;
 import org.apache.commons.io.FileUtils;
 
 import javax.lang.model.SourceVersion;
+import javax.lang.model.element.AnnotationValue;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
 import javax.lang.model.element.Modifier;
@@ -53,6 +55,27 @@ public class CrdReferenceDoclet implements Doclet {
     private String outputFile;
     private Map<Element, Element> child2ParentElements;
 
+    private String getNameOrJsonPropValue(Element e) {
+        return e.getAnnotationMirrors().stream()
+                .filter(
+                        am ->
+                                am.getAnnotationType()
+                                        .toString()
+                                        .equals(JsonProperty.class.getName()))
+                .flatMap(am -> am.getElementValues().entrySet().stream())
+                .filter(entry -> 
entry.getKey().getSimpleName().toString().equals("value"))
+                .map(
+                        entry -> {
+                            AnnotationValue value = entry.getValue();
+                            if (value.getValue() instanceof String) {
+                                return (String) value.getValue();
+                            }
+                            return e.getSimpleName().toString();
+                        })
+                .findFirst()
+                .orElse(e.getSimpleName().toString());
+    }
+
     @Override
     public void init(Locale locale, Reporter reporter) {}
 
@@ -190,7 +213,7 @@ public class CrdReferenceDoclet implements Doclet {
                 case FIELD:
                     out.println(
                             "| "
-                                    + e
+                                    + getNameOrJsonPropValue(e)
                                     + " | "
                                     + e.asType().toString()
                                     + " | "
@@ -210,7 +233,7 @@ public class CrdReferenceDoclet implements Doclet {
                 case ENUM_CONSTANT:
                     out.println(
                             "| "
-                                    + e
+                                    + getNameOrJsonPropValue(e)
                                     + " | "
                                     + (dcTree != null ? 
cleanDoc(dcTree.toString()) : "")
                                     + " |");

Reply via email to