Skip to content

Commit

Permalink
Merge pull request #279 from werf/fix-generic-dont-fail-on-jsonpath-e…
Browse files Browse the repository at this point in the history
…rrs-on-condition-search

fix(generic): ignore jsonpath errs on Condition search
  • Loading branch information
ilya-lesikov authored Jul 29, 2022
2 parents e0b8f7c + 8d88c65 commit 6eba124
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/utils/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ func JSONPath(tmpl string, input interface{}) (result string, found bool, err er

resultBuf := &bytes.Buffer{}
if err := jsonPath.Execute(resultBuf, input); err != nil {
if strings.HasSuffix(err.Error(), " is not found") {
return "", false, nil
} else {
return "", false, fmt.Errorf("error executing jsonpath: %w", err)
if debug() && !strings.HasSuffix(err.Error(), " is not found") {
fmt.Printf("error executing jsonpath for tmpl %q and input %v: %s\n", tmpl, input, err)
}
return "", false, nil
}

if strings.TrimSpace(resultBuf.String()) == "" {
return "", false, nil
}
Expand Down

0 comments on commit 6eba124

Please sign in to comment.