Skip to content

Commit

Permalink
make comment message configureable
Browse files Browse the repository at this point in the history
  • Loading branch information
KyriosGN0 committed Sep 10, 2024
1 parent d11855c commit f8d5888
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/on_pull-request_closed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
remove-temp-image:
runs-on: ubuntu-22.04
if: github.repository == 'zapier/kubechecks'
continue-on-error: true

# should match env.FS_TAG, in both pr-open.yaml and pr-close.yaml
concurrency: pr-${{ github.event.pull_request.number }}
Expand Down
3 changes: 3 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ func init() {
stringFlag(flags, "worst-hooks-state", "The worst state that can be returned from the hooks renderer.",
newStringOpts().
withDefault("panic"))
stringFlag(flags, "replan-comment-msg", "comment message which re-triggers kubechecks on PR",
newStringOpts().
withDefault("kubechecks again"))

panicIfError(viper.BindPFlags(flags))
setupLogOutput()
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ type ServerConfig struct {
TidyOutdatedCommentsMode string `mapstructure:"tidy-outdated-comments-mode"`
MaxQueueSize int64 `mapstructure:"max-queue-size"`
MaxConcurrenctChecks int `mapstructure:"max-concurrenct-checks"`
ReplanCommentMessage string `mapstructure:"replan-comment-msg"`
}

func New() (ServerConfig, error) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/vcs/github_client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ func (c *Client) ParseHook(ctx context.Context, r *http.Request, request []byte)
case *github.IssueCommentEvent:
switch p.GetAction() {
case "created":
if strings.ToLower(p.Comment.GetBody()) == "kubechecks again" {
log.Info().Msg("Got kubechecks again comment, Running again")
if strings.ToLower(p.Comment.GetBody()) == c.cfg.ReplanCommentMessage {
log.Info().Msgf("Got %s comment, Running again", c.cfg.ReplanCommentMessage)
return c.buildRepoFromComment(ctx, p), nil
} else {
log.Info().Str("action", p.GetAction()).Msg("ignoring Github issue comment event due to non matching string")
Expand Down
4 changes: 2 additions & 2 deletions pkg/vcs/gitlab_client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ func (c *Client) ParseHook(ctx context.Context, r *http.Request, request []byte)
case *gitlab.MergeCommentEvent:
switch event.ObjectAttributes.Action {
case gitlab.CommentEventActionCreate:
if strings.ToLower(event.ObjectAttributes.Note) == "kubechecks again" {
log.Info().Msg("Got kubechecks again comment, Running again")
if strings.ToLower(event.ObjectAttributes.Note) == c.cfg.ReplanCommentMessage {
log.Info().Msgf("Got %s comment, Running again", c.cfg.ReplanCommentMessage)
return c.buildRepoFromComment(event), nil
} else {
log.Info().Msg("ignoring Gitlab merge comment event due to non matching string")
Expand Down

0 comments on commit f8d5888

Please sign in to comment.