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)
| 30 | // for "host/foo/bar:baz". |
| 31 | // When push is true, both pull and push are added to the scope. |
| 32 | func 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"}) |
no outgoing calls
searching dependent graphs…