From f745d455a26145ab06fca2efa23a9fd9da7cda2d Mon Sep 17 00:00:00 2001 From: Hector Huertas Date: Tue, 11 May 2021 17:29:10 +0200 Subject: [PATCH] clairctl: add support for s3 registries using V4 S3 signature V4 includes the http method on the signature. To create URLs that clair can use to fetch layers, clairctl needs to make GET calls instead of HEAD ones Fixes #1264 Signed-off-by: Hector Huertas --- cmd/clairctl/manifest.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/clairctl/manifest.go b/cmd/clairctl/manifest.go index 584b101ce1..e24e306a67 100644 --- a/cmd/clairctl/manifest.go +++ b/cmd/clairctl/manifest.go @@ -125,10 +125,11 @@ func Inspect(ctx context.Context, r string) (*claircore.Manifest, error) { if err != nil { return nil, err } - req, err := http.NewRequestWithContext(ctx, http.MethodHead, u.String(), nil) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil) if err != nil { return nil, err } + req.Header.Add("Range", "bytes=0-0") res, err := c.Do(req) if err != nil { return nil, err @@ -136,6 +137,7 @@ func Inspect(ctx context.Context, r string) (*claircore.Manifest, error) { res.Body.Close() res.Request.Header.Del("User-Agent") + res.Request.Header.Del("Range") out.Layers = append(out.Layers, &claircore.Layer{ Hash: ccd, URI: res.Request.URL.String(),