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/storage/driver/base/regulator.go | URLFor | func (r *regulator) URLFor(ctx context.Context, path string, options map[string]interface{}) (string, error) {
r.enter()
defer r.exit()
return r.StorageDriver.URLFor(ctx, path, options)
} | go | func (r *regulator) URLFor(ctx context.Context, path string, options map[string]interface{}) (string, error) {
r.enter()
defer r.exit()
return r.StorageDriver.URLFor(ctx, path, options)
} | [
"func",
"(",
"r",
"*",
"regulator",
")",
"URLFor",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
",",
"options",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"error",
")",
"{",
"r",
".",
"enter",
"(",
... | // URLFor returns a URL which may be used to retrieve the content stored at
// the given path, possibly using the given options.
// May return an ErrUnsupportedMethod in certain StorageDriver
// implementations. | [
"URLFor",
"returns",
"a",
"URL",
"which",
"may",
"be",
"used",
"to",
"retrieve",
"the",
"content",
"stored",
"at",
"the",
"given",
"path",
"possibly",
"using",
"the",
"given",
"options",
".",
"May",
"return",
"an",
"ErrUnsupportedMethod",
"in",
"certain",
"S... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/base/regulator.go#L179-L184 | train |
docker/distribution | registry/storage/driver/swift/swift.go | URLFor | func (d *driver) URLFor(ctx context.Context, path string, options map[string]interface{}) (string, error) {
if d.SecretKey == "" {
return "", storagedriver.ErrUnsupportedMethod{}
}
methodString := "GET"
method, ok := options["method"]
if ok {
if methodString, ok = method.(string); !ok {
return "", storaged... | go | func (d *driver) URLFor(ctx context.Context, path string, options map[string]interface{}) (string, error) {
if d.SecretKey == "" {
return "", storagedriver.ErrUnsupportedMethod{}
}
methodString := "GET"
method, ok := options["method"]
if ok {
if methodString, ok = method.(string); !ok {
return "", storaged... | [
"func",
"(",
"d",
"*",
"driver",
")",
"URLFor",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
",",
"options",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"d",
".",
"SecretKey",... | // URLFor returns a URL which may be used to retrieve the content stored at the given path. | [
"URLFor",
"returns",
"a",
"URL",
"which",
"may",
"be",
"used",
"to",
"retrieve",
"the",
"content",
"stored",
"at",
"the",
"given",
"path",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/swift/swift.go#L606-L658 | train |
docker/distribution | manifest/schema2/manifest.go | References | func (m Manifest) References() []distribution.Descriptor {
references := make([]distribution.Descriptor, 0, 1+len(m.Layers))
references = append(references, m.Config)
references = append(references, m.Layers...)
return references
} | go | func (m Manifest) References() []distribution.Descriptor {
references := make([]distribution.Descriptor, 0, 1+len(m.Layers))
references = append(references, m.Config)
references = append(references, m.Layers...)
return references
} | [
"func",
"(",
"m",
"Manifest",
")",
"References",
"(",
")",
"[",
"]",
"distribution",
".",
"Descriptor",
"{",
"references",
":=",
"make",
"(",
"[",
"]",
"distribution",
".",
"Descriptor",
",",
"0",
",",
"1",
"+",
"len",
"(",
"m",
".",
"Layers",
")",
... | // References returns the descriptors of this manifests references. | [
"References",
"returns",
"the",
"descriptors",
"of",
"this",
"manifests",
"references",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/schema2/manifest.go#L75-L80 | train |
docker/distribution | manifest/schema2/manifest.go | FromStruct | func FromStruct(m Manifest) (*DeserializedManifest, error) {
var deserialized DeserializedManifest
deserialized.Manifest = m
var err error
deserialized.canonical, err = json.MarshalIndent(&m, "", " ")
return &deserialized, err
} | go | func FromStruct(m Manifest) (*DeserializedManifest, error) {
var deserialized DeserializedManifest
deserialized.Manifest = m
var err error
deserialized.canonical, err = json.MarshalIndent(&m, "", " ")
return &deserialized, err
} | [
"func",
"FromStruct",
"(",
"m",
"Manifest",
")",
"(",
"*",
"DeserializedManifest",
",",
"error",
")",
"{",
"var",
"deserialized",
"DeserializedManifest",
"\n",
"deserialized",
".",
"Manifest",
"=",
"m",
"\n\n",
"var",
"err",
"error",
"\n",
"deserialized",
".",... | // FromStruct takes a Manifest structure, marshals it to JSON, and returns a
// DeserializedManifest which contains the manifest and its JSON representation. | [
"FromStruct",
"takes",
"a",
"Manifest",
"structure",
"marshals",
"it",
"to",
"JSON",
"and",
"returns",
"a",
"DeserializedManifest",
"which",
"contains",
"the",
"manifest",
"and",
"its",
"JSON",
"representation",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/schema2/manifest.go#L98-L105 | train |
docker/distribution | manifest/schema2/manifest.go | MarshalJSON | func (m *DeserializedManifest) MarshalJSON() ([]byte, error) {
if len(m.canonical) > 0 {
return m.canonical, nil
}
return nil, errors.New("JSON representation not initialized in DeserializedManifest")
} | go | func (m *DeserializedManifest) MarshalJSON() ([]byte, error) {
if len(m.canonical) > 0 {
return m.canonical, nil
}
return nil, errors.New("JSON representation not initialized in DeserializedManifest")
} | [
"func",
"(",
"m",
"*",
"DeserializedManifest",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"len",
"(",
"m",
".",
"canonical",
")",
">",
"0",
"{",
"return",
"m",
".",
"canonical",
",",
"nil",
"\n",
"}",
"\n\n... | // MarshalJSON returns the contents of canonical. If canonical is empty,
// marshals the inner contents. | [
"MarshalJSON",
"returns",
"the",
"contents",
"of",
"canonical",
".",
"If",
"canonical",
"is",
"empty",
"marshals",
"the",
"inner",
"contents",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/schema2/manifest.go#L132-L138 | train |
docker/distribution | registry/storage/blobwriter_resumable.go | resumeDigest | func (bw *blobWriter) resumeDigest(ctx context.Context) error {
if !bw.resumableDigestEnabled {
return errResumableDigestNotAvailable
}
h, ok := bw.digester.Hash().(encoding.BinaryUnmarshaler)
if !ok {
return errResumableDigestNotAvailable
}
offset := bw.fileWriter.Size()
if offset == bw.written {
// Sta... | go | func (bw *blobWriter) resumeDigest(ctx context.Context) error {
if !bw.resumableDigestEnabled {
return errResumableDigestNotAvailable
}
h, ok := bw.digester.Hash().(encoding.BinaryUnmarshaler)
if !ok {
return errResumableDigestNotAvailable
}
offset := bw.fileWriter.Size()
if offset == bw.written {
// Sta... | [
"func",
"(",
"bw",
"*",
"blobWriter",
")",
"resumeDigest",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"if",
"!",
"bw",
".",
"resumableDigestEnabled",
"{",
"return",
"errResumableDigestNotAvailable",
"\n",
"}",
"\n\n",
"h",
",",
"ok",
":=",
"... | // resumeDigest attempts to restore the state of the internal hash function
// by loading the most recent saved hash state equal to the current size of the blob. | [
"resumeDigest",
"attempts",
"to",
"restore",
"the",
"state",
"of",
"the",
"internal",
"hash",
"function",
"by",
"loading",
"the",
"most",
"recent",
"saved",
"hash",
"state",
"equal",
"to",
"the",
"current",
"size",
"of",
"the",
"blob",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/blobwriter_resumable.go#L19-L72 | train |
docker/distribution | registry/storage/blobwriter_resumable.go | getStoredHashStates | func (bw *blobWriter) getStoredHashStates(ctx context.Context) ([]hashStateEntry, error) {
uploadHashStatePathPrefix, err := pathFor(uploadHashStatePathSpec{
name: bw.blobStore.repository.Named().String(),
id: bw.id,
alg: bw.digester.Digest().Algorithm(),
list: true,
})
if err != nil {
return nil, err
... | go | func (bw *blobWriter) getStoredHashStates(ctx context.Context) ([]hashStateEntry, error) {
uploadHashStatePathPrefix, err := pathFor(uploadHashStatePathSpec{
name: bw.blobStore.repository.Named().String(),
id: bw.id,
alg: bw.digester.Digest().Algorithm(),
list: true,
})
if err != nil {
return nil, err
... | [
"func",
"(",
"bw",
"*",
"blobWriter",
")",
"getStoredHashStates",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"hashStateEntry",
",",
"error",
")",
"{",
"uploadHashStatePathPrefix",
",",
"err",
":=",
"pathFor",
"(",
"uploadHashStatePathSpec",
"{"... | // getStoredHashStates returns a slice of hashStateEntries for this upload. | [
"getStoredHashStates",
"returns",
"a",
"slice",
"of",
"hashStateEntries",
"for",
"this",
"upload",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/blobwriter_resumable.go#L80-L115 | train |
docker/distribution | registry/storage/catalog.go | Repositories | func (reg *registry) Repositories(ctx context.Context, repos []string, last string) (n int, err error) {
var finishedWalk bool
var foundRepos []string
if len(repos) == 0 {
return 0, errors.New("no space in slice")
}
root, err := pathFor(repositoriesRootPathSpec{})
if err != nil {
return 0, err
}
err = re... | go | func (reg *registry) Repositories(ctx context.Context, repos []string, last string) (n int, err error) {
var finishedWalk bool
var foundRepos []string
if len(repos) == 0 {
return 0, errors.New("no space in slice")
}
root, err := pathFor(repositoriesRootPathSpec{})
if err != nil {
return 0, err
}
err = re... | [
"func",
"(",
"reg",
"*",
"registry",
")",
"Repositories",
"(",
"ctx",
"context",
".",
"Context",
",",
"repos",
"[",
"]",
"string",
",",
"last",
"string",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"var",
"finishedWalk",
"bool",
"\n",
"var",... | // Returns a list, or partial list, of repositories in the registry.
// Because it's a quite expensive operation, it should only be used when building up
// an initial set of repositories. | [
"Returns",
"a",
"list",
"or",
"partial",
"list",
"of",
"repositories",
"in",
"the",
"registry",
".",
"Because",
"it",
"s",
"a",
"quite",
"expensive",
"operation",
"it",
"should",
"only",
"be",
"used",
"when",
"building",
"up",
"an",
"initial",
"set",
"of",... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/catalog.go#L17-L58 | train |
docker/distribution | registry/storage/catalog.go | Enumerate | func (reg *registry) Enumerate(ctx context.Context, ingester func(string) error) error {
root, err := pathFor(repositoriesRootPathSpec{})
if err != nil {
return err
}
err = reg.blobStore.driver.Walk(ctx, root, func(fileInfo driver.FileInfo) error {
return handleRepository(fileInfo, root, "", ingester)
})
re... | go | func (reg *registry) Enumerate(ctx context.Context, ingester func(string) error) error {
root, err := pathFor(repositoriesRootPathSpec{})
if err != nil {
return err
}
err = reg.blobStore.driver.Walk(ctx, root, func(fileInfo driver.FileInfo) error {
return handleRepository(fileInfo, root, "", ingester)
})
re... | [
"func",
"(",
"reg",
"*",
"registry",
")",
"Enumerate",
"(",
"ctx",
"context",
".",
"Context",
",",
"ingester",
"func",
"(",
"string",
")",
"error",
")",
"error",
"{",
"root",
",",
"err",
":=",
"pathFor",
"(",
"repositoriesRootPathSpec",
"{",
"}",
")",
... | // Enumerate applies ingester to each repository | [
"Enumerate",
"applies",
"ingester",
"to",
"each",
"repository"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/catalog.go#L61-L72 | train |
docker/distribution | registry/storage/catalog.go | Remove | func (reg *registry) Remove(ctx context.Context, name reference.Named) error {
root, err := pathFor(repositoriesRootPathSpec{})
if err != nil {
return err
}
repoDir := path.Join(root, name.Name())
return reg.driver.Delete(ctx, repoDir)
} | go | func (reg *registry) Remove(ctx context.Context, name reference.Named) error {
root, err := pathFor(repositoriesRootPathSpec{})
if err != nil {
return err
}
repoDir := path.Join(root, name.Name())
return reg.driver.Delete(ctx, repoDir)
} | [
"func",
"(",
"reg",
"*",
"registry",
")",
"Remove",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"reference",
".",
"Named",
")",
"error",
"{",
"root",
",",
"err",
":=",
"pathFor",
"(",
"repositoriesRootPathSpec",
"{",
"}",
")",
"\n",
"if",
"err"... | // Remove removes a repository from storage | [
"Remove",
"removes",
"a",
"repository",
"from",
"storage"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/catalog.go#L75-L82 | train |
docker/distribution | registry/storage/catalog.go | compareReplaceInline | func compareReplaceInline(s1, s2 string, old, new byte) int {
// TODO(stevvooe): We are missing an optimization when the s1 and s2 have
// the exact same slice header. It will make the code unsafe but can
// provide some extra performance.
l := len(s1)
if len(s2) < l {
l = len(s2)
}
for i := 0; i < l; i++ {
... | go | func compareReplaceInline(s1, s2 string, old, new byte) int {
// TODO(stevvooe): We are missing an optimization when the s1 and s2 have
// the exact same slice header. It will make the code unsafe but can
// provide some extra performance.
l := len(s1)
if len(s2) < l {
l = len(s2)
}
for i := 0; i < l; i++ {
... | [
"func",
"compareReplaceInline",
"(",
"s1",
",",
"s2",
"string",
",",
"old",
",",
"new",
"byte",
")",
"int",
"{",
"// TODO(stevvooe): We are missing an optimization when the s1 and s2 have",
"// the exact same slice header. It will make the code unsafe but can",
"// provide some ext... | // compareReplaceInline modifies runtime.cmpstring to replace old with new
// during a byte-wise comparison. | [
"compareReplaceInline",
"modifies",
"runtime",
".",
"cmpstring",
"to",
"replace",
"old",
"with",
"new",
"during",
"a",
"byte",
"-",
"wise",
"comparison",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/catalog.go#L95-L133 | train |
docker/distribution | registry/storage/catalog.go | handleRepository | func handleRepository(fileInfo driver.FileInfo, root, last string, fn func(repoPath string) error) error {
filePath := fileInfo.Path()
// lop the base path off
repo := filePath[len(root)+1:]
_, file := path.Split(repo)
if file == "_layers" {
repo = strings.TrimSuffix(repo, "/_layers")
if lessPath(last, repo)... | go | func handleRepository(fileInfo driver.FileInfo, root, last string, fn func(repoPath string) error) error {
filePath := fileInfo.Path()
// lop the base path off
repo := filePath[len(root)+1:]
_, file := path.Split(repo)
if file == "_layers" {
repo = strings.TrimSuffix(repo, "/_layers")
if lessPath(last, repo)... | [
"func",
"handleRepository",
"(",
"fileInfo",
"driver",
".",
"FileInfo",
",",
"root",
",",
"last",
"string",
",",
"fn",
"func",
"(",
"repoPath",
"string",
")",
"error",
")",
"error",
"{",
"filePath",
":=",
"fileInfo",
".",
"Path",
"(",
")",
"\n\n",
"// lo... | // handleRepository calls function fn with a repository path if fileInfo
// has a path of a repository under root and that it is lexographically
// after last. Otherwise, it will return ErrSkipDir. This should be used
// with Walk to do handling with repositories in a storage. | [
"handleRepository",
"calls",
"function",
"fn",
"with",
"a",
"repository",
"path",
"if",
"fileInfo",
"has",
"a",
"path",
"of",
"a",
"repository",
"under",
"root",
"and",
"that",
"it",
"is",
"lexographically",
"after",
"last",
".",
"Otherwise",
"it",
"will",
"... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/catalog.go#L139-L159 | train |
docker/distribution | registry/storage/driver/middleware/cloudfront/middleware.go | URLFor | func (lh *cloudFrontStorageMiddleware) URLFor(ctx context.Context, path string, options map[string]interface{}) (string, error) {
// TODO(endophage): currently only supports S3
keyer, ok := lh.StorageDriver.(S3BucketKeyer)
if !ok {
dcontext.GetLogger(ctx).Warn("the CloudFront middleware does not support this backe... | go | func (lh *cloudFrontStorageMiddleware) URLFor(ctx context.Context, path string, options map[string]interface{}) (string, error) {
// TODO(endophage): currently only supports S3
keyer, ok := lh.StorageDriver.(S3BucketKeyer)
if !ok {
dcontext.GetLogger(ctx).Warn("the CloudFront middleware does not support this backe... | [
"func",
"(",
"lh",
"*",
"cloudFrontStorageMiddleware",
")",
"URLFor",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
",",
"options",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"error",
")",
"{",
"// TODO(end... | // URLFor attempts to find a url which may be used to retrieve the file at the given path.
// Returns an error if the file cannot be found. | [
"URLFor",
"attempts",
"to",
"find",
"a",
"url",
"which",
"may",
"be",
"used",
"to",
"retrieve",
"the",
"file",
"at",
"the",
"given",
"path",
".",
"Returns",
"an",
"error",
"if",
"the",
"file",
"cannot",
"be",
"found",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/middleware/cloudfront/middleware.go#L187-L205 | train |
docker/distribution | registry/storage/paths.go | digestFromPath | func digestFromPath(digestPath string) (digest.Digest, error) {
digestPath = strings.TrimSuffix(digestPath, "/data")
dir, hex := path.Split(digestPath)
dir = path.Dir(dir)
dir, next := path.Split(dir)
// next is either the algorithm OR the first two characters in the hex string
var algo string
if next == hex[:... | go | func digestFromPath(digestPath string) (digest.Digest, error) {
digestPath = strings.TrimSuffix(digestPath, "/data")
dir, hex := path.Split(digestPath)
dir = path.Dir(dir)
dir, next := path.Split(dir)
// next is either the algorithm OR the first two characters in the hex string
var algo string
if next == hex[:... | [
"func",
"digestFromPath",
"(",
"digestPath",
"string",
")",
"(",
"digest",
".",
"Digest",
",",
"error",
")",
"{",
"digestPath",
"=",
"strings",
".",
"TrimSuffix",
"(",
"digestPath",
",",
"\"",
"\"",
")",
"\n",
"dir",
",",
"hex",
":=",
"path",
".",
"Spl... | // Reconstructs a digest from a path | [
"Reconstructs",
"a",
"digest",
"from",
"a",
"path"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/paths.go#L460-L477 | train |
docker/distribution | registry/storage/blobwriter.go | Commit | func (bw *blobWriter) Commit(ctx context.Context, desc distribution.Descriptor) (distribution.Descriptor, error) {
dcontext.GetLogger(ctx).Debug("(*blobWriter).Commit")
if err := bw.fileWriter.Commit(); err != nil {
return distribution.Descriptor{}, err
}
bw.Close()
desc.Size = bw.Size()
canonical, err := bw... | go | func (bw *blobWriter) Commit(ctx context.Context, desc distribution.Descriptor) (distribution.Descriptor, error) {
dcontext.GetLogger(ctx).Debug("(*blobWriter).Commit")
if err := bw.fileWriter.Commit(); err != nil {
return distribution.Descriptor{}, err
}
bw.Close()
desc.Size = bw.Size()
canonical, err := bw... | [
"func",
"(",
"bw",
"*",
"blobWriter",
")",
"Commit",
"(",
"ctx",
"context",
".",
"Context",
",",
"desc",
"distribution",
".",
"Descriptor",
")",
"(",
"distribution",
".",
"Descriptor",
",",
"error",
")",
"{",
"dcontext",
".",
"GetLogger",
"(",
"ctx",
")"... | // Commit marks the upload as completed, returning a valid descriptor. The
// final size and digest are checked against the first descriptor provided. | [
"Commit",
"marks",
"the",
"upload",
"as",
"completed",
"returning",
"a",
"valid",
"descriptor",
".",
"The",
"final",
"size",
"and",
"digest",
"are",
"checked",
"against",
"the",
"first",
"descriptor",
"provided",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/blobwriter.go#L59-L93 | train |
docker/distribution | registry/storage/blobwriter.go | Cancel | func (bw *blobWriter) Cancel(ctx context.Context) error {
dcontext.GetLogger(ctx).Debug("(*blobWriter).Cancel")
if err := bw.fileWriter.Cancel(); err != nil {
return err
}
if err := bw.Close(); err != nil {
dcontext.GetLogger(ctx).Errorf("error closing blobwriter: %s", err)
}
return bw.removeResources(ctx)
... | go | func (bw *blobWriter) Cancel(ctx context.Context) error {
dcontext.GetLogger(ctx).Debug("(*blobWriter).Cancel")
if err := bw.fileWriter.Cancel(); err != nil {
return err
}
if err := bw.Close(); err != nil {
dcontext.GetLogger(ctx).Errorf("error closing blobwriter: %s", err)
}
return bw.removeResources(ctx)
... | [
"func",
"(",
"bw",
"*",
"blobWriter",
")",
"Cancel",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"dcontext",
".",
"GetLogger",
"(",
"ctx",
")",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
":=",
"bw",
".",
"fileWriter",
".",... | // Cancel the blob upload process, releasing any resources associated with
// the writer and canceling the operation. | [
"Cancel",
"the",
"blob",
"upload",
"process",
"releasing",
"any",
"resources",
"associated",
"with",
"the",
"writer",
"and",
"canceling",
"the",
"operation",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/blobwriter.go#L97-L108 | train |
docker/distribution | registry/storage/blobwriter.go | moveBlob | func (bw *blobWriter) moveBlob(ctx context.Context, desc distribution.Descriptor) error {
blobPath, err := pathFor(blobDataPathSpec{
digest: desc.Digest,
})
if err != nil {
return err
}
// Check for existence
if _, err := bw.blobStore.driver.Stat(ctx, blobPath); err != nil {
switch err := err.(type) {
c... | go | func (bw *blobWriter) moveBlob(ctx context.Context, desc distribution.Descriptor) error {
blobPath, err := pathFor(blobDataPathSpec{
digest: desc.Digest,
})
if err != nil {
return err
}
// Check for existence
if _, err := bw.blobStore.driver.Stat(ctx, blobPath); err != nil {
switch err := err.(type) {
c... | [
"func",
"(",
"bw",
"*",
"blobWriter",
")",
"moveBlob",
"(",
"ctx",
"context",
".",
"Context",
",",
"desc",
"distribution",
".",
"Descriptor",
")",
"error",
"{",
"blobPath",
",",
"err",
":=",
"pathFor",
"(",
"blobDataPathSpec",
"{",
"digest",
":",
"desc",
... | // moveBlob moves the data into its final, hash-qualified destination,
// identified by dgst. The layer should be validated before commencing the
// move. | [
"moveBlob",
"moves",
"the",
"data",
"into",
"its",
"final",
"hash",
"-",
"qualified",
"destination",
"identified",
"by",
"dgst",
".",
"The",
"layer",
"should",
"be",
"validated",
"before",
"commencing",
"the",
"move",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/blobwriter.go#L295-L348 | train |
docker/distribution | registry/storage/blobwriter.go | removeResources | func (bw *blobWriter) removeResources(ctx context.Context) error {
dataPath, err := pathFor(uploadDataPathSpec{
name: bw.blobStore.repository.Named().Name(),
id: bw.id,
})
if err != nil {
return err
}
// Resolve and delete the containing directory, which should include any
// upload related files.
dirP... | go | func (bw *blobWriter) removeResources(ctx context.Context) error {
dataPath, err := pathFor(uploadDataPathSpec{
name: bw.blobStore.repository.Named().Name(),
id: bw.id,
})
if err != nil {
return err
}
// Resolve and delete the containing directory, which should include any
// upload related files.
dirP... | [
"func",
"(",
"bw",
"*",
"blobWriter",
")",
"removeResources",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"dataPath",
",",
"err",
":=",
"pathFor",
"(",
"uploadDataPathSpec",
"{",
"name",
":",
"bw",
".",
"blobStore",
".",
"repository",
".",
... | // removeResources should clean up all resources associated with the upload
// instance. An error will be returned if the clean up cannot proceed. If the
// resources are already not present, no error will be returned. | [
"removeResources",
"should",
"clean",
"up",
"all",
"resources",
"associated",
"with",
"the",
"upload",
"instance",
".",
"An",
"error",
"will",
"be",
"returned",
"if",
"the",
"clean",
"up",
"cannot",
"proceed",
".",
"If",
"the",
"resources",
"are",
"already",
... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/blobwriter.go#L353-L380 | train |
docker/distribution | manifest/schema1/verify.go | Verify | func Verify(sm *SignedManifest) ([]libtrust.PublicKey, error) {
js, err := libtrust.ParsePrettySignature(sm.all, "signatures")
if err != nil {
logrus.WithField("err", err).Debugf("(*SignedManifest).Verify")
return nil, err
}
return js.Verify()
} | go | func Verify(sm *SignedManifest) ([]libtrust.PublicKey, error) {
js, err := libtrust.ParsePrettySignature(sm.all, "signatures")
if err != nil {
logrus.WithField("err", err).Debugf("(*SignedManifest).Verify")
return nil, err
}
return js.Verify()
} | [
"func",
"Verify",
"(",
"sm",
"*",
"SignedManifest",
")",
"(",
"[",
"]",
"libtrust",
".",
"PublicKey",
",",
"error",
")",
"{",
"js",
",",
"err",
":=",
"libtrust",
".",
"ParsePrettySignature",
"(",
"sm",
".",
"all",
",",
"\"",
"\"",
")",
"\n",
"if",
... | // Verify verifies the signature of the signed manifest returning the public
// keys used during signing. | [
"Verify",
"verifies",
"the",
"signature",
"of",
"the",
"signed",
"manifest",
"returning",
"the",
"public",
"keys",
"used",
"during",
"signing",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/schema1/verify.go#L12-L20 | train |
docker/distribution | manifest/schema1/verify.go | VerifyChains | func VerifyChains(sm *SignedManifest, ca *x509.CertPool) ([][]*x509.Certificate, error) {
js, err := libtrust.ParsePrettySignature(sm.all, "signatures")
if err != nil {
return nil, err
}
return js.VerifyChains(ca)
} | go | func VerifyChains(sm *SignedManifest, ca *x509.CertPool) ([][]*x509.Certificate, error) {
js, err := libtrust.ParsePrettySignature(sm.all, "signatures")
if err != nil {
return nil, err
}
return js.VerifyChains(ca)
} | [
"func",
"VerifyChains",
"(",
"sm",
"*",
"SignedManifest",
",",
"ca",
"*",
"x509",
".",
"CertPool",
")",
"(",
"[",
"]",
"[",
"]",
"*",
"x509",
".",
"Certificate",
",",
"error",
")",
"{",
"js",
",",
"err",
":=",
"libtrust",
".",
"ParsePrettySignature",
... | // VerifyChains verifies the signature of the signed manifest against the
// certificate pool returning the list of verified chains. Signatures without
// an x509 chain are not checked. | [
"VerifyChains",
"verifies",
"the",
"signature",
"of",
"the",
"signed",
"manifest",
"against",
"the",
"certificate",
"pool",
"returning",
"the",
"list",
"of",
"verified",
"chains",
".",
"Signatures",
"without",
"an",
"x509",
"chain",
"are",
"not",
"checked",
"."
... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/schema1/verify.go#L25-L32 | train |
docker/distribution | registry/proxy/proxyauth.go | configureAuth | func configureAuth(username, password, remoteURL string) (auth.CredentialStore, error) {
creds := map[string]userpass{}
authURLs, err := getAuthURLs(remoteURL)
if err != nil {
return nil, err
}
for _, url := range authURLs {
context.GetLogger(context.Background()).Infof("Discovered token authentication URL: ... | go | func configureAuth(username, password, remoteURL string) (auth.CredentialStore, error) {
creds := map[string]userpass{}
authURLs, err := getAuthURLs(remoteURL)
if err != nil {
return nil, err
}
for _, url := range authURLs {
context.GetLogger(context.Background()).Infof("Discovered token authentication URL: ... | [
"func",
"configureAuth",
"(",
"username",
",",
"password",
",",
"remoteURL",
"string",
")",
"(",
"auth",
".",
"CredentialStore",
",",
"error",
")",
"{",
"creds",
":=",
"map",
"[",
"string",
"]",
"userpass",
"{",
"}",
"\n\n",
"authURLs",
",",
"err",
":=",... | // configureAuth stores credentials for challenge responses | [
"configureAuth",
"stores",
"credentials",
"for",
"challenge",
"responses"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/proxy/proxyauth.go#L38-L55 | train |
docker/distribution | registry/storage/driver/inmemory/mfs.go | add | func (d *dir) add(n node) {
if d.children == nil {
d.children = make(map[string]node)
}
d.children[n.name()] = n
d.mod = time.Now()
} | go | func (d *dir) add(n node) {
if d.children == nil {
d.children = make(map[string]node)
}
d.children[n.name()] = n
d.mod = time.Now()
} | [
"func",
"(",
"d",
"*",
"dir",
")",
"add",
"(",
"n",
"node",
")",
"{",
"if",
"d",
".",
"children",
"==",
"nil",
"{",
"d",
".",
"children",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"node",
")",
"\n",
"}",
"\n\n",
"d",
".",
"children",
"[",
... | // add places the node n into dir d. | [
"add",
"places",
"the",
"node",
"n",
"into",
"dir",
"d",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/inmemory/mfs.go#L42-L49 | train |
docker/distribution | registry/storage/driver/inmemory/mfs.go | mkfile | func (d *dir) mkfile(p string) (*file, error) {
n := d.find(p)
if n.path() == p {
if n.isdir() {
return nil, errIsDir
}
return n.(*file), nil
}
dirpath, filename := path.Split(p)
// Make any non-existent directories
n, err := d.mkdirs(dirpath)
if err != nil {
return nil, err
}
dd := n.(*dir)
n =... | go | func (d *dir) mkfile(p string) (*file, error) {
n := d.find(p)
if n.path() == p {
if n.isdir() {
return nil, errIsDir
}
return n.(*file), nil
}
dirpath, filename := path.Split(p)
// Make any non-existent directories
n, err := d.mkdirs(dirpath)
if err != nil {
return nil, err
}
dd := n.(*dir)
n =... | [
"func",
"(",
"d",
"*",
"dir",
")",
"mkfile",
"(",
"p",
"string",
")",
"(",
"*",
"file",
",",
"error",
")",
"{",
"n",
":=",
"d",
".",
"find",
"(",
"p",
")",
"\n",
"if",
"n",
".",
"path",
"(",
")",
"==",
"p",
"{",
"if",
"n",
".",
"isdir",
... | // mkfile or return the existing one. returns an error if it exists and is a
// directory. Essentially, this is open or create. | [
"mkfile",
"or",
"return",
"the",
"existing",
"one",
".",
"returns",
"an",
"error",
"if",
"it",
"exists",
"and",
"is",
"a",
"directory",
".",
"Essentially",
"this",
"is",
"open",
"or",
"create",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/inmemory/mfs.go#L111-L138 | train |
docker/distribution | registry/storage/driver/inmemory/mfs.go | mkdirs | func (d *dir) mkdirs(p string) (*dir, error) {
p = normalize(p)
n := d.find(p)
if !n.isdir() {
// Found something there
return nil, errIsNotDir
}
if n.path() == p {
return n.(*dir), nil
}
dd := n.(*dir)
relative := strings.Trim(strings.TrimPrefix(p, n.path()), "/")
if relative == "" {
return dd, ... | go | func (d *dir) mkdirs(p string) (*dir, error) {
p = normalize(p)
n := d.find(p)
if !n.isdir() {
// Found something there
return nil, errIsNotDir
}
if n.path() == p {
return n.(*dir), nil
}
dd := n.(*dir)
relative := strings.Trim(strings.TrimPrefix(p, n.path()), "/")
if relative == "" {
return dd, ... | [
"func",
"(",
"d",
"*",
"dir",
")",
"mkdirs",
"(",
"p",
"string",
")",
"(",
"*",
"dir",
",",
"error",
")",
"{",
"p",
"=",
"normalize",
"(",
"p",
")",
"\n\n",
"n",
":=",
"d",
".",
"find",
"(",
"p",
")",
"\n\n",
"if",
"!",
"n",
".",
"isdir",
... | // mkdirs creates any missing directory entries in p and returns the result. | [
"mkdirs",
"creates",
"any",
"missing",
"directory",
"entries",
"in",
"p",
"and",
"returns",
"the",
"result",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/inmemory/mfs.go#L141-L175 | train |
docker/distribution | registry/storage/driver/inmemory/mfs.go | mkdir | func (d *dir) mkdir(name string) (*dir, error) {
if name == "" {
return nil, fmt.Errorf("invalid dirname")
}
_, ok := d.children[name]
if ok {
return nil, errExists
}
child := &dir{
common: common{
p: path.Join(d.path(), name),
mod: time.Now(),
},
}
d.add(child)
d.mod = time.Now()
return ch... | go | func (d *dir) mkdir(name string) (*dir, error) {
if name == "" {
return nil, fmt.Errorf("invalid dirname")
}
_, ok := d.children[name]
if ok {
return nil, errExists
}
child := &dir{
common: common{
p: path.Join(d.path(), name),
mod: time.Now(),
},
}
d.add(child)
d.mod = time.Now()
return ch... | [
"func",
"(",
"d",
"*",
"dir",
")",
"mkdir",
"(",
"name",
"string",
")",
"(",
"*",
"dir",
",",
"error",
")",
"{",
"if",
"name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"_",
... | // mkdir creates a child directory under d with the given name. | [
"mkdir",
"creates",
"a",
"child",
"directory",
"under",
"d",
"with",
"the",
"given",
"name",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/inmemory/mfs.go#L178-L198 | train |
docker/distribution | registry/client/repository.go | checkHTTPRedirect | func checkHTTPRedirect(req *http.Request, via []*http.Request) error {
if len(via) >= 10 {
return errors.New("stopped after 10 redirects")
}
if len(via) > 0 {
for headerName, headerVals := range via[0].Header {
if headerName != "Accept" && headerName != "Range" {
continue
}
for _, val := range head... | go | func checkHTTPRedirect(req *http.Request, via []*http.Request) error {
if len(via) >= 10 {
return errors.New("stopped after 10 redirects")
}
if len(via) > 0 {
for headerName, headerVals := range via[0].Header {
if headerName != "Accept" && headerName != "Range" {
continue
}
for _, val := range head... | [
"func",
"checkHTTPRedirect",
"(",
"req",
"*",
"http",
".",
"Request",
",",
"via",
"[",
"]",
"*",
"http",
".",
"Request",
")",
"error",
"{",
"if",
"len",
"(",
"via",
")",
">=",
"10",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",... | // checkHTTPRedirect is a callback that can manipulate redirected HTTP
// requests. It is used to preserve Accept and Range headers. | [
"checkHTTPRedirect",
"is",
"a",
"callback",
"that",
"can",
"manipulate",
"redirected",
"HTTP",
"requests",
".",
"It",
"is",
"used",
"to",
"preserve",
"Accept",
"and",
"Range",
"headers",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/client/repository.go#L33-L62 | train |
docker/distribution | registry/client/repository.go | NewRegistry | func NewRegistry(baseURL string, transport http.RoundTripper) (Registry, error) {
ub, err := v2.NewURLBuilderFromString(baseURL, false)
if err != nil {
return nil, err
}
client := &http.Client{
Transport: transport,
Timeout: 1 * time.Minute,
CheckRedirect: checkHTTPRedirect,
}
return ®istry... | go | func NewRegistry(baseURL string, transport http.RoundTripper) (Registry, error) {
ub, err := v2.NewURLBuilderFromString(baseURL, false)
if err != nil {
return nil, err
}
client := &http.Client{
Transport: transport,
Timeout: 1 * time.Minute,
CheckRedirect: checkHTTPRedirect,
}
return ®istry... | [
"func",
"NewRegistry",
"(",
"baseURL",
"string",
",",
"transport",
"http",
".",
"RoundTripper",
")",
"(",
"Registry",
",",
"error",
")",
"{",
"ub",
",",
"err",
":=",
"v2",
".",
"NewURLBuilderFromString",
"(",
"baseURL",
",",
"false",
")",
"\n",
"if",
"er... | // NewRegistry creates a registry namespace which can be used to get a listing of repositories | [
"NewRegistry",
"creates",
"a",
"registry",
"namespace",
"which",
"can",
"be",
"used",
"to",
"get",
"a",
"listing",
"of",
"repositories"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/client/repository.go#L65-L81 | train |
docker/distribution | registry/client/repository.go | Repositories | func (r *registry) Repositories(ctx context.Context, entries []string, last string) (int, error) {
var numFilled int
var returnErr error
values := buildCatalogValues(len(entries), last)
u, err := r.ub.BuildCatalogURL(values)
if err != nil {
return 0, err
}
resp, err := r.client.Get(u)
if err != nil {
retu... | go | func (r *registry) Repositories(ctx context.Context, entries []string, last string) (int, error) {
var numFilled int
var returnErr error
values := buildCatalogValues(len(entries), last)
u, err := r.ub.BuildCatalogURL(values)
if err != nil {
return 0, err
}
resp, err := r.client.Get(u)
if err != nil {
retu... | [
"func",
"(",
"r",
"*",
"registry",
")",
"Repositories",
"(",
"ctx",
"context",
".",
"Context",
",",
"entries",
"[",
"]",
"string",
",",
"last",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"var",
"numFilled",
"int",
"\n",
"var",
"returnErr",
"e... | // Repositories returns a lexigraphically sorted catalog given a base URL. The 'entries' slice will be filled up to the size
// of the slice, starting at the value provided in 'last'. The number of entries will be returned along with io.EOF if there
// are no more entries | [
"Repositories",
"returns",
"a",
"lexigraphically",
"sorted",
"catalog",
"given",
"a",
"base",
"URL",
".",
"The",
"entries",
"slice",
"will",
"be",
"filled",
"up",
"to",
"the",
"size",
"of",
"the",
"slice",
"starting",
"at",
"the",
"value",
"provided",
"in",
... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/client/repository.go#L91-L131 | train |
docker/distribution | registry/client/repository.go | NewRepository | func NewRepository(name reference.Named, baseURL string, transport http.RoundTripper) (distribution.Repository, error) {
ub, err := v2.NewURLBuilderFromString(baseURL, false)
if err != nil {
return nil, err
}
client := &http.Client{
Transport: transport,
CheckRedirect: checkHTTPRedirect,
// TODO(dmcgow... | go | func NewRepository(name reference.Named, baseURL string, transport http.RoundTripper) (distribution.Repository, error) {
ub, err := v2.NewURLBuilderFromString(baseURL, false)
if err != nil {
return nil, err
}
client := &http.Client{
Transport: transport,
CheckRedirect: checkHTTPRedirect,
// TODO(dmcgow... | [
"func",
"NewRepository",
"(",
"name",
"reference",
".",
"Named",
",",
"baseURL",
"string",
",",
"transport",
"http",
".",
"RoundTripper",
")",
"(",
"distribution",
".",
"Repository",
",",
"error",
")",
"{",
"ub",
",",
"err",
":=",
"v2",
".",
"NewURLBuilder... | // NewRepository creates a new Repository for the given repository name and base URL. | [
"NewRepository",
"creates",
"a",
"new",
"Repository",
"for",
"the",
"given",
"repository",
"name",
"and",
"base",
"URL",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/client/repository.go#L134-L151 | train |
docker/distribution | registry/client/repository.go | Get | func (t *tags) Get(ctx context.Context, tag string) (distribution.Descriptor, error) {
ref, err := reference.WithTag(t.name, tag)
if err != nil {
return distribution.Descriptor{}, err
}
u, err := t.ub.BuildManifestURL(ref)
if err != nil {
return distribution.Descriptor{}, err
}
newRequest := func(method str... | go | func (t *tags) Get(ctx context.Context, tag string) (distribution.Descriptor, error) {
ref, err := reference.WithTag(t.name, tag)
if err != nil {
return distribution.Descriptor{}, err
}
u, err := t.ub.BuildManifestURL(ref)
if err != nil {
return distribution.Descriptor{}, err
}
newRequest := func(method str... | [
"func",
"(",
"t",
"*",
"tags",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"tag",
"string",
")",
"(",
"distribution",
".",
"Descriptor",
",",
"error",
")",
"{",
"ref",
",",
"err",
":=",
"reference",
".",
"WithTag",
"(",
"t",
".",
"name"... | // Get issues a HEAD request for a Manifest against its named endpoint in order
// to construct a descriptor for the tag. If the registry doesn't support HEADing
// a manifest, fallback to GET. | [
"Get",
"issues",
"a",
"HEAD",
"request",
"for",
"a",
"Manifest",
"against",
"its",
"named",
"endpoint",
"in",
"order",
"to",
"construct",
"a",
"descriptor",
"for",
"the",
"tag",
".",
"If",
"the",
"registry",
"doesn",
"t",
"support",
"HEADing",
"a",
"manife... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/client/repository.go#L299-L348 | train |
docker/distribution | registry/client/repository.go | Put | func (ms *manifests) Put(ctx context.Context, m distribution.Manifest, options ...distribution.ManifestServiceOption) (digest.Digest, error) {
ref := ms.name
var tagged bool
for _, option := range options {
if opt, ok := option.(distribution.WithTagOption); ok {
var err error
ref, err = reference.WithTag(re... | go | func (ms *manifests) Put(ctx context.Context, m distribution.Manifest, options ...distribution.ManifestServiceOption) (digest.Digest, error) {
ref := ms.name
var tagged bool
for _, option := range options {
if opt, ok := option.(distribution.WithTagOption); ok {
var err error
ref, err = reference.WithTag(re... | [
"func",
"(",
"ms",
"*",
"manifests",
")",
"Put",
"(",
"ctx",
"context",
".",
"Context",
",",
"m",
"distribution",
".",
"Manifest",
",",
"options",
"...",
"distribution",
".",
"ManifestServiceOption",
")",
"(",
"digest",
".",
"Digest",
",",
"error",
")",
... | // Put puts a manifest. A tag can be specified using an options parameter which uses some shared state to hold the
// tag name in order to build the correct upload URL. | [
"Put",
"puts",
"a",
"manifest",
".",
"A",
"tag",
"can",
"be",
"specified",
"using",
"an",
"options",
"parameter",
"which",
"uses",
"some",
"shared",
"state",
"to",
"hold",
"the",
"tag",
"name",
"in",
"order",
"to",
"build",
"the",
"correct",
"upload",
"U... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/client/repository.go#L514-L579 | train |
docker/distribution | registry/client/repository.go | WithMountFrom | func WithMountFrom(ref reference.Canonical) distribution.BlobCreateOption {
return optionFunc(func(v interface{}) error {
opts, ok := v.(*distribution.CreateOptions)
if !ok {
return fmt.Errorf("unexpected options type: %T", v)
}
opts.Mount.ShouldMount = true
opts.Mount.From = ref
return nil
})
} | go | func WithMountFrom(ref reference.Canonical) distribution.BlobCreateOption {
return optionFunc(func(v interface{}) error {
opts, ok := v.(*distribution.CreateOptions)
if !ok {
return fmt.Errorf("unexpected options type: %T", v)
}
opts.Mount.ShouldMount = true
opts.Mount.From = ref
return nil
})
} | [
"func",
"WithMountFrom",
"(",
"ref",
"reference",
".",
"Canonical",
")",
"distribution",
".",
"BlobCreateOption",
"{",
"return",
"optionFunc",
"(",
"func",
"(",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"opts",
",",
"ok",
":=",
"v",
".",
"(",
"*",
... | // WithMountFrom returns a BlobCreateOption which designates that the blob should be
// mounted from the given canonical reference. | [
"WithMountFrom",
"returns",
"a",
"BlobCreateOption",
"which",
"designates",
"that",
"the",
"blob",
"should",
"be",
"mounted",
"from",
"the",
"given",
"canonical",
"reference",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/client/repository.go#L704-L716 | train |
docker/distribution | registry/client/auth/session.go | String | func (rs RepositoryScope) String() string {
repoType := "repository"
// Keep existing format for image class to maintain backwards compatibility
// with authorization servers which do not support the expanded grammar.
if rs.Class != "" && rs.Class != "image" {
repoType = fmt.Sprintf("%s(%s)", repoType, rs.Class)
... | go | func (rs RepositoryScope) String() string {
repoType := "repository"
// Keep existing format for image class to maintain backwards compatibility
// with authorization servers which do not support the expanded grammar.
if rs.Class != "" && rs.Class != "image" {
repoType = fmt.Sprintf("%s(%s)", repoType, rs.Class)
... | [
"func",
"(",
"rs",
"RepositoryScope",
")",
"String",
"(",
")",
"string",
"{",
"repoType",
":=",
"\"",
"\"",
"\n",
"// Keep existing format for image class to maintain backwards compatibility",
"// with authorization servers which do not support the expanded grammar.",
"if",
"rs",... | // String returns the string representation of the repository
// using the scope grammar | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"the",
"repository",
"using",
"the",
"scope",
"grammar"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/client/auth/session.go#L155-L163 | train |
docker/distribution | registry/client/auth/session.go | String | func (rs RegistryScope) String() string {
return fmt.Sprintf("registry:%s:%s", rs.Name, strings.Join(rs.Actions, ","))
} | go | func (rs RegistryScope) String() string {
return fmt.Sprintf("registry:%s:%s", rs.Name, strings.Join(rs.Actions, ","))
} | [
"func",
"(",
"rs",
"RegistryScope",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"rs",
".",
"Name",
",",
"strings",
".",
"Join",
"(",
"rs",
".",
"Actions",
",",
"\"",
"\"",
")",
")",
"\n",
"}"
] | // String returns the string representation of the user
// using the scope grammar | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"the",
"user",
"using",
"the",
"scope",
"grammar"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/client/auth/session.go#L174-L176 | train |
docker/distribution | registry/client/auth/session.go | NewTokenHandler | func NewTokenHandler(transport http.RoundTripper, creds CredentialStore, scope string, actions ...string) AuthenticationHandler {
// Create options...
return NewTokenHandlerWithOptions(TokenHandlerOptions{
Transport: transport,
Credentials: creds,
Scopes: []Scope{
RepositoryScope{
Repository: scope,
... | go | func NewTokenHandler(transport http.RoundTripper, creds CredentialStore, scope string, actions ...string) AuthenticationHandler {
// Create options...
return NewTokenHandlerWithOptions(TokenHandlerOptions{
Transport: transport,
Credentials: creds,
Scopes: []Scope{
RepositoryScope{
Repository: scope,
... | [
"func",
"NewTokenHandler",
"(",
"transport",
"http",
".",
"RoundTripper",
",",
"creds",
"CredentialStore",
",",
"scope",
"string",
",",
"actions",
"...",
"string",
")",
"AuthenticationHandler",
"{",
"// Create options...",
"return",
"NewTokenHandlerWithOptions",
"(",
... | // NewTokenHandler creates a new AuthenicationHandler which supports
// fetching tokens from a remote token server. | [
"NewTokenHandler",
"creates",
"a",
"new",
"AuthenicationHandler",
"which",
"supports",
"fetching",
"tokens",
"from",
"a",
"remote",
"token",
"server",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/client/auth/session.go#L210-L222 | train |
docker/distribution | registry/client/auth/session.go | NewTokenHandlerWithOptions | func NewTokenHandlerWithOptions(options TokenHandlerOptions) AuthenticationHandler {
handler := &tokenHandler{
transport: options.Transport,
creds: options.Credentials,
offlineAccess: options.OfflineAccess,
forceOAuth: options.ForceOAuth,
clientID: options.ClientID,
scopes: optio... | go | func NewTokenHandlerWithOptions(options TokenHandlerOptions) AuthenticationHandler {
handler := &tokenHandler{
transport: options.Transport,
creds: options.Credentials,
offlineAccess: options.OfflineAccess,
forceOAuth: options.ForceOAuth,
clientID: options.ClientID,
scopes: optio... | [
"func",
"NewTokenHandlerWithOptions",
"(",
"options",
"TokenHandlerOptions",
")",
"AuthenticationHandler",
"{",
"handler",
":=",
"&",
"tokenHandler",
"{",
"transport",
":",
"options",
".",
"Transport",
",",
"creds",
":",
"options",
".",
"Credentials",
",",
"offlineA... | // NewTokenHandlerWithOptions creates a new token handler using the provided
// options structure. | [
"NewTokenHandlerWithOptions",
"creates",
"a",
"new",
"token",
"handler",
"using",
"the",
"provided",
"options",
"structure",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/client/auth/session.go#L226-L239 | train |
docker/distribution | registry/proxy/proxymetrics.go | BlobPull | func (pmc *proxyMetricsCollector) BlobPull(bytesPulled uint64) {
atomic.AddUint64(&pmc.blobMetrics.Misses, 1)
atomic.AddUint64(&pmc.blobMetrics.BytesPulled, bytesPulled)
} | go | func (pmc *proxyMetricsCollector) BlobPull(bytesPulled uint64) {
atomic.AddUint64(&pmc.blobMetrics.Misses, 1)
atomic.AddUint64(&pmc.blobMetrics.BytesPulled, bytesPulled)
} | [
"func",
"(",
"pmc",
"*",
"proxyMetricsCollector",
")",
"BlobPull",
"(",
"bytesPulled",
"uint64",
")",
"{",
"atomic",
".",
"AddUint64",
"(",
"&",
"pmc",
".",
"blobMetrics",
".",
"Misses",
",",
"1",
")",
"\n",
"atomic",
".",
"AddUint64",
"(",
"&",
"pmc",
... | // BlobPull tracks metrics about blobs pulled into the cache | [
"BlobPull",
"tracks",
"metrics",
"about",
"blobs",
"pulled",
"into",
"the",
"cache"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/proxy/proxymetrics.go#L24-L27 | train |
docker/distribution | registry/proxy/proxymetrics.go | BlobPush | func (pmc *proxyMetricsCollector) BlobPush(bytesPushed uint64) {
atomic.AddUint64(&pmc.blobMetrics.Requests, 1)
atomic.AddUint64(&pmc.blobMetrics.Hits, 1)
atomic.AddUint64(&pmc.blobMetrics.BytesPushed, bytesPushed)
} | go | func (pmc *proxyMetricsCollector) BlobPush(bytesPushed uint64) {
atomic.AddUint64(&pmc.blobMetrics.Requests, 1)
atomic.AddUint64(&pmc.blobMetrics.Hits, 1)
atomic.AddUint64(&pmc.blobMetrics.BytesPushed, bytesPushed)
} | [
"func",
"(",
"pmc",
"*",
"proxyMetricsCollector",
")",
"BlobPush",
"(",
"bytesPushed",
"uint64",
")",
"{",
"atomic",
".",
"AddUint64",
"(",
"&",
"pmc",
".",
"blobMetrics",
".",
"Requests",
",",
"1",
")",
"\n",
"atomic",
".",
"AddUint64",
"(",
"&",
"pmc",... | // BlobPush tracks metrics about blobs pushed to clients | [
"BlobPush",
"tracks",
"metrics",
"about",
"blobs",
"pushed",
"to",
"clients"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/proxy/proxymetrics.go#L30-L34 | train |
docker/distribution | registry/proxy/proxymetrics.go | ManifestPull | func (pmc *proxyMetricsCollector) ManifestPull(bytesPulled uint64) {
atomic.AddUint64(&pmc.manifestMetrics.Misses, 1)
atomic.AddUint64(&pmc.manifestMetrics.BytesPulled, bytesPulled)
} | go | func (pmc *proxyMetricsCollector) ManifestPull(bytesPulled uint64) {
atomic.AddUint64(&pmc.manifestMetrics.Misses, 1)
atomic.AddUint64(&pmc.manifestMetrics.BytesPulled, bytesPulled)
} | [
"func",
"(",
"pmc",
"*",
"proxyMetricsCollector",
")",
"ManifestPull",
"(",
"bytesPulled",
"uint64",
")",
"{",
"atomic",
".",
"AddUint64",
"(",
"&",
"pmc",
".",
"manifestMetrics",
".",
"Misses",
",",
"1",
")",
"\n",
"atomic",
".",
"AddUint64",
"(",
"&",
... | // ManifestPull tracks metrics related to Manifests pulled into the cache | [
"ManifestPull",
"tracks",
"metrics",
"related",
"to",
"Manifests",
"pulled",
"into",
"the",
"cache"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/proxy/proxymetrics.go#L37-L40 | train |
docker/distribution | registry/proxy/proxymetrics.go | ManifestPush | func (pmc *proxyMetricsCollector) ManifestPush(bytesPushed uint64) {
atomic.AddUint64(&pmc.manifestMetrics.Requests, 1)
atomic.AddUint64(&pmc.manifestMetrics.Hits, 1)
atomic.AddUint64(&pmc.manifestMetrics.BytesPushed, bytesPushed)
} | go | func (pmc *proxyMetricsCollector) ManifestPush(bytesPushed uint64) {
atomic.AddUint64(&pmc.manifestMetrics.Requests, 1)
atomic.AddUint64(&pmc.manifestMetrics.Hits, 1)
atomic.AddUint64(&pmc.manifestMetrics.BytesPushed, bytesPushed)
} | [
"func",
"(",
"pmc",
"*",
"proxyMetricsCollector",
")",
"ManifestPush",
"(",
"bytesPushed",
"uint64",
")",
"{",
"atomic",
".",
"AddUint64",
"(",
"&",
"pmc",
".",
"manifestMetrics",
".",
"Requests",
",",
"1",
")",
"\n",
"atomic",
".",
"AddUint64",
"(",
"&",
... | // ManifestPush tracks metrics about manifests pushed to clients | [
"ManifestPush",
"tracks",
"metrics",
"about",
"manifests",
"pushed",
"to",
"clients"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/proxy/proxymetrics.go#L43-L47 | train |
docker/distribution | registry/storage/driver/middleware/alicdn/middleware.go | URLFor | func (ac *aliCDNStorageMiddleware) URLFor(ctx context.Context, path string, options map[string]interface{}) (string, error) {
if ac.StorageDriver.Name() != "oss" {
dcontext.GetLogger(ctx).Warn("the AliCDN middleware does not support this backend storage driver")
return ac.StorageDriver.URLFor(ctx, path, options)
... | go | func (ac *aliCDNStorageMiddleware) URLFor(ctx context.Context, path string, options map[string]interface{}) (string, error) {
if ac.StorageDriver.Name() != "oss" {
dcontext.GetLogger(ctx).Warn("the AliCDN middleware does not support this backend storage driver")
return ac.StorageDriver.URLFor(ctx, path, options)
... | [
"func",
"(",
"ac",
"*",
"aliCDNStorageMiddleware",
")",
"URLFor",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
",",
"options",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"ac",
... | // URLFor attempts to find a url which may be used to retrieve the file at the given path. | [
"URLFor",
"attempts",
"to",
"find",
"a",
"url",
"which",
"may",
"be",
"used",
"to",
"retrieve",
"the",
"file",
"at",
"the",
"given",
"path",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/middleware/alicdn/middleware.go#L100-L111 | train |
docker/distribution | health/api/api.go | DownHandler | func DownHandler(w http.ResponseWriter, r *http.Request) {
if r.Method == "POST" {
updater.Update(errors.New("manual Check"))
} else {
w.WriteHeader(http.StatusNotFound)
}
} | go | func DownHandler(w http.ResponseWriter, r *http.Request) {
if r.Method == "POST" {
updater.Update(errors.New("manual Check"))
} else {
w.WriteHeader(http.StatusNotFound)
}
} | [
"func",
"DownHandler",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"r",
".",
"Method",
"==",
"\"",
"\"",
"{",
"updater",
".",
"Update",
"(",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
")",
"\n"... | // DownHandler registers a manual_http_status that always returns an Error | [
"DownHandler",
"registers",
"a",
"manual_http_status",
"that",
"always",
"returns",
"an",
"Error"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/health/api/api.go#L15-L21 | train |
docker/distribution | health/api/api.go | UpHandler | func UpHandler(w http.ResponseWriter, r *http.Request) {
if r.Method == "POST" {
updater.Update(nil)
} else {
w.WriteHeader(http.StatusNotFound)
}
} | go | func UpHandler(w http.ResponseWriter, r *http.Request) {
if r.Method == "POST" {
updater.Update(nil)
} else {
w.WriteHeader(http.StatusNotFound)
}
} | [
"func",
"UpHandler",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"r",
".",
"Method",
"==",
"\"",
"\"",
"{",
"updater",
".",
"Update",
"(",
"nil",
")",
"\n",
"}",
"else",
"{",
"w",
".",
"WriteHea... | // UpHandler registers a manual_http_status that always returns nil | [
"UpHandler",
"registers",
"a",
"manual_http_status",
"that",
"always",
"returns",
"nil"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/health/api/api.go#L24-L30 | train |
docker/distribution | health/api/api.go | init | func init() {
health.Register("manual_http_status", updater)
http.HandleFunc("/debug/health/down", DownHandler)
http.HandleFunc("/debug/health/up", UpHandler)
} | go | func init() {
health.Register("manual_http_status", updater)
http.HandleFunc("/debug/health/down", DownHandler)
http.HandleFunc("/debug/health/up", UpHandler)
} | [
"func",
"init",
"(",
")",
"{",
"health",
".",
"Register",
"(",
"\"",
"\"",
",",
"updater",
")",
"\n",
"http",
".",
"HandleFunc",
"(",
"\"",
"\"",
",",
"DownHandler",
")",
"\n",
"http",
".",
"HandleFunc",
"(",
"\"",
"\"",
",",
"UpHandler",
")",
"\n"... | // init sets up the two endpoints to bring the service up and down | [
"init",
"sets",
"up",
"the",
"two",
"endpoints",
"to",
"bring",
"the",
"service",
"up",
"and",
"down"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/health/api/api.go#L33-L37 | train |
docker/distribution | health/checks/checks.go | HTTPChecker | func HTTPChecker(r string, statusCode int, timeout time.Duration, headers http.Header) health.Checker {
return health.CheckFunc(func() error {
client := http.Client{
Timeout: timeout,
}
req, err := http.NewRequest("HEAD", r, nil)
if err != nil {
return errors.New("error creating request: " + r)
}
for... | go | func HTTPChecker(r string, statusCode int, timeout time.Duration, headers http.Header) health.Checker {
return health.CheckFunc(func() error {
client := http.Client{
Timeout: timeout,
}
req, err := http.NewRequest("HEAD", r, nil)
if err != nil {
return errors.New("error creating request: " + r)
}
for... | [
"func",
"HTTPChecker",
"(",
"r",
"string",
",",
"statusCode",
"int",
",",
"timeout",
"time",
".",
"Duration",
",",
"headers",
"http",
".",
"Header",
")",
"health",
".",
"Checker",
"{",
"return",
"health",
".",
"CheckFunc",
"(",
"func",
"(",
")",
"error",... | // HTTPChecker does a HEAD request and verifies that the HTTP status code
// returned matches statusCode. | [
"HTTPChecker",
"does",
"a",
"HEAD",
"request",
"and",
"verifies",
"that",
"the",
"HTTP",
"status",
"code",
"returned",
"matches",
"statusCode",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/health/checks/checks.go#L38-L61 | train |
docker/distribution | health/checks/checks.go | TCPChecker | func TCPChecker(addr string, timeout time.Duration) health.Checker {
return health.CheckFunc(func() error {
conn, err := net.DialTimeout("tcp", addr, timeout)
if err != nil {
return errors.New("connection to " + addr + " failed")
}
conn.Close()
return nil
})
} | go | func TCPChecker(addr string, timeout time.Duration) health.Checker {
return health.CheckFunc(func() error {
conn, err := net.DialTimeout("tcp", addr, timeout)
if err != nil {
return errors.New("connection to " + addr + " failed")
}
conn.Close()
return nil
})
} | [
"func",
"TCPChecker",
"(",
"addr",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"health",
".",
"Checker",
"{",
"return",
"health",
".",
"CheckFunc",
"(",
"func",
"(",
")",
"error",
"{",
"conn",
",",
"err",
":=",
"net",
".",
"DialTimeout",
"(... | // TCPChecker attempts to open a TCP connection. | [
"TCPChecker",
"attempts",
"to",
"open",
"a",
"TCP",
"connection",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/health/checks/checks.go#L64-L73 | train |
docker/distribution | registry/storage/manifeststore.go | Delete | func (ms *manifestStore) Delete(ctx context.Context, dgst digest.Digest) error {
dcontext.GetLogger(ms.ctx).Debug("(*manifestStore).Delete")
return ms.blobStore.Delete(ctx, dgst)
} | go | func (ms *manifestStore) Delete(ctx context.Context, dgst digest.Digest) error {
dcontext.GetLogger(ms.ctx).Debug("(*manifestStore).Delete")
return ms.blobStore.Delete(ctx, dgst)
} | [
"func",
"(",
"ms",
"*",
"manifestStore",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"dgst",
"digest",
".",
"Digest",
")",
"error",
"{",
"dcontext",
".",
"GetLogger",
"(",
"ms",
".",
"ctx",
")",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\... | // Delete removes the revision of the specified manifest. | [
"Delete",
"removes",
"the",
"revision",
"of",
"the",
"specified",
"manifest",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/manifeststore.go#L147-L150 | train |
docker/distribution | registry/middleware/registry/middleware.go | Register | func Register(name string, initFunc InitFunc) error {
if middlewares == nil {
middlewares = make(map[string]InitFunc)
}
if _, exists := middlewares[name]; exists {
return fmt.Errorf("name already registered: %s", name)
}
middlewares[name] = initFunc
return nil
} | go | func Register(name string, initFunc InitFunc) error {
if middlewares == nil {
middlewares = make(map[string]InitFunc)
}
if _, exists := middlewares[name]; exists {
return fmt.Errorf("name already registered: %s", name)
}
middlewares[name] = initFunc
return nil
} | [
"func",
"Register",
"(",
"name",
"string",
",",
"initFunc",
"InitFunc",
")",
"error",
"{",
"if",
"middlewares",
"==",
"nil",
"{",
"middlewares",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"InitFunc",
")",
"\n",
"}",
"\n",
"if",
"_",
",",
"exists",
... | // Register is used to register an InitFunc for
// a RegistryMiddleware backend with the given name. | [
"Register",
"is",
"used",
"to",
"register",
"an",
"InitFunc",
"for",
"a",
"RegistryMiddleware",
"backend",
"with",
"the",
"given",
"name",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/middleware/registry/middleware.go#L20-L31 | train |
docker/distribution | registry/middleware/registry/middleware.go | Get | func Get(ctx context.Context, name string, options map[string]interface{}, registry distribution.Namespace) (distribution.Namespace, error) {
if middlewares != nil {
if initFunc, exists := middlewares[name]; exists {
return initFunc(ctx, registry, options)
}
}
return nil, fmt.Errorf("no registry middleware r... | go | func Get(ctx context.Context, name string, options map[string]interface{}, registry distribution.Namespace) (distribution.Namespace, error) {
if middlewares != nil {
if initFunc, exists := middlewares[name]; exists {
return initFunc(ctx, registry, options)
}
}
return nil, fmt.Errorf("no registry middleware r... | [
"func",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"options",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"registry",
"distribution",
".",
"Namespace",
")",
"(",
"distribution",
".",
"Namespace",
",",
"error",
")... | // Get constructs a RegistryMiddleware with the given options using the named backend. | [
"Get",
"constructs",
"a",
"RegistryMiddleware",
"with",
"the",
"given",
"options",
"using",
"the",
"named",
"backend",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/middleware/registry/middleware.go#L34-L42 | train |
docker/distribution | registry/middleware/registry/middleware.go | RegisterOptions | func RegisterOptions(options ...storage.RegistryOption) error {
registryoptions = append(registryoptions, options...)
return nil
} | go | func RegisterOptions(options ...storage.RegistryOption) error {
registryoptions = append(registryoptions, options...)
return nil
} | [
"func",
"RegisterOptions",
"(",
"options",
"...",
"storage",
".",
"RegistryOption",
")",
"error",
"{",
"registryoptions",
"=",
"append",
"(",
"registryoptions",
",",
"options",
"...",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // RegisterOptions adds more options to RegistryOption list. Options get applied before
// any other configuration-based options. | [
"RegisterOptions",
"adds",
"more",
"options",
"to",
"RegistryOption",
"list",
".",
"Options",
"get",
"applied",
"before",
"any",
"other",
"configuration",
"-",
"based",
"options",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/middleware/registry/middleware.go#L46-L49 | train |
docker/distribution | reference/reference.go | Domain | func Domain(named Named) string {
if r, ok := named.(namedRepository); ok {
return r.Domain()
}
domain, _ := splitDomain(named.Name())
return domain
} | go | func Domain(named Named) string {
if r, ok := named.(namedRepository); ok {
return r.Domain()
}
domain, _ := splitDomain(named.Name())
return domain
} | [
"func",
"Domain",
"(",
"named",
"Named",
")",
"string",
"{",
"if",
"r",
",",
"ok",
":=",
"named",
".",
"(",
"namedRepository",
")",
";",
"ok",
"{",
"return",
"r",
".",
"Domain",
"(",
")",
"\n",
"}",
"\n",
"domain",
",",
"_",
":=",
"splitDomain",
... | // Domain returns the domain part of the Named reference | [
"Domain",
"returns",
"the",
"domain",
"part",
"of",
"the",
"Named",
"reference"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/reference/reference.go#L149-L155 | train |
docker/distribution | reference/reference.go | Path | func Path(named Named) (name string) {
if r, ok := named.(namedRepository); ok {
return r.Path()
}
_, path := splitDomain(named.Name())
return path
} | go | func Path(named Named) (name string) {
if r, ok := named.(namedRepository); ok {
return r.Path()
}
_, path := splitDomain(named.Name())
return path
} | [
"func",
"Path",
"(",
"named",
"Named",
")",
"(",
"name",
"string",
")",
"{",
"if",
"r",
",",
"ok",
":=",
"named",
".",
"(",
"namedRepository",
")",
";",
"ok",
"{",
"return",
"r",
".",
"Path",
"(",
")",
"\n",
"}",
"\n",
"_",
",",
"path",
":=",
... | // Path returns the name without the domain part of the Named reference | [
"Path",
"returns",
"the",
"name",
"without",
"the",
"domain",
"part",
"of",
"the",
"Named",
"reference"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/reference/reference.go#L158-L164 | train |
docker/distribution | reference/reference.go | TrimNamed | func TrimNamed(ref Named) Named {
domain, path := SplitHostname(ref)
return repository{
domain: domain,
path: path,
}
} | go | func TrimNamed(ref Named) Named {
domain, path := SplitHostname(ref)
return repository{
domain: domain,
path: path,
}
} | [
"func",
"TrimNamed",
"(",
"ref",
"Named",
")",
"Named",
"{",
"domain",
",",
"path",
":=",
"SplitHostname",
"(",
"ref",
")",
"\n",
"return",
"repository",
"{",
"domain",
":",
"domain",
",",
"path",
":",
"path",
",",
"}",
"\n",
"}"
] | // TrimNamed removes any tag or digest from the named reference. | [
"TrimNamed",
"removes",
"any",
"tag",
"or",
"digest",
"from",
"the",
"named",
"reference",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/reference/reference.go#L322-L328 | train |
docker/distribution | registry/storage/cache/cachecheck/suite.go | CheckBlobDescriptorCache | func CheckBlobDescriptorCache(t *testing.T, provider cache.BlobDescriptorCacheProvider) {
ctx := context.Background()
checkBlobDescriptorCacheEmptyRepository(ctx, t, provider)
checkBlobDescriptorCacheSetAndRead(ctx, t, provider)
checkBlobDescriptorCacheClear(ctx, t, provider)
} | go | func CheckBlobDescriptorCache(t *testing.T, provider cache.BlobDescriptorCacheProvider) {
ctx := context.Background()
checkBlobDescriptorCacheEmptyRepository(ctx, t, provider)
checkBlobDescriptorCacheSetAndRead(ctx, t, provider)
checkBlobDescriptorCacheClear(ctx, t, provider)
} | [
"func",
"CheckBlobDescriptorCache",
"(",
"t",
"*",
"testing",
".",
"T",
",",
"provider",
"cache",
".",
"BlobDescriptorCacheProvider",
")",
"{",
"ctx",
":=",
"context",
".",
"Background",
"(",
")",
"\n\n",
"checkBlobDescriptorCacheEmptyRepository",
"(",
"ctx",
",",... | // CheckBlobDescriptorCache takes a cache implementation through a common set
// of operations. If adding new tests, please add them here so new
// implementations get the benefit. This should be used for unit tests. | [
"CheckBlobDescriptorCache",
"takes",
"a",
"cache",
"implementation",
"through",
"a",
"common",
"set",
"of",
"operations",
".",
"If",
"adding",
"new",
"tests",
"please",
"add",
"them",
"here",
"so",
"new",
"implementations",
"get",
"the",
"benefit",
".",
"This",
... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/cache/cachecheck/suite.go#L16-L22 | train |
docker/distribution | registry/storage/vacuum.go | RemoveBlob | func (v Vacuum) RemoveBlob(dgst string) error {
d, err := digest.Parse(dgst)
if err != nil {
return err
}
blobPath, err := pathFor(blobPathSpec{digest: d})
if err != nil {
return err
}
dcontext.GetLogger(v.ctx).Infof("Deleting blob: %s", blobPath)
err = v.driver.Delete(v.ctx, blobPath)
if err != nil {
... | go | func (v Vacuum) RemoveBlob(dgst string) error {
d, err := digest.Parse(dgst)
if err != nil {
return err
}
blobPath, err := pathFor(blobPathSpec{digest: d})
if err != nil {
return err
}
dcontext.GetLogger(v.ctx).Infof("Deleting blob: %s", blobPath)
err = v.driver.Delete(v.ctx, blobPath)
if err != nil {
... | [
"func",
"(",
"v",
"Vacuum",
")",
"RemoveBlob",
"(",
"dgst",
"string",
")",
"error",
"{",
"d",
",",
"err",
":=",
"digest",
".",
"Parse",
"(",
"dgst",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"blobPath",
",",
"e... | // RemoveBlob removes a blob from the filesystem | [
"RemoveBlob",
"removes",
"a",
"blob",
"from",
"the",
"filesystem"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/vacuum.go#L32-L51 | train |
docker/distribution | registry/storage/vacuum.go | RemoveManifest | func (v Vacuum) RemoveManifest(name string, dgst digest.Digest, tags []string) error {
// remove a tag manifest reference, in case of not found continue to next one
for _, tag := range tags {
tagsPath, err := pathFor(manifestTagIndexEntryPathSpec{name: name, revision: dgst, tag: tag})
if err != nil {
return e... | go | func (v Vacuum) RemoveManifest(name string, dgst digest.Digest, tags []string) error {
// remove a tag manifest reference, in case of not found continue to next one
for _, tag := range tags {
tagsPath, err := pathFor(manifestTagIndexEntryPathSpec{name: name, revision: dgst, tag: tag})
if err != nil {
return e... | [
"func",
"(",
"v",
"Vacuum",
")",
"RemoveManifest",
"(",
"name",
"string",
",",
"dgst",
"digest",
".",
"Digest",
",",
"tags",
"[",
"]",
"string",
")",
"error",
"{",
"// remove a tag manifest reference, in case of not found continue to next one",
"for",
"_",
",",
"t... | // RemoveManifest removes a manifest from the filesystem | [
"RemoveManifest",
"removes",
"a",
"manifest",
"from",
"the",
"filesystem"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/vacuum.go#L54-L85 | train |
docker/distribution | registry/storage/vacuum.go | RemoveRepository | func (v Vacuum) RemoveRepository(repoName string) error {
rootForRepository, err := pathFor(repositoriesRootPathSpec{})
if err != nil {
return err
}
repoDir := path.Join(rootForRepository, repoName)
dcontext.GetLogger(v.ctx).Infof("Deleting repo: %s", repoDir)
err = v.driver.Delete(v.ctx, repoDir)
if err != ni... | go | func (v Vacuum) RemoveRepository(repoName string) error {
rootForRepository, err := pathFor(repositoriesRootPathSpec{})
if err != nil {
return err
}
repoDir := path.Join(rootForRepository, repoName)
dcontext.GetLogger(v.ctx).Infof("Deleting repo: %s", repoDir)
err = v.driver.Delete(v.ctx, repoDir)
if err != ni... | [
"func",
"(",
"v",
"Vacuum",
")",
"RemoveRepository",
"(",
"repoName",
"string",
")",
"error",
"{",
"rootForRepository",
",",
"err",
":=",
"pathFor",
"(",
"repositoriesRootPathSpec",
"{",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",... | // RemoveRepository removes a repository directory from the
// filesystem | [
"RemoveRepository",
"removes",
"a",
"repository",
"directory",
"from",
"the",
"filesystem"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/vacuum.go#L89-L102 | train |
docker/distribution | registry/proxy/proxytagservice.go | Get | func (pt proxyTagService) Get(ctx context.Context, tag string) (distribution.Descriptor, error) {
err := pt.authChallenger.tryEstablishChallenges(ctx)
if err == nil {
desc, err := pt.remoteTags.Get(ctx, tag)
if err == nil {
err := pt.localTags.Tag(ctx, tag, desc)
if err != nil {
return distribution.Desc... | go | func (pt proxyTagService) Get(ctx context.Context, tag string) (distribution.Descriptor, error) {
err := pt.authChallenger.tryEstablishChallenges(ctx)
if err == nil {
desc, err := pt.remoteTags.Get(ctx, tag)
if err == nil {
err := pt.localTags.Tag(ctx, tag, desc)
if err != nil {
return distribution.Desc... | [
"func",
"(",
"pt",
"proxyTagService",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"tag",
"string",
")",
"(",
"distribution",
".",
"Descriptor",
",",
"error",
")",
"{",
"err",
":=",
"pt",
".",
"authChallenger",
".",
"tryEstablishChallenges",
"("... | // Get attempts to get the most recent digest for the tag by checking the remote
// tag service first and then caching it locally. If the remote is unavailable
// the local association is returned | [
"Get",
"attempts",
"to",
"get",
"the",
"most",
"recent",
"digest",
"for",
"the",
"tag",
"by",
"checking",
"the",
"remote",
"tag",
"service",
"first",
"and",
"then",
"caching",
"it",
"locally",
".",
"If",
"the",
"remote",
"is",
"unavailable",
"the",
"local"... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/proxy/proxytagservice.go#L21-L39 | train |
docker/distribution | configuration/configuration.go | UnmarshalYAML | func (version *Version) UnmarshalYAML(unmarshal func(interface{}) error) error {
var versionString string
err := unmarshal(&versionString)
if err != nil {
return err
}
newVersion := Version(versionString)
if _, err := newVersion.major(); err != nil {
return err
}
if _, err := newVersion.minor(); err != ni... | go | func (version *Version) UnmarshalYAML(unmarshal func(interface{}) error) error {
var versionString string
err := unmarshal(&versionString)
if err != nil {
return err
}
newVersion := Version(versionString)
if _, err := newVersion.major(); err != nil {
return err
}
if _, err := newVersion.minor(); err != ni... | [
"func",
"(",
"version",
"*",
"Version",
")",
"UnmarshalYAML",
"(",
"unmarshal",
"func",
"(",
"interface",
"{",
"}",
")",
"error",
")",
"error",
"{",
"var",
"versionString",
"string",
"\n",
"err",
":=",
"unmarshal",
"(",
"&",
"versionString",
")",
"\n",
"... | // UnmarshalYAML implements the yaml.Unmarshaler interface
// Unmarshals a string of the form X.Y into a Version, validating that X and Y can represent unsigned integers | [
"UnmarshalYAML",
"implements",
"the",
"yaml",
".",
"Unmarshaler",
"interface",
"Unmarshals",
"a",
"string",
"of",
"the",
"form",
"X",
".",
"Y",
"into",
"a",
"Version",
"validating",
"that",
"X",
"and",
"Y",
"can",
"represent",
"unsigned",
"integers"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/configuration/configuration.go#L353-L371 | train |
docker/distribution | configuration/configuration.go | UnmarshalYAML | func (loglevel *Loglevel) UnmarshalYAML(unmarshal func(interface{}) error) error {
var loglevelString string
err := unmarshal(&loglevelString)
if err != nil {
return err
}
loglevelString = strings.ToLower(loglevelString)
switch loglevelString {
case "error", "warn", "info", "debug":
default:
return fmt.Err... | go | func (loglevel *Loglevel) UnmarshalYAML(unmarshal func(interface{}) error) error {
var loglevelString string
err := unmarshal(&loglevelString)
if err != nil {
return err
}
loglevelString = strings.ToLower(loglevelString)
switch loglevelString {
case "error", "warn", "info", "debug":
default:
return fmt.Err... | [
"func",
"(",
"loglevel",
"*",
"Loglevel",
")",
"UnmarshalYAML",
"(",
"unmarshal",
"func",
"(",
"interface",
"{",
"}",
")",
"error",
")",
"error",
"{",
"var",
"loglevelString",
"string",
"\n",
"err",
":=",
"unmarshal",
"(",
"&",
"loglevelString",
")",
"\n",... | // UnmarshalYAML implements the yaml.Umarshaler interface
// Unmarshals a string into a Loglevel, lowercasing the string and validating that it represents a
// valid loglevel | [
"UnmarshalYAML",
"implements",
"the",
"yaml",
".",
"Umarshaler",
"interface",
"Unmarshals",
"a",
"string",
"into",
"a",
"Loglevel",
"lowercasing",
"the",
"string",
"and",
"validating",
"that",
"it",
"represents",
"a",
"valid",
"loglevel"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/configuration/configuration.go#L383-L399 | train |
docker/distribution | configuration/configuration.go | Type | func (storage Storage) Type() string {
var storageType []string
// Return only key in this map
for k := range storage {
switch k {
case "maintenance":
// allow configuration of maintenance
case "cache":
// allow configuration of caching
case "delete":
// allow configuration of delete
case "redire... | go | func (storage Storage) Type() string {
var storageType []string
// Return only key in this map
for k := range storage {
switch k {
case "maintenance":
// allow configuration of maintenance
case "cache":
// allow configuration of caching
case "delete":
// allow configuration of delete
case "redire... | [
"func",
"(",
"storage",
"Storage",
")",
"Type",
"(",
")",
"string",
"{",
"var",
"storageType",
"[",
"]",
"string",
"\n\n",
"// Return only key in this map",
"for",
"k",
":=",
"range",
"storage",
"{",
"switch",
"k",
"{",
"case",
"\"",
"\"",
":",
"// allow c... | // Type returns the storage driver type, such as filesystem or s3 | [
"Type",
"returns",
"the",
"storage",
"driver",
"type",
"such",
"as",
"filesystem",
"or",
"s3"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/configuration/configuration.go#L408-L433 | train |
docker/distribution | uuid/uuid.go | Generate | func Generate() (u UUID) {
const (
// ensures we backoff for less than 450ms total. Use the following to
// select new value, in units of 10ms:
// n*(n+1)/2 = d -> n^2 + n - 2d -> n = (sqrt(8d + 1) - 1)/2
maxretries = 9
backoff = time.Millisecond * 10
)
var (
totalBackoff time.Duration
count ... | go | func Generate() (u UUID) {
const (
// ensures we backoff for less than 450ms total. Use the following to
// select new value, in units of 10ms:
// n*(n+1)/2 = d -> n^2 + n - 2d -> n = (sqrt(8d + 1) - 1)/2
maxretries = 9
backoff = time.Millisecond * 10
)
var (
totalBackoff time.Duration
count ... | [
"func",
"Generate",
"(",
")",
"(",
"u",
"UUID",
")",
"{",
"const",
"(",
"// ensures we backoff for less than 450ms total. Use the following to",
"// select new value, in units of 10ms:",
"// \tn*(n+1)/2 = d -> n^2 + n - 2d -> n = (sqrt(8d + 1) - 1)/2",
"maxretries",
"=",
"9",
"\n",... | // Generate creates a new, version 4 uuid. | [
"Generate",
"creates",
"a",
"new",
"version",
"4",
"uuid",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/uuid/uuid.go#L40-L84 | train |
docker/distribution | uuid/uuid.go | Parse | func Parse(s string) (u UUID, err error) {
if len(s) != 36 {
return UUID{}, ErrUUIDInvalid
}
// create stack addresses for each section of the uuid.
p := make([][]byte, 5)
if _, err := fmt.Sscanf(s, format, &p[0], &p[1], &p[2], &p[3], &p[4]); err != nil {
return u, err
}
copy(u[0:4], p[0])
copy(u[4:6], p... | go | func Parse(s string) (u UUID, err error) {
if len(s) != 36 {
return UUID{}, ErrUUIDInvalid
}
// create stack addresses for each section of the uuid.
p := make([][]byte, 5)
if _, err := fmt.Sscanf(s, format, &p[0], &p[1], &p[2], &p[3], &p[4]); err != nil {
return u, err
}
copy(u[0:4], p[0])
copy(u[4:6], p... | [
"func",
"Parse",
"(",
"s",
"string",
")",
"(",
"u",
"UUID",
",",
"err",
"error",
")",
"{",
"if",
"len",
"(",
"s",
")",
"!=",
"36",
"{",
"return",
"UUID",
"{",
"}",
",",
"ErrUUIDInvalid",
"\n",
"}",
"\n\n",
"// create stack addresses for each section of t... | // Parse attempts to extract a uuid from the string or returns an error. | [
"Parse",
"attempts",
"to",
"extract",
"a",
"uuid",
"from",
"the",
"string",
"or",
"returns",
"an",
"error",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/uuid/uuid.go#L87-L106 | train |
docker/distribution | registry/storage/driver/s3-aws/s3.go | New | func New(params DriverParameters) (*Driver, error) {
if !params.V4Auth &&
(params.RegionEndpoint == "" ||
strings.Contains(params.RegionEndpoint, "s3.amazonaws.com")) {
return nil, fmt.Errorf("on Amazon S3 this storage driver can only be used with v4 authentication")
}
awsConfig := aws.NewConfig()
sess, err... | go | func New(params DriverParameters) (*Driver, error) {
if !params.V4Auth &&
(params.RegionEndpoint == "" ||
strings.Contains(params.RegionEndpoint, "s3.amazonaws.com")) {
return nil, fmt.Errorf("on Amazon S3 this storage driver can only be used with v4 authentication")
}
awsConfig := aws.NewConfig()
sess, err... | [
"func",
"New",
"(",
"params",
"DriverParameters",
")",
"(",
"*",
"Driver",
",",
"error",
")",
"{",
"if",
"!",
"params",
".",
"V4Auth",
"&&",
"(",
"params",
".",
"RegionEndpoint",
"==",
"\"",
"\"",
"||",
"strings",
".",
"Contains",
"(",
"params",
".",
... | // New constructs a new Driver with the given AWS credentials, region, encryption flag, and
// bucketName | [
"New",
"constructs",
"a",
"new",
"Driver",
"with",
"the",
"given",
"AWS",
"credentials",
"region",
"encryption",
"flag",
"and",
"bucketName"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/s3-aws/s3.go#L400-L499 | train |
docker/distribution | registry/storage/driver/s3-aws/s3.go | Delete | func (d *driver) Delete(ctx context.Context, path string) error {
s3Objects := make([]*s3.ObjectIdentifier, 0, listMax)
s3Path := d.s3Path(path)
listObjectsInput := &s3.ListObjectsInput{
Bucket: aws.String(d.Bucket),
Prefix: aws.String(s3Path),
}
ListLoop:
for {
// list all the objects
resp, err := d.S3.Li... | go | func (d *driver) Delete(ctx context.Context, path string) error {
s3Objects := make([]*s3.ObjectIdentifier, 0, listMax)
s3Path := d.s3Path(path)
listObjectsInput := &s3.ListObjectsInput{
Bucket: aws.String(d.Bucket),
Prefix: aws.String(s3Path),
}
ListLoop:
for {
// list all the objects
resp, err := d.S3.Li... | [
"func",
"(",
"d",
"*",
"driver",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
")",
"error",
"{",
"s3Objects",
":=",
"make",
"(",
"[",
"]",
"*",
"s3",
".",
"ObjectIdentifier",
",",
"0",
",",
"listMax",
")",
"\n",
"s3P... | // Delete recursively deletes all objects stored at "path" and its subpaths.
// We must be careful since S3 does not guarantee read after delete consistency | [
"Delete",
"recursively",
"deletes",
"all",
"objects",
"stored",
"at",
"path",
"and",
"its",
"subpaths",
".",
"We",
"must",
"be",
"careful",
"since",
"S3",
"does",
"not",
"guarantee",
"read",
"after",
"delete",
"consistency"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/s3-aws/s3.go#L808-L862 | train |
docker/distribution | registry/storage/driver/s3-aws/s3.go | S3BucketKey | func (d *Driver) S3BucketKey(path string) string {
return d.StorageDriver.(*driver).s3Path(path)
} | go | func (d *Driver) S3BucketKey(path string) string {
return d.StorageDriver.(*driver).s3Path(path)
} | [
"func",
"(",
"d",
"*",
"Driver",
")",
"S3BucketKey",
"(",
"path",
"string",
")",
"string",
"{",
"return",
"d",
".",
"StorageDriver",
".",
"(",
"*",
"driver",
")",
".",
"s3Path",
"(",
"path",
")",
"\n",
"}"
] | // S3BucketKey returns the s3 bucket key for the given storage driver path. | [
"S3BucketKey",
"returns",
"the",
"s3",
"bucket",
"key",
"for",
"the",
"given",
"storage",
"driver",
"path",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/s3-aws/s3.go#L1040-L1042 | train |
docker/distribution | registry/storage/cache/cachedblobdescriptorstore.go | NewCachedBlobStatter | func NewCachedBlobStatter(cache distribution.BlobDescriptorService, backend distribution.BlobDescriptorService) distribution.BlobDescriptorService {
return &cachedBlobStatter{
cache: cache,
backend: backend,
}
} | go | func NewCachedBlobStatter(cache distribution.BlobDescriptorService, backend distribution.BlobDescriptorService) distribution.BlobDescriptorService {
return &cachedBlobStatter{
cache: cache,
backend: backend,
}
} | [
"func",
"NewCachedBlobStatter",
"(",
"cache",
"distribution",
".",
"BlobDescriptorService",
",",
"backend",
"distribution",
".",
"BlobDescriptorService",
")",
"distribution",
".",
"BlobDescriptorService",
"{",
"return",
"&",
"cachedBlobStatter",
"{",
"cache",
":",
"cach... | // NewCachedBlobStatter creates a new statter which prefers a cache and
// falls back to a backend. | [
"NewCachedBlobStatter",
"creates",
"a",
"new",
"statter",
"which",
"prefers",
"a",
"cache",
"and",
"falls",
"back",
"to",
"a",
"backend",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/cache/cachedblobdescriptorstore.go#L49-L54 | train |
docker/distribution | registry/storage/cache/cachedblobdescriptorstore.go | NewCachedBlobStatterWithMetrics | func NewCachedBlobStatterWithMetrics(cache distribution.BlobDescriptorService, backend distribution.BlobDescriptorService, tracker MetricsTracker) distribution.BlobStatter {
return &cachedBlobStatter{
cache: cache,
backend: backend,
tracker: tracker,
}
} | go | func NewCachedBlobStatterWithMetrics(cache distribution.BlobDescriptorService, backend distribution.BlobDescriptorService, tracker MetricsTracker) distribution.BlobStatter {
return &cachedBlobStatter{
cache: cache,
backend: backend,
tracker: tracker,
}
} | [
"func",
"NewCachedBlobStatterWithMetrics",
"(",
"cache",
"distribution",
".",
"BlobDescriptorService",
",",
"backend",
"distribution",
".",
"BlobDescriptorService",
",",
"tracker",
"MetricsTracker",
")",
"distribution",
".",
"BlobStatter",
"{",
"return",
"&",
"cachedBlobS... | // NewCachedBlobStatterWithMetrics creates a new statter which prefers a cache and
// falls back to a backend. Hits and misses will send to the tracker. | [
"NewCachedBlobStatterWithMetrics",
"creates",
"a",
"new",
"statter",
"which",
"prefers",
"a",
"cache",
"and",
"falls",
"back",
"to",
"a",
"backend",
".",
"Hits",
"and",
"misses",
"will",
"send",
"to",
"the",
"tracker",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/cache/cachedblobdescriptorstore.go#L58-L64 | train |
docker/distribution | context/version.go | WithVersion | func WithVersion(ctx context.Context, version string) context.Context {
ctx = context.WithValue(ctx, versionKey{}, version)
// push a new logger onto the stack
return WithLogger(ctx, GetLogger(ctx, versionKey{}))
} | go | func WithVersion(ctx context.Context, version string) context.Context {
ctx = context.WithValue(ctx, versionKey{}, version)
// push a new logger onto the stack
return WithLogger(ctx, GetLogger(ctx, versionKey{}))
} | [
"func",
"WithVersion",
"(",
"ctx",
"context",
".",
"Context",
",",
"version",
"string",
")",
"context",
".",
"Context",
"{",
"ctx",
"=",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"versionKey",
"{",
"}",
",",
"version",
")",
"\n",
"// push a new logger ... | // WithVersion stores the application version in the context. The new context
// gets a logger to ensure log messages are marked with the application
// version. | [
"WithVersion",
"stores",
"the",
"application",
"version",
"in",
"the",
"context",
".",
"The",
"new",
"context",
"gets",
"a",
"logger",
"to",
"ensure",
"log",
"messages",
"are",
"marked",
"with",
"the",
"application",
"version",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/context/version.go#L12-L16 | train |
docker/distribution | registry/storage/driver/middleware/cloudfront/s3filter.go | newAWSIPs | func newAWSIPs(host string, updateFrequency time.Duration, awsRegion []string) *awsIPs {
ips := &awsIPs{
host: host,
updateFrequency: updateFrequency,
awsRegion: awsRegion,
updaterStopChan: make(chan bool),
}
if err := ips.tryUpdate(); err != nil {
dcontext.GetLogger(context.Background()).... | go | func newAWSIPs(host string, updateFrequency time.Duration, awsRegion []string) *awsIPs {
ips := &awsIPs{
host: host,
updateFrequency: updateFrequency,
awsRegion: awsRegion,
updaterStopChan: make(chan bool),
}
if err := ips.tryUpdate(); err != nil {
dcontext.GetLogger(context.Background()).... | [
"func",
"newAWSIPs",
"(",
"host",
"string",
",",
"updateFrequency",
"time",
".",
"Duration",
",",
"awsRegion",
"[",
"]",
"string",
")",
"*",
"awsIPs",
"{",
"ips",
":=",
"&",
"awsIPs",
"{",
"host",
":",
"host",
",",
"updateFrequency",
":",
"updateFrequency"... | // newAWSIPs returns a New awsIP object.
// If awsRegion is `nil`, it accepts any region. Otherwise, it only allow the regions specified | [
"newAWSIPs",
"returns",
"a",
"New",
"awsIP",
"object",
".",
"If",
"awsRegion",
"is",
"nil",
"it",
"accepts",
"any",
"region",
".",
"Otherwise",
"it",
"only",
"allow",
"the",
"regions",
"specified"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/middleware/cloudfront/s3filter.go#L26-L38 | train |
docker/distribution | registry/storage/driver/middleware/cloudfront/s3filter.go | tryUpdate | func (s *awsIPs) tryUpdate() error {
response, err := fetchAWSIPs(s.host)
if err != nil {
return err
}
var ipv4 []net.IPNet
var ipv6 []net.IPNet
processAddress := func(output *[]net.IPNet, prefix string, region string) {
regionAllowed := false
if len(s.awsRegion) > 0 {
for _, ar := range s.awsRegion {
... | go | func (s *awsIPs) tryUpdate() error {
response, err := fetchAWSIPs(s.host)
if err != nil {
return err
}
var ipv4 []net.IPNet
var ipv6 []net.IPNet
processAddress := func(output *[]net.IPNet, prefix string, region string) {
regionAllowed := false
if len(s.awsRegion) > 0 {
for _, ar := range s.awsRegion {
... | [
"func",
"(",
"s",
"*",
"awsIPs",
")",
"tryUpdate",
"(",
")",
"error",
"{",
"response",
",",
"err",
":=",
"fetchAWSIPs",
"(",
"s",
".",
"host",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"var",
"ipv4",
"[",
"]",
... | // tryUpdate attempts to download the new set of ip addresses.
// tryUpdate must be thread safe with contains | [
"tryUpdate",
"attempts",
"to",
"download",
"the",
"new",
"set",
"of",
"ip",
"addresses",
".",
"tryUpdate",
"must",
"be",
"thread",
"safe",
"with",
"contains"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/middleware/cloudfront/s3filter.go#L84-L132 | train |
docker/distribution | registry/storage/driver/middleware/cloudfront/s3filter.go | updater | func (s *awsIPs) updater() {
defer close(s.updaterStopChan)
for {
time.Sleep(s.updateFrequency)
select {
case <-s.updaterStopChan:
dcontext.GetLogger(context.Background()).Info("aws ip updater received stop signal")
return
default:
err := s.tryUpdate()
if err != nil {
dcontext.GetLogger(contex... | go | func (s *awsIPs) updater() {
defer close(s.updaterStopChan)
for {
time.Sleep(s.updateFrequency)
select {
case <-s.updaterStopChan:
dcontext.GetLogger(context.Background()).Info("aws ip updater received stop signal")
return
default:
err := s.tryUpdate()
if err != nil {
dcontext.GetLogger(contex... | [
"func",
"(",
"s",
"*",
"awsIPs",
")",
"updater",
"(",
")",
"{",
"defer",
"close",
"(",
"s",
".",
"updaterStopChan",
")",
"\n",
"for",
"{",
"time",
".",
"Sleep",
"(",
"s",
".",
"updateFrequency",
")",
"\n",
"select",
"{",
"case",
"<-",
"s",
".",
"... | // This function is meant to be run in a background goroutine.
// It will periodically update the ips from aws. | [
"This",
"function",
"is",
"meant",
"to",
"be",
"run",
"in",
"a",
"background",
"goroutine",
".",
"It",
"will",
"periodically",
"update",
"the",
"ips",
"from",
"aws",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/middleware/cloudfront/s3filter.go#L136-L151 | train |
docker/distribution | registry/storage/driver/middleware/cloudfront/s3filter.go | getCandidateNetworks | func (s *awsIPs) getCandidateNetworks(ip net.IP) []net.IPNet {
s.mutex.RLock()
defer s.mutex.RUnlock()
if ip.To4() != nil {
return s.ipv4
} else if ip.To16() != nil {
return s.ipv6
} else {
dcontext.GetLoggerWithFields(dcontext.Background(), map[interface{}]interface{}{
"ip": ip,
}).Error("unknown ip ad... | go | func (s *awsIPs) getCandidateNetworks(ip net.IP) []net.IPNet {
s.mutex.RLock()
defer s.mutex.RUnlock()
if ip.To4() != nil {
return s.ipv4
} else if ip.To16() != nil {
return s.ipv6
} else {
dcontext.GetLoggerWithFields(dcontext.Background(), map[interface{}]interface{}{
"ip": ip,
}).Error("unknown ip ad... | [
"func",
"(",
"s",
"*",
"awsIPs",
")",
"getCandidateNetworks",
"(",
"ip",
"net",
".",
"IP",
")",
"[",
"]",
"net",
".",
"IPNet",
"{",
"s",
".",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"mutex",
".",
"RUnlock",
"(",
")",
"\n",
"if... | // getCandidateNetworks returns either the ipv4 or ipv6 networks
// that were last read from aws. The networks returned
// have the same type as the ip address provided. | [
"getCandidateNetworks",
"returns",
"either",
"the",
"ipv4",
"or",
"ipv6",
"networks",
"that",
"were",
"last",
"read",
"from",
"aws",
".",
"The",
"networks",
"returned",
"have",
"the",
"same",
"type",
"as",
"the",
"ip",
"address",
"provided",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/middleware/cloudfront/s3filter.go#L156-L170 | train |
docker/distribution | registry/storage/driver/middleware/cloudfront/s3filter.go | contains | func (s *awsIPs) contains(ip net.IP) bool {
networks := s.getCandidateNetworks(ip)
for _, network := range networks {
if network.Contains(ip) {
return true
}
}
return false
} | go | func (s *awsIPs) contains(ip net.IP) bool {
networks := s.getCandidateNetworks(ip)
for _, network := range networks {
if network.Contains(ip) {
return true
}
}
return false
} | [
"func",
"(",
"s",
"*",
"awsIPs",
")",
"contains",
"(",
"ip",
"net",
".",
"IP",
")",
"bool",
"{",
"networks",
":=",
"s",
".",
"getCandidateNetworks",
"(",
"ip",
")",
"\n",
"for",
"_",
",",
"network",
":=",
"range",
"networks",
"{",
"if",
"network",
... | // Contains determines whether the host is within aws. | [
"Contains",
"determines",
"whether",
"the",
"host",
"is",
"within",
"aws",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/middleware/cloudfront/s3filter.go#L173-L181 | train |
docker/distribution | registry/storage/driver/middleware/cloudfront/s3filter.go | parseIPFromRequest | func parseIPFromRequest(ctx context.Context) (net.IP, error) {
request, err := dcontext.GetRequest(ctx)
if err != nil {
return nil, err
}
ipStr := dcontext.RemoteIP(request)
ip := net.ParseIP(ipStr)
if ip == nil {
return nil, fmt.Errorf("invalid ip address from requester: %s", ipStr)
}
return ip, nil
} | go | func parseIPFromRequest(ctx context.Context) (net.IP, error) {
request, err := dcontext.GetRequest(ctx)
if err != nil {
return nil, err
}
ipStr := dcontext.RemoteIP(request)
ip := net.ParseIP(ipStr)
if ip == nil {
return nil, fmt.Errorf("invalid ip address from requester: %s", ipStr)
}
return ip, nil
} | [
"func",
"parseIPFromRequest",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"net",
".",
"IP",
",",
"error",
")",
"{",
"request",
",",
"err",
":=",
"dcontext",
".",
"GetRequest",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil"... | // parseIPFromRequest attempts to extract the ip address of the
// client that made the request | [
"parseIPFromRequest",
"attempts",
"to",
"extract",
"the",
"ip",
"address",
"of",
"the",
"client",
"that",
"made",
"the",
"request"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/middleware/cloudfront/s3filter.go#L185-L197 | train |
docker/distribution | registry/storage/driver/middleware/cloudfront/s3filter.go | eligibleForS3 | func eligibleForS3(ctx context.Context, awsIPs *awsIPs) bool {
if awsIPs != nil && awsIPs.initialized {
if addr, err := parseIPFromRequest(ctx); err == nil {
request, err := dcontext.GetRequest(ctx)
if err != nil {
dcontext.GetLogger(ctx).Warnf("the CloudFront middleware cannot parse the request: %s", err)... | go | func eligibleForS3(ctx context.Context, awsIPs *awsIPs) bool {
if awsIPs != nil && awsIPs.initialized {
if addr, err := parseIPFromRequest(ctx); err == nil {
request, err := dcontext.GetRequest(ctx)
if err != nil {
dcontext.GetLogger(ctx).Warnf("the CloudFront middleware cannot parse the request: %s", err)... | [
"func",
"eligibleForS3",
"(",
"ctx",
"context",
".",
"Context",
",",
"awsIPs",
"*",
"awsIPs",
")",
"bool",
"{",
"if",
"awsIPs",
"!=",
"nil",
"&&",
"awsIPs",
".",
"initialized",
"{",
"if",
"addr",
",",
"err",
":=",
"parseIPFromRequest",
"(",
"ctx",
")",
... | // eligibleForS3 checks if a request is eligible for using S3 directly
// Return true only when the IP belongs to a specific aws region and user-agent is docker | [
"eligibleForS3",
"checks",
"if",
"a",
"request",
"is",
"eligible",
"for",
"using",
"S3",
"directly",
"Return",
"true",
"only",
"when",
"the",
"IP",
"belongs",
"to",
"a",
"specific",
"aws",
"region",
"and",
"user",
"-",
"agent",
"is",
"docker"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/driver/middleware/cloudfront/s3filter.go#L201-L223 | train |
docker/distribution | registry/storage/cache/redis/redis.go | RepositoryScoped | func (rbds *redisBlobDescriptorService) RepositoryScoped(repo string) (distribution.BlobDescriptorService, error) {
if _, err := reference.ParseNormalizedNamed(repo); err != nil {
return nil, err
}
return &repositoryScopedRedisBlobDescriptorService{
repo: repo,
upstream: rbds,
}, nil
} | go | func (rbds *redisBlobDescriptorService) RepositoryScoped(repo string) (distribution.BlobDescriptorService, error) {
if _, err := reference.ParseNormalizedNamed(repo); err != nil {
return nil, err
}
return &repositoryScopedRedisBlobDescriptorService{
repo: repo,
upstream: rbds,
}, nil
} | [
"func",
"(",
"rbds",
"*",
"redisBlobDescriptorService",
")",
"RepositoryScoped",
"(",
"repo",
"string",
")",
"(",
"distribution",
".",
"BlobDescriptorService",
",",
"error",
")",
"{",
"if",
"_",
",",
"err",
":=",
"reference",
".",
"ParseNormalizedNamed",
"(",
... | // RepositoryScoped returns the scoped cache. | [
"RepositoryScoped",
"returns",
"the",
"scoped",
"cache",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/cache/redis/redis.go#L43-L52 | train |
docker/distribution | registry/storage/cache/redis/redis.go | Stat | func (rbds *redisBlobDescriptorService) Stat(ctx context.Context, dgst digest.Digest) (distribution.Descriptor, error) {
if err := dgst.Validate(); err != nil {
return distribution.Descriptor{}, err
}
conn := rbds.pool.Get()
defer conn.Close()
return rbds.stat(ctx, conn, dgst)
} | go | func (rbds *redisBlobDescriptorService) Stat(ctx context.Context, dgst digest.Digest) (distribution.Descriptor, error) {
if err := dgst.Validate(); err != nil {
return distribution.Descriptor{}, err
}
conn := rbds.pool.Get()
defer conn.Close()
return rbds.stat(ctx, conn, dgst)
} | [
"func",
"(",
"rbds",
"*",
"redisBlobDescriptorService",
")",
"Stat",
"(",
"ctx",
"context",
".",
"Context",
",",
"dgst",
"digest",
".",
"Digest",
")",
"(",
"distribution",
".",
"Descriptor",
",",
"error",
")",
"{",
"if",
"err",
":=",
"dgst",
".",
"Valida... | // Stat retrieves the descriptor data from the redis hash entry. | [
"Stat",
"retrieves",
"the",
"descriptor",
"data",
"from",
"the",
"redis",
"hash",
"entry",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/cache/redis/redis.go#L55-L64 | train |
docker/distribution | registry/storage/cache/redis/redis.go | stat | func (rbds *redisBlobDescriptorService) stat(ctx context.Context, conn redis.Conn, dgst digest.Digest) (distribution.Descriptor, error) {
reply, err := redis.Values(conn.Do("HMGET", rbds.blobDescriptorHashKey(dgst), "digest", "size", "mediatype"))
if err != nil {
return distribution.Descriptor{}, err
}
// NOTE(s... | go | func (rbds *redisBlobDescriptorService) stat(ctx context.Context, conn redis.Conn, dgst digest.Digest) (distribution.Descriptor, error) {
reply, err := redis.Values(conn.Do("HMGET", rbds.blobDescriptorHashKey(dgst), "digest", "size", "mediatype"))
if err != nil {
return distribution.Descriptor{}, err
}
// NOTE(s... | [
"func",
"(",
"rbds",
"*",
"redisBlobDescriptorService",
")",
"stat",
"(",
"ctx",
"context",
".",
"Context",
",",
"conn",
"redis",
".",
"Conn",
",",
"dgst",
"digest",
".",
"Digest",
")",
"(",
"distribution",
".",
"Descriptor",
",",
"error",
")",
"{",
"rep... | // stat provides an internal stat call that takes a connection parameter. This
// allows some internal management of the connection scope. | [
"stat",
"provides",
"an",
"internal",
"stat",
"call",
"that",
"takes",
"a",
"connection",
"parameter",
".",
"This",
"allows",
"some",
"internal",
"management",
"of",
"the",
"connection",
"scope",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/cache/redis/redis.go#L89-L108 | train |
docker/distribution | registry/storage/cache/redis/redis.go | SetDescriptor | func (rbds *redisBlobDescriptorService) SetDescriptor(ctx context.Context, dgst digest.Digest, desc distribution.Descriptor) error {
if err := dgst.Validate(); err != nil {
return err
}
if err := cache.ValidateDescriptor(desc); err != nil {
return err
}
conn := rbds.pool.Get()
defer conn.Close()
return rb... | go | func (rbds *redisBlobDescriptorService) SetDescriptor(ctx context.Context, dgst digest.Digest, desc distribution.Descriptor) error {
if err := dgst.Validate(); err != nil {
return err
}
if err := cache.ValidateDescriptor(desc); err != nil {
return err
}
conn := rbds.pool.Get()
defer conn.Close()
return rb... | [
"func",
"(",
"rbds",
"*",
"redisBlobDescriptorService",
")",
"SetDescriptor",
"(",
"ctx",
"context",
".",
"Context",
",",
"dgst",
"digest",
".",
"Digest",
",",
"desc",
"distribution",
".",
"Descriptor",
")",
"error",
"{",
"if",
"err",
":=",
"dgst",
".",
"V... | // SetDescriptor sets the descriptor data for the given digest using a redis
// hash. A hash is used here since we may store unrelated fields about a layer
// in the future. | [
"SetDescriptor",
"sets",
"the",
"descriptor",
"data",
"for",
"the",
"given",
"digest",
"using",
"a",
"redis",
"hash",
".",
"A",
"hash",
"is",
"used",
"here",
"since",
"we",
"may",
"store",
"unrelated",
"fields",
"about",
"a",
"layer",
"in",
"the",
"future"... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/cache/redis/redis.go#L113-L126 | train |
docker/distribution | registry/storage/cache/redis/redis.go | Stat | func (rsrbds *repositoryScopedRedisBlobDescriptorService) Stat(ctx context.Context, dgst digest.Digest) (distribution.Descriptor, error) {
if err := dgst.Validate(); err != nil {
return distribution.Descriptor{}, err
}
conn := rsrbds.upstream.pool.Get()
defer conn.Close()
// Check membership to repository firs... | go | func (rsrbds *repositoryScopedRedisBlobDescriptorService) Stat(ctx context.Context, dgst digest.Digest) (distribution.Descriptor, error) {
if err := dgst.Validate(); err != nil {
return distribution.Descriptor{}, err
}
conn := rsrbds.upstream.pool.Get()
defer conn.Close()
// Check membership to repository firs... | [
"func",
"(",
"rsrbds",
"*",
"repositoryScopedRedisBlobDescriptorService",
")",
"Stat",
"(",
"ctx",
"context",
".",
"Context",
",",
"dgst",
"digest",
".",
"Digest",
")",
"(",
"distribution",
".",
"Descriptor",
",",
"error",
")",
"{",
"if",
"err",
":=",
"dgst"... | // Stat ensures that the digest is a member of the specified repository and
// forwards the descriptor request to the global blob store. If the media type
// differs for the repository, we override it. | [
"Stat",
"ensures",
"that",
"the",
"digest",
"is",
"a",
"member",
"of",
"the",
"specified",
"repository",
"and",
"forwards",
"the",
"descriptor",
"request",
"to",
"the",
"global",
"blob",
"store",
".",
"If",
"the",
"media",
"type",
"differs",
"for",
"the",
... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/cache/redis/redis.go#L158-L192 | train |
docker/distribution | registry/storage/cache/redis/redis.go | Clear | func (rsrbds *repositoryScopedRedisBlobDescriptorService) Clear(ctx context.Context, dgst digest.Digest) error {
if err := dgst.Validate(); err != nil {
return err
}
conn := rsrbds.upstream.pool.Get()
defer conn.Close()
// Check membership to repository first
member, err := redis.Bool(conn.Do("SISMEMBER", rsr... | go | func (rsrbds *repositoryScopedRedisBlobDescriptorService) Clear(ctx context.Context, dgst digest.Digest) error {
if err := dgst.Validate(); err != nil {
return err
}
conn := rsrbds.upstream.pool.Get()
defer conn.Close()
// Check membership to repository first
member, err := redis.Bool(conn.Do("SISMEMBER", rsr... | [
"func",
"(",
"rsrbds",
"*",
"repositoryScopedRedisBlobDescriptorService",
")",
"Clear",
"(",
"ctx",
"context",
".",
"Context",
",",
"dgst",
"digest",
".",
"Digest",
")",
"error",
"{",
"if",
"err",
":=",
"dgst",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
... | // Clear removes the descriptor from the cache and forwards to the upstream descriptor store | [
"Clear",
"removes",
"the",
"descriptor",
"from",
"the",
"cache",
"and",
"forwards",
"to",
"the",
"upstream",
"descriptor",
"store"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/storage/cache/redis/redis.go#L195-L214 | train |
docker/distribution | registry/handlers/catalog.go | createLinkEntry | func createLinkEntry(origURL string, maxEntries int, lastEntry string) (string, error) {
calledURL, err := url.Parse(origURL)
if err != nil {
return "", err
}
v := url.Values{}
v.Add("n", strconv.Itoa(maxEntries))
v.Add("last", lastEntry)
calledURL.RawQuery = v.Encode()
calledURL.Fragment = ""
urlStr := f... | go | func createLinkEntry(origURL string, maxEntries int, lastEntry string) (string, error) {
calledURL, err := url.Parse(origURL)
if err != nil {
return "", err
}
v := url.Values{}
v.Add("n", strconv.Itoa(maxEntries))
v.Add("last", lastEntry)
calledURL.RawQuery = v.Encode()
calledURL.Fragment = ""
urlStr := f... | [
"func",
"createLinkEntry",
"(",
"origURL",
"string",
",",
"maxEntries",
"int",
",",
"lastEntry",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"calledURL",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"origURL",
")",
"\n",
"if",
"err",
"!=",
"ni... | // Use the original URL from the request to create a new URL for
// the link header | [
"Use",
"the",
"original",
"URL",
"from",
"the",
"request",
"to",
"create",
"a",
"new",
"URL",
"for",
"the",
"link",
"header"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/catalog.go#L82-L98 | train |
docker/distribution | contrib/token-server/main.go | handlerWithContext | func handlerWithContext(ctx context.Context, handler func(context.Context, http.ResponseWriter, *http.Request)) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := dcontext.WithRequest(ctx, r)
logger := dcontext.GetRequestLogger(ctx)
ctx = dcontext.WithLogger(ctx, logger)... | go | func handlerWithContext(ctx context.Context, handler func(context.Context, http.ResponseWriter, *http.Request)) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := dcontext.WithRequest(ctx, r)
logger := dcontext.GetRequestLogger(ctx)
ctx = dcontext.WithLogger(ctx, logger)... | [
"func",
"handlerWithContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"handler",
"func",
"(",
"context",
".",
"Context",
",",
"http",
".",
"ResponseWriter",
",",
"*",
"http",
".",
"Request",
")",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".... | // handlerWithContext wraps the given context-aware handler by setting up the
// request context from a base context. | [
"handlerWithContext",
"wraps",
"the",
"given",
"context",
"-",
"aware",
"handler",
"by",
"setting",
"up",
"the",
"request",
"context",
"from",
"a",
"base",
"context",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/contrib/token-server/main.go#L117-L125 | train |
docker/distribution | registry/handlers/app.go | register | func (app *App) register(routeName string, dispatch dispatchFunc) {
handler := app.dispatcher(dispatch)
// Chain the handler with prometheus instrumented handler
if app.Config.HTTP.Debug.Prometheus.Enabled {
namespace := metrics.NewNamespace(prometheus.NamespacePrefix, "http", nil)
httpMetrics := namespace.NewD... | go | func (app *App) register(routeName string, dispatch dispatchFunc) {
handler := app.dispatcher(dispatch)
// Chain the handler with prometheus instrumented handler
if app.Config.HTTP.Debug.Prometheus.Enabled {
namespace := metrics.NewNamespace(prometheus.NamespacePrefix, "http", nil)
httpMetrics := namespace.NewD... | [
"func",
"(",
"app",
"*",
"App",
")",
"register",
"(",
"routeName",
"string",
",",
"dispatch",
"dispatchFunc",
")",
"{",
"handler",
":=",
"app",
".",
"dispatcher",
"(",
"dispatch",
")",
"\n\n",
"// Chain the handler with prometheus instrumented handler",
"if",
"app... | // register a handler with the application, by route name. The handler will be
// passed through the application filters and context will be constructed at
// request time. | [
"register",
"a",
"handler",
"with",
"the",
"application",
"by",
"route",
"name",
".",
"The",
"handler",
"will",
"be",
"passed",
"through",
"the",
"application",
"filters",
"and",
"context",
"will",
"be",
"constructed",
"at",
"request",
"time",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/app.go#L426-L444 | train |
docker/distribution | registry/handlers/app.go | configureEvents | func (app *App) configureEvents(configuration *configuration.Configuration) {
// Configure all of the endpoint sinks.
var sinks []notifications.Sink
for _, endpoint := range configuration.Notifications.Endpoints {
if endpoint.Disabled {
dcontext.GetLogger(app).Infof("endpoint %s disabled, skipping", endpoint.Na... | go | func (app *App) configureEvents(configuration *configuration.Configuration) {
// Configure all of the endpoint sinks.
var sinks []notifications.Sink
for _, endpoint := range configuration.Notifications.Endpoints {
if endpoint.Disabled {
dcontext.GetLogger(app).Infof("endpoint %s disabled, skipping", endpoint.Na... | [
"func",
"(",
"app",
"*",
"App",
")",
"configureEvents",
"(",
"configuration",
"*",
"configuration",
".",
"Configuration",
")",
"{",
"// Configure all of the endpoint sinks.",
"var",
"sinks",
"[",
"]",
"notifications",
".",
"Sink",
"\n",
"for",
"_",
",",
"endpoin... | // configureEvents prepares the event sink for action. | [
"configureEvents",
"prepares",
"the",
"event",
"sink",
"for",
"action",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/app.go#L447-L491 | train |
docker/distribution | registry/handlers/app.go | configureLogHook | func (app *App) configureLogHook(configuration *configuration.Configuration) {
entry, ok := dcontext.GetLogger(app).(*logrus.Entry)
if !ok {
// somehow, we are not using logrus
return
}
logger := entry.Logger
for _, configHook := range configuration.Log.Hooks {
if !configHook.Disabled {
switch configHoo... | go | func (app *App) configureLogHook(configuration *configuration.Configuration) {
entry, ok := dcontext.GetLogger(app).(*logrus.Entry)
if !ok {
// somehow, we are not using logrus
return
}
logger := entry.Logger
for _, configHook := range configuration.Log.Hooks {
if !configHook.Disabled {
switch configHoo... | [
"func",
"(",
"app",
"*",
"App",
")",
"configureLogHook",
"(",
"configuration",
"*",
"configuration",
".",
"Configuration",
")",
"{",
"entry",
",",
"ok",
":=",
"dcontext",
".",
"GetLogger",
"(",
"app",
")",
".",
"(",
"*",
"logrus",
".",
"Entry",
")",
"\... | // configureLogHook prepares logging hook parameters. | [
"configureLogHook",
"prepares",
"logging",
"hook",
"parameters",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/app.go#L578-L606 | train |
docker/distribution | registry/handlers/app.go | configureSecret | func (app *App) configureSecret(configuration *configuration.Configuration) {
if configuration.HTTP.Secret == "" {
var secretBytes [randomSecretSize]byte
if _, err := cryptorand.Read(secretBytes[:]); err != nil {
panic(fmt.Sprintf("could not generate random bytes for HTTP secret: %v", err))
}
configuration.... | go | func (app *App) configureSecret(configuration *configuration.Configuration) {
if configuration.HTTP.Secret == "" {
var secretBytes [randomSecretSize]byte
if _, err := cryptorand.Read(secretBytes[:]); err != nil {
panic(fmt.Sprintf("could not generate random bytes for HTTP secret: %v", err))
}
configuration.... | [
"func",
"(",
"app",
"*",
"App",
")",
"configureSecret",
"(",
"configuration",
"*",
"configuration",
".",
"Configuration",
")",
"{",
"if",
"configuration",
".",
"HTTP",
".",
"Secret",
"==",
"\"",
"\"",
"{",
"var",
"secretBytes",
"[",
"randomSecretSize",
"]",
... | // configureSecret creates a random secret if a secret wasn't included in the
// configuration. | [
"configureSecret",
"creates",
"a",
"random",
"secret",
"if",
"a",
"secret",
"wasn",
"t",
"included",
"in",
"the",
"configuration",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/app.go#L610-L619 | train |
docker/distribution | registry/handlers/app.go | context | func (app *App) context(w http.ResponseWriter, r *http.Request) *Context {
ctx := r.Context()
ctx = dcontext.WithVars(ctx, r)
ctx = dcontext.WithLogger(ctx, dcontext.GetLogger(ctx,
"vars.name",
"vars.reference",
"vars.digest",
"vars.uuid"))
context := &Context{
App: app,
Context: ctx,
}
if app.h... | go | func (app *App) context(w http.ResponseWriter, r *http.Request) *Context {
ctx := r.Context()
ctx = dcontext.WithVars(ctx, r)
ctx = dcontext.WithLogger(ctx, dcontext.GetLogger(ctx,
"vars.name",
"vars.reference",
"vars.digest",
"vars.uuid"))
context := &Context{
App: app,
Context: ctx,
}
if app.h... | [
"func",
"(",
"app",
"*",
"App",
")",
"context",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"*",
"Context",
"{",
"ctx",
":=",
"r",
".",
"Context",
"(",
")",
"\n",
"ctx",
"=",
"dcontext",
".",
"WithVars",
"... | // context constructs the context object for the application. This only be
// called once per request. | [
"context",
"constructs",
"the",
"context",
"object",
"for",
"the",
"application",
".",
"This",
"only",
"be",
"called",
"once",
"per",
"request",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/app.go#L780-L804 | train |
docker/distribution | registry/handlers/app.go | authorized | func (app *App) authorized(w http.ResponseWriter, r *http.Request, context *Context) error {
dcontext.GetLogger(context).Debug("authorizing request")
repo := getName(context)
if app.accessController == nil {
return nil // access controller is not enabled.
}
var accessRecords []auth.Access
if repo != "" {
a... | go | func (app *App) authorized(w http.ResponseWriter, r *http.Request, context *Context) error {
dcontext.GetLogger(context).Debug("authorizing request")
repo := getName(context)
if app.accessController == nil {
return nil // access controller is not enabled.
}
var accessRecords []auth.Access
if repo != "" {
a... | [
"func",
"(",
"app",
"*",
"App",
")",
"authorized",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"context",
"*",
"Context",
")",
"error",
"{",
"dcontext",
".",
"GetLogger",
"(",
"context",
")",
".",
"Debug",
"("... | // authorized checks if the request can proceed with access to the requested
// repository. If it succeeds, the context may access the requested
// repository. An error will be returned if access is not available. | [
"authorized",
"checks",
"if",
"the",
"request",
"can",
"proceed",
"with",
"access",
"to",
"the",
"requested",
"repository",
".",
"If",
"it",
"succeeds",
"the",
"context",
"may",
"access",
"the",
"requested",
"repository",
".",
"An",
"error",
"will",
"be",
"r... | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/app.go#L809-L871 | train |
docker/distribution | registry/handlers/app.go | eventBridge | func (app *App) eventBridge(ctx *Context, r *http.Request) notifications.Listener {
actor := notifications.ActorRecord{
Name: getUserName(ctx, r),
}
request := notifications.NewRequestRecord(dcontext.GetRequestID(ctx), r)
return notifications.NewBridge(ctx.urlBuilder, app.events.source, actor, request, app.event... | go | func (app *App) eventBridge(ctx *Context, r *http.Request) notifications.Listener {
actor := notifications.ActorRecord{
Name: getUserName(ctx, r),
}
request := notifications.NewRequestRecord(dcontext.GetRequestID(ctx), r)
return notifications.NewBridge(ctx.urlBuilder, app.events.source, actor, request, app.event... | [
"func",
"(",
"app",
"*",
"App",
")",
"eventBridge",
"(",
"ctx",
"*",
"Context",
",",
"r",
"*",
"http",
".",
"Request",
")",
"notifications",
".",
"Listener",
"{",
"actor",
":=",
"notifications",
".",
"ActorRecord",
"{",
"Name",
":",
"getUserName",
"(",
... | // eventBridge returns a bridge for the current request, configured with the
// correct actor and source. | [
"eventBridge",
"returns",
"a",
"bridge",
"for",
"the",
"current",
"request",
"configured",
"with",
"the",
"correct",
"actor",
"and",
"source",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/app.go#L875-L882 | train |
docker/distribution | registry/handlers/app.go | nameRequired | func (app *App) nameRequired(r *http.Request) bool {
route := mux.CurrentRoute(r)
if route == nil {
return true
}
routeName := route.GetName()
return routeName != v2.RouteNameBase && routeName != v2.RouteNameCatalog
} | go | func (app *App) nameRequired(r *http.Request) bool {
route := mux.CurrentRoute(r)
if route == nil {
return true
}
routeName := route.GetName()
return routeName != v2.RouteNameBase && routeName != v2.RouteNameCatalog
} | [
"func",
"(",
"app",
"*",
"App",
")",
"nameRequired",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"bool",
"{",
"route",
":=",
"mux",
".",
"CurrentRoute",
"(",
"r",
")",
"\n",
"if",
"route",
"==",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n",
"rou... | // nameRequired returns true if the route requires a name. | [
"nameRequired",
"returns",
"true",
"if",
"the",
"route",
"requires",
"a",
"name",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/app.go#L885-L892 | train |
docker/distribution | registry/handlers/app.go | apiBase | func apiBase(w http.ResponseWriter, r *http.Request) {
const emptyJSON = "{}"
// Provide a simple /v2/ 200 OK response with empty json response.
w.Header().Set("Content-Type", "application/json")
w.Header().Set("Content-Length", fmt.Sprint(len(emptyJSON)))
fmt.Fprint(w, emptyJSON)
} | go | func apiBase(w http.ResponseWriter, r *http.Request) {
const emptyJSON = "{}"
// Provide a simple /v2/ 200 OK response with empty json response.
w.Header().Set("Content-Type", "application/json")
w.Header().Set("Content-Length", fmt.Sprint(len(emptyJSON)))
fmt.Fprint(w, emptyJSON)
} | [
"func",
"apiBase",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"const",
"emptyJSON",
"=",
"\"",
"\"",
"\n",
"// Provide a simple /v2/ 200 OK response with empty json response.",
"w",
".",
"Header",
"(",
")",
".",
"... | // apiBase implements a simple yes-man for doing overall checks against the
// api. This can support auth roundtrips to support docker login. | [
"apiBase",
"implements",
"a",
"simple",
"yes",
"-",
"man",
"for",
"doing",
"overall",
"checks",
"against",
"the",
"api",
".",
"This",
"can",
"support",
"auth",
"roundtrips",
"to",
"support",
"docker",
"login",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/app.go#L896-L903 | train |
docker/distribution | registry/handlers/app.go | appendAccessRecords | func appendAccessRecords(records []auth.Access, method string, repo string) []auth.Access {
resource := auth.Resource{
Type: "repository",
Name: repo,
}
switch method {
case "GET", "HEAD":
records = append(records,
auth.Access{
Resource: resource,
Action: "pull",
})
case "POST", "PUT", "PATC... | go | func appendAccessRecords(records []auth.Access, method string, repo string) []auth.Access {
resource := auth.Resource{
Type: "repository",
Name: repo,
}
switch method {
case "GET", "HEAD":
records = append(records,
auth.Access{
Resource: resource,
Action: "pull",
})
case "POST", "PUT", "PATC... | [
"func",
"appendAccessRecords",
"(",
"records",
"[",
"]",
"auth",
".",
"Access",
",",
"method",
"string",
",",
"repo",
"string",
")",
"[",
"]",
"auth",
".",
"Access",
"{",
"resource",
":=",
"auth",
".",
"Resource",
"{",
"Type",
":",
"\"",
"\"",
",",
"... | // appendAccessRecords checks the method and adds the appropriate Access records to the records list. | [
"appendAccessRecords",
"checks",
"the",
"method",
"and",
"adds",
"the",
"appropriate",
"Access",
"records",
"to",
"the",
"records",
"list",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/app.go#L906-L937 | train |
docker/distribution | registry/handlers/app.go | appendCatalogAccessRecord | func appendCatalogAccessRecord(accessRecords []auth.Access, r *http.Request) []auth.Access {
route := mux.CurrentRoute(r)
routeName := route.GetName()
if routeName == v2.RouteNameCatalog {
resource := auth.Resource{
Type: "registry",
Name: "catalog",
}
accessRecords = append(accessRecords,
auth.Acce... | go | func appendCatalogAccessRecord(accessRecords []auth.Access, r *http.Request) []auth.Access {
route := mux.CurrentRoute(r)
routeName := route.GetName()
if routeName == v2.RouteNameCatalog {
resource := auth.Resource{
Type: "registry",
Name: "catalog",
}
accessRecords = append(accessRecords,
auth.Acce... | [
"func",
"appendCatalogAccessRecord",
"(",
"accessRecords",
"[",
"]",
"auth",
".",
"Access",
",",
"r",
"*",
"http",
".",
"Request",
")",
"[",
"]",
"auth",
".",
"Access",
"{",
"route",
":=",
"mux",
".",
"CurrentRoute",
"(",
"r",
")",
"\n",
"routeName",
"... | // Add the access record for the catalog if it's our current route | [
"Add",
"the",
"access",
"record",
"for",
"the",
"catalog",
"if",
"it",
"s",
"our",
"current",
"route"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/app.go#L940-L957 | train |
docker/distribution | registry/handlers/app.go | applyRegistryMiddleware | func applyRegistryMiddleware(ctx context.Context, registry distribution.Namespace, middlewares []configuration.Middleware) (distribution.Namespace, error) {
for _, mw := range middlewares {
rmw, err := registrymiddleware.Get(ctx, mw.Name, mw.Options, registry)
if err != nil {
return nil, fmt.Errorf("unable to c... | go | func applyRegistryMiddleware(ctx context.Context, registry distribution.Namespace, middlewares []configuration.Middleware) (distribution.Namespace, error) {
for _, mw := range middlewares {
rmw, err := registrymiddleware.Get(ctx, mw.Name, mw.Options, registry)
if err != nil {
return nil, fmt.Errorf("unable to c... | [
"func",
"applyRegistryMiddleware",
"(",
"ctx",
"context",
".",
"Context",
",",
"registry",
"distribution",
".",
"Namespace",
",",
"middlewares",
"[",
"]",
"configuration",
".",
"Middleware",
")",
"(",
"distribution",
".",
"Namespace",
",",
"error",
")",
"{",
"... | // applyRegistryMiddleware wraps a registry instance with the configured middlewares | [
"applyRegistryMiddleware",
"wraps",
"a",
"registry",
"instance",
"with",
"the",
"configured",
"middlewares"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/app.go#L960-L970 | train |
docker/distribution | registry/handlers/app.go | applyRepoMiddleware | func applyRepoMiddleware(ctx context.Context, repository distribution.Repository, middlewares []configuration.Middleware) (distribution.Repository, error) {
for _, mw := range middlewares {
rmw, err := repositorymiddleware.Get(ctx, mw.Name, mw.Options, repository)
if err != nil {
return nil, err
}
repositor... | go | func applyRepoMiddleware(ctx context.Context, repository distribution.Repository, middlewares []configuration.Middleware) (distribution.Repository, error) {
for _, mw := range middlewares {
rmw, err := repositorymiddleware.Get(ctx, mw.Name, mw.Options, repository)
if err != nil {
return nil, err
}
repositor... | [
"func",
"applyRepoMiddleware",
"(",
"ctx",
"context",
".",
"Context",
",",
"repository",
"distribution",
".",
"Repository",
",",
"middlewares",
"[",
"]",
"configuration",
".",
"Middleware",
")",
"(",
"distribution",
".",
"Repository",
",",
"error",
")",
"{",
"... | // applyRepoMiddleware wraps a repository with the configured middlewares | [
"applyRepoMiddleware",
"wraps",
"a",
"repository",
"with",
"the",
"configured",
"middlewares"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/app.go#L973-L982 | train |
docker/distribution | registry/handlers/app.go | applyStorageMiddleware | func applyStorageMiddleware(driver storagedriver.StorageDriver, middlewares []configuration.Middleware) (storagedriver.StorageDriver, error) {
for _, mw := range middlewares {
smw, err := storagemiddleware.Get(mw.Name, mw.Options, driver)
if err != nil {
return nil, fmt.Errorf("unable to configure storage middl... | go | func applyStorageMiddleware(driver storagedriver.StorageDriver, middlewares []configuration.Middleware) (storagedriver.StorageDriver, error) {
for _, mw := range middlewares {
smw, err := storagemiddleware.Get(mw.Name, mw.Options, driver)
if err != nil {
return nil, fmt.Errorf("unable to configure storage middl... | [
"func",
"applyStorageMiddleware",
"(",
"driver",
"storagedriver",
".",
"StorageDriver",
",",
"middlewares",
"[",
"]",
"configuration",
".",
"Middleware",
")",
"(",
"storagedriver",
".",
"StorageDriver",
",",
"error",
")",
"{",
"for",
"_",
",",
"mw",
":=",
"ran... | // applyStorageMiddleware wraps a storage driver with the configured middlewares | [
"applyStorageMiddleware",
"wraps",
"a",
"storage",
"driver",
"with",
"the",
"configured",
"middlewares"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/app.go#L985-L994 | train |
docker/distribution | registry/handlers/app.go | startUploadPurger | func startUploadPurger(ctx context.Context, storageDriver storagedriver.StorageDriver, log dcontext.Logger, config map[interface{}]interface{}) {
if config["enabled"] == false {
return
}
var purgeAgeDuration time.Duration
var err error
purgeAge, ok := config["age"]
if ok {
ageStr, ok := purgeAge.(string)
i... | go | func startUploadPurger(ctx context.Context, storageDriver storagedriver.StorageDriver, log dcontext.Logger, config map[interface{}]interface{}) {
if config["enabled"] == false {
return
}
var purgeAgeDuration time.Duration
var err error
purgeAge, ok := config["age"]
if ok {
ageStr, ok := purgeAge.(string)
i... | [
"func",
"startUploadPurger",
"(",
"ctx",
"context",
".",
"Context",
",",
"storageDriver",
"storagedriver",
".",
"StorageDriver",
",",
"log",
"dcontext",
".",
"Logger",
",",
"config",
"map",
"[",
"interface",
"{",
"}",
"]",
"interface",
"{",
"}",
")",
"{",
... | // startUploadPurger schedules a goroutine which will periodically
// check upload directories for old files and delete them | [
"startUploadPurger",
"schedules",
"a",
"goroutine",
"which",
"will",
"periodically",
"check",
"upload",
"directories",
"for",
"old",
"files",
"and",
"delete",
"them"
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/registry/handlers/app.go#L1014-L1074 | train |
docker/distribution | manifest/schema1/sign.go | Sign | func Sign(m *Manifest, pk libtrust.PrivateKey) (*SignedManifest, error) {
p, err := json.MarshalIndent(m, "", " ")
if err != nil {
return nil, err
}
js, err := libtrust.NewJSONSignature(p)
if err != nil {
return nil, err
}
if err := js.Sign(pk); err != nil {
return nil, err
}
pretty, err := js.Prett... | go | func Sign(m *Manifest, pk libtrust.PrivateKey) (*SignedManifest, error) {
p, err := json.MarshalIndent(m, "", " ")
if err != nil {
return nil, err
}
js, err := libtrust.NewJSONSignature(p)
if err != nil {
return nil, err
}
if err := js.Sign(pk); err != nil {
return nil, err
}
pretty, err := js.Prett... | [
"func",
"Sign",
"(",
"m",
"*",
"Manifest",
",",
"pk",
"libtrust",
".",
"PrivateKey",
")",
"(",
"*",
"SignedManifest",
",",
"error",
")",
"{",
"p",
",",
"err",
":=",
"json",
".",
"MarshalIndent",
"(",
"m",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\... | // Sign signs the manifest with the provided private key, returning a
// SignedManifest. This typically won't be used within the registry, except
// for testing. | [
"Sign",
"signs",
"the",
"manifest",
"with",
"the",
"provided",
"private",
"key",
"returning",
"a",
"SignedManifest",
".",
"This",
"typically",
"won",
"t",
"be",
"used",
"within",
"the",
"registry",
"except",
"for",
"testing",
"."
] | 3226863cbcba6dbc2f6c83a37b28126c934af3f8 | https://github.com/docker/distribution/blob/3226863cbcba6dbc2f6c83a37b28126c934af3f8/manifest/schema1/sign.go#L13-L38 | 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.