mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-08-03 15:08:49 +00:00
Include directory in slack webhook message
Fixes: https://github.com/runatlantis/atlantis/issues/660
This commit is contained in:
committed by
Tollef Fog Heen
parent
1fa621dc83
commit
8a3e342344
@@ -240,6 +240,7 @@ func (p *DefaultProjectCommandRunner) doApply(ctx models.ProjectCommandContext)
|
||||
Repo: ctx.BaseRepo,
|
||||
Pull: ctx.Pull,
|
||||
Success: err == nil,
|
||||
Directory: ctx.RepoRelDir,
|
||||
})
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("%s\n%s", err, strings.Join(outputs, "\n"))
|
||||
|
||||
@@ -98,6 +98,11 @@ func (d *DefaultSlackClient) createAttachments(applyResult ApplyResult) []slack.
|
||||
}
|
||||
|
||||
text := fmt.Sprintf("Apply %s for <%s|%s>", successWord, applyResult.Pull.URL, applyResult.Repo.FullName)
|
||||
directory := applyResult.Directory
|
||||
if directory == "." {
|
||||
directory = "/"
|
||||
}
|
||||
|
||||
attachment := slack.Attachment{
|
||||
Color: colour,
|
||||
Text: text,
|
||||
@@ -112,6 +117,11 @@ func (d *DefaultSlackClient) createAttachments(applyResult ApplyResult) []slack.
|
||||
Value: applyResult.User.Username,
|
||||
Short: true,
|
||||
},
|
||||
{
|
||||
Title: "Directory",
|
||||
Value: directory,
|
||||
Short: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
return []slack.Attachment{attachment}
|
||||
|
||||
@@ -109,6 +109,11 @@ func TestPostMessage_Success(t *testing.T) {
|
||||
Value: result.User.Username,
|
||||
Short: true,
|
||||
},
|
||||
{
|
||||
Title: "Directory",
|
||||
Value: result.Directory,
|
||||
Short: true,
|
||||
},
|
||||
},
|
||||
}}
|
||||
expParams.AsUser = false
|
||||
@@ -148,6 +153,11 @@ func TestPostMessage_Error(t *testing.T) {
|
||||
Value: result.User.Username,
|
||||
Short: true,
|
||||
},
|
||||
{
|
||||
Title: "Directory",
|
||||
Value: result.Directory,
|
||||
Short: true,
|
||||
},
|
||||
},
|
||||
}}
|
||||
expParams.AsUser = false
|
||||
|
||||
@@ -41,6 +41,7 @@ type ApplyResult struct {
|
||||
Pull models.PullRequest
|
||||
User models.User
|
||||
Success bool
|
||||
Directory string
|
||||
}
|
||||
|
||||
// MultiWebhookSender sends multiple webhooks for each one it's configured for.
|
||||
|
||||
Reference in New Issue
Block a user