@@ -80,7 +80,7 @@ func (r *registry) handleCatalogList(ctx context.Context, resp http.ResponseWrit
8080}
8181
8282// TODO: implement handling of artifactType querystring
83- func (r * registry ) handleReferrersList (ctx context.Context , resp http.ResponseWriter , req * http.Request , rreq * ocirequest.Request ) ( _err error ) {
83+ func (r * registry ) handleReferrersList (ctx context.Context , resp http.ResponseWriter , req * http.Request , rreq * ocirequest.Request ) error {
8484 if r .opts .DisableReferrersAPI {
8585 return withHTTPCode (http .StatusNotFound , fmt .Errorf ("referrers API has been disabled" ))
8686 }
@@ -91,18 +91,11 @@ func (r *registry) handleReferrersList(ctx context.Context, resp http.ResponseWr
9191 }
9292
9393 // TODO support artifactType filtering
94- it := r .backend .Referrers (ctx , rreq .Repo , ociregistry .Digest (rreq .Digest ), "" )
95- // TODO(go1.23) for desc, err := range it {
96- it (func (desc ociregistry.Descriptor , err error ) bool {
94+ for desc , err := range r .backend .Referrers (ctx , rreq .Repo , ociregistry .Digest (rreq .Digest ), "" ) {
9795 if err != nil {
98- _err = err
99- return false
96+ return err
10097 }
10198 im .Manifests = append (im .Manifests , desc )
102- return true
103- })
104- if _err != nil {
105- return _err
10699 }
107100 msg , err := json .Marshal (im )
108101 if err != nil {
@@ -115,7 +108,7 @@ func (r *registry) handleReferrersList(ctx context.Context, resp http.ResponseWr
115108 return nil
116109}
117110
118- func (r * registry ) nextListResults (req * http.Request , rreq * ocirequest.Request , itemsIter ociregistry.Seq [string ]) (items []string , link string , _err error ) {
111+ func (r * registry ) nextListResults (req * http.Request , rreq * ocirequest.Request , itemsIter ociregistry.Seq [string ]) (items []string , link string , _ error ) {
119112 if r .opts .MaxListPageSize > 0 && rreq .ListN > r .opts .MaxListPageSize {
120113 return nil , "" , ociregistry .NewError (fmt .Sprintf ("query parameter n is too large (n=%d, max=%d)" , rreq .ListN , r .opts .MaxListPageSize ), ociregistry .ErrUnsupported .Code (), nil )
121114 }
@@ -124,24 +117,18 @@ func (r *registry) nextListResults(req *http.Request, rreq *ocirequest.Request,
124117 n = maxPageSize
125118 }
126119 truncated := false
127- // TODO(go1.23) for repo, err := range itemsIter {
128- itemsIter (func (item string , err error ) bool {
120+ for item , err := range itemsIter {
129121 if err != nil {
130- _err = err
131- return false
122+ return nil , "" , err
132123 }
133124 if rreq .ListN > 0 && len (items ) >= rreq .ListN {
134125 truncated = true
135- return false
126+ break
136127 }
137128 // TODO we might want some way to limit on the total number
138129 // of items returned in the absence of a ListN limit.
139130 items = append (items , item )
140131 // TODO sanity check that the items are in lexical order?
141- return true
142- })
143- if _err != nil {
144- return nil , "" , _err
145132 }
146133 if truncated && ! r .opts .OmitLinkHeaderFromResponses {
147134 link = r .makeNextLink (req , items [len (items )- 1 ])
0 commit comments