You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampark.apache.org by be...@apache.org on 2022/12/07 05:35:43 UTC

[incubator-streampark] branch git-call updated: [Bug] project git clone bug fixed.

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

benjobs pushed a commit to branch git-call
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git


The following commit(s) were added to refs/heads/git-call by this push:
     new 963ec583b [Bug] project git clone bug fixed.
963ec583b is described below

commit 963ec583b61af59299083e1591ad26b66ebd2322
Author: benjobs <be...@apache.org>
AuthorDate: Wed Dec 7 13:34:07 2022 +0800

    [Bug] project git clone bug fixed.
---
 .../streampark/console/base/util/GitUtils.java     |  2 +-
 .../streampark/console/core/entity/Project.java    |  5 ++-
 .../streampark/console/core/enums/GitProtocol.java |  2 +-
 .../src/main/resources/db/data-h2.sql              |  2 +-
 .../src/main/resources/db/schema-h2.sql            |  2 ++
 .../main/resources/mapper/core/ProjectMapper.xml   |  2 ++
 .../src/locales/lang/en/flink/project.ts           |  5 +++
 .../src/locales/lang/zh-CN/flink/project.ts        |  5 +++
 .../src/views/flink/project/Add.vue                |  2 ++
 .../src/views/flink/project/Edit.vue               |  2 ++
 .../src/views/flink/project/project.data.ts        |  5 +++
 .../src/views/flink/project/useProject.ts          | 40 ++++++++++++++++++++--
 12 files changed, 65 insertions(+), 9 deletions(-)

diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/util/GitUtils.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/util/GitUtils.java
index dd6ce0584..3aba5844c 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/util/GitUtils.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/util/GitUtils.java
@@ -69,7 +69,7 @@ public class GitUtils {
     private static void setCredentials(TransportCommand<?, ?> transportCommand, Project project) {
         GitProtocol gitProtocol = GitProtocol.of(project.getGitProtocol());
         switch (gitProtocol) {
-            case HTTP:
+            case HTTPS:
                 UsernamePasswordCredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider(project.getUserName(), project.getPassword());
                 transportCommand.setCredentialsProvider(credentialsProvider);
                 break;
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
index 0584fa204..8953bebff 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
@@ -20,6 +20,7 @@ package org.apache.streampark.console.core.entity;
 import org.apache.streampark.common.conf.CommonConfig;
 import org.apache.streampark.common.conf.Workspace;
 import org.apache.streampark.common.util.CommandUtils;
+import org.apache.streampark.console.base.exception.ApiDetailException;
 import org.apache.streampark.console.base.util.CommonUtils;
 import org.apache.streampark.console.base.util.GitUtils;
 import org.apache.streampark.console.base.util.WebUtils;
@@ -41,7 +42,6 @@ import org.eclipse.jgit.lib.Constants;
 import java.io.File;
 import java.io.IOException;
 import java.io.Serializable;
-import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 
@@ -156,9 +156,8 @@ public class Project implements Serializable {
         try {
             return GitUtils.getBranchList(this);
         } catch (Exception e) {
-            log.error(e.getMessage(), e);
+            throw new ApiDetailException(e);
         }
-        return Collections.emptyList();
     }
 
     public GitAuthorizedError gitCheck() {
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/enums/GitProtocol.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/enums/GitProtocol.java
index f05de6b5c..2eba459da 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/enums/GitProtocol.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/enums/GitProtocol.java
@@ -21,7 +21,7 @@ import java.util.Arrays;
 
 public enum GitProtocol {
 
-    HTTP(1),
+    HTTPS(1),
     SSH(2);
 
     private final int value;
diff --git a/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql b/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql
index 4cad11b90..1261c633c 100644
--- a/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql
+++ b/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql
@@ -35,7 +35,7 @@ insert into `t_flink_effective` values (100000, 100000, 2, 100000, now());
 -- ----------------------------
 -- Records of t_flink_project
 -- ----------------------------
-insert into `t_flink_project` values (100000, 100000, 'streampark-quickstart', 'https://github.com/apache/incubator-streampark-quickstart', 'main', null, null, null, null, 1, 1, null, 'streampark-quickstart', -1, now(), now());
+insert into `t_flink_project` values (100000, 100000, 'streampark-quickstart', '1', 'https://github.com/apache/incubator-streampark-quickstart', 'main', null, null, null, null, null, 1, 1, null, 'streampark-quickstart', -1, now(), now());
 
 -- ----------------------------
 -- Records of t_flink_sql
diff --git a/streampark-console/streampark-console-service/src/main/resources/db/schema-h2.sql b/streampark-console/streampark-console-service/src/main/resources/db/schema-h2.sql
index 16dde69fe..6e4b7f4a3 100644
--- a/streampark-console/streampark-console-service/src/main/resources/db/schema-h2.sql
+++ b/streampark-console/streampark-console-service/src/main/resources/db/schema-h2.sql
@@ -176,10 +176,12 @@ create table if not exists `t_flink_project` (
   `id` bigint generated by default as identity not null,
   `team_id` bigint not null,
   `name` varchar(255)  default null,
+  `git_protocol` tinyint not null,
   `url` varchar(1000)  default null,
   `branches` varchar(1000)  default null,
   `user_name` varchar(255)  default null,
   `password` varchar(255)  default null,
+  `rsa_path` varchar(255)  default null,
   `pom` varchar(255)  default null,
   `build_args` varchar(255) default null,
   `type` tinyint default null,
diff --git a/streampark-console/streampark-console-service/src/main/resources/mapper/core/ProjectMapper.xml b/streampark-console/streampark-console-service/src/main/resources/mapper/core/ProjectMapper.xml
index 472fd657e..574bbf223 100644
--- a/streampark-console/streampark-console-service/src/main/resources/mapper/core/ProjectMapper.xml
+++ b/streampark-console/streampark-console-service/src/main/resources/mapper/core/ProjectMapper.xml
@@ -24,11 +24,13 @@
         <id column="id" jdbcType="INTEGER" property="id"/>
         <result column="team_id" jdbcType="BIGINT" property="teamId"/>
         <result column="name" jdbcType="VARCHAR" property="name"/>
+        <result column="git_protocol" jdbcType="INTEGER" property="gitProtocol"/>
         <result column="url" jdbcType="VARCHAR" property="url"/>
         <result column="repository" jdbcType="INTEGER" property="repository"/>
         <result column="branches" jdbcType="VARCHAR" property="branches"/>
         <result column="user_name" jdbcType="VARCHAR" property="userName"/>
         <result column="password" jdbcType="VARCHAR" property="password"/>
+        <result column="rsa_path" jdbcType="VARCHAR" property="rsaPath"/>
         <result column="pom" jdbcType="VARCHAR" property="pom"/>
         <result column="build_args" jdbcType="VARCHAR" property="buildArgs"/>
         <result column="type" jdbcType="INTEGER" property="type"/>
diff --git a/streampark-console/streampark-console-webapp/src/locales/lang/en/flink/project.ts b/streampark-console/streampark-console-webapp/src/locales/lang/en/flink/project.ts
index c09413070..805848b8e 100644
--- a/streampark-console/streampark-console-webapp/src/locales/lang/en/flink/project.ts
+++ b/streampark-console/streampark-console-webapp/src/locales/lang/en/flink/project.ts
@@ -32,6 +32,10 @@ export default {
     projectType: 'Project Type',
     projectTypePlaceholder: 'please select project type',
     cvs: 'CVS',
+    rsaPath: 'RSAPath',
+    rsaPathPlaceholder: 'RSA private key path, e.g: ~/.ssh/id_rsa',
+    gitProtocol: 'Connect Type',
+    gitProtocolPlaceholder: 'Git connection type, http/ssh',
     cvsPlaceholder: 'CVS',
     repositoryURL: 'Repository URL',
     repositoryURLPlaceholder: 'The Repository URL for this project',
@@ -55,6 +59,7 @@ export default {
     projectNameIsRequiredMessage: 'Project Name is required',
     projectNameIsUniqueMessage: 'The Project Name is already exists. Please check',
     projectTypeIsRequiredMessage: 'Project Type is required',
+    gitProtocolIsRequiredMessage: 'Connect Type is required',
     cvsIsRequiredMessage: 'CVS is required',
     repositoryURLIsRequiredMessage: 'Repository URL is required',
     pomSpecifiesModuleMessage:
diff --git a/streampark-console/streampark-console-webapp/src/locales/lang/zh-CN/flink/project.ts b/streampark-console/streampark-console-webapp/src/locales/lang/zh-CN/flink/project.ts
index 6a335bfd3..3397bb5eb 100644
--- a/streampark-console/streampark-console-webapp/src/locales/lang/zh-CN/flink/project.ts
+++ b/streampark-console/streampark-console-webapp/src/locales/lang/zh-CN/flink/project.ts
@@ -32,6 +32,10 @@ export default {
     projectType: '项目类型',
     projectTypePlaceholder: '请选择项目类型',
     cvs: 'CVS',
+    rsaPath: 'RSA私钥',
+    rsaPathPlaceholder: 'RSA私钥文件路径, 如: ~/.ssh/id_rsa',
+    gitProtocol: '连接方式',
+    gitProtocolPlaceholder: 'Git连接方式, http/ssh',
     cvsPlaceholder: 'CVS类型: git/svn',
     repositoryURL: '仓库地址',
     repositoryURLPlaceholder: '请输入该项目的仓库地址',
@@ -54,6 +58,7 @@ export default {
     projectNameIsRequiredMessage: '项目名称必填',
     projectNameIsUniqueMessage: '项目名称已存在,请再次输入',
     projectTypeIsRequiredMessage: '项目类型必选',
+    gitProtocolIsRequiredMessage: 'Git连接方式为必填项',
     cvsIsRequiredMessage: '资源来源必选',
     repositoryURLIsRequiredMessage: '(项目)仓库地址必填',
     pomSpecifiesModuleMessage: '指定编译pom.xml的模块 如未指定,则在根路径pom.xml下找到',
diff --git a/streampark-console/streampark-console-webapp/src/views/flink/project/Add.vue b/streampark-console/streampark-console-webapp/src/views/flink/project/Add.vue
index a16e16ab3..4d3eae72f 100644
--- a/streampark-console/streampark-console-webapp/src/views/flink/project/Add.vue
+++ b/streampark-console/streampark-console-webapp/src/views/flink/project/Add.vue
@@ -42,12 +42,14 @@
       const res = await createProject({
         teamId: getUserTeamId(),
         name: values.name,
+        gitProtocol: values.gitProtocol,
         url: values.url,
         repository: values.repository,
         type: values.type,
         branches: values.branches,
         userName: values.userName,
         password: values.password,
+        rsaPath: values.rsaPath || null,
         pom: values.pom,
         buildArgs: values.buildArgs,
         description: values.description,
diff --git a/streampark-console/streampark-console-webapp/src/views/flink/project/Edit.vue b/streampark-console/streampark-console-webapp/src/views/flink/project/Edit.vue
index ab7ea4b90..84f44d44d 100644
--- a/streampark-console/streampark-console-webapp/src/views/flink/project/Edit.vue
+++ b/streampark-console/streampark-console-webapp/src/views/flink/project/Edit.vue
@@ -60,12 +60,14 @@
       const { data } = await updateProject({
         id: route.query.id,
         name: values.name,
+        gitProtocol: values.gitProtocol,
         url: values.url,
         repository: values.repository,
         type: values.type,
         branches: values.branches,
         userName: values.userName,
         password: values.password,
+        rsaPath: values.rsaPath,
         pom: values.pom,
         buildArgs: values.buildArgs,
         description: values.description,
diff --git a/streampark-console/streampark-console-webapp/src/views/flink/project/project.data.ts b/streampark-console/streampark-console-webapp/src/views/flink/project/project.data.ts
index 625b9ae36..68b777eba 100644
--- a/streampark-console/streampark-console-webapp/src/views/flink/project/project.data.ts
+++ b/streampark-console/streampark-console-webapp/src/views/flink/project/project.data.ts
@@ -60,3 +60,8 @@ export enum ProjectType {
   Flink = 1,
   Spark = 2,
 }
+
+export enum GitProtocol {
+  https = 1,
+  ssh = 2,
+}
diff --git a/streampark-console/streampark-console-webapp/src/views/flink/project/useProject.ts b/streampark-console/streampark-console-webapp/src/views/flink/project/useProject.ts
index 37617331c..515cda801 100644
--- a/streampark-console/streampark-console-webapp/src/views/flink/project/useProject.ts
+++ b/streampark-console/streampark-console-webapp/src/views/flink/project/useProject.ts
@@ -78,8 +78,7 @@ export const useProject = () => {
           optionFilterProp: 'children',
           filterOption,
           options: [
-            { label: 'GitHub/GitLab', value: 1, disabled: false },
-            { label: 'Subversion', value: 2, disabled: true },
+            { label: 'GitHub/GitLab', value: 1, disabled: false }
           ],
           placeholder: t('flink.project.form.cvsPlaceholder'),
         },
@@ -91,6 +90,28 @@ export const useProject = () => {
           },
         ],
       },
+      {
+        field: 'gitProtocol',
+        label: t('flink.project.form.gitProtocol'),
+        component: 'Select',
+        componentProps: {
+          showSearch: true,
+          optionFilterProp: 'children',
+          filterOption,
+          options: [
+            { label: 'http/https', value: 1},
+            { label: 'ssh', value: 2},
+          ],
+          placeholder: t('flink.project.form.gitProtocolPlaceholder'),
+        },
+        rules: [
+          {
+            required: true,
+            type: 'number',
+            message: t('flink.project.operationTips.gitProtocolIsRequiredMessage'),
+          },
+        ],
+      },
       {
         field: 'url',
         label: t('flink.project.form.repositoryURL'),
@@ -121,6 +142,14 @@ export const useProject = () => {
           placeholder: t('flink.project.form.passwordPlaceholder'),
         },
       },
+      {
+        field: 'rsaPath',
+        label: t('flink.project.form.rsaPath'),
+        component: 'Input',
+        componentProps: {
+          placeholder: t('flink.project.form.rsaPathPlaceholder'),
+        },
+      },
       {
         field: 'branches',
         label: t('flink.project.form.branches'),
@@ -209,6 +238,7 @@ export const useProject = () => {
         branches: values.branches,
         userName: values.userName || null,
         password: values.password || null,
+        rsaPath: values.rsaPath || null,
       });
       if (res === 0) {
         if (branchList.value.length === 0) {
@@ -242,12 +272,14 @@ export const useProject = () => {
     try {
       const url = values.url;
       if (url) {
+        const gitProtocol = values.gitProtocol;
         const userName = values.userName || null;
         const password = values.password || null;
+        const rsaPath = values.rsaPath || null;
         const userNull = userName === null || userName === undefined || userName === '';
         const passNull = password === null || password === undefined || password === '';
         if ((userNull && passNull) || (!userNull && !passNull)) {
-          const res = await fetchBranches({ url, userName, password });
+          const res = await fetchBranches({ gitProtocol, url, userName, password, rsaPath });
           if (res) branchList.value = res.map((i) => ({ label: i, value: i }));
         }
       }
@@ -266,9 +298,11 @@ export const useProject = () => {
         name: res.name,
         type: res.type,
         repository: res.repository,
+        gitProtocol: res.gitProtocol,
         url: res.url,
         userName: res.userName,
         password: res.password,
+        rsaPath: res.rsaPath || null,
         branches: res.branches,
         pom: res.pom,
         buildArgs: res.buildArgs,