Skip to content

Commit

Permalink
Ensure we pass a path to client.NewRequest (#167)
Browse files Browse the repository at this point in the history
We had an inconsistency where NewRequest was used in the apiv2 adapter,
we were passing in a full URL including the hostname instead of just the
path (which is what NewRequest expected). This caused the scheme://host
to be prefixed twice. Apparently http.client.Do was able to sanitize
this in some way with an implicit Parse call, but the problem came to
light when the URL was passed to a proxy to execute, and it wasn't
cleaned.
  • Loading branch information
Erik Nelson authored and dymurray committed Aug 28, 2018
1 parent 1474a70 commit 65190a0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions registries/adapters/apiv2_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ import (
)

const (
apiV2ManifestURL = "%v/v2/%v/manifests/%v"
apiV2CatalogURL = "%v/v2/_catalog"
schema1Ct = "application/vnd.docker.distribution.manifest.v1+json"
schema2Ct = "application/vnd.docker.distribution.manifest.v2+json"
apiV2ManifestPath = "/v2/%v/manifests/%v"
apiV2CatalogURL = "%v/v2/_catalog"
schema1Ct = "application/vnd.docker.distribution.manifest.v1+json"
schema2Ct = "application/vnd.docker.distribution.manifest.v2+json"
)

// OpenShiftAdapter - OpenShift Adapter
Expand Down Expand Up @@ -246,7 +246,7 @@ func (r APIV2Adapter) getNextImageURL(link string) string {
func (r APIV2Adapter) loadSpec(imageName string) (*bundle.Spec, error) {
log.Debugf("%s - LoadSpec", r.config.AdapterName)

req, err := r.client.NewRequest(fmt.Sprintf(apiV2ManifestURL, r.config.URL, imageName, r.config.Tag))
req, err := r.client.NewRequest(fmt.Sprintf(apiV2ManifestPath, imageName, r.config.Tag))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -290,7 +290,7 @@ func (r APIV2Adapter) loadSpec(imageName string) (*bundle.Spec, error) {
digest := mConf.Config.Digest

// get response with digest
req, err = r.client.NewRequest(fmt.Sprintf("%s/v2/%s/blobs/%s", r.config.URL, imageName, digest))
req, err = r.client.NewRequest(fmt.Sprintf("/v2/%s/blobs/%s", imageName, digest))
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 65190a0

Please sign in to comment.