Aitozi commented on a change in pull request #112:
URL: 
https://github.com/apache/flink-kubernetes-operator/pull/112#discussion_r841216699



##########
File path: 
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/validation/DefaultValidator.java
##########
@@ -270,4 +271,37 @@
 
         return Optional.empty();
     }
+
+    // validate session job
+
+    @Override
+    public Optional<String> validate(
+            FlinkSessionJob sessionJob, Optional<FlinkDeployment> session) {
+
+        return firstPresent(
+                validateNotApplicationCluster(session),
+                validateSessionClusterId(sessionJob, session));
+    }
+
+    private Optional<String> validateSessionClusterId(
+            FlinkSessionJob sessionJob, Optional<FlinkDeployment> session) {
+        return session.map(
+                s -> {
+                    if 
(!s.getMetadata().getName().equals(sessionJob.getSpec().getClusterId())) {
+                        return "The session job's cluster id is not match with 
the session cluster";
+                    }
+                    return null;
+                });
+    }
+
+    private Optional<String> 
validateNotApplicationCluster(Optional<FlinkDeployment> session) {
+        return session.map(
+                s -> {
+                    if (s.getSpec().getJob() != null) {
+                        return "Can not submit to application cluster";
+                    } else {
+                        return null;

Review comment:
       The null value can be handled by `Optional.ofNullable` in `map` 
function, but the `flatMap` way looks more clear, Adjusted accordingly.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to