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

Method UpdateDiff

httptransport/client/matcher.go:228–262  ·  view source on GitHub ↗

UpdateDiff reports the diff of two update operations, identified by the provided refs. "Prev" may be passed uuid.Nil if the client's last known state has been forgotten by the server.

(ctx context.Context, prev, cur uuid.UUID)

Source from the content-addressed store, hash-verified

226// "Prev" may be passed uuid.Nil if the client's last known state has been
227// forgotten by the server.
228func (c *HTTP) UpdateDiff(ctx context.Context, prev, cur uuid.UUID) (*driver.UpdateDiff, error) {
229 u, err := c.addr.Parse(httptransport.UpdateDiffAPIPath)
230 if err != nil {
231 return nil, err
232 }
233 req, err := httputil.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)
234 if err != nil {
235 return nil, err
236 }
237 v := req.URL.Query()
238 if prev != uuid.Nil {
239 v.Set("prev", prev.String())
240 }
241 v.Set("cur", cur.String())
242 req.URL.RawQuery = v.Encode()
243 if err := c.sign(ctx, req); err != nil {
244 return nil, fmt.Errorf("failed to create request: %v", err)
245 }
246
247 res, err := c.c.Do(req)
248 if err != nil {
249 return nil, err
250 }
251 defer res.Body.Close()
252 if res.StatusCode != http.StatusOK {
253 return nil, fmt.Errorf("%v: unexpected status: %s", u.Path, res.Status)
254 }
255 d := driver.UpdateDiff{}
256 dec := codec.GetDecoder(res.Body)
257 defer codec.PutDecoder(dec)
258 if err := dec.Decode(&d); err != nil {
259 return nil, err
260 }
261 return &d, nil
262}
263
264// Initialized is present to fulfill the interface, but isn't exposed as part of
265// the HTTP API. This method is stubbed out.

Callers 1

TestDifferFunction · 0.95

Calls 7

signMethod · 0.95
NewRequestWithContextFunction · 0.92
GetDecoderFunction · 0.92
PutDecoderFunction · 0.92
CloseMethod · 0.65
StringMethod · 0.45
SetMethod · 0.45

Tested by 1

TestDifferFunction · 0.76