Skip to content

Commit

Permalink
fix pipeline source is not unique due to version lock (#6044)
Browse files Browse the repository at this point in the history
  • Loading branch information
chengjoey authored Sep 20, 2023
1 parent a9861e5 commit 806ebd2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
14 changes: 8 additions & 6 deletions internal/tools/pipeline/providers/source/db/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ type PipelineSource struct {
}

type PipelineSourceUnique struct {
SourceType string `json:"sourceType"`
Remote string `json:"remote"`
Ref string `json:"ref"`
Path string `json:"path"`
Name string `json:"name"`
IDList []string `json:"idList"`
SourceType string `json:"sourceType"`
Remote string `json:"remote"`
Ref string `json:"ref"`
Path string `json:"path"`
Name string `json:"name"`
IDList []string `json:"idList"`
VersionLock uint64 `json:"versionLock" xorm:"version_lock version"`
}

func (PipelineSource) TableName() string {
Expand Down Expand Up @@ -111,6 +112,7 @@ func (client *Client) GetPipelineSourceByUnique(unique *PipelineSourceUnique, op
Where("path = ?", unique.Path).
Where("name = ?", unique.Name).
Where("soft_deleted_at = 0").
Where("version_lock = ?", unique.VersionLock).
Find(&pipelineSources); err != nil {
return nil, err
}
Expand Down
11 changes: 6 additions & 5 deletions internal/tools/pipeline/providers/source/pipeline_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ type pipelineSource struct {

func (p pipelineSource) Create(ctx context.Context, request *pb.PipelineSourceCreateRequest) (*pb.PipelineSourceCreateResponse, error) {
unique := &db.PipelineSourceUnique{
SourceType: request.SourceType,
Remote: request.Remote,
Ref: request.Ref,
Path: request.Path,
Name: request.Name,
SourceType: request.SourceType,
Remote: request.Remote,
Ref: request.Ref,
Path: request.Path,
Name: request.Name,
VersionLock: request.VersionLock,
}

var (
Expand Down

0 comments on commit 806ebd2

Please sign in to comment.