Skip to content

Commit

Permalink
feat(integration-git): init git integration storage layer and git cli…
Browse files Browse the repository at this point in the history
…ent (#3070)

* init dao layer for git integration

* add jgit dependency and sdk implement

* add github and gitlab api client

* add git repo mapper

* format code

* fix UT failed

* move modules from integration.git to git

* format code

* response  to CR comments

* add `salt` column into table `integration_git_repository`

* response to CR comments

* rm unused class
  • Loading branch information
LuckyPickleZZ authored Aug 7, 2024
1 parent 4a36746 commit 90be76e
Show file tree
Hide file tree
Showing 20 changed files with 1,194 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@

<jwt.version>3.9.0</jwt.version>
<okhttp.version>4.11.0</okhttp.version>
<jgit.version>5.13.3.202401111512-r</jgit.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -1168,6 +1169,11 @@
<artifactId>java-jwt</artifactId>
<version>${jwt.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>${jgit.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
CREATE TABLE IF NOT EXISTS `integration_git_repository` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`creator_id` bigint(20) NOT NULL COMMENT 'creator user id, references iam_user.id',
`organization_id` bigint(20) NOT NULL COMMENT 'organization id, references iam_organization.id',
`project_id` bigint(20) DEFAULT NULL COMMENT 'project id, references collaboration_project.id',
`description` varchar(512) DEFAULT NULL COMMENT 'description',
`name` varchar(512) NOT NULL COMMENT 'repository name',
`provider_type` varchar(32) NOT NULL COMMENT 'git provider type',
`provider_url` varchar(128) NOT NULL COMMENT 'git provider url',
`ssh_address` varchar(512) NOT NULL COMMENT 'ssh clone url, like [email protected]:xxx/xxx.git',
`clone_address` varchar(512) NOT NULL COMMENT 'https clone url, like https://github.com/xxx/xxx.git',
`email` varchar(128) NOT NULL COMMENT 'user email for commit',
`personal_access_token` varchar(512) NOT NULL COMMENT 'personal access token',
`salt` varchar(32) DEFAULT NULL COMMENT 'used to connect the random value used by the encryption and decryption algorithm of the secret field',
PRIMARY KEY (`id`),
KEY `integration_git_repository_organization_id_project_id` (`organization_id`, `project_id`)
) COMMENT = 'integration git repository';

CREATE TABLE IF NOT EXISTS `integration_git_repository_stage` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`description` varchar(512) DEFAULT NULL COMMENT 'description',
`organization_id` bigint(20) NOT NULL COMMENT 'organization id, references iam_organization.id',
`repo_id` bigint(20) NOT NULL COMMENT 'git repository id, references integration_git_repository.id',
`state` varchar(32) NOT NULL COMMENT 'local repository state',
`branch` varchar(512) NOT NULL COMMENT 'last edit branch',
`last_commit_id` varchar(64) DEFAULT NULL COMMENT 'git commit revision number',
`diff_patch_storage` varchar(512) DEFAULT NULL COMMENT 'storage information of patch file',
`user_id` bigint(20) NOT NULL COMMENT 'user id, references iam_user.id',
PRIMARY KEY (`id`),
KEY `integration_git_edit_stage_organization_id_repo_id_user_id` (`organization_id`, `repo_id`, `user_id`)
) COMMENT = 'integration git repository stage, to save the stage of workspace';
4 changes: 4 additions & 0 deletions server/odc-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2023 OceanBase.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.oceanbase.odc.metadb.git;

import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import com.oceanbase.odc.config.jpa.OdcJpaRepository;

/**
* @author: liuyizhuo.lyz
* @date: 2024/7/29
*/
public interface GitRepoRepository extends OdcJpaRepository<GitRepositoryEntity, Long>,
JpaSpecificationExecutor<GitRepositoryEntity> {

List<GitRepositoryEntity> findByOrganizationIdAndProjectId(Long organizationId, Long projectId);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Copyright (c) 2023 OceanBase.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.oceanbase.odc.metadb.git;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import com.oceanbase.odc.service.git.model.VcsProvider;

import lombok.Data;

/**
* @author: liuyizhuo.lyz
* @date: 2024/7/29
*/
@Data
@Entity
@Table(name = "integration_git_repository")
public class GitRepositoryEntity {

@Id
@Column(name = "id", nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "create_time", insertable = false, updatable = false)
private Date createTime;

@Column(name = "update_time", insertable = false, updatable = false)
private Date updateTime;

@Column(name = "creator_id", nullable = false)
private Long creatorId;

@Column(name = "organization_id", nullable = false)
private Long organizationId;

@Column(name = "project_id", nullable = false)
private Long projectId;

@Column(name = "name", nullable = false)
private String name;

@Column(name = "description")
private String description;

@Enumerated(EnumType.STRING)
@Column(name = "provider_type", nullable = false)
private VcsProvider providerType;

@Column(name = "provider_url", nullable = false)
private String providerUrl;

@Column(name = "ssh_address", nullable = false)
private String sshAddress;

@Column(name = "clone_address", nullable = false)
private String cloneAddress;

@Column(name = "email", nullable = false)
private String email;

@Column(name = "personal_access_token", nullable = false)
private String personalAccessToken;

@Column(name = "salt", nullable = false)
private String salt;

}
Loading

0 comments on commit 90be76e

Please sign in to comment.