Skip to content

Commit

Permalink
Add source.omit_target_url
Browse files Browse the repository at this point in the history
Closes #159
  • Loading branch information
marco-m-pix4d committed Dec 6, 2024
1 parent b47951b commit 6e33f8f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Optional `source.omit_target_url`. If set to true, will omit the GitHub Commit status API `target_url` (see README).
- pkg/sets: add Intersect() and Add() methods.

## [v0.12.1] - 2024-04-03
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ With reference to the [GitHub Commit status API], the `POST` parameters (`state`
GitHub hostname. This allows to post commit statuses to repositories hosted by GitHub Enterprise (GHE) instances. For example: github.mycompany.org will be expanded by cogito to https://github.mycompany.org/api/v3 \
Default: `github.com`

- `omit_target_url`:\
If set to true, will omit the GitHub Commit status API `target_url` (the URL to the build on Concourse).\n
Default: `false`.

- `log_url`. **DEPRECATED, no-op, will be removed**\
A Google Hangout Chat webhook. Useful to obtain logging for the `check` step for Concourse < v7.x

Expand Down
3 changes: 3 additions & 0 deletions cogito/ghcommitsink.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ func (sink GitHubCommitStatusSink) Send() error {
"state", ghState, "owner", sink.Request.Source.Owner,
"repo", sink.Request.Source.Repo, "git-ref", sink.GitRef,
"context", context, "buildURL", buildURL, "description", description)
if sink.Request.Source.OmitTargetURL {
buildURL = ""
}
if err := commitStatus.Add(sink.GitRef, ghState, buildURL, description); err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion cogito/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ type Source struct {
LogLevel string `json:"log_level"`
LogUrl string `json:"log_url"` // DEPRECATED
ContextPrefix string `json:"context_prefix"`
OmitTargetURL bool `json:"omit_target_url"`
ChatAppendSummary bool `json:"chat_append_summary"`
ChatNotifyOnStates []BuildState `json:"chat_notify_on_states"`
Sinks []string `json:"sinks"`
Expand All @@ -189,6 +190,7 @@ func (src Source) String() string {
fmt.Fprintf(&bld, "gchat_webhook: %s\n", redact(src.GChatWebHook))
fmt.Fprintf(&bld, "log_level: %s\n", src.LogLevel)
fmt.Fprintf(&bld, "context_prefix: %s\n", src.ContextPrefix)
fmt.Fprintf(&bld, "omit_target_url: %t\n", src.OmitTargetURL)
fmt.Fprintf(&bld, "chat_append_summary: %t\n", src.ChatAppendSummary)
fmt.Fprintf(&bld, "chat_notify_on_states: %s\n", src.ChatNotifyOnStates)
// Last one: no newline.
Expand Down Expand Up @@ -253,7 +255,6 @@ func (src *Source) Validate() error {
if src.GChatWebHook == "" {
mandatory = append(mandatory, "gchat_webhook")
}

}

if len(mandatory) > 0 {
Expand Down
2 changes: 2 additions & 0 deletions cogito/protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ access_token: ***REDACTED***
gchat_webhook: ***REDACTED***
log_level: debug
context_prefix: the-prefix
omit_target_url: false
chat_append_summary: true
chat_notify_on_states: [success failure]
sinks: []`
Expand All @@ -239,6 +240,7 @@ access_token:
gchat_webhook:
log_level:
context_prefix:
omit_target_url: false
chat_append_summary: false
chat_notify_on_states: []
sinks: []`
Expand Down

0 comments on commit 6e33f8f

Please sign in to comment.