Skip to content

Commit

Permalink
fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
Claire.Nicholas authored and Claire.Nicholas committed Nov 28, 2023
1 parent 6cae776 commit b6f543e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
18 changes: 17 additions & 1 deletion DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ steps:
+ text: "Hello Repo {{ .RepositoryName }}!"
```
Sample of sending a message with attachment file:
Sample of sending a message with local attachment file:
```diff
steps:
Expand All @@ -47,6 +47,22 @@ steps:
parameters:
- text: "Hello World!"
filepath: slack_attachment.json
remote: false
registry: https://github.com
```
Sample of sending a message with remote attachment file:
```diff
steps:
- name: message-with-remote-attachment
image: target/vela-slack:latest
secrets: [ webhook ]
parameters:
- text: "Hello World!"
filepath: slack_attachment.json
remote: true
registry: https://github.com
```
content of `slack_attachment.json`:
Expand Down
6 changes: 2 additions & 4 deletions cmd/vela-slack/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,9 @@ func (p *Plugin) Validate() error {
return nil
}

// getRemoteAttachment function to open and parse slack attachment json file into
// slack webhook message payload.
// getRemoteAttachment function converts bytes into string and replaces variables
// such as {{ .BuildCreated }} with a correct values before returning it back into bytes again.
func replaceString(bytes []byte, p *Plugin) []byte {
// Converts bytes into string and replaces {{ .BuildCreated }}
// with a timestamp before returning it back into bytes again.
bStr := string(bytes)
bStr = strings.ReplaceAll(bStr, "{{ .BuildCreated }}", strconv.Itoa(p.Env.BuildCreated))
bStr = strings.ReplaceAll(bStr, "{{ .BuildEnqueued }}", strconv.Itoa(p.Env.BuildEnqueued))
Expand Down

0 comments on commit b6f543e

Please sign in to comment.