Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: circleci/ex
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0.13884-435ea0d
Choose a base ref
...
head repository: circleci/ex
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.0.14333-a6de3e3
Choose a head ref

Commits on Feb 6, 2025

  1. Update module google.golang.org/protobuf to v1.36.5

    renovate[bot] authored Feb 6, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    Copy the full SHA
    9cbb776 View commit details

Commits on Feb 10, 2025

  1. Update module golang.org/x/net to v0.35.0

    renovate[bot] authored Feb 10, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    5a15f33 View commit details
  2. Merge pull request #1093 from circleci/renovate/google.golang.org-pro…

    …tobuf-1.x
    
    Update module google.golang.org/protobuf to v1.36.5
    brentmmarks authored Feb 10, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    b979298 View commit details

Commits on Feb 11, 2025

  1. Remove internal.span.format from expected span fields

    Bryan Johnson committed Feb 11, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    58c14c4 View commit details
  2. Merge pull request #1096 from circleci/renovate/golang.org-x-net-0.x

    Update module golang.org/x/net to v0.35.0
    Bryan Johnson authored Feb 11, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    cd1b902 View commit details
  3. Update module gotest.tools/v3 to v3.5.2

    renovate[bot] authored Feb 11, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    34deeeb View commit details
  4. Update aws-sdk-go-v2 monorepo

    renovate[bot] authored Feb 11, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    006e63d View commit details
  5. Update module github.com/hashicorp/vault/api to v1.16.0

    renovate[bot] authored Feb 11, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    d1b359c View commit details
  6. Merge pull request #1094 from circleci/renovate/gotest.tools-v3-3.x

    Update module gotest.tools/v3 to v3.5.2
    Bryan Johnson authored Feb 11, 2025
    Copy the full SHA
    bbec8df View commit details
  7. Merge pull request #1092 from circleci/renovate/aws-sdk-go-v2-monorepo

    Update aws-sdk-go-v2 monorepo
    Bryan Johnson authored Feb 11, 2025
    Copy the full SHA
    ffb145e View commit details

Commits on Feb 12, 2025

  1. Copy the full SHA
    595adf9 View commit details
  2. Merge pull request #1100 from circleci/renovate/github.com-golangci-g…

    …olangci-lint-1.x
    
    Update module github.com/golangci/golangci-lint to v1.64.2
    brentmmarks authored Feb 12, 2025
    Copy the full SHA
    a603afc View commit details
  3. Copy the full SHA
    e2ef34a View commit details
  4. Merge pull request #1101 from circleci/renovate/github.com-golangci-g…

    …olangci-lint-1.x
    
    Update module github.com/golangci/golangci-lint to v1.64.3
    brentmmarks authored Feb 12, 2025
    Copy the full SHA
    e496b9b View commit details

Commits on Feb 13, 2025

  1. Copy the full SHA
    7ab8829 View commit details
  2. Merge pull request #1102 from circleci/renovate/github.com-golangci-g…

    …olangci-lint-1.x
    
    Update module github.com/golangci/golangci-lint to v1.64.4
    brentmmarks authored Feb 13, 2025
    Copy the full SHA
    0cdb57d View commit details
  3. Merge pull request #1097 from circleci/renovate/github.com-hashicorp-…

    …vault-api-1.x
    
    Update module github.com/hashicorp/vault/api to v1.16.0
    brentmmarks authored Feb 13, 2025
    Copy the full SHA
    4af1c21 View commit details
  4. Copy the full SHA
    9412e1a View commit details
  5. Copy the full SHA
    8d2dda3 View commit details
  6. Merge pull request #1095 from circleci/renovate/github.com-alecthomas…

    …-kong-1.x
    
    Update module github.com/alecthomas/kong to v1.8.1
    Bryan Johnson authored Feb 13, 2025
    Copy the full SHA
    3026131 View commit details
  7. use once to guard closing the chanel

    The mutex was only guarding one method, so a sync once i think is
    the better option.
    danmux committed Feb 13, 2025
    Copy the full SHA
    5d8cff4 View commit details
  8. Merge pull request #1103 from circleci/dm/remove-httpmetric-race

    use once to guard closing the channel
    danmux authored Feb 13, 2025
    Copy the full SHA
    da8257b View commit details
  9. Merge pull request #1098 from circleci/renovate/github.com-hashicorp-…

    …vault-api-auth-kubernetes-0.x
    
    Update module github.com/hashicorp/vault/api/auth/kubernetes to v0.9.0
    brentmmarks authored Feb 13, 2025
    Copy the full SHA
    dc6ae63 View commit details
  10. Copy the full SHA
    e3a4c67 View commit details
  11. Merge pull request #1104 from circleci/renovate/github.com-golangci-g…

    …olangci-lint-1.x
    
    Update module github.com/golangci/golangci-lint to v1.64.5
    brentmmarks authored Feb 13, 2025
    Copy the full SHA
    f6c4619 View commit details

Commits on Feb 14, 2025

  1. Copy the full SHA
    c57f0d1 View commit details
  2. Merge pull request #1105 from circleci/renovate/aws-sdk-go-v2-monorepo

    Update aws-sdk-go-v2 monorepo
    brentmmarks authored Feb 14, 2025
    Copy the full SHA
    17d5ab3 View commit details

Commits on Feb 18, 2025

  1. Copy the full SHA
    855bf21 View commit details

Commits on Feb 19, 2025

  1. Copy the full SHA
    f1bf5c5 View commit details
  2. Merge pull request #1107 from circleci/renovate/github.com-klauspost-…

    …compress-1.x
    
    Update module github.com/klauspost/compress to v1.18.0
    brentmmarks authored Feb 19, 2025
    Copy the full SHA
    30ca6e1 View commit details
  3. Merge pull request #1106 from circleci/renovate/aws-sdk-go-v2-monorepo

    Update aws-sdk-go-v2 monorepo
    brentmmarks authored Feb 19, 2025
    Copy the full SHA
    deb9714 View commit details

Commits on Feb 20, 2025

  1. Copy the full SHA
    cdadafd View commit details

Commits on Feb 21, 2025

  1. Copy the full SHA
    a4c07ef View commit details
  2. Merge pull request #1108 from circleci/renovate/go.mongodb.org-mongo-…

    …driver-v2-2.x
    
    Update module go.mongodb.org/mongo-driver/v2 to v2.0.1
    brentmmarks authored Feb 21, 2025
    Copy the full SHA
    33c5291 View commit details
  3. Copy the full SHA
    8920c41 View commit details
  4. Copy the full SHA
    40e9dcf View commit details
  5. Merge pull request #1111 from circleci/renovate/go-1.x

    Update dependency go to v1.24.0
    brentmmarks authored Feb 21, 2025
    Copy the full SHA
    ebc7ea5 View commit details
  6. Merge pull request #1109 from circleci/clean-up-httpclient

    Remove GET with Body support now RT-724 is complete
    SemanticallyNull authored Feb 21, 2025
    Copy the full SHA
    aaca78d View commit details
  7. Merge pull request #1110 from circleci/renovate/github.com-redis-go-r…

    …edis-v9-9.x
    
    Update module github.com/redis/go-redis/v9 to v9.7.1
    brentmmarks authored Feb 21, 2025
    Copy the full SHA
    34ecd1d View commit details

Commits on Feb 22, 2025

  1. Copy the full SHA
    6292cd1 View commit details

Commits on Feb 23, 2025

  1. Copy the full SHA
    7b1dc1a View commit details

Commits on Feb 24, 2025

  1. Merge pull request #1112 from circleci/renovate/github.com-google-go-…

    …cmp-0.x
    
    Update module github.com/google/go-cmp to v0.7.0
    brentmmarks authored Feb 24, 2025
    Copy the full SHA
    7dc82f9 View commit details
  2. Merge pull request #1113 from circleci/renovate/github.com-kimmachine…

    …gun-automemlimit-0.x
    
    Update module github.com/KimMachineGun/automemlimit to v0.7.1
    brentmmarks authored Feb 24, 2025
    Copy the full SHA
    6cbe68c View commit details
  3. Add timestamp to httpmetric

    danmux committed Feb 24, 2025
    Copy the full SHA
    ad19cfc View commit details
  4. Merge pull request #1114 from circleci/dm/timestamp-httpmetrics

    Add timestamp to httpmetric
    danmux authored Feb 24, 2025
    Copy the full SHA
    f74e0e6 View commit details

Commits on Feb 27, 2025

  1. Copy the full SHA
    f087325 View commit details
  2. Merge pull request #1117 from circleci/update-rootcerts

    [NOTICKET] Update rootcerts package via ./do check-rootcerts
    Bryan Johnson authored Feb 27, 2025
    Copy the full SHA
    f8b1c62 View commit details
  3. Bump github.com/go-jose/go-jose/v4 from 4.0.1 to 4.0.5

    Bumps [github.com/go-jose/go-jose/v4](https://github.com/go-jose/go-jose) from 4.0.1 to 4.0.5.
    - [Release notes](https://github.com/go-jose/go-jose/releases)
    - [Changelog](https://github.com/go-jose/go-jose/blob/main/CHANGELOG.md)
    - [Commits](go-jose/go-jose@v4.0.1...v4.0.5)
    
    ---
    updated-dependencies:
    - dependency-name: github.com/go-jose/go-jose/v4
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Feb 27, 2025
    Copy the full SHA
    41b3428 View commit details
  4. Copy the full SHA
    d53095e View commit details
  5. Copy the full SHA
    168fc79 View commit details
Showing with 552 additions and 504 deletions.
  1. +1 −1 .circleci/config.yml
  2. +1 −1 docker-compose.yml
  3. +34 −34 go.mod
  4. +66 −66 go.sum
  5. +1 −15 httpclient/httpclient.go
  6. +0 −1 httpclient/httpclient_test.go
  7. +15 −18 o11y/httpmetrics/provider.go
  8. +36 −2 o11y/httpmetrics/provider_test.go
  9. +13 −25 releases/release/handler.go
  10. +0 −79 releases/release/handler_test.go
  11. +273 −140 rootcerts/rootcerts.go
  12. +36 −39 tools/go.mod
  13. +76 −83 tools/go.sum
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ jobs:
'/datanv',
'--address', ':9124',
]
- image: hashicorp/vault:1.18.4
- image: hashicorp/vault:1.18.5
environment:
SKIP_SETCAP: skip
VAULT_DEV_ROOT_TOKEN_ID: dummyroot
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -77,7 +77,7 @@ services:
- '127.0.0.1:9001:9001'

vault:
image: hashicorp/vault:1.18.4
image: hashicorp/vault:1.18.5
environment:
VAULT_DEV_ROOT_TOKEN_ID: dummyroot
ports:
68 changes: 34 additions & 34 deletions go.mod
Original file line number Diff line number Diff line change
@@ -2,37 +2,37 @@ module github.com/circleci/ex

go 1.22.7

toolchain go1.23.6
toolchain go1.24.0

require (
github.com/DataDog/datadog-go v4.8.3+incompatible
github.com/KimMachineGun/automemlimit v0.7.0
github.com/alecthomas/kong v1.7.0
github.com/aws/aws-sdk-go-v2 v1.36.0
github.com/aws/aws-sdk-go-v2/config v1.29.5
github.com/aws/aws-sdk-go-v2/credentials v1.17.58
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.58
github.com/aws/aws-sdk-go-v2/service/s3 v1.75.3
github.com/KimMachineGun/automemlimit v0.7.1
github.com/alecthomas/kong v1.8.1
github.com/aws/aws-sdk-go-v2 v1.36.2
github.com/aws/aws-sdk-go-v2/config v1.29.7
github.com/aws/aws-sdk-go-v2/credentials v1.17.60
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.63
github.com/aws/aws-sdk-go-v2/service/s3 v1.77.1
github.com/cenkalti/backoff/v4 v4.3.0
github.com/gin-gonic/gin v1.10.0
github.com/google/go-cmp v0.6.0
github.com/google/go-cmp v0.7.0
github.com/google/uuid v1.6.0
github.com/hashicorp/vault/api v1.15.0
github.com/hashicorp/vault/api/auth/kubernetes v0.8.0
github.com/hashicorp/vault/api v1.16.0
github.com/hashicorp/vault/api/auth/kubernetes v0.9.0
github.com/hellofresh/health-go/v5 v5.5.3
github.com/honeycombio/beeline-go v1.18.0
github.com/honeycombio/dynsampler-go v0.6.0
github.com/honeycombio/libhoney-go v1.25.0
github.com/jackc/pgx/v5 v5.7.2
github.com/jmoiron/sqlx v1.4.0
github.com/jolestar/go-commons-pool/v2 v2.1.2
github.com/klauspost/compress v1.17.11
github.com/klauspost/compress v1.18.0
github.com/makasim/amqpextra v1.2.1
github.com/rabbitmq/amqp091-go v1.10.0
github.com/redis/go-redis/v9 v9.7.0
github.com/redis/go-redis/v9 v9.7.1
github.com/rollbar/rollbar-go v1.4.5
github.com/vmihailenco/go-tinylfu v0.2.2
go.mongodb.org/mongo-driver/v2 v2.0.0
go.mongodb.org/mongo-driver/v2 v2.1.0
go.opentelemetry.io/otel v1.34.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.34.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.34.0
@@ -41,28 +41,28 @@ require (
go.opentelemetry.io/otel/trace v1.34.0
go.opentelemetry.io/proto/otlp v1.5.0
go.uber.org/automaxprocs v1.6.0
golang.org/x/net v0.34.0
golang.org/x/net v0.35.0
golang.org/x/sync v0.11.0
google.golang.org/grpc v1.70.0
google.golang.org/protobuf v1.36.4
gotest.tools/v3 v3.5.1
google.golang.org/protobuf v1.36.5
gotest.tools/v3 v3.5.2
)

require (
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.8 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.27 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.31 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.31 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.2 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.31 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.2 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.5.5 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.12 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.12 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.24.14 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.13 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.33.13 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.10 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.29 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.33 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.33 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.33 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.6.1 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.14 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.14 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.24.16 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.15 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.33.15 // indirect
github.com/aws/smithy-go v1.22.2 // indirect
github.com/bytedance/sonic v1.11.6 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
@@ -76,7 +76,7 @@ require (
github.com/facebookgo/muster v0.0.0-20150708232844-fd3d7953fd52 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-jose/go-jose/v4 v4.0.1 // indirect
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-playground/locales v0.14.1 // indirect
@@ -120,10 +120,10 @@ require (
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/otel/metric v1.34.0 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/crypto v0.33.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/text v0.22.0 // indirect
golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f // indirect
132 changes: 66 additions & 66 deletions go.sum

Large diffs are not rendered by default.

16 changes: 1 addition & 15 deletions httpclient/httpclient.go
Original file line number Diff line number Diff line change
@@ -174,11 +174,6 @@ type Request struct {
query url.Values
rawquery string

// We want to prevent HTTP GETs with body or rawBody due to incompatibilities with CloudFront WAF which API Infra
// are introducing. In order to facilitate a migration for runner we need to be able to override this. This can be
// removed once RT-724 is completed.
allowGETWithBody bool

propagation bool
flatten string

@@ -218,14 +213,6 @@ func RouteParams(routeParams ...interface{}) func(*Request) {
}
}

// AllowGETWithBody will allow the client to send a GET request with a body, which we error on by default. We should
// remove this once RT-724 is completed.
func AllowGETWithBody() func(*Request) {
return func(r *Request) {
r.allowGETWithBody = true
}
}

// Decoder adds a response body decoder to some http status code
// Note this will modify the original Request.
//
@@ -793,7 +780,6 @@ func doneRetrying(err error) error {
func (r Request) validate() error {
// We do not allow GET requests with Body as they are not supported by CloudFront WAF, which requests are routed
// through. - https://circleci.slack.com/archives/C03M4P0Q4GH/p1659566842825159
// This can be overridden with httpclient.AllowGETWithBody() if required for legacy or third-party compatibility
if !r.validateGetWithBody() {
return errors.New("cannot have GET request with body or raw body")
}
@@ -814,7 +800,7 @@ func (r Request) validateOnlyRawBodyOrBody() bool {
}

func (r Request) validateGetWithBody() bool {
if !r.allowGETWithBody && (r.method == "GET" && r.hasBody()) {
if r.method == "GET" && r.hasBody() {
return false
}

1 change: 0 additions & 1 deletion httpclient/httpclient_test.go
Original file line number Diff line number Diff line change
@@ -297,7 +297,6 @@ func TestClient_Call_Propagates(t *testing.T) {
"hc_tcl.http.host": true,
"hc_tcl.http.method": true,
"span.kind": true,
"internal.span.format": true,

// N.B. these are added by the jaegertracing/all-in-one:latest image. If you see different results than CI,
// it's best to do a docker-compose pull to ensure you're using the latest image.
33 changes: 15 additions & 18 deletions o11y/httpmetrics/provider.go
Original file line number Diff line number Diff line change
@@ -33,15 +33,17 @@ type Provider struct {
publishInterval time.Duration
mu sync.RWMutex
data []metricData
stop chan bool
stopMu sync.Mutex

stop chan bool
stopOnce sync.Once // only close the chanel once
}

type metricData struct {
Type string `json:"type"`
Name string `json:"name"`
Value float64 `json:"value"`
Tags []string `json:"tags"`
Type string `json:"type"`
Name string `json:"name"`
Timestamp int64 `json:"timestamp"`
Value float64 `json:"value"`
Tags []string `json:"tags"`
}

type Tags map[string]string
@@ -105,18 +107,12 @@ func (m *Provider) Count(n string, v int64, t []string, rate float64) error {
}

func (m *Provider) Close() error {
m.stopMu.Lock()
defer m.stopMu.Unlock()

if m.stop != nil {
m.stopOnce.Do(func() {
close(m.stop)
m.stop = nil

ctx, done := context.WithTimeout(context.Background(), sendTimeout)
defer done()
m.Publish(ctx)
}

})
return nil
}

@@ -129,10 +125,11 @@ func (m *Provider) record(metricType, metricName string, metricValue float64, me
name = fmt.Sprintf("%s.%s", m.namespace, name)
}
m.data = append(m.data, metricData{
Type: metricType,
Name: name,
Value: metricValue,
Tags: metricTags,
Type: metricType,
Name: name,
Timestamp: time.Now().Unix(),
Value: metricValue,
Tags: metricTags,
})
}

38 changes: 36 additions & 2 deletions o11y/httpmetrics/provider_test.go
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import (
"testing"
"time"

gcmp "github.com/google/go-cmp/cmp"
"golang.org/x/sync/errgroup"
"gotest.tools/v3/assert"
"gotest.tools/v3/assert/cmp"
@@ -132,7 +133,11 @@ func TestProvider_Record(t *testing.T) {
m.record(aMet.Type, aMet.Name, aMet.Value, aMet.Tags)
}

assert.Check(t, cmp.DeepEqual(m.data, tt.expectedMetricsData))
for i := range tt.expectedMetricsData {
tt.expectedMetricsData[i].Timestamp = time.Now().Unix()
}

assert.Check(t, cmp.DeepEqual(m.data, tt.expectedMetricsData, equateApproxUnixTime(1)))
})
}
}
@@ -255,7 +260,11 @@ func TestProvider_Publish(t *testing.T) {
err := eg.Wait()
assert.NilError(t, err)

assert.Check(t, cmp.DeepEqual(m.data, tt.expectedMetricsData))
for i := range tt.expectedMetricsData {
tt.expectedMetricsData[i].Timestamp = time.Now().Unix()
}

assert.Check(t, cmp.DeepEqual(m.data, tt.expectedMetricsData, equateApproxUnixTime(1)))
})
}
}
@@ -353,3 +362,28 @@ func TestProvider_New(t *testing.T) {
})
}
}

func equateApproxUnixTime(marginSec int64) gcmp.Option {
if marginSec < 0 {
panic("margin must be a non-negative number")
}
a := timeApproximator{marginSec}
return gcmp.FilterValues(areNonZeroTimes, gcmp.Comparer(a.compare))
}

func areNonZeroTimes(x, y int64) bool {
return x > 0 && y > 0
}

type timeApproximator struct {
marginSec int64
}

func (a timeApproximator) compare(x, y int64) bool {
if x > y {
// Ensure x is always before y
x, y = y, x
}
// We're within the margin if x+margin >= y.
return x+a.marginSec >= y
}
38 changes: 13 additions & 25 deletions releases/release/handler.go
Original file line number Diff line number Diff line change
@@ -30,7 +30,19 @@ func Handler(cfg HandlerConfig) func(c *gin.Context) {
ctx := c.Request.Context()
var req Requirements

bindAndValidate(c, &req)
if err := c.BindQuery(&req); err != nil {
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{
"message": fmt.Sprintf("bad request: %s", err),
})
return
}

if err := req.Validate(); err != nil {
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{
"message": fmt.Sprintf("bad request: %s", err),
})
return
}

// if list is nil, client should never proceed to download
if cfg.List == nil {
@@ -70,27 +82,3 @@ func Handler(cfg HandlerConfig) func(c *gin.Context) {
}
}
}

func bindAndValidate(c *gin.Context, req *Requirements) {
// To support a migration path from JSON body to query params we check the content length header. This can be
// removed when RT-724 is done
var err error
if c.Request.ContentLength != 0 {
err = c.BindJSON(&req)
} else {
err = c.BindQuery(&req)
}
if err != nil {
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{
"message": fmt.Sprintf("bad request: %s", err),
})
return
}

if err = req.Validate(); err != nil {
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{
"message": fmt.Sprintf("bad request: %s", err),
})
return
}
}
79 changes: 0 additions & 79 deletions releases/release/handler_test.go
Original file line number Diff line number Diff line change
@@ -19,81 +19,6 @@ import (
"github.com/circleci/ex/testing/testcontext"
)

func TestHandler_WithBody(t *testing.T) {
ctx := testcontext.Background()

t.Run("Test success", func(t *testing.T) {
fix := startAPI(ctx, t)

t.Run("Can get a release", func(t *testing.T) {
agent, err := fix.DownloadWithBody(ctx, release.Requirements{
Platform: "linux",
Arch: "amd64",
})

assert.Assert(t, err)
assert.Check(t, cmp.DeepEqual(agent, &release.Release{
URL: fix.S3URL + "/1.1.1-abcdef01/linux/amd64/circleci-agent",
Checksum: "4a62f09b64873a20386cdbfaca87cc10d8352fab014ef0018f1abcce08a3d027",
Version: "1.1.1-abcdef01",
}))
})
})

t.Run("Test for unknown arch", func(t *testing.T) {
fix := startAPI(ctx, t)

t.Run("Release not found", func(t *testing.T) {
_, err := fix.DownloadWithBody(ctx, release.Requirements{
Platform: "linux",
Arch: "enemy",
})
assert.Check(t, httpclient.HasStatusCode(err, http.StatusNotFound))
assert.Check(t, cmp.ErrorContains(err,
`404 (Not Found) (1 attempts): no download found for version="1.1.1-abcdef01" os="linux" arch="enemy"`,
))
})
})

t.Run("Test invalid requests", func(t *testing.T) {
fix := startAPI(ctx, t)

t.Run("No platform", func(t *testing.T) {
_, err := fix.DownloadWithBody(ctx, release.Requirements{
Arch: "enemy",
})
assert.Check(t, httpclient.HasStatusCode(err, http.StatusBadRequest))
assert.Check(t, cmp.ErrorContains(err,
`400 (Bad Request) (1 attempts): bad request: platform is required`,
))
})
t.Run("No arch", func(t *testing.T) {
_, err := fix.DownloadWithBody(ctx, release.Requirements{
Platform: "linux",
})
assert.Check(t, httpclient.HasStatusCode(err, http.StatusBadRequest))
assert.Check(t, cmp.ErrorContains(err,
`400 (Bad Request) (1 attempts): bad request: arch is required`,
))
})
})

t.Run("Test no downloads", func(t *testing.T) {
fix := startAPIWithDownloads(ctx, t, false)

t.Run("Should give 410", func(t *testing.T) {
_, err := fix.DownloadWithBody(ctx, release.Requirements{
Platform: "linux",
Arch: "amd64",
})
assert.Check(t, httpclient.HasStatusCode(err, http.StatusGone))
assert.Check(t, cmp.ErrorContains(err,
`410 (Gone) (1 attempts): no more downloads possible`,
))
})
})
}

func TestHandler_WithQuery(t *testing.T) {
ctx := testcontext.Background()

@@ -169,10 +94,6 @@ func TestHandler_WithQuery(t *testing.T) {
})
}

func (f *fixture) DownloadWithBody(ctx context.Context, requirements release.Requirements) (*release.Release, error) {
return f.download(ctx, httpclient.Body(requirements), httpclient.AllowGETWithBody())
}

func (f *fixture) DownloadWithQuery(ctx context.Context, requirements release.Requirements) (*release.Release, error) {
return f.download(ctx, httpclient.QueryParams(map[string]string{
"arch": requirements.Arch,
413 changes: 273 additions & 140 deletions rootcerts/rootcerts.go

Large diffs are not rendered by default.

75 changes: 36 additions & 39 deletions tools/go.mod
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
module tools

go 1.22.1
go 1.23.0

toolchain go1.23.6
toolchain go1.24.0

require (
github.com/golangci/golangci-lint v1.63.4
github.com/golangci/golangci-lint v1.64.5
github.com/gwatts/rootcerts v0.0.0-20250101202213-6b948e2b3fef
github.com/rinchsan/gosimports v0.3.8
gotest.tools/gotestsum v1.12.0
)

require (
4d63.com/gocheckcompilerdirectives v1.2.1 // indirect
4d63.com/gochecknoglobals v0.2.1 // indirect
4d63.com/gochecknoglobals v0.2.2 // indirect
github.com/4meepo/tagalign v1.4.1 // indirect
github.com/Abirdcfly/dupword v0.1.3 // indirect
github.com/Antonboom/errname v1.0.0 // indirect
github.com/Antonboom/nilnil v1.0.1 // indirect
github.com/Antonboom/testifylint v1.5.2 // indirect
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c // indirect
github.com/Crocmagnon/fatcontext v0.5.3 // indirect
github.com/Crocmagnon/fatcontext v0.7.1 // indirect
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect
github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.0 // indirect
github.com/Masterminds/semver/v3 v3.3.0 // indirect
@@ -29,7 +29,7 @@ require (
github.com/alexkohler/nakedret/v2 v2.0.5 // indirect
github.com/alexkohler/prealloc v1.0.0 // indirect
github.com/alingse/asasalint v0.0.11 // indirect
github.com/alingse/nilnesserr v0.1.1 // indirect
github.com/alingse/nilnesserr v0.1.2 // indirect
github.com/ashanbrown/forbidigo v1.6.0 // indirect
github.com/ashanbrown/makezero v1.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
@@ -41,9 +41,9 @@ require (
github.com/breml/errchkjson v0.4.0 // indirect
github.com/butuzov/ireturn v0.3.1 // indirect
github.com/butuzov/mirror v1.3.0 // indirect
github.com/catenacyber/perfsprint v0.7.1 // indirect
github.com/catenacyber/perfsprint v0.8.1 // indirect
github.com/ccojocar/zxcvbn-go v1.0.2 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/charithe/durationcheck v0.0.10 // indirect
github.com/chavacava/garif v0.1.0 // indirect
github.com/ckaznocha/intrange v0.3.0 // indirect
@@ -58,8 +58,8 @@ require (
github.com/firefart/nonamedreturns v1.0.5 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fzipp/gocyclo v0.6.0 // indirect
github.com/ghostiam/protogetter v0.3.8 // indirect
github.com/go-critic/go-critic v0.11.5 // indirect
github.com/ghostiam/protogetter v0.3.9 // indirect
github.com/go-critic/go-critic v0.12.0 // indirect
github.com/go-toolsmith/astcast v1.1.0 // indirect
github.com/go-toolsmith/astcopy v1.1.0 // indirect
github.com/go-toolsmith/astequal v1.2.0 // indirect
@@ -74,17 +74,17 @@ require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect
github.com/golangci/go-printf-func-name v0.1.0 // indirect
github.com/golangci/gofmt v0.0.0-20241223200906-057b0627d9b9 // indirect
github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d // indirect
github.com/golangci/misspell v0.6.0 // indirect
github.com/golangci/plugin-module-register v0.1.1 // indirect
github.com/golangci/revgrep v0.5.3 // indirect
github.com/golangci/revgrep v0.8.0 // indirect
github.com/golangci/unconvert v0.0.0-20240309020433-c5143eacb3ed // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/gordonklaus/ineffassign v0.1.0 // indirect
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
github.com/gostaticanalysis/comment v1.4.2 // indirect
github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect
github.com/gostaticanalysis/forcetypeassert v0.2.0 // indirect
github.com/gostaticanalysis/nilerr v0.1.1 // indirect
github.com/hashicorp/go-immutable-radix/v2 v2.1.0 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
@@ -96,41 +96,40 @@ require (
github.com/jingyugao/rowserrcheck v1.1.1 // indirect
github.com/jjti/go-spancheck v0.6.4 // indirect
github.com/julz/importas v0.2.0 // indirect
github.com/karamaru-alpha/copyloopvar v1.1.0 // indirect
github.com/karamaru-alpha/copyloopvar v1.2.1 // indirect
github.com/kisielk/errcheck v1.8.0 // indirect
github.com/kkHAIKE/contextcheck v1.1.5 // indirect
github.com/kulti/thelper v0.6.3 // indirect
github.com/kunwardeep/paralleltest v1.0.10 // indirect
github.com/kyoh86/exportloopref v0.1.11 // indirect
github.com/lasiar/canonicalheader v1.1.2 // indirect
github.com/ldez/exptostd v0.3.1 // indirect
github.com/ldez/gomoddirectives v0.6.0 // indirect
github.com/ldez/grignotin v0.7.0 // indirect
github.com/ldez/exptostd v0.4.1 // indirect
github.com/ldez/gomoddirectives v0.6.1 // indirect
github.com/ldez/grignotin v0.9.0 // indirect
github.com/ldez/tagliatelle v0.7.1 // indirect
github.com/ldez/usetesting v0.4.2 // indirect
github.com/leonklingele/grouper v1.1.2 // indirect
github.com/macabu/inamedparam v0.1.3 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/maratori/testableexamples v1.0.0 // indirect
github.com/maratori/testpackage v1.1.1 // indirect
github.com/matoous/godox v0.0.0-20230222163458-006bad1f9d26 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/matoous/godox v1.1.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mgechev/revive v1.5.1 // indirect
github.com/mgechev/revive v1.6.1 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moricho/tparallel v0.3.2 // indirect
github.com/nakabonne/nestif v0.3.1 // indirect
github.com/nishanths/exhaustive v0.12.0 // indirect
github.com/nishanths/predeclared v0.2.2 // indirect
github.com/nunnatsa/ginkgolinter v0.18.4 // indirect
github.com/nunnatsa/ginkgolinter v0.19.0 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/polyfloyd/go-errorlint v1.7.0 // indirect
github.com/polyfloyd/go-errorlint v1.7.1 // indirect
github.com/prometheus/client_golang v1.12.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
@@ -149,25 +148,24 @@ require (
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 // indirect
github.com/sashamelentyev/interfacebloat v1.1.0 // indirect
github.com/sashamelentyev/usestdlibvars v1.28.0 // indirect
github.com/securego/gosec/v2 v2.21.4 // indirect
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c // indirect
github.com/securego/gosec/v2 v2.22.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sivchari/containedctx v1.0.3 // indirect
github.com/sivchari/tenv v1.12.1 // indirect
github.com/sonatard/noctx v0.1.0 // indirect
github.com/sourcegraph/go-diff v0.7.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/afero v1.12.0 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/spf13/viper v1.12.0 // indirect
github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect
github.com/stbenjam/no-sprintf-host-port v0.2.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/stretchr/testify v1.10.0 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
github.com/tdakkota/asciicheck v0.3.0 // indirect
github.com/tdakkota/asciicheck v0.4.0 // indirect
github.com/tetafro/godot v1.4.20 // indirect
github.com/timakin/bodyclose v0.0.0-20241017074812-ed6a65f985e3 // indirect
github.com/timonwong/loggercheck v0.10.1 // indirect
@@ -176,31 +174,30 @@ require (
github.com/ultraware/funlen v0.2.0 // indirect
github.com/ultraware/whitespace v0.2.0 // indirect
github.com/uudashr/gocognit v1.2.0 // indirect
github.com/uudashr/iface v1.3.0 // indirect
github.com/uudashr/iface v1.3.1 // indirect
github.com/xen0n/gosmopolitan v1.2.2 // indirect
github.com/yagipy/maintidx v1.0.0 // indirect
github.com/yeya24/promlinter v0.3.0 // indirect
github.com/ykadowak/zerologlint v0.1.5 // indirect
gitlab.com/bosi/decorder v0.4.2 // indirect
go-simpler.org/musttag v0.13.0 // indirect
go-simpler.org/sloglint v0.7.2 // indirect
go-simpler.org/sloglint v0.9.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/automaxprocs v1.6.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
golang.org/x/exp/typeparams v0.0.0-20241108190413-2d47ceb2692f // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/exp/typeparams v0.0.0-20250210185358-939b2ce775ac // indirect
golang.org/x/mod v0.23.0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/tools v0.28.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
golang.org/x/text v0.22.0 // indirect
golang.org/x/tools v0.30.0 // indirect
google.golang.org/protobuf v1.36.4 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
honnef.co/go/tools v0.5.1 // indirect
honnef.co/go/tools v0.6.0 // indirect
mvdan.cc/gofumpt v0.7.0 // indirect
mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f // indirect
)
159 changes: 76 additions & 83 deletions tools/go.sum

Large diffs are not rendered by default.