Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert plugin scope hack #1531

Merged
merged 1 commit into from
Jan 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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