Skip to content

Commit

Permalink
Merge pull request #72 from devtron-labs/stable-dt19-v3
Browse files Browse the repository at this point in the history
fix: Stable dt19 v3 + v4
  • Loading branch information
prakash100198 authored Nov 2, 2023
2 parents 2784227 + 6264303 commit 4f3b9a1
Show file tree
Hide file tree
Showing 13 changed files with 494 additions and 469 deletions.
1 change: 1 addition & 0 deletions api/GrpcHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ func (impl *GrpcHandlerImpl) SavePipelineMaterial(ctx context.Context, req *pb.S
CommitAuthor: item.CommitAuthor,
CommitDate: item.CommitDate.AsTime(),
CommitHistory: item.CommitHistory,
CommitMessage: item.CommitMessage,
Errored: item.Errored,
ErrorMsg: item.ErrorMsg,
})
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.17
require (
github.com/caarlos0/env v3.5.0+incompatible
github.com/devtron-labs/common-lib v0.0.0-20230109070754-ff4dca200a2c
github.com/devtron-labs/protos v0.0.0-20230503113602-282404f70fd2
github.com/devtron-labs/protos v0.0.2
github.com/gammazero/workerpool v0.0.0-20200206003619-019d125201ab
github.com/go-pg/pg v6.15.1+incompatible
github.com/google/wire v0.4.0
Expand All @@ -17,6 +17,7 @@ require (
github.com/stretchr/testify v1.8.2
github.com/tidwall/gjson v1.8.0
go.uber.org/zap v1.21.0
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f
google.golang.org/grpc v1.51.0
google.golang.org/protobuf v1.28.1
gopkg.in/src-d/go-git.v4 v4.13.1
Expand Down Expand Up @@ -57,7 +58,6 @@ require (
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 // indirect
google.golang.org/genproto v0.0.0-20220810155839-1856144b1d9c // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/devtron-labs/common-lib v0.0.0-20230109070754-ff4dca200a2c h1:jz7yPUlIJXFg9AvJh2fb0QW7JT6+RKj8LOl1mWM/HQA=
github.com/devtron-labs/common-lib v0.0.0-20230109070754-ff4dca200a2c/go.mod h1:R24nOqgk4buk9zv+BXzORfObZsOe3NE9P55KrZXGX9k=
github.com/devtron-labs/protos v0.0.0-20230503113602-282404f70fd2 h1:/IEIsJTxDZ3hv8uOoCaqdWCXqcv7nCAgX9AP/v84dUY=
github.com/devtron-labs/protos v0.0.0-20230503113602-282404f70fd2/go.mod h1:l85jxWHlcSo910hdUfRycL40yGzC6glE93V1sVxVPto=
github.com/devtron-labs/protos v0.0.2 h1:BXrW3sXpUZKz25fbHHOAlnth1apHlALU3gfrbGd+WTY=
github.com/devtron-labs/protos v0.0.2/go.mod h1:l85jxWHlcSo910hdUfRycL40yGzC6glE93V1sVxVPto=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
Expand Down
10 changes: 5 additions & 5 deletions internal/sql/CiPipelineMaterial.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ type CiPipelineMaterial struct {
LastSeenHash string `sql:"last_seen_hash,notnull"`
CommitAuthor string `sql:"commit_author"`
CommitDate time.Time `sql:"commit_date"`

CommitHistory string `sql:"commit_history"` //last five commit for caching purpose1
Errored bool `sql:"errored,notnull"`
ErrorMsg string `sql:"error_msg,notnull"`
}
CommitMessage string `sql:"commit_message"`

CommitHistory string `sql:"commit_history"` //last five commit for caching purpose1
Errored bool `sql:"errored,notnull"`
ErrorMsg string `sql:"error_msg,notnull"`
}

type CiPipelineMaterialRepository interface {
FindByGitMaterialId(gitMaterialId int) ([]*CiPipelineMaterial, error)
Expand Down
8 changes: 5 additions & 3 deletions pkg/RepoManages.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ func (impl RepoManagerImpl) updatePipelineMaterialCommit(materials []*sql.CiPipe
pipelineMaterial.LastSeenHash = latestCommit.Commit
pipelineMaterial.CommitAuthor = latestCommit.Author
pipelineMaterial.CommitDate = latestCommit.Date
pipelineMaterial.CommitMessage = latestCommit.Message
}
pipelineMaterial.Errored = false
pipelineMaterial.ErrorMsg = ""
Expand Down Expand Up @@ -416,9 +417,10 @@ func (impl RepoManagerImpl) materialTOMaterialBeanConverter(material *sql.CiPipe
Value: material.Value,
Active: material.Active,
GitCommit: &git.GitCommit{
Commit: material.LastSeenHash,
Author: material.CommitAuthor,
Date: material.CommitDate,
Commit: material.LastSeenHash,
Author: material.CommitAuthor,
Date: material.CommitDate,
Message: material.CommitMessage,
},
}
return materialBean
Expand Down
10 changes: 9 additions & 1 deletion pkg/git/GitCliUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package git

import (
"context"
"errors"
"fmt"
"go.uber.org/zap"
"gopkg.in/src-d/go-git.v4"
Expand All @@ -28,7 +29,10 @@ func NewGitUtil(logger *zap.SugaredLogger) *GitUtil {
}
}

const GIT_ASK_PASS = "/git-ask-pass.sh"
const (
GIT_ASK_PASS = "/git-ask-pass.sh"
AUTHENTICATION_FAILED_ERROR = "Authentication failed"
)

func (impl *GitUtil) Fetch(gitContext *GitContext, rootDir string) (response, errMsg string, err error) {
impl.logger.Debugw("git fetch ", "location", rootDir)
Expand Down Expand Up @@ -64,6 +68,10 @@ func (impl *GitUtil) runCommand(cmd *exec.Cmd) (response, errMsg string, err err
if !ok {
return "", string(outBytes), err
}
if strings.Contains(string(outBytes), AUTHENTICATION_FAILED_ERROR) {
impl.logger.Errorw("authentication failed", "msg", string(outBytes), "err", err.Error())
return "", "authentication failed", errors.New("authentication failed")
}
errOutput := string(exErr.Stderr)
return "", errOutput, err
}
Expand Down
1 change: 1 addition & 0 deletions pkg/git/Watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ func (impl GitWatcherImpl) pollGitMaterialAndNotify(material *sql.GitMaterial) e
material.LastSeenHash = latestCommit.Commit
material.CommitAuthor = latestCommit.Author
material.CommitDate = latestCommit.Date
material.CommitMessage = latestCommit.Message
commitJson, _ := json.Marshal(commits)
material.CommitHistory = string(commitJson)
material.Errored = false
Expand Down
1 change: 1 addition & 0 deletions scripts/sql/11_add_commit_message.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "public"."ci_pipeline_material" DROP COLUMN IF EXISTS "commit_message";
1 change: 1 addition & 0 deletions scripts/sql/11_add_commit_message.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "public"."ci_pipeline_material" ADD COLUMN IF NOT EXISTS "commit_message" text;
Loading

0 comments on commit 4f3b9a1

Please sign in to comment.