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 | registry/handlers/blobupload.go | blobUploadResponse | func (buh *blobUploadHandler) blobUploadResponse(w http.ResponseWriter, r *http.Request, fresh bool) error {
// TODO(stevvooe): Need a better way to manage the upload state automatically.
buh.State.Name = buh.Repository.Named().Name()
buh.State.UUID = buh.Upload.ID()
buh.Upload.Close()
buh.State.Offset = buh.Uploa... | go | func (buh *blobUploadHandler) blobUploadResponse(w http.ResponseWriter, r *http.Request, fresh bool) error {
// TODO(stevvooe): Need a better way to manage the upload state automatically.
buh.State.Name = buh.Repository.Named().Name()
buh.State.UUID = buh.Upload.ID()
buh.Upload.Close()
buh.State.Offset = buh.Uploa... | [
"func",
"(",
"buh",
"*",
"blobUploadHandler",
")",
"blobUploadResponse",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"fresh",
"bool",
")",
"error",
"{",
"// TODO(stevvooe): Need a better way to manage the upload state automatic... | // blobUploadResponse provides a standard request for uploading blobs and
// chunk responses. This sets the correct headers but the response status is
// left to the caller. The fresh argument is used to ensure that new blob
// uploads always start at a 0 offset. This allows disabling resumable push by
// always return... | [
"blobUploadResponse",
"provides",
"a",
"standard",
"request",
"for",
"uploading",
"blobs",
"and",
"chunk",
"responses",
".",
"This",
"sets",
"the",
"correct",
"headers",
"but",
"the",
"response",
"status",
"is",
"left",
"to",
"the",
"caller",
".",
"The",
"fres... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/blobupload.go#L290-L326 | train |
docker/distribution | registry/handlers/blobupload.go | createBlobMountOption | func (buh *blobUploadHandler) createBlobMountOption(fromRepo, mountDigest string) (distribution.BlobCreateOption, error) {
dgst, err := digest.Parse(mountDigest)
if err != nil {
return nil, err
}
ref, err := reference.WithName(fromRepo)
if err != nil {
return nil, err
}
canonical, err := reference.WithDige... | go | func (buh *blobUploadHandler) createBlobMountOption(fromRepo, mountDigest string) (distribution.BlobCreateOption, error) {
dgst, err := digest.Parse(mountDigest)
if err != nil {
return nil, err
}
ref, err := reference.WithName(fromRepo)
if err != nil {
return nil, err
}
canonical, err := reference.WithDige... | [
"func",
"(",
"buh",
"*",
"blobUploadHandler",
")",
"createBlobMountOption",
"(",
"fromRepo",
",",
"mountDigest",
"string",
")",
"(",
"distribution",
".",
"BlobCreateOption",
",",
"error",
")",
"{",
"dgst",
",",
"err",
":=",
"digest",
".",
"Parse",
"(",
"moun... | // mountBlob attempts to mount a blob from another repository by its digest. If
// successful, the blob is linked into the blob store and 201 Created is
// returned with the canonical url of the blob. | [
"mountBlob",
"attempts",
"to",
"mount",
"a",
"blob",
"from",
"another",
"repository",
"by",
"its",
"digest",
".",
"If",
"successful",
"the",
"blob",
"is",
"linked",
"into",
"the",
"blob",
"store",
"and",
"201",
"Created",
"is",
"returned",
"with",
"the",
"... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/blobupload.go#L331-L348 | train |
docker/distribution | registry/handlers/blobupload.go | writeBlobCreatedHeaders | func (buh *blobUploadHandler) writeBlobCreatedHeaders(w http.ResponseWriter, desc distribution.Descriptor) error {
ref, err := reference.WithDigest(buh.Repository.Named(), desc.Digest)
if err != nil {
return err
}
blobURL, err := buh.urlBuilder.BuildBlobURL(ref)
if err != nil {
return err
}
w.Header().Set("... | go | func (buh *blobUploadHandler) writeBlobCreatedHeaders(w http.ResponseWriter, desc distribution.Descriptor) error {
ref, err := reference.WithDigest(buh.Repository.Named(), desc.Digest)
if err != nil {
return err
}
blobURL, err := buh.urlBuilder.BuildBlobURL(ref)
if err != nil {
return err
}
w.Header().Set("... | [
"func",
"(",
"buh",
"*",
"blobUploadHandler",
")",
"writeBlobCreatedHeaders",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"desc",
"distribution",
".",
"Descriptor",
")",
"error",
"{",
"ref",
",",
"err",
":=",
"reference",
".",
"WithDigest",
"(",
"buh",
"."... | // writeBlobCreatedHeaders writes the standard headers describing a newly
// created blob. A 201 Created is written as well as the canonical URL and
// blob digest. | [
"writeBlobCreatedHeaders",
"writes",
"the",
"standard",
"headers",
"describing",
"a",
"newly",
"created",
"blob",
".",
"A",
"201",
"Created",
"is",
"written",
"as",
"well",
"as",
"the",
"canonical",
"URL",
"and",
"blob",
"digest",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/blobupload.go#L353-L368 | train |
docker/distribution | registry/storage/signedmanifesthandler.go | verifyManifest | func (ms *signedManifestHandler) verifyManifest(ctx context.Context, mnfst schema1.SignedManifest, skipDependencyVerification bool) error {
var errs distribution.ErrManifestVerification
if len(mnfst.Name) > reference.NameTotalLengthMax {
errs = append(errs,
distribution.ErrManifestNameInvalid{
Name: mnfst... | go | func (ms *signedManifestHandler) verifyManifest(ctx context.Context, mnfst schema1.SignedManifest, skipDependencyVerification bool) error {
var errs distribution.ErrManifestVerification
if len(mnfst.Name) > reference.NameTotalLengthMax {
errs = append(errs,
distribution.ErrManifestNameInvalid{
Name: mnfst... | [
"func",
"(",
"ms",
"*",
"signedManifestHandler",
")",
"verifyManifest",
"(",
"ctx",
"context",
".",
"Context",
",",
"mnfst",
"schema1",
".",
"SignedManifest",
",",
"skipDependencyVerification",
"bool",
")",
"error",
"{",
"var",
"errs",
"distribution",
".",
"ErrM... | // verifyManifest ensures that the manifest content is valid from the
// perspective of the registry. It ensures that the signature is valid for the
// enclosed payload. As a policy, the registry only tries to store valid
// content, leaving trust policies of that content up to consumers. | [
"verifyManifest",
"ensures",
"that",
"the",
"manifest",
"content",
"is",
"valid",
"from",
"the",
"perspective",
"of",
"the",
"registry",
".",
"It",
"ensures",
"that",
"the",
"signature",
"is",
"valid",
"for",
"the",
"enclosed",
"payload",
".",
"As",
"a",
"po... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/signedmanifesthandler.go#L87-L142 | train |
docker/distribution | context/context.go | WithValues | func WithValues(ctx context.Context, m map[string]interface{}) context.Context {
mo := make(map[string]interface{}, len(m)) // make our own copy.
for k, v := range m {
mo[k] = v
}
return stringMapContext{
Context: ctx,
m: mo,
}
} | go | func WithValues(ctx context.Context, m map[string]interface{}) context.Context {
mo := make(map[string]interface{}, len(m)) // make our own copy.
for k, v := range m {
mo[k] = v
}
return stringMapContext{
Context: ctx,
m: mo,
}
} | [
"func",
"WithValues",
"(",
"ctx",
"context",
".",
"Context",
",",
"m",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"context",
".",
"Context",
"{",
"mo",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"len",
"("... | // WithValues returns a context that proxies lookups through a map. Only
// supports string keys. | [
"WithValues",
"returns",
"a",
"context",
"that",
"proxies",
"lookups",
"through",
"a",
"map",
".",
"Only",
"supports",
"string",
"keys",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/context/context.go#L53-L63 | train |
docker/distribution | context/util.go | Since | func Since(ctx context.Context, key interface{}) time.Duration {
if startedAt, ok := ctx.Value(key).(time.Time); ok {
return time.Since(startedAt)
}
return 0
} | go | func Since(ctx context.Context, key interface{}) time.Duration {
if startedAt, ok := ctx.Value(key).(time.Time); ok {
return time.Since(startedAt)
}
return 0
} | [
"func",
"Since",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
"interface",
"{",
"}",
")",
"time",
".",
"Duration",
"{",
"if",
"startedAt",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"key",
")",
".",
"(",
"time",
".",
"Time",
")",
";",
"ok",... | // Since looks up key, which should be a time.Time, and returns the duration
// since that time. If the key is not found, the value returned will be zero.
// This is helpful when inferring metrics related to context execution times. | [
"Since",
"looks",
"up",
"key",
"which",
"should",
"be",
"a",
"time",
".",
"Time",
"and",
"returns",
"the",
"duration",
"since",
"that",
"time",
".",
"If",
"the",
"key",
"is",
"not",
"found",
"the",
"value",
"returned",
"will",
"be",
"zero",
".",
"This"... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/context/util.go#L11-L16 | train |
docker/distribution | context/util.go | GetStringValue | func GetStringValue(ctx context.Context, key interface{}) (value string) {
if valuev, ok := ctx.Value(key).(string); ok {
value = valuev
}
return value
} | go | func GetStringValue(ctx context.Context, key interface{}) (value string) {
if valuev, ok := ctx.Value(key).(string); ok {
value = valuev
}
return value
} | [
"func",
"GetStringValue",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
"interface",
"{",
"}",
")",
"(",
"value",
"string",
")",
"{",
"if",
"valuev",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"key",
")",
".",
"(",
"string",
")",
";",
"ok",
... | // GetStringValue returns a string value from the context. The empty string
// will be returned if not found. | [
"GetStringValue",
"returns",
"a",
"string",
"value",
"from",
"the",
"context",
".",
"The",
"empty",
"string",
"will",
"be",
"returned",
"if",
"not",
"found",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/context/util.go#L20-L25 | train |
docker/distribution | manifest/schema2/builder.go | NewManifestBuilder | func NewManifestBuilder(bs distribution.BlobService, configMediaType string, configJSON []byte) distribution.ManifestBuilder {
mb := &builder{
bs: bs,
configMediaType: configMediaType,
configJSON: make([]byte, len(configJSON)),
}
copy(mb.configJSON, configJSON)
return mb
} | go | func NewManifestBuilder(bs distribution.BlobService, configMediaType string, configJSON []byte) distribution.ManifestBuilder {
mb := &builder{
bs: bs,
configMediaType: configMediaType,
configJSON: make([]byte, len(configJSON)),
}
copy(mb.configJSON, configJSON)
return mb
} | [
"func",
"NewManifestBuilder",
"(",
"bs",
"distribution",
".",
"BlobService",
",",
"configMediaType",
"string",
",",
"configJSON",
"[",
"]",
"byte",
")",
"distribution",
".",
"ManifestBuilder",
"{",
"mb",
":=",
"&",
"builder",
"{",
"bs",
":",
"bs",
",",
"conf... | // NewManifestBuilder is used to build new manifests for the current schema
// version. It takes a BlobService so it can publish the configuration blob
// as part of the Build process. | [
"NewManifestBuilder",
"is",
"used",
"to",
"build",
"new",
"manifests",
"for",
"the",
"current",
"schema",
"version",
".",
"It",
"takes",
"a",
"BlobService",
"so",
"it",
"can",
"publish",
"the",
"configuration",
"blob",
"as",
"part",
"of",
"the",
"Build",
"pr... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/schema2/builder.go#L29-L38 | train |
docker/distribution | registry/storage/linkedblobstore.go | Create | func (lbs *linkedBlobStore) Create(ctx context.Context, options ...distribution.BlobCreateOption) (distribution.BlobWriter, error) {
dcontext.GetLogger(ctx).Debug("(*linkedBlobStore).Writer")
var opts distribution.CreateOptions
for _, option := range options {
err := option.Apply(&opts)
if err != nil {
retu... | go | func (lbs *linkedBlobStore) Create(ctx context.Context, options ...distribution.BlobCreateOption) (distribution.BlobWriter, error) {
dcontext.GetLogger(ctx).Debug("(*linkedBlobStore).Writer")
var opts distribution.CreateOptions
for _, option := range options {
err := option.Apply(&opts)
if err != nil {
retu... | [
"func",
"(",
"lbs",
"*",
"linkedBlobStore",
")",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"options",
"...",
"distribution",
".",
"BlobCreateOption",
")",
"(",
"distribution",
".",
"BlobWriter",
",",
"error",
")",
"{",
"dcontext",
".",
"GetLogger... | // Writer begins a blob write session, returning a handle. | [
"Writer",
"begins",
"a",
"blob",
"write",
"session",
"returning",
"a",
"handle",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/linkedblobstore.go#L128-L175 | train |
docker/distribution | registry/storage/linkedblobstore.go | newBlobUpload | func (lbs *linkedBlobStore) newBlobUpload(ctx context.Context, uuid, path string, startedAt time.Time, append bool) (distribution.BlobWriter, error) {
fw, err := lbs.driver.Writer(ctx, path, append)
if err != nil {
return nil, err
}
bw := &blobWriter{
ctx: ctx,
blobStore: lbs,... | go | func (lbs *linkedBlobStore) newBlobUpload(ctx context.Context, uuid, path string, startedAt time.Time, append bool) (distribution.BlobWriter, error) {
fw, err := lbs.driver.Writer(ctx, path, append)
if err != nil {
return nil, err
}
bw := &blobWriter{
ctx: ctx,
blobStore: lbs,... | [
"func",
"(",
"lbs",
"*",
"linkedBlobStore",
")",
"newBlobUpload",
"(",
"ctx",
"context",
".",
"Context",
",",
"uuid",
",",
"path",
"string",
",",
"startedAt",
"time",
".",
"Time",
",",
"append",
"bool",
")",
"(",
"distribution",
".",
"BlobWriter",
",",
"... | // newBlobUpload allocates a new upload controller with the given state. | [
"newBlobUpload",
"allocates",
"a",
"new",
"upload",
"controller",
"with",
"the",
"given",
"state",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/linkedblobstore.go#L308-L327 | train |
docker/distribution | registry/storage/linkedblobstore.go | linkBlob | func (lbs *linkedBlobStore) linkBlob(ctx context.Context, canonical distribution.Descriptor, aliases ...digest.Digest) error {
dgsts := append([]digest.Digest{canonical.Digest}, aliases...)
// TODO(stevvooe): Need to write out mediatype for only canonical hash
// since we don't care about the aliases. They are gene... | go | func (lbs *linkedBlobStore) linkBlob(ctx context.Context, canonical distribution.Descriptor, aliases ...digest.Digest) error {
dgsts := append([]digest.Digest{canonical.Digest}, aliases...)
// TODO(stevvooe): Need to write out mediatype for only canonical hash
// since we don't care about the aliases. They are gene... | [
"func",
"(",
"lbs",
"*",
"linkedBlobStore",
")",
"linkBlob",
"(",
"ctx",
"context",
".",
"Context",
",",
"canonical",
"distribution",
".",
"Descriptor",
",",
"aliases",
"...",
"digest",
".",
"Digest",
")",
"error",
"{",
"dgsts",
":=",
"append",
"(",
"[",
... | // linkBlob links a valid, written blob into the registry under the named
// repository for the upload controller. | [
"linkBlob",
"links",
"a",
"valid",
"written",
"blob",
"into",
"the",
"registry",
"under",
"the",
"named",
"repository",
"for",
"the",
"upload",
"controller",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/linkedblobstore.go#L331-L361 | train |
docker/distribution | registry/storage/linkedblobstore.go | resolveWithLinkFunc | func (lbs *linkedBlobStatter) resolveWithLinkFunc(ctx context.Context, dgst digest.Digest, linkPathFn linkPathFunc) (digest.Digest, error) {
blobLinkPath, err := linkPathFn(lbs.repository.Named().Name(), dgst)
if err != nil {
return "", err
}
return lbs.blobStore.readlink(ctx, blobLinkPath)
} | go | func (lbs *linkedBlobStatter) resolveWithLinkFunc(ctx context.Context, dgst digest.Digest, linkPathFn linkPathFunc) (digest.Digest, error) {
blobLinkPath, err := linkPathFn(lbs.repository.Named().Name(), dgst)
if err != nil {
return "", err
}
return lbs.blobStore.readlink(ctx, blobLinkPath)
} | [
"func",
"(",
"lbs",
"*",
"linkedBlobStatter",
")",
"resolveWithLinkFunc",
"(",
"ctx",
"context",
".",
"Context",
",",
"dgst",
"digest",
".",
"Digest",
",",
"linkPathFn",
"linkPathFunc",
")",
"(",
"digest",
".",
"Digest",
",",
"error",
")",
"{",
"blobLinkPath... | // resolveTargetWithFunc allows us to read a link to a resource with different
// linkPathFuncs to let us try a few different paths before returning not
// found. | [
"resolveTargetWithFunc",
"allows",
"us",
"to",
"read",
"a",
"link",
"to",
"a",
"resource",
"with",
"different",
"linkPathFuncs",
"to",
"let",
"us",
"try",
"a",
"few",
"different",
"paths",
"before",
"returning",
"not",
"found",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/linkedblobstore.go#L443-L450 | train |
docker/distribution | registry/storage/linkedblobstore.go | blobLinkPath | func blobLinkPath(name string, dgst digest.Digest) (string, error) {
return pathFor(layerLinkPathSpec{name: name, digest: dgst})
} | go | func blobLinkPath(name string, dgst digest.Digest) (string, error) {
return pathFor(layerLinkPathSpec{name: name, digest: dgst})
} | [
"func",
"blobLinkPath",
"(",
"name",
"string",
",",
"dgst",
"digest",
".",
"Digest",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"pathFor",
"(",
"layerLinkPathSpec",
"{",
"name",
":",
"name",
",",
"digest",
":",
"dgst",
"}",
")",
"\n",
"}"
] | // blobLinkPath provides the path to the blob link, also known as layers. | [
"blobLinkPath",
"provides",
"the",
"path",
"to",
"the",
"blob",
"link",
"also",
"known",
"as",
"layers",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/linkedblobstore.go#L458-L460 | train |
docker/distribution | registry/storage/linkedblobstore.go | manifestRevisionLinkPath | func manifestRevisionLinkPath(name string, dgst digest.Digest) (string, error) {
return pathFor(manifestRevisionLinkPathSpec{name: name, revision: dgst})
} | go | func manifestRevisionLinkPath(name string, dgst digest.Digest) (string, error) {
return pathFor(manifestRevisionLinkPathSpec{name: name, revision: dgst})
} | [
"func",
"manifestRevisionLinkPath",
"(",
"name",
"string",
",",
"dgst",
"digest",
".",
"Digest",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"pathFor",
"(",
"manifestRevisionLinkPathSpec",
"{",
"name",
":",
"name",
",",
"revision",
":",
"dgst",
"}"... | // manifestRevisionLinkPath provides the path to the manifest revision link. | [
"manifestRevisionLinkPath",
"provides",
"the",
"path",
"to",
"the",
"manifest",
"revision",
"link",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/linkedblobstore.go#L463-L465 | train |
docker/distribution | registry/api/errcode/errors.go | Descriptor | func (ec ErrorCode) Descriptor() ErrorDescriptor {
d, ok := errorCodeToDescriptors[ec]
if !ok {
return ErrorCodeUnknown.Descriptor()
}
return d
} | go | func (ec ErrorCode) Descriptor() ErrorDescriptor {
d, ok := errorCodeToDescriptors[ec]
if !ok {
return ErrorCodeUnknown.Descriptor()
}
return d
} | [
"func",
"(",
"ec",
"ErrorCode",
")",
"Descriptor",
"(",
")",
"ErrorDescriptor",
"{",
"d",
",",
"ok",
":=",
"errorCodeToDescriptors",
"[",
"ec",
"]",
"\n\n",
"if",
"!",
"ok",
"{",
"return",
"ErrorCodeUnknown",
".",
"Descriptor",
"(",
")",
"\n",
"}",
"\n\n... | // Descriptor returns the descriptor for the error code. | [
"Descriptor",
"returns",
"the",
"descriptor",
"for",
"the",
"error",
"code",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/api/errcode/errors.go#L33-L41 | train |
docker/distribution | registry/api/errcode/errors.go | UnmarshalText | func (ec *ErrorCode) UnmarshalText(text []byte) error {
desc, ok := idToDescriptors[string(text)]
if !ok {
desc = ErrorCodeUnknown.Descriptor()
}
*ec = desc.Code
return nil
} | go | func (ec *ErrorCode) UnmarshalText(text []byte) error {
desc, ok := idToDescriptors[string(text)]
if !ok {
desc = ErrorCodeUnknown.Descriptor()
}
*ec = desc.Code
return nil
} | [
"func",
"(",
"ec",
"*",
"ErrorCode",
")",
"UnmarshalText",
"(",
"text",
"[",
"]",
"byte",
")",
"error",
"{",
"desc",
",",
"ok",
":=",
"idToDescriptors",
"[",
"string",
"(",
"text",
")",
"]",
"\n\n",
"if",
"!",
"ok",
"{",
"desc",
"=",
"ErrorCodeUnknow... | // UnmarshalText decodes the form generated by MarshalText. | [
"UnmarshalText",
"decodes",
"the",
"form",
"generated",
"by",
"MarshalText",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/api/errcode/errors.go#L60-L70 | train |
docker/distribution | registry/api/errcode/errors.go | WithMessage | func (ec ErrorCode) WithMessage(message string) Error {
return Error{
Code: ec,
Message: message,
}
} | go | func (ec ErrorCode) WithMessage(message string) Error {
return Error{
Code: ec,
Message: message,
}
} | [
"func",
"(",
"ec",
"ErrorCode",
")",
"WithMessage",
"(",
"message",
"string",
")",
"Error",
"{",
"return",
"Error",
"{",
"Code",
":",
"ec",
",",
"Message",
":",
"message",
",",
"}",
"\n",
"}"
] | // WithMessage creates a new Error struct based on the passed-in info and
// overrides the Message property. | [
"WithMessage",
"creates",
"a",
"new",
"Error",
"struct",
"based",
"on",
"the",
"passed",
"-",
"in",
"info",
"and",
"overrides",
"the",
"Message",
"property",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/api/errcode/errors.go#L74-L79 | train |
docker/distribution | registry/api/errcode/errors.go | WithDetail | func (ec ErrorCode) WithDetail(detail interface{}) Error {
return Error{
Code: ec,
Message: ec.Message(),
}.WithDetail(detail)
} | go | func (ec ErrorCode) WithDetail(detail interface{}) Error {
return Error{
Code: ec,
Message: ec.Message(),
}.WithDetail(detail)
} | [
"func",
"(",
"ec",
"ErrorCode",
")",
"WithDetail",
"(",
"detail",
"interface",
"{",
"}",
")",
"Error",
"{",
"return",
"Error",
"{",
"Code",
":",
"ec",
",",
"Message",
":",
"ec",
".",
"Message",
"(",
")",
",",
"}",
".",
"WithDetail",
"(",
"detail",
... | // WithDetail creates a new Error struct based on the passed-in info and
// set the Detail property appropriately | [
"WithDetail",
"creates",
"a",
"new",
"Error",
"struct",
"based",
"on",
"the",
"passed",
"-",
"in",
"info",
"and",
"set",
"the",
"Detail",
"property",
"appropriately"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/api/errcode/errors.go#L83-L88 | train |
docker/distribution | registry/api/errcode/errors.go | WithArgs | func (ec ErrorCode) WithArgs(args ...interface{}) Error {
return Error{
Code: ec,
Message: ec.Message(),
}.WithArgs(args...)
} | go | func (ec ErrorCode) WithArgs(args ...interface{}) Error {
return Error{
Code: ec,
Message: ec.Message(),
}.WithArgs(args...)
} | [
"func",
"(",
"ec",
"ErrorCode",
")",
"WithArgs",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Error",
"{",
"return",
"Error",
"{",
"Code",
":",
"ec",
",",
"Message",
":",
"ec",
".",
"Message",
"(",
")",
",",
"}",
".",
"WithArgs",
"(",
"args",
... | // WithArgs creates a new Error struct and sets the Args slice | [
"WithArgs",
"creates",
"a",
"new",
"Error",
"struct",
"and",
"sets",
"the",
"Args",
"slice"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/api/errcode/errors.go#L91-L96 | train |
docker/distribution | registry/api/errcode/errors.go | WithDetail | func (e Error) WithDetail(detail interface{}) Error {
return Error{
Code: e.Code,
Message: e.Message,
Detail: detail,
}
} | go | func (e Error) WithDetail(detail interface{}) Error {
return Error{
Code: e.Code,
Message: e.Message,
Detail: detail,
}
} | [
"func",
"(",
"e",
"Error",
")",
"WithDetail",
"(",
"detail",
"interface",
"{",
"}",
")",
"Error",
"{",
"return",
"Error",
"{",
"Code",
":",
"e",
".",
"Code",
",",
"Message",
":",
"e",
".",
"Message",
",",
"Detail",
":",
"detail",
",",
"}",
"\n",
... | // WithDetail will return a new Error, based on the current one, but with
// some Detail info added | [
"WithDetail",
"will",
"return",
"a",
"new",
"Error",
"based",
"on",
"the",
"current",
"one",
"but",
"with",
"some",
"Detail",
"info",
"added"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/api/errcode/errors.go#L122-L128 | train |
docker/distribution | registry/api/errcode/errors.go | ParseErrorCode | func ParseErrorCode(value string) ErrorCode {
ed, ok := idToDescriptors[value]
if ok {
return ed.Code
}
return ErrorCodeUnknown
} | go | func ParseErrorCode(value string) ErrorCode {
ed, ok := idToDescriptors[value]
if ok {
return ed.Code
}
return ErrorCodeUnknown
} | [
"func",
"ParseErrorCode",
"(",
"value",
"string",
")",
"ErrorCode",
"{",
"ed",
",",
"ok",
":=",
"idToDescriptors",
"[",
"value",
"]",
"\n",
"if",
"ok",
"{",
"return",
"ed",
".",
"Code",
"\n",
"}",
"\n\n",
"return",
"ErrorCodeUnknown",
"\n",
"}"
] | // ParseErrorCode returns the value by the string error code.
// `ErrorCodeUnknown` will be returned if the error is not known. | [
"ParseErrorCode",
"returns",
"the",
"value",
"by",
"the",
"string",
"error",
"code",
".",
"ErrorCodeUnknown",
"will",
"be",
"returned",
"if",
"the",
"error",
"is",
"not",
"known",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/api/errcode/errors.go#L165-L172 | train |
docker/distribution | registry/api/errcode/errors.go | MarshalJSON | func (errs Errors) MarshalJSON() ([]byte, error) {
var tmpErrs struct {
Errors []Error `json:"errors,omitempty"`
}
for _, daErr := range errs {
var err Error
switch daErr := daErr.(type) {
case ErrorCode:
err = daErr.WithDetail(nil)
case Error:
err = daErr
default:
err = ErrorCodeUnknown.WithD... | go | func (errs Errors) MarshalJSON() ([]byte, error) {
var tmpErrs struct {
Errors []Error `json:"errors,omitempty"`
}
for _, daErr := range errs {
var err Error
switch daErr := daErr.(type) {
case ErrorCode:
err = daErr.WithDetail(nil)
case Error:
err = daErr
default:
err = ErrorCodeUnknown.WithD... | [
"func",
"(",
"errs",
"Errors",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"tmpErrs",
"struct",
"{",
"Errors",
"[",
"]",
"Error",
"`json:\"errors,omitempty\"`",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"daErr",
":=",
... | // MarshalJSON converts slice of error, ErrorCode or Error into a
// slice of Error - then serializes | [
"MarshalJSON",
"converts",
"slice",
"of",
"error",
"ErrorCode",
"or",
"Error",
"into",
"a",
"slice",
"of",
"Error",
"-",
"then",
"serializes"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/api/errcode/errors.go#L202-L235 | train |
docker/distribution | registry/client/transport/transport.go | NewTransport | func NewTransport(base http.RoundTripper, modifiers ...RequestModifier) http.RoundTripper {
return &transport{
Modifiers: modifiers,
Base: base,
}
} | go | func NewTransport(base http.RoundTripper, modifiers ...RequestModifier) http.RoundTripper {
return &transport{
Modifiers: modifiers,
Base: base,
}
} | [
"func",
"NewTransport",
"(",
"base",
"http",
".",
"RoundTripper",
",",
"modifiers",
"...",
"RequestModifier",
")",
"http",
".",
"RoundTripper",
"{",
"return",
"&",
"transport",
"{",
"Modifiers",
":",
"modifiers",
",",
"Base",
":",
"base",
",",
"}",
"\n",
"... | // NewTransport creates a new transport which will apply modifiers to
// the request on a RoundTrip call. | [
"NewTransport",
"creates",
"a",
"new",
"transport",
"which",
"will",
"apply",
"modifiers",
"to",
"the",
"request",
"on",
"a",
"RoundTrip",
"call",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/client/transport/transport.go#L33-L38 | train |
docker/distribution | registry/storage/driver/walk.go | WalkFallback | func WalkFallback(ctx context.Context, driver StorageDriver, from string, f WalkFn) error {
children, err := driver.List(ctx, from)
if err != nil {
return err
}
sort.Stable(sort.StringSlice(children))
for _, child := range children {
// TODO(stevvooe): Calling driver.Stat for every entry is quite
// expensiv... | go | func WalkFallback(ctx context.Context, driver StorageDriver, from string, f WalkFn) error {
children, err := driver.List(ctx, from)
if err != nil {
return err
}
sort.Stable(sort.StringSlice(children))
for _, child := range children {
// TODO(stevvooe): Calling driver.Stat for every entry is quite
// expensiv... | [
"func",
"WalkFallback",
"(",
"ctx",
"context",
".",
"Context",
",",
"driver",
"StorageDriver",
",",
"from",
"string",
",",
"f",
"WalkFn",
")",
"error",
"{",
"children",
",",
"err",
":=",
"driver",
".",
"List",
"(",
"ctx",
",",
"from",
")",
"\n",
"if",
... | // WalkFallback traverses a filesystem defined within driver, starting
// from the given path, calling f on each file. It uses the List method and Stat to drive itself.
// If the returned error from the WalkFn is ErrSkipDir and fileInfo refers
// to a directory, the directory will not be entered and Walk
// will contin... | [
"WalkFallback",
"traverses",
"a",
"filesystem",
"defined",
"within",
"driver",
"starting",
"from",
"the",
"given",
"path",
"calling",
"f",
"on",
"each",
"file",
".",
"It",
"uses",
"the",
"List",
"method",
"and",
"Stat",
"to",
"drive",
"itself",
".",
"If",
... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/walk.go#L24-L61 | train |
docker/distribution | registry/storage/cache/cache.go | ValidateDescriptor | func ValidateDescriptor(desc distribution.Descriptor) error {
if err := desc.Digest.Validate(); err != nil {
return err
}
if desc.Size < 0 {
return fmt.Errorf("cache: invalid length in descriptor: %v < 0", desc.Size)
}
if desc.MediaType == "" {
return fmt.Errorf("cache: empty mediatype on descriptor: %v", ... | go | func ValidateDescriptor(desc distribution.Descriptor) error {
if err := desc.Digest.Validate(); err != nil {
return err
}
if desc.Size < 0 {
return fmt.Errorf("cache: invalid length in descriptor: %v < 0", desc.Size)
}
if desc.MediaType == "" {
return fmt.Errorf("cache: empty mediatype on descriptor: %v", ... | [
"func",
"ValidateDescriptor",
"(",
"desc",
"distribution",
".",
"Descriptor",
")",
"error",
"{",
"if",
"err",
":=",
"desc",
".",
"Digest",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"desc",
".",
... | // ValidateDescriptor provides a helper function to ensure that caches have
// common criteria for admitting descriptors. | [
"ValidateDescriptor",
"provides",
"a",
"helper",
"function",
"to",
"ensure",
"that",
"caches",
"have",
"common",
"criteria",
"for",
"admitting",
"descriptors",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/cache/cache.go#L21-L35 | train |
docker/distribution | notifications/listener.go | Listen | func Listen(repo distribution.Repository, remover distribution.RepositoryRemover, listener Listener) (distribution.Repository, distribution.RepositoryRemover) {
return &repositoryListener{
Repository: repo,
listener: listener,
}, &removerListener{
RepositoryRemover: remover,
listener: listener... | go | func Listen(repo distribution.Repository, remover distribution.RepositoryRemover, listener Listener) (distribution.Repository, distribution.RepositoryRemover) {
return &repositoryListener{
Repository: repo,
listener: listener,
}, &removerListener{
RepositoryRemover: remover,
listener: listener... | [
"func",
"Listen",
"(",
"repo",
"distribution",
".",
"Repository",
",",
"remover",
"distribution",
".",
"RepositoryRemover",
",",
"listener",
"Listener",
")",
"(",
"distribution",
".",
"Repository",
",",
"distribution",
".",
"RepositoryRemover",
")",
"{",
"return",... | // Listen dispatches events on the repository to the listener. | [
"Listen",
"dispatches",
"events",
"on",
"the",
"repository",
"to",
"the",
"listener",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/notifications/listener.go#L53-L61 | train |
docker/distribution | registry/handlers/blob.go | blobDispatcher | func blobDispatcher(ctx *Context, r *http.Request) http.Handler {
dgst, err := getDigest(ctx)
if err != nil {
if err == errDigestNotAvailable {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx.Errors = append(ctx.Errors, v2.ErrorCodeDigestInvalid.WithDetail(err))
})
}
retur... | go | func blobDispatcher(ctx *Context, r *http.Request) http.Handler {
dgst, err := getDigest(ctx)
if err != nil {
if err == errDigestNotAvailable {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx.Errors = append(ctx.Errors, v2.ErrorCodeDigestInvalid.WithDetail(err))
})
}
retur... | [
"func",
"blobDispatcher",
"(",
"ctx",
"*",
"Context",
",",
"r",
"*",
"http",
".",
"Request",
")",
"http",
".",
"Handler",
"{",
"dgst",
",",
"err",
":=",
"getDigest",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"err",
"==",
"errDiges... | // blobDispatcher uses the request context to build a blobHandler. | [
"blobDispatcher",
"uses",
"the",
"request",
"context",
"to",
"build",
"a",
"blobHandler",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/blob.go#L15-L45 | train |
docker/distribution | registry/handlers/blob.go | GetBlob | func (bh *blobHandler) GetBlob(w http.ResponseWriter, r *http.Request) {
context.GetLogger(bh).Debug("GetBlob")
blobs := bh.Repository.Blobs(bh)
desc, err := blobs.Stat(bh, bh.Digest)
if err != nil {
if err == distribution.ErrBlobUnknown {
bh.Errors = append(bh.Errors, v2.ErrorCodeBlobUnknown.WithDetail(bh.Dig... | go | func (bh *blobHandler) GetBlob(w http.ResponseWriter, r *http.Request) {
context.GetLogger(bh).Debug("GetBlob")
blobs := bh.Repository.Blobs(bh)
desc, err := blobs.Stat(bh, bh.Digest)
if err != nil {
if err == distribution.ErrBlobUnknown {
bh.Errors = append(bh.Errors, v2.ErrorCodeBlobUnknown.WithDetail(bh.Dig... | [
"func",
"(",
"bh",
"*",
"blobHandler",
")",
"GetBlob",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"context",
".",
"GetLogger",
"(",
"bh",
")",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"blobs",
":=",
... | // GetBlob fetches the binary data from backend storage returns it in the
// response. | [
"GetBlob",
"fetches",
"the",
"binary",
"data",
"from",
"backend",
"storage",
"returns",
"it",
"in",
"the",
"response",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/blob.go#L56-L74 | train |
docker/distribution | registry/handlers/blob.go | DeleteBlob | func (bh *blobHandler) DeleteBlob(w http.ResponseWriter, r *http.Request) {
context.GetLogger(bh).Debug("DeleteBlob")
blobs := bh.Repository.Blobs(bh)
err := blobs.Delete(bh, bh.Digest)
if err != nil {
switch err {
case distribution.ErrUnsupported:
bh.Errors = append(bh.Errors, errcode.ErrorCodeUnsupported)... | go | func (bh *blobHandler) DeleteBlob(w http.ResponseWriter, r *http.Request) {
context.GetLogger(bh).Debug("DeleteBlob")
blobs := bh.Repository.Blobs(bh)
err := blobs.Delete(bh, bh.Digest)
if err != nil {
switch err {
case distribution.ErrUnsupported:
bh.Errors = append(bh.Errors, errcode.ErrorCodeUnsupported)... | [
"func",
"(",
"bh",
"*",
"blobHandler",
")",
"DeleteBlob",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"context",
".",
"GetLogger",
"(",
"bh",
")",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n\n",
"blobs",
":... | // DeleteBlob deletes a layer blob | [
"DeleteBlob",
"deletes",
"a",
"layer",
"blob"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/blob.go#L77-L99 | train |
docker/distribution | manifest/ocischema/manifest.go | UnmarshalJSON | func (m *DeserializedManifest) UnmarshalJSON(b []byte) error {
m.canonical = make([]byte, len(b))
// store manifest in canonical
copy(m.canonical, b)
// Unmarshal canonical JSON into Manifest object
var manifest Manifest
if err := json.Unmarshal(m.canonical, &manifest); err != nil {
return err
}
if manifest... | go | func (m *DeserializedManifest) UnmarshalJSON(b []byte) error {
m.canonical = make([]byte, len(b))
// store manifest in canonical
copy(m.canonical, b)
// Unmarshal canonical JSON into Manifest object
var manifest Manifest
if err := json.Unmarshal(m.canonical, &manifest); err != nil {
return err
}
if manifest... | [
"func",
"(",
"m",
"*",
"DeserializedManifest",
")",
"UnmarshalJSON",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"m",
".",
"canonical",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"len",
"(",
"b",
")",
")",
"\n",
"// store manifest in canonical",
"copy... | // UnmarshalJSON populates a new Manifest struct from JSON data. | [
"UnmarshalJSON",
"populates",
"a",
"new",
"Manifest",
"struct",
"from",
"JSON",
"data",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/ocischema/manifest.go#L89-L108 | train |
docker/distribution | registry/proxy/scheduler/scheduler.go | New | func New(ctx context.Context, driver driver.StorageDriver, path string) *TTLExpirationScheduler {
return &TTLExpirationScheduler{
entries: make(map[string]*schedulerEntry),
driver: driver,
pathToStateFile: path,
ctx: ctx,
stopped: true,
doneChan: make(chan struct... | go | func New(ctx context.Context, driver driver.StorageDriver, path string) *TTLExpirationScheduler {
return &TTLExpirationScheduler{
entries: make(map[string]*schedulerEntry),
driver: driver,
pathToStateFile: path,
ctx: ctx,
stopped: true,
doneChan: make(chan struct... | [
"func",
"New",
"(",
"ctx",
"context",
".",
"Context",
",",
"driver",
"driver",
".",
"StorageDriver",
",",
"path",
"string",
")",
"*",
"TTLExpirationScheduler",
"{",
"return",
"&",
"TTLExpirationScheduler",
"{",
"entries",
":",
"make",
"(",
"map",
"[",
"strin... | // New returns a new instance of the scheduler | [
"New",
"returns",
"a",
"new",
"instance",
"of",
"the",
"scheduler"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/proxy/scheduler/scheduler.go#L35-L45 | train |
docker/distribution | registry/proxy/scheduler/scheduler.go | OnBlobExpire | func (ttles *TTLExpirationScheduler) OnBlobExpire(f expiryFunc) {
ttles.Lock()
defer ttles.Unlock()
ttles.onBlobExpire = f
} | go | func (ttles *TTLExpirationScheduler) OnBlobExpire(f expiryFunc) {
ttles.Lock()
defer ttles.Unlock()
ttles.onBlobExpire = f
} | [
"func",
"(",
"ttles",
"*",
"TTLExpirationScheduler",
")",
"OnBlobExpire",
"(",
"f",
"expiryFunc",
")",
"{",
"ttles",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ttles",
".",
"Unlock",
"(",
")",
"\n\n",
"ttles",
".",
"onBlobExpire",
"=",
"f",
"\n",
"}"
] | // OnBlobExpire is called when a scheduled blob's TTL expires | [
"OnBlobExpire",
"is",
"called",
"when",
"a",
"scheduled",
"blob",
"s",
"TTL",
"expires"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/proxy/scheduler/scheduler.go#L69-L74 | train |
docker/distribution | registry/proxy/scheduler/scheduler.go | OnManifestExpire | func (ttles *TTLExpirationScheduler) OnManifestExpire(f expiryFunc) {
ttles.Lock()
defer ttles.Unlock()
ttles.onManifestExpire = f
} | go | func (ttles *TTLExpirationScheduler) OnManifestExpire(f expiryFunc) {
ttles.Lock()
defer ttles.Unlock()
ttles.onManifestExpire = f
} | [
"func",
"(",
"ttles",
"*",
"TTLExpirationScheduler",
")",
"OnManifestExpire",
"(",
"f",
"expiryFunc",
")",
"{",
"ttles",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ttles",
".",
"Unlock",
"(",
")",
"\n\n",
"ttles",
".",
"onManifestExpire",
"=",
"f",
"\n",
"}"... | // OnManifestExpire is called when a scheduled manifest's TTL expires | [
"OnManifestExpire",
"is",
"called",
"when",
"a",
"scheduled",
"manifest",
"s",
"TTL",
"expires"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/proxy/scheduler/scheduler.go#L77-L82 | train |
docker/distribution | registry/proxy/scheduler/scheduler.go | AddBlob | func (ttles *TTLExpirationScheduler) AddBlob(blobRef reference.Canonical, ttl time.Duration) error {
ttles.Lock()
defer ttles.Unlock()
if ttles.stopped {
return fmt.Errorf("scheduler not started")
}
ttles.add(blobRef, ttl, entryTypeBlob)
return nil
} | go | func (ttles *TTLExpirationScheduler) AddBlob(blobRef reference.Canonical, ttl time.Duration) error {
ttles.Lock()
defer ttles.Unlock()
if ttles.stopped {
return fmt.Errorf("scheduler not started")
}
ttles.add(blobRef, ttl, entryTypeBlob)
return nil
} | [
"func",
"(",
"ttles",
"*",
"TTLExpirationScheduler",
")",
"AddBlob",
"(",
"blobRef",
"reference",
".",
"Canonical",
",",
"ttl",
"time",
".",
"Duration",
")",
"error",
"{",
"ttles",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ttles",
".",
"Unlock",
"(",
")",
... | // AddBlob schedules a blob cleanup after ttl expires | [
"AddBlob",
"schedules",
"a",
"blob",
"cleanup",
"after",
"ttl",
"expires"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/proxy/scheduler/scheduler.go#L85-L95 | train |
docker/distribution | registry/proxy/scheduler/scheduler.go | AddManifest | func (ttles *TTLExpirationScheduler) AddManifest(manifestRef reference.Canonical, ttl time.Duration) error {
ttles.Lock()
defer ttles.Unlock()
if ttles.stopped {
return fmt.Errorf("scheduler not started")
}
ttles.add(manifestRef, ttl, entryTypeManifest)
return nil
} | go | func (ttles *TTLExpirationScheduler) AddManifest(manifestRef reference.Canonical, ttl time.Duration) error {
ttles.Lock()
defer ttles.Unlock()
if ttles.stopped {
return fmt.Errorf("scheduler not started")
}
ttles.add(manifestRef, ttl, entryTypeManifest)
return nil
} | [
"func",
"(",
"ttles",
"*",
"TTLExpirationScheduler",
")",
"AddManifest",
"(",
"manifestRef",
"reference",
".",
"Canonical",
",",
"ttl",
"time",
".",
"Duration",
")",
"error",
"{",
"ttles",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ttles",
".",
"Unlock",
"(",
... | // AddManifest schedules a manifest cleanup after ttl expires | [
"AddManifest",
"schedules",
"a",
"manifest",
"cleanup",
"after",
"ttl",
"expires"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/proxy/scheduler/scheduler.go#L98-L108 | train |
docker/distribution | registry/proxy/scheduler/scheduler.go | Stop | func (ttles *TTLExpirationScheduler) Stop() {
ttles.Lock()
defer ttles.Unlock()
if err := ttles.writeState(); err != nil {
dcontext.GetLogger(ttles.ctx).Errorf("Error writing scheduler state: %s", err)
}
for _, entry := range ttles.entries {
entry.timer.Stop()
}
close(ttles.doneChan)
ttles.saveTimer.Stop... | go | func (ttles *TTLExpirationScheduler) Stop() {
ttles.Lock()
defer ttles.Unlock()
if err := ttles.writeState(); err != nil {
dcontext.GetLogger(ttles.ctx).Errorf("Error writing scheduler state: %s", err)
}
for _, entry := range ttles.entries {
entry.timer.Stop()
}
close(ttles.doneChan)
ttles.saveTimer.Stop... | [
"func",
"(",
"ttles",
"*",
"TTLExpirationScheduler",
")",
"Stop",
"(",
")",
"{",
"ttles",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ttles",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"err",
":=",
"ttles",
".",
"writeState",
"(",
")",
";",
"err",
"!=",
"ni... | // Stop stops the scheduler. | [
"Stop",
"stops",
"the",
"scheduler",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/proxy/scheduler/scheduler.go#L209-L224 | train |
docker/distribution | registry/auth/htpasswd/htpasswd.go | newHTPasswd | func newHTPasswd(rd io.Reader) (*htpasswd, error) {
entries, err := parseHTPasswd(rd)
if err != nil {
return nil, err
}
return &htpasswd{entries: entries}, nil
} | go | func newHTPasswd(rd io.Reader) (*htpasswd, error) {
entries, err := parseHTPasswd(rd)
if err != nil {
return nil, err
}
return &htpasswd{entries: entries}, nil
} | [
"func",
"newHTPasswd",
"(",
"rd",
"io",
".",
"Reader",
")",
"(",
"*",
"htpasswd",
",",
"error",
")",
"{",
"entries",
",",
"err",
":=",
"parseHTPasswd",
"(",
"rd",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"... | // newHTPasswd parses the reader and returns an htpasswd or an error. | [
"newHTPasswd",
"parses",
"the",
"reader",
"and",
"returns",
"an",
"htpasswd",
"or",
"an",
"error",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/auth/htpasswd/htpasswd.go#L21-L28 | train |
docker/distribution | registry/auth/htpasswd/htpasswd.go | parseHTPasswd | func parseHTPasswd(rd io.Reader) (map[string][]byte, error) {
entries := map[string][]byte{}
scanner := bufio.NewScanner(rd)
var line int
for scanner.Scan() {
line++ // 1-based line numbering
t := strings.TrimSpace(scanner.Text())
if len(t) < 1 {
continue
}
// lines that *begin* with a '#' are consid... | go | func parseHTPasswd(rd io.Reader) (map[string][]byte, error) {
entries := map[string][]byte{}
scanner := bufio.NewScanner(rd)
var line int
for scanner.Scan() {
line++ // 1-based line numbering
t := strings.TrimSpace(scanner.Text())
if len(t) < 1 {
continue
}
// lines that *begin* with a '#' are consid... | [
"func",
"parseHTPasswd",
"(",
"rd",
"io",
".",
"Reader",
")",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"entries",
":=",
"map",
"[",
"string",
"]",
"[",
"]",
"byte",
"{",
"}",
"\n",
"scanner",
":=",
"bufio",
".",
... | // parseHTPasswd parses the contents of htpasswd. This will read all the
// entries in the file, whether or not they are needed. An error is returned
// if a syntax errors are encountered or if the reader fails. | [
"parseHTPasswd",
"parses",
"the",
"contents",
"of",
"htpasswd",
".",
"This",
"will",
"read",
"all",
"the",
"entries",
"in",
"the",
"file",
"whether",
"or",
"not",
"they",
"are",
"needed",
".",
"An",
"error",
"is",
"returned",
"if",
"a",
"syntax",
"errors",... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/auth/htpasswd/htpasswd.go#L52-L82 | train |
docker/distribution | registry/storage/error.go | pushError | func pushError(errors []error, path string, err error) []error {
return append(errors, fmt.Errorf("%s: %s", path, err))
} | go | func pushError(errors []error, path string, err error) []error {
return append(errors, fmt.Errorf("%s: %s", path, err))
} | [
"func",
"pushError",
"(",
"errors",
"[",
"]",
"error",
",",
"path",
"string",
",",
"err",
"error",
")",
"[",
"]",
"error",
"{",
"return",
"append",
"(",
"errors",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"path",
",",
"err",
")",
")",
"\n"... | // pushError formats an error type given a path and an error
// and pushes it to a slice of errors | [
"pushError",
"formats",
"an",
"error",
"type",
"given",
"a",
"path",
"and",
"an",
"error",
"and",
"pushes",
"it",
"to",
"a",
"slice",
"of",
"errors"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/error.go#L7-L9 | train |
docker/distribution | manifest/schema1/reference_builder.go | NewReferenceManifestBuilder | func NewReferenceManifestBuilder(pk libtrust.PrivateKey, ref reference.Named, architecture string) distribution.ManifestBuilder {
tag := ""
if tagged, isTagged := ref.(reference.Tagged); isTagged {
tag = tagged.Tag()
}
return &referenceManifestBuilder{
Manifest: Manifest{
Versioned: manifest.Versioned{
... | go | func NewReferenceManifestBuilder(pk libtrust.PrivateKey, ref reference.Named, architecture string) distribution.ManifestBuilder {
tag := ""
if tagged, isTagged := ref.(reference.Tagged); isTagged {
tag = tagged.Tag()
}
return &referenceManifestBuilder{
Manifest: Manifest{
Versioned: manifest.Versioned{
... | [
"func",
"NewReferenceManifestBuilder",
"(",
"pk",
"libtrust",
".",
"PrivateKey",
",",
"ref",
"reference",
".",
"Named",
",",
"architecture",
"string",
")",
"distribution",
".",
"ManifestBuilder",
"{",
"tag",
":=",
"\"",
"\"",
"\n",
"if",
"tagged",
",",
"isTagg... | // NewReferenceManifestBuilder is used to build new manifests for the current
// schema version using schema1 dependencies. | [
"NewReferenceManifestBuilder",
"is",
"used",
"to",
"build",
"new",
"manifests",
"for",
"the",
"current",
"schema",
"version",
"using",
"schema1",
"dependencies",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/schema1/reference_builder.go#L24-L41 | train |
docker/distribution | manifest/schema1/reference_builder.go | References | func (mb *referenceManifestBuilder) References() []distribution.Descriptor {
refs := make([]distribution.Descriptor, len(mb.Manifest.FSLayers))
for i := range mb.Manifest.FSLayers {
layerDigest := mb.Manifest.FSLayers[i].BlobSum
history := mb.Manifest.History[i]
ref := Reference{layerDigest, 0, history}
refs[... | go | func (mb *referenceManifestBuilder) References() []distribution.Descriptor {
refs := make([]distribution.Descriptor, len(mb.Manifest.FSLayers))
for i := range mb.Manifest.FSLayers {
layerDigest := mb.Manifest.FSLayers[i].BlobSum
history := mb.Manifest.History[i]
ref := Reference{layerDigest, 0, history}
refs[... | [
"func",
"(",
"mb",
"*",
"referenceManifestBuilder",
")",
"References",
"(",
")",
"[",
"]",
"distribution",
".",
"Descriptor",
"{",
"refs",
":=",
"make",
"(",
"[",
"]",
"distribution",
".",
"Descriptor",
",",
"len",
"(",
"mb",
".",
"Manifest",
".",
"FSLay... | // References returns the current references added to this builder | [
"References",
"returns",
"the",
"current",
"references",
"added",
"to",
"this",
"builder"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/schema1/reference_builder.go#L72-L81 | train |
docker/distribution | manifest/schema1/reference_builder.go | Descriptor | func (r Reference) Descriptor() distribution.Descriptor {
return distribution.Descriptor{
MediaType: MediaTypeManifestLayer,
Digest: r.Digest,
Size: r.Size,
}
} | go | func (r Reference) Descriptor() distribution.Descriptor {
return distribution.Descriptor{
MediaType: MediaTypeManifestLayer,
Digest: r.Digest,
Size: r.Size,
}
} | [
"func",
"(",
"r",
"Reference",
")",
"Descriptor",
"(",
")",
"distribution",
".",
"Descriptor",
"{",
"return",
"distribution",
".",
"Descriptor",
"{",
"MediaType",
":",
"MediaTypeManifestLayer",
",",
"Digest",
":",
"r",
".",
"Digest",
",",
"Size",
":",
"r",
... | // Descriptor describes a reference | [
"Descriptor",
"describes",
"a",
"reference"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/schema1/reference_builder.go#L92-L98 | train |
docker/distribution | registry/auth/token/token.go | NewToken | func NewToken(rawToken string) (*Token, error) {
parts := strings.Split(rawToken, TokenSeparator)
if len(parts) != 3 {
return nil, ErrMalformedToken
}
var (
rawHeader, rawClaims = parts[0], parts[1]
headerJSON, claimsJSON []byte
err error
)
defer func() {
if err != nil {
log.In... | go | func NewToken(rawToken string) (*Token, error) {
parts := strings.Split(rawToken, TokenSeparator)
if len(parts) != 3 {
return nil, ErrMalformedToken
}
var (
rawHeader, rawClaims = parts[0], parts[1]
headerJSON, claimsJSON []byte
err error
)
defer func() {
if err != nil {
log.In... | [
"func",
"NewToken",
"(",
"rawToken",
"string",
")",
"(",
"*",
"Token",
",",
"error",
")",
"{",
"parts",
":=",
"strings",
".",
"Split",
"(",
"rawToken",
",",
"TokenSeparator",
")",
"\n",
"if",
"len",
"(",
"parts",
")",
"!=",
"3",
"{",
"return",
"nil",... | // NewToken parses the given raw token string
// and constructs an unverified JSON Web Token. | [
"NewToken",
"parses",
"the",
"given",
"raw",
"token",
"string",
"and",
"constructs",
"an",
"unverified",
"JSON",
"Web",
"Token",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/auth/token/token.go#L85-L132 | train |
docker/distribution | registry/auth/token/token.go | Verify | func (t *Token) Verify(verifyOpts VerifyOptions) error {
// Verify that the Issuer claim is a trusted authority.
if !contains(verifyOpts.TrustedIssuers, t.Claims.Issuer) {
log.Infof("token from untrusted issuer: %q", t.Claims.Issuer)
return ErrInvalidToken
}
// Verify that the Audience claim is allowed.
if !c... | go | func (t *Token) Verify(verifyOpts VerifyOptions) error {
// Verify that the Issuer claim is a trusted authority.
if !contains(verifyOpts.TrustedIssuers, t.Claims.Issuer) {
log.Infof("token from untrusted issuer: %q", t.Claims.Issuer)
return ErrInvalidToken
}
// Verify that the Audience claim is allowed.
if !c... | [
"func",
"(",
"t",
"*",
"Token",
")",
"Verify",
"(",
"verifyOpts",
"VerifyOptions",
")",
"error",
"{",
"// Verify that the Issuer claim is a trusted authority.",
"if",
"!",
"contains",
"(",
"verifyOpts",
".",
"TrustedIssuers",
",",
"t",
".",
"Claims",
".",
"Issuer"... | // Verify attempts to verify this token using the given options.
// Returns a nil error if the token is valid. | [
"Verify",
"attempts",
"to",
"verify",
"this",
"token",
"using",
"the",
"given",
"options",
".",
"Returns",
"a",
"nil",
"error",
"if",
"the",
"token",
"is",
"valid",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/auth/token/token.go#L136-L184 | train |
docker/distribution | registry/auth/token/token.go | accessSet | func (t *Token) accessSet() accessSet {
if t.Claims == nil {
return nil
}
accessSet := make(accessSet, len(t.Claims.Access))
for _, resourceActions := range t.Claims.Access {
resource := auth.Resource{
Type: resourceActions.Type,
Name: resourceActions.Name,
}
set, exists := accessSet[resource]
if... | go | func (t *Token) accessSet() accessSet {
if t.Claims == nil {
return nil
}
accessSet := make(accessSet, len(t.Claims.Access))
for _, resourceActions := range t.Claims.Access {
resource := auth.Resource{
Type: resourceActions.Type,
Name: resourceActions.Name,
}
set, exists := accessSet[resource]
if... | [
"func",
"(",
"t",
"*",
"Token",
")",
"accessSet",
"(",
")",
"accessSet",
"{",
"if",
"t",
".",
"Claims",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"accessSet",
":=",
"make",
"(",
"accessSet",
",",
"len",
"(",
"t",
".",
"Claims",
".",
"... | // accessSet returns a set of actions available for the resource
// actions listed in the `access` section of this token. | [
"accessSet",
"returns",
"a",
"set",
"of",
"actions",
"available",
"for",
"the",
"resource",
"actions",
"listed",
"in",
"the",
"access",
"section",
"of",
"this",
"token",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/auth/token/token.go#L326-L351 | train |
docker/distribution | registry/storage/blobstore.go | Get | func (bs *blobStore) Get(ctx context.Context, dgst digest.Digest) ([]byte, error) {
bp, err := bs.path(dgst)
if err != nil {
return nil, err
}
p, err := getContent(ctx, bs.driver, bp)
if err != nil {
switch err.(type) {
case driver.PathNotFoundError:
return nil, distribution.ErrBlobUnknown
}
return ... | go | func (bs *blobStore) Get(ctx context.Context, dgst digest.Digest) ([]byte, error) {
bp, err := bs.path(dgst)
if err != nil {
return nil, err
}
p, err := getContent(ctx, bs.driver, bp)
if err != nil {
switch err.(type) {
case driver.PathNotFoundError:
return nil, distribution.ErrBlobUnknown
}
return ... | [
"func",
"(",
"bs",
"*",
"blobStore",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"dgst",
"digest",
".",
"Digest",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"bp",
",",
"err",
":=",
"bs",
".",
"path",
"(",
"dgst",
")",
"\n",... | // Get implements the BlobReadService.Get call. | [
"Get",
"implements",
"the",
"BlobReadService",
".",
"Get",
"call",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/blobstore.go#L25-L42 | train |
docker/distribution | registry/storage/blobstore.go | Put | func (bs *blobStore) Put(ctx context.Context, mediaType string, p []byte) (distribution.Descriptor, error) {
dgst := digest.FromBytes(p)
desc, err := bs.statter.Stat(ctx, dgst)
if err == nil {
// content already present
return desc, nil
} else if err != distribution.ErrBlobUnknown {
dcontext.GetLogger(ctx).Er... | go | func (bs *blobStore) Put(ctx context.Context, mediaType string, p []byte) (distribution.Descriptor, error) {
dgst := digest.FromBytes(p)
desc, err := bs.statter.Stat(ctx, dgst)
if err == nil {
// content already present
return desc, nil
} else if err != distribution.ErrBlobUnknown {
dcontext.GetLogger(ctx).Er... | [
"func",
"(",
"bs",
"*",
"blobStore",
")",
"Put",
"(",
"ctx",
"context",
".",
"Context",
",",
"mediaType",
"string",
",",
"p",
"[",
"]",
"byte",
")",
"(",
"distribution",
".",
"Descriptor",
",",
"error",
")",
"{",
"dgst",
":=",
"digest",
".",
"FromByt... | // Put stores the content p in the blob store, calculating the digest. If the
// content is already present, only the digest will be returned. This should
// only be used for small objects, such as manifests. This implemented as a convenience for other Put implementations | [
"Put",
"stores",
"the",
"content",
"p",
"in",
"the",
"blob",
"store",
"calculating",
"the",
"digest",
".",
"If",
"the",
"content",
"is",
"already",
"present",
"only",
"the",
"digest",
"will",
"be",
"returned",
".",
"This",
"should",
"only",
"be",
"used",
... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/blobstore.go#L61-L88 | train |
docker/distribution | registry/storage/blobstore.go | path | func (bs *blobStore) path(dgst digest.Digest) (string, error) {
bp, err := pathFor(blobDataPathSpec{
digest: dgst,
})
if err != nil {
return "", err
}
return bp, nil
} | go | func (bs *blobStore) path(dgst digest.Digest) (string, error) {
bp, err := pathFor(blobDataPathSpec{
digest: dgst,
})
if err != nil {
return "", err
}
return bp, nil
} | [
"func",
"(",
"bs",
"*",
"blobStore",
")",
"path",
"(",
"dgst",
"digest",
".",
"Digest",
")",
"(",
"string",
",",
"error",
")",
"{",
"bp",
",",
"err",
":=",
"pathFor",
"(",
"blobDataPathSpec",
"{",
"digest",
":",
"dgst",
",",
"}",
")",
"\n\n",
"if",... | // path returns the canonical path for the blob identified by digest. The blob
// may or may not exist. | [
"path",
"returns",
"the",
"canonical",
"path",
"for",
"the",
"blob",
"identified",
"by",
"digest",
".",
"The",
"blob",
"may",
"or",
"may",
"not",
"exist",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/blobstore.go#L120-L130 | train |
docker/distribution | registry/storage/blobstore.go | link | func (bs *blobStore) link(ctx context.Context, path string, dgst digest.Digest) error {
// The contents of the "link" file are the exact string contents of the
// digest, which is specified in that package.
return bs.driver.PutContent(ctx, path, []byte(dgst))
} | go | func (bs *blobStore) link(ctx context.Context, path string, dgst digest.Digest) error {
// The contents of the "link" file are the exact string contents of the
// digest, which is specified in that package.
return bs.driver.PutContent(ctx, path, []byte(dgst))
} | [
"func",
"(",
"bs",
"*",
"blobStore",
")",
"link",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
",",
"dgst",
"digest",
".",
"Digest",
")",
"error",
"{",
"// The contents of the \"link\" file are the exact string contents of the",
"// digest, which is s... | // link links the path to the provided digest by writing the digest into the
// target file. Caller must ensure that the blob actually exists. | [
"link",
"links",
"the",
"path",
"to",
"the",
"provided",
"digest",
"by",
"writing",
"the",
"digest",
"into",
"the",
"target",
"file",
".",
"Caller",
"must",
"ensure",
"that",
"the",
"blob",
"actually",
"exists",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/blobstore.go#L134-L138 | train |
docker/distribution | registry/storage/blobstore.go | readlink | func (bs *blobStore) readlink(ctx context.Context, path string) (digest.Digest, error) {
content, err := bs.driver.GetContent(ctx, path)
if err != nil {
return "", err
}
linked, err := digest.Parse(string(content))
if err != nil {
return "", err
}
return linked, nil
} | go | func (bs *blobStore) readlink(ctx context.Context, path string) (digest.Digest, error) {
content, err := bs.driver.GetContent(ctx, path)
if err != nil {
return "", err
}
linked, err := digest.Parse(string(content))
if err != nil {
return "", err
}
return linked, nil
} | [
"func",
"(",
"bs",
"*",
"blobStore",
")",
"readlink",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
")",
"(",
"digest",
".",
"Digest",
",",
"error",
")",
"{",
"content",
",",
"err",
":=",
"bs",
".",
"driver",
".",
"GetContent",
"(",
... | // readlink returns the linked digest at path. | [
"readlink",
"returns",
"the",
"linked",
"digest",
"at",
"path",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/blobstore.go#L141-L153 | train |
docker/distribution | registry/storage/blobstore.go | Stat | func (bs *blobStatter) Stat(ctx context.Context, dgst digest.Digest) (distribution.Descriptor, error) {
path, err := pathFor(blobDataPathSpec{
digest: dgst,
})
if err != nil {
return distribution.Descriptor{}, err
}
fi, err := bs.driver.Stat(ctx, path)
if err != nil {
switch err := err.(type) {
case dri... | go | func (bs *blobStatter) Stat(ctx context.Context, dgst digest.Digest) (distribution.Descriptor, error) {
path, err := pathFor(blobDataPathSpec{
digest: dgst,
})
if err != nil {
return distribution.Descriptor{}, err
}
fi, err := bs.driver.Stat(ctx, path)
if err != nil {
switch err := err.(type) {
case dri... | [
"func",
"(",
"bs",
"*",
"blobStatter",
")",
"Stat",
"(",
"ctx",
"context",
".",
"Context",
",",
"dgst",
"digest",
".",
"Digest",
")",
"(",
"distribution",
".",
"Descriptor",
",",
"error",
")",
"{",
"path",
",",
"err",
":=",
"pathFor",
"(",
"blobDataPat... | // Stat implements BlobStatter.Stat by returning the descriptor for the blob
// in the main blob store. If this method returns successfully, there is
// strong guarantee that the blob exists and is available. | [
"Stat",
"implements",
"BlobStatter",
".",
"Stat",
"by",
"returning",
"the",
"descriptor",
"for",
"the",
"blob",
"in",
"the",
"main",
"blob",
"store",
".",
"If",
"this",
"method",
"returns",
"successfully",
"there",
"is",
"strong",
"guarantee",
"that",
"the",
... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/blobstore.go#L164-L204 | train |
docker/distribution | registry/storage/driver/inmemory/driver.go | New | func New() *Driver {
return &Driver{
baseEmbed: baseEmbed{
Base: base.Base{
StorageDriver: &driver{
root: &dir{
common: common{
p: "/",
mod: time.Now(),
},
},
},
},
},
}
} | go | func New() *Driver {
return &Driver{
baseEmbed: baseEmbed{
Base: base.Base{
StorageDriver: &driver{
root: &dir{
common: common{
p: "/",
mod: time.Now(),
},
},
},
},
},
}
} | [
"func",
"New",
"(",
")",
"*",
"Driver",
"{",
"return",
"&",
"Driver",
"{",
"baseEmbed",
":",
"baseEmbed",
"{",
"Base",
":",
"base",
".",
"Base",
"{",
"StorageDriver",
":",
"&",
"driver",
"{",
"root",
":",
"&",
"dir",
"{",
"common",
":",
"common",
"... | // New constructs a new Driver. | [
"New",
"constructs",
"a",
"new",
"Driver",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/inmemory/driver.go#L48-L63 | train |
docker/distribution | registry/storage/driver/inmemory/driver.go | Stat | func (d *driver) Stat(ctx context.Context, path string) (storagedriver.FileInfo, error) {
d.mutex.RLock()
defer d.mutex.RUnlock()
normalized := normalize(path)
found := d.root.find(normalized)
if found.path() != normalized {
return nil, storagedriver.PathNotFoundError{Path: path}
}
fi := storagedriver.FileI... | go | func (d *driver) Stat(ctx context.Context, path string) (storagedriver.FileInfo, error) {
d.mutex.RLock()
defer d.mutex.RUnlock()
normalized := normalize(path)
found := d.root.find(normalized)
if found.path() != normalized {
return nil, storagedriver.PathNotFoundError{Path: path}
}
fi := storagedriver.FileI... | [
"func",
"(",
"d",
"*",
"driver",
")",
"Stat",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
")",
"(",
"storagedriver",
".",
"FileInfo",
",",
"error",
")",
"{",
"d",
".",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"defer",
"d",
".",
"m... | // Stat returns info about the provided path. | [
"Stat",
"returns",
"info",
"about",
"the",
"provided",
"path",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/inmemory/driver.go#L154-L176 | train |
docker/distribution | registry/storage/driver/filesystem/driver.go | New | func New(params DriverParameters) *Driver {
fsDriver := &driver{rootDirectory: params.RootDirectory}
return &Driver{
baseEmbed: baseEmbed{
Base: base.Base{
StorageDriver: base.NewRegulator(fsDriver, params.MaxThreads),
},
},
}
} | go | func New(params DriverParameters) *Driver {
fsDriver := &driver{rootDirectory: params.RootDirectory}
return &Driver{
baseEmbed: baseEmbed{
Base: base.Base{
StorageDriver: base.NewRegulator(fsDriver, params.MaxThreads),
},
},
}
} | [
"func",
"New",
"(",
"params",
"DriverParameters",
")",
"*",
"Driver",
"{",
"fsDriver",
":=",
"&",
"driver",
"{",
"rootDirectory",
":",
"params",
".",
"RootDirectory",
"}",
"\n\n",
"return",
"&",
"Driver",
"{",
"baseEmbed",
":",
"baseEmbed",
"{",
"Base",
":... | // New constructs a new Driver with a given rootDirectory | [
"New",
"constructs",
"a",
"new",
"Driver",
"with",
"a",
"given",
"rootDirectory"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/filesystem/driver.go#L100-L110 | train |
docker/distribution | registry/storage/driver/filesystem/driver.go | fullPath | func (d *driver) fullPath(subPath string) string {
return path.Join(d.rootDirectory, subPath)
} | go | func (d *driver) fullPath(subPath string) string {
return path.Join(d.rootDirectory, subPath)
} | [
"func",
"(",
"d",
"*",
"driver",
")",
"fullPath",
"(",
"subPath",
"string",
")",
"string",
"{",
"return",
"path",
".",
"Join",
"(",
"d",
".",
"rootDirectory",
",",
"subPath",
")",
"\n",
"}"
] | // fullPath returns the absolute path of a key within the Driver's storage. | [
"fullPath",
"returns",
"the",
"absolute",
"path",
"of",
"a",
"key",
"within",
"the",
"Driver",
"s",
"storage",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/filesystem/driver.go#L299-L301 | train |
docker/distribution | registry/handlers/helpers.go | closeResources | func closeResources(handler http.Handler, closers ...io.Closer) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
for _, closer := range closers {
defer closer.Close()
}
handler.ServeHTTP(w, r)
})
} | go | func closeResources(handler http.Handler, closers ...io.Closer) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
for _, closer := range closers {
defer closer.Close()
}
handler.ServeHTTP(w, r)
})
} | [
"func",
"closeResources",
"(",
"handler",
"http",
".",
"Handler",
",",
"closers",
"...",
"io",
".",
"Closer",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"... | // closeResources closes all the provided resources after running the target
// handler. | [
"closeResources",
"closes",
"all",
"the",
"provided",
"resources",
"after",
"running",
"the",
"target",
"handler",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/helpers.go#L14-L21 | train |
docker/distribution | registry/handlers/helpers.go | copyFullPayload | func copyFullPayload(ctx context.Context, responseWriter http.ResponseWriter, r *http.Request, destWriter io.Writer, limit int64, action string) error {
// Get a channel that tells us if the client disconnects
clientClosed := r.Context().Done()
var body = r.Body
if limit > 0 {
body = http.MaxBytesReader(responseW... | go | func copyFullPayload(ctx context.Context, responseWriter http.ResponseWriter, r *http.Request, destWriter io.Writer, limit int64, action string) error {
// Get a channel that tells us if the client disconnects
clientClosed := r.Context().Done()
var body = r.Body
if limit > 0 {
body = http.MaxBytesReader(responseW... | [
"func",
"copyFullPayload",
"(",
"ctx",
"context",
".",
"Context",
",",
"responseWriter",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"destWriter",
"io",
".",
"Writer",
",",
"limit",
"int64",
",",
"action",
"string",
")",
"err... | // copyFullPayload copies the payload of an HTTP request to destWriter. If it
// receives less content than expected, and the client disconnected during the
// upload, it avoids sending a 400 error to keep the logs cleaner.
//
// The copy will be limited to `limit` bytes, if limit is greater than zero. | [
"copyFullPayload",
"copies",
"the",
"payload",
"of",
"an",
"HTTP",
"request",
"to",
"destWriter",
".",
"If",
"it",
"receives",
"less",
"content",
"than",
"expected",
"and",
"the",
"client",
"disconnected",
"during",
"the",
"upload",
"it",
"avoids",
"sending",
... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/helpers.go#L28-L66 | train |
docker/distribution | manifest/manifestlist/manifestlist.go | References | func (m ManifestList) References() []distribution.Descriptor {
dependencies := make([]distribution.Descriptor, len(m.Manifests))
for i := range m.Manifests {
dependencies[i] = m.Manifests[i].Descriptor
}
return dependencies
} | go | func (m ManifestList) References() []distribution.Descriptor {
dependencies := make([]distribution.Descriptor, len(m.Manifests))
for i := range m.Manifests {
dependencies[i] = m.Manifests[i].Descriptor
}
return dependencies
} | [
"func",
"(",
"m",
"ManifestList",
")",
"References",
"(",
")",
"[",
"]",
"distribution",
".",
"Descriptor",
"{",
"dependencies",
":=",
"make",
"(",
"[",
"]",
"distribution",
".",
"Descriptor",
",",
"len",
"(",
"m",
".",
"Manifests",
")",
")",
"\n",
"fo... | // References returns the distribution descriptors for the referenced image
// manifests. | [
"References",
"returns",
"the",
"distribution",
"descriptors",
"for",
"the",
"referenced",
"image",
"manifests",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/manifestlist/manifestlist.go#L125-L132 | train |
docker/distribution | manifest/manifestlist/manifestlist.go | FromDescriptors | func FromDescriptors(descriptors []ManifestDescriptor) (*DeserializedManifestList, error) {
var mediaType string
if len(descriptors) > 0 && descriptors[0].Descriptor.MediaType == v1.MediaTypeImageManifest {
mediaType = v1.MediaTypeImageIndex
} else {
mediaType = MediaTypeManifestList
}
return FromDescriptorsW... | go | func FromDescriptors(descriptors []ManifestDescriptor) (*DeserializedManifestList, error) {
var mediaType string
if len(descriptors) > 0 && descriptors[0].Descriptor.MediaType == v1.MediaTypeImageManifest {
mediaType = v1.MediaTypeImageIndex
} else {
mediaType = MediaTypeManifestList
}
return FromDescriptorsW... | [
"func",
"FromDescriptors",
"(",
"descriptors",
"[",
"]",
"ManifestDescriptor",
")",
"(",
"*",
"DeserializedManifestList",
",",
"error",
")",
"{",
"var",
"mediaType",
"string",
"\n",
"if",
"len",
"(",
"descriptors",
")",
">",
"0",
"&&",
"descriptors",
"[",
"0... | // FromDescriptors takes a slice of descriptors, and returns a
// DeserializedManifestList which contains the resulting manifest list
// and its JSON representation. | [
"FromDescriptors",
"takes",
"a",
"slice",
"of",
"descriptors",
"and",
"returns",
"a",
"DeserializedManifestList",
"which",
"contains",
"the",
"resulting",
"manifest",
"list",
"and",
"its",
"JSON",
"representation",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/manifestlist/manifestlist.go#L146-L155 | train |
docker/distribution | manifest/manifestlist/manifestlist.go | FromDescriptorsWithMediaType | func FromDescriptorsWithMediaType(descriptors []ManifestDescriptor, mediaType string) (*DeserializedManifestList, error) {
m := ManifestList{
Versioned: manifest.Versioned{
SchemaVersion: 2,
MediaType: mediaType,
},
}
m.Manifests = make([]ManifestDescriptor, len(descriptors))
copy(m.Manifests, descri... | go | func FromDescriptorsWithMediaType(descriptors []ManifestDescriptor, mediaType string) (*DeserializedManifestList, error) {
m := ManifestList{
Versioned: manifest.Versioned{
SchemaVersion: 2,
MediaType: mediaType,
},
}
m.Manifests = make([]ManifestDescriptor, len(descriptors))
copy(m.Manifests, descri... | [
"func",
"FromDescriptorsWithMediaType",
"(",
"descriptors",
"[",
"]",
"ManifestDescriptor",
",",
"mediaType",
"string",
")",
"(",
"*",
"DeserializedManifestList",
",",
"error",
")",
"{",
"m",
":=",
"ManifestList",
"{",
"Versioned",
":",
"manifest",
".",
"Versioned... | // FromDescriptorsWithMediaType is for testing purposes, it's useful to be able to specify the media type explicitly | [
"FromDescriptorsWithMediaType",
"is",
"for",
"testing",
"purposes",
"it",
"s",
"useful",
"to",
"be",
"able",
"to",
"specify",
"the",
"media",
"type",
"explicitly"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/manifestlist/manifestlist.go#L158-L176 | train |
docker/distribution | manifest/manifestlist/manifestlist.go | UnmarshalJSON | func (m *DeserializedManifestList) UnmarshalJSON(b []byte) error {
m.canonical = make([]byte, len(b))
// store manifest list in canonical
copy(m.canonical, b)
// Unmarshal canonical JSON into ManifestList object
var manifestList ManifestList
if err := json.Unmarshal(m.canonical, &manifestList); err != nil {
re... | go | func (m *DeserializedManifestList) UnmarshalJSON(b []byte) error {
m.canonical = make([]byte, len(b))
// store manifest list in canonical
copy(m.canonical, b)
// Unmarshal canonical JSON into ManifestList object
var manifestList ManifestList
if err := json.Unmarshal(m.canonical, &manifestList); err != nil {
re... | [
"func",
"(",
"m",
"*",
"DeserializedManifestList",
")",
"UnmarshalJSON",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"m",
".",
"canonical",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"len",
"(",
"b",
")",
")",
"\n",
"// store manifest list in canonical"... | // UnmarshalJSON populates a new ManifestList struct from JSON data. | [
"UnmarshalJSON",
"populates",
"a",
"new",
"ManifestList",
"struct",
"from",
"JSON",
"data",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/manifestlist/manifestlist.go#L179-L193 | train |
docker/distribution | manifest/manifestlist/manifestlist.go | Payload | func (m DeserializedManifestList) Payload() (string, []byte, error) {
var mediaType string
if m.MediaType == "" {
mediaType = v1.MediaTypeImageIndex
} else {
mediaType = m.MediaType
}
return mediaType, m.canonical, nil
} | go | func (m DeserializedManifestList) Payload() (string, []byte, error) {
var mediaType string
if m.MediaType == "" {
mediaType = v1.MediaTypeImageIndex
} else {
mediaType = m.MediaType
}
return mediaType, m.canonical, nil
} | [
"func",
"(",
"m",
"DeserializedManifestList",
")",
"Payload",
"(",
")",
"(",
"string",
",",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"mediaType",
"string",
"\n",
"if",
"m",
".",
"MediaType",
"==",
"\"",
"\"",
"{",
"mediaType",
"=",
"v1",
".",... | // Payload returns the raw content of the manifest list. The contents can be
// used to calculate the content identifier. | [
"Payload",
"returns",
"the",
"raw",
"content",
"of",
"the",
"manifest",
"list",
".",
"The",
"contents",
"can",
"be",
"used",
"to",
"calculate",
"the",
"content",
"identifier",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/manifestlist/manifestlist.go#L207-L216 | train |
docker/distribution | registry/handlers/tags.go | tagsDispatcher | func tagsDispatcher(ctx *Context, r *http.Request) http.Handler {
tagsHandler := &tagsHandler{
Context: ctx,
}
return handlers.MethodHandler{
"GET": http.HandlerFunc(tagsHandler.GetTags),
}
} | go | func tagsDispatcher(ctx *Context, r *http.Request) http.Handler {
tagsHandler := &tagsHandler{
Context: ctx,
}
return handlers.MethodHandler{
"GET": http.HandlerFunc(tagsHandler.GetTags),
}
} | [
"func",
"tagsDispatcher",
"(",
"ctx",
"*",
"Context",
",",
"r",
"*",
"http",
".",
"Request",
")",
"http",
".",
"Handler",
"{",
"tagsHandler",
":=",
"&",
"tagsHandler",
"{",
"Context",
":",
"ctx",
",",
"}",
"\n\n",
"return",
"handlers",
".",
"MethodHandle... | // tagsDispatcher constructs the tags handler api endpoint. | [
"tagsDispatcher",
"constructs",
"the",
"tags",
"handler",
"api",
"endpoint",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/tags.go#L14-L22 | train |
docker/distribution | registry/handlers/tags.go | GetTags | func (th *tagsHandler) GetTags(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
tagService := th.Repository.Tags(th)
tags, err := tagService.All(th)
if err != nil {
switch err := err.(type) {
case distribution.ErrRepositoryUnknown:
th.Errors = append(th.Errors, v2.ErrorCodeNameUnknown.WithDeta... | go | func (th *tagsHandler) GetTags(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
tagService := th.Repository.Tags(th)
tags, err := tagService.All(th)
if err != nil {
switch err := err.(type) {
case distribution.ErrRepositoryUnknown:
th.Errors = append(th.Errors, v2.ErrorCodeNameUnknown.WithDeta... | [
"func",
"(",
"th",
"*",
"tagsHandler",
")",
"GetTags",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"defer",
"r",
".",
"Body",
".",
"Close",
"(",
")",
"\n\n",
"tagService",
":=",
"th",
".",
"Repository",
... | // GetTags returns a json list of tags for a specific image name. | [
"GetTags",
"returns",
"a",
"json",
"list",
"of",
"tags",
"for",
"a",
"specific",
"image",
"name",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/tags.go#L35-L62 | train |
docker/distribution | registry/storage/driver/factory/factory.go | Create | func Create(name string, parameters map[string]interface{}) (storagedriver.StorageDriver, error) {
driverFactory, ok := driverFactories[name]
if !ok {
return nil, InvalidStorageDriverError{name}
}
return driverFactory.Create(parameters)
} | go | func Create(name string, parameters map[string]interface{}) (storagedriver.StorageDriver, error) {
driverFactory, ok := driverFactories[name]
if !ok {
return nil, InvalidStorageDriverError{name}
}
return driverFactory.Create(parameters)
} | [
"func",
"Create",
"(",
"name",
"string",
",",
"parameters",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"storagedriver",
".",
"StorageDriver",
",",
"error",
")",
"{",
"driverFactory",
",",
"ok",
":=",
"driverFactories",
"[",
"name",
"]",
... | // Create a new storagedriver.StorageDriver with the given name and
// parameters. To use a driver, the StorageDriverFactory must first be
// registered with the given name. If no drivers are found, an
// InvalidStorageDriverError is returned | [
"Create",
"a",
"new",
"storagedriver",
".",
"StorageDriver",
"with",
"the",
"given",
"name",
"and",
"parameters",
".",
"To",
"use",
"a",
"driver",
"the",
"StorageDriverFactory",
"must",
"first",
"be",
"registered",
"with",
"the",
"given",
"name",
".",
"If",
... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/factory/factory.go#L49-L55 | train |
docker/distribution | registry/api/v2/routes.go | RouterWithPrefix | func RouterWithPrefix(prefix string) *mux.Router {
rootRouter := mux.NewRouter()
router := rootRouter
if prefix != "" {
router = router.PathPrefix(prefix).Subrouter()
}
router.StrictSlash(true)
for _, descriptor := range routeDescriptors {
router.Path(descriptor.Path).Name(descriptor.Name)
}
return rootR... | go | func RouterWithPrefix(prefix string) *mux.Router {
rootRouter := mux.NewRouter()
router := rootRouter
if prefix != "" {
router = router.PathPrefix(prefix).Subrouter()
}
router.StrictSlash(true)
for _, descriptor := range routeDescriptors {
router.Path(descriptor.Path).Name(descriptor.Name)
}
return rootR... | [
"func",
"RouterWithPrefix",
"(",
"prefix",
"string",
")",
"*",
"mux",
".",
"Router",
"{",
"rootRouter",
":=",
"mux",
".",
"NewRouter",
"(",
")",
"\n",
"router",
":=",
"rootRouter",
"\n",
"if",
"prefix",
"!=",
"\"",
"\"",
"{",
"router",
"=",
"router",
"... | // RouterWithPrefix builds a gorilla router with a configured prefix
// on all routes. | [
"RouterWithPrefix",
"builds",
"a",
"gorilla",
"router",
"with",
"a",
"configured",
"prefix",
"on",
"all",
"routes",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/api/v2/routes.go#L26-L40 | train |
docker/distribution | health/health.go | Update | func (u *updater) Update(status error) {
u.mu.Lock()
defer u.mu.Unlock()
u.status = status
} | go | func (u *updater) Update(status error) {
u.mu.Lock()
defer u.mu.Unlock()
u.status = status
} | [
"func",
"(",
"u",
"*",
"updater",
")",
"Update",
"(",
"status",
"error",
")",
"{",
"u",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"u",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"u",
".",
"status",
"=",
"status",
"\n",
"}"
] | // Update implements the Updater interface, allowing asynchronous access to
// the status of a Checker. | [
"Update",
"implements",
"the",
"Updater",
"interface",
"allowing",
"asynchronous",
"access",
"to",
"the",
"status",
"of",
"a",
"Checker",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/health/health.go#L78-L83 | train |
docker/distribution | health/health.go | Update | func (tu *thresholdUpdater) Update(status error) {
tu.mu.Lock()
defer tu.mu.Unlock()
if status == nil {
tu.count = 0
} else if tu.count < tu.threshold {
tu.count++
}
tu.status = status
} | go | func (tu *thresholdUpdater) Update(status error) {
tu.mu.Lock()
defer tu.mu.Unlock()
if status == nil {
tu.count = 0
} else if tu.count < tu.threshold {
tu.count++
}
tu.status = status
} | [
"func",
"(",
"tu",
"*",
"thresholdUpdater",
")",
"Update",
"(",
"status",
"error",
")",
"{",
"tu",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"tu",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"status",
"==",
"nil",
"{",
"tu",
".",
"... | // thresholdUpdater implements the Updater interface, allowing asynchronous
// access to the status of a Checker. | [
"thresholdUpdater",
"implements",
"the",
"Updater",
"interface",
"allowing",
"asynchronous",
"access",
"to",
"the",
"status",
"of",
"a",
"Checker",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/health/health.go#L115-L126 | train |
docker/distribution | health/health.go | PeriodicChecker | func PeriodicChecker(check Checker, period time.Duration) Checker {
u := NewStatusUpdater()
go func() {
t := time.NewTicker(period)
for {
<-t.C
u.Update(check.Check())
}
}()
return u
} | go | func PeriodicChecker(check Checker, period time.Duration) Checker {
u := NewStatusUpdater()
go func() {
t := time.NewTicker(period)
for {
<-t.C
u.Update(check.Check())
}
}()
return u
} | [
"func",
"PeriodicChecker",
"(",
"check",
"Checker",
",",
"period",
"time",
".",
"Duration",
")",
"Checker",
"{",
"u",
":=",
"NewStatusUpdater",
"(",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"t",
":=",
"time",
".",
"NewTicker",
"(",
"period",
")",
"\n",
... | // PeriodicChecker wraps an updater to provide a periodic checker | [
"PeriodicChecker",
"wraps",
"an",
"updater",
"to",
"provide",
"a",
"periodic",
"checker"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/health/health.go#L134-L145 | train |
docker/distribution | health/health.go | PeriodicThresholdChecker | func PeriodicThresholdChecker(check Checker, period time.Duration, threshold int) Checker {
tu := NewThresholdStatusUpdater(threshold)
go func() {
t := time.NewTicker(period)
for {
<-t.C
tu.Update(check.Check())
}
}()
return tu
} | go | func PeriodicThresholdChecker(check Checker, period time.Duration, threshold int) Checker {
tu := NewThresholdStatusUpdater(threshold)
go func() {
t := time.NewTicker(period)
for {
<-t.C
tu.Update(check.Check())
}
}()
return tu
} | [
"func",
"PeriodicThresholdChecker",
"(",
"check",
"Checker",
",",
"period",
"time",
".",
"Duration",
",",
"threshold",
"int",
")",
"Checker",
"{",
"tu",
":=",
"NewThresholdStatusUpdater",
"(",
"threshold",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"t",
":=",
... | // PeriodicThresholdChecker wraps an updater to provide a periodic checker that
// uses a threshold before it changes status | [
"PeriodicThresholdChecker",
"wraps",
"an",
"updater",
"to",
"provide",
"a",
"periodic",
"checker",
"that",
"uses",
"a",
"threshold",
"before",
"it",
"changes",
"status"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/health/health.go#L149-L160 | train |
docker/distribution | health/health.go | CheckStatus | func (registry *Registry) CheckStatus() map[string]string { // TODO(stevvooe) this needs a proper type
registry.mu.RLock()
defer registry.mu.RUnlock()
statusKeys := make(map[string]string)
for k, v := range registry.registeredChecks {
err := v.Check()
if err != nil {
statusKeys[k] = err.Error()
}
}
retu... | go | func (registry *Registry) CheckStatus() map[string]string { // TODO(stevvooe) this needs a proper type
registry.mu.RLock()
defer registry.mu.RUnlock()
statusKeys := make(map[string]string)
for k, v := range registry.registeredChecks {
err := v.Check()
if err != nil {
statusKeys[k] = err.Error()
}
}
retu... | [
"func",
"(",
"registry",
"*",
"Registry",
")",
"CheckStatus",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"// TODO(stevvooe) this needs a proper type",
"registry",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"registry",
".",
"mu",
".",
"RUnlock... | // CheckStatus returns a map with all the current health check errors | [
"CheckStatus",
"returns",
"a",
"map",
"with",
"all",
"the",
"current",
"health",
"check",
"errors"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/health/health.go#L163-L175 | train |
docker/distribution | health/health.go | Register | func (registry *Registry) Register(name string, check Checker) {
if registry == nil {
registry = DefaultRegistry
}
registry.mu.Lock()
defer registry.mu.Unlock()
_, ok := registry.registeredChecks[name]
if ok {
panic("Check already exists: " + name)
}
registry.registeredChecks[name] = check
} | go | func (registry *Registry) Register(name string, check Checker) {
if registry == nil {
registry = DefaultRegistry
}
registry.mu.Lock()
defer registry.mu.Unlock()
_, ok := registry.registeredChecks[name]
if ok {
panic("Check already exists: " + name)
}
registry.registeredChecks[name] = check
} | [
"func",
"(",
"registry",
"*",
"Registry",
")",
"Register",
"(",
"name",
"string",
",",
"check",
"Checker",
")",
"{",
"if",
"registry",
"==",
"nil",
"{",
"registry",
"=",
"DefaultRegistry",
"\n",
"}",
"\n",
"registry",
".",
"mu",
".",
"Lock",
"(",
")",
... | // Register associates the checker with the provided name. | [
"Register",
"associates",
"the",
"checker",
"with",
"the",
"provided",
"name",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/health/health.go#L184-L195 | train |
docker/distribution | health/health.go | StatusHandler | func StatusHandler(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
checks := CheckStatus()
status := http.StatusOK
// If there is an error, return 503
if len(checks) != 0 {
status = http.StatusServiceUnavailable
}
statusResponse(w, r, status, checks)
} else {
http.NotFound(w, r)
}... | go | func StatusHandler(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
checks := CheckStatus()
status := http.StatusOK
// If there is an error, return 503
if len(checks) != 0 {
status = http.StatusServiceUnavailable
}
statusResponse(w, r, status, checks)
} else {
http.NotFound(w, r)
}... | [
"func",
"StatusHandler",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"r",
".",
"Method",
"==",
"\"",
"\"",
"{",
"checks",
":=",
"CheckStatus",
"(",
")",
"\n",
"status",
":=",
"http",
".",
"StatusOK"... | // StatusHandler returns a JSON blob with all the currently registered Health Checks
// and their corresponding status.
// Returns 503 if any Error status exists, 200 otherwise | [
"StatusHandler",
"returns",
"a",
"JSON",
"blob",
"with",
"all",
"the",
"currently",
"registered",
"Health",
"Checks",
"and",
"their",
"corresponding",
"status",
".",
"Returns",
"503",
"if",
"any",
"Error",
"status",
"exists",
"200",
"otherwise"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/health/health.go#L242-L256 | train |
docker/distribution | health/health.go | Handler | func Handler(handler http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
checks := CheckStatus()
if len(checks) != 0 {
errcode.ServeJSON(w, errcode.ErrorCodeUnavailable.
WithDetail("health check failed: please see /debug/health"))
return
}
handler.Serv... | go | func Handler(handler http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
checks := CheckStatus()
if len(checks) != 0 {
errcode.ServeJSON(w, errcode.ErrorCodeUnavailable.
WithDetail("health check failed: please see /debug/health"))
return
}
handler.Serv... | [
"func",
"Handler",
"(",
"handler",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"checks",
":=",
... | // Handler returns a handler that will return 503 response code if the health
// checks have failed. If everything is okay with the health checks, the
// handler will pass through to the provided handler. Use this handler to
// disable a web application when the health checks fail. | [
"Handler",
"returns",
"a",
"handler",
"that",
"will",
"return",
"503",
"response",
"code",
"if",
"the",
"health",
"checks",
"have",
"failed",
".",
"If",
"everything",
"is",
"okay",
"with",
"the",
"health",
"checks",
"the",
"handler",
"will",
"pass",
"through... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/health/health.go#L262-L273 | train |
docker/distribution | health/health.go | statusResponse | func statusResponse(w http.ResponseWriter, r *http.Request, status int, checks map[string]string) {
p, err := json.Marshal(checks)
if err != nil {
context.GetLogger(context.Background()).Errorf("error serializing health status: %v", err)
p, err = json.Marshal(struct {
ServerError string `json:"server_error"`
... | go | func statusResponse(w http.ResponseWriter, r *http.Request, status int, checks map[string]string) {
p, err := json.Marshal(checks)
if err != nil {
context.GetLogger(context.Background()).Errorf("error serializing health status: %v", err)
p, err = json.Marshal(struct {
ServerError string `json:"server_error"`
... | [
"func",
"statusResponse",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"status",
"int",
",",
"checks",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"p",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"checks"... | // statusResponse completes the request with a response describing the health
// of the service. | [
"statusResponse",
"completes",
"the",
"request",
"with",
"a",
"response",
"describing",
"the",
"health",
"of",
"the",
"service",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/health/health.go#L277-L300 | train |
docker/distribution | registry/api/v2/urls.go | NewURLBuilder | func NewURLBuilder(root *url.URL, relative bool) *URLBuilder {
return &URLBuilder{
root: root,
router: Router(),
relative: relative,
}
} | go | func NewURLBuilder(root *url.URL, relative bool) *URLBuilder {
return &URLBuilder{
root: root,
router: Router(),
relative: relative,
}
} | [
"func",
"NewURLBuilder",
"(",
"root",
"*",
"url",
".",
"URL",
",",
"relative",
"bool",
")",
"*",
"URLBuilder",
"{",
"return",
"&",
"URLBuilder",
"{",
"root",
":",
"root",
",",
"router",
":",
"Router",
"(",
")",
",",
"relative",
":",
"relative",
",",
... | // NewURLBuilder creates a URLBuilder with provided root url object. | [
"NewURLBuilder",
"creates",
"a",
"URLBuilder",
"with",
"provided",
"root",
"url",
"object",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/api/v2/urls.go#L27-L33 | train |
docker/distribution | registry/api/v2/urls.go | NewURLBuilderFromString | func NewURLBuilderFromString(root string, relative bool) (*URLBuilder, error) {
u, err := url.Parse(root)
if err != nil {
return nil, err
}
return NewURLBuilder(u, relative), nil
} | go | func NewURLBuilderFromString(root string, relative bool) (*URLBuilder, error) {
u, err := url.Parse(root)
if err != nil {
return nil, err
}
return NewURLBuilder(u, relative), nil
} | [
"func",
"NewURLBuilderFromString",
"(",
"root",
"string",
",",
"relative",
"bool",
")",
"(",
"*",
"URLBuilder",
",",
"error",
")",
"{",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"root",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil"... | // NewURLBuilderFromString workes identically to NewURLBuilder except it takes
// a string argument for the root, returning an error if it is not a valid
// url. | [
"NewURLBuilderFromString",
"workes",
"identically",
"to",
"NewURLBuilder",
"except",
"it",
"takes",
"a",
"string",
"argument",
"for",
"the",
"root",
"returning",
"an",
"error",
"if",
"it",
"is",
"not",
"a",
"valid",
"url",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/api/v2/urls.go#L38-L45 | train |
docker/distribution | registry/api/v2/urls.go | BuildCatalogURL | func (ub *URLBuilder) BuildCatalogURL(values ...url.Values) (string, error) {
route := ub.cloneRoute(RouteNameCatalog)
catalogURL, err := route.URL()
if err != nil {
return "", err
}
return appendValuesURL(catalogURL, values...).String(), nil
} | go | func (ub *URLBuilder) BuildCatalogURL(values ...url.Values) (string, error) {
route := ub.cloneRoute(RouteNameCatalog)
catalogURL, err := route.URL()
if err != nil {
return "", err
}
return appendValuesURL(catalogURL, values...).String(), nil
} | [
"func",
"(",
"ub",
"*",
"URLBuilder",
")",
"BuildCatalogURL",
"(",
"values",
"...",
"url",
".",
"Values",
")",
"(",
"string",
",",
"error",
")",
"{",
"route",
":=",
"ub",
".",
"cloneRoute",
"(",
"RouteNameCatalog",
")",
"\n\n",
"catalogURL",
",",
"err",
... | // BuildCatalogURL constructs a url get a catalog of repositories | [
"BuildCatalogURL",
"constructs",
"a",
"url",
"get",
"a",
"catalog",
"of",
"repositories"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/api/v2/urls.go#L119-L128 | train |
docker/distribution | registry/api/v2/urls.go | BuildTagsURL | func (ub *URLBuilder) BuildTagsURL(name reference.Named) (string, error) {
route := ub.cloneRoute(RouteNameTags)
tagsURL, err := route.URL("name", name.Name())
if err != nil {
return "", err
}
return tagsURL.String(), nil
} | go | func (ub *URLBuilder) BuildTagsURL(name reference.Named) (string, error) {
route := ub.cloneRoute(RouteNameTags)
tagsURL, err := route.URL("name", name.Name())
if err != nil {
return "", err
}
return tagsURL.String(), nil
} | [
"func",
"(",
"ub",
"*",
"URLBuilder",
")",
"BuildTagsURL",
"(",
"name",
"reference",
".",
"Named",
")",
"(",
"string",
",",
"error",
")",
"{",
"route",
":=",
"ub",
".",
"cloneRoute",
"(",
"RouteNameTags",
")",
"\n\n",
"tagsURL",
",",
"err",
":=",
"rout... | // BuildTagsURL constructs a url to list the tags in the named repository. | [
"BuildTagsURL",
"constructs",
"a",
"url",
"to",
"list",
"the",
"tags",
"in",
"the",
"named",
"repository",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/api/v2/urls.go#L131-L140 | train |
docker/distribution | registry/api/v2/urls.go | BuildManifestURL | func (ub *URLBuilder) BuildManifestURL(ref reference.Named) (string, error) {
route := ub.cloneRoute(RouteNameManifest)
tagOrDigest := ""
switch v := ref.(type) {
case reference.Tagged:
tagOrDigest = v.Tag()
case reference.Digested:
tagOrDigest = v.Digest().String()
default:
return "", fmt.Errorf("referenc... | go | func (ub *URLBuilder) BuildManifestURL(ref reference.Named) (string, error) {
route := ub.cloneRoute(RouteNameManifest)
tagOrDigest := ""
switch v := ref.(type) {
case reference.Tagged:
tagOrDigest = v.Tag()
case reference.Digested:
tagOrDigest = v.Digest().String()
default:
return "", fmt.Errorf("referenc... | [
"func",
"(",
"ub",
"*",
"URLBuilder",
")",
"BuildManifestURL",
"(",
"ref",
"reference",
".",
"Named",
")",
"(",
"string",
",",
"error",
")",
"{",
"route",
":=",
"ub",
".",
"cloneRoute",
"(",
"RouteNameManifest",
")",
"\n\n",
"tagOrDigest",
":=",
"\"",
"\... | // BuildManifestURL constructs a url for the manifest identified by name and
// reference. The argument reference may be either a tag or digest. | [
"BuildManifestURL",
"constructs",
"a",
"url",
"for",
"the",
"manifest",
"identified",
"by",
"name",
"and",
"reference",
".",
"The",
"argument",
"reference",
"may",
"be",
"either",
"a",
"tag",
"or",
"digest",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/api/v2/urls.go#L144-L163 | train |
docker/distribution | registry/api/v2/urls.go | BuildBlobURL | func (ub *URLBuilder) BuildBlobURL(ref reference.Canonical) (string, error) {
route := ub.cloneRoute(RouteNameBlob)
layerURL, err := route.URL("name", ref.Name(), "digest", ref.Digest().String())
if err != nil {
return "", err
}
return layerURL.String(), nil
} | go | func (ub *URLBuilder) BuildBlobURL(ref reference.Canonical) (string, error) {
route := ub.cloneRoute(RouteNameBlob)
layerURL, err := route.URL("name", ref.Name(), "digest", ref.Digest().String())
if err != nil {
return "", err
}
return layerURL.String(), nil
} | [
"func",
"(",
"ub",
"*",
"URLBuilder",
")",
"BuildBlobURL",
"(",
"ref",
"reference",
".",
"Canonical",
")",
"(",
"string",
",",
"error",
")",
"{",
"route",
":=",
"ub",
".",
"cloneRoute",
"(",
"RouteNameBlob",
")",
"\n\n",
"layerURL",
",",
"err",
":=",
"... | // BuildBlobURL constructs the url for the blob identified by name and dgst. | [
"BuildBlobURL",
"constructs",
"the",
"url",
"for",
"the",
"blob",
"identified",
"by",
"name",
"and",
"dgst",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/api/v2/urls.go#L166-L175 | train |
docker/distribution | registry/api/v2/urls.go | BuildBlobUploadURL | func (ub *URLBuilder) BuildBlobUploadURL(name reference.Named, values ...url.Values) (string, error) {
route := ub.cloneRoute(RouteNameBlobUpload)
uploadURL, err := route.URL("name", name.Name())
if err != nil {
return "", err
}
return appendValuesURL(uploadURL, values...).String(), nil
} | go | func (ub *URLBuilder) BuildBlobUploadURL(name reference.Named, values ...url.Values) (string, error) {
route := ub.cloneRoute(RouteNameBlobUpload)
uploadURL, err := route.URL("name", name.Name())
if err != nil {
return "", err
}
return appendValuesURL(uploadURL, values...).String(), nil
} | [
"func",
"(",
"ub",
"*",
"URLBuilder",
")",
"BuildBlobUploadURL",
"(",
"name",
"reference",
".",
"Named",
",",
"values",
"...",
"url",
".",
"Values",
")",
"(",
"string",
",",
"error",
")",
"{",
"route",
":=",
"ub",
".",
"cloneRoute",
"(",
"RouteNameBlobUp... | // BuildBlobUploadURL constructs a url to begin a blob upload in the
// repository identified by name. | [
"BuildBlobUploadURL",
"constructs",
"a",
"url",
"to",
"begin",
"a",
"blob",
"upload",
"in",
"the",
"repository",
"identified",
"by",
"name",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/api/v2/urls.go#L179-L188 | train |
docker/distribution | registry/api/v2/urls.go | BuildBlobUploadChunkURL | func (ub *URLBuilder) BuildBlobUploadChunkURL(name reference.Named, uuid string, values ...url.Values) (string, error) {
route := ub.cloneRoute(RouteNameBlobUploadChunk)
uploadURL, err := route.URL("name", name.Name(), "uuid", uuid)
if err != nil {
return "", err
}
return appendValuesURL(uploadURL, values...).... | go | func (ub *URLBuilder) BuildBlobUploadChunkURL(name reference.Named, uuid string, values ...url.Values) (string, error) {
route := ub.cloneRoute(RouteNameBlobUploadChunk)
uploadURL, err := route.URL("name", name.Name(), "uuid", uuid)
if err != nil {
return "", err
}
return appendValuesURL(uploadURL, values...).... | [
"func",
"(",
"ub",
"*",
"URLBuilder",
")",
"BuildBlobUploadChunkURL",
"(",
"name",
"reference",
".",
"Named",
",",
"uuid",
"string",
",",
"values",
"...",
"url",
".",
"Values",
")",
"(",
"string",
",",
"error",
")",
"{",
"route",
":=",
"ub",
".",
"clon... | // BuildBlobUploadChunkURL constructs a url for the upload identified by uuid,
// including any url values. This should generally not be used by clients, as
// this url is provided by server implementations during the blob upload
// process. | [
"BuildBlobUploadChunkURL",
"constructs",
"a",
"url",
"for",
"the",
"upload",
"identified",
"by",
"uuid",
"including",
"any",
"url",
"values",
".",
"This",
"should",
"generally",
"not",
"be",
"used",
"by",
"clients",
"as",
"this",
"url",
"is",
"provided",
"by",... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/api/v2/urls.go#L194-L203 | train |
docker/distribution | registry/api/v2/urls.go | cloneRoute | func (ub *URLBuilder) cloneRoute(name string) clonedRoute {
route := new(mux.Route)
root := new(url.URL)
*route = *ub.router.GetRoute(name) // clone the route
*root = *ub.root
return clonedRoute{Route: route, root: root, relative: ub.relative}
} | go | func (ub *URLBuilder) cloneRoute(name string) clonedRoute {
route := new(mux.Route)
root := new(url.URL)
*route = *ub.router.GetRoute(name) // clone the route
*root = *ub.root
return clonedRoute{Route: route, root: root, relative: ub.relative}
} | [
"func",
"(",
"ub",
"*",
"URLBuilder",
")",
"cloneRoute",
"(",
"name",
"string",
")",
"clonedRoute",
"{",
"route",
":=",
"new",
"(",
"mux",
".",
"Route",
")",
"\n",
"root",
":=",
"new",
"(",
"url",
".",
"URL",
")",
"\n\n",
"*",
"route",
"=",
"*",
... | // clondedRoute returns a clone of the named route from the router. Routes
// must be cloned to avoid modifying them during url generation. | [
"clondedRoute",
"returns",
"a",
"clone",
"of",
"the",
"named",
"route",
"from",
"the",
"router",
".",
"Routes",
"must",
"be",
"cloned",
"to",
"avoid",
"modifying",
"them",
"during",
"url",
"generation",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/api/v2/urls.go#L207-L215 | train |
docker/distribution | registry/api/v2/urls.go | appendValuesURL | func appendValuesURL(u *url.URL, values ...url.Values) *url.URL {
merged := u.Query()
for _, v := range values {
for k, vv := range v {
merged[k] = append(merged[k], vv...)
}
}
u.RawQuery = merged.Encode()
return u
} | go | func appendValuesURL(u *url.URL, values ...url.Values) *url.URL {
merged := u.Query()
for _, v := range values {
for k, vv := range v {
merged[k] = append(merged[k], vv...)
}
}
u.RawQuery = merged.Encode()
return u
} | [
"func",
"appendValuesURL",
"(",
"u",
"*",
"url",
".",
"URL",
",",
"values",
"...",
"url",
".",
"Values",
")",
"*",
"url",
".",
"URL",
"{",
"merged",
":=",
"u",
".",
"Query",
"(",
")",
"\n\n",
"for",
"_",
",",
"v",
":=",
"range",
"values",
"{",
... | // appendValuesURL appends the parameters to the url. | [
"appendValuesURL",
"appends",
"the",
"parameters",
"to",
"the",
"url",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/api/v2/urls.go#L243-L254 | train |
docker/distribution | notifications/http.go | newHTTPSink | func newHTTPSink(u string, timeout time.Duration, headers http.Header, transport *http.Transport, listeners ...httpStatusListener) *httpSink {
if transport == nil {
transport = http.DefaultTransport.(*http.Transport)
}
return &httpSink{
url: u,
listeners: listeners,
client: &http.Client{
Transport: ... | go | func newHTTPSink(u string, timeout time.Duration, headers http.Header, transport *http.Transport, listeners ...httpStatusListener) *httpSink {
if transport == nil {
transport = http.DefaultTransport.(*http.Transport)
}
return &httpSink{
url: u,
listeners: listeners,
client: &http.Client{
Transport: ... | [
"func",
"newHTTPSink",
"(",
"u",
"string",
",",
"timeout",
"time",
".",
"Duration",
",",
"headers",
"http",
".",
"Header",
",",
"transport",
"*",
"http",
".",
"Transport",
",",
"listeners",
"...",
"httpStatusListener",
")",
"*",
"httpSink",
"{",
"if",
"tra... | // newHTTPSink returns an unreliable, single-flight http sink. Wrap in other
// sinks for increased reliability. | [
"newHTTPSink",
"returns",
"an",
"unreliable",
"single",
"-",
"flight",
"http",
"sink",
".",
"Wrap",
"in",
"other",
"sinks",
"for",
"increased",
"reliability",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/notifications/http.go#L29-L44 | train |
docker/distribution | notifications/http.go | Write | func (hs *httpSink) Write(events ...Event) error {
hs.mu.Lock()
defer hs.mu.Unlock()
defer hs.client.Transport.(*headerRoundTripper).CloseIdleConnections()
if hs.closed {
return ErrSinkClosed
}
envelope := Envelope{
Events: events,
}
// TODO(stevvooe): It is not ideal to keep re-encoding the request body... | go | func (hs *httpSink) Write(events ...Event) error {
hs.mu.Lock()
defer hs.mu.Unlock()
defer hs.client.Transport.(*headerRoundTripper).CloseIdleConnections()
if hs.closed {
return ErrSinkClosed
}
envelope := Envelope{
Events: events,
}
// TODO(stevvooe): It is not ideal to keep re-encoding the request body... | [
"func",
"(",
"hs",
"*",
"httpSink",
")",
"Write",
"(",
"events",
"...",
"Event",
")",
"error",
"{",
"hs",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"hs",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"defer",
"hs",
".",
"client",
".",
"Trans... | // Accept makes an attempt to notify the endpoint, returning an error if it
// fails. It is the caller's responsibility to retry on error. The events are
// accepted or rejected as a group. | [
"Accept",
"makes",
"an",
"attempt",
"to",
"notify",
"the",
"endpoint",
"returning",
"an",
"error",
"if",
"it",
"fails",
".",
"It",
"is",
"the",
"caller",
"s",
"responsibility",
"to",
"retry",
"on",
"error",
".",
"The",
"events",
"are",
"accepted",
"or",
... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/notifications/http.go#L56-L111 | train |
docker/distribution | notifications/http.go | Close | func (hs *httpSink) Close() error {
hs.mu.Lock()
defer hs.mu.Unlock()
if hs.closed {
return fmt.Errorf("httpsink: already closed")
}
hs.closed = true
return nil
} | go | func (hs *httpSink) Close() error {
hs.mu.Lock()
defer hs.mu.Unlock()
if hs.closed {
return fmt.Errorf("httpsink: already closed")
}
hs.closed = true
return nil
} | [
"func",
"(",
"hs",
"*",
"httpSink",
")",
"Close",
"(",
")",
"error",
"{",
"hs",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"hs",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"hs",
".",
"closed",
"{",
"return",
"fmt",
".",
"Errorf",
... | // Close the endpoint | [
"Close",
"the",
"endpoint"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/notifications/http.go#L114-L124 | train |
docker/distribution | registry/auth/auth.go | WithUser | func WithUser(ctx context.Context, user UserInfo) context.Context {
return userInfoContext{
Context: ctx,
user: user,
}
} | go | func WithUser(ctx context.Context, user UserInfo) context.Context {
return userInfoContext{
Context: ctx,
user: user,
}
} | [
"func",
"WithUser",
"(",
"ctx",
"context",
".",
"Context",
",",
"user",
"UserInfo",
")",
"context",
".",
"Context",
"{",
"return",
"userInfoContext",
"{",
"Context",
":",
"ctx",
",",
"user",
":",
"user",
",",
"}",
"\n",
"}"
] | // WithUser returns a context with the authorized user info. | [
"WithUser",
"returns",
"a",
"context",
"with",
"the",
"authorized",
"user",
"info",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/auth/auth.go#L115-L120 | train |
docker/distribution | registry/auth/auth.go | WithResources | func WithResources(ctx context.Context, resources []Resource) context.Context {
return resourceContext{
Context: ctx,
resources: resources,
}
} | go | func WithResources(ctx context.Context, resources []Resource) context.Context {
return resourceContext{
Context: ctx,
resources: resources,
}
} | [
"func",
"WithResources",
"(",
"ctx",
"context",
".",
"Context",
",",
"resources",
"[",
"]",
"Resource",
")",
"context",
".",
"Context",
"{",
"return",
"resourceContext",
"{",
"Context",
":",
"ctx",
",",
"resources",
":",
"resources",
",",
"}",
"\n",
"}"
] | // WithResources returns a context with the authorized resources. | [
"WithResources",
"returns",
"a",
"context",
"with",
"the",
"authorized",
"resources",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/auth/auth.go#L139-L144 | train |
docker/distribution | registry/auth/auth.go | AuthorizedResources | func AuthorizedResources(ctx context.Context) []Resource {
if resources, ok := ctx.Value(resourceKey{}).([]Resource); ok {
return resources
}
return nil
} | go | func AuthorizedResources(ctx context.Context) []Resource {
if resources, ok := ctx.Value(resourceKey{}).([]Resource); ok {
return resources
}
return nil
} | [
"func",
"AuthorizedResources",
"(",
"ctx",
"context",
".",
"Context",
")",
"[",
"]",
"Resource",
"{",
"if",
"resources",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"resourceKey",
"{",
"}",
")",
".",
"(",
"[",
"]",
"Resource",
")",
";",
"ok",
"{",
"... | // AuthorizedResources returns the list of resources which have
// been authorized for this request. | [
"AuthorizedResources",
"returns",
"the",
"list",
"of",
"resources",
"which",
"have",
"been",
"authorized",
"for",
"this",
"request",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/auth/auth.go#L163-L169 | train |
docker/distribution | registry/auth/auth.go | GetAccessController | func GetAccessController(name string, options map[string]interface{}) (AccessController, error) {
if initFunc, exists := accessControllers[name]; exists {
return initFunc(options)
}
return nil, fmt.Errorf("no access controller registered with name: %s", name)
} | go | func GetAccessController(name string, options map[string]interface{}) (AccessController, error) {
if initFunc, exists := accessControllers[name]; exists {
return initFunc(options)
}
return nil, fmt.Errorf("no access controller registered with name: %s", name)
} | [
"func",
"GetAccessController",
"(",
"name",
"string",
",",
"options",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"AccessController",
",",
"error",
")",
"{",
"if",
"initFunc",
",",
"exists",
":=",
"accessControllers",
"[",
"name",
"]",
";",... | // GetAccessController constructs an AccessController
// with the given options using the named backend. | [
"GetAccessController",
"constructs",
"an",
"AccessController",
"with",
"the",
"given",
"options",
"using",
"the",
"named",
"backend",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/auth/auth.go#L195-L201 | train |
docker/distribution | reference/normalize.go | ParseNormalizedNamed | func ParseNormalizedNamed(s string) (Named, error) {
if ok := anchoredIdentifierRegexp.MatchString(s); ok {
return nil, fmt.Errorf("invalid repository name (%s), cannot specify 64-byte hexadecimal strings", s)
}
domain, remainder := splitDockerDomain(s)
var remoteName string
if tagSep := strings.IndexRune(remain... | go | func ParseNormalizedNamed(s string) (Named, error) {
if ok := anchoredIdentifierRegexp.MatchString(s); ok {
return nil, fmt.Errorf("invalid repository name (%s), cannot specify 64-byte hexadecimal strings", s)
}
domain, remainder := splitDockerDomain(s)
var remoteName string
if tagSep := strings.IndexRune(remain... | [
"func",
"ParseNormalizedNamed",
"(",
"s",
"string",
")",
"(",
"Named",
",",
"error",
")",
"{",
"if",
"ok",
":=",
"anchoredIdentifierRegexp",
".",
"MatchString",
"(",
"s",
")",
";",
"ok",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",... | // ParseNormalizedNamed parses a string into a named reference
// transforming a familiar name from Docker UI to a fully
// qualified reference. If the value may be an identifier
// use ParseAnyReference. | [
"ParseNormalizedNamed",
"parses",
"a",
"string",
"into",
"a",
"named",
"reference",
"transforming",
"a",
"familiar",
"name",
"from",
"Docker",
"UI",
"to",
"a",
"fully",
"qualified",
"reference",
".",
"If",
"the",
"value",
"may",
"be",
"an",
"identifier",
"use"... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/reference/normalize.go#L33-L57 | train |
docker/distribution | reference/normalize.go | splitDockerDomain | func splitDockerDomain(name string) (domain, remainder string) {
i := strings.IndexRune(name, '/')
if i == -1 || (!strings.ContainsAny(name[:i], ".:") && name[:i] != "localhost") {
domain, remainder = defaultDomain, name
} else {
domain, remainder = name[:i], name[i+1:]
}
if domain == legacyDefaultDomain {
d... | go | func splitDockerDomain(name string) (domain, remainder string) {
i := strings.IndexRune(name, '/')
if i == -1 || (!strings.ContainsAny(name[:i], ".:") && name[:i] != "localhost") {
domain, remainder = defaultDomain, name
} else {
domain, remainder = name[:i], name[i+1:]
}
if domain == legacyDefaultDomain {
d... | [
"func",
"splitDockerDomain",
"(",
"name",
"string",
")",
"(",
"domain",
",",
"remainder",
"string",
")",
"{",
"i",
":=",
"strings",
".",
"IndexRune",
"(",
"name",
",",
"'/'",
")",
"\n",
"if",
"i",
"==",
"-",
"1",
"||",
"(",
"!",
"strings",
".",
"Co... | // splitDockerDomain splits a repository name to domain and remotename string.
// If no valid domain is found, the default domain is used. Repository name
// needs to be already validated before. | [
"splitDockerDomain",
"splits",
"a",
"repository",
"name",
"to",
"domain",
"and",
"remotename",
"string",
".",
"If",
"no",
"valid",
"domain",
"is",
"found",
"the",
"default",
"domain",
"is",
"used",
".",
"Repository",
"name",
"needs",
"to",
"be",
"already",
"... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/reference/normalize.go#L91-L105 | train |
docker/distribution | reference/normalize.go | TagNameOnly | func TagNameOnly(ref Named) Named {
if IsNameOnly(ref) {
namedTagged, err := WithTag(ref, defaultTag)
if err != nil {
// Default tag must be valid, to create a NamedTagged
// type with non-validated input the WithTag function
// should be used instead
panic(err)
}
return namedTagged
}
return ref
... | go | func TagNameOnly(ref Named) Named {
if IsNameOnly(ref) {
namedTagged, err := WithTag(ref, defaultTag)
if err != nil {
// Default tag must be valid, to create a NamedTagged
// type with non-validated input the WithTag function
// should be used instead
panic(err)
}
return namedTagged
}
return ref
... | [
"func",
"TagNameOnly",
"(",
"ref",
"Named",
")",
"Named",
"{",
"if",
"IsNameOnly",
"(",
"ref",
")",
"{",
"namedTagged",
",",
"err",
":=",
"WithTag",
"(",
"ref",
",",
"defaultTag",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// Default tag must be valid, to ... | // TagNameOnly adds the default tag "latest" to a reference if it only has
// a repo name. | [
"TagNameOnly",
"adds",
"the",
"default",
"tag",
"latest",
"to",
"a",
"reference",
"if",
"it",
"only",
"has",
"a",
"repo",
"name",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/reference/normalize.go#L157-L169 | train |
docker/distribution | reference/normalize.go | ParseAnyReference | func ParseAnyReference(ref string) (Reference, error) {
if ok := anchoredIdentifierRegexp.MatchString(ref); ok {
return digestReference("sha256:" + ref), nil
}
if dgst, err := digest.Parse(ref); err == nil {
return digestReference(dgst), nil
}
return ParseNormalizedNamed(ref)
} | go | func ParseAnyReference(ref string) (Reference, error) {
if ok := anchoredIdentifierRegexp.MatchString(ref); ok {
return digestReference("sha256:" + ref), nil
}
if dgst, err := digest.Parse(ref); err == nil {
return digestReference(dgst), nil
}
return ParseNormalizedNamed(ref)
} | [
"func",
"ParseAnyReference",
"(",
"ref",
"string",
")",
"(",
"Reference",
",",
"error",
")",
"{",
"if",
"ok",
":=",
"anchoredIdentifierRegexp",
".",
"MatchString",
"(",
"ref",
")",
";",
"ok",
"{",
"return",
"digestReference",
"(",
"\"",
"\"",
"+",
"ref",
... | // ParseAnyReference parses a reference string as a possible identifier,
// full digest, or familiar name. | [
"ParseAnyReference",
"parses",
"a",
"reference",
"string",
"as",
"a",
"possible",
"identifier",
"full",
"digest",
"or",
"familiar",
"name",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/reference/normalize.go#L173-L182 | train |
docker/distribution | reference/normalize.go | ParseAnyReferenceWithSet | func ParseAnyReferenceWithSet(ref string, ds *digestset.Set) (Reference, error) {
if ok := anchoredShortIdentifierRegexp.MatchString(ref); ok {
dgst, err := ds.Lookup(ref)
if err == nil {
return digestReference(dgst), nil
}
} else {
if dgst, err := digest.Parse(ref); err == nil {
return digestReference(... | go | func ParseAnyReferenceWithSet(ref string, ds *digestset.Set) (Reference, error) {
if ok := anchoredShortIdentifierRegexp.MatchString(ref); ok {
dgst, err := ds.Lookup(ref)
if err == nil {
return digestReference(dgst), nil
}
} else {
if dgst, err := digest.Parse(ref); err == nil {
return digestReference(... | [
"func",
"ParseAnyReferenceWithSet",
"(",
"ref",
"string",
",",
"ds",
"*",
"digestset",
".",
"Set",
")",
"(",
"Reference",
",",
"error",
")",
"{",
"if",
"ok",
":=",
"anchoredShortIdentifierRegexp",
".",
"MatchString",
"(",
"ref",
")",
";",
"ok",
"{",
"dgst"... | // ParseAnyReferenceWithSet parses a reference string as a possible short
// identifier to be matched in a digest set, a full digest, or familiar name. | [
"ParseAnyReferenceWithSet",
"parses",
"a",
"reference",
"string",
"as",
"a",
"possible",
"short",
"identifier",
"to",
"be",
"matched",
"in",
"a",
"digest",
"set",
"a",
"full",
"digest",
"or",
"familiar",
"name",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/reference/normalize.go#L186-L199 | train |
docker/distribution | registry/api/errcode/register.go | Register | func Register(group string, descriptor ErrorDescriptor) ErrorCode {
registerLock.Lock()
defer registerLock.Unlock()
descriptor.Code = ErrorCode(nextCode)
if _, ok := idToDescriptors[descriptor.Value]; ok {
panic(fmt.Sprintf("ErrorValue %q is already registered", descriptor.Value))
}
if _, ok := errorCodeToDes... | go | func Register(group string, descriptor ErrorDescriptor) ErrorCode {
registerLock.Lock()
defer registerLock.Unlock()
descriptor.Code = ErrorCode(nextCode)
if _, ok := idToDescriptors[descriptor.Value]; ok {
panic(fmt.Sprintf("ErrorValue %q is already registered", descriptor.Value))
}
if _, ok := errorCodeToDes... | [
"func",
"Register",
"(",
"group",
"string",
",",
"descriptor",
"ErrorDescriptor",
")",
"ErrorCode",
"{",
"registerLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"registerLock",
".",
"Unlock",
"(",
")",
"\n\n",
"descriptor",
".",
"Code",
"=",
"ErrorCode",
"(",
... | // Register will make the passed-in error known to the environment and
// return a new ErrorCode | [
"Register",
"will",
"make",
"the",
"passed",
"-",
"in",
"error",
"known",
"to",
"the",
"environment",
"and",
"return",
"a",
"new",
"ErrorCode"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/api/errcode/register.go#L83-L102 | train |
docker/distribution | registry/api/errcode/register.go | GetGroupNames | func GetGroupNames() []string {
keys := []string{}
for k := range groupToDescriptors {
keys = append(keys, k)
}
sort.Strings(keys)
return keys
} | go | func GetGroupNames() []string {
keys := []string{}
for k := range groupToDescriptors {
keys = append(keys, k)
}
sort.Strings(keys)
return keys
} | [
"func",
"GetGroupNames",
"(",
")",
"[",
"]",
"string",
"{",
"keys",
":=",
"[",
"]",
"string",
"{",
"}",
"\n\n",
"for",
"k",
":=",
"range",
"groupToDescriptors",
"{",
"keys",
"=",
"append",
"(",
"keys",
",",
"k",
")",
"\n",
"}",
"\n",
"sort",
".",
... | // GetGroupNames returns the list of Error group names that are registered | [
"GetGroupNames",
"returns",
"the",
"list",
"of",
"Error",
"group",
"names",
"that",
"are",
"registered"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/api/errcode/register.go#L111-L119 | train |
docker/distribution | registry/api/errcode/register.go | GetErrorCodeGroup | func GetErrorCodeGroup(name string) []ErrorDescriptor {
desc := groupToDescriptors[name]
sort.Sort(byValue(desc))
return desc
} | go | func GetErrorCodeGroup(name string) []ErrorDescriptor {
desc := groupToDescriptors[name]
sort.Sort(byValue(desc))
return desc
} | [
"func",
"GetErrorCodeGroup",
"(",
"name",
"string",
")",
"[",
"]",
"ErrorDescriptor",
"{",
"desc",
":=",
"groupToDescriptors",
"[",
"name",
"]",
"\n",
"sort",
".",
"Sort",
"(",
"byValue",
"(",
"desc",
")",
")",
"\n",
"return",
"desc",
"\n",
"}"
] | // GetErrorCodeGroup returns the named group of error descriptors | [
"GetErrorCodeGroup",
"returns",
"the",
"named",
"group",
"of",
"error",
"descriptors"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/api/errcode/register.go#L122-L126 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.