MCPcopy
hub / github.com/containerd/containerd / RepositoryScope

Function RepositoryScope

core/remotes/docker/scope.go:32–42  ·  view source on GitHub ↗

RepositoryScope returns a repository scope string such as "repository:foo/bar:pull" for "host/foo/bar:baz". When push is true, both pull and push are added to the scope.

(refspec reference.Spec, push bool)

Source from the content-addressed store, hash-verified

30// for "host/foo/bar:baz".
31// When push is true, both pull and push are added to the scope.
32func RepositoryScope(refspec reference.Spec, push bool) (string, error) {
33 u, err := url.Parse("dummy://" + refspec.Locator)
34 if err != nil {
35 return "", err
36 }
37 s := "repository:" + strings.TrimPrefix(u.Path, "/") + ":pull"
38 if push {
39 s += ",push"
40 }
41 return s, nil
42}
43
44// tokenScopesKey is used for the key for context.WithValue().
45// value: []string (e.g. {"registry:foo/bar:pull"})

Callers 2

TestRepositoryScopeFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestRepositoryScopeFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…