mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-08-06 15:48:46 +00:00
This is two changes: Replacing all usages of SimpleLogger with it's interface SimpleLogging which makes it easier to swap out loggers going forward Nukes SimpleLogger in favor of StructuredLogger which allows us to better analyze logs in our log management system we choose.
33 lines
1.2 KiB
Go
33 lines
1.2 KiB
Go
package events
|
|
|
|
import "github.com/runatlantis/atlantis/server/events/vcs"
|
|
|
|
type PullUpdater struct {
|
|
HidePrevPlanComments bool
|
|
VCSClient vcs.Client
|
|
MarkdownRenderer *MarkdownRenderer
|
|
}
|
|
|
|
func (c *PullUpdater) updatePull(ctx *CommandContext, command PullCommand, res CommandResult) {
|
|
// Log if we got any errors or failures.
|
|
if res.Error != nil {
|
|
ctx.Log.Err(res.Error.Error())
|
|
} else if res.Failure != "" {
|
|
ctx.Log.Warn(res.Failure)
|
|
}
|
|
|
|
// HidePrevPlanComments will hide old comments left from previous plan runs to reduce
|
|
// clutter in a pull/merge request. This will not delete the comment, since the
|
|
// comment trail may be useful in auditing or backtracing problems.
|
|
if c.HidePrevPlanComments {
|
|
if err := c.VCSClient.HidePrevPlanComments(ctx.Pull.BaseRepo, ctx.Pull.Num); err != nil {
|
|
ctx.Log.Err("unable to hide old comments: %s", err)
|
|
}
|
|
}
|
|
|
|
comment := c.MarkdownRenderer.Render(res, command.CommandName(), ctx.Log.GetHistory(), command.IsVerbose(), ctx.Pull.BaseRepo.VCSHost.Type)
|
|
if err := c.VCSClient.CreateComment(ctx.Pull.BaseRepo, ctx.Pull.Num, comment, command.CommandName().String()); err != nil {
|
|
ctx.Log.Err("unable to comment: %s", err)
|
|
}
|
|
}
|