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 <js@schumann-it.com>
Co-authored-by: pasha-codefresh <pavel@codefresh.io>
  • Loading branch information
janschumann and pasha-codefresh authored Feb 12, 2024
1 parent 4458d5f commit 82433ff
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 82433ff

Please sign in to comment.