Skip to content

Commit eedb0d5

Browse files
committed
deprecate packages sets, retry, github; release v0.14.0
The deprecation warnings will be picked up by the documentation shown on https://pkg.go.dev/github.com/Pix4D/cogito and by any IDE that is Go-aware. PCI-4471
1 parent bc71434 commit eedb0d5

File tree

9 files changed

+84
-1
lines changed

9 files changed

+84
-1
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [v0.14.0] - 2026-01-22
9+
10+
### Deprecated
11+
12+
- All APIs in packages `sets`, `retry`, `github` are DEPRECATED. Will be removed in the next release.
13+
This does not impact the users of the cogito Concourse resource.
14+
It impacts only code using these packages directly. Such code should switch to https://github.com/Pix4D/go-kit, which contains the same packages (drop-in replacement).
15+
816
## [v0.13.0] - 2025-05-05
917

1018
### Added

github/commitstatus.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
//
33
// See the README and CONTRIBUTING files for additional information, caveats about GitHub
44
// API and imposed limits, and reference to official documentation.
5+
//
6+
// Deprecated: Package github is replaced by github.com/Pix4D/go-kit/github.
57
package github
68

79
import (
@@ -22,12 +24,15 @@ import (
2224
)
2325

2426
// StatusError is one of the possible errors returned by the github package.
27+
//
28+
// Deprecated: Package github is replaced by github.com/Pix4D/go-kit/github.
2529
type StatusError struct {
2630
What string
2731
StatusCode int
2832
Details string
2933
}
3034

35+
// Deprecated: Package github is replaced by github.com/Pix4D/go-kit/github.
3136
func (e *StatusError) Error() string {
3237
return fmt.Sprintf("%s\n%s", e.What, e.Details)
3338
}
@@ -37,6 +42,7 @@ const GhDefaultHostname = "github.com"
3742

3843
var localhostRegexp = regexp.MustCompile(`^127.0.0.1:[0-9]+$`)
3944

45+
// Deprecated: Package github is replaced by github.com/Pix4D/go-kit/github.
4046
type Target struct {
4147
// Client is the http client
4248
Client *http.Client
@@ -51,6 +57,8 @@ type Target struct {
5157
// See also:
5258
// - NewCommitStatus
5359
// - https://docs.github.com/en/rest/commits/statuses
60+
//
61+
// Deprecated: Package github is replaced by github.com/Pix4D/go-kit/github.
5462
type CommitStatus struct {
5563
target *Target
5664
token string
@@ -72,6 +80,8 @@ type CommitStatus struct {
7280
//
7381
// See also:
7482
// - https://docs.github.com/en/rest/commits/statuses
83+
//
84+
// Deprecated: Package github is replaced by github.com/Pix4D/go-kit/github.
7585
func NewCommitStatus(
7686
target *Target,
7787
token, owner, repo, context string,
@@ -88,6 +98,8 @@ func NewCommitStatus(
8898
}
8999

90100
// AddRequest is the JSON object sent to the API.
101+
//
102+
// Deprecated: Package github is replaced by github.com/Pix4D/go-kit/github.
91103
type AddRequest struct {
92104
State string `json:"state"`
93105
TargetURL string `json:"target_url"`
@@ -108,6 +120,8 @@ type AddRequest struct {
108120
// The returned error contains some diagnostic information to help troubleshooting.
109121
//
110122
// See also: https://docs.github.com/en/rest/commits/statuses#create-a-commit-status
123+
//
124+
// Deprecated: Package github is replaced by github.com/Pix4D/go-kit/github.
111125
func (cs CommitStatus) Add(ctx context.Context, sha, state, targetURL, description string) error {
112126
// API: POST /repos/{owner}/{repo}/statuses/{sha}
113127
url := cs.target.Server + path.Join("/repos", cs.owner, cs.repo, "statuses", sha)
@@ -236,6 +250,8 @@ func (cs CommitStatus) explainError(err error, state, sha, url string) error {
236250
// if hostname looks like a httptest server, it returns http://127.0.0.1:PORT
237251
// otherwise, hostname is assumed to be of a Github Enterprise instance.
238252
// For example, github.mycompany.org returns https://github.mycompany.org/api/v3
253+
//
254+
// Deprecated: Package github is replaced by github.com/Pix4D/go-kit/github.
239255
func ApiRoot(h string) string {
240256
hostname := strings.ToLower(h)
241257
if hostname == GhDefaultHostname {

github/githubapp.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ import (
1313
"github.com/golang-jwt/jwt/v5"
1414
)
1515

16+
// Deprecated: Package github is replaced by github.com/Pix4D/go-kit/github.
1617
type GitHubApp struct {
1718
ClientId string `json:"client_id"`
1819
InstallationId int `json:"installation_id"`
1920
PrivateKey string `json:"private_key"` // SENSITIVE
2021
}
2122

23+
// Deprecated: Package github is replaced by github.com/Pix4D/go-kit/github.
2224
func (app *GitHubApp) IsZero() bool {
2325
return *app == GitHubApp{}
2426
}
@@ -54,6 +56,8 @@ func generateJWTtoken(clientId, privateKey string) (string, error) {
5456
}
5557

5658
// GenerateInstallationToken returns an installation token used to authenticate as GitHub App installation
59+
//
60+
// Deprecated: Package github is replaced by github.com/Pix4D/go-kit/github.
5761
func GenerateInstallationToken(ctx context.Context, client *http.Client, server string, app GitHubApp) (string, error) {
5862
// API: POST /app/installations/{installationId}/access_tokens
5963
installationId := strconv.Itoa(app.InstallationId)

github/githuberror.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"time"
88
)
99

10+
// Deprecated: Package github is replaced by github.com/Pix4D/go-kit/github.
1011
type GitHubError struct {
1112
StatusCode int
1213
OauthInfo string
@@ -16,6 +17,7 @@ type GitHubError struct {
1617
innerErr error
1718
}
1819

20+
// Deprecated: Package github is replaced by github.com/Pix4D/go-kit/github.
1921
func NewGitHubError(httpResp *http.Response, innerErr error) error {
2022
ghErr := GitHubError{
2123
innerErr: innerErr,
@@ -73,10 +75,12 @@ func NewGitHubError(httpResp *http.Response, innerErr error) error {
7375
return ghErr
7476
}
7577

78+
// Deprecated: Package github is replaced by github.com/Pix4D/go-kit/github.
7679
func (ghe GitHubError) Error() string {
7780
return ghe.innerErr.Error()
7881
}
7982

83+
// Deprecated: Package github is replaced by github.com/Pix4D/go-kit/github.
8084
func (ghe GitHubError) Unwrap() error {
8185
return ghe.innerErr
8286
}

github/retry.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
)
1212

1313
// Classifier implements [retry.ClassifierFunc] for GitHub.
14+
//
15+
// Deprecated: Package github is replaced by github.com/Pix4D/go-kit/github.
1416
func Classifier(err error) retry.Action {
1517
if err == nil {
1618
return retry.Success
@@ -31,6 +33,8 @@ func Classifier(err error) retry.Action {
3133
}
3234

3335
// Backoff implements [retry.BackoffFunc] for GitHub.
36+
//
37+
// Deprecated: Package github is replaced by github.com/Pix4D/go-kit/github.
3438
func Backoff(first bool, previous, limit time.Duration, err error) time.Duration {
3539
// Optimization: Are we rate limited?
3640
// This allows to immediately terminate the retry loop if it would take too
@@ -62,12 +66,16 @@ func Backoff(first bool, previous, limit time.Duration, err error) time.Duration
6266

6367
// RateLimited returns true if the http.Response in err reports being rate limited.
6468
// See https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#exceeding-the-rate-limit
69+
//
70+
// Deprecated: Package github is replaced by github.com/Pix4D/go-kit/github.
6571
func RateLimited(err GitHubError) bool {
6672
return err.StatusCode == http.StatusForbidden && err.RateLimitRemaining == 0
6773
}
6874

6975
// TransientError returns true if the http.Response in err has a status code
7076
// that can be retried.
77+
//
78+
// Deprecated: Package github is replaced by github.com/Pix4D/go-kit/github.
7179
func TransientError(statusCode int) bool {
7280
switch statusCode {
7381
case

github/url.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"strings"
88
)
99

10+
// Deprecated: Package github is replaced by github.com/Pix4D/go-kit/github.
1011
type GitURL struct {
1112
URL *url.URL
1213
Owner string
@@ -42,6 +43,8 @@ func safeUrlParse(rawURL string) (*url.URL, error) {
4243
// - https with u:p: https//username:password@github.com/Pix4D/cogito.git
4344
// - http: http://github.com/Pix4D/cogito.git
4445
// - http with u:p: http://username:password@github.com/Pix4D/cogito.git
46+
//
47+
// Deprecated: Package github is replaced by github.com/Pix4D/go-kit/github.
4548
func ParseGitPseudoURL(rawURL string) (GitURL, error) {
4649
workURL := rawURL
4750
// If ssh pseudo URL, we need to massage the rawURL ourselves :-(

retry/backoff.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import (
44
"time"
55
)
66

7+
// Deprecated: Package retry is replaced by github.com/Pix4D/go-kit/retry.
78
func ConstantBackoff(first bool, previous, limit time.Duration, err error) time.Duration {
89
return min(previous, limit)
910
}
1011

12+
// Deprecated: Package retry is replaced by github.com/Pix4D/go-kit/retry.
1113
func ExponentialBackoff(first bool, previous, limit time.Duration, err error) time.Duration {
1214
if first {
1315
return previous

retry/retry.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
//
33
// Took some inspiration from:
44
// - https://github.com/eapache/go-resiliency/tree/main/retrier
5+
//
6+
// Deprecated: Package retry is replaced by github.com/Pix4D/go-kit/retry.
57
package retry
68

79
import (
@@ -11,6 +13,8 @@ import (
1113
)
1214

1315
// Action is returned by a ClassifierFunc to indicate to Retry how to proceed.
16+
//
17+
// Deprecated: Package retry is replaced by github.com/Pix4D/go-kit/retry.
1418
type Action int
1519

1620
const (
@@ -26,6 +30,8 @@ const (
2630

2731
// Retry is the controller of the retry mechanism.
2832
// See the examples in file retry_example_test.go.
33+
//
34+
// Deprecated: Package retry is replaced by github.com/Pix4D/go-kit/retry.
2935
type Retry struct {
3036
UpTo time.Duration // Total maximum duration of the retries.
3137
FirstDelay time.Duration // Duration of the first backoff.
@@ -41,19 +47,27 @@ type Retry struct {
4147
// and return a custom delay; this can be used in special cases such as when
4248
// rate-limited with a fixed window; for an example see
4349
// [github.com/Pix4D/cogito/github.Backoff].
50+
//
51+
// Deprecated: Package retry is replaced by github.com/Pix4D/go-kit/retry.
4452
type BackoffFunc func(first bool, previous, limit time.Duration, err error) time.Duration
4553

4654
// ClassifierFunc decides whether to proceed or not; called by [Retry.Do].
4755
// Parameter err allows to inspect the error; for an example see
4856
// [github.com/Pix4D/cogito/github.Classifier]
57+
//
58+
// Deprecated: Package retry is replaced by github.com/Pix4D/go-kit/retry.
4959
type ClassifierFunc func(err error) Action
5060

5161
// WorkFunc does the unit of work that might fail and need to be retried; called
5262
// by [Retry.Do].
63+
//
64+
// Deprecated: Package retry is replaced by github.com/Pix4D/go-kit/retry.
5365
type WorkFunc func() error
5466

5567
// Do is the loop of [Retry].
5668
// See the examples in file retry_example_test.go.
69+
//
70+
// Deprecated: Package retry is replaced by github.com/Pix4D/go-kit/retry.
5771
func (rtr Retry) Do(
5872
backoffFn BackoffFunc,
5973
classifierFn ClassifierFunc,

sets/sets.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Package sets is a minimal implementation of a generic set data structure.
2-
2+
//
3+
// Deprecated: Package sets is replaced by github.com/Pix4D/go-kit/sets.
34
package sets
45

56
import (
@@ -10,17 +11,23 @@ import (
1011

1112
// Set is a minimal set that takes only ordered types: any type that supports the
1213
// operators < <= >= >.
14+
//
15+
// Deprecated: Package sets is replaced by github.com/Pix4D/go-kit/sets.
1316
type Set[T cmp.Ordered] struct {
1417
items map[T]struct{}
1518
}
1619

1720
// New returns an empty set with capacity size. The capacity will grow and shrink as a
1821
// stdlib map.
22+
//
23+
// Deprecated: Package sets is replaced by github.com/Pix4D/go-kit/sets.
1924
func New[T cmp.Ordered](size int) *Set[T] {
2025
return &Set[T]{items: make(map[T]struct{}, size)}
2126
}
2227

2328
// From returns a set from elements.
29+
//
30+
// Deprecated: Package sets is replaced by github.com/Pix4D/go-kit/sets.
2431
func From[T cmp.Ordered](elements ...T) *Set[T] {
2532
s := New[T](len(elements))
2633
for _, i := range elements {
@@ -32,17 +39,22 @@ func From[T cmp.Ordered](elements ...T) *Set[T] {
3239
// String returns a string representation of s, ordered. This allows to simply pass a
3340
// sets.Set as parameter to a function that expects a fmt.Stringer interface and obtain
3441
// a comparable string.
42+
//
43+
// Deprecated: Package sets is replaced by github.com/Pix4D/go-kit/sets.
3544
func (s *Set[T]) String() string {
3645
return fmt.Sprint(s.OrderedList())
3746
}
3847

48+
// Deprecated: Package sets is replaced by github.com/Pix4D/go-kit/sets.
3949
func (s *Set[T]) Size() int {
4050
return len(s.items)
4151
}
4252

4353
// OrderedList returns a slice of the elements of s, ordered.
4454
// TODO This can probably be replaced in Go 1.20 when a generics slice packages reaches
4555
// the stdlib.
56+
//
57+
// Deprecated: Package sets is replaced by github.com/Pix4D/go-kit/sets.
4658
func (s *Set[T]) OrderedList() []T {
4759
elements := make([]T, 0, len(s.items))
4860
for e := range s.items {
@@ -55,12 +67,16 @@ func (s *Set[T]) OrderedList() []T {
5567
}
5668

5769
// Contains returns true if s contains item.
70+
//
71+
// Deprecated: Package sets is replaced by github.com/Pix4D/go-kit/sets.
5872
func (s *Set[T]) Contains(item T) bool {
5973
_, found := s.items[item]
6074
return found
6175
}
6276

6377
// Add inserts item into s. Returns true if the item was present.
78+
//
79+
// Deprecated: Package sets is replaced by github.com/Pix4D/go-kit/sets.
6480
func (s *Set[T]) Add(item T) bool {
6581
if s.Contains(item) {
6682
return true
@@ -70,6 +86,8 @@ func (s *Set[T]) Add(item T) bool {
7086
}
7187

7288
// Remove deletes item from s. Returns true if the item was present.
89+
//
90+
// Deprecated: Package sets is replaced by github.com/Pix4D/go-kit/sets.
7391
func (s *Set[T]) Remove(item T) bool {
7492
if !s.Contains(item) {
7593
return false
@@ -79,6 +97,8 @@ func (s *Set[T]) Remove(item T) bool {
7997
}
8098

8199
// Difference returns a set containing the elements of s that are not in x.
100+
//
101+
// Deprecated: Package sets is replaced by github.com/Pix4D/go-kit/sets.
82102
func (s *Set[T]) Difference(x *Set[T]) *Set[T] {
83103
result := New[T](max(0, s.Size()-x.Size()))
84104
for item := range s.items {
@@ -90,6 +110,8 @@ func (s *Set[T]) Difference(x *Set[T]) *Set[T] {
90110
}
91111

92112
// Intersection returns a set containing the elements that are both in s and x.
113+
//
114+
// Deprecated: Package sets is replaced by github.com/Pix4D/go-kit/sets.
93115
func (s *Set[T]) Intersection(x *Set[T]) *Set[T] {
94116
result := New[T](0)
95117
// loop over the smaller set (thanks to https://github.com/deckarep/golang-set)
@@ -107,6 +129,8 @@ func (s *Set[T]) Intersection(x *Set[T]) *Set[T] {
107129
}
108130

109131
// Union returns a set containing all the elements of s and x.
132+
//
133+
// Deprecated: Package sets is replaced by github.com/Pix4D/go-kit/sets.
110134
func (s *Set[T]) Union(x *Set[T]) *Set[T] {
111135
result := New[T](max(s.Size(), x.Size()))
112136
for item := range s.items {

0 commit comments

Comments
 (0)