Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: more verbose errors #36

Merged
merged 6 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions .github/workflows/pull_request_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
name: Validate dockerfile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: dorny/paths-filter@v2
id: filter
Expand All @@ -24,7 +24,7 @@ jobs:
name: Validate build-tools
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: dorny/paths-filter@v2
id: filter
Expand All @@ -41,7 +41,7 @@ jobs:
name: Validate test-server
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: dorny/paths-filter@v2
id: filter
Expand All @@ -58,7 +58,7 @@ jobs:
name: Validate dev-container
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: dorny/paths-filter@v2
id: filter
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull_request_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: Static Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Configure python
uses: actions/[email protected]
with:
Expand All @@ -37,7 +37,7 @@ jobs:
git-server:
image: ghcr.io/docplanner/helm-repo-updater/git-repo-server:develop
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Build app
run: make build
Expand Down
22 changes: 22 additions & 0 deletions internal/app/updater/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ func commitGitChanges(appName string, gitW git.Worktree, commitMessage string, g
},
})
if err != nil {
logCtx.Errorf(err.Error())

return nil, err
}
return &commit, nil
Expand All @@ -93,6 +95,8 @@ func pushGitChanges(appName string, objC object.Commit, gitR *git.Repository, gi
Auth: gitAuth,
})
if err != nil {
logCtx.Errorf(err.Error())

return err
}

Expand All @@ -110,6 +114,8 @@ func commitAndPushGitChanges(cfg HelmUpdaterConfig, commitMessage string, gitW g
logCtx.Infof("Adding file %s to git for commit changes", targetFile)
_, err := gitW.Add(targetFile)
if err != nil {
logCtx.Errorf(err.Error())

return err
}

Expand All @@ -120,12 +126,16 @@ func commitAndPushGitChanges(cfg HelmUpdaterConfig, commitMessage string, gitW g

gitR, err := git.PlainOpen(tempRoot)
if err != nil {
logCtx.Errorf(err.Error())

return err
}

logCtx.Debugf("Obtaining current HEAD to verify added changes")
obj, err := gitR.CommitObject(*commit)
if err != nil {
logCtx.Errorf(err.Error())

return err
}
err = pushGitChanges(cfg.AppName, *obj, gitR, gitAuth)
Expand Down Expand Up @@ -288,26 +298,36 @@ func commitChangesGit(cfg HelmUpdaterConfig, write changeWriter) (*[]ChangeEntry
logCtx := log.WithContext().AddField("application", cfg.AppName)
creds, err := cfg.GitCredentials.NewGitCreds(cfg.GitConf.RepoURL, cfg.GitCredentials.Password)
if err != nil {
logCtx.Errorf(err.Error())

return nil, fmt.Errorf("could not get creds for repo '%s': %v", cfg.AppName, err)
}

tempRoot, err := createTempFileInDirectory(fmt.Sprintf("git-%s", cfg.AppName), cfg.AppName, cfg.GitConf.RepoURL)
if err != nil {
logCtx.Errorf(err.Error())

return nil, err
}

gitW, err := cloneGitRepositoryInBranch(cfg.AppName, cfg.GitConf.RepoURL, creds, *tempRoot, cfg.GitConf.Branch)
if err != nil {
logCtx.Errorf(err.Error())

return nil, err
}

// write changes to files
if apps, err = write(cfg, *tempRoot, *gitW); err != nil {
logCtx.Errorf(err.Error())

return nil, err
}

commitMessage, err := configureCommitMessage(cfg.AppName, apps, cfg.GitConf.Message)
if err != nil {
logCtx.Errorf(err.Error())

return nil, err
}

Expand All @@ -318,6 +338,8 @@ func commitChangesGit(cfg HelmUpdaterConfig, write changeWriter) (*[]ChangeEntry

err = commitAndPushGitChanges(cfg, *commitMessage, *gitW, *tempRoot, creds)
if err != nil {
logCtx.Errorf(err.Error())

return nil, err
}

Expand Down
Loading