Skip to content

Commit

Permalink
revert changes to error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mightyguava committed Sep 17, 2022
1 parent 3217f9a commit 57947c4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
6 changes: 5 additions & 1 deletion api/internal/git/cloner.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ func ClonerUsingGitExec(repoSpec *RepoSpec) error {
if err = r.run("init"); err != nil {
return err
}
if err = r.run(
"remote", "add", "origin", repoSpec.CloneSpec()); err != nil {
return err
}
ref := "HEAD"
if repoSpec.Ref != "" {
ref = repoSpec.Ref
}
if err = r.run("fetch", "--depth=1", repoSpec.CloneSpec(), ref); err != nil {
if err = r.run("fetch", "--depth=1", "origin", ref); err != nil {
return err
}
if err = r.run("checkout", "FETCH_HEAD"); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions api/internal/git/gitrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ func (r gitRunner) run(args ...string) error {
cmd.String(),
r.duration,
func() error {
out, err := cmd.CombinedOutput()
_, err := cmd.CombinedOutput()
if err != nil {
return errors.Wrapf(err, "failed to run '%s': %s", cmd.String(), string(out))
return errors.Wrapf(err, "git cmd = '%s'", cmd.String())
}
return err
})
Expand Down
11 changes: 3 additions & 8 deletions api/internal/target/kusttarget.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,16 +412,11 @@ func (kt *KustTarget) accumulateResources(
}
ldr, err := kt.ldr.New(path)
if err != nil {
if strings.Contains(err.Error(), load.ErrRtNotDir.Error()) { // Was neither a remote resource nor a local directory.
if kusterr.IsMalformedYAMLError(errF) {
// Some error occurred while tyring to decode YAML file
return nil, errF
}
return nil, errors.Wrapf(
err, "accumulation err='%s'", errF.Error())
if kusterr.IsMalformedYAMLError(errF) { // Some error occurred while tyring to decode YAML file
return nil, errF
}
return nil, errors.Wrapf(
err, "accumulating remote resource: %s", path)
err, "accumulation err='%s'", errF.Error())
}
// store the origin, we'll need it later
origin := kt.origin.Copy()
Expand Down

0 comments on commit 57947c4

Please sign in to comment.