Skip to content

Commit f3faa8e

Browse files
chore(deps): update cuelabs.dev/go/oci/ociregistry digest to 074d060
Signed-off-by: red-hat-konflux-kflux-prd-rh02 <190377777+red-hat-konflux-kflux-prd-rh02[bot]@users.noreply.github.com>
1 parent 4523135 commit f3faa8e

File tree

9 files changed

+179
-118
lines changed

9 files changed

+179
-118
lines changed

upstream/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ require (
5656
cloud.google.com/go/compute/metadata v0.6.0 // indirect
5757
contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d // indirect
5858
contrib.go.opencensus.io/exporter/prometheus v0.4.2 // indirect
59-
cuelabs.dev/go/oci/ociregistry v0.0.0-20241125120445-2c00c104c6e1 // indirect
59+
cuelabs.dev/go/oci/ociregistry v0.0.0-20250722084951-074d06050084 // indirect
6060
cuelang.org/go v0.12.1 // indirect
6161
github.com/AlecAivazis/survey/v2 v2.3.7 // indirect
6262
github.com/AliyunContainerService/ack-ram-tool/pkg/credentials/provider v0.14.0 // indirect
@@ -227,7 +227,7 @@ require (
227227
github.com/protocolbuffers/txtpbfmt v0.0.0-20241112170944-20d2c9ebc01d // indirect
228228
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
229229
github.com/rivo/uniseg v0.4.4 // indirect
230-
github.com/rogpeppe/go-internal v1.13.2-0.20241226121412-a5dc8ff20d0a // indirect
230+
github.com/rogpeppe/go-internal v1.14.1 // indirect
231231
github.com/sagikazarmark/locafero v0.7.0 // indirect
232232
github.com/sassoftware/relic v7.2.1+incompatible // indirect
233233
github.com/secure-systems-lab/go-securesystemslib v0.9.0 // indirect

upstream/go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d h
6565
contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d/go.mod h1:IshRmMJBhDfFj5Y67nVhMYTTIze91RUeT73ipWKs/GY=
6666
contrib.go.opencensus.io/exporter/prometheus v0.4.2 h1:sqfsYl5GIY/L570iT+l93ehxaWJs2/OwXtiWwew3oAg=
6767
contrib.go.opencensus.io/exporter/prometheus v0.4.2/go.mod h1:dvEHbiKmgvbr5pjaF9fpw1KeYcjrnC1J8B+JKjsZyRQ=
68-
cuelabs.dev/go/oci/ociregistry v0.0.0-20241125120445-2c00c104c6e1 h1:mRwydyTyhtRX2wXS3mqYWzR2qlv6KsmoKXmlz5vInjg=
69-
cuelabs.dev/go/oci/ociregistry v0.0.0-20241125120445-2c00c104c6e1/go.mod h1:5A4xfTzHTXfeVJBU6RAUf+QrlfTCW+017q/QiW+sMLg=
68+
cuelabs.dev/go/oci/ociregistry v0.0.0-20250722084951-074d06050084 h1:4k1yAtPvZJZQTu8DRY8muBo0LHv6TqtrE0AO5n6IPYs=
69+
cuelabs.dev/go/oci/ociregistry v0.0.0-20250722084951-074d06050084/go.mod h1:4WWeZNxUO1vRoZWAHIG0KZOd6dA25ypyWuwD3ti0Tdc=
7070
cuelang.org/go v0.12.1 h1:5I+zxmXim9MmiN2tqRapIqowQxABv2NKTgbOspud1Eo=
7171
cuelang.org/go v0.12.1/go.mod h1:B4+kjvGGQnbkz+GuAv1dq/R308gTkp0sO28FdMrJ2Kw=
7272
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
@@ -1030,8 +1030,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
10301030
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
10311031
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
10321032
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
1033-
github.com/rogpeppe/go-internal v1.13.2-0.20241226121412-a5dc8ff20d0a h1:w3tdWGKbLGBPtR/8/oO74W6hmz0qE5q0z9aqSAewaaM=
1034-
github.com/rogpeppe/go-internal v1.13.2-0.20241226121412-a5dc8ff20d0a/go.mod h1:S8kfXMp+yh77OxPD4fdM6YUknrZpQxLhvxzS4gDHENY=
1033+
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
1034+
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
10351035
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
10361036
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
10371037
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=

upstream/vendor/cuelabs.dev/go/oci/ociregistry/internal/ocirequest/create.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (req *Request) MustConstruct() (method string, ustr string) {
4040
return method, ustr
4141
}
4242

43-
func (req *Request) construct() (method string, url string) {
43+
func (req *Request) construct() (method string, urlStr string) {
4444
switch req.Kind {
4545
case ReqPing:
4646
return "GET", "/v2/"
@@ -77,7 +77,11 @@ func (req *Request) construct() (method string, url string) {
7777
case ReqTagsList:
7878
return "GET", "/v2/" + req.Repo + "/tags/list" + req.listParams()
7979
case ReqReferrersList:
80-
return "GET", "/v2/" + req.Repo + "/referrers/" + req.Digest
80+
p := "/v2/" + req.Repo + "/referrers/" + req.Digest
81+
if req.ArtifactType != "" {
82+
p += "?" + url.Values{"artifactType": {req.ArtifactType}}.Encode()
83+
}
84+
return "GET", p
8185
case ReqCatalogList:
8286
return "GET", "/v2/_catalog" + req.listParams()
8387
default:

upstream/vendor/cuelabs.dev/go/oci/ociregistry/internal/ocirequest/request.go

Lines changed: 44 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ package ocirequest
1616

1717
import (
1818
"encoding/base64"
19-
"errors"
2019
"fmt"
20+
"net/http"
2121
"net/url"
2222
"strconv"
2323
"strings"
@@ -27,27 +27,20 @@ import (
2727
"cuelabs.dev/go/oci/ociregistry/ociref"
2828
)
2929

30-
// ParseError represents an error that can happen when parsing.
31-
// The Err field holds one of the possible error values below.
32-
type ParseError struct {
33-
Err error
34-
}
30+
var (
31+
errBadlyFormedDigest = ociregistry.NewError("badly formed digest", ociregistry.ErrDigestInvalid.Code(), nil)
32+
errMethodNotAllowed = httpErrorf(http.StatusMethodNotAllowed, "method not allowed")
33+
errNotFound = httpErrorf(http.StatusNotFound, "page not found")
34+
)
3535

36-
func (e *ParseError) Error() string {
37-
return e.Err.Error()
36+
func badRequestf(f string, a ...any) error {
37+
return httpErrorf(http.StatusBadRequest, f, a...)
3838
}
3939

40-
func (e *ParseError) Unwrap() error {
41-
return e.Err
40+
func httpErrorf(statusCode int, f string, a ...any) error {
41+
return ociregistry.NewHTTPError(fmt.Errorf(f, a...), statusCode, nil, nil)
4242
}
4343

44-
var (
45-
ErrNotFound = errors.New("page not found")
46-
ErrBadlyFormedDigest = errors.New("badly formed digest")
47-
ErrMethodNotAllowed = errors.New("method not allowed")
48-
ErrBadRequest = errors.New("bad request")
49-
)
50-
5144
type Request struct {
5245
Kind Kind
5346

@@ -98,17 +91,22 @@ type Request struct {
9891
// Valid for:
9992
// ReqTagsList
10093
// ReqCatalog
101-
// ReqReferrers
10294
ListN int
10395

104-
// listLast holds the item to start just after
96+
// ListLast holds the item to start just after
10597
// when listing.
10698
//
10799
// Valid for:
108100
// ReqTagsList
109101
// ReqCatalog
110-
// ReqReferrers
111102
ListLast string
103+
104+
// ArtifactType holds the artifact type to filter by when
105+
// listing.
106+
//
107+
// Valid for:
108+
// ReqReferrersList
109+
ArtifactType string
112110
}
113111

114112
type Kind int
@@ -185,22 +183,14 @@ const (
185183
// Parse parses the given HTTP method and URL as an OCI registry request.
186184
// It understands the endpoints described in the [distribution spec].
187185
//
188-
// If it returns an error, it will be of type *ParseError.
186+
// If it returns an error, it will be of type [ociregistry.Error] or [ociregistry.HTTPError].
189187
//
190188
// [distribution spec]: https://github.com/opencontainers/distribution-spec/blob/main/spec.md#endpoints
191189
func Parse(method string, u *url.URL) (*Request, error) {
192-
req, err := parse(method, u)
193-
if err != nil {
194-
return nil, &ParseError{err}
195-
}
196-
return req, nil
197-
}
198-
199-
func parse(method string, u *url.URL) (*Request, error) {
200190
path := u.Path
201191
urlq, err := url.ParseQuery(u.RawQuery)
202192
if err != nil {
203-
return nil, err
193+
return nil, badRequestf("invalid query parameters: %v", err)
204194
}
205195

206196
var rreq Request
@@ -214,7 +204,7 @@ func parse(method string, u *url.URL) (*Request, error) {
214204
}
215205
if path == "_catalog" {
216206
if method != "GET" {
217-
return nil, ErrMethodNotAllowed
207+
return nil, errMethodNotAllowed
218208
}
219209
rreq.Kind = ReqCatalogList
220210
setListQueryParams(&rreq, urlq)
@@ -230,7 +220,7 @@ func parse(method string, u *url.URL) (*Request, error) {
230220
return nil, ociregistry.ErrNameInvalid
231221
}
232222
if method != "POST" {
233-
return nil, ErrMethodNotAllowed
223+
return nil, errMethodNotAllowed
234224
}
235225
if d := urlq.Get("mount"); d != "" {
236226
// end-11
@@ -257,7 +247,7 @@ func parse(method string, u *url.URL) (*Request, error) {
257247
// end-4b
258248
rreq.Digest = d
259249
if !ociref.IsValidDigest(d) {
260-
return nil, ErrBadlyFormedDigest
250+
return nil, errBadlyFormedDigest
261251
}
262252
rreq.Kind = ReqBlobUploadBlob
263253
return &rreq, nil
@@ -268,17 +258,17 @@ func parse(method string, u *url.URL) (*Request, error) {
268258
}
269259
path, last, ok := cutLast(path, "/")
270260
if !ok {
271-
return nil, ErrNotFound
261+
return nil, errNotFound
272262
}
273263
path, lastButOne, ok := cutLast(path, "/")
274264
if !ok {
275-
return nil, ErrNotFound
265+
return nil, errNotFound
276266
}
277267
switch lastButOne {
278268
case "blobs":
279269
rreq.Repo = path
280270
if !ociref.IsValidDigest(last) {
281-
return nil, ErrBadlyFormedDigest
271+
return nil, errBadlyFormedDigest
282272
}
283273
if !ociref.IsValidRepository(rreq.Repo) {
284274
return nil, ociregistry.ErrNameInvalid
@@ -292,30 +282,30 @@ func parse(method string, u *url.URL) (*Request, error) {
292282
case "DELETE":
293283
rreq.Kind = ReqBlobDelete
294284
default:
295-
return nil, ErrMethodNotAllowed
285+
return nil, errMethodNotAllowed
296286
}
297287
return &rreq, nil
298288
case "uploads":
299289
// Note: this section is all specific to ociserver and
300290
// isn't part of the OCI registry spec.
301291
repo, ok := strings.CutSuffix(path, "/blobs")
302292
if !ok {
303-
return nil, ErrNotFound
293+
return nil, errNotFound
304294
}
305295
rreq.Repo = repo
306296
if !ociref.IsValidRepository(rreq.Repo) {
307297
return nil, ociregistry.ErrNameInvalid
308298
}
309299
uploadID64 := last
310300
if uploadID64 == "" {
311-
return nil, ErrNotFound
301+
return nil, errNotFound
312302
}
313303
uploadID, err := base64.RawURLEncoding.DecodeString(uploadID64)
314304
if err != nil {
315-
return nil, fmt.Errorf("invalid upload ID %q (cannot decode)", uploadID64)
305+
return nil, badRequestf("invalid upload ID %q (cannot decode)", uploadID64)
316306
}
317307
if !utf8.Valid(uploadID) {
318-
return nil, fmt.Errorf("upload ID %q decoded to invalid utf8", uploadID64)
308+
return nil, badRequestf("upload ID %q decoded to invalid utf8", uploadID64)
319309
}
320310
rreq.UploadID = string(uploadID)
321311

@@ -328,10 +318,10 @@ func parse(method string, u *url.URL) (*Request, error) {
328318
rreq.Kind = ReqBlobCompleteUpload
329319
rreq.Digest = urlq.Get("digest")
330320
if !ociref.IsValidDigest(rreq.Digest) {
331-
return nil, ErrBadlyFormedDigest
321+
return nil, errBadlyFormedDigest
332322
}
333323
default:
334-
return nil, ErrMethodNotAllowed
324+
return nil, errMethodNotAllowed
335325
}
336326
return &rreq, nil
337327
case "manifests":
@@ -345,7 +335,7 @@ func parse(method string, u *url.URL) (*Request, error) {
345335
case ociref.IsValidTag(last):
346336
rreq.Tag = last
347337
default:
348-
return nil, ErrNotFound
338+
return nil, errNotFound
349339
}
350340
switch method {
351341
case "GET":
@@ -357,19 +347,19 @@ func parse(method string, u *url.URL) (*Request, error) {
357347
case "DELETE":
358348
rreq.Kind = ReqManifestDelete
359349
default:
360-
return nil, ErrMethodNotAllowed
350+
return nil, errMethodNotAllowed
361351
}
362352
return &rreq, nil
363353

364354
case "tags":
365355
if last != "list" {
366-
return nil, ErrNotFound
356+
return nil, errNotFound
367357
}
368358
if err := setListQueryParams(&rreq, urlq); err != nil {
369359
return nil, err
370360
}
371361
if method != "GET" {
372-
return nil, ErrMethodNotAllowed
362+
return nil, errMethodNotAllowed
373363
}
374364
rreq.Repo = path
375365
if !ociref.IsValidRepository(rreq.Repo) {
@@ -379,31 +369,32 @@ func parse(method string, u *url.URL) (*Request, error) {
379369
return &rreq, nil
380370
case "referrers":
381371
if !ociref.IsValidDigest(last) {
382-
return nil, ErrBadlyFormedDigest
372+
return nil, errBadlyFormedDigest
383373
}
384374
if method != "GET" {
385-
return nil, ErrMethodNotAllowed
375+
return nil, errMethodNotAllowed
386376
}
387377
rreq.Repo = path
388378
if !ociref.IsValidRepository(rreq.Repo) {
389379
return nil, ociregistry.ErrNameInvalid
390380
}
391-
// TODO is there any kind of pagination for referrers?
392-
// We'll set ListN to be future-proof.
381+
// Unlike other list-oriented endpoints, there appears to be no defined way for the client
382+
// to indicate the desired number of results, but set ListN anyway to be future-proof.
393383
rreq.ListN = -1
394384
rreq.Digest = last
385+
rreq.ArtifactType = urlq.Get("artifactType")
395386
rreq.Kind = ReqReferrersList
396387
return &rreq, nil
397388
}
398-
return nil, ErrNotFound
389+
return nil, errNotFound
399390
}
400391

401392
func setListQueryParams(rreq *Request, urlq url.Values) error {
402393
rreq.ListN = -1
403394
if nstr := urlq.Get("n"); nstr != "" {
404395
n, err := strconv.Atoi(nstr)
405396
if err != nil {
406-
return fmt.Errorf("n is not a valid integer: %w", ErrBadRequest)
397+
return badRequestf("query parameter n is not a valid integer")
407398
}
408399
rreq.ListN = n
409400
}

upstream/vendor/cuelabs.dev/go/oci/ociregistry/iter.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,23 @@
1414

1515
package ociregistry
1616

17-
// TODO(go1.23) when we can depend on Go 1.23, this should be:
17+
// TODO(go1.24) when we can depend on Go 1.24, this should be:
1818
// type Seq[T any] = iter.Seq2[T, error]
1919

2020
// Seq defines the type of an iterator sequence returned from
2121
// the iterator functions. In general, a non-nil
2222
// error means that the item is the last in the sequence.
2323
type Seq[T any] func(yield func(T, error) bool)
2424

25-
func All[T any](it Seq[T]) (_ []T, _err error) {
25+
func All[T any](it Seq[T]) ([]T, error) {
2626
xs := []T{}
27-
// TODO(go1.23) for x, err := range it
28-
it(func(x T, err error) bool {
27+
for x, err := range it {
2928
if err != nil {
30-
_err = err
31-
return false
29+
return nil, err
3230
}
3331
xs = append(xs, x)
34-
return true
35-
})
36-
return xs, _err
32+
}
33+
return xs, nil
3734
}
3835

3936
func SliceSeq[T any](xs []T) Seq[T] {

upstream/vendor/cuelabs.dev/go/oci/ociregistry/ociauth/challenge.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func init() {
3232
// token = 1*<any CHAR except CTLs or separators>
3333
// qdtext = <any TEXT except <">>
3434

35-
for c := 0; c < 256; c++ {
35+
for c := range 256 {
3636
var t octetType
3737
isCtl := c <= 31 || c == 127
3838
isChar := 0 <= c && c <= 127

upstream/vendor/cuelabs.dev/go/oci/ociregistry/ociclient/client.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"log"
2626
"net/http"
2727
"net/url"
28+
"slices"
2829
"strconv"
2930
"strings"
3031
"sync/atomic"
@@ -324,10 +325,8 @@ func (c *client) do(req *http.Request, okStatuses ...int) (*http.Response, error
324325
if len(okStatuses) == 0 && resp.StatusCode == http.StatusOK {
325326
return resp, nil
326327
}
327-
for _, status := range okStatuses {
328-
if resp.StatusCode == status {
329-
return resp, nil
330-
}
328+
if slices.Contains(okStatuses, resp.StatusCode) {
329+
return resp, nil
331330
}
332331
defer resp.Body.Close()
333332
if !isOKStatus(resp.StatusCode) {

0 commit comments

Comments
 (0)