MCPcopy Create free account
hub / github.com/quay/clair / updateOperations

Method updateOperations

httptransport/client/matcher.go:193–221  ·  view source on GitHub ↗

updateOperations is a private method implementing the common bits for retrieving UpdateOperations an ouCache is passed in by the caller to cache any responses providing an etag. if a subsequent response provides a StatusNotModified status, the map of UpdateOprations is served from cache.

(ctx context.Context, req *http.Request, cache *uoCache)

Source from the content-addressed store, hash-verified

191// an ouCache is passed in by the caller to cache any responses providing an etag.
192// if a subsequent response provides a StatusNotModified status, the map of UpdateOprations is served from cache.
193func (c *HTTP) updateOperations(ctx context.Context, req *http.Request, cache *uoCache) (map[string][]driver.UpdateOperation, error) {
194 if err := c.sign(ctx, req); err != nil {
195 return nil, fmt.Errorf("failed to create request: %v", err)
196 }
197 res, err := c.c.Do(req)
198 if err != nil {
199 return nil, err
200 }
201 defer res.Body.Close()
202 switch res.StatusCode {
203 case http.StatusOK:
204 m := make(map[string][]driver.UpdateOperation)
205 dec := codec.GetDecoder(res.Body)
206 defer codec.PutDecoder(dec)
207 if err := dec.Decode(&m); err != nil {
208 return nil, err
209 }
210 // check for etag, if exists store the value and add returned map
211 // to cache
212 if v := res.Header.Get("etag"); v != "" && !strings.HasPrefix(v, "W/") {
213 cache.Set(m, v)
214 }
215 return cache.Copy(), nil
216 case http.StatusNotModified:
217 return cache.Copy(), nil
218 default:
219 }
220 return nil, fmt.Errorf("%v: unexpected status: %s", req.URL.Path, res.Status)
221}
222
223// UpdateDiff reports the diff of two update operations, identified by the
224// provided refs.

Callers 2

UpdateOperationsMethod · 0.95

Calls 6

signMethod · 0.95
GetDecoderFunction · 0.92
PutDecoderFunction · 0.92
CopyMethod · 0.80
CloseMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected