Browse Source

fix: Alarm instance port verification (#13827)

close: #13532
Jay Chung 2 years ago
parent
commit
6a33d2bec0

+ 4 - 1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkAlertChannelFactory.java

@@ -26,10 +26,12 @@ import org.apache.dolphinscheduler.alert.api.AlertChannel;
 import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
 import org.apache.dolphinscheduler.alert.api.AlertInputTips;
 import org.apache.dolphinscheduler.spi.params.PasswordParam;
+import org.apache.dolphinscheduler.spi.params.base.DataType;
 import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
 import org.apache.dolphinscheduler.spi.params.base.PluginParams;
 import org.apache.dolphinscheduler.spi.params.base.Validate;
 import org.apache.dolphinscheduler.spi.params.input.InputParam;
+import org.apache.dolphinscheduler.spi.params.input.number.InputNumberParam;
 import org.apache.dolphinscheduler.spi.params.radio.RadioParam;
 
 import java.util.Arrays;
@@ -120,10 +122,11 @@ public final class DingTalkAlertChannelFactory implements AlertChannelFactory {
                         .build())
                 .build();
 
-        InputParam portParam = InputParam
+        InputNumberParam portParam = InputNumberParam
                 .newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PORT, DingTalkParamsConstants.DING_TALK_PORT)
                 .addValidate(Validate.newBuilder()
                         .setRequired(false)
+                        .setType(DataType.NUMBER.getDataType())
                         .build())
                 .build();
 

+ 6 - 3
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannelFactory.java

@@ -28,10 +28,12 @@ import org.apache.dolphinscheduler.alert.api.AlertConstants;
 import org.apache.dolphinscheduler.alert.api.AlertInputTips;
 import org.apache.dolphinscheduler.alert.api.ShowType;
 import org.apache.dolphinscheduler.spi.params.PasswordParam;
+import org.apache.dolphinscheduler.spi.params.base.DataType;
 import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
 import org.apache.dolphinscheduler.spi.params.base.PluginParams;
 import org.apache.dolphinscheduler.spi.params.base.Validate;
 import org.apache.dolphinscheduler.spi.params.input.InputParam;
+import org.apache.dolphinscheduler.spi.params.input.number.InputNumberParam;
 import org.apache.dolphinscheduler.spi.params.radio.RadioParam;
 
 import java.util.ArrayList;
@@ -69,11 +71,12 @@ public final class EmailAlertChannelFactory implements AlertChannelFactory {
                         .addValidate(Validate.newBuilder().setRequired(true).build())
                         .build();
 
-        InputParam mailSmtpPort =
-                InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_PORT, MailParamsConstants.MAIL_SMTP_PORT)
-                        .setValue("25")
+        InputNumberParam mailSmtpPort =
+                InputNumberParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_PORT, MailParamsConstants.MAIL_SMTP_PORT)
+                        .setValue(25)
                         .addValidate(Validate.newBuilder()
                                 .setRequired(true)
+                                .setType(DataType.NUMBER.getDataType())
                                 .build())
                         .build();
 

+ 7 - 3
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuAlertChannelFactory.java

@@ -26,10 +26,12 @@ import org.apache.dolphinscheduler.alert.api.AlertChannel;
 import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
 import org.apache.dolphinscheduler.alert.api.AlertInputTips;
 import org.apache.dolphinscheduler.spi.params.PasswordParam;
+import org.apache.dolphinscheduler.spi.params.base.DataType;
 import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
 import org.apache.dolphinscheduler.spi.params.base.PluginParams;
 import org.apache.dolphinscheduler.spi.params.base.Validate;
 import org.apache.dolphinscheduler.spi.params.input.InputParam;
+import org.apache.dolphinscheduler.spi.params.input.number.InputNumberParam;
 import org.apache.dolphinscheduler.spi.params.radio.RadioParam;
 
 import java.util.Arrays;
@@ -70,10 +72,12 @@ public final class FeiShuAlertChannelFactory implements AlertChannelFactory {
                                 .setRequired(false).build())
                         .build();
 
-        InputParam portParam =
-                InputParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PORT, FeiShuParamsConstants.FEI_SHU_PORT)
+        InputNumberParam portParam =
+                InputNumberParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PORT, FeiShuParamsConstants.FEI_SHU_PORT)
                         .addValidate(Validate.newBuilder()
-                                .setRequired(false).build())
+                                .setRequired(false)
+                                .setType(DataType.NUMBER.getDataType())
+                                .build())
                         .build();
 
         InputParam userParam =

+ 6 - 2
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-telegram/src/main/java/org/apache/dolphinscheduler/plugin/alert/telegram/TelegramAlertChannelFactory.java

@@ -26,10 +26,12 @@ import org.apache.dolphinscheduler.alert.api.AlertChannel;
 import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
 import org.apache.dolphinscheduler.alert.api.AlertInputTips;
 import org.apache.dolphinscheduler.spi.params.PasswordParam;
+import org.apache.dolphinscheduler.spi.params.base.DataType;
 import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
 import org.apache.dolphinscheduler.spi.params.base.PluginParams;
 import org.apache.dolphinscheduler.spi.params.base.Validate;
 import org.apache.dolphinscheduler.spi.params.input.InputParam;
+import org.apache.dolphinscheduler.spi.params.input.number.InputNumberParam;
 import org.apache.dolphinscheduler.spi.params.radio.RadioParam;
 import org.apache.dolphinscheduler.spi.params.select.SelectParam;
 
@@ -113,10 +115,12 @@ public final class TelegramAlertChannelFactory implements AlertChannelFactory {
                         .build())
                 .build();
 
-        InputParam portParam =
-                InputParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PORT, TelegramParamsConstants.TELEGRAM_PORT)
+        InputNumberParam portParam =
+                InputNumberParam
+                        .newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PORT, TelegramParamsConstants.TELEGRAM_PORT)
                         .addValidate(Validate.newBuilder()
                                 .setRequired(false)
+                                .setType(DataType.NUMBER.getDataType())
                                 .build())
                         .build();
 

+ 1 - 1
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/params/base/FormType.java

@@ -28,7 +28,7 @@ import com.google.common.base.Functions;
 public enum FormType {
 
     INPUT("input"),
-    INPUTNUMBER("inputNumber"),
+    INPUTNUMBER("input-number"),
     RADIO("radio"),
     SELECT("select"),
     SWITCH("switch"),

+ 8 - 2
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/params/input/number/InputNumberParam.java

@@ -30,12 +30,13 @@ import java.util.List;
  */
 public class InputNumberParam extends PluginParams {
 
+    private final InputNumberParamProps props;
+
     private InputNumberParam(Builder builder) {
         super(builder);
+        this.props = builder.props;
     }
 
-    private InputNumberParamProps props;
-
     public static Builder newBuilder(String name, String title) {
         return new Builder(name, title);
     }
@@ -95,6 +96,11 @@ public class InputNumberParam extends PluginParams {
             this.display = display;
             return this;
         }
+
+        @Override
+        public InputNumberParam build() {
+            return new InputNumberParam(this);
+        }
     }
 
     @Override