From 7fdb38028e1b52ce46b78e9e4528c019e9b91103 Mon Sep 17 00:00:00 2001 From: Meredith Lancaster Date: Thu, 6 Feb 2025 16:06:43 -0700 Subject: [PATCH] remove custom transport Signed-off-by: Meredith Lancaster --- pkg/cmd/attestation/artifact/oci/client.go | 26 +--------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/pkg/cmd/attestation/artifact/oci/client.go b/pkg/cmd/attestation/artifact/oci/client.go index bda114708..4e5acef3c 100644 --- a/pkg/cmd/attestation/artifact/oci/client.go +++ b/pkg/cmd/attestation/artifact/oci/client.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" "io" - "net/http" "strings" "github.com/google/go-containerregistry/pkg/authn" @@ -69,33 +68,10 @@ func (c LiveClient) GetImageDigest(imgName string) (*v1.Hash, name.Reference, er return &desc.Digest, name, nil } -type noncompliantRegistryTransport struct{} - -// RoundTrip will check if a request and associated response fulfill the following: -// 1. The response returns a 406 status code -// 2. The request path contains /referrers/ -// If both conditions are met, the response's status code will be overwritten to 404 -// This is a temporary solution to handle non compliant registries that return -// an unexpected status code 406 when the go-containerregistry library used -// by this code attempts to make a request to the referrers API. -// The go-containerregistry library can handle 404 response but not a 406 response. -// See the related go-containerregistry issue: https://github.com/google/go-containerregistry/issues/1962 -func (a *noncompliantRegistryTransport) RoundTrip(req *http.Request) (*http.Response, error) { - resp, err := http.DefaultTransport.RoundTrip(req) - if err != nil { - return resp, err - } - if resp.StatusCode == http.StatusNotAcceptable && strings.Contains(req.URL.Path, "/referrers/") { - resp.StatusCode = http.StatusNotFound - } - - return resp, err -} - func (c LiveClient) GetAttestations(ref name.Reference, digest string) ([]*api.Attestation, error) { attestations := make([]*api.Attestation, 0) - transportOpts := []remote.Option{remote.WithTransport(&noncompliantRegistryTransport{}), remote.WithAuthFromKeychain(authn.DefaultKeychain)} + transportOpts := []remote.Option{remote.WithAuthFromKeychain(authn.DefaultKeychain)} referrers, err := remote.Referrers(ref.Context().Digest(digest), transportOpts...) if err != nil { return attestations, fmt.Errorf("error getting referrers: %w", err)