Skip to content

Commit

Permalink
Revert "Hack around DockerHub plugin scope handling" (#1531)
Browse files Browse the repository at this point in the history
This reverts commit 46031f6.
  • Loading branch information
jonjohnsonjr committed Jan 11, 2023
1 parent 5ad0a76 commit 8e08d51
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions pkg/v1/remote/descriptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,28 +209,6 @@ func (d *Descriptor) remoteIndex() *remoteIndex {
}
}

// https://github.com/docker/hub-feedback/issues/2107#issuecomment-1371293316
//
// DockerHub supports plugins, which look like normal manifests, but will
// return a 401 with an incorrect challenge if you attempt to fetch them.
//
// They require you send, e.g.:
// 'repository(plugin):vieux/sshfs:pull' not 'repository:vieux/sshfs:pull'.
//
// Hack around this by always including the plugin-ified version in the initial
// scopes. The request will succeed with the correct subset, so it is safe to
// have extraneous scopes here.
func fixPluginScopes(ref name.Reference, scopes []string) []string {
if ref.Context().Registry.String() == name.DefaultRegistry {
for _, scope := range scopes {
if strings.HasPrefix(scope, "repository") {
scopes = append(scopes, strings.Replace(scope, "repository", "repository(plugin)", 1))
}
}
}
return scopes
}

// fetcher implements methods for reading from a registry.
type fetcher struct {
Ref name.Reference
Expand All @@ -239,10 +217,7 @@ type fetcher struct {
}

func makeFetcher(ref name.Reference, o *options) (*fetcher, error) {
scopes := []string{ref.Scope(transport.PullScope)}
scopes = fixPluginScopes(ref, scopes)

tr, err := transport.NewWithContext(o.context, ref.Context().Registry, o.auth, o.transport, scopes)
tr, err := transport.NewWithContext(o.context, ref.Context().Registry, o.auth, o.transport, []string{ref.Scope(transport.PullScope)})
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 8e08d51

Please sign in to comment.