repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
docker/distribution
manifest/schema1/sign.go
SignWithChain
func SignWithChain(m *Manifest, key libtrust.PrivateKey, chain []*x509.Certificate) (*SignedManifest, error) { p, err := json.MarshalIndent(m, "", " ") if err != nil { return nil, err } js, err := libtrust.NewJSONSignature(p) if err != nil { return nil, err } if err := js.SignWithChain(key, chain); err !...
go
func SignWithChain(m *Manifest, key libtrust.PrivateKey, chain []*x509.Certificate) (*SignedManifest, error) { p, err := json.MarshalIndent(m, "", " ") if err != nil { return nil, err } js, err := libtrust.NewJSONSignature(p) if err != nil { return nil, err } if err := js.SignWithChain(key, chain); err !...
[ "func", "SignWithChain", "(", "m", "*", "Manifest", ",", "key", "libtrust", ".", "PrivateKey", ",", "chain", "[", "]", "*", "x509", ".", "Certificate", ")", "(", "*", "SignedManifest", ",", "error", ")", "{", "p", ",", "err", ":=", "json", ".", "Mars...
// SignWithChain signs the manifest with the given private key and x509 chain. // The public key of the first element in the chain must be the public key // corresponding with the sign key.
[ "SignWithChain", "signs", "the", "manifest", "with", "the", "given", "private", "key", "and", "x509", "chain", ".", "The", "public", "key", "of", "the", "first", "element", "in", "the", "chain", "must", "be", "the", "public", "key", "corresponding", "with", ...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/schema1/sign.go#L43-L68
train
docker/distribution
digestset/set.go
checkShortMatch
func checkShortMatch(alg digest.Algorithm, hex, shortAlg, shortHex string) bool { if len(hex) == len(shortHex) { if hex != shortHex { return false } if len(shortAlg) > 0 && string(alg) != shortAlg { return false } } else if !strings.HasPrefix(hex, shortHex) { return false } else if len(shortAlg) > 0 ...
go
func checkShortMatch(alg digest.Algorithm, hex, shortAlg, shortHex string) bool { if len(hex) == len(shortHex) { if hex != shortHex { return false } if len(shortAlg) > 0 && string(alg) != shortAlg { return false } } else if !strings.HasPrefix(hex, shortHex) { return false } else if len(shortAlg) > 0 ...
[ "func", "checkShortMatch", "(", "alg", "digest", ".", "Algorithm", ",", "hex", ",", "shortAlg", ",", "shortHex", "string", ")", "bool", "{", "if", "len", "(", "hex", ")", "==", "len", "(", "shortHex", ")", "{", "if", "hex", "!=", "shortHex", "{", "re...
// checkShortMatch checks whether two digests match as either whole // values or short values. This function does not test equality, // rather whether the second value could match against the first // value.
[ "checkShortMatch", "checks", "whether", "two", "digests", "match", "as", "either", "whole", "values", "or", "short", "values", ".", "This", "function", "does", "not", "test", "equality", "rather", "whether", "the", "second", "value", "could", "match", "against",...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/digestset/set.go#L49-L63
train
docker/distribution
digestset/set.go
Lookup
func (dst *Set) Lookup(d string) (digest.Digest, error) { dst.mutex.RLock() defer dst.mutex.RUnlock() if len(dst.entries) == 0 { return "", ErrDigestNotFound } var ( searchFunc func(int) bool alg digest.Algorithm hex string ) dgst, err := digest.Parse(d) if err == digest.ErrDigestInvalidFo...
go
func (dst *Set) Lookup(d string) (digest.Digest, error) { dst.mutex.RLock() defer dst.mutex.RUnlock() if len(dst.entries) == 0 { return "", ErrDigestNotFound } var ( searchFunc func(int) bool alg digest.Algorithm hex string ) dgst, err := digest.Parse(d) if err == digest.ErrDigestInvalidFo...
[ "func", "(", "dst", "*", "Set", ")", "Lookup", "(", "d", "string", ")", "(", "digest", ".", "Digest", ",", "error", ")", "{", "dst", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "dst", ".", "mutex", ".", "RUnlock", "(", ")", "\n", "if",...
// Lookup looks for a digest matching the given string representation. // If no digests could be found ErrDigestNotFound will be returned // with an empty digest value. If multiple matches are found // ErrDigestAmbiguous will be returned with an empty digest value.
[ "Lookup", "looks", "for", "a", "digest", "matching", "the", "given", "string", "representation", ".", "If", "no", "digests", "could", "be", "found", "ErrDigestNotFound", "will", "be", "returned", "with", "an", "empty", "digest", "value", ".", "If", "multiple",...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/digestset/set.go#L69-L108
train
docker/distribution
digestset/set.go
Add
func (dst *Set) Add(d digest.Digest) error { if err := d.Validate(); err != nil { return err } dst.mutex.Lock() defer dst.mutex.Unlock() entry := &digestEntry{alg: d.Algorithm(), val: d.Hex(), digest: d} searchFunc := func(i int) bool { if dst.entries[i].val == entry.val { return dst.entries[i].alg >= entr...
go
func (dst *Set) Add(d digest.Digest) error { if err := d.Validate(); err != nil { return err } dst.mutex.Lock() defer dst.mutex.Unlock() entry := &digestEntry{alg: d.Algorithm(), val: d.Hex(), digest: d} searchFunc := func(i int) bool { if dst.entries[i].val == entry.val { return dst.entries[i].alg >= entr...
[ "func", "(", "dst", "*", "Set", ")", "Add", "(", "d", "digest", ".", "Digest", ")", "error", "{", "if", "err", ":=", "d", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "dst", ".", "mutex", ".", "Lo...
// Add adds the given digest to the set. An error will be returned // if the given digest is invalid. If the digest already exists in the // set, this operation will be a no-op.
[ "Add", "adds", "the", "given", "digest", "to", "the", "set", ".", "An", "error", "will", "be", "returned", "if", "the", "given", "digest", "is", "invalid", ".", "If", "the", "digest", "already", "exists", "in", "the", "set", "this", "operation", "will", ...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/digestset/set.go#L113-L139
train
docker/distribution
digestset/set.go
All
func (dst *Set) All() []digest.Digest { dst.mutex.RLock() defer dst.mutex.RUnlock() retValues := make([]digest.Digest, len(dst.entries)) for i := range dst.entries { retValues[i] = dst.entries[i].digest } return retValues }
go
func (dst *Set) All() []digest.Digest { dst.mutex.RLock() defer dst.mutex.RUnlock() retValues := make([]digest.Digest, len(dst.entries)) for i := range dst.entries { retValues[i] = dst.entries[i].digest } return retValues }
[ "func", "(", "dst", "*", "Set", ")", "All", "(", ")", "[", "]", "digest", ".", "Digest", "{", "dst", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "dst", ".", "mutex", ".", "RUnlock", "(", ")", "\n", "retValues", ":=", "make", "(", "[", ...
// All returns all the digests in the set
[ "All", "returns", "all", "the", "digests", "in", "the", "set" ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/digestset/set.go#L172-L181
train
docker/distribution
digestset/set.go
ShortCodeTable
func ShortCodeTable(dst *Set, length int) map[digest.Digest]string { dst.mutex.RLock() defer dst.mutex.RUnlock() m := make(map[digest.Digest]string, len(dst.entries)) l := length resetIdx := 0 for i := 0; i < len(dst.entries); i++ { var short string extended := true for extended { extended = false if ...
go
func ShortCodeTable(dst *Set, length int) map[digest.Digest]string { dst.mutex.RLock() defer dst.mutex.RUnlock() m := make(map[digest.Digest]string, len(dst.entries)) l := length resetIdx := 0 for i := 0; i < len(dst.entries); i++ { var short string extended := true for extended { extended = false if ...
[ "func", "ShortCodeTable", "(", "dst", "*", "Set", ",", "length", "int", ")", "map", "[", "digest", ".", "Digest", "]", "string", "{", "dst", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "dst", ".", "mutex", ".", "RUnlock", "(", ")", "\n", ...
// ShortCodeTable returns a map of Digest to unique short codes. The // length represents the minimum value, the maximum length may be the // entire value of digest if uniqueness cannot be achieved without the // full value. This function will attempt to make short codes as short // as possible to be unique.
[ "ShortCodeTable", "returns", "a", "map", "of", "Digest", "to", "unique", "short", "codes", ".", "The", "length", "represents", "the", "minimum", "value", "the", "maximum", "length", "may", "be", "the", "entire", "value", "of", "digest", "if", "uniqueness", "...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/digestset/set.go#L188-L224
train
docker/distribution
registry/handlers/manifests.go
manifestDispatcher
func manifestDispatcher(ctx *Context, r *http.Request) http.Handler { manifestHandler := &manifestHandler{ Context: ctx, } reference := getReference(ctx) dgst, err := digest.Parse(reference) if err != nil { // We just have a tag manifestHandler.Tag = reference } else { manifestHandler.Digest = dgst } m...
go
func manifestDispatcher(ctx *Context, r *http.Request) http.Handler { manifestHandler := &manifestHandler{ Context: ctx, } reference := getReference(ctx) dgst, err := digest.Parse(reference) if err != nil { // We just have a tag manifestHandler.Tag = reference } else { manifestHandler.Digest = dgst } m...
[ "func", "manifestDispatcher", "(", "ctx", "*", "Context", ",", "r", "*", "http", ".", "Request", ")", "http", ".", "Handler", "{", "manifestHandler", ":=", "&", "manifestHandler", "{", "Context", ":", "ctx", ",", "}", "\n", "reference", ":=", "getReference...
// manifestDispatcher takes the request context and builds the // appropriate handler for handling manifest requests.
[ "manifestDispatcher", "takes", "the", "request", "context", "and", "builds", "the", "appropriate", "handler", "for", "handling", "manifest", "requests", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/manifests.go#L46-L70
train
docker/distribution
registry/handlers/manifests.go
applyResourcePolicy
func (imh *manifestHandler) applyResourcePolicy(manifest distribution.Manifest) error { allowedClasses := imh.App.Config.Policy.Repository.Classes if len(allowedClasses) == 0 { return nil } var class string switch m := manifest.(type) { case *schema1.SignedManifest: class = imageClass case *schema2.Deserial...
go
func (imh *manifestHandler) applyResourcePolicy(manifest distribution.Manifest) error { allowedClasses := imh.App.Config.Policy.Repository.Classes if len(allowedClasses) == 0 { return nil } var class string switch m := manifest.(type) { case *schema1.SignedManifest: class = imageClass case *schema2.Deserial...
[ "func", "(", "imh", "*", "manifestHandler", ")", "applyResourcePolicy", "(", "manifest", "distribution", ".", "Manifest", ")", "error", "{", "allowedClasses", ":=", "imh", ".", "App", ".", "Config", ".", "Policy", ".", "Repository", ".", "Classes", "\n", "if...
// applyResourcePolicy checks whether the resource class matches what has // been authorized and allowed by the policy configuration.
[ "applyResourcePolicy", "checks", "whether", "the", "resource", "class", "matches", "what", "has", "been", "authorized", "and", "allowed", "by", "the", "policy", "configuration", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/manifests.go#L418-L485
train
docker/distribution
registry/handlers/manifests.go
DeleteManifest
func (imh *manifestHandler) DeleteManifest(w http.ResponseWriter, r *http.Request) { dcontext.GetLogger(imh).Debug("DeleteImageManifest") manifests, err := imh.Repository.Manifests(imh) if err != nil { imh.Errors = append(imh.Errors, err) return } err = manifests.Delete(imh, imh.Digest) if err != nil { sw...
go
func (imh *manifestHandler) DeleteManifest(w http.ResponseWriter, r *http.Request) { dcontext.GetLogger(imh).Debug("DeleteImageManifest") manifests, err := imh.Repository.Manifests(imh) if err != nil { imh.Errors = append(imh.Errors, err) return } err = manifests.Delete(imh, imh.Digest) if err != nil { sw...
[ "func", "(", "imh", "*", "manifestHandler", ")", "DeleteManifest", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "dcontext", ".", "GetLogger", "(", "imh", ")", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "m...
// DeleteManifest removes the manifest with the given digest from the registry.
[ "DeleteManifest", "removes", "the", "manifest", "with", "the", "given", "digest", "from", "the", "registry", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/manifests.go#L488-L531
train
docker/distribution
configuration/parser.go
MajorMinorVersion
func MajorMinorVersion(major, minor uint) Version { return Version(fmt.Sprintf("%d.%d", major, minor)) }
go
func MajorMinorVersion(major, minor uint) Version { return Version(fmt.Sprintf("%d.%d", major, minor)) }
[ "func", "MajorMinorVersion", "(", "major", ",", "minor", "uint", ")", "Version", "{", "return", "Version", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "major", ",", "minor", ")", ")", "\n", "}" ]
// MajorMinorVersion constructs a Version from its Major and Minor components
[ "MajorMinorVersion", "constructs", "a", "Version", "from", "its", "Major", "and", "Minor", "components" ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/configuration/parser.go#L21-L23
train
docker/distribution
reference/helpers.go
IsNameOnly
func IsNameOnly(ref Named) bool { if _, ok := ref.(NamedTagged); ok { return false } if _, ok := ref.(Canonical); ok { return false } return true }
go
func IsNameOnly(ref Named) bool { if _, ok := ref.(NamedTagged); ok { return false } if _, ok := ref.(Canonical); ok { return false } return true }
[ "func", "IsNameOnly", "(", "ref", "Named", ")", "bool", "{", "if", "_", ",", "ok", ":=", "ref", ".", "(", "NamedTagged", ")", ";", "ok", "{", "return", "false", "\n", "}", "\n", "if", "_", ",", "ok", ":=", "ref", ".", "(", "Canonical", ")", ";"...
// IsNameOnly returns true if reference only contains a repo name.
[ "IsNameOnly", "returns", "true", "if", "reference", "only", "contains", "a", "repo", "name", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/reference/helpers.go#L6-L14
train
docker/distribution
reference/helpers.go
FamiliarName
func FamiliarName(ref Named) string { if nn, ok := ref.(normalizedNamed); ok { return nn.Familiar().Name() } return ref.Name() }
go
func FamiliarName(ref Named) string { if nn, ok := ref.(normalizedNamed); ok { return nn.Familiar().Name() } return ref.Name() }
[ "func", "FamiliarName", "(", "ref", "Named", ")", "string", "{", "if", "nn", ",", "ok", ":=", "ref", ".", "(", "normalizedNamed", ")", ";", "ok", "{", "return", "nn", ".", "Familiar", "(", ")", ".", "Name", "(", ")", "\n", "}", "\n", "return", "r...
// FamiliarName returns the familiar name string // for the given named, familiarizing if needed.
[ "FamiliarName", "returns", "the", "familiar", "name", "string", "for", "the", "given", "named", "familiarizing", "if", "needed", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/reference/helpers.go#L18-L23
train
docker/distribution
reference/helpers.go
FamiliarString
func FamiliarString(ref Reference) string { if nn, ok := ref.(normalizedNamed); ok { return nn.Familiar().String() } return ref.String() }
go
func FamiliarString(ref Reference) string { if nn, ok := ref.(normalizedNamed); ok { return nn.Familiar().String() } return ref.String() }
[ "func", "FamiliarString", "(", "ref", "Reference", ")", "string", "{", "if", "nn", ",", "ok", ":=", "ref", ".", "(", "normalizedNamed", ")", ";", "ok", "{", "return", "nn", ".", "Familiar", "(", ")", ".", "String", "(", ")", "\n", "}", "\n", "retur...
// FamiliarString returns the familiar string representation // for the given reference, familiarizing if needed.
[ "FamiliarString", "returns", "the", "familiar", "string", "representation", "for", "the", "given", "reference", "familiarizing", "if", "needed", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/reference/helpers.go#L27-L32
train
docker/distribution
registry/storage/io.go
limitReader
func limitReader(r io.Reader, n int64) io.Reader { return &limitedReader{r: r, n: n} }
go
func limitReader(r io.Reader, n int64) io.Reader { return &limitedReader{r: r, n: n} }
[ "func", "limitReader", "(", "r", "io", ".", "Reader", ",", "n", "int64", ")", "io", ".", "Reader", "{", "return", "&", "limitedReader", "{", "r", ":", "r", ",", "n", ":", "n", "}", "\n", "}" ]
// limitReader returns a new reader limited to n bytes. Unlike io.LimitReader, // this returns an error when the limit reached.
[ "limitReader", "returns", "a", "new", "reader", "limited", "to", "n", "bytes", ".", "Unlike", "io", ".", "LimitReader", "this", "returns", "an", "error", "when", "the", "limit", "reached", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/io.go#L32-L34
train
docker/distribution
registry/storage/driver/base/base.go
setDriverName
func (base *Base) setDriverName(e error) error { switch actual := e.(type) { case nil: return nil case storagedriver.ErrUnsupportedMethod: actual.DriverName = base.StorageDriver.Name() return actual case storagedriver.PathNotFoundError: actual.DriverName = base.StorageDriver.Name() return actual case sto...
go
func (base *Base) setDriverName(e error) error { switch actual := e.(type) { case nil: return nil case storagedriver.ErrUnsupportedMethod: actual.DriverName = base.StorageDriver.Name() return actual case storagedriver.PathNotFoundError: actual.DriverName = base.StorageDriver.Name() return actual case sto...
[ "func", "(", "base", "*", "Base", ")", "setDriverName", "(", "e", "error", ")", "error", "{", "switch", "actual", ":=", "e", ".", "(", "type", ")", "{", "case", "nil", ":", "return", "nil", "\n", "case", "storagedriver", ".", "ErrUnsupportedMethod", ":...
// Format errors received from the storage driver
[ "Format", "errors", "received", "from", "the", "storage", "driver" ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/base/base.go#L67-L91
train
docker/distribution
registry/storage/driver/base/base.go
GetContent
func (base *Base) GetContent(ctx context.Context, path string) ([]byte, error) { ctx, done := dcontext.WithTrace(ctx) defer done("%s.GetContent(%q)", base.Name(), path) if !storagedriver.PathRegexp.MatchString(path) { return nil, storagedriver.InvalidPathError{Path: path, DriverName: base.StorageDriver.Name()} }...
go
func (base *Base) GetContent(ctx context.Context, path string) ([]byte, error) { ctx, done := dcontext.WithTrace(ctx) defer done("%s.GetContent(%q)", base.Name(), path) if !storagedriver.PathRegexp.MatchString(path) { return nil, storagedriver.InvalidPathError{Path: path, DriverName: base.StorageDriver.Name()} }...
[ "func", "(", "base", "*", "Base", ")", "GetContent", "(", "ctx", "context", ".", "Context", ",", "path", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "ctx", ",", "done", ":=", "dcontext", ".", "WithTrace", "(", "ctx", ")", "\n", ...
// GetContent wraps GetContent of underlying storage driver.
[ "GetContent", "wraps", "GetContent", "of", "underlying", "storage", "driver", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/base/base.go#L94-L106
train
docker/distribution
registry/storage/driver/base/base.go
Reader
func (base *Base) Reader(ctx context.Context, path string, offset int64) (io.ReadCloser, error) { ctx, done := dcontext.WithTrace(ctx) defer done("%s.Reader(%q, %d)", base.Name(), path, offset) if offset < 0 { return nil, storagedriver.InvalidOffsetError{Path: path, Offset: offset, DriverName: base.StorageDriver....
go
func (base *Base) Reader(ctx context.Context, path string, offset int64) (io.ReadCloser, error) { ctx, done := dcontext.WithTrace(ctx) defer done("%s.Reader(%q, %d)", base.Name(), path, offset) if offset < 0 { return nil, storagedriver.InvalidOffsetError{Path: path, Offset: offset, DriverName: base.StorageDriver....
[ "func", "(", "base", "*", "Base", ")", "Reader", "(", "ctx", "context", ".", "Context", ",", "path", "string", ",", "offset", "int64", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "ctx", ",", "done", ":=", "dcontext", ".", "WithTrace", ...
// Reader wraps Reader of underlying storage driver.
[ "Reader", "wraps", "Reader", "of", "underlying", "storage", "driver", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/base/base.go#L124-L138
train
docker/distribution
registry/storage/driver/base/base.go
Writer
func (base *Base) Writer(ctx context.Context, path string, append bool) (storagedriver.FileWriter, error) { ctx, done := dcontext.WithTrace(ctx) defer done("%s.Writer(%q, %v)", base.Name(), path, append) if !storagedriver.PathRegexp.MatchString(path) { return nil, storagedriver.InvalidPathError{Path: path, Driver...
go
func (base *Base) Writer(ctx context.Context, path string, append bool) (storagedriver.FileWriter, error) { ctx, done := dcontext.WithTrace(ctx) defer done("%s.Writer(%q, %v)", base.Name(), path, append) if !storagedriver.PathRegexp.MatchString(path) { return nil, storagedriver.InvalidPathError{Path: path, Driver...
[ "func", "(", "base", "*", "Base", ")", "Writer", "(", "ctx", "context", ".", "Context", ",", "path", "string", ",", "append", "bool", ")", "(", "storagedriver", ".", "FileWriter", ",", "error", ")", "{", "ctx", ",", "done", ":=", "dcontext", ".", "Wi...
// Writer wraps Writer of underlying storage driver.
[ "Writer", "wraps", "Writer", "of", "underlying", "storage", "driver", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/base/base.go#L141-L151
train
docker/distribution
registry/storage/driver/base/base.go
Move
func (base *Base) Move(ctx context.Context, sourcePath string, destPath string) error { ctx, done := dcontext.WithTrace(ctx) defer done("%s.Move(%q, %q", base.Name(), sourcePath, destPath) if !storagedriver.PathRegexp.MatchString(sourcePath) { return storagedriver.InvalidPathError{Path: sourcePath, DriverName: ba...
go
func (base *Base) Move(ctx context.Context, sourcePath string, destPath string) error { ctx, done := dcontext.WithTrace(ctx) defer done("%s.Move(%q, %q", base.Name(), sourcePath, destPath) if !storagedriver.PathRegexp.MatchString(sourcePath) { return storagedriver.InvalidPathError{Path: sourcePath, DriverName: ba...
[ "func", "(", "base", "*", "Base", ")", "Move", "(", "ctx", "context", ".", "Context", ",", "sourcePath", "string", ",", "destPath", "string", ")", "error", "{", "ctx", ",", "done", ":=", "dcontext", ".", "WithTrace", "(", "ctx", ")", "\n", "defer", "...
// Move wraps Move of underlying storage driver.
[ "Move", "wraps", "Move", "of", "underlying", "storage", "driver", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/base/base.go#L184-L198
train
docker/distribution
registry/storage/driver/base/base.go
Walk
func (base *Base) Walk(ctx context.Context, path string, f storagedriver.WalkFn) error { ctx, done := dcontext.WithTrace(ctx) defer done("%s.Walk(%q)", base.Name(), path) if !storagedriver.PathRegexp.MatchString(path) && path != "/" { return storagedriver.InvalidPathError{Path: path, DriverName: base.StorageDrive...
go
func (base *Base) Walk(ctx context.Context, path string, f storagedriver.WalkFn) error { ctx, done := dcontext.WithTrace(ctx) defer done("%s.Walk(%q)", base.Name(), path) if !storagedriver.PathRegexp.MatchString(path) && path != "/" { return storagedriver.InvalidPathError{Path: path, DriverName: base.StorageDrive...
[ "func", "(", "base", "*", "Base", ")", "Walk", "(", "ctx", "context", ".", "Context", ",", "path", "string", ",", "f", "storagedriver", ".", "WalkFn", ")", "error", "{", "ctx", ",", "done", ":=", "dcontext", ".", "WithTrace", "(", "ctx", ")", "\n", ...
// Walk wraps Walk of underlying storage driver.
[ "Walk", "wraps", "Walk", "of", "underlying", "storage", "driver", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/base/base.go#L231-L240
train
docker/distribution
registry/middleware/repository/middleware.go
Get
func Get(ctx context.Context, name string, options map[string]interface{}, repository distribution.Repository) (distribution.Repository, error) { if middlewares != nil { if initFunc, exists := middlewares[name]; exists { return initFunc(ctx, repository, options) } } return nil, fmt.Errorf("no repository midd...
go
func Get(ctx context.Context, name string, options map[string]interface{}, repository distribution.Repository) (distribution.Repository, error) { if middlewares != nil { if initFunc, exists := middlewares[name]; exists { return initFunc(ctx, repository, options) } } return nil, fmt.Errorf("no repository midd...
[ "func", "Get", "(", "ctx", "context", ".", "Context", ",", "name", "string", ",", "options", "map", "[", "string", "]", "interface", "{", "}", ",", "repository", "distribution", ".", "Repository", ")", "(", "distribution", ".", "Repository", ",", "error", ...
// Get constructs a RepositoryMiddleware with the given options using the named backend.
[ "Get", "constructs", "a", "RepositoryMiddleware", "with", "the", "given", "options", "using", "the", "named", "backend", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/middleware/repository/middleware.go#L32-L40
train
docker/distribution
manifest/schema1/manifest.go
UnmarshalJSON
func (sm *SignedManifest) UnmarshalJSON(b []byte) error { sm.all = make([]byte, len(b)) // store manifest and signatures in all copy(sm.all, b) jsig, err := libtrust.ParsePrettySignature(b, "signatures") if err != nil { return err } // Resolve the payload in the manifest. bytes, err := jsig.Payload() if er...
go
func (sm *SignedManifest) UnmarshalJSON(b []byte) error { sm.all = make([]byte, len(b)) // store manifest and signatures in all copy(sm.all, b) jsig, err := libtrust.ParsePrettySignature(b, "signatures") if err != nil { return err } // Resolve the payload in the manifest. bytes, err := jsig.Payload() if er...
[ "func", "(", "sm", "*", "SignedManifest", ")", "UnmarshalJSON", "(", "b", "[", "]", "byte", ")", "error", "{", "sm", ".", "all", "=", "make", "(", "[", "]", "byte", ",", "len", "(", "b", ")", ")", "\n", "// store manifest and signatures in all", "copy"...
// UnmarshalJSON populates a new SignedManifest struct from JSON data.
[ "UnmarshalJSON", "populates", "a", "new", "SignedManifest", "struct", "from", "JSON", "data", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/schema1/manifest.go#L110-L139
train
docker/distribution
manifest/schema1/manifest.go
References
func (sm SignedManifest) References() []distribution.Descriptor { dependencies := make([]distribution.Descriptor, len(sm.FSLayers)) for i, fsLayer := range sm.FSLayers { dependencies[i] = distribution.Descriptor{ MediaType: "application/vnd.docker.container.image.rootfs.diff+x-gtar", Digest: fsLayer.BlobSu...
go
func (sm SignedManifest) References() []distribution.Descriptor { dependencies := make([]distribution.Descriptor, len(sm.FSLayers)) for i, fsLayer := range sm.FSLayers { dependencies[i] = distribution.Descriptor{ MediaType: "application/vnd.docker.container.image.rootfs.diff+x-gtar", Digest: fsLayer.BlobSu...
[ "func", "(", "sm", "SignedManifest", ")", "References", "(", ")", "[", "]", "distribution", ".", "Descriptor", "{", "dependencies", ":=", "make", "(", "[", "]", "distribution", ".", "Descriptor", ",", "len", "(", "sm", ".", "FSLayers", ")", ")", "\n", ...
// References returns the descriptors of this manifests references
[ "References", "returns", "the", "descriptors", "of", "this", "manifests", "references" ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/schema1/manifest.go#L142-L153
train
docker/distribution
manifest/schema1/manifest.go
MarshalJSON
func (sm *SignedManifest) MarshalJSON() ([]byte, error) { if len(sm.all) > 0 { return sm.all, nil } // If the raw data is not available, just dump the inner content. return json.Marshal(&sm.Manifest) }
go
func (sm *SignedManifest) MarshalJSON() ([]byte, error) { if len(sm.all) > 0 { return sm.all, nil } // If the raw data is not available, just dump the inner content. return json.Marshal(&sm.Manifest) }
[ "func", "(", "sm", "*", "SignedManifest", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "len", "(", "sm", ".", "all", ")", ">", "0", "{", "return", "sm", ".", "all", ",", "nil", "\n", "}", "\n\n", "// If the...
// MarshalJSON returns the contents of raw. If Raw is nil, marshals the inner // contents. Applications requiring a marshaled signed manifest should simply // use Raw directly, since the the content produced by json.Marshal will be // compacted and will fail signature checks.
[ "MarshalJSON", "returns", "the", "contents", "of", "raw", ".", "If", "Raw", "is", "nil", "marshals", "the", "inner", "contents", ".", "Applications", "requiring", "a", "marshaled", "signed", "manifest", "should", "simply", "use", "Raw", "directly", "since", "t...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/schema1/manifest.go#L159-L166
train
docker/distribution
manifest/schema1/manifest.go
Payload
func (sm SignedManifest) Payload() (string, []byte, error) { return MediaTypeSignedManifest, sm.all, nil }
go
func (sm SignedManifest) Payload() (string, []byte, error) { return MediaTypeSignedManifest, sm.all, nil }
[ "func", "(", "sm", "SignedManifest", ")", "Payload", "(", ")", "(", "string", ",", "[", "]", "byte", ",", "error", ")", "{", "return", "MediaTypeSignedManifest", ",", "sm", ".", "all", ",", "nil", "\n", "}" ]
// Payload returns the signed content of the signed manifest.
[ "Payload", "returns", "the", "signed", "content", "of", "the", "signed", "manifest", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/schema1/manifest.go#L169-L171
train
docker/distribution
context/logger.go
WithLogger
func WithLogger(ctx context.Context, logger Logger) context.Context { return context.WithValue(ctx, loggerKey{}, logger) }
go
func WithLogger(ctx context.Context, logger Logger) context.Context { return context.WithValue(ctx, loggerKey{}, logger) }
[ "func", "WithLogger", "(", "ctx", "context", ".", "Context", ",", "logger", "Logger", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "loggerKey", "{", "}", ",", "logger", ")", "\n", "}" ]
// WithLogger creates a new context with provided logger.
[ "WithLogger", "creates", "a", "new", "context", "with", "provided", "logger", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/context/logger.go#L49-L51
train
docker/distribution
context/logger.go
GetLoggerWithField
func GetLoggerWithField(ctx context.Context, key, value interface{}, keys ...interface{}) Logger { return getLogrusLogger(ctx, keys...).WithField(fmt.Sprint(key), value) }
go
func GetLoggerWithField(ctx context.Context, key, value interface{}, keys ...interface{}) Logger { return getLogrusLogger(ctx, keys...).WithField(fmt.Sprint(key), value) }
[ "func", "GetLoggerWithField", "(", "ctx", "context", ".", "Context", ",", "key", ",", "value", "interface", "{", "}", ",", "keys", "...", "interface", "{", "}", ")", "Logger", "{", "return", "getLogrusLogger", "(", "ctx", ",", "keys", "...", ")", ".", ...
// GetLoggerWithField returns a logger instance with the specified field key // and value without affecting the context. Extra specified keys will be // resolved from the context.
[ "GetLoggerWithField", "returns", "a", "logger", "instance", "with", "the", "specified", "field", "key", "and", "value", "without", "affecting", "the", "context", ".", "Extra", "specified", "keys", "will", "be", "resolved", "from", "the", "context", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/context/logger.go#L56-L58
train
docker/distribution
context/logger.go
GetLoggerWithFields
func GetLoggerWithFields(ctx context.Context, fields map[interface{}]interface{}, keys ...interface{}) Logger { // must convert from interface{} -> interface{} to string -> interface{} for logrus. lfields := make(logrus.Fields, len(fields)) for key, value := range fields { lfields[fmt.Sprint(key)] = value } ret...
go
func GetLoggerWithFields(ctx context.Context, fields map[interface{}]interface{}, keys ...interface{}) Logger { // must convert from interface{} -> interface{} to string -> interface{} for logrus. lfields := make(logrus.Fields, len(fields)) for key, value := range fields { lfields[fmt.Sprint(key)] = value } ret...
[ "func", "GetLoggerWithFields", "(", "ctx", "context", ".", "Context", ",", "fields", "map", "[", "interface", "{", "}", "]", "interface", "{", "}", ",", "keys", "...", "interface", "{", "}", ")", "Logger", "{", "// must convert from interface{} -> interface{} to...
// GetLoggerWithFields returns a logger instance with the specified fields // without affecting the context. Extra specified keys will be resolved from // the context.
[ "GetLoggerWithFields", "returns", "a", "logger", "instance", "with", "the", "specified", "fields", "without", "affecting", "the", "context", ".", "Extra", "specified", "keys", "will", "be", "resolved", "from", "the", "context", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/context/logger.go#L63-L71
train
docker/distribution
context/logger.go
getLogrusLogger
func getLogrusLogger(ctx context.Context, keys ...interface{}) *logrus.Entry { var logger *logrus.Entry // Get a logger, if it is present. loggerInterface := ctx.Value(loggerKey{}) if loggerInterface != nil { if lgr, ok := loggerInterface.(*logrus.Entry); ok { logger = lgr } } if logger == nil { fields...
go
func getLogrusLogger(ctx context.Context, keys ...interface{}) *logrus.Entry { var logger *logrus.Entry // Get a logger, if it is present. loggerInterface := ctx.Value(loggerKey{}) if loggerInterface != nil { if lgr, ok := loggerInterface.(*logrus.Entry); ok { logger = lgr } } if logger == nil { fields...
[ "func", "getLogrusLogger", "(", "ctx", "context", ".", "Context", ",", "keys", "...", "interface", "{", "}", ")", "*", "logrus", ".", "Entry", "{", "var", "logger", "*", "logrus", ".", "Entry", "\n\n", "// Get a logger, if it is present.", "loggerInterface", "...
// GetLogrusLogger returns the logrus logger for the context. If one more keys // are provided, they will be resolved on the context and included in the // logger. Only use this function if specific logrus functionality is // required.
[ "GetLogrusLogger", "returns", "the", "logrus", "logger", "for", "the", "context", ".", "If", "one", "more", "keys", "are", "provided", "they", "will", "be", "resolved", "on", "the", "context", "and", "included", "in", "the", "logger", ".", "Only", "use", "...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/context/logger.go#L87-L121
train
docker/distribution
registry/handlers/context.go
getUserName
func getUserName(ctx context.Context, r *http.Request) string { username := dcontext.GetStringValue(ctx, auth.UserNameKey) // Fallback to request user with basic auth if username == "" { var ok bool uname, _, ok := basicAuth(r) if ok { username = uname } } return username }
go
func getUserName(ctx context.Context, r *http.Request) string { username := dcontext.GetStringValue(ctx, auth.UserNameKey) // Fallback to request user with basic auth if username == "" { var ok bool uname, _, ok := basicAuth(r) if ok { username = uname } } return username }
[ "func", "getUserName", "(", "ctx", "context", ".", "Context", ",", "r", "*", "http", ".", "Request", ")", "string", "{", "username", ":=", "dcontext", ".", "GetStringValue", "(", "ctx", ",", "auth", ".", "UserNameKey", ")", "\n\n", "// Fallback to request us...
// getUserName attempts to resolve a username from the context and request. If // a username cannot be resolved, the empty string is returned.
[ "getUserName", "attempts", "to", "resolve", "a", "username", "from", "the", "context", "and", "request", ".", "If", "a", "username", "cannot", "be", "resolved", "the", "empty", "string", "is", "returned", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/context.go#L82-L95
train
docker/distribution
registry/registry.go
NewRegistry
func NewRegistry(ctx context.Context, config *configuration.Configuration) (*Registry, error) { var err error ctx, err = configureLogging(ctx, config) if err != nil { return nil, fmt.Errorf("error configuring logger: %v", err) } configureBugsnag(config) // inject a logger into the uuid library. warns us if th...
go
func NewRegistry(ctx context.Context, config *configuration.Configuration) (*Registry, error) { var err error ctx, err = configureLogging(ctx, config) if err != nil { return nil, fmt.Errorf("error configuring logger: %v", err) } configureBugsnag(config) // inject a logger into the uuid library. warns us if th...
[ "func", "NewRegistry", "(", "ctx", "context", ".", "Context", ",", "config", "*", "configuration", ".", "Configuration", ")", "(", "*", "Registry", ",", "error", ")", "{", "var", "err", "error", "\n", "ctx", ",", "err", "=", "configureLogging", "(", "ctx...
// NewRegistry creates a new registry from a context and configuration struct.
[ "NewRegistry", "creates", "a", "new", "registry", "from", "a", "context", "and", "configuration", "struct", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/registry.go#L92-L126
train
docker/distribution
registry/registry.go
configureLogging
func configureLogging(ctx context.Context, config *configuration.Configuration) (context.Context, error) { log.SetLevel(logLevel(config.Log.Level)) formatter := config.Log.Formatter if formatter == "" { formatter = "text" // default formatter } switch formatter { case "json": log.SetFormatter(&log.JSONForma...
go
func configureLogging(ctx context.Context, config *configuration.Configuration) (context.Context, error) { log.SetLevel(logLevel(config.Log.Level)) formatter := config.Log.Formatter if formatter == "" { formatter = "text" // default formatter } switch formatter { case "json": log.SetFormatter(&log.JSONForma...
[ "func", "configureLogging", "(", "ctx", "context", ".", "Context", ",", "config", "*", "configuration", ".", "Configuration", ")", "(", "context", ".", "Context", ",", "error", ")", "{", "log", ".", "SetLevel", "(", "logLevel", "(", "config", ".", "Log", ...
// configureLogging prepares the context with a logger using the // configuration.
[ "configureLogging", "prepares", "the", "context", "with", "a", "logger", "using", "the", "configuration", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/registry.go#L272-L316
train
docker/distribution
registry/registry.go
configureBugsnag
func configureBugsnag(config *configuration.Configuration) { if config.Reporting.Bugsnag.APIKey == "" { return } bugsnagConfig := bugsnag.Configuration{ APIKey: config.Reporting.Bugsnag.APIKey, } if config.Reporting.Bugsnag.ReleaseStage != "" { bugsnagConfig.ReleaseStage = config.Reporting.Bugsnag.ReleaseSt...
go
func configureBugsnag(config *configuration.Configuration) { if config.Reporting.Bugsnag.APIKey == "" { return } bugsnagConfig := bugsnag.Configuration{ APIKey: config.Reporting.Bugsnag.APIKey, } if config.Reporting.Bugsnag.ReleaseStage != "" { bugsnagConfig.ReleaseStage = config.Reporting.Bugsnag.ReleaseSt...
[ "func", "configureBugsnag", "(", "config", "*", "configuration", ".", "Configuration", ")", "{", "if", "config", ".", "Reporting", ".", "Bugsnag", ".", "APIKey", "==", "\"", "\"", "{", "return", "\n", "}", "\n\n", "bugsnagConfig", ":=", "bugsnag", ".", "Co...
// configureBugsnag configures bugsnag reporting, if enabled
[ "configureBugsnag", "configures", "bugsnag", "reporting", "if", "enabled" ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/registry.go#L329-L352
train
docker/distribution
registry/registry.go
panicHandler
func panicHandler(handler http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer func() { if err := recover(); err != nil { log.Panic(fmt.Sprintf("%v", err)) } }() handler.ServeHTTP(w, r) }) }
go
func panicHandler(handler http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer func() { if err := recover(); err != nil { log.Panic(fmt.Sprintf("%v", err)) } }() handler.ServeHTTP(w, r) }) }
[ "func", "panicHandler", "(", "handler", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "return", "http", ".", "HandlerFunc", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "defer", "fun...
// panicHandler add an HTTP handler to web app. The handler recover the happening // panic. logrus.Panic transmits panic message to pre-config log hooks, which is // defined in config.yml.
[ "panicHandler", "add", "an", "HTTP", "handler", "to", "web", "app", ".", "The", "handler", "recover", "the", "happening", "panic", ".", "logrus", ".", "Panic", "transmits", "panic", "message", "to", "pre", "-", "config", "log", "hooks", "which", "is", "def...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/registry.go#L357-L366
train
docker/distribution
registry/storage/cache/memory/memory.go
NewInMemoryBlobDescriptorCacheProvider
func NewInMemoryBlobDescriptorCacheProvider() cache.BlobDescriptorCacheProvider { return &inMemoryBlobDescriptorCacheProvider{ global: newMapBlobDescriptorCache(), repositories: make(map[string]*mapBlobDescriptorCache), } }
go
func NewInMemoryBlobDescriptorCacheProvider() cache.BlobDescriptorCacheProvider { return &inMemoryBlobDescriptorCacheProvider{ global: newMapBlobDescriptorCache(), repositories: make(map[string]*mapBlobDescriptorCache), } }
[ "func", "NewInMemoryBlobDescriptorCacheProvider", "(", ")", "cache", ".", "BlobDescriptorCacheProvider", "{", "return", "&", "inMemoryBlobDescriptorCacheProvider", "{", "global", ":", "newMapBlobDescriptorCache", "(", ")", ",", "repositories", ":", "make", "(", "map", "...
// NewInMemoryBlobDescriptorCacheProvider returns a new mapped-based cache for // storing blob descriptor data.
[ "NewInMemoryBlobDescriptorCacheProvider", "returns", "a", "new", "mapped", "-", "based", "cache", "for", "storing", "blob", "descriptor", "data", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/cache/memory/memory.go#L21-L26
train
docker/distribution
registry/storage/registry.go
ManifestURLsAllowRegexp
func ManifestURLsAllowRegexp(r *regexp.Regexp) RegistryOption { return func(registry *registry) error { registry.manifestURLs.allow = r return nil } }
go
func ManifestURLsAllowRegexp(r *regexp.Regexp) RegistryOption { return func(registry *registry) error { registry.manifestURLs.allow = r return nil } }
[ "func", "ManifestURLsAllowRegexp", "(", "r", "*", "regexp", ".", "Regexp", ")", "RegistryOption", "{", "return", "func", "(", "registry", "*", "registry", ")", "error", "{", "registry", ".", "manifestURLs", ".", "allow", "=", "r", "\n", "return", "nil", "\...
// ManifestURLsAllowRegexp is a functional option for NewRegistry.
[ "ManifestURLsAllowRegexp", "is", "a", "functional", "option", "for", "NewRegistry", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/registry.go#L68-L73
train
docker/distribution
registry/storage/registry.go
ManifestURLsDenyRegexp
func ManifestURLsDenyRegexp(r *regexp.Regexp) RegistryOption { return func(registry *registry) error { registry.manifestURLs.deny = r return nil } }
go
func ManifestURLsDenyRegexp(r *regexp.Regexp) RegistryOption { return func(registry *registry) error { registry.manifestURLs.deny = r return nil } }
[ "func", "ManifestURLsDenyRegexp", "(", "r", "*", "regexp", ".", "Regexp", ")", "RegistryOption", "{", "return", "func", "(", "registry", "*", "registry", ")", "error", "{", "registry", ".", "manifestURLs", ".", "deny", "=", "r", "\n", "return", "nil", "\n"...
// ManifestURLsDenyRegexp is a functional option for NewRegistry.
[ "ManifestURLsDenyRegexp", "is", "a", "functional", "option", "for", "NewRegistry", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/registry.go#L76-L81
train
docker/distribution
registry/storage/registry.go
Schema1SigningKey
func Schema1SigningKey(key libtrust.PrivateKey) RegistryOption { return func(registry *registry) error { registry.schema1SigningKey = key return nil } }
go
func Schema1SigningKey(key libtrust.PrivateKey) RegistryOption { return func(registry *registry) error { registry.schema1SigningKey = key return nil } }
[ "func", "Schema1SigningKey", "(", "key", "libtrust", ".", "PrivateKey", ")", "RegistryOption", "{", "return", "func", "(", "registry", "*", "registry", ")", "error", "{", "registry", ".", "schema1SigningKey", "=", "key", "\n", "return", "nil", "\n", "}", "\n...
// Schema1SigningKey returns a functional option for NewRegistry. It sets the // key for signing all schema1 manifests.
[ "Schema1SigningKey", "returns", "a", "functional", "option", "for", "NewRegistry", ".", "It", "sets", "the", "key", "for", "signing", "all", "schema1", "manifests", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/registry.go#L85-L90
train
docker/distribution
registry/storage/registry.go
BlobDescriptorServiceFactory
func BlobDescriptorServiceFactory(factory distribution.BlobDescriptorServiceFactory) RegistryOption { return func(registry *registry) error { registry.blobDescriptorServiceFactory = factory return nil } }
go
func BlobDescriptorServiceFactory(factory distribution.BlobDescriptorServiceFactory) RegistryOption { return func(registry *registry) error { registry.blobDescriptorServiceFactory = factory return nil } }
[ "func", "BlobDescriptorServiceFactory", "(", "factory", "distribution", ".", "BlobDescriptorServiceFactory", ")", "RegistryOption", "{", "return", "func", "(", "registry", "*", "registry", ")", "error", "{", "registry", ".", "blobDescriptorServiceFactory", "=", "factory...
// BlobDescriptorServiceFactory returns a functional option for NewRegistry. It sets the // factory to create BlobDescriptorServiceFactory middleware.
[ "BlobDescriptorServiceFactory", "returns", "a", "functional", "option", "for", "NewRegistry", ".", "It", "sets", "the", "factory", "to", "create", "BlobDescriptorServiceFactory", "middleware", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/registry.go#L94-L99
train
docker/distribution
registry/storage/registry.go
BlobDescriptorCacheProvider
func BlobDescriptorCacheProvider(blobDescriptorCacheProvider cache.BlobDescriptorCacheProvider) RegistryOption { // TODO(aaronl): The duplication of statter across several objects is // ugly, and prevents us from using interface types in the registry // struct. Ideally, blobStore and blobServer should be lazily // ...
go
func BlobDescriptorCacheProvider(blobDescriptorCacheProvider cache.BlobDescriptorCacheProvider) RegistryOption { // TODO(aaronl): The duplication of statter across several objects is // ugly, and prevents us from using interface types in the registry // struct. Ideally, blobStore and blobServer should be lazily // ...
[ "func", "BlobDescriptorCacheProvider", "(", "blobDescriptorCacheProvider", "cache", ".", "BlobDescriptorCacheProvider", ")", "RegistryOption", "{", "// TODO(aaronl): The duplication of statter across several objects is", "// ugly, and prevents us from using interface types in the registry", ...
// BlobDescriptorCacheProvider returns a functional option for // NewRegistry. It creates a cached blob statter for use by the // registry.
[ "BlobDescriptorCacheProvider", "returns", "a", "functional", "option", "for", "NewRegistry", ".", "It", "creates", "a", "cached", "blob", "statter", "for", "use", "by", "the", "registry", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/registry.go#L104-L119
train
docker/distribution
registry/storage/registry.go
Repository
func (reg *registry) Repository(ctx context.Context, canonicalName reference.Named) (distribution.Repository, error) { var descriptorCache distribution.BlobDescriptorService if reg.blobDescriptorCacheProvider != nil { var err error descriptorCache, err = reg.blobDescriptorCacheProvider.RepositoryScoped(canonicalN...
go
func (reg *registry) Repository(ctx context.Context, canonicalName reference.Named) (distribution.Repository, error) { var descriptorCache distribution.BlobDescriptorService if reg.blobDescriptorCacheProvider != nil { var err error descriptorCache, err = reg.blobDescriptorCacheProvider.RepositoryScoped(canonicalN...
[ "func", "(", "reg", "*", "registry", ")", "Repository", "(", "ctx", "context", ".", "Context", ",", "canonicalName", "reference", ".", "Named", ")", "(", "distribution", ".", "Repository", ",", "error", ")", "{", "var", "descriptorCache", "distribution", "."...
// Repository returns an instance of the repository tied to the registry. // Instances should not be shared between goroutines but are cheap to // allocate. In general, they should be request scoped.
[ "Repository", "returns", "an", "instance", "of", "the", "repository", "tied", "to", "the", "registry", ".", "Instances", "should", "not", "be", "shared", "between", "goroutines", "but", "are", "cheap", "to", "allocate", ".", "In", "general", "they", "should", ...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/registry.go#L166-L182
train
docker/distribution
registry/storage/registry.go
Manifests
func (repo *repository) Manifests(ctx context.Context, options ...distribution.ManifestServiceOption) (distribution.ManifestService, error) { manifestLinkPathFns := []linkPathFunc{ // NOTE(stevvooe): Need to search through multiple locations since // 2.1.0 unintentionally linked into _layers. manifestRevisionLi...
go
func (repo *repository) Manifests(ctx context.Context, options ...distribution.ManifestServiceOption) (distribution.ManifestService, error) { manifestLinkPathFns := []linkPathFunc{ // NOTE(stevvooe): Need to search through multiple locations since // 2.1.0 unintentionally linked into _layers. manifestRevisionLi...
[ "func", "(", "repo", "*", "repository", ")", "Manifests", "(", "ctx", "context", ".", "Context", ",", "options", "...", "distribution", ".", "ManifestServiceOption", ")", "(", "distribution", ".", "ManifestService", ",", "error", ")", "{", "manifestLinkPathFns",...
// Manifests returns an instance of ManifestService. Instantiation is cheap and // may be context sensitive in the future. The instance should be used similar // to a request local.
[ "Manifests", "returns", "an", "instance", "of", "ManifestService", ".", "Instantiation", "is", "cheap", "and", "may", "be", "context", "sensitive", "in", "the", "future", ".", "The", "instance", "should", "be", "used", "similar", "to", "a", "request", "local",...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/registry.go#L217-L302
train
docker/distribution
registry/storage/registry.go
Blobs
func (repo *repository) Blobs(ctx context.Context) distribution.BlobStore { var statter distribution.BlobDescriptorService = &linkedBlobStatter{ blobStore: repo.blobStore, repository: repo, linkPathFns: []linkPathFunc{blobLinkPath}, } if repo.descriptorCache != nil { statter = cache.NewCachedBlobStatter(...
go
func (repo *repository) Blobs(ctx context.Context) distribution.BlobStore { var statter distribution.BlobDescriptorService = &linkedBlobStatter{ blobStore: repo.blobStore, repository: repo, linkPathFns: []linkPathFunc{blobLinkPath}, } if repo.descriptorCache != nil { statter = cache.NewCachedBlobStatter(...
[ "func", "(", "repo", "*", "repository", ")", "Blobs", "(", "ctx", "context", ".", "Context", ")", "distribution", ".", "BlobStore", "{", "var", "statter", "distribution", ".", "BlobDescriptorService", "=", "&", "linkedBlobStatter", "{", "blobStore", ":", "repo...
// Blobs returns an instance of the BlobStore. Instantiation is cheap and // may be context sensitive in the future. The instance should be used similar // to a request local.
[ "Blobs", "returns", "an", "instance", "of", "the", "BlobStore", ".", "Instantiation", "is", "cheap", "and", "may", "be", "context", "sensitive", "in", "the", "future", ".", "The", "instance", "should", "be", "used", "similar", "to", "a", "request", "local", ...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/registry.go#L307-L336
train
docker/distribution
notifications/endpoint.go
defaults
func (ec *EndpointConfig) defaults() { if ec.Timeout <= 0 { ec.Timeout = time.Second } if ec.Threshold <= 0 { ec.Threshold = 10 } if ec.Backoff <= 0 { ec.Backoff = time.Second } if ec.Transport == nil { ec.Transport = http.DefaultTransport.(*http.Transport) } }
go
func (ec *EndpointConfig) defaults() { if ec.Timeout <= 0 { ec.Timeout = time.Second } if ec.Threshold <= 0 { ec.Threshold = 10 } if ec.Backoff <= 0 { ec.Backoff = time.Second } if ec.Transport == nil { ec.Transport = http.DefaultTransport.(*http.Transport) } }
[ "func", "(", "ec", "*", "EndpointConfig", ")", "defaults", "(", ")", "{", "if", "ec", ".", "Timeout", "<=", "0", "{", "ec", ".", "Timeout", "=", "time", ".", "Second", "\n", "}", "\n\n", "if", "ec", ".", "Threshold", "<=", "0", "{", "ec", ".", ...
// defaults set any zero-valued fields to a reasonable default.
[ "defaults", "set", "any", "zero", "-", "valued", "fields", "to", "a", "reasonable", "default", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/notifications/endpoint.go#L23-L39
train
docker/distribution
notifications/endpoint.go
NewEndpoint
func NewEndpoint(name, url string, config EndpointConfig) *Endpoint { var endpoint Endpoint endpoint.name = name endpoint.url = url endpoint.EndpointConfig = config endpoint.defaults() endpoint.metrics = newSafeMetrics() // Configures the inmemory queue, retry, http pipeline. endpoint.Sink = newHTTPSink( end...
go
func NewEndpoint(name, url string, config EndpointConfig) *Endpoint { var endpoint Endpoint endpoint.name = name endpoint.url = url endpoint.EndpointConfig = config endpoint.defaults() endpoint.metrics = newSafeMetrics() // Configures the inmemory queue, retry, http pipeline. endpoint.Sink = newHTTPSink( end...
[ "func", "NewEndpoint", "(", "name", ",", "url", "string", ",", "config", "EndpointConfig", ")", "*", "Endpoint", "{", "var", "endpoint", "Endpoint", "\n", "endpoint", ".", "name", "=", "name", "\n", "endpoint", ".", "url", "=", "url", "\n", "endpoint", "...
// NewEndpoint returns a running endpoint, ready to receive events.
[ "NewEndpoint", "returns", "a", "running", "endpoint", "ready", "to", "receive", "events", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/notifications/endpoint.go#L55-L74
train
docker/distribution
notifications/endpoint.go
ReadMetrics
func (e *Endpoint) ReadMetrics(em *EndpointMetrics) { e.metrics.Lock() defer e.metrics.Unlock() *em = e.metrics.EndpointMetrics // Map still need to copied in a threadsafe manner. em.Statuses = make(map[string]int) for k, v := range e.metrics.Statuses { em.Statuses[k] = v } }
go
func (e *Endpoint) ReadMetrics(em *EndpointMetrics) { e.metrics.Lock() defer e.metrics.Unlock() *em = e.metrics.EndpointMetrics // Map still need to copied in a threadsafe manner. em.Statuses = make(map[string]int) for k, v := range e.metrics.Statuses { em.Statuses[k] = v } }
[ "func", "(", "e", "*", "Endpoint", ")", "ReadMetrics", "(", "em", "*", "EndpointMetrics", ")", "{", "e", ".", "metrics", ".", "Lock", "(", ")", "\n", "defer", "e", ".", "metrics", ".", "Unlock", "(", ")", "\n\n", "*", "em", "=", "e", ".", "metric...
// ReadMetrics populates em with metrics from the endpoint.
[ "ReadMetrics", "populates", "em", "with", "metrics", "from", "the", "endpoint", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/notifications/endpoint.go#L87-L97
train
docker/distribution
manifest/schema1/config_builder.go
NewConfigManifestBuilder
func NewConfigManifestBuilder(bs distribution.BlobService, pk libtrust.PrivateKey, ref reference.Named, configJSON []byte) distribution.ManifestBuilder { return &configManifestBuilder{ bs: bs, pk: pk, configJSON: configJSON, ref: ref, } }
go
func NewConfigManifestBuilder(bs distribution.BlobService, pk libtrust.PrivateKey, ref reference.Named, configJSON []byte) distribution.ManifestBuilder { return &configManifestBuilder{ bs: bs, pk: pk, configJSON: configJSON, ref: ref, } }
[ "func", "NewConfigManifestBuilder", "(", "bs", "distribution", ".", "BlobService", ",", "pk", "libtrust", ".", "PrivateKey", ",", "ref", "reference", ".", "Named", ",", "configJSON", "[", "]", "byte", ")", "distribution", ".", "ManifestBuilder", "{", "return", ...
// NewConfigManifestBuilder is used to build new manifests for the current // schema version from an image configuration and a set of descriptors. // It takes a BlobService so that it can add an empty tar to the blob store // if the resulting manifest needs empty layers.
[ "NewConfigManifestBuilder", "is", "used", "to", "build", "new", "manifests", "for", "the", "current", "schema", "version", "from", "an", "image", "configuration", "and", "a", "set", "of", "descriptors", ".", "It", "takes", "a", "BlobService", "so", "that", "it...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/schema1/config_builder.go#L55-L62
train
docker/distribution
manifest/schema1/config_builder.go
emptyTar
func (mb *configManifestBuilder) emptyTar(ctx context.Context) (digest.Digest, error) { if mb.emptyTarDigest != "" { // Already put an empty tar return mb.emptyTarDigest, nil } descriptor, err := mb.bs.Stat(ctx, digestSHA256GzippedEmptyTar) switch err { case nil: mb.emptyTarDigest = descriptor.Digest retu...
go
func (mb *configManifestBuilder) emptyTar(ctx context.Context) (digest.Digest, error) { if mb.emptyTarDigest != "" { // Already put an empty tar return mb.emptyTarDigest, nil } descriptor, err := mb.bs.Stat(ctx, digestSHA256GzippedEmptyTar) switch err { case nil: mb.emptyTarDigest = descriptor.Digest retu...
[ "func", "(", "mb", "*", "configManifestBuilder", ")", "emptyTar", "(", "ctx", "context", ".", "Context", ")", "(", "digest", ".", "Digest", ",", "error", ")", "{", "if", "mb", ".", "emptyTarDigest", "!=", "\"", "\"", "{", "// Already put an empty tar", "re...
// emptyTar pushes a compressed empty tar to the blob store if one doesn't // already exist, and returns its blobsum.
[ "emptyTar", "pushes", "a", "compressed", "empty", "tar", "to", "the", "blob", "store", "if", "one", "doesn", "t", "already", "exist", "and", "returns", "its", "blobsum", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/schema1/config_builder.go#L213-L239
train
docker/distribution
manifest/schema1/config_builder.go
MakeV1ConfigFromConfig
func MakeV1ConfigFromConfig(configJSON []byte, v1ID, parentV1ID string, throwaway bool) ([]byte, error) { // Top-level v1compatibility string should be a modified version of the // image config. var configAsMap map[string]*json.RawMessage if err := json.Unmarshal(configJSON, &configAsMap); err != nil { return nil...
go
func MakeV1ConfigFromConfig(configJSON []byte, v1ID, parentV1ID string, throwaway bool) ([]byte, error) { // Top-level v1compatibility string should be a modified version of the // image config. var configAsMap map[string]*json.RawMessage if err := json.Unmarshal(configJSON, &configAsMap); err != nil { return nil...
[ "func", "MakeV1ConfigFromConfig", "(", "configJSON", "[", "]", "byte", ",", "v1ID", ",", "parentV1ID", "string", ",", "throwaway", "bool", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// Top-level v1compatibility string should be a modified version of the", ...
// MakeV1ConfigFromConfig creates an legacy V1 image config from image config JSON
[ "MakeV1ConfigFromConfig", "creates", "an", "legacy", "V1", "image", "config", "from", "image", "config", "JSON" ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/schema1/config_builder.go#L259-L279
train
docker/distribution
registry/storage/driver/azure/azure.go
FromParameters
func FromParameters(parameters map[string]interface{}) (*Driver, error) { accountName, ok := parameters[paramAccountName] if !ok || fmt.Sprint(accountName) == "" { return nil, fmt.Errorf("no %s parameter provided", paramAccountName) } accountKey, ok := parameters[paramAccountKey] if !ok || fmt.Sprint(accountKey...
go
func FromParameters(parameters map[string]interface{}) (*Driver, error) { accountName, ok := parameters[paramAccountName] if !ok || fmt.Sprint(accountName) == "" { return nil, fmt.Errorf("no %s parameter provided", paramAccountName) } accountKey, ok := parameters[paramAccountKey] if !ok || fmt.Sprint(accountKey...
[ "func", "FromParameters", "(", "parameters", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "*", "Driver", ",", "error", ")", "{", "accountName", ",", "ok", ":=", "parameters", "[", "paramAccountName", "]", "\n", "if", "!", "ok", "||", "fm...
// FromParameters constructs a new Driver with a given parameters map.
[ "FromParameters", "constructs", "a", "new", "Driver", "with", "a", "given", "parameters", "map", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/azure/azure.go#L55-L77
train
docker/distribution
registry/storage/driver/azure/azure.go
New
func New(accountName, accountKey, container, realm string) (*Driver, error) { api, err := azure.NewClient(accountName, accountKey, realm, azure.DefaultAPIVersion, true) if err != nil { return nil, err } blobClient := api.GetBlobService() // Create registry container containerRef := blobClient.GetContainerRefe...
go
func New(accountName, accountKey, container, realm string) (*Driver, error) { api, err := azure.NewClient(accountName, accountKey, realm, azure.DefaultAPIVersion, true) if err != nil { return nil, err } blobClient := api.GetBlobService() // Create registry container containerRef := blobClient.GetContainerRefe...
[ "func", "New", "(", "accountName", ",", "accountKey", ",", "container", ",", "realm", "string", ")", "(", "*", "Driver", ",", "error", ")", "{", "api", ",", "err", ":=", "azure", ".", "NewClient", "(", "accountName", ",", "accountKey", ",", "realm", ",...
// New constructs a new Driver with the given Azure Storage Account credentials
[ "New", "constructs", "a", "new", "Driver", "with", "the", "given", "Azure", "Storage", "Account", "credentials" ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/azure/azure.go#L80-L98
train
docker/distribution
notifications/sinks.go
NewBroadcaster
func NewBroadcaster(sinks ...Sink) *Broadcaster { b := Broadcaster{ sinks: sinks, events: make(chan []Event), closed: make(chan chan struct{}), } // Start the broadcaster go b.run() return &b }
go
func NewBroadcaster(sinks ...Sink) *Broadcaster { b := Broadcaster{ sinks: sinks, events: make(chan []Event), closed: make(chan chan struct{}), } // Start the broadcaster go b.run() return &b }
[ "func", "NewBroadcaster", "(", "sinks", "...", "Sink", ")", "*", "Broadcaster", "{", "b", ":=", "Broadcaster", "{", "sinks", ":", "sinks", ",", "events", ":", "make", "(", "chan", "[", "]", "Event", ")", ",", "closed", ":", "make", "(", "chan", "chan...
// NewBroadcaster ... // Add appends one or more sinks to the list of sinks. The broadcaster // behavior will be affected by the properties of the sink. Generally, the // sink should accept all messages and deal with reliability on its own. Use // of EventQueue and RetryingSink should be used here.
[ "NewBroadcaster", "...", "Add", "appends", "one", "or", "more", "sinks", "to", "the", "list", "of", "sinks", ".", "The", "broadcaster", "behavior", "will", "be", "affected", "by", "the", "properties", "of", "the", "sink", ".", "Generally", "the", "sink", "...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/notifications/sinks.go#L31-L42
train
docker/distribution
notifications/sinks.go
newEventQueue
func newEventQueue(sink Sink, listeners ...eventQueueListener) *eventQueue { eq := eventQueue{ sink: sink, events: list.New(), listeners: listeners, } eq.cond = sync.NewCond(&eq.mu) go eq.run() return &eq }
go
func newEventQueue(sink Sink, listeners ...eventQueueListener) *eventQueue { eq := eventQueue{ sink: sink, events: list.New(), listeners: listeners, } eq.cond = sync.NewCond(&eq.mu) go eq.run() return &eq }
[ "func", "newEventQueue", "(", "sink", "Sink", ",", "listeners", "...", "eventQueueListener", ")", "*", "eventQueue", "{", "eq", ":=", "eventQueue", "{", "sink", ":", "sink", ",", "events", ":", "list", ".", "New", "(", ")", ",", "listeners", ":", "listen...
// newEventQueue returns a queue to the provided sink. If the updater is non- // nil, it will be called to update pending metrics on ingress and egress.
[ "newEventQueue", "returns", "a", "queue", "to", "the", "provided", "sink", ".", "If", "the", "updater", "is", "non", "-", "nil", "it", "will", "be", "called", "to", "update", "pending", "metrics", "on", "ingress", "and", "egress", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/notifications/sinks.go#L123-L133
train
docker/distribution
notifications/sinks.go
Write
func (eq *eventQueue) Write(events ...Event) error { eq.mu.Lock() defer eq.mu.Unlock() if eq.closed { return ErrSinkClosed } for _, listener := range eq.listeners { listener.ingress(events...) } eq.events.PushBack(events) eq.cond.Signal() // signal waiters return nil }
go
func (eq *eventQueue) Write(events ...Event) error { eq.mu.Lock() defer eq.mu.Unlock() if eq.closed { return ErrSinkClosed } for _, listener := range eq.listeners { listener.ingress(events...) } eq.events.PushBack(events) eq.cond.Signal() // signal waiters return nil }
[ "func", "(", "eq", "*", "eventQueue", ")", "Write", "(", "events", "...", "Event", ")", "error", "{", "eq", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "eq", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "if", "eq", ".", "closed", "{", "retu...
// Write accepts the events into the queue, only failing if the queue has // beend closed.
[ "Write", "accepts", "the", "events", "into", "the", "queue", "only", "failing", "if", "the", "queue", "has", "beend", "closed", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/notifications/sinks.go#L137-L152
train
docker/distribution
notifications/sinks.go
Close
func (eq *eventQueue) Close() error { eq.mu.Lock() defer eq.mu.Unlock() if eq.closed { return fmt.Errorf("eventqueue: already closed") } // set closed flag eq.closed = true eq.cond.Signal() // signal flushes queue eq.cond.Wait() // wait for signal from last flush return eq.sink.Close() }
go
func (eq *eventQueue) Close() error { eq.mu.Lock() defer eq.mu.Unlock() if eq.closed { return fmt.Errorf("eventqueue: already closed") } // set closed flag eq.closed = true eq.cond.Signal() // signal flushes queue eq.cond.Wait() // wait for signal from last flush return eq.sink.Close() }
[ "func", "(", "eq", "*", "eventQueue", ")", "Close", "(", ")", "error", "{", "eq", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "eq", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "if", "eq", ".", "closed", "{", "return", "fmt", ".", "Errorf",...
// Close shuts down the event queue, flushing
[ "Close", "shuts", "down", "the", "event", "queue", "flushing" ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/notifications/sinks.go#L155-L169
train
docker/distribution
notifications/sinks.go
next
func (eq *eventQueue) next() []Event { eq.mu.Lock() defer eq.mu.Unlock() for eq.events.Len() < 1 { if eq.closed { eq.cond.Broadcast() return nil } eq.cond.Wait() } front := eq.events.Front() block := front.Value.([]Event) eq.events.Remove(front) return block }
go
func (eq *eventQueue) next() []Event { eq.mu.Lock() defer eq.mu.Unlock() for eq.events.Len() < 1 { if eq.closed { eq.cond.Broadcast() return nil } eq.cond.Wait() } front := eq.events.Front() block := front.Value.([]Event) eq.events.Remove(front) return block }
[ "func", "(", "eq", "*", "eventQueue", ")", "next", "(", ")", "[", "]", "Event", "{", "eq", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "eq", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "for", "eq", ".", "events", ".", "Len", "(", ")", ...
// next encompasses the critical section of the run loop. When the queue is // empty, it will block on the condition. If new data arrives, it will wake // and return a block. When closed, a nil slice will be returned.
[ "next", "encompasses", "the", "critical", "section", "of", "the", "run", "loop", ".", "When", "the", "queue", "is", "empty", "it", "will", "block", "on", "the", "condition", ".", "If", "new", "data", "arrives", "it", "will", "wake", "and", "return", "a",...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/notifications/sinks.go#L193-L211
train
docker/distribution
notifications/sinks.go
Write
func (imts *ignoredSink) Write(events ...Event) error { var kept []Event for _, e := range events { if !imts.ignoreMediaTypes[e.Target.MediaType] { kept = append(kept, e) } } if len(kept) == 0 { return nil } var results []Event for _, e := range kept { if !imts.ignoreActions[e.Action] { results = ...
go
func (imts *ignoredSink) Write(events ...Event) error { var kept []Event for _, e := range events { if !imts.ignoreMediaTypes[e.Target.MediaType] { kept = append(kept, e) } } if len(kept) == 0 { return nil } var results []Event for _, e := range kept { if !imts.ignoreActions[e.Action] { results = ...
[ "func", "(", "imts", "*", "ignoredSink", ")", "Write", "(", "events", "...", "Event", ")", "error", "{", "var", "kept", "[", "]", "Event", "\n", "for", "_", ",", "e", ":=", "range", "events", "{", "if", "!", "imts", ".", "ignoreMediaTypes", "[", "e...
// Write discards events with ignored target media types and passes the rest // along.
[ "Write", "discards", "events", "with", "ignored", "target", "media", "types", "and", "passes", "the", "rest", "along", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/notifications/sinks.go#L245-L266
train
docker/distribution
notifications/sinks.go
write
func (rs *retryingSink) write(events ...Event) error { if err := rs.sink.Write(events...); err != nil { rs.failure() return err } rs.reset() return nil }
go
func (rs *retryingSink) write(events ...Event) error { if err := rs.sink.Write(events...); err != nil { rs.failure() return err } rs.reset() return nil }
[ "func", "(", "rs", "*", "retryingSink", ")", "write", "(", "events", "...", "Event", ")", "error", "{", "if", "err", ":=", "rs", ".", "sink", ".", "Write", "(", "events", "...", ")", ";", "err", "!=", "nil", "{", "rs", ".", "failure", "(", ")", ...
// write provides a helper that dispatches failure and success properly. Used // by write as the single-flight write call.
[ "write", "provides", "a", "helper", "that", "dispatches", "failure", "and", "success", "properly", ".", "Used", "by", "write", "as", "the", "single", "-", "flight", "write", "call", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/notifications/sinks.go#L350-L358
train
docker/distribution
notifications/sinks.go
wait
func (rs *retryingSink) wait(backoff time.Duration) { rs.mu.Unlock() defer rs.mu.Lock() // backoff here time.Sleep(backoff) }
go
func (rs *retryingSink) wait(backoff time.Duration) { rs.mu.Unlock() defer rs.mu.Lock() // backoff here time.Sleep(backoff) }
[ "func", "(", "rs", "*", "retryingSink", ")", "wait", "(", "backoff", "time", ".", "Duration", ")", "{", "rs", ".", "mu", ".", "Unlock", "(", ")", "\n", "defer", "rs", ".", "mu", ".", "Lock", "(", ")", "\n\n", "// backoff here", "time", ".", "Sleep"...
// wait backoff time against the sink, unlocking so others can proceed. Should // only be called by methods that currently have the mutex.
[ "wait", "backoff", "time", "against", "the", "sink", "unlocking", "so", "others", "can", "proceed", ".", "Should", "only", "be", "called", "by", "methods", "that", "currently", "have", "the", "mutex", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/notifications/sinks.go#L362-L368
train
docker/distribution
notifications/sinks.go
reset
func (rs *retryingSink) reset() { rs.failures.recent = 0 rs.failures.last = time.Time{} }
go
func (rs *retryingSink) reset() { rs.failures.recent = 0 rs.failures.last = time.Time{} }
[ "func", "(", "rs", "*", "retryingSink", ")", "reset", "(", ")", "{", "rs", ".", "failures", ".", "recent", "=", "0", "\n", "rs", ".", "failures", ".", "last", "=", "time", ".", "Time", "{", "}", "\n", "}" ]
// reset marks a successful call.
[ "reset", "marks", "a", "successful", "call", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/notifications/sinks.go#L371-L374
train
docker/distribution
notifications/sinks.go
failure
func (rs *retryingSink) failure() { rs.failures.recent++ rs.failures.last = time.Now().UTC() }
go
func (rs *retryingSink) failure() { rs.failures.recent++ rs.failures.last = time.Now().UTC() }
[ "func", "(", "rs", "*", "retryingSink", ")", "failure", "(", ")", "{", "rs", ".", "failures", ".", "recent", "++", "\n", "rs", ".", "failures", ".", "last", "=", "time", ".", "Now", "(", ")", ".", "UTC", "(", ")", "\n", "}" ]
// failure records a failure.
[ "failure", "records", "a", "failure", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/notifications/sinks.go#L377-L380
train
docker/distribution
notifications/sinks.go
proceed
func (rs *retryingSink) proceed() bool { return rs.failures.recent < rs.failures.threshold || time.Now().UTC().After(rs.failures.last.Add(rs.failures.backoff)) }
go
func (rs *retryingSink) proceed() bool { return rs.failures.recent < rs.failures.threshold || time.Now().UTC().After(rs.failures.last.Add(rs.failures.backoff)) }
[ "func", "(", "rs", "*", "retryingSink", ")", "proceed", "(", ")", "bool", "{", "return", "rs", ".", "failures", ".", "recent", "<", "rs", ".", "failures", ".", "threshold", "||", "time", ".", "Now", "(", ")", ".", "UTC", "(", ")", ".", "After", "...
// proceed returns true if the call should proceed based on circuit breaker // heuristics.
[ "proceed", "returns", "true", "if", "the", "call", "should", "proceed", "based", "on", "circuit", "breaker", "heuristics", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/notifications/sinks.go#L384-L387
train
docker/distribution
registry/auth/token/stringset.go
newStringSet
func newStringSet(keys ...string) stringSet { ss := make(stringSet, len(keys)) ss.add(keys...) return ss }
go
func newStringSet(keys ...string) stringSet { ss := make(stringSet, len(keys)) ss.add(keys...) return ss }
[ "func", "newStringSet", "(", "keys", "...", "string", ")", "stringSet", "{", "ss", ":=", "make", "(", "stringSet", ",", "len", "(", "keys", ")", ")", "\n", "ss", ".", "add", "(", "keys", "...", ")", "\n", "return", "ss", "\n", "}" ]
// NewStringSet creates a new StringSet with the given strings.
[ "NewStringSet", "creates", "a", "new", "StringSet", "with", "the", "given", "strings", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/auth/token/stringset.go#L7-L11
train
docker/distribution
registry/auth/token/stringset.go
add
func (ss stringSet) add(keys ...string) { for _, key := range keys { ss[key] = struct{}{} } }
go
func (ss stringSet) add(keys ...string) { for _, key := range keys { ss[key] = struct{}{} } }
[ "func", "(", "ss", "stringSet", ")", "add", "(", "keys", "...", "string", ")", "{", "for", "_", ",", "key", ":=", "range", "keys", "{", "ss", "[", "key", "]", "=", "struct", "{", "}", "{", "}", "\n", "}", "\n", "}" ]
// Add inserts the given keys into this StringSet.
[ "Add", "inserts", "the", "given", "keys", "into", "this", "StringSet", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/auth/token/stringset.go#L14-L18
train
docker/distribution
registry/auth/token/stringset.go
contains
func (ss stringSet) contains(key string) bool { _, ok := ss[key] return ok }
go
func (ss stringSet) contains(key string) bool { _, ok := ss[key] return ok }
[ "func", "(", "ss", "stringSet", ")", "contains", "(", "key", "string", ")", "bool", "{", "_", ",", "ok", ":=", "ss", "[", "key", "]", "\n", "return", "ok", "\n", "}" ]
// Contains returns whether the given key is in this StringSet.
[ "Contains", "returns", "whether", "the", "given", "key", "is", "in", "this", "StringSet", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/auth/token/stringset.go#L21-L24
train
docker/distribution
registry/auth/token/stringset.go
keys
func (ss stringSet) keys() []string { keys := make([]string, 0, len(ss)) for key := range ss { keys = append(keys, key) } return keys }
go
func (ss stringSet) keys() []string { keys := make([]string, 0, len(ss)) for key := range ss { keys = append(keys, key) } return keys }
[ "func", "(", "ss", "stringSet", ")", "keys", "(", ")", "[", "]", "string", "{", "keys", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "ss", ")", ")", "\n\n", "for", "key", ":=", "range", "ss", "{", "keys", "=", "append", "...
// Keys returns a slice of all keys in this StringSet.
[ "Keys", "returns", "a", "slice", "of", "all", "keys", "in", "this", "StringSet", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/auth/token/stringset.go#L27-L35
train
docker/distribution
registry/storage/driver/gcs/gcs.go
New
func New(params driverParameters) (storagedriver.StorageDriver, error) { rootDirectory := strings.Trim(params.rootDirectory, "/") if rootDirectory != "" { rootDirectory += "/" } if params.chunkSize <= 0 || params.chunkSize%minChunkSize != 0 { return nil, fmt.Errorf("Invalid chunksize: %d is not a positive multi...
go
func New(params driverParameters) (storagedriver.StorageDriver, error) { rootDirectory := strings.Trim(params.rootDirectory, "/") if rootDirectory != "" { rootDirectory += "/" } if params.chunkSize <= 0 || params.chunkSize%minChunkSize != 0 { return nil, fmt.Errorf("Invalid chunksize: %d is not a positive multi...
[ "func", "New", "(", "params", "driverParameters", ")", "(", "storagedriver", ".", "StorageDriver", ",", "error", ")", "{", "rootDirectory", ":=", "strings", ".", "Trim", "(", "params", ".", "rootDirectory", ",", "\"", "\"", ")", "\n", "if", "rootDirectory", ...
// New constructs a new driver
[ "New", "constructs", "a", "new", "driver" ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/gcs/gcs.go#L214-L238
train
docker/distribution
registry/storage/driver/gcs/gcs.go
Cancel
func (w *writer) Cancel() error { w.closed = true err := storageDeleteObject(cloud.NewContext(dummyProjectID, w.client), w.bucket, w.name) if err != nil { if status, ok := err.(*googleapi.Error); ok { if status.Code == http.StatusNotFound { err = nil } } } return err }
go
func (w *writer) Cancel() error { w.closed = true err := storageDeleteObject(cloud.NewContext(dummyProjectID, w.client), w.bucket, w.name) if err != nil { if status, ok := err.(*googleapi.Error); ok { if status.Code == http.StatusNotFound { err = nil } } } return err }
[ "func", "(", "w", "*", "writer", ")", "Cancel", "(", ")", "error", "{", "w", ".", "closed", "=", "true", "\n", "err", ":=", "storageDeleteObject", "(", "cloud", ".", "NewContext", "(", "dummyProjectID", ",", "w", ".", "client", ")", ",", "w", ".", ...
// Cancel removes any written content from this FileWriter.
[ "Cancel", "removes", "any", "written", "content", "from", "this", "FileWriter", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/gcs/gcs.go#L374-L385
train
docker/distribution
registry/storage/driver/gcs/gcs.go
Commit
func (w *writer) Commit() error { if err := w.checkClosed(); err != nil { return err } w.closed = true // no session started yet just perform a simple upload if w.sessionURI == "" { err := retry(func() error { wc := storage.NewWriter(cloud.NewContext(dummyProjectID, w.client), w.bucket, w.name) wc.Cont...
go
func (w *writer) Commit() error { if err := w.checkClosed(); err != nil { return err } w.closed = true // no session started yet just perform a simple upload if w.sessionURI == "" { err := retry(func() error { wc := storage.NewWriter(cloud.NewContext(dummyProjectID, w.client), w.bucket, w.name) wc.Cont...
[ "func", "(", "w", "*", "writer", ")", "Commit", "(", ")", "error", "{", "if", "err", ":=", "w", ".", "checkClosed", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "w", ".", "closed", "=", "true", "\n\n", "// no session ...
// Commit flushes all content written to this FileWriter and makes it // available for future calls to StorageDriver.GetContent and // StorageDriver.Reader.
[ "Commit", "flushes", "all", "content", "written", "to", "this", "FileWriter", "and", "makes", "it", "available", "for", "future", "calls", "to", "StorageDriver", ".", "GetContent", "and", "StorageDriver", ".", "Reader", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/gcs/gcs.go#L445-L485
train
docker/distribution
registry/storage/driver/gcs/gcs.go
listAll
func (d *driver) listAll(context context.Context, prefix string) ([]string, error) { list := make([]string, 0, 64) query := &storage.Query{} query.Prefix = prefix query.Versions = false for { objects, err := storageListObjects(d.context(context), d.bucket, query) if err != nil { return nil, err } for _,...
go
func (d *driver) listAll(context context.Context, prefix string) ([]string, error) { list := make([]string, 0, 64) query := &storage.Query{} query.Prefix = prefix query.Versions = false for { objects, err := storageListObjects(d.context(context), d.bucket, query) if err != nil { return nil, err } for _,...
[ "func", "(", "d", "*", "driver", ")", "listAll", "(", "context", "context", ".", "Context", ",", "prefix", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "list", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "64", ")", ...
// listAll recursively lists all names of objects stored at "prefix" and its subpaths.
[ "listAll", "recursively", "lists", "all", "names", "of", "objects", "stored", "at", "prefix", "and", "its", "subpaths", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/gcs/gcs.go#L701-L725
train
docker/distribution
registry/storage/driver/gcs/gcs.go
URLFor
func (d *driver) URLFor(context context.Context, path string, options map[string]interface{}) (string, error) { if d.privateKey == nil { return "", storagedriver.ErrUnsupportedMethod{} } name := d.pathToKey(path) methodString := "GET" method, ok := options["method"] if ok { methodString, ok = method.(string)...
go
func (d *driver) URLFor(context context.Context, path string, options map[string]interface{}) (string, error) { if d.privateKey == nil { return "", storagedriver.ErrUnsupportedMethod{} } name := d.pathToKey(path) methodString := "GET" method, ok := options["method"] if ok { methodString, ok = method.(string)...
[ "func", "(", "d", "*", "driver", ")", "URLFor", "(", "context", "context", ".", "Context", ",", "path", "string", ",", "options", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "string", ",", "error", ")", "{", "if", "d", ".", "private...
// URLFor returns a URL which may be used to retrieve the content stored at // the given path, possibly using the given options. // Returns ErrUnsupportedMethod if this driver has no privateKey
[ "URLFor", "returns", "a", "URL", "which", "may", "be", "used", "to", "retrieve", "the", "content", "stored", "at", "the", "given", "path", "possibly", "using", "the", "given", "options", ".", "Returns", "ErrUnsupportedMethod", "if", "this", "driver", "has", ...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/gcs/gcs.go#L803-L834
train
docker/distribution
notifications/bridge.go
NewRequestRecord
func NewRequestRecord(id string, r *http.Request) RequestRecord { return RequestRecord{ ID: id, Addr: context.RemoteAddr(r), Host: r.Host, Method: r.Method, UserAgent: r.UserAgent(), } }
go
func NewRequestRecord(id string, r *http.Request) RequestRecord { return RequestRecord{ ID: id, Addr: context.RemoteAddr(r), Host: r.Host, Method: r.Method, UserAgent: r.UserAgent(), } }
[ "func", "NewRequestRecord", "(", "id", "string", ",", "r", "*", "http", ".", "Request", ")", "RequestRecord", "{", "return", "RequestRecord", "{", "ID", ":", "id", ",", "Addr", ":", "context", ".", "RemoteAddr", "(", "r", ")", ",", "Host", ":", "r", ...
// NewRequestRecord builds a RequestRecord for use in NewBridge from an // http.Request, associating it with a request id.
[ "NewRequestRecord", "builds", "a", "RequestRecord", "for", "use", "in", "NewBridge", "from", "an", "http", ".", "Request", "associating", "it", "with", "a", "request", "id", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/notifications/bridge.go#L48-L56
train
docker/distribution
notifications/bridge.go
createEvent
func (b *bridge) createEvent(action string) *Event { event := createEvent(action) event.Source = b.source event.Actor = b.actor event.Request = b.request return event }
go
func (b *bridge) createEvent(action string) *Event { event := createEvent(action) event.Source = b.source event.Actor = b.actor event.Request = b.request return event }
[ "func", "(", "b", "*", "bridge", ")", "createEvent", "(", "action", "string", ")", "*", "Event", "{", "event", ":=", "createEvent", "(", "action", ")", "\n", "event", ".", "Source", "=", "b", ".", "source", "\n", "event", ".", "Actor", "=", "b", "....
// createEvent creates an event with actor and source populated.
[ "createEvent", "creates", "an", "event", "with", "actor", "and", "source", "populated", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/notifications/bridge.go#L209-L216
train
docker/distribution
notifications/bridge.go
createEvent
func createEvent(action string) *Event { return &Event{ ID: uuid.Generate().String(), Timestamp: time.Now(), Action: action, } }
go
func createEvent(action string) *Event { return &Event{ ID: uuid.Generate().String(), Timestamp: time.Now(), Action: action, } }
[ "func", "createEvent", "(", "action", "string", ")", "*", "Event", "{", "return", "&", "Event", "{", "ID", ":", "uuid", ".", "Generate", "(", ")", ".", "String", "(", ")", ",", "Timestamp", ":", "time", ".", "Now", "(", ")", ",", "Action", ":", "...
// createEvent returns a new event, timestamped, with the specified action.
[ "createEvent", "returns", "a", "new", "event", "timestamped", "with", "the", "specified", "action", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/notifications/bridge.go#L219-L225
train
docker/distribution
registry/storage/tagstore.go
Tag
func (ts *tagStore) Tag(ctx context.Context, tag string, desc distribution.Descriptor) error { currentPath, err := pathFor(manifestTagCurrentPathSpec{ name: ts.repository.Named().Name(), tag: tag, }) if err != nil { return err } lbs := ts.linkedBlobStore(ctx, tag) // Link into the index if err := lbs.l...
go
func (ts *tagStore) Tag(ctx context.Context, tag string, desc distribution.Descriptor) error { currentPath, err := pathFor(manifestTagCurrentPathSpec{ name: ts.repository.Named().Name(), tag: tag, }) if err != nil { return err } lbs := ts.linkedBlobStore(ctx, tag) // Link into the index if err := lbs.l...
[ "func", "(", "ts", "*", "tagStore", ")", "Tag", "(", "ctx", "context", ".", "Context", ",", "tag", "string", ",", "desc", "distribution", ".", "Descriptor", ")", "error", "{", "currentPath", ",", "err", ":=", "pathFor", "(", "manifestTagCurrentPathSpec", "...
// Tag tags the digest with the given tag, updating the the store to point at // the current tag. The digest must point to a manifest.
[ "Tag", "tags", "the", "digest", "with", "the", "given", "tag", "updating", "the", "the", "store", "to", "point", "at", "the", "current", "tag", ".", "The", "digest", "must", "point", "to", "a", "manifest", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/tagstore.go#L55-L74
train
docker/distribution
registry/storage/tagstore.go
Get
func (ts *tagStore) Get(ctx context.Context, tag string) (distribution.Descriptor, error) { currentPath, err := pathFor(manifestTagCurrentPathSpec{ name: ts.repository.Named().Name(), tag: tag, }) if err != nil { return distribution.Descriptor{}, err } revision, err := ts.blobStore.readlink(ctx, currentPa...
go
func (ts *tagStore) Get(ctx context.Context, tag string) (distribution.Descriptor, error) { currentPath, err := pathFor(manifestTagCurrentPathSpec{ name: ts.repository.Named().Name(), tag: tag, }) if err != nil { return distribution.Descriptor{}, err } revision, err := ts.blobStore.readlink(ctx, currentPa...
[ "func", "(", "ts", "*", "tagStore", ")", "Get", "(", "ctx", "context", ".", "Context", ",", "tag", "string", ")", "(", "distribution", ".", "Descriptor", ",", "error", ")", "{", "currentPath", ",", "err", ":=", "pathFor", "(", "manifestTagCurrentPathSpec",...
// resolve the current revision for name and tag.
[ "resolve", "the", "current", "revision", "for", "name", "and", "tag", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/tagstore.go#L77-L98
train
docker/distribution
registry/storage/tagstore.go
Untag
func (ts *tagStore) Untag(ctx context.Context, tag string) error { tagPath, err := pathFor(manifestTagPathSpec{ name: ts.repository.Named().Name(), tag: tag, }) if err != nil { return err } if err := ts.blobStore.driver.Delete(ctx, tagPath); err != nil { switch err.(type) { case storagedriver.PathNotFo...
go
func (ts *tagStore) Untag(ctx context.Context, tag string) error { tagPath, err := pathFor(manifestTagPathSpec{ name: ts.repository.Named().Name(), tag: tag, }) if err != nil { return err } if err := ts.blobStore.driver.Delete(ctx, tagPath); err != nil { switch err.(type) { case storagedriver.PathNotFo...
[ "func", "(", "ts", "*", "tagStore", ")", "Untag", "(", "ctx", "context", ".", "Context", ",", "tag", "string", ")", "error", "{", "tagPath", ",", "err", ":=", "pathFor", "(", "manifestTagPathSpec", "{", "name", ":", "ts", ".", "repository", ".", "Named...
// Untag removes the tag association
[ "Untag", "removes", "the", "tag", "association" ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/tagstore.go#L101-L120
train
docker/distribution
registry/storage/tagstore.go
linkedBlobStore
func (ts *tagStore) linkedBlobStore(ctx context.Context, tag string) *linkedBlobStore { return &linkedBlobStore{ blobStore: ts.blobStore, repository: ts.repository, ctx: ctx, linkPathFns: []linkPathFunc{func(name string, dgst digest.Digest) (string, error) { return pathFor(manifestTagIndexEntryLinkP...
go
func (ts *tagStore) linkedBlobStore(ctx context.Context, tag string) *linkedBlobStore { return &linkedBlobStore{ blobStore: ts.blobStore, repository: ts.repository, ctx: ctx, linkPathFns: []linkPathFunc{func(name string, dgst digest.Digest) (string, error) { return pathFor(manifestTagIndexEntryLinkP...
[ "func", "(", "ts", "*", "tagStore", ")", "linkedBlobStore", "(", "ctx", "context", ".", "Context", ",", "tag", "string", ")", "*", "linkedBlobStore", "{", "return", "&", "linkedBlobStore", "{", "blobStore", ":", "ts", ".", "blobStore", ",", "repository", "...
// linkedBlobStore returns the linkedBlobStore for the named tag, allowing one // to index manifest blobs by tag name. While the tag store doesn't map // precisely to the linked blob store, using this ensures the links are // managed via the same code path.
[ "linkedBlobStore", "returns", "the", "linkedBlobStore", "for", "the", "named", "tag", "allowing", "one", "to", "index", "manifest", "blobs", "by", "tag", "name", ".", "While", "the", "tag", "store", "doesn", "t", "map", "precisely", "to", "the", "linked", "b...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/tagstore.go#L126-L140
train
docker/distribution
registry/storage/tagstore.go
Lookup
func (ts *tagStore) Lookup(ctx context.Context, desc distribution.Descriptor) ([]string, error) { allTags, err := ts.All(ctx) switch err.(type) { case distribution.ErrRepositoryUnknown: // This tag store has been initialized but not yet populated break case nil: break default: return nil, err } var tags...
go
func (ts *tagStore) Lookup(ctx context.Context, desc distribution.Descriptor) ([]string, error) { allTags, err := ts.All(ctx) switch err.(type) { case distribution.ErrRepositoryUnknown: // This tag store has been initialized but not yet populated break case nil: break default: return nil, err } var tags...
[ "func", "(", "ts", "*", "tagStore", ")", "Lookup", "(", "ctx", "context", ".", "Context", ",", "desc", "distribution", ".", "Descriptor", ")", "(", "[", "]", "string", ",", "error", ")", "{", "allTags", ",", "err", ":=", "ts", ".", "All", "(", "ctx...
// Lookup recovers a list of tags which refer to this digest. When a manifest is deleted by // digest, tag entries which point to it need to be recovered to avoid dangling tags.
[ "Lookup", "recovers", "a", "list", "of", "tags", "which", "refer", "to", "this", "digest", ".", "When", "a", "manifest", "is", "deleted", "by", "digest", "tag", "entries", "which", "point", "to", "it", "need", "to", "be", "recovered", "to", "avoid", "dan...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/tagstore.go#L144-L179
train
docker/distribution
registry/storage/driver/middleware/storagemiddleware.go
Get
func Get(name string, options map[string]interface{}, storageDriver storagedriver.StorageDriver) (storagedriver.StorageDriver, error) { if storageMiddlewares != nil { if initFunc, exists := storageMiddlewares[name]; exists { return initFunc(storageDriver, options) } } return nil, fmt.Errorf("no storage middl...
go
func Get(name string, options map[string]interface{}, storageDriver storagedriver.StorageDriver) (storagedriver.StorageDriver, error) { if storageMiddlewares != nil { if initFunc, exists := storageMiddlewares[name]; exists { return initFunc(storageDriver, options) } } return nil, fmt.Errorf("no storage middl...
[ "func", "Get", "(", "name", "string", ",", "options", "map", "[", "string", "]", "interface", "{", "}", ",", "storageDriver", "storagedriver", ".", "StorageDriver", ")", "(", "storagedriver", ".", "StorageDriver", ",", "error", ")", "{", "if", "storageMiddle...
// Get constructs a StorageMiddleware with the given options using the named backend.
[ "Get", "constructs", "a", "StorageMiddleware", "with", "the", "given", "options", "using", "the", "named", "backend", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/middleware/storagemiddleware.go#L31-L39
train
docker/distribution
context/http.go
RemoteAddr
func RemoteAddr(r *http.Request) string { if prior := r.Header.Get("X-Forwarded-For"); prior != "" { proxies := strings.Split(prior, ",") if len(proxies) > 0 { remoteAddr := strings.Trim(proxies[0], " ") if parseIP(remoteAddr) != nil { return remoteAddr } } } // X-Real-Ip is less supported, but wo...
go
func RemoteAddr(r *http.Request) string { if prior := r.Header.Get("X-Forwarded-For"); prior != "" { proxies := strings.Split(prior, ",") if len(proxies) > 0 { remoteAddr := strings.Trim(proxies[0], " ") if parseIP(remoteAddr) != nil { return remoteAddr } } } // X-Real-Ip is less supported, but wo...
[ "func", "RemoteAddr", "(", "r", "*", "http", ".", "Request", ")", "string", "{", "if", "prior", ":=", "r", ".", "Header", ".", "Get", "(", "\"", "\"", ")", ";", "prior", "!=", "\"", "\"", "{", "proxies", ":=", "strings", ".", "Split", "(", "prior...
// RemoteAddr extracts the remote address of the request, taking into // account proxy headers.
[ "RemoteAddr", "extracts", "the", "remote", "address", "of", "the", "request", "taking", "into", "account", "proxy", "headers", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/context/http.go#L33-L52
train
docker/distribution
context/http.go
RemoteIP
func RemoteIP(r *http.Request) string { addr := RemoteAddr(r) // Try parsing it as "IP:port" if ip, _, err := net.SplitHostPort(addr); err == nil { return ip } return addr }
go
func RemoteIP(r *http.Request) string { addr := RemoteAddr(r) // Try parsing it as "IP:port" if ip, _, err := net.SplitHostPort(addr); err == nil { return ip } return addr }
[ "func", "RemoteIP", "(", "r", "*", "http", ".", "Request", ")", "string", "{", "addr", ":=", "RemoteAddr", "(", "r", ")", "\n\n", "// Try parsing it as \"IP:port\"", "if", "ip", ",", "_", ",", "err", ":=", "net", ".", "SplitHostPort", "(", "addr", ")", ...
// RemoteIP extracts the remote IP of the request, taking into // account proxy headers.
[ "RemoteIP", "extracts", "the", "remote", "IP", "of", "the", "request", "taking", "into", "account", "proxy", "headers", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/context/http.go#L56-L65
train
docker/distribution
context/http.go
WithRequest
func WithRequest(ctx context.Context, r *http.Request) context.Context { if ctx.Value("http.request") != nil { // NOTE(stevvooe): This needs to be considered a programming error. It // is unlikely that we'd want to have more than one request in // context. panic("only one request per context") } return &htt...
go
func WithRequest(ctx context.Context, r *http.Request) context.Context { if ctx.Value("http.request") != nil { // NOTE(stevvooe): This needs to be considered a programming error. It // is unlikely that we'd want to have more than one request in // context. panic("only one request per context") } return &htt...
[ "func", "WithRequest", "(", "ctx", "context", ".", "Context", ",", "r", "*", "http", ".", "Request", ")", "context", ".", "Context", "{", "if", "ctx", ".", "Value", "(", "\"", "\"", ")", "!=", "nil", "{", "// NOTE(stevvooe): This needs to be considered a pro...
// WithRequest places the request on the context. The context of the request // is assigned a unique id, available at "http.request.id". The request itself // is available at "http.request". Other common attributes are available under // the prefix "http.request.". If a request is already present on the context, // thi...
[ "WithRequest", "places", "the", "request", "on", "the", "context", ".", "The", "context", "of", "the", "request", "is", "assigned", "a", "unique", "id", "available", "at", "http", ".", "request", ".", "id", ".", "The", "request", "itself", "is", "available...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/context/http.go#L72-L86
train
docker/distribution
context/http.go
GetRequest
func GetRequest(ctx context.Context) (*http.Request, error) { if r, ok := ctx.Value("http.request").(*http.Request); r != nil && ok { return r, nil } return nil, ErrNoRequestContext }
go
func GetRequest(ctx context.Context) (*http.Request, error) { if r, ok := ctx.Value("http.request").(*http.Request); r != nil && ok { return r, nil } return nil, ErrNoRequestContext }
[ "func", "GetRequest", "(", "ctx", "context", ".", "Context", ")", "(", "*", "http", ".", "Request", ",", "error", ")", "{", "if", "r", ",", "ok", ":=", "ctx", ".", "Value", "(", "\"", "\"", ")", ".", "(", "*", "http", ".", "Request", ")", ";", ...
// GetRequest returns the http request in the given context. Returns // ErrNoRequestContext if the context does not have an http request associated // with it.
[ "GetRequest", "returns", "the", "http", "request", "in", "the", "given", "context", ".", "Returns", "ErrNoRequestContext", "if", "the", "context", "does", "not", "have", "an", "http", "request", "associated", "with", "it", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/context/http.go#L91-L96
train
docker/distribution
context/http.go
WithResponseWriter
func WithResponseWriter(ctx context.Context, w http.ResponseWriter) (context.Context, http.ResponseWriter) { irw := instrumentedResponseWriter{ ResponseWriter: w, Context: ctx, } return &irw, &irw }
go
func WithResponseWriter(ctx context.Context, w http.ResponseWriter) (context.Context, http.ResponseWriter) { irw := instrumentedResponseWriter{ ResponseWriter: w, Context: ctx, } return &irw, &irw }
[ "func", "WithResponseWriter", "(", "ctx", "context", ".", "Context", ",", "w", "http", ".", "ResponseWriter", ")", "(", "context", ".", "Context", ",", "http", ".", "ResponseWriter", ")", "{", "irw", ":=", "instrumentedResponseWriter", "{", "ResponseWriter", "...
// WithResponseWriter returns a new context and response writer that makes // interesting response statistics available within the context.
[ "WithResponseWriter", "returns", "a", "new", "context", "and", "response", "writer", "that", "makes", "interesting", "response", "statistics", "available", "within", "the", "context", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/context/http.go#L106-L112
train
docker/distribution
context/http.go
GetResponseWriter
func GetResponseWriter(ctx context.Context) (http.ResponseWriter, error) { v := ctx.Value("http.response") rw, ok := v.(http.ResponseWriter) if !ok || rw == nil { return nil, ErrNoResponseWriterContext } return rw, nil }
go
func GetResponseWriter(ctx context.Context) (http.ResponseWriter, error) { v := ctx.Value("http.response") rw, ok := v.(http.ResponseWriter) if !ok || rw == nil { return nil, ErrNoResponseWriterContext } return rw, nil }
[ "func", "GetResponseWriter", "(", "ctx", "context", ".", "Context", ")", "(", "http", ".", "ResponseWriter", ",", "error", ")", "{", "v", ":=", "ctx", ".", "Value", "(", "\"", "\"", ")", "\n\n", "rw", ",", "ok", ":=", "v", ".", "(", "http", ".", ...
// GetResponseWriter returns the http.ResponseWriter from the provided // context. If not present, ErrNoResponseWriterContext is returned. The // returned instance provides instrumentation in the context.
[ "GetResponseWriter", "returns", "the", "http", ".", "ResponseWriter", "from", "the", "provided", "context", ".", "If", "not", "present", "ErrNoResponseWriterContext", "is", "returned", ".", "The", "returned", "instance", "provides", "instrumentation", "in", "the", "...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/context/http.go#L117-L126
train
docker/distribution
context/http.go
GetResponseLogger
func GetResponseLogger(ctx context.Context) Logger { l := getLogrusLogger(ctx, "http.response.written", "http.response.status", "http.response.contenttype") duration := Since(ctx, "http.request.startedat") if duration > 0 { l = l.WithField("http.response.duration", duration.String()) } return l }
go
func GetResponseLogger(ctx context.Context) Logger { l := getLogrusLogger(ctx, "http.response.written", "http.response.status", "http.response.contenttype") duration := Since(ctx, "http.request.startedat") if duration > 0 { l = l.WithField("http.response.duration", duration.String()) } return l }
[ "func", "GetResponseLogger", "(", "ctx", "context", ".", "Context", ")", "Logger", "{", "l", ":=", "getLogrusLogger", "(", "ctx", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", "\n\n", "duration", ":=", "Since", "(", "ctx", ",", "\"", "\"", ...
// GetResponseLogger reads the current response stats and builds a logger. // Because the values are read at call time, pushing a logger returned from // this function on the context will lead to missing or invalid data. Only // call this at the end of a request, after the response has been written.
[ "GetResponseLogger", "reads", "the", "current", "response", "stats", "and", "builds", "a", "logger", ".", "Because", "the", "values", "are", "read", "at", "call", "time", "pushing", "a", "logger", "returned", "from", "this", "function", "on", "the", "context",...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/context/http.go#L163-L176
train
docker/distribution
registry/client/auth/challenge/authchallenge.go
ResponseChallenges
func ResponseChallenges(resp *http.Response) []Challenge { if resp.StatusCode == http.StatusUnauthorized { // Parse the WWW-Authenticate Header and store the challenges // on this endpoint object. return parseAuthHeader(resp.Header) } return nil }
go
func ResponseChallenges(resp *http.Response) []Challenge { if resp.StatusCode == http.StatusUnauthorized { // Parse the WWW-Authenticate Header and store the challenges // on this endpoint object. return parseAuthHeader(resp.Header) } return nil }
[ "func", "ResponseChallenges", "(", "resp", "*", "http", ".", "Response", ")", "[", "]", "Challenge", "{", "if", "resp", ".", "StatusCode", "==", "http", ".", "StatusUnauthorized", "{", "// Parse the WWW-Authenticate Header and store the challenges", "// on this endpoint...
// ResponseChallenges returns a list of authorization challenges // for the given http Response. Challenges are only checked if // the response status code was a 401.
[ "ResponseChallenges", "returns", "a", "list", "of", "authorization", "challenges", "for", "the", "given", "http", "Response", ".", "Challenges", "are", "only", "checked", "if", "the", "response", "status", "code", "was", "a", "401", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/client/auth/challenge/authchallenge.go#L134-L142
train
docker/distribution
registry/storage/purgeuploads.go
PurgeUploads
func PurgeUploads(ctx context.Context, driver storageDriver.StorageDriver, olderThan time.Time, actuallyDelete bool) ([]string, []error) { logrus.Infof("PurgeUploads starting: olderThan=%s, actuallyDelete=%t", olderThan, actuallyDelete) uploadData, errors := getOutstandingUploads(ctx, driver) var deleted []string f...
go
func PurgeUploads(ctx context.Context, driver storageDriver.StorageDriver, olderThan time.Time, actuallyDelete bool) ([]string, []error) { logrus.Infof("PurgeUploads starting: olderThan=%s, actuallyDelete=%t", olderThan, actuallyDelete) uploadData, errors := getOutstandingUploads(ctx, driver) var deleted []string f...
[ "func", "PurgeUploads", "(", "ctx", "context", ".", "Context", ",", "driver", "storageDriver", ".", "StorageDriver", ",", "olderThan", "time", ".", "Time", ",", "actuallyDelete", "bool", ")", "(", "[", "]", "string", ",", "[", "]", "error", ")", "{", "lo...
// PurgeUploads deletes files from the upload directory // created before olderThan. The list of files deleted and errors // encountered are returned
[ "PurgeUploads", "deletes", "files", "from", "the", "upload", "directory", "created", "before", "olderThan", ".", "The", "list", "of", "files", "deleted", "and", "errors", "encountered", "are", "returned" ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/purgeuploads.go#L32-L54
train
docker/distribution
registry/storage/purgeuploads.go
getOutstandingUploads
func getOutstandingUploads(ctx context.Context, driver storageDriver.StorageDriver) (map[string]uploadData, []error) { var errors []error uploads := make(map[string]uploadData) inUploadDir := false root, err := pathFor(repositoriesRootPathSpec{}) if err != nil { return uploads, append(errors, err) } err = dr...
go
func getOutstandingUploads(ctx context.Context, driver storageDriver.StorageDriver) (map[string]uploadData, []error) { var errors []error uploads := make(map[string]uploadData) inUploadDir := false root, err := pathFor(repositoriesRootPathSpec{}) if err != nil { return uploads, append(errors, err) } err = dr...
[ "func", "getOutstandingUploads", "(", "ctx", "context", ".", "Context", ",", "driver", "storageDriver", ".", "StorageDriver", ")", "(", "map", "[", "string", "]", "uploadData", ",", "[", "]", "error", ")", "{", "var", "errors", "[", "]", "error", "\n", "...
// getOutstandingUploads walks the upload directory, collecting files // which could be eligible for deletion. The only reliable way to // classify the age of a file is with the date stored in the startedAt // file, so gather files by UUID with a date from startedAt.
[ "getOutstandingUploads", "walks", "the", "upload", "directory", "collecting", "files", "which", "could", "be", "eligible", "for", "deletion", ".", "The", "only", "reliable", "way", "to", "classify", "the", "age", "of", "a", "file", "is", "with", "the", "date",...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/purgeuploads.go#L60-L112
train
docker/distribution
registry/storage/purgeuploads.go
uuidFromPath
func uuidFromPath(path string) (string, bool) { components := strings.Split(path, "/") for i := len(components) - 1; i >= 0; i-- { if u, err := uuid.Parse(components[i]); err == nil { return u.String(), i == len(components)-1 } } return "", false }
go
func uuidFromPath(path string) (string, bool) { components := strings.Split(path, "/") for i := len(components) - 1; i >= 0; i-- { if u, err := uuid.Parse(components[i]); err == nil { return u.String(), i == len(components)-1 } } return "", false }
[ "func", "uuidFromPath", "(", "path", "string", ")", "(", "string", ",", "bool", ")", "{", "components", ":=", "strings", ".", "Split", "(", "path", ",", "\"", "\"", ")", "\n", "for", "i", ":=", "len", "(", "components", ")", "-", "1", ";", "i", "...
// uuidFromPath extracts the upload UUID from a given path // If the UUID is the last path component, this is the containing // directory for all upload files
[ "uuidFromPath", "extracts", "the", "upload", "UUID", "from", "a", "given", "path", "If", "the", "UUID", "is", "the", "last", "path", "component", "this", "is", "the", "containing", "directory", "for", "all", "upload", "files" ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/purgeuploads.go#L117-L125
train
docker/distribution
registry/storage/purgeuploads.go
readStartedAtFile
func readStartedAtFile(driver storageDriver.StorageDriver, path string) (time.Time, error) { // todo:(richardscothern) - pass in a context startedAtBytes, err := driver.GetContent(context.Background(), path) if err != nil { return time.Now(), err } startedAt, err := time.Parse(time.RFC3339, string(startedAtBytes...
go
func readStartedAtFile(driver storageDriver.StorageDriver, path string) (time.Time, error) { // todo:(richardscothern) - pass in a context startedAtBytes, err := driver.GetContent(context.Background(), path) if err != nil { return time.Now(), err } startedAt, err := time.Parse(time.RFC3339, string(startedAtBytes...
[ "func", "readStartedAtFile", "(", "driver", "storageDriver", ".", "StorageDriver", ",", "path", "string", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "// todo:(richardscothern) - pass in a context", "startedAtBytes", ",", "err", ":=", "driver", ".", "Ge...
// readStartedAtFile reads the date from an upload's startedAtFile
[ "readStartedAtFile", "reads", "the", "date", "from", "an", "upload", "s", "startedAtFile" ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/purgeuploads.go#L128-L139
train
docker/distribution
registry/storage/filereader.go
newFileReader
func newFileReader(ctx context.Context, driver storagedriver.StorageDriver, path string, size int64) (*fileReader, error) { return &fileReader{ ctx: ctx, driver: driver, path: path, size: size, }, nil }
go
func newFileReader(ctx context.Context, driver storagedriver.StorageDriver, path string, size int64) (*fileReader, error) { return &fileReader{ ctx: ctx, driver: driver, path: path, size: size, }, nil }
[ "func", "newFileReader", "(", "ctx", "context", ".", "Context", ",", "driver", "storagedriver", ".", "StorageDriver", ",", "path", "string", ",", "size", "int64", ")", "(", "*", "fileReader", ",", "error", ")", "{", "return", "&", "fileReader", "{", "ctx",...
// newFileReader initializes a file reader for the remote file. The reader // takes on the size and path that must be determined externally with a stat // call. The reader operates optimistically, assuming that the file is already // there.
[ "newFileReader", "initializes", "a", "file", "reader", "for", "the", "remote", "file", ".", "The", "reader", "takes", "on", "the", "size", "and", "path", "that", "must", "be", "determined", "externally", "with", "a", "stat", "call", ".", "The", "reader", "...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/filereader.go#L44-L51
train
docker/distribution
registry/storage/filereader.go
reader
func (fr *fileReader) reader() (io.Reader, error) { if fr.err != nil { return nil, fr.err } if fr.rc != nil { return fr.brd, nil } // If we don't have a reader, open one up. rc, err := fr.driver.Reader(fr.ctx, fr.path, fr.offset) if err != nil { switch err := err.(type) { case storagedriver.PathNotFoun...
go
func (fr *fileReader) reader() (io.Reader, error) { if fr.err != nil { return nil, fr.err } if fr.rc != nil { return fr.brd, nil } // If we don't have a reader, open one up. rc, err := fr.driver.Reader(fr.ctx, fr.path, fr.offset) if err != nil { switch err := err.(type) { case storagedriver.PathNotFoun...
[ "func", "(", "fr", "*", "fileReader", ")", "reader", "(", ")", "(", "io", ".", "Reader", ",", "error", ")", "{", "if", "fr", ".", "err", "!=", "nil", "{", "return", "nil", ",", "fr", ".", "err", "\n", "}", "\n\n", "if", "fr", ".", "rc", "!=",...
// reader prepares the current reader at the lrs offset, ensuring its buffered // and ready to go.
[ "reader", "prepares", "the", "current", "reader", "at", "the", "lrs", "offset", "ensuring", "its", "buffered", "and", "ready", "to", "go", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/filereader.go#L111-L144
train
docker/distribution
registry/storage/filereader.go
reset
func (fr *fileReader) reset() { if fr.err != nil { return } if fr.rc != nil { fr.rc.Close() fr.rc = nil } }
go
func (fr *fileReader) reset() { if fr.err != nil { return } if fr.rc != nil { fr.rc.Close() fr.rc = nil } }
[ "func", "(", "fr", "*", "fileReader", ")", "reset", "(", ")", "{", "if", "fr", ".", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "if", "fr", ".", "rc", "!=", "nil", "{", "fr", ".", "rc", ".", "Close", "(", ")", "\n", "fr", ".", "rc",...
// resetReader resets the reader, forcing the read method to open up a new // connection and rebuild the buffered reader. This should be called when the // offset and the reader will become out of sync, such as during a seek // operation.
[ "resetReader", "resets", "the", "reader", "forcing", "the", "read", "method", "to", "open", "up", "a", "new", "connection", "and", "rebuild", "the", "buffered", "reader", ".", "This", "should", "be", "called", "when", "the", "offset", "and", "the", "reader",...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/filereader.go#L150-L158
train
docker/distribution
registry/handlers/blobupload.go
StartBlobUpload
func (buh *blobUploadHandler) StartBlobUpload(w http.ResponseWriter, r *http.Request) { var options []distribution.BlobCreateOption fromRepo := r.FormValue("from") mountDigest := r.FormValue("mount") if mountDigest != "" && fromRepo != "" { opt, err := buh.createBlobMountOption(fromRepo, mountDigest) if opt !...
go
func (buh *blobUploadHandler) StartBlobUpload(w http.ResponseWriter, r *http.Request) { var options []distribution.BlobCreateOption fromRepo := r.FormValue("from") mountDigest := r.FormValue("mount") if mountDigest != "" && fromRepo != "" { opt, err := buh.createBlobMountOption(fromRepo, mountDigest) if opt !...
[ "func", "(", "buh", "*", "blobUploadHandler", ")", "StartBlobUpload", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "var", "options", "[", "]", "distribution", ".", "BlobCreateOption", "\n\n", "fromRepo", ":=", "...
// StartBlobUpload begins the blob upload process and allocates a server-side // blob writer session, optionally mounting the blob from a separate repository.
[ "StartBlobUpload", "begins", "the", "blob", "upload", "process", "and", "allocates", "a", "server", "-", "side", "blob", "writer", "session", "optionally", "mounting", "the", "blob", "from", "a", "separate", "repository", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/blobupload.go#L107-L145
train
docker/distribution
registry/handlers/blobupload.go
GetUploadStatus
func (buh *blobUploadHandler) GetUploadStatus(w http.ResponseWriter, r *http.Request) { if buh.Upload == nil { buh.Errors = append(buh.Errors, v2.ErrorCodeBlobUploadUnknown) return } // TODO(dmcgowan): Set last argument to false in blobUploadResponse when // resumable upload is supported. This will enable retu...
go
func (buh *blobUploadHandler) GetUploadStatus(w http.ResponseWriter, r *http.Request) { if buh.Upload == nil { buh.Errors = append(buh.Errors, v2.ErrorCodeBlobUploadUnknown) return } // TODO(dmcgowan): Set last argument to false in blobUploadResponse when // resumable upload is supported. This will enable retu...
[ "func", "(", "buh", "*", "blobUploadHandler", ")", "GetUploadStatus", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "if", "buh", ".", "Upload", "==", "nil", "{", "buh", ".", "Errors", "=", "append", "(", "b...
// GetUploadStatus returns the status of a given upload, identified by id.
[ "GetUploadStatus", "returns", "the", "status", "of", "a", "given", "upload", "identified", "by", "id", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/blobupload.go#L148-L164
train
docker/distribution
registry/handlers/blobupload.go
PatchBlobData
func (buh *blobUploadHandler) PatchBlobData(w http.ResponseWriter, r *http.Request) { if buh.Upload == nil { buh.Errors = append(buh.Errors, v2.ErrorCodeBlobUploadUnknown) return } ct := r.Header.Get("Content-Type") if ct != "" && ct != "application/octet-stream" { buh.Errors = append(buh.Errors, errcode.Err...
go
func (buh *blobUploadHandler) PatchBlobData(w http.ResponseWriter, r *http.Request) { if buh.Upload == nil { buh.Errors = append(buh.Errors, v2.ErrorCodeBlobUploadUnknown) return } ct := r.Header.Get("Content-Type") if ct != "" && ct != "application/octet-stream" { buh.Errors = append(buh.Errors, errcode.Err...
[ "func", "(", "buh", "*", "blobUploadHandler", ")", "PatchBlobData", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "if", "buh", ".", "Upload", "==", "nil", "{", "buh", ".", "Errors", "=", "append", "(", "buh...
// PatchBlobData writes data to an upload.
[ "PatchBlobData", "writes", "data", "to", "an", "upload", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/blobupload.go#L167-L193
train
docker/distribution
registry/handlers/blobupload.go
PutBlobUploadComplete
func (buh *blobUploadHandler) PutBlobUploadComplete(w http.ResponseWriter, r *http.Request) { if buh.Upload == nil { buh.Errors = append(buh.Errors, v2.ErrorCodeBlobUploadUnknown) return } dgstStr := r.FormValue("digest") // TODO(stevvooe): Support multiple digest parameters! if dgstStr == "" { // no digest...
go
func (buh *blobUploadHandler) PutBlobUploadComplete(w http.ResponseWriter, r *http.Request) { if buh.Upload == nil { buh.Errors = append(buh.Errors, v2.ErrorCodeBlobUploadUnknown) return } dgstStr := r.FormValue("digest") // TODO(stevvooe): Support multiple digest parameters! if dgstStr == "" { // no digest...
[ "func", "(", "buh", "*", "blobUploadHandler", ")", "PutBlobUploadComplete", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "if", "buh", ".", "Upload", "==", "nil", "{", "buh", ".", "Errors", "=", "append", "("...
// PutBlobUploadComplete takes the final request of a blob upload. The // request may include all the blob data or no blob data. Any data // provided is received and verified. If successful, the blob is linked // into the blob store and 201 Created is returned with the canonical // url of the blob.
[ "PutBlobUploadComplete", "takes", "the", "final", "request", "of", "a", "blob", "upload", ".", "The", "request", "may", "include", "all", "the", "blob", "data", "or", "no", "blob", "data", ".", "Any", "data", "provided", "is", "received", "and", "verified", ...
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/blobupload.go#L200-L267
train
docker/distribution
registry/handlers/blobupload.go
CancelBlobUpload
func (buh *blobUploadHandler) CancelBlobUpload(w http.ResponseWriter, r *http.Request) { if buh.Upload == nil { buh.Errors = append(buh.Errors, v2.ErrorCodeBlobUploadUnknown) return } w.Header().Set("Docker-Upload-UUID", buh.UUID) if err := buh.Upload.Cancel(buh); err != nil { dcontext.GetLogger(buh).Errorf(...
go
func (buh *blobUploadHandler) CancelBlobUpload(w http.ResponseWriter, r *http.Request) { if buh.Upload == nil { buh.Errors = append(buh.Errors, v2.ErrorCodeBlobUploadUnknown) return } w.Header().Set("Docker-Upload-UUID", buh.UUID) if err := buh.Upload.Cancel(buh); err != nil { dcontext.GetLogger(buh).Errorf(...
[ "func", "(", "buh", "*", "blobUploadHandler", ")", "CancelBlobUpload", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "if", "buh", ".", "Upload", "==", "nil", "{", "buh", ".", "Errors", "=", "append", "(", "...
// CancelBlobUpload cancels an in-progress upload of a blob.
[ "CancelBlobUpload", "cancels", "an", "in", "-", "progress", "upload", "of", "a", "blob", "." ]
3226863cbcba6dbc2f6c83a37b28126c934af3f8
https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/blobupload.go#L270-L283
train