Skip to content

Commit

Permalink
feat: query escape function for notifications (argoproj#16343)
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Schumann <[email protected]>
Co-authored-by: pasha-codefresh <[email protected]>
Signed-off-by: Adrian Aneci <[email protected]>
  • Loading branch information
2 people authored and adriananeci committed Feb 25, 2024
1 parent e47c324 commit fd06ac0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/operator-manual/notifications/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ Transforms given GIT URL into HTTPs format.

Returns repository URL full name `(<owner>/<repoName>)`. Currently supports only Github, GitLab and Bitbucket.

<hr>
**`repo.QueryEscape(s string) string`**

QueryEscape escapes the string, so it can be safely placed inside a URL

Example:
```
/projects/{{ call .repo.QueryEscape (call .repo.FullNameByRepoURL .app.status.RepoURL) }}/merge_requests
```

<hr>
**`repo.GetCommitMetadata(sha string) CommitMetadata`**

Expand Down
2 changes: 2 additions & 0 deletions util/notification/expression/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"errors"
"net/url"
"regexp"
"strings"

Expand Down Expand Up @@ -90,6 +91,7 @@ func NewExprs(argocdService service.Service, app *unstructured.Unstructured) map
return map[string]interface{}{
"RepoURLToHTTPS": repoURLToHTTPS,
"FullNameByRepoURL": FullNameByRepoURL,
"QueryEscape": url.QueryEscape,
"GetCommitMetadata": func(commitSHA string) interface{} {
meta, err := getCommitMetadata(commitSHA, app, argocdService)
if err != nil {
Expand Down

0 comments on commit fd06ac0

Please sign in to comment.