Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions internal/util/GitCliUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (impl *GitCliUtil) Init(rootDir string, remoteUrl string, isBare bool) erro
}

func (impl *GitCliUtil) Clone(rootDir string, remoteUrl string, username string, password string) (response, errMsg string, err error) {
impl.logger.Infow("input", rootDir, remoteUrl, username)
impl.logger.Infow("git clone request", "rootDir", rootDir, "remoteUrl", remoteUrl, "username", username)
err = impl.Init(rootDir, remoteUrl, false)
if err != nil {
return "", "", err
Expand All @@ -111,24 +111,30 @@ func (impl *GitCliUtil) Clone(rootDir string, remoteUrl string, username string,
if err == nil && errMsg == "" {
impl.logger.Warn("git fetch completed, pulling master branch data from remote origin")
response, errMsg, err = impl.ListBranch(rootDir, username, password)
if err != nil {
impl.logger.Errorw("error on git pull", "response", response, "errMsg", errMsg, "err", err)
return response, errMsg, err
}
branches := strings.Split(response, "\n")
impl.logger.Info(branches)
impl.logger.Infow("total branch available in git repo", "branches", branches)
branch := ""
for _, item := range branches {
if strings.TrimSpace(item) == "origin/master" {
branch = Branch_Master
}
}
if len(branch) == 0 && len(branches) > 0 {
//if git repo has some branch take pull of the first branch, but eventually proxy chart will push into master branch
if len(branch) == 0 && branches != nil && len(branches[0]) > 0 {
branch = strings.ReplaceAll(branches[0], "origin/", "")
} else if len(branch) == 0 {
// only fetch will work, as we don't have any branch for pull
return "", "", nil
}
if branch == "" {
impl.logger.Warnw("no branch found in git repo", "remoteUrl", remoteUrl, "response", response)
return response, "", nil
}
response, errMsg, err = impl.Pull(rootDir, username, password, branch)
if err != nil {
impl.logger.Errorw("error on git pull", "branch", branch, "err", err)
return "", "", err
return response, errMsg, err
}
}
return response, errMsg, err
Expand Down
10 changes: 9 additions & 1 deletion pkg/appStore/deployment/service/AppStoreDeploymentService.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"github.com/devtron-labs/devtron/pkg/sql"
util2 "github.com/devtron-labs/devtron/util"
"github.com/go-pg/pg"
"github.com/google/go-github/github"
"go.uber.org/zap"
"net/http"
"time"
Expand Down Expand Up @@ -995,7 +996,14 @@ func (impl AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Context
err = impl.appStoreDeploymentArgoCdService.UpdateRequirementDependencies(environment, installedAppVersion, installAppVersionRequest, appStoreAppVersion)
if err != nil {
impl.logger.Errorw("error while commit required dependencies to git", "error", err)
return nil, err
statusError, ok := err.(*github.ErrorResponse)
if ok && statusError.Response.StatusCode == http.StatusNotFound {
impl.logger.Errorw("no content found while updating requirement file, git repo, do auto fix", "error", err)
//if by mistake no content found while updating git repo, do auto fix
installAppVersionRequest, err = impl.appStoreDeploymentArgoCdService.OnUpdateRepoInInstalledApp(ctx, installAppVersionRequest)
} else {
return nil, err
}
}
}
installAppVersionRequest.Id = installedAppVersion.Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/ghodss/yaml"
"github.com/go-pg/pg"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/google/go-github/github"
"go.uber.org/zap"
"net/http"
"strings"
Expand Down Expand Up @@ -385,7 +386,14 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) UpdateInstalledApp(ctx context.C
installAppVersionRequest, err := impl.updateValuesYaml(environment, installedAppVersion, installAppVersionRequest)
if err != nil {
impl.Logger.Errorw("error while commit values to git", "error", err)
return nil, err
statusError, ok := err.(*github.ErrorResponse)
if ok && statusError.Response.StatusCode == http.StatusNotFound {
impl.Logger.Errorw("no content found while updating git repo, do auto fix", "error", err)
//if by mistake no content found while updating git repo, do auto fix
installAppVersionRequest, err = impl.OnUpdateRepoInInstalledApp(ctx, installAppVersionRequest)
} else {
return nil, err
}
}
installAppVersionRequest.Environment = environment

Expand Down