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
perkeep/perkeep
pkg/importer/flickr/flickr.go
updatePrimaryPhoto
func (r *run) updatePrimaryPhoto(photoNode *importer.Object) error { photoId := photoNode.Attr(attrFlickrId) for album, photo := range r.primaryPhoto { if photoId != photo { continue } setsNode, err := r.getTopLevelNode("sets", "Sets") if err != nil { return fmt.Errorf("could not set %v as primary photo...
go
func (r *run) updatePrimaryPhoto(photoNode *importer.Object) error { photoId := photoNode.Attr(attrFlickrId) for album, photo := range r.primaryPhoto { if photoId != photo { continue } setsNode, err := r.getTopLevelNode("sets", "Sets") if err != nil { return fmt.Errorf("could not set %v as primary photo...
[ "func", "(", "r", "*", "run", ")", "updatePrimaryPhoto", "(", "photoNode", "*", "importer", ".", "Object", ")", "error", "{", "photoId", ":=", "photoNode", ".", "Attr", "(", "attrFlickrId", ")", "\n", "for", "album", ",", "photo", ":=", "range", "r", "...
// updatePrimaryPhoto uses the camliContent of photoNode to set the // camliContentImage of any album for which photoNode is the primary photo.
[ "updatePrimaryPhoto", "uses", "the", "camliContent", "of", "photoNode", "to", "set", "the", "camliContentImage", "of", "any", "album", "for", "which", "photoNode", "is", "the", "primary", "photo", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/flickr/flickr.go#L455-L479
train
perkeep/perkeep
internal/images/docker.go
pull
func pull(image string) error { var stdout, stderr bytes.Buffer cmd := exec.Command("docker", "pull", image) cmd.Stdout = &stdout cmd.Stderr = &stderr err := cmd.Run() out := stdout.String() // TODO(mpl): if it turns out docker respects conventions and the // "Authentication is required" message does come from ...
go
func pull(image string) error { var stdout, stderr bytes.Buffer cmd := exec.Command("docker", "pull", image) cmd.Stdout = &stdout cmd.Stderr = &stderr err := cmd.Run() out := stdout.String() // TODO(mpl): if it turns out docker respects conventions and the // "Authentication is required" message does come from ...
[ "func", "pull", "(", "image", "string", ")", "error", "{", "var", "stdout", ",", "stderr", "bytes", ".", "Buffer", "\n", "cmd", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "\"", "\"", ",", "image", ")", "\n", "cmd", ".", "Stdout", "=", "&...
// Pull retrieves the docker image with 'docker pull'.
[ "Pull", "retrieves", "the", "docker", "image", "with", "docker", "pull", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/images/docker.go#L78-L92
train
perkeep/perkeep
app/scanningcabinet/datastore.go
updateScan
func (h *handler) updateScan(ctx context.Context, pn blob.Ref, new, old *mediaObject) error { if old == nil { mo, err := h.fetchScan(pn) if err != nil { return fmt.Errorf("scan %v not found: %v", pn, err) } old = &mo } if new.contentRef.Valid() && old.contentRef != new.contentRef { if err := h.setAttrib...
go
func (h *handler) updateScan(ctx context.Context, pn blob.Ref, new, old *mediaObject) error { if old == nil { mo, err := h.fetchScan(pn) if err != nil { return fmt.Errorf("scan %v not found: %v", pn, err) } old = &mo } if new.contentRef.Valid() && old.contentRef != new.contentRef { if err := h.setAttrib...
[ "func", "(", "h", "*", "handler", ")", "updateScan", "(", "ctx", "context", ".", "Context", ",", "pn", "blob", ".", "Ref", ",", "new", ",", "old", "*", "mediaObject", ")", "error", "{", "if", "old", "==", "nil", "{", "mo", ",", "err", ":=", "h", ...
// old is an optimization, in case the caller already had fetched the old scan. // If nil, the current scan will be fetched for comparison with new.
[ "old", "is", "an", "optimization", "in", "case", "the", "caller", "already", "had", "fetched", "the", "old", "scan", ".", "If", "nil", "the", "current", "scan", "will", "be", "fetched", "for", "comparison", "with", "new", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/scanningcabinet/datastore.go#L331-L361
train
perkeep/perkeep
app/scanningcabinet/datastore.go
persistDocAndPages
func (h *handler) persistDocAndPages(ctx context.Context, newDoc document) (blob.Ref, error) { br := blob.Ref{} pn, err := h.createDocument(ctx, newDoc) if err != nil { return br, err } for _, page := range newDoc.pages { if err := h.setAttribute(ctx, page, "document", pn.String()); err != nil { return br, ...
go
func (h *handler) persistDocAndPages(ctx context.Context, newDoc document) (blob.Ref, error) { br := blob.Ref{} pn, err := h.createDocument(ctx, newDoc) if err != nil { return br, err } for _, page := range newDoc.pages { if err := h.setAttribute(ctx, page, "document", pn.String()); err != nil { return br, ...
[ "func", "(", "h", "*", "handler", ")", "persistDocAndPages", "(", "ctx", "context", ".", "Context", ",", "newDoc", "document", ")", "(", "blob", ".", "Ref", ",", "error", ")", "{", "br", ":=", "blob", ".", "Ref", "{", "}", "\n", "pn", ",", "err", ...
// persistDocAndPages creates a new Document struct that represents // the given mediaObject structs and stores it in the datastore, updates each of // these mediaObject in the datastore with references back to the new Document struct // and returns the key to the new document entity
[ "persistDocAndPages", "creates", "a", "new", "Document", "struct", "that", "represents", "the", "given", "mediaObject", "structs", "and", "stores", "it", "in", "the", "datastore", "updates", "each", "of", "these", "mediaObject", "in", "the", "datastore", "with", ...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/scanningcabinet/datastore.go#L480-L493
train
perkeep/perkeep
app/scanningcabinet/datastore.go
dateOrZero
func dateOrZero(datestr, format string) (time.Time, error) { if datestr == "" { return time.Time{}, nil } if format == "" { format = time.RFC3339 } return time.Parse(format, datestr) }
go
func dateOrZero(datestr, format string) (time.Time, error) { if datestr == "" { return time.Time{}, nil } if format == "" { format = time.RFC3339 } return time.Parse(format, datestr) }
[ "func", "dateOrZero", "(", "datestr", ",", "format", "string", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "if", "datestr", "==", "\"", "\"", "{", "return", "time", ".", "Time", "{", "}", ",", "nil", "\n", "}", "\n", "if", "format", "=...
// dateOrZero parses datestr with the given format and returns the resulting // time and error. An empty datestr is not an error and yields a zero time. format // defaults to time.RFC3339 if empty.
[ "dateOrZero", "parses", "datestr", "with", "the", "given", "format", "and", "returns", "the", "resulting", "time", "and", "error", ".", "An", "empty", "datestr", "is", "not", "an", "error", "and", "yields", "a", "zero", "time", ".", "format", "defaults", "...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/scanningcabinet/datastore.go#L769-L777
train
perkeep/perkeep
app/scanningcabinet/datastore.go
breakAndDeleteDoc
func (h *handler) breakAndDeleteDoc(ctx context.Context, docRef blob.Ref) error { doc, err := h.fetchDocument(docRef) if err != nil { return fmt.Errorf("document %v not found: %v", docRef, err) } if err := h.deleteNode(ctx, docRef); err != nil { return fmt.Errorf("could not delete document %v: %v", docRef, err)...
go
func (h *handler) breakAndDeleteDoc(ctx context.Context, docRef blob.Ref) error { doc, err := h.fetchDocument(docRef) if err != nil { return fmt.Errorf("document %v not found: %v", docRef, err) } if err := h.deleteNode(ctx, docRef); err != nil { return fmt.Errorf("could not delete document %v: %v", docRef, err)...
[ "func", "(", "h", "*", "handler", ")", "breakAndDeleteDoc", "(", "ctx", "context", ".", "Context", ",", "docRef", "blob", ".", "Ref", ")", "error", "{", "doc", ",", "err", ":=", "h", ".", "fetchDocument", "(", "docRef", ")", "\n", "if", "err", "!=", ...
// breakAndDeleteDoc deletes the given document struct and marks all of its // associated mediaObject as not being part of a document
[ "breakAndDeleteDoc", "deletes", "the", "given", "document", "struct", "and", "marks", "all", "of", "its", "associated", "mediaObject", "as", "not", "being", "part", "of", "a", "document" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/scanningcabinet/datastore.go#L840-L854
train
perkeep/perkeep
pkg/index/index.go
NewOwner
func NewOwner(keyID string, ref blob.Ref) *Owner { return &Owner{ keyID: []string{keyID}, blobByKeyID: map[string]SignerRefSet{keyID: SignerRefSet{ref.String()}}, } }
go
func NewOwner(keyID string, ref blob.Ref) *Owner { return &Owner{ keyID: []string{keyID}, blobByKeyID: map[string]SignerRefSet{keyID: SignerRefSet{ref.String()}}, } }
[ "func", "NewOwner", "(", "keyID", "string", ",", "ref", "blob", ".", "Ref", ")", "*", "Owner", "{", "return", "&", "Owner", "{", "keyID", ":", "[", "]", "string", "{", "keyID", "}", ",", "blobByKeyID", ":", "map", "[", "string", "]", "SignerRefSet", ...
// NewOwner returns an Owner that associates keyID with ref.
[ "NewOwner", "returns", "an", "Owner", "that", "associates", "keyID", "with", "ref", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/index.go#L124-L129
train
perkeep/perkeep
pkg/index/index.go
RefSet
func (o *Owner) RefSet(keyID string) SignerRefSet { if o == nil || len(o.blobByKeyID) == 0 { return nil } refs := o.blobByKeyID[keyID] if len(refs) == 0 { return nil } return refs }
go
func (o *Owner) RefSet(keyID string) SignerRefSet { if o == nil || len(o.blobByKeyID) == 0 { return nil } refs := o.blobByKeyID[keyID] if len(refs) == 0 { return nil } return refs }
[ "func", "(", "o", "*", "Owner", ")", "RefSet", "(", "keyID", "string", ")", "SignerRefSet", "{", "if", "o", "==", "nil", "||", "len", "(", "o", ".", "blobByKeyID", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "refs", ":=", "o", ".", "...
// RefSet returns the set of refs that represent the same owner as keyID.
[ "RefSet", "returns", "the", "set", "of", "refs", "that", "represent", "the", "same", "owner", "as", "keyID", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/index.go#L141-L150
train
perkeep/perkeep
pkg/index/index.go
SetReindexMaxProcs
func SetReindexMaxProcs(n int) { reindexMaxProcs.Lock() defer reindexMaxProcs.Unlock() reindexMaxProcs.v = n }
go
func SetReindexMaxProcs(n int) { reindexMaxProcs.Lock() defer reindexMaxProcs.Unlock() reindexMaxProcs.v = n }
[ "func", "SetReindexMaxProcs", "(", "n", "int", ")", "{", "reindexMaxProcs", ".", "Lock", "(", ")", "\n", "defer", "reindexMaxProcs", ".", "Unlock", "(", ")", "\n", "reindexMaxProcs", ".", "v", "=", "n", "\n", "}" ]
// SetReindexMaxProcs sets the maximum number of concurrent goroutines that are // used during reindexing.
[ "SetReindexMaxProcs", "sets", "the", "maximum", "number", "of", "concurrent", "goroutines", "that", "are", "used", "during", "reindexing", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/index.go#L435-L439
train
perkeep/perkeep
pkg/index/index.go
integrityCheck
func (x *Index) integrityCheck(timeout time.Duration) error { t0 := time.Now() x.logf("starting integrity check...") defer func() { x.logf("integrity check done (after %v)", time.Since(t0).Round(10*time.Millisecond)) }() if x.blobSource == nil { return errors.New("index: can't check sanity of index: no blobSou...
go
func (x *Index) integrityCheck(timeout time.Duration) error { t0 := time.Now() x.logf("starting integrity check...") defer func() { x.logf("integrity check done (after %v)", time.Since(t0).Round(10*time.Millisecond)) }() if x.blobSource == nil { return errors.New("index: can't check sanity of index: no blobSou...
[ "func", "(", "x", "*", "Index", ")", "integrityCheck", "(", "timeout", "time", ".", "Duration", ")", "error", "{", "t0", ":=", "time", ".", "Now", "(", ")", "\n", "x", ".", "logf", "(", "\"", "\"", ")", "\n", "defer", "func", "(", ")", "{", "x"...
// integrityCheck enumerates blobs through x.blobSource during timemout, and // verifies for each of them that it has a meta row in the index. It logs a message // if any of them is not found. It only returns an error if something went wrong // during the enumeration.
[ "integrityCheck", "enumerates", "blobs", "through", "x", ".", "blobSource", "during", "timemout", "and", "verifies", "for", "each", "of", "them", "that", "it", "has", "a", "meta", "row", "in", "the", "index", ".", "It", "logs", "a", "message", "if", "any",...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/index.go#L561-L602
train
perkeep/perkeep
pkg/index/index.go
schemaVersion
func (x *Index) schemaVersion() int { schemaVersionStr, err := x.s.Get(keySchemaVersion.name) if err != nil { if err == sorted.ErrNotFound { return 0 } panic(fmt.Sprintf("Could not get index schema version: %v", err)) } schemaVersion, err := strconv.Atoi(schemaVersionStr) if err != nil { panic(fmt.Sprin...
go
func (x *Index) schemaVersion() int { schemaVersionStr, err := x.s.Get(keySchemaVersion.name) if err != nil { if err == sorted.ErrNotFound { return 0 } panic(fmt.Sprintf("Could not get index schema version: %v", err)) } schemaVersion, err := strconv.Atoi(schemaVersionStr) if err != nil { panic(fmt.Sprin...
[ "func", "(", "x", "*", "Index", ")", "schemaVersion", "(", ")", "int", "{", "schemaVersionStr", ",", "err", ":=", "x", ".", "s", ".", "Get", "(", "keySchemaVersion", ".", "name", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "sorted"...
// schemaVersion returns the version of schema as it is found // in the currently used index. If not found, it returns 0.
[ "schemaVersion", "returns", "the", "version", "of", "schema", "as", "it", "is", "found", "in", "the", "currently", "used", "index", ".", "If", "not", "found", "it", "returns", "0", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/index.go#L637-L650
train
perkeep/perkeep
pkg/index/index.go
initDeletesCache
func (x *Index) initDeletesCache() (err error) { x.deletes = newDeletionCache() it := x.queryPrefix(keyDeleted) defer closeIterator(it, &err) for it.Next() { cl, ok := kvDeleted(it.Key()) if !ok { return fmt.Errorf("Bogus keyDeleted entry key: want |\"deleted\"|<deleted blobref>|<reverse claimdate>|<deleter ...
go
func (x *Index) initDeletesCache() (err error) { x.deletes = newDeletionCache() it := x.queryPrefix(keyDeleted) defer closeIterator(it, &err) for it.Next() { cl, ok := kvDeleted(it.Key()) if !ok { return fmt.Errorf("Bogus keyDeleted entry key: want |\"deleted\"|<deleted blobref>|<reverse claimdate>|<deleter ...
[ "func", "(", "x", "*", "Index", ")", "initDeletesCache", "(", ")", "(", "err", "error", ")", "{", "x", ".", "deletes", "=", "newDeletionCache", "(", ")", "\n", "it", ":=", "x", ".", "queryPrefix", "(", "keyDeleted", ")", "\n", "defer", "closeIterator",...
// initDeletesCache creates and populates the deletion status cache used by the index // for faster calls to IsDeleted and DeletedAt. It is called by New.
[ "initDeletesCache", "creates", "and", "populates", "the", "deletion", "status", "cache", "used", "by", "the", "index", "for", "faster", "calls", "to", "IsDeleted", "and", "DeletedAt", ".", "It", "is", "called", "by", "New", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/index.go#L676-L694
train
perkeep/perkeep
pkg/index/index.go
isDeleted
func (x *Index) isDeleted(br blob.Ref) bool { deletes, ok := x.deletes.m[br] if !ok { return false } for _, v := range deletes { if !x.isDeleted(v.deleter) { return true } } return false }
go
func (x *Index) isDeleted(br blob.Ref) bool { deletes, ok := x.deletes.m[br] if !ok { return false } for _, v := range deletes { if !x.isDeleted(v.deleter) { return true } } return false }
[ "func", "(", "x", "*", "Index", ")", "isDeleted", "(", "br", "blob", ".", "Ref", ")", "bool", "{", "deletes", ",", "ok", ":=", "x", ".", "deletes", ".", "m", "[", "br", "]", "\n", "if", "!", "ok", "{", "return", "false", "\n", "}", "\n", "for...
// The caller must hold x.deletes.mu for read.
[ "The", "caller", "must", "hold", "x", ".", "deletes", ".", "mu", "for", "read", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/index.go#L739-L750
train
perkeep/perkeep
pkg/index/index.go
GetRecentPermanodes
func (x *Index) GetRecentPermanodes(ctx context.Context, dest chan<- camtypes.RecentPermanode, owner blob.Ref, limit int, before time.Time) (err error) { defer close(dest) keyId, err := x.KeyId(ctx, owner) if err == sorted.ErrNotFound { x.logf("no recent permanodes because keyId for owner %v not found", owner) ...
go
func (x *Index) GetRecentPermanodes(ctx context.Context, dest chan<- camtypes.RecentPermanode, owner blob.Ref, limit int, before time.Time) (err error) { defer close(dest) keyId, err := x.KeyId(ctx, owner) if err == sorted.ErrNotFound { x.logf("no recent permanodes because keyId for owner %v not found", owner) ...
[ "func", "(", "x", "*", "Index", ")", "GetRecentPermanodes", "(", "ctx", "context", ".", "Context", ",", "dest", "chan", "<-", "camtypes", ".", "RecentPermanode", ",", "owner", "blob", ".", "Ref", ",", "limit", "int", ",", "before", "time", ".", "Time", ...
// GetRecentPermanodes sends results to dest filtered by owner, limit, and // before. A zero value for before will default to the current time. The // results will have duplicates suppressed, with most recent permanode // returned. // Note, permanodes more recent than before will still be fetched from the // index th...
[ "GetRecentPermanodes", "sends", "results", "to", "dest", "filtered", "by", "owner", "limit", "and", "before", ".", "A", "zero", "value", "for", "before", "will", "default", "to", "the", "current", "time", ".", "The", "results", "will", "have", "duplicates", ...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/index.go#L785-L839
train
perkeep/perkeep
pkg/index/index.go
HasLegacySHA1
func (x *Index) HasLegacySHA1() (ok bool, err error) { if x.corpus != nil { return x.corpus.hasLegacySHA1, err } it := x.queryPrefix(keyWholeToFileRef, "sha1-") defer closeIterator(it, &err) for it.Next() { return true, err } return false, err }
go
func (x *Index) HasLegacySHA1() (ok bool, err error) { if x.corpus != nil { return x.corpus.hasLegacySHA1, err } it := x.queryPrefix(keyWholeToFileRef, "sha1-") defer closeIterator(it, &err) for it.Next() { return true, err } return false, err }
[ "func", "(", "x", "*", "Index", ")", "HasLegacySHA1", "(", ")", "(", "ok", "bool", ",", "err", "error", ")", "{", "if", "x", ".", "corpus", "!=", "nil", "{", "return", "x", ".", "corpus", ".", "hasLegacySHA1", ",", "err", "\n", "}", "\n", "it", ...
// HasLegacySHA1 reports whether the index has legacy SHA-1 blobs.
[ "HasLegacySHA1", "reports", "whether", "the", "index", "has", "legacy", "SHA", "-", "1", "blobs", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/index.go#L965-L975
train
perkeep/perkeep
pkg/index/index.go
signerRefs
func (x *Index) signerRefs(ctx context.Context, keyID string) (SignerRefSet, error) { if x.corpus != nil { return x.corpus.signerRefs[keyID], nil } it := x.queryPrefixString(keySignerKeyID.name) var err error var refs SignerRefSet defer closeIterator(it, &err) prefix := keySignerKeyID.name + ":" for it.Next()...
go
func (x *Index) signerRefs(ctx context.Context, keyID string) (SignerRefSet, error) { if x.corpus != nil { return x.corpus.signerRefs[keyID], nil } it := x.queryPrefixString(keySignerKeyID.name) var err error var refs SignerRefSet defer closeIterator(it, &err) prefix := keySignerKeyID.name + ":" for it.Next()...
[ "func", "(", "x", "*", "Index", ")", "signerRefs", "(", "ctx", "context", ".", "Context", ",", "keyID", "string", ")", "(", "SignerRefSet", ",", "error", ")", "{", "if", "x", ".", "corpus", "!=", "nil", "{", "return", "x", ".", "corpus", ".", "sign...
// signerRefs returns the set of signer blobRefs matching the signer keyID. It // does not return an error if none is found.
[ "signerRefs", "returns", "the", "set", "of", "signer", "blobRefs", "matching", "the", "signer", "keyID", ".", "It", "does", "not", "return", "an", "error", "if", "none", "is", "found", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/index.go#L986-L1001
train
perkeep/perkeep
pkg/index/index.go
SearchPermanodesWithAttr
func (x *Index) SearchPermanodesWithAttr(ctx context.Context, dest chan<- blob.Ref, request *camtypes.PermanodeByAttrRequest) (err error) { defer close(dest) if request.FuzzyMatch { // TODO(bradfitz): remove this for now? figure out how to handle it generically? return errors.New("TODO: SearchPermanodesWithAttr: ...
go
func (x *Index) SearchPermanodesWithAttr(ctx context.Context, dest chan<- blob.Ref, request *camtypes.PermanodeByAttrRequest) (err error) { defer close(dest) if request.FuzzyMatch { // TODO(bradfitz): remove this for now? figure out how to handle it generically? return errors.New("TODO: SearchPermanodesWithAttr: ...
[ "func", "(", "x", "*", "Index", ")", "SearchPermanodesWithAttr", "(", "ctx", "context", ".", "Context", ",", "dest", "chan", "<-", "blob", ".", "Ref", ",", "request", "*", "camtypes", ".", "PermanodeByAttrRequest", ")", "(", "err", "error", ")", "{", "de...
// SearchPermanodesWithAttr is just like PermanodeOfSignerAttrValue // except we return multiple and dup-suppress. If request.Query is // "", it is not used in the prefix search.
[ "SearchPermanodesWithAttr", "is", "just", "like", "PermanodeOfSignerAttrValue", "except", "we", "return", "multiple", "and", "dup", "-", "suppress", ".", "If", "request", ".", "Query", "is", "it", "is", "not", "used", "in", "the", "prefix", "search", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/index.go#L1025-L1083
train
perkeep/perkeep
pkg/index/index.go
ExistingFileSchemas
func (x *Index) ExistingFileSchemas(wholeRef ...blob.Ref) (WholeRefToFile, error) { schemaRefs := make(WholeRefToFile) for _, v := range wholeRef { newRefs, err := x.existingFileSchemas(v) if err != nil { return nil, err } schemaRefs[v.String()] = newRefs } return schemaRefs, nil }
go
func (x *Index) ExistingFileSchemas(wholeRef ...blob.Ref) (WholeRefToFile, error) { schemaRefs := make(WholeRefToFile) for _, v := range wholeRef { newRefs, err := x.existingFileSchemas(v) if err != nil { return nil, err } schemaRefs[v.String()] = newRefs } return schemaRefs, nil }
[ "func", "(", "x", "*", "Index", ")", "ExistingFileSchemas", "(", "wholeRef", "...", "blob", ".", "Ref", ")", "(", "WholeRefToFile", ",", "error", ")", "{", "schemaRefs", ":=", "make", "(", "WholeRefToFile", ")", "\n", "for", "_", ",", "v", ":=", "range...
// ExistingFileSchemas returns the file schemas for the provided file contents refs.
[ "ExistingFileSchemas", "returns", "the", "file", "schemas", "for", "the", "provided", "file", "contents", "refs", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/index.go#L1341-L1351
train
perkeep/perkeep
pkg/index/index.go
kvImageInfo
func kvImageInfo(v []byte) (ii camtypes.ImageInfo, ok bool) { pipei := bytes.IndexByte(v, '|') if pipei < 0 { return } w, err := strutil.ParseUintBytes(v[:pipei], 10, 16) if err != nil { return } h, err := strutil.ParseUintBytes(v[pipei+1:], 10, 16) if err != nil { return } ii.Width = uint16(w) ii.Heig...
go
func kvImageInfo(v []byte) (ii camtypes.ImageInfo, ok bool) { pipei := bytes.IndexByte(v, '|') if pipei < 0 { return } w, err := strutil.ParseUintBytes(v[:pipei], 10, 16) if err != nil { return } h, err := strutil.ParseUintBytes(v[pipei+1:], 10, 16) if err != nil { return } ii.Width = uint16(w) ii.Heig...
[ "func", "kvImageInfo", "(", "v", "[", "]", "byte", ")", "(", "ii", "camtypes", ".", "ImageInfo", ",", "ok", "bool", ")", "{", "pipei", ":=", "bytes", ".", "IndexByte", "(", "v", ",", "'|'", ")", "\n", "if", "pipei", "<", "0", "{", "return", "\n",...
// v is "width|height"
[ "v", "is", "width|height" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/index.go#L1420-L1436
train
perkeep/perkeep
pkg/index/index.go
GetDirMembers
func (x *Index) GetDirMembers(ctx context.Context, dir blob.Ref, dest chan<- blob.Ref, limit int) (err error) { defer close(dest) sent := 0 if x.corpus != nil { children, err := x.corpus.GetDirChildren(ctx, dir) if err != nil { return err } for child := range children { dest <- child sent++ if s...
go
func (x *Index) GetDirMembers(ctx context.Context, dir blob.Ref, dest chan<- blob.Ref, limit int) (err error) { defer close(dest) sent := 0 if x.corpus != nil { children, err := x.corpus.GetDirChildren(ctx, dir) if err != nil { return err } for child := range children { dest <- child sent++ if s...
[ "func", "(", "x", "*", "Index", ")", "GetDirMembers", "(", "ctx", "context", ".", "Context", ",", "dir", "blob", ".", "Ref", ",", "dest", "chan", "<-", "blob", ".", "Ref", ",", "limit", "int", ")", "(", "err", "error", ")", "{", "defer", "close", ...
// GetDirMembers sends on dest the children of the static directory dir.
[ "GetDirMembers", "sends", "on", "dest", "the", "children", "of", "the", "static", "directory", "dir", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/index.go#L1579-L1617
train
perkeep/perkeep
pkg/index/index.go
Close
func (x *Index) Close() error { if cl, ok := x.s.(io.Closer); ok { return cl.Close() } return nil }
go
func (x *Index) Close() error { if cl, ok := x.s.(io.Closer); ok { return cl.Close() } return nil }
[ "func", "(", "x", "*", "Index", ")", "Close", "(", ")", "error", "{", "if", "cl", ",", "ok", ":=", "x", ".", "s", ".", "(", "io", ".", "Closer", ")", ";", "ok", "{", "return", "cl", ".", "Close", "(", ")", "\n", "}", "\n", "return", "nil", ...
// Close closes the underlying sorted.KeyValue, if the storage has a Close method. // The return value is the return value of the underlying Close, or // nil otherwise.
[ "Close", "closes", "the", "underlying", "sorted", ".", "KeyValue", "if", "the", "storage", "has", "a", "Close", "method", ".", "The", "return", "value", "is", "the", "return", "value", "of", "the", "underlying", "Close", "or", "nil", "otherwise", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/index.go#L1726-L1731
train
perkeep/perkeep
pkg/index/index.go
initNeededMaps
func (x *Index) initNeededMaps() (err error) { x.deletes = newDeletionCache() it := x.queryPrefix(keyMissing) defer closeIterator(it, &err) for it.Next() { key := it.KeyBytes() pair := key[len("missing|"):] pipe := bytes.IndexByte(pair, '|') if pipe < 0 { return fmt.Errorf("Bogus missing key %q", key) ...
go
func (x *Index) initNeededMaps() (err error) { x.deletes = newDeletionCache() it := x.queryPrefix(keyMissing) defer closeIterator(it, &err) for it.Next() { key := it.KeyBytes() pair := key[len("missing|"):] pipe := bytes.IndexByte(pair, '|') if pipe < 0 { return fmt.Errorf("Bogus missing key %q", key) ...
[ "func", "(", "x", "*", "Index", ")", "initNeededMaps", "(", ")", "(", "err", "error", ")", "{", "x", ".", "deletes", "=", "newDeletionCache", "(", ")", "\n", "it", ":=", "x", ".", "queryPrefix", "(", "keyMissing", ")", "\n", "defer", "closeIterator", ...
// initNeededMaps initializes x.needs and x.neededBy on start-up.
[ "initNeededMaps", "initializes", "x", ".", "needs", "and", "x", ".", "neededBy", "on", "start", "-", "up", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/index.go#L1734-L1753
train
perkeep/perkeep
internal/lru/cache.go
NewUnlocked
func NewUnlocked(maxEntries int) *Cache { c := New(maxEntries) c.nolock = true return c }
go
func NewUnlocked(maxEntries int) *Cache { c := New(maxEntries) c.nolock = true return c }
[ "func", "NewUnlocked", "(", "maxEntries", "int", ")", "*", "Cache", "{", "c", ":=", "New", "(", "maxEntries", ")", "\n", "c", ".", "nolock", "=", "true", "\n", "return", "c", "\n", "}" ]
// NewUnlocked is like New but returns a Cache that is not safe // for concurrent access.
[ "NewUnlocked", "is", "like", "New", "but", "returns", "a", "Cache", "that", "is", "not", "safe", "for", "concurrent", "access", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/lru/cache.go#L53-L57
train
perkeep/perkeep
internal/lru/cache.go
RemoveOldest
func (c *Cache) RemoveOldest() (key string, value interface{}) { if !c.nolock { c.mu.Lock() defer c.mu.Unlock() } return c.removeOldest() }
go
func (c *Cache) RemoveOldest() (key string, value interface{}) { if !c.nolock { c.mu.Lock() defer c.mu.Unlock() } return c.removeOldest() }
[ "func", "(", "c", "*", "Cache", ")", "RemoveOldest", "(", ")", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "{", "if", "!", "c", ".", "nolock", "{", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mu", ".",...
// RemoveOldest removes the oldest item in the cache and returns its key and value. // If the cache is empty, the empty string and nil are returned.
[ "RemoveOldest", "removes", "the", "oldest", "item", "in", "the", "cache", "and", "returns", "its", "key", "and", "value", ".", "If", "the", "cache", "is", "empty", "the", "empty", "string", "and", "nil", "are", "returned", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/lru/cache.go#L99-L105
train
perkeep/perkeep
pkg/importer/twitter/twitter.go
importTweets
func (r *run) importTweets(userID string, apiPath string) error { maxId := "" continueRequests := true var tweetsNode *importer.Object var err error var importType string if apiPath == userLikesAPIPath { importType = "likes" } else { importType = "tweets" } tweetsNode, err = r.getTopLevelNode(importType) ...
go
func (r *run) importTweets(userID string, apiPath string) error { maxId := "" continueRequests := true var tweetsNode *importer.Object var err error var importType string if apiPath == userLikesAPIPath { importType = "likes" } else { importType = "tweets" } tweetsNode, err = r.getTopLevelNode(importType) ...
[ "func", "(", "r", "*", "run", ")", "importTweets", "(", "userID", "string", ",", "apiPath", "string", ")", "error", "{", "maxId", ":=", "\"", "\"", "\n", "continueRequests", ":=", "true", "\n\n", "var", "tweetsNode", "*", "importer", ".", "Object", "\n",...
// importTweets imports the tweets related to userID, through apiPath. // If apiPath is userTimeLineAPIPath, the tweets and retweets posted by userID are imported. // If apiPath is userLikesAPIPath, the tweets liked by userID are imported.
[ "importTweets", "imports", "the", "tweets", "related", "to", "userID", "through", "apiPath", ".", "If", "apiPath", "is", "userTimeLineAPIPath", "the", "tweets", "and", "retweets", "posted", "by", "userID", "are", "imported", ".", "If", "apiPath", "is", "userLike...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/twitter/twitter.go#L374-L468
train
perkeep/perkeep
pkg/serverinit/serverinit.go
detectConfigChange
func detectConfigChange(conf jsonconfig.Obj) error { oldHTTPSKey, oldHTTPSCert := conf.OptionalString("HTTPSKeyFile", ""), conf.OptionalString("HTTPSCertFile", "") if oldHTTPSKey != "" || oldHTTPSCert != "" { return fmt.Errorf("config keys %q and %q have respectively been renamed to %q and %q, please fix your serve...
go
func detectConfigChange(conf jsonconfig.Obj) error { oldHTTPSKey, oldHTTPSCert := conf.OptionalString("HTTPSKeyFile", ""), conf.OptionalString("HTTPSCertFile", "") if oldHTTPSKey != "" || oldHTTPSCert != "" { return fmt.Errorf("config keys %q and %q have respectively been renamed to %q and %q, please fix your serve...
[ "func", "detectConfigChange", "(", "conf", "jsonconfig", ".", "Obj", ")", "error", "{", "oldHTTPSKey", ",", "oldHTTPSCert", ":=", "conf", ".", "OptionalString", "(", "\"", "\"", ",", "\"", "\"", ")", ",", "conf", ".", "OptionalString", "(", "\"", "\"", "...
// detectConfigChange returns an informative error if conf contains obsolete keys.
[ "detectConfigChange", "returns", "an", "informative", "error", "if", "conf", "contains", "obsolete", "keys", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/serverinit/serverinit.go#L467-L474
train
perkeep/perkeep
pkg/serverinit/serverinit.go
Load
func Load(config []byte) (*Config, error) { return load("", func(filename string) (jsonconfig.File, error) { if filename != "" { return nil, errors.New("JSON files with includes not supported with jsonconfig.Load") } return jsonFileImpl{bytes.NewReader(config), "config file"}, nil }) }
go
func Load(config []byte) (*Config, error) { return load("", func(filename string) (jsonconfig.File, error) { if filename != "" { return nil, errors.New("JSON files with includes not supported with jsonconfig.Load") } return jsonFileImpl{bytes.NewReader(config), "config file"}, nil }) }
[ "func", "Load", "(", "config", "[", "]", "byte", ")", "(", "*", "Config", ",", "error", ")", "{", "return", "load", "(", "\"", "\"", ",", "func", "(", "filename", "string", ")", "(", "jsonconfig", ".", "File", ",", "error", ")", "{", "if", "filen...
// Load returns a low-level "handler config" from the provided config. // If the config doesn't contain a top-level JSON key of "handlerConfig" // with boolean value true, the configuration is assumed to be a high-level // "user config" file, and transformed into a low-level config.
[ "Load", "returns", "a", "low", "-", "level", "handler", "config", "from", "the", "provided", "config", ".", "If", "the", "config", "doesn", "t", "contain", "a", "top", "-", "level", "JSON", "key", "of", "handlerConfig", "with", "boolean", "value", "true", ...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/serverinit/serverinit.go#L498-L505
train
perkeep/perkeep
pkg/serverinit/serverinit.go
readFields
func (c *Config) readFields() error { c.camliNetIP = c.jconf.OptionalString("camliNetIP", "") c.listenAddr = c.jconf.OptionalString("listen", "") c.baseURL = strings.TrimSuffix(c.jconf.OptionalString("baseURL", ""), "/") c.httpsCert = c.jconf.OptionalString("httpsCert", "") c.httpsKey = c.jconf.OptionalString("htt...
go
func (c *Config) readFields() error { c.camliNetIP = c.jconf.OptionalString("camliNetIP", "") c.listenAddr = c.jconf.OptionalString("listen", "") c.baseURL = strings.TrimSuffix(c.jconf.OptionalString("baseURL", ""), "/") c.httpsCert = c.jconf.OptionalString("httpsCert", "") c.httpsKey = c.jconf.OptionalString("htt...
[ "func", "(", "c", "*", "Config", ")", "readFields", "(", ")", "error", "{", "c", ".", "camliNetIP", "=", "c", ".", "jconf", ".", "OptionalString", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "c", ".", "listenAddr", "=", "c", ".", "jconf", ".", ...
// readFields reads the low-level jsonconfig fields using the jsonconfig package // and copies them into c. This marks them as known fields before a future call to InstallerHandlers
[ "readFields", "reads", "the", "low", "-", "level", "jsonconfig", "fields", "using", "the", "jsonconfig", "package", "and", "copies", "them", "into", "c", ".", "This", "marks", "them", "as", "known", "fields", "before", "a", "future", "call", "to", "Installer...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/serverinit/serverinit.go#L573-L589
train
perkeep/perkeep
pkg/serverinit/serverinit.go
StartApps
func (c *Config) StartApps() error { for _, ap := range c.apps { if err := ap.Start(); err != nil { return fmt.Errorf("error starting app %v: %v", ap.ProgramName(), err) } } return nil }
go
func (c *Config) StartApps() error { for _, ap := range c.apps { if err := ap.Start(); err != nil { return fmt.Errorf("error starting app %v: %v", ap.ProgramName(), err) } } return nil }
[ "func", "(", "c", "*", "Config", ")", "StartApps", "(", ")", "error", "{", "for", "_", ",", "ap", ":=", "range", "c", ".", "apps", "{", "if", "err", ":=", "ap", ".", "Start", "(", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Erro...
// StartApps starts all the server applications that were configured // during InstallHandlers. It should only be called after perkeepd // has started serving, since these apps might request some configuration // from Perkeep to finish initializing.
[ "StartApps", "starts", "all", "the", "server", "applications", "that", "were", "configured", "during", "InstallHandlers", ".", "It", "should", "only", "be", "called", "after", "perkeepd", "has", "started", "serving", "since", "these", "apps", "might", "request", ...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/serverinit/serverinit.go#L773-L780
train
perkeep/perkeep
pkg/serverinit/serverinit.go
UploadPublicKey
func (c *Config) UploadPublicKey(ctx context.Context) error { if c.signHandler == nil { return nil } return c.signHandler.UploadPublicKey(ctx) }
go
func (c *Config) UploadPublicKey(ctx context.Context) error { if c.signHandler == nil { return nil } return c.signHandler.UploadPublicKey(ctx) }
[ "func", "(", "c", "*", "Config", ")", "UploadPublicKey", "(", "ctx", "context", ".", "Context", ")", "error", "{", "if", "c", ".", "signHandler", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "c", ".", "signHandler", ".", "UploadPublicK...
// UploadPublicKey uploads the public key blob with the sign handler that was // configured during InstallHandlers.
[ "UploadPublicKey", "uploads", "the", "public", "key", "blob", "with", "the", "sign", "handler", "that", "was", "configured", "during", "InstallHandlers", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/serverinit/serverinit.go#L784-L789
train
perkeep/perkeep
pkg/serverinit/serverinit.go
AppURL
func (c *Config) AppURL() map[string]string { appURL := make(map[string]string, len(c.apps)) for _, ap := range c.apps { appURL[ap.ProgramName()] = ap.BackendURL() } return appURL }
go
func (c *Config) AppURL() map[string]string { appURL := make(map[string]string, len(c.apps)) for _, ap := range c.apps { appURL[ap.ProgramName()] = ap.BackendURL() } return appURL }
[ "func", "(", "c", "*", "Config", ")", "AppURL", "(", ")", "map", "[", "string", "]", "string", "{", "appURL", ":=", "make", "(", "map", "[", "string", "]", "string", ",", "len", "(", "c", ".", "apps", ")", ")", "\n", "for", "_", ",", "ap", ":...
// AppURL returns a map of app name to app base URL for all the configured // server apps.
[ "AppURL", "returns", "a", "map", "of", "app", "name", "to", "app", "base", "URL", "for", "all", "the", "configured", "server", "apps", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/serverinit/serverinit.go#L793-L799
train
perkeep/perkeep
pkg/serverinit/serverinit.go
highLevelConfFields
func highLevelConfFields() map[string]bool { knownFields := make(map[string]bool) var c serverconfig.Config s := reflect.ValueOf(&c).Elem() for i := 0; i < s.NumField(); i++ { f := s.Type().Field(i) jsonTag, ok := f.Tag.Lookup("json") if !ok { panic(fmt.Sprintf("%q field in serverconfig.Config does not hav...
go
func highLevelConfFields() map[string]bool { knownFields := make(map[string]bool) var c serverconfig.Config s := reflect.ValueOf(&c).Elem() for i := 0; i < s.NumField(); i++ { f := s.Type().Field(i) jsonTag, ok := f.Tag.Lookup("json") if !ok { panic(fmt.Sprintf("%q field in serverconfig.Config does not hav...
[ "func", "highLevelConfFields", "(", ")", "map", "[", "string", "]", "bool", "{", "knownFields", ":=", "make", "(", "map", "[", "string", "]", "bool", ")", "\n", "var", "c", "serverconfig", ".", "Config", "\n", "s", ":=", "reflect", ".", "ValueOf", "(",...
// highLevelConfFields returns all the possible fields of a serverconfig.Config, // in their JSON form. This allows checking that the parameters in the high-level // server configuration file are at least valid names, which is useful to catch // typos.
[ "highLevelConfFields", "returns", "all", "the", "possible", "fields", "of", "a", "serverconfig", ".", "Config", "in", "their", "JSON", "form", ".", "This", "allows", "checking", "that", "the", "parameters", "in", "the", "high", "-", "level", "server", "configu...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/serverinit/serverinit.go#L915-L933
train
perkeep/perkeep
internal/azure/storage/client.go
containerURL
func (c *Client) containerURL(container string) string { return fmt.Sprintf("https://%s/%s/", c.hostname(), container) }
go
func (c *Client) containerURL(container string) string { return fmt.Sprintf("https://%s/%s/", c.hostname(), container) }
[ "func", "(", "c", "*", "Client", ")", "containerURL", "(", "container", "string", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "c", ".", "hostname", "(", ")", ",", "container", ")", "\n", "}" ]
// containerURL returns the URL prefix of the container, with trailing slash
[ "containerURL", "returns", "the", "URL", "prefix", "of", "the", "container", "with", "trailing", "slash" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/azure/storage/client.go#L76-L78
train
perkeep/perkeep
internal/azure/storage/client.go
Containers
func (c *Client) Containers(ctx context.Context) ([]*Container, error) { req := newReq(ctx, "https://"+c.hostname()+"/") c.Auth.SignRequest(req) res, err := c.transport().RoundTrip(req) if err != nil { return nil, err } defer res.Body.Close() if res.StatusCode != http.StatusOK { return nil, fmt.Errorf("azure...
go
func (c *Client) Containers(ctx context.Context) ([]*Container, error) { req := newReq(ctx, "https://"+c.hostname()+"/") c.Auth.SignRequest(req) res, err := c.transport().RoundTrip(req) if err != nil { return nil, err } defer res.Body.Close() if res.StatusCode != http.StatusOK { return nil, fmt.Errorf("azure...
[ "func", "(", "c", "*", "Client", ")", "Containers", "(", "ctx", "context", ".", "Context", ")", "(", "[", "]", "*", "Container", ",", "error", ")", "{", "req", ":=", "newReq", "(", "ctx", ",", "\"", "\"", "+", "c", ".", "hostname", "(", ")", "+...
// Containers list the containers active under the current account.
[ "Containers", "list", "the", "containers", "active", "under", "the", "current", "account", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/azure/storage/client.go#L95-L107
train
perkeep/perkeep
internal/azure/storage/client.go
Stat
func (c *Client) Stat(ctx context.Context, key, container string) (size int64, reterr error) { req := newReq(ctx, c.keyURL(container, key)) req.Method = "HEAD" c.Auth.SignRequest(req) res, err := c.transport().RoundTrip(req) if err != nil { return 0, err } if res.Body != nil { defer res.Body.Close() } swit...
go
func (c *Client) Stat(ctx context.Context, key, container string) (size int64, reterr error) { req := newReq(ctx, c.keyURL(container, key)) req.Method = "HEAD" c.Auth.SignRequest(req) res, err := c.transport().RoundTrip(req) if err != nil { return 0, err } if res.Body != nil { defer res.Body.Close() } swit...
[ "func", "(", "c", "*", "Client", ")", "Stat", "(", "ctx", "context", ".", "Context", ",", "key", ",", "container", "string", ")", "(", "size", "int64", ",", "reterr", "error", ")", "{", "req", ":=", "newReq", "(", "ctx", ",", "c", ".", "keyURL", ...
// Stat Stats a blob in Azure. // It returns 0, os.ErrNotExist if not found on Azure, otherwise reterr is real.
[ "Stat", "Stats", "a", "blob", "in", "Azure", ".", "It", "returns", "0", "os", ".", "ErrNotExist", "if", "not", "found", "on", "Azure", "otherwise", "reterr", "is", "real", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/azure/storage/client.go#L124-L142
train
perkeep/perkeep
internal/azure/storage/client.go
PutObject
func (c *Client) PutObject(ctx context.Context, key, container string, md5 hash.Hash, size int64, body io.Reader) error { req := newReq(ctx, c.keyURL(container, key)) req.Method = "PUT" req.ContentLength = size if md5 != nil { b64 := new(bytes.Buffer) encoder := base64.NewEncoder(base64.StdEncoding, b64) enco...
go
func (c *Client) PutObject(ctx context.Context, key, container string, md5 hash.Hash, size int64, body io.Reader) error { req := newReq(ctx, c.keyURL(container, key)) req.Method = "PUT" req.ContentLength = size if md5 != nil { b64 := new(bytes.Buffer) encoder := base64.NewEncoder(base64.StdEncoding, b64) enco...
[ "func", "(", "c", "*", "Client", ")", "PutObject", "(", "ctx", "context", ".", "Context", ",", "key", ",", "container", "string", ",", "md5", "hash", ".", "Hash", ",", "size", "int64", ",", "body", "io", ".", "Reader", ")", "error", "{", "req", ":=...
// PutObject puts a blob to the specified container on Azure
[ "PutObject", "puts", "a", "blob", "to", "the", "specified", "container", "on", "Azure" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/azure/storage/client.go#L145-L176
train
perkeep/perkeep
internal/azure/storage/client.go
Get
func (c *Client) Get(ctx context.Context, container, key string) (body io.ReadCloser, size int64, err error) { req := newReq(ctx, c.keyURL(container, key)) c.Auth.SignRequest(req) res, err := c.transport().RoundTrip(req) if err != nil { return } switch res.StatusCode { case http.StatusOK: return res.Body, re...
go
func (c *Client) Get(ctx context.Context, container, key string) (body io.ReadCloser, size int64, err error) { req := newReq(ctx, c.keyURL(container, key)) c.Auth.SignRequest(req) res, err := c.transport().RoundTrip(req) if err != nil { return } switch res.StatusCode { case http.StatusOK: return res.Body, re...
[ "func", "(", "c", "*", "Client", ")", "Get", "(", "ctx", "context", ".", "Context", ",", "container", ",", "key", "string", ")", "(", "body", "io", ".", "ReadCloser", ",", "size", "int64", ",", "err", "error", ")", "{", "req", ":=", "newReq", "(", ...
// Get retrieves a blob from Azure or returns os.ErrNotExist if not found
[ "Get", "retrieves", "a", "blob", "from", "Azure", "or", "returns", "os", ".", "ErrNotExist", "if", "not", "found" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/azure/storage/client.go#L274-L291
train
perkeep/perkeep
internal/azure/storage/client.go
GetPartial
func (c *Client) GetPartial(ctx context.Context, container, key string, offset, length int64) (rc io.ReadCloser, err error) { if offset < 0 { return nil, errors.New("invalid negative length") } req := newReq(ctx, c.keyURL(container, key)) if length >= 0 { req.Header.Set("Range", fmt.Sprintf("bytes=%d-%d", offs...
go
func (c *Client) GetPartial(ctx context.Context, container, key string, offset, length int64) (rc io.ReadCloser, err error) { if offset < 0 { return nil, errors.New("invalid negative length") } req := newReq(ctx, c.keyURL(container, key)) if length >= 0 { req.Header.Set("Range", fmt.Sprintf("bytes=%d-%d", offs...
[ "func", "(", "c", "*", "Client", ")", "GetPartial", "(", "ctx", "context", ".", "Context", ",", "container", ",", "key", "string", ",", "offset", ",", "length", "int64", ")", "(", "rc", "io", ".", "ReadCloser", ",", "err", "error", ")", "{", "if", ...
// GetPartial fetches part of the blob in container. // If length is negative, the rest of the object is returned. // The caller must close rc.
[ "GetPartial", "fetches", "part", "of", "the", "blob", "in", "container", ".", "If", "length", "is", "negative", "the", "rest", "of", "the", "object", "is", "returned", ".", "The", "caller", "must", "close", "rc", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/azure/storage/client.go#L296-L323
train
perkeep/perkeep
internal/azure/storage/client.go
Delete
func (c *Client) Delete(ctx context.Context, container, key string) error { req := newReq(ctx, c.keyURL(container, key)) req.Method = "DELETE" c.Auth.SignRequest(req) res, err := c.transport().RoundTrip(req) if err != nil { return err } if res != nil && res.Body != nil { defer res.Body.Close() } if res.Sta...
go
func (c *Client) Delete(ctx context.Context, container, key string) error { req := newReq(ctx, c.keyURL(container, key)) req.Method = "DELETE" c.Auth.SignRequest(req) res, err := c.transport().RoundTrip(req) if err != nil { return err } if res != nil && res.Body != nil { defer res.Body.Close() } if res.Sta...
[ "func", "(", "c", "*", "Client", ")", "Delete", "(", "ctx", "context", ".", "Context", ",", "container", ",", "key", "string", ")", "error", "{", "req", ":=", "newReq", "(", "ctx", ",", "c", ".", "keyURL", "(", "container", ",", "key", ")", ")", ...
// Delete deletes a blob from the specified container. // It may take a few moments before the blob is actually deleted by Azure.
[ "Delete", "deletes", "a", "blob", "from", "the", "specified", "container", ".", "It", "may", "take", "a", "few", "moments", "before", "the", "blob", "is", "actually", "deleted", "by", "Azure", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/azure/storage/client.go#L327-L343
train
perkeep/perkeep
internal/azure/storage/client.go
Error
func (e *Error) Error() string { if e.AzureError.Code != "" { return fmt.Sprintf("azure.%s: status %d, code: %s", e.Op, e.Code, e.AzureError.Code) } return fmt.Sprintf("azure.%s: status %d", e.Op, e.Code) }
go
func (e *Error) Error() string { if e.AzureError.Code != "" { return fmt.Sprintf("azure.%s: status %d, code: %s", e.Op, e.Code, e.AzureError.Code) } return fmt.Sprintf("azure.%s: status %d", e.Op, e.Code) }
[ "func", "(", "e", "*", "Error", ")", "Error", "(", ")", "string", "{", "if", "e", ".", "AzureError", ".", "Code", "!=", "\"", "\"", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "Op", ",", "e", ".", "Code", ",", "e", ...
// Error returns a formatted error message
[ "Error", "returns", "a", "formatted", "error", "message" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/azure/storage/client.go#L391-L396
train
perkeep/perkeep
pkg/fs/fs.go
NewDefaultCamliFileSystem
func NewDefaultCamliFileSystem(client *client.Client, fetcher blob.Fetcher) *CamliFileSystem { if client == nil || fetcher == nil { panic("nil argument") } fs := newCamliFileSystem(fetcher) fs.root = &root{fs: fs} // root.go fs.client = client return fs }
go
func NewDefaultCamliFileSystem(client *client.Client, fetcher blob.Fetcher) *CamliFileSystem { if client == nil || fetcher == nil { panic("nil argument") } fs := newCamliFileSystem(fetcher) fs.root = &root{fs: fs} // root.go fs.client = client return fs }
[ "func", "NewDefaultCamliFileSystem", "(", "client", "*", "client", ".", "Client", ",", "fetcher", "blob", ".", "Fetcher", ")", "*", "CamliFileSystem", "{", "if", "client", "==", "nil", "||", "fetcher", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n...
// NewDefaultCamliFileSystem returns a filesystem with a generic base, from which // users can navigate by blobref, tag, date, etc.
[ "NewDefaultCamliFileSystem", "returns", "a", "filesystem", "with", "a", "generic", "base", "from", "which", "users", "can", "navigate", "by", "blobref", "tag", "date", "etc", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fs/fs.go#L76-L84
train
perkeep/perkeep
pkg/fs/fs.go
NewRootedCamliFileSystem
func NewRootedCamliFileSystem(cli *client.Client, fetcher blob.Fetcher, root blob.Ref) (*CamliFileSystem, error) { fs := newCamliFileSystem(fetcher) fs.client = cli n, err := fs.newNodeFromBlobRef(root) if err != nil { return nil, err } fs.root = n return fs, nil }
go
func NewRootedCamliFileSystem(cli *client.Client, fetcher blob.Fetcher, root blob.Ref) (*CamliFileSystem, error) { fs := newCamliFileSystem(fetcher) fs.client = cli n, err := fs.newNodeFromBlobRef(root) if err != nil { return nil, err } fs.root = n return fs, nil }
[ "func", "NewRootedCamliFileSystem", "(", "cli", "*", "client", ".", "Client", ",", "fetcher", "blob", ".", "Fetcher", ",", "root", "blob", ".", "Ref", ")", "(", "*", "CamliFileSystem", ",", "error", ")", "{", "fs", ":=", "newCamliFileSystem", "(", "fetcher...
// NewRootedCamliFileSystem returns a CamliFileSystem with a node based on a blobref // as its base.
[ "NewRootedCamliFileSystem", "returns", "a", "CamliFileSystem", "with", "a", "node", "based", "on", "a", "blobref", "as", "its", "base", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fs/fs.go#L88-L101
train
perkeep/perkeep
pkg/fs/fs.go
populateAttr
func (n *node) populateAttr() error { meta := n.meta n.attr.Mode = meta.FileMode() if n.fs.IgnoreOwners { n.attr.Uid = uint32(os.Getuid()) n.attr.Gid = uint32(os.Getgid()) executeBit := n.attr.Mode & 0100 n.attr.Mode = (n.attr.Mode ^ n.attr.Mode.Perm()) | 0400 | executeBit } else { n.attr.Uid = uint32(m...
go
func (n *node) populateAttr() error { meta := n.meta n.attr.Mode = meta.FileMode() if n.fs.IgnoreOwners { n.attr.Uid = uint32(os.Getuid()) n.attr.Gid = uint32(os.Getgid()) executeBit := n.attr.Mode & 0100 n.attr.Mode = (n.attr.Mode ^ n.attr.Mode.Perm()) | 0400 | executeBit } else { n.attr.Uid = uint32(m...
[ "func", "(", "n", "*", "node", ")", "populateAttr", "(", ")", "error", "{", "meta", ":=", "n", ".", "meta", "\n\n", "n", ".", "attr", ".", "Mode", "=", "meta", ".", "FileMode", "(", ")", "\n\n", "if", "n", ".", "fs", ".", "IgnoreOwners", "{", "...
// populateAttr should only be called once n.ss is known to be set and // non-nil
[ "populateAttr", "should", "only", "be", "called", "once", "n", ".", "ss", "is", "known", "to", "be", "set", "and", "non", "-", "nil" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fs/fs.go#L283-L319
train
perkeep/perkeep
pkg/fs/fs.go
newNodeFromBlobRef
func (fs *CamliFileSystem) newNodeFromBlobRef(root blob.Ref) (fusefs.Node, error) { blob, err := fs.fetchSchemaMeta(context.TODO(), root) if err != nil { return nil, err } switch blob.Type() { case "directory": n := &node{fs: fs, blobref: root, meta: blob} n.populateAttr() return n, nil case "permanode"...
go
func (fs *CamliFileSystem) newNodeFromBlobRef(root blob.Ref) (fusefs.Node, error) { blob, err := fs.fetchSchemaMeta(context.TODO(), root) if err != nil { return nil, err } switch blob.Type() { case "directory": n := &node{fs: fs, blobref: root, meta: blob} n.populateAttr() return n, nil case "permanode"...
[ "func", "(", "fs", "*", "CamliFileSystem", ")", "newNodeFromBlobRef", "(", "root", "blob", ".", "Ref", ")", "(", "fusefs", ".", "Node", ",", "error", ")", "{", "blob", ",", "err", ":=", "fs", ".", "fetchSchemaMeta", "(", "context", ".", "TODO", "(", ...
// consolated logic for determining a node to mount based on an arbitrary blobref
[ "consolated", "logic", "for", "determining", "a", "node", "to", "mount", "based", "on", "an", "arbitrary", "blobref" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fs/fs.go#L367-L385
train
perkeep/perkeep
dev/devcam/devcam.go
build
func build(targets ...string) error { if v, _ := strconv.ParseBool(os.Getenv("CAMLI_FAST_DEV")); v { // Demo mode. See dev/demo.sh. return nil } var fullTargets []string for _, t := range targets { t = filepath.ToSlash(t) if !strings.HasPrefix(t, "perkeep.org") { t = pathpkg.Join("perkeep.org", t) } ...
go
func build(targets ...string) error { if v, _ := strconv.ParseBool(os.Getenv("CAMLI_FAST_DEV")); v { // Demo mode. See dev/demo.sh. return nil } var fullTargets []string for _, t := range targets { t = filepath.ToSlash(t) if !strings.HasPrefix(t, "perkeep.org") { t = pathpkg.Join("perkeep.org", t) } ...
[ "func", "build", "(", "targets", "...", "string", ")", "error", "{", "if", "v", ",", "_", ":=", "strconv", ".", "ParseBool", "(", "os", ".", "Getenv", "(", "\"", "\"", ")", ")", ";", "v", "{", "// Demo mode. See dev/demo.sh.", "return", "nil", "\n", ...
// build builds the named perkeep targets. // Each target may have its "perkeep.org" prefix removed.
[ "build", "builds", "the", "named", "perkeep", "targets", ".", "Each", "target", "may", "have", "its", "perkeep", ".", "org", "prefix", "removed", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/dev/devcam/devcam.go#L238-L267
train
perkeep/perkeep
pkg/index/location.go
NewLocationHelper
func NewLocationHelper(ix *Index) *LocationHelper { lh := &LocationHelper{index: ix} if ix.corpus != nil { lh.corpus = ix.corpus } return lh }
go
func NewLocationHelper(ix *Index) *LocationHelper { lh := &LocationHelper{index: ix} if ix.corpus != nil { lh.corpus = ix.corpus } return lh }
[ "func", "NewLocationHelper", "(", "ix", "*", "Index", ")", "*", "LocationHelper", "{", "lh", ":=", "&", "LocationHelper", "{", "index", ":", "ix", "}", "\n", "if", "ix", ".", "corpus", "!=", "nil", "{", "lh", ".", "corpus", "=", "ix", ".", "corpus", ...
// NewLocationHelper returns a new location handler // that uses ix to query blob attributes.
[ "NewLocationHelper", "returns", "a", "new", "location", "handler", "that", "uses", "ix", "to", "query", "blob", "attributes", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/location.go#L26-L32
train
perkeep/perkeep
pkg/index/location.go
get
func (pa permAttr) get(attr string) string { if pa.attrs != nil { v := pa.attrs[attr] if len(v) != 0 { return v[0] } return "" } if pa.claims != nil { return claimsIntfAttrValue(pa.claims, attr, pa.at, pa.signerFilter) } return "" }
go
func (pa permAttr) get(attr string) string { if pa.attrs != nil { v := pa.attrs[attr] if len(v) != 0 { return v[0] } return "" } if pa.claims != nil { return claimsIntfAttrValue(pa.claims, attr, pa.at, pa.signerFilter) } return "" }
[ "func", "(", "pa", "permAttr", ")", "get", "(", "attr", "string", ")", "string", "{", "if", "pa", ".", "attrs", "!=", "nil", "{", "v", ":=", "pa", ".", "attrs", "[", "attr", "]", "\n", "if", "len", "(", "v", ")", "!=", "0", "{", "return", "v"...
// get returns the value of attr.
[ "get", "returns", "the", "value", "of", "attr", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/index/location.go#L147-L161
train
perkeep/perkeep
pkg/fileembed/fileembed.go
IsEmpty
func (f *Files) IsEmpty() bool { f.lk.Lock() defer f.lk.Unlock() return len(f.file) == 0 }
go
func (f *Files) IsEmpty() bool { f.lk.Lock() defer f.lk.Unlock() return len(f.file) == 0 }
[ "func", "(", "f", "*", "Files", ")", "IsEmpty", "(", ")", "bool", "{", "f", ".", "lk", ".", "Lock", "(", ")", "\n", "defer", "f", ".", "lk", ".", "Unlock", "(", ")", "\n", "return", "len", "(", "f", ".", "file", ")", "==", "0", "\n", "}" ]
// IsEmpty reports whether f is empty.
[ "IsEmpty", "reports", "whether", "f", "is", "empty", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fileembed/fileembed.go#L121-L125
train
perkeep/perkeep
pkg/fileembed/fileembed.go
Add
func (f *Files) Add(filename string, size int64, modtime time.Time, o Opener) { f.lk.Lock() defer f.lk.Unlock() r, err := o.Open() if err != nil { log.Printf("Could not add file %v: %v", filename, err) return } contents, err := ioutil.ReadAll(r) if err != nil { log.Printf("Could not read contents of file ...
go
func (f *Files) Add(filename string, size int64, modtime time.Time, o Opener) { f.lk.Lock() defer f.lk.Unlock() r, err := o.Open() if err != nil { log.Printf("Could not add file %v: %v", filename, err) return } contents, err := ioutil.ReadAll(r) if err != nil { log.Printf("Could not read contents of file ...
[ "func", "(", "f", "*", "Files", ")", "Add", "(", "filename", "string", ",", "size", "int64", ",", "modtime", "time", ".", "Time", ",", "o", "Opener", ")", "{", "f", ".", "lk", ".", "Lock", "(", ")", "\n", "defer", "f", ".", "lk", ".", "Unlock",...
// Add adds a file to the file set.
[ "Add", "adds", "a", "file", "to", "the", "file", "set", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fileembed/fileembed.go#L128-L148
train
perkeep/perkeep
pkg/fileembed/fileembed.go
add
func (f *Files) add(filename string, sf *staticFile) { if f.file == nil { f.file = make(map[string]*staticFile) } f.file[filename] = sf }
go
func (f *Files) add(filename string, sf *staticFile) { if f.file == nil { f.file = make(map[string]*staticFile) } f.file[filename] = sf }
[ "func", "(", "f", "*", "Files", ")", "add", "(", "filename", "string", ",", "sf", "*", "staticFile", ")", "{", "if", "f", ".", "file", "==", "nil", "{", "f", ".", "file", "=", "make", "(", "map", "[", "string", "]", "*", "staticFile", ")", "\n"...
// f.lk must be locked
[ "f", ".", "lk", "must", "be", "locked" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fileembed/fileembed.go#L151-L156
train
perkeep/perkeep
pkg/fileembed/fileembed.go
openFallback
func (f *Files) openFallback(filename string) (http.File, error) { if f.DirFallback == "" { return nil, os.ErrNotExist } of, err := os.Open(filepath.Join(f.DirFallback, filename)) switch { case err != nil: return nil, err case f.SlurpToMemory: defer of.Close() bs, err := ioutil.ReadAll(of) if err != nil...
go
func (f *Files) openFallback(filename string) (http.File, error) { if f.DirFallback == "" { return nil, os.ErrNotExist } of, err := os.Open(filepath.Join(f.DirFallback, filename)) switch { case err != nil: return nil, err case f.SlurpToMemory: defer of.Close() bs, err := ioutil.ReadAll(of) if err != nil...
[ "func", "(", "f", "*", "Files", ")", "openFallback", "(", "filename", "string", ")", "(", "http", ".", "File", ",", "error", ")", "{", "if", "f", ".", "DirFallback", "==", "\"", "\"", "{", "return", "nil", ",", "os", ".", "ErrNotExist", "\n", "}", ...
// f.lk is held
[ "f", ".", "lk", "is", "held" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fileembed/fileembed.go#L180-L205
train
perkeep/perkeep
website/pk-web/format.go
commentSelection
func commentSelection(src []byte) Selection { var s scanner.Scanner fset := token.NewFileSet() file := fset.AddFile("", fset.Base(), len(src)) s.Init(file, src, nil, scanner.ScanComments) return func() (seg []int) { for { pos, tok, lit := s.Scan() if tok == token.EOF { break } offs := file.Offset...
go
func commentSelection(src []byte) Selection { var s scanner.Scanner fset := token.NewFileSet() file := fset.AddFile("", fset.Base(), len(src)) s.Init(file, src, nil, scanner.ScanComments) return func() (seg []int) { for { pos, tok, lit := s.Scan() if tok == token.EOF { break } offs := file.Offset...
[ "func", "commentSelection", "(", "src", "[", "]", "byte", ")", "Selection", "{", "var", "s", "scanner", ".", "Scanner", "\n", "fset", ":=", "token", ".", "NewFileSet", "(", ")", "\n", "file", ":=", "fset", ".", "AddFile", "(", "\"", "\"", ",", "fset"...
// commentSelection returns the sequence of consecutive comments // in the Go src text as a Selection. //
[ "commentSelection", "returns", "the", "sequence", "of", "consecutive", "comments", "in", "the", "Go", "src", "text", "as", "a", "Selection", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/website/pk-web/format.go#L232-L251
train
perkeep/perkeep
website/pk-web/format.go
makeSelection
func makeSelection(matches [][]int) Selection { return func() (seg []int) { if len(matches) > 0 { seg = matches[0] matches = matches[1:] } return } }
go
func makeSelection(matches [][]int) Selection { return func() (seg []int) { if len(matches) > 0 { seg = matches[0] matches = matches[1:] } return } }
[ "func", "makeSelection", "(", "matches", "[", "]", "[", "]", "int", ")", "Selection", "{", "return", "func", "(", ")", "(", "seg", "[", "]", "int", ")", "{", "if", "len", "(", "matches", ")", ">", "0", "{", "seg", "=", "matches", "[", "0", "]",...
// makeSelection is a helper function to make a Selection from a slice of pairs.
[ "makeSelection", "is", "a", "helper", "function", "to", "make", "a", "Selection", "from", "a", "slice", "of", "pairs", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/website/pk-web/format.go#L254-L262
train
perkeep/perkeep
website/pk-web/format.go
regexpSelection
func regexpSelection(text []byte, expr string) Selection { var matches [][]int if rx, err := regexp.Compile(expr); err == nil { matches = rx.FindAllIndex(text, -1) } return makeSelection(matches) }
go
func regexpSelection(text []byte, expr string) Selection { var matches [][]int if rx, err := regexp.Compile(expr); err == nil { matches = rx.FindAllIndex(text, -1) } return makeSelection(matches) }
[ "func", "regexpSelection", "(", "text", "[", "]", "byte", ",", "expr", "string", ")", "Selection", "{", "var", "matches", "[", "]", "[", "]", "int", "\n", "if", "rx", ",", "err", ":=", "regexp", ".", "Compile", "(", "expr", ")", ";", "err", "==", ...
// regexpSelection computes the Selection for the regular expression expr in text.
[ "regexpSelection", "computes", "the", "Selection", "for", "the", "regular", "expression", "expr", "in", "text", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/website/pk-web/format.go#L265-L271
train
perkeep/perkeep
website/pk-web/format.go
rangeSelection
func rangeSelection(str string) Selection { m := selRx.FindStringSubmatch(str) if len(m) >= 2 { from, _ := strconv.Atoi(m[1]) to, _ := strconv.Atoi(m[2]) if from < to { return makeSelection([][]int{{from, to}}) } } return nil }
go
func rangeSelection(str string) Selection { m := selRx.FindStringSubmatch(str) if len(m) >= 2 { from, _ := strconv.Atoi(m[1]) to, _ := strconv.Atoi(m[2]) if from < to { return makeSelection([][]int{{from, to}}) } } return nil }
[ "func", "rangeSelection", "(", "str", "string", ")", "Selection", "{", "m", ":=", "selRx", ".", "FindStringSubmatch", "(", "str", ")", "\n", "if", "len", "(", "m", ")", ">=", "2", "{", "from", ",", "_", ":=", "strconv", ".", "Atoi", "(", "m", "[", ...
// rangeSelection computes the Selection for a text range described // by the argument str; the range description must match the selRx // regular expression. //
[ "rangeSelection", "computes", "the", "Selection", "for", "a", "text", "range", "described", "by", "the", "argument", "str", ";", "the", "range", "description", "must", "match", "the", "selRx", "regular", "expression", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/website/pk-web/format.go#L279-L289
train
perkeep/perkeep
clients/android/build-in-docker.go
getVersion
func getVersion() string { slurp, err := ioutil.ReadFile(filepath.Join(camliDir, "VERSION")) if err == nil { return strings.TrimSpace(string(slurp)) } return gitVersion() }
go
func getVersion() string { slurp, err := ioutil.ReadFile(filepath.Join(camliDir, "VERSION")) if err == nil { return strings.TrimSpace(string(slurp)) } return gitVersion() }
[ "func", "getVersion", "(", ")", "string", "{", "slurp", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "filepath", ".", "Join", "(", "camliDir", ",", "\"", "\"", ")", ")", "\n", "if", "err", "==", "nil", "{", "return", "strings", ".", "TrimSpace",...
// getVersion returns the version of Perkeep. Either from a VERSION file at the root, // or from git.
[ "getVersion", "returns", "the", "version", "of", "Perkeep", ".", "Either", "from", "a", "VERSION", "file", "at", "the", "root", "or", "from", "git", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/clients/android/build-in-docker.go#L107-L113
train
perkeep/perkeep
clients/android/build-in-docker.go
gitVersion
func gitVersion() string { cmd := exec.Command("git", "rev-list", "--max-count=1", "--pretty=format:'%ad-%h'", "--date=short", "--abbrev=10", "HEAD") cmd.Dir = camliDir out, err := cmd.Output() if err != nil { log.Fatalf("Error running git rev-list in %s: %v", camliDir, err) } v := strings.TrimSpace(string(ou...
go
func gitVersion() string { cmd := exec.Command("git", "rev-list", "--max-count=1", "--pretty=format:'%ad-%h'", "--date=short", "--abbrev=10", "HEAD") cmd.Dir = camliDir out, err := cmd.Output() if err != nil { log.Fatalf("Error running git rev-list in %s: %v", camliDir, err) } v := strings.TrimSpace(string(ou...
[ "func", "gitVersion", "(", ")", "string", "{", "cmd", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "cmd", ".", "Dir", "=", "c...
// gitVersion returns the git version of the git repo at camRoot as a // string of the form "yyyy-mm-dd-xxxxxxx", with an optional trailing // '+' if there are any local uncommitted modifications to the tree.
[ "gitVersion", "returns", "the", "git", "version", "of", "the", "git", "repo", "at", "camRoot", "as", "a", "string", "of", "the", "form", "yyyy", "-", "mm", "-", "dd", "-", "xxxxxxx", "with", "an", "optional", "trailing", "+", "if", "there", "are", "any...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/clients/android/build-in-docker.go#L120-L140
train
perkeep/perkeep
pkg/importer/picasa/picasa.go
findExistingPermanode
func findExistingPermanode(ctx context.Context, qs search.QueryDescriber, wholeRef blob.Ref) (pn blob.Ref, err error) { res, err := qs.Query(ctx, &search.SearchQuery{ Constraint: &search.Constraint{ Permanode: &search.PermanodeConstraint{ Attr: "camliContent", ValueInSet: &search.Constraint{ File: &s...
go
func findExistingPermanode(ctx context.Context, qs search.QueryDescriber, wholeRef blob.Ref) (pn blob.Ref, err error) { res, err := qs.Query(ctx, &search.SearchQuery{ Constraint: &search.Constraint{ Permanode: &search.PermanodeConstraint{ Attr: "camliContent", ValueInSet: &search.Constraint{ File: &s...
[ "func", "findExistingPermanode", "(", "ctx", "context", ".", "Context", ",", "qs", "search", ".", "QueryDescriber", ",", "wholeRef", "blob", ".", "Ref", ")", "(", "pn", "blob", ".", "Ref", ",", "err", "error", ")", "{", "res", ",", "err", ":=", "qs", ...
// findExistingPermanode finds an existing permanode that has a // camliContent pointing to a file with the provided wholeRef and // doesn't have any conflicting attributes that would prevent the // picasa importer from re-using that permanode for its own use.
[ "findExistingPermanode", "finds", "an", "existing", "permanode", "that", "has", "a", "camliContent", "pointing", "to", "a", "file", "with", "the", "provided", "wholeRef", "and", "doesn", "t", "have", "any", "conflicting", "attributes", "that", "would", "prevent", ...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/importer/picasa/picasa.go#L550-L588
train
perkeep/perkeep
server/perkeepd/ui/goui/importshare/importshare.go
Import
func Import(ctx context.Context, config map[string]string, shareURL string, updateDialogFunc func(message string, importedBlobRef string)) { printerr := func(msg string) { showError(msg, func(msg string) { updateDialogFunc(msg, "") }) } if config == nil { printerr("Nil config for Import share") return }...
go
func Import(ctx context.Context, config map[string]string, shareURL string, updateDialogFunc func(message string, importedBlobRef string)) { printerr := func(msg string) { showError(msg, func(msg string) { updateDialogFunc(msg, "") }) } if config == nil { printerr("Nil config for Import share") return }...
[ "func", "Import", "(", "ctx", "context", ".", "Context", ",", "config", "map", "[", "string", "]", "string", ",", "shareURL", "string", ",", "updateDialogFunc", "func", "(", "message", "string", ",", "importedBlobRef", "string", ")", ")", "{", "printerr", ...
// Import sends the shareURL to the server, so it can import all the blobs // transitively reachable through the claim in that share URL. It then regularly // polls the server to get the state of the currently running import process, and // it uses updateDialogFunc to update the web UI with that state. Message is // pr...
[ "Import", "sends", "the", "shareURL", "to", "the", "server", "so", "it", "can", "import", "all", "the", "blobs", "transitively", "reachable", "through", "the", "claim", "in", "that", "share", "URL", ".", "It", "then", "regularly", "polls", "the", "server", ...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/ui/goui/importshare/importshare.go#L45-L107
train
perkeep/perkeep
server/perkeepd/ui/goui/importshare/importshare.go
updateDialog
func updateDialog(progress camtypes.ShareImportProgress, updateDialogFunc func(message string, importedBlobRef string)) { if progress.Running { if progress.Assembled { updateDialogFunc("Importing file in progress", "") return } updateDialogFunc(fmt.Sprintf("Working - %d/%d files imported", progress.FilesC...
go
func updateDialog(progress camtypes.ShareImportProgress, updateDialogFunc func(message string, importedBlobRef string)) { if progress.Running { if progress.Assembled { updateDialogFunc("Importing file in progress", "") return } updateDialogFunc(fmt.Sprintf("Working - %d/%d files imported", progress.FilesC...
[ "func", "updateDialog", "(", "progress", "camtypes", ".", "ShareImportProgress", ",", "updateDialogFunc", "func", "(", "message", "string", ",", "importedBlobRef", "string", ")", ")", "{", "if", "progress", ".", "Running", "{", "if", "progress", ".", "Assembled"...
// updateDialog uses updateDialogFunc to refresh the dialog that displays the // status of the import. Message is printed first in the dialog, and // importBlobRef is only passed when the import is done, to be displayed below as a // link to the newly imported file or directory.
[ "updateDialog", "uses", "updateDialogFunc", "to", "refresh", "the", "dialog", "that", "displays", "the", "status", "of", "the", "import", ".", "Message", "is", "printed", "first", "in", "the", "dialog", "and", "importBlobRef", "is", "only", "passed", "when", "...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/ui/goui/importshare/importshare.go#L113-L129
train
perkeep/perkeep
pkg/webserver/listen/listen.go
NewFlag
func NewFlag(flagName, defaultValue string, serverType string) *Addr { addr := &Addr{ s: defaultValue, } flag.Var(addr, flagName, Usage(serverType)) return addr }
go
func NewFlag(flagName, defaultValue string, serverType string) *Addr { addr := &Addr{ s: defaultValue, } flag.Var(addr, flagName, Usage(serverType)) return addr }
[ "func", "NewFlag", "(", "flagName", ",", "defaultValue", "string", ",", "serverType", "string", ")", "*", "Addr", "{", "addr", ":=", "&", "Addr", "{", "s", ":", "defaultValue", ",", "}", "\n", "flag", ".", "Var", "(", "addr", ",", "flagName", ",", "U...
// NewFlag returns a flag that implements the flag.Value interface.
[ "NewFlag", "returns", "a", "flag", "that", "implements", "the", "flag", ".", "Value", "interface", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/webserver/listen/listen.go#L31-L37
train
perkeep/perkeep
pkg/webserver/listen/listen.go
Usage
func Usage(name string) string { if name == "" { name = "Listen address" } if !strings.HasSuffix(name, " address") { name += " address" } return name + "; may be port, :port, ip:port, or FD:<fd_num>" }
go
func Usage(name string) string { if name == "" { name = "Listen address" } if !strings.HasSuffix(name, " address") { name += " address" } return name + "; may be port, :port, ip:port, or FD:<fd_num>" }
[ "func", "Usage", "(", "name", "string", ")", "string", "{", "if", "name", "==", "\"", "\"", "{", "name", "=", "\"", "\"", "\n", "}", "\n", "if", "!", "strings", ".", "HasSuffix", "(", "name", ",", "\"", "\"", ")", "{", "name", "+=", "\"", "\"",...
// Usage returns a descriptive usage message for a flag given the name // of thing being addressed.
[ "Usage", "returns", "a", "descriptive", "usage", "message", "for", "a", "flag", "given", "the", "name", "of", "thing", "being", "addressed", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/webserver/listen/listen.go#L49-L57
train
perkeep/perkeep
pkg/webserver/listen/listen.go
Listen
func (a *Addr) Listen() (net.Listener, error) { // Start the listener now, if there's a default // and nothing's called Set yet. if a.err == nil && a.ln == nil && a.s != "" { if err := a.Set(a.s); err != nil { return nil, err } } if a.err != nil { return nil, a.err } if a.ln != nil { return a.ln, nil ...
go
func (a *Addr) Listen() (net.Listener, error) { // Start the listener now, if there's a default // and nothing's called Set yet. if a.err == nil && a.ln == nil && a.s != "" { if err := a.Set(a.s); err != nil { return nil, err } } if a.err != nil { return nil, a.err } if a.ln != nil { return a.ln, nil ...
[ "func", "(", "a", "*", "Addr", ")", "Listen", "(", ")", "(", "net", ".", "Listener", ",", "error", ")", "{", "// Start the listener now, if there's a default", "// and nothing's called Set yet.", "if", "a", ".", "err", "==", "nil", "&&", "a", ".", "ln", "=="...
// Listen returns the address's TCP listener.
[ "Listen", "returns", "the", "address", "s", "TCP", "listener", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/webserver/listen/listen.go#L118-L133
train
perkeep/perkeep
pkg/schema/dirreader.go
NewDirReader
func NewDirReader(ctx context.Context, fetcher blob.Fetcher, dirBlobRef blob.Ref) (*DirReader, error) { ss := new(superset) err := ss.setFromBlobRef(ctx, fetcher, dirBlobRef) if err != nil { return nil, err } if ss.Type != "directory" { return nil, fmt.Errorf("schema/dirreader: expected \"directory\" schema bl...
go
func NewDirReader(ctx context.Context, fetcher blob.Fetcher, dirBlobRef blob.Ref) (*DirReader, error) { ss := new(superset) err := ss.setFromBlobRef(ctx, fetcher, dirBlobRef) if err != nil { return nil, err } if ss.Type != "directory" { return nil, fmt.Errorf("schema/dirreader: expected \"directory\" schema bl...
[ "func", "NewDirReader", "(", "ctx", "context", ".", "Context", ",", "fetcher", "blob", ".", "Fetcher", ",", "dirBlobRef", "blob", ".", "Ref", ")", "(", "*", "DirReader", ",", "error", ")", "{", "ss", ":=", "new", "(", "superset", ")", "\n", "err", ":...
// NewDirReader creates a new directory reader and prepares to // fetch the static-set entries
[ "NewDirReader", "creates", "a", "new", "directory", "reader", "and", "prepares", "to", "fetch", "the", "static", "-", "set", "entries" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/schema/dirreader.go#L43-L58
train
perkeep/perkeep
pkg/schema/dirreader.go
StaticSet
func (dr *DirReader) StaticSet(ctx context.Context) ([]blob.Ref, error) { if dr.staticSet != nil { return dr.staticSet, nil } staticSetBlobref := dr.ss.Entries if !staticSetBlobref.Valid() { return nil, errors.New("schema/dirreader: Invalid blobref") } members, err := staticSet(ctx, staticSetBlobref, dr.fetch...
go
func (dr *DirReader) StaticSet(ctx context.Context) ([]blob.Ref, error) { if dr.staticSet != nil { return dr.staticSet, nil } staticSetBlobref := dr.ss.Entries if !staticSetBlobref.Valid() { return nil, errors.New("schema/dirreader: Invalid blobref") } members, err := staticSet(ctx, staticSetBlobref, dr.fetch...
[ "func", "(", "dr", "*", "DirReader", ")", "StaticSet", "(", "ctx", "context", ".", "Context", ")", "(", "[", "]", "blob", ".", "Ref", ",", "error", ")", "{", "if", "dr", ".", "staticSet", "!=", "nil", "{", "return", "dr", ".", "staticSet", ",", "...
// StaticSet returns the whole of the static set members of that directory
[ "StaticSet", "returns", "the", "whole", "of", "the", "static", "set", "members", "of", "that", "directory" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/schema/dirreader.go#L88-L102
train
perkeep/perkeep
pkg/schema/dirreader.go
Readdir
func (dr *DirReader) Readdir(ctx context.Context, n int) (entries []DirectoryEntry, err error) { sts, err := dr.StaticSet(ctx) if err != nil { return nil, fmt.Errorf("schema/dirreader: can't get StaticSet: %v", err) } up := dr.current + n if n <= 0 { dr.current = 0 up = len(sts) } else { if n > (len(sts) ...
go
func (dr *DirReader) Readdir(ctx context.Context, n int) (entries []DirectoryEntry, err error) { sts, err := dr.StaticSet(ctx) if err != nil { return nil, fmt.Errorf("schema/dirreader: can't get StaticSet: %v", err) } up := dr.current + n if n <= 0 { dr.current = 0 up = len(sts) } else { if n > (len(sts) ...
[ "func", "(", "dr", "*", "DirReader", ")", "Readdir", "(", "ctx", "context", ".", "Context", ",", "n", "int", ")", "(", "entries", "[", "]", "DirectoryEntry", ",", "err", "error", ")", "{", "sts", ",", "err", ":=", "dr", ".", "StaticSet", "(", "ctx"...
// Readdir implements the Directory interface.
[ "Readdir", "implements", "the", "Directory", "interface", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/schema/dirreader.go#L146-L197
train
perkeep/perkeep
server/perkeepd/ui/goui/selectallbutton/gen_SelectAllBtn_reactGen.go
Props
func (s SelectAllBtnDef) Props() SelectAllBtnProps { uprops := s.ComponentDef.Props() return uprops.(SelectAllBtnProps) }
go
func (s SelectAllBtnDef) Props() SelectAllBtnProps { uprops := s.ComponentDef.Props() return uprops.(SelectAllBtnProps) }
[ "func", "(", "s", "SelectAllBtnDef", ")", "Props", "(", ")", "SelectAllBtnProps", "{", "uprops", ":=", "s", ".", "ComponentDef", ".", "Props", "(", ")", "\n", "return", "uprops", ".", "(", "SelectAllBtnProps", ")", "\n", "}" ]
// Props is an auto-generated proxy to the current props of SelectAllBtn
[ "Props", "is", "an", "auto", "-", "generated", "proxy", "to", "the", "current", "props", "of", "SelectAllBtn" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/ui/goui/selectallbutton/gen_SelectAllBtn_reactGen.go#L30-L33
train
perkeep/perkeep
pkg/blobserver/dir/dir.go
New
func New(dir string) (blobserver.Storage, error) { if v, err := diskpacked.IsDir(dir); err != nil { return nil, err } else if v { return diskpacked.New(dir) } if v, err := localdisk.IsDir(dir); err != nil { return nil, err } else if v { return localdisk.New(dir) } return diskpacked.New(dir) }
go
func New(dir string) (blobserver.Storage, error) { if v, err := diskpacked.IsDir(dir); err != nil { return nil, err } else if v { return diskpacked.New(dir) } if v, err := localdisk.IsDir(dir); err != nil { return nil, err } else if v { return localdisk.New(dir) } return diskpacked.New(dir) }
[ "func", "New", "(", "dir", "string", ")", "(", "blobserver", ".", "Storage", ",", "error", ")", "{", "if", "v", ",", "err", ":=", "diskpacked", ".", "IsDir", "(", "dir", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", ...
// New returns a new blobserver Storage implementation, storing blobs in the provided dir. // If dir has an index.kv file, a diskpacked implementation is returned.
[ "New", "returns", "a", "new", "blobserver", "Storage", "implementation", "storing", "blobs", "in", "the", "provided", "dir", ".", "If", "dir", "has", "an", "index", ".", "kv", "file", "a", "diskpacked", "implementation", "is", "returned", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/dir/dir.go#L30-L42
train
perkeep/perkeep
pkg/blobserver/localdisk/localdisk.go
New
func New(root string) (*DiskStorage, error) { // Local disk. fi, err := os.Stat(root) if os.IsNotExist(err) { // As a special case, we auto-created the "packed" directory for subpacked. if filepath.Base(root) == "packed" { if err := os.Mkdir(root, 0700); err != nil { return nil, fmt.Errorf("failed to mkdi...
go
func New(root string) (*DiskStorage, error) { // Local disk. fi, err := os.Stat(root) if os.IsNotExist(err) { // As a special case, we auto-created the "packed" directory for subpacked. if filepath.Base(root) == "packed" { if err := os.Mkdir(root, 0700); err != nil { return nil, fmt.Errorf("failed to mkdi...
[ "func", "New", "(", "root", "string", ")", "(", "*", "DiskStorage", ",", "error", ")", "{", "// Local disk.", "fi", ",", "err", ":=", "os", ".", "Stat", "(", "root", ")", "\n", "if", "os", ".", "IsNotExist", "(", "err", ")", "{", "// As a special cas...
// New returns a new local disk storage implementation at the provided // root directory, which must already exist.
[ "New", "returns", "a", "new", "local", "disk", "storage", "implementation", "at", "the", "provided", "root", "directory", "which", "must", "already", "exist", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/localdisk/localdisk.go#L96-L146
train
perkeep/perkeep
app/scanningcabinet/models.go
MakeMediaObjectViewModels
func MakeMediaObjectViewModels(mediaObjects []mediaObject) []MediaObjectVM { models := make([]MediaObjectVM, len(mediaObjects)) for i := 0; i < len(mediaObjects); i++ { models[i] = mediaObjects[i].MakeViewModel() } return models }
go
func MakeMediaObjectViewModels(mediaObjects []mediaObject) []MediaObjectVM { models := make([]MediaObjectVM, len(mediaObjects)) for i := 0; i < len(mediaObjects); i++ { models[i] = mediaObjects[i].MakeViewModel() } return models }
[ "func", "MakeMediaObjectViewModels", "(", "mediaObjects", "[", "]", "mediaObject", ")", "[", "]", "MediaObjectVM", "{", "models", ":=", "make", "(", "[", "]", "MediaObjectVM", ",", "len", "(", "mediaObjects", ")", ")", "\n", "for", "i", ":=", "0", ";", "...
// MakeMediaObjectViewModels takes a slice of MediaObjects and returns a slice of // the same number of MediaObjectVMs with the data converted.
[ "MakeMediaObjectViewModels", "takes", "a", "slice", "of", "MediaObjects", "and", "returns", "a", "slice", "of", "the", "same", "number", "of", "MediaObjectVMs", "with", "the", "data", "converted", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/scanningcabinet/models.go#L93-L99
train
perkeep/perkeep
app/scanningcabinet/models.go
someTitle
func (doc *document) someTitle() string { if doc.title != "" { return doc.title } if doc.tags.isEmpty() { return fmt.Sprintf("Doc Ref %s", doc.permanode) } return strings.Join(doc.tags, ",") }
go
func (doc *document) someTitle() string { if doc.title != "" { return doc.title } if doc.tags.isEmpty() { return fmt.Sprintf("Doc Ref %s", doc.permanode) } return strings.Join(doc.tags, ",") }
[ "func", "(", "doc", "*", "document", ")", "someTitle", "(", ")", "string", "{", "if", "doc", ".", "title", "!=", "\"", "\"", "{", "return", "doc", ".", "title", "\n", "}", "\n", "if", "doc", ".", "tags", ".", "isEmpty", "(", ")", "{", "return", ...
// SomeTitle returns this struct's title or, failing that, its tags - // and even failing that, its IntID
[ "SomeTitle", "returns", "this", "struct", "s", "title", "or", "failing", "that", "its", "tags", "-", "and", "even", "failing", "that", "its", "IntID" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/scanningcabinet/models.go#L154-L162
train
perkeep/perkeep
app/scanningcabinet/models.go
formatYyyyMmDd
func formatYyyyMmDd(indate time.Time) string { if indate.IsZero() { return "" } return indate.Format(dateformatYyyyMmDd) }
go
func formatYyyyMmDd(indate time.Time) string { if indate.IsZero() { return "" } return indate.Format(dateformatYyyyMmDd) }
[ "func", "formatYyyyMmDd", "(", "indate", "time", ".", "Time", ")", "string", "{", "if", "indate", ".", "IsZero", "(", ")", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "indate", ".", "Format", "(", "dateformatYyyyMmDd", ")", "\n", "}" ]
// formatYyyyMmDd is a convenience function that formats a given Time according to // the DateformatYyyyMmDd const
[ "formatYyyyMmDd", "is", "a", "convenience", "function", "that", "formats", "a", "given", "Time", "according", "to", "the", "DateformatYyyyMmDd", "const" ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/scanningcabinet/models.go#L176-L181
train
perkeep/perkeep
app/scanningcabinet/models.go
MakeDocumentViewModels
func MakeDocumentViewModels(docs []*document) []DocumentVM { models := make([]DocumentVM, len(docs)) for i := 0; i < len(docs); i++ { models[i] = docs[i].MakeViewModel() } return models }
go
func MakeDocumentViewModels(docs []*document) []DocumentVM { models := make([]DocumentVM, len(docs)) for i := 0; i < len(docs); i++ { models[i] = docs[i].MakeViewModel() } return models }
[ "func", "MakeDocumentViewModels", "(", "docs", "[", "]", "*", "document", ")", "[", "]", "DocumentVM", "{", "models", ":=", "make", "(", "[", "]", "DocumentVM", ",", "len", "(", "docs", ")", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", ...
// MakeDocumentViewModels takes a slice of Documents and returns a slice of // the same number of DocumentVMs with the data converted.
[ "MakeDocumentViewModels", "takes", "a", "slice", "of", "Documents", "and", "returns", "a", "slice", "of", "the", "same", "number", "of", "DocumentVMs", "with", "the", "data", "converted", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/app/scanningcabinet/models.go#L211-L217
train
perkeep/perkeep
pkg/blobserver/gethandler/get.go
ServeBlobRef
func ServeBlobRef(rw http.ResponseWriter, req *http.Request, blobRef blob.Ref, fetcher blob.Fetcher) { ctx := req.Context() if fetcher == nil { log.Printf("gethandler: no fetcher configured for %s (ref=%v)", req.URL.Path, blobRef) rw.WriteHeader(http.StatusNotFound) io.WriteString(rw, "no fetcher configured") ...
go
func ServeBlobRef(rw http.ResponseWriter, req *http.Request, blobRef blob.Ref, fetcher blob.Fetcher) { ctx := req.Context() if fetcher == nil { log.Printf("gethandler: no fetcher configured for %s (ref=%v)", req.URL.Path, blobRef) rw.WriteHeader(http.StatusNotFound) io.WriteString(rw, "no fetcher configured") ...
[ "func", "ServeBlobRef", "(", "rw", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ",", "blobRef", "blob", ".", "Ref", ",", "fetcher", "blob", ".", "Fetcher", ")", "{", "ctx", ":=", "req", ".", "Context", "(", ")", "\n", "if",...
// ServeBlobRef serves a blob.
[ "ServeBlobRef", "serves", "a", "blob", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/gethandler/get.go#L65-L121
train
perkeep/perkeep
pkg/blobserver/gethandler/get.go
simulatePrematurelyClosedConnection
func simulatePrematurelyClosedConnection(rw http.ResponseWriter, req *http.Request) { flusher, ok := rw.(http.Flusher) if !ok { return } hj, ok := rw.(http.Hijacker) if !ok { return } for n := 1; n <= 100; n++ { fmt.Fprintf(rw, "line %d\n", n) flusher.Flush() } wrc, _, _ := hj.Hijack() wrc.Close() // ...
go
func simulatePrematurelyClosedConnection(rw http.ResponseWriter, req *http.Request) { flusher, ok := rw.(http.Flusher) if !ok { return } hj, ok := rw.(http.Hijacker) if !ok { return } for n := 1; n <= 100; n++ { fmt.Fprintf(rw, "line %d\n", n) flusher.Flush() } wrc, _, _ := hj.Hijack() wrc.Close() // ...
[ "func", "simulatePrematurelyClosedConnection", "(", "rw", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "flusher", ",", "ok", ":=", "rw", ".", "(", "http", ".", "Flusher", ")", "\n", "if", "!", "ok", "{", "return", "...
// For client testing.
[ "For", "client", "testing", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/gethandler/get.go#L138-L153
train
perkeep/perkeep
pkg/fileembed/genfileembed/genfileembed.go
matchingFiles
func matchingFiles(p *regexp.Regexp) []string { var f []string err := filepath.Walk(".", func(path string, fi os.FileInfo, err error) error { if err != nil { return err } n := filepath.Base(path) if !fi.IsDir() && !strings.HasPrefix(n, "zembed_") && p.MatchString(n) { f = append(f, path) } return ni...
go
func matchingFiles(p *regexp.Regexp) []string { var f []string err := filepath.Walk(".", func(path string, fi os.FileInfo, err error) error { if err != nil { return err } n := filepath.Base(path) if !fi.IsDir() && !strings.HasPrefix(n, "zembed_") && p.MatchString(n) { f = append(f, path) } return ni...
[ "func", "matchingFiles", "(", "p", "*", "regexp", ".", "Regexp", ")", "[", "]", "string", "{", "var", "f", "[", "]", "string", "\n", "err", ":=", "filepath", ".", "Walk", "(", "\"", "\"", ",", "func", "(", "path", "string", ",", "fi", "os", ".", ...
// matchingFiles finds all files matching a regex that should be embedded. This // skips files prefixed with "zembed_", since those are an implementation // detail of the embedding process itself.
[ "matchingFiles", "finds", "all", "files", "matching", "a", "regex", "that", "should", "be", "embedded", ".", "This", "skips", "files", "prefixed", "with", "zembed_", "since", "those", "are", "an", "implementation", "detail", "of", "the", "embedding", "process", ...
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/fileembed/genfileembed/genfileembed.go#L265-L282
train
perkeep/perkeep
pkg/jsonsign/signhandler/sig.go
UploadPublicKey
func (h *Handler) UploadPublicKey(ctx context.Context) error { h.pubKeyUploadMu.RLock() if h.pubKeyUploaded { h.pubKeyUploadMu.RUnlock() return nil } h.pubKeyUploadMu.RUnlock() sto := h.pubKeyDest h.pubKeyUploadMu.Lock() defer h.pubKeyUploadMu.Unlock() if h.pubKeyUploaded { return nil } _, err := blob...
go
func (h *Handler) UploadPublicKey(ctx context.Context) error { h.pubKeyUploadMu.RLock() if h.pubKeyUploaded { h.pubKeyUploadMu.RUnlock() return nil } h.pubKeyUploadMu.RUnlock() sto := h.pubKeyDest h.pubKeyUploadMu.Lock() defer h.pubKeyUploadMu.Unlock() if h.pubKeyUploaded { return nil } _, err := blob...
[ "func", "(", "h", "*", "Handler", ")", "UploadPublicKey", "(", "ctx", "context", ".", "Context", ")", "error", "{", "h", ".", "pubKeyUploadMu", ".", "RLock", "(", ")", "\n", "if", "h", ".", "pubKeyUploaded", "{", "h", ".", "pubKeyUploadMu", ".", "RUnlo...
// UploadPublicKey writes the public key to the destination blobserver // defined for the handler, if needed.
[ "UploadPublicKey", "writes", "the", "public", "key", "to", "the", "destination", "blobserver", "defined", "for", "the", "handler", "if", "needed", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/jsonsign/signhandler/sig.go#L136-L159
train
perkeep/perkeep
pkg/jsonsign/signhandler/sig.go
Discovery
func (h *Handler) Discovery(base string) *camtypes.SignDiscovery { sd := &camtypes.SignDiscovery{ PublicKeyID: h.entity.PrimaryKey.KeyIdString(), SignHandler: base + "camli/sig/sign", VerifyHandler: base + "camli/sig/verify", } if h.pubKeyBlobRef.Valid() { sd.PublicKeyBlobRef = h.pubKeyBlobRef sd.Publi...
go
func (h *Handler) Discovery(base string) *camtypes.SignDiscovery { sd := &camtypes.SignDiscovery{ PublicKeyID: h.entity.PrimaryKey.KeyIdString(), SignHandler: base + "camli/sig/sign", VerifyHandler: base + "camli/sig/verify", } if h.pubKeyBlobRef.Valid() { sd.PublicKeyBlobRef = h.pubKeyBlobRef sd.Publi...
[ "func", "(", "h", "*", "Handler", ")", "Discovery", "(", "base", "string", ")", "*", "camtypes", ".", "SignDiscovery", "{", "sd", ":=", "&", "camtypes", ".", "SignDiscovery", "{", "PublicKeyID", ":", "h", ".", "entity", ".", "PrimaryKey", ".", "KeyIdStri...
// Discovery returns the Discovery response for the signing handler.
[ "Discovery", "returns", "the", "Discovery", "response", "for", "the", "signing", "handler", "." ]
e28bbbd1588d64df8ab7a82393afd39d64c061f7
https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/jsonsign/signhandler/sig.go#L162-L173
train
jwilder/docker-gen
template.go
generalizedGroupBy
func generalizedGroupBy(funcName string, entries interface{}, getValue func(interface{}) (interface{}, error), addEntry func(map[string][]interface{}, interface{}, interface{})) (map[string][]interface{}, error) { entriesVal, err := getArrayValues(funcName, entries) if err != nil { return nil, err } groups := m...
go
func generalizedGroupBy(funcName string, entries interface{}, getValue func(interface{}) (interface{}, error), addEntry func(map[string][]interface{}, interface{}, interface{})) (map[string][]interface{}, error) { entriesVal, err := getArrayValues(funcName, entries) if err != nil { return nil, err } groups := m...
[ "func", "generalizedGroupBy", "(", "funcName", "string", ",", "entries", "interface", "{", "}", ",", "getValue", "func", "(", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", ",", "addEntry", "func", "(", "map", "[", "string", ...
// Generalized groupBy function
[ "Generalized", "groupBy", "function" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L54-L73
train
jwilder/docker-gen
template.go
groupBy
func groupBy(entries interface{}, key string) (map[string][]interface{}, error) { return generalizedGroupByKey("groupBy", entries, key, func(groups map[string][]interface{}, value interface{}, v interface{}) { groups[value.(string)] = append(groups[value.(string)], v) }) }
go
func groupBy(entries interface{}, key string) (map[string][]interface{}, error) { return generalizedGroupByKey("groupBy", entries, key, func(groups map[string][]interface{}, value interface{}, v interface{}) { groups[value.(string)] = append(groups[value.(string)], v) }) }
[ "func", "groupBy", "(", "entries", "interface", "{", "}", ",", "key", "string", ")", "(", "map", "[", "string", "]", "[", "]", "interface", "{", "}", ",", "error", ")", "{", "return", "generalizedGroupByKey", "(", "\"", "\"", ",", "entries", ",", "ke...
// groupBy groups a generic array or slice by the path property key
[ "groupBy", "groups", "a", "generic", "array", "or", "slice", "by", "the", "path", "property", "key" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L92-L96
train
jwilder/docker-gen
template.go
groupByKeys
func groupByKeys(entries interface{}, key string) ([]string, error) { keys, err := generalizedGroupByKey("groupByKeys", entries, key, func(groups map[string][]interface{}, value interface{}, v interface{}) { groups[value.(string)] = append(groups[value.(string)], v) }) if err != nil { return nil, err } ret :...
go
func groupByKeys(entries interface{}, key string) ([]string, error) { keys, err := generalizedGroupByKey("groupByKeys", entries, key, func(groups map[string][]interface{}, value interface{}, v interface{}) { groups[value.(string)] = append(groups[value.(string)], v) }) if err != nil { return nil, err } ret :...
[ "func", "groupByKeys", "(", "entries", "interface", "{", "}", ",", "key", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "keys", ",", "err", ":=", "generalizedGroupByKey", "(", "\"", "\"", ",", "entries", ",", "key", ",", "func", "("...
// groupByKeys is the same as groupBy but only returns a list of keys
[ "groupByKeys", "is", "the", "same", "as", "groupBy", "but", "only", "returns", "a", "list", "of", "keys" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L99-L113
train
jwilder/docker-gen
template.go
groupByLabel
func groupByLabel(entries interface{}, label string) (map[string][]interface{}, error) { getLabel := func(v interface{}) (interface{}, error) { if container, ok := v.(RuntimeContainer); ok { if value, ok := container.Labels[label]; ok { return value, nil } return nil, nil } return nil, fmt.Errorf("M...
go
func groupByLabel(entries interface{}, label string) (map[string][]interface{}, error) { getLabel := func(v interface{}) (interface{}, error) { if container, ok := v.(RuntimeContainer); ok { if value, ok := container.Labels[label]; ok { return value, nil } return nil, nil } return nil, fmt.Errorf("M...
[ "func", "groupByLabel", "(", "entries", "interface", "{", "}", ",", "label", "string", ")", "(", "map", "[", "string", "]", "[", "]", "interface", "{", "}", ",", "error", ")", "{", "getLabel", ":=", "func", "(", "v", "interface", "{", "}", ")", "("...
// groupByLabel is the same as groupBy but over a given label
[ "groupByLabel", "is", "the", "same", "as", "groupBy", "but", "over", "a", "given", "label" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L116-L129
train
jwilder/docker-gen
template.go
generalizedWhere
func generalizedWhere(funcName string, entries interface{}, key string, test func(interface{}) bool) (interface{}, error) { entriesVal, err := getArrayValues(funcName, entries) if err != nil { return nil, err } selection := make([]interface{}, 0) for i := 0; i < entriesVal.Len(); i++ { v := reflect.Indirect(...
go
func generalizedWhere(funcName string, entries interface{}, key string, test func(interface{}) bool) (interface{}, error) { entriesVal, err := getArrayValues(funcName, entries) if err != nil { return nil, err } selection := make([]interface{}, 0) for i := 0; i < entriesVal.Len(); i++ { v := reflect.Indirect(...
[ "func", "generalizedWhere", "(", "funcName", "string", ",", "entries", "interface", "{", "}", ",", "key", "string", ",", "test", "func", "(", "interface", "{", "}", ")", "bool", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "entriesVal", ","...
// Generalized where function
[ "Generalized", "where", "function" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L132-L150
train
jwilder/docker-gen
template.go
where
func where(entries interface{}, key string, cmp interface{}) (interface{}, error) { return generalizedWhere("where", entries, key, func(value interface{}) bool { return reflect.DeepEqual(value, cmp) }) }
go
func where(entries interface{}, key string, cmp interface{}) (interface{}, error) { return generalizedWhere("where", entries, key, func(value interface{}) bool { return reflect.DeepEqual(value, cmp) }) }
[ "func", "where", "(", "entries", "interface", "{", "}", ",", "key", "string", ",", "cmp", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "generalizedWhere", "(", "\"", "\"", ",", "entries", ",", "key", ",", ...
// selects entries based on key
[ "selects", "entries", "based", "on", "key" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L153-L157
train
jwilder/docker-gen
template.go
whereExist
func whereExist(entries interface{}, key string) (interface{}, error) { return generalizedWhere("whereExist", entries, key, func(value interface{}) bool { return value != nil }) }
go
func whereExist(entries interface{}, key string) (interface{}, error) { return generalizedWhere("whereExist", entries, key, func(value interface{}) bool { return value != nil }) }
[ "func", "whereExist", "(", "entries", "interface", "{", "}", ",", "key", "string", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "generalizedWhere", "(", "\"", "\"", ",", "entries", ",", "key", ",", "func", "(", "value", "interface...
// selects entries where a key exists
[ "selects", "entries", "where", "a", "key", "exists" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L167-L171
train
jwilder/docker-gen
template.go
whereAny
func whereAny(entries interface{}, key, sep string, cmp []string) (interface{}, error) { return generalizedWhere("whereAny", entries, key, func(value interface{}) bool { if value == nil { return false } else { items := strings.Split(value.(string), sep) return len(intersect(cmp, items)) > 0 } }) }
go
func whereAny(entries interface{}, key, sep string, cmp []string) (interface{}, error) { return generalizedWhere("whereAny", entries, key, func(value interface{}) bool { if value == nil { return false } else { items := strings.Split(value.(string), sep) return len(intersect(cmp, items)) > 0 } }) }
[ "func", "whereAny", "(", "entries", "interface", "{", "}", ",", "key", ",", "sep", "string", ",", "cmp", "[", "]", "string", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "generalizedWhere", "(", "\"", "\"", ",", "entries", ",", ...
// selects entries based on key. Assumes key is delimited and breaks it apart before comparing
[ "selects", "entries", "based", "on", "key", ".", "Assumes", "key", "is", "delimited", "and", "breaks", "it", "apart", "before", "comparing" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L181-L190
train
jwilder/docker-gen
template.go
generalizedWhereLabel
func generalizedWhereLabel(funcName string, containers Context, label string, test func(string, bool) bool) (Context, error) { selection := make([]*RuntimeContainer, 0) for i := 0; i < len(containers); i++ { container := containers[i] value, ok := container.Labels[label] if test(value, ok) { selection = ap...
go
func generalizedWhereLabel(funcName string, containers Context, label string, test func(string, bool) bool) (Context, error) { selection := make([]*RuntimeContainer, 0) for i := 0; i < len(containers); i++ { container := containers[i] value, ok := container.Labels[label] if test(value, ok) { selection = ap...
[ "func", "generalizedWhereLabel", "(", "funcName", "string", ",", "containers", "Context", ",", "label", "string", ",", "test", "func", "(", "string", ",", "bool", ")", "bool", ")", "(", "Context", ",", "error", ")", "{", "selection", ":=", "make", "(", "...
// generalized whereLabel function
[ "generalized", "whereLabel", "function" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L206-L219
train
jwilder/docker-gen
template.go
whereLabelExists
func whereLabelExists(containers Context, label string) (Context, error) { return generalizedWhereLabel("whereLabelExists", containers, label, func(_ string, ok bool) bool { return ok }) }
go
func whereLabelExists(containers Context, label string) (Context, error) { return generalizedWhereLabel("whereLabelExists", containers, label, func(_ string, ok bool) bool { return ok }) }
[ "func", "whereLabelExists", "(", "containers", "Context", ",", "label", "string", ")", "(", "Context", ",", "error", ")", "{", "return", "generalizedWhereLabel", "(", "\"", "\"", ",", "containers", ",", "label", ",", "func", "(", "_", "string", ",", "ok", ...
// selects containers that have a particular label
[ "selects", "containers", "that", "have", "a", "particular", "label" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L222-L226
train
jwilder/docker-gen
template.go
whereLabelValueMatches
func whereLabelValueMatches(containers Context, label, pattern string) (Context, error) { rx, err := regexp.Compile(pattern) if err != nil { return nil, err } return generalizedWhereLabel("whereLabelValueMatches", containers, label, func(value string, ok bool) bool { return ok && rx.MatchString(value) }) }
go
func whereLabelValueMatches(containers Context, label, pattern string) (Context, error) { rx, err := regexp.Compile(pattern) if err != nil { return nil, err } return generalizedWhereLabel("whereLabelValueMatches", containers, label, func(value string, ok bool) bool { return ok && rx.MatchString(value) }) }
[ "func", "whereLabelValueMatches", "(", "containers", "Context", ",", "label", ",", "pattern", "string", ")", "(", "Context", ",", "error", ")", "{", "rx", ",", "err", ":=", "regexp", ".", "Compile", "(", "pattern", ")", "\n", "if", "err", "!=", "nil", ...
// selects containers with a particular label whose value matches a regular expression
[ "selects", "containers", "with", "a", "particular", "label", "whose", "value", "matches", "a", "regular", "expression" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L236-L245
train
jwilder/docker-gen
template.go
arrayFirst
func arrayFirst(input interface{}) interface{} { if input == nil { return nil } arr := reflect.ValueOf(input) if arr.Len() == 0 { return nil } return arr.Index(0).Interface() }
go
func arrayFirst(input interface{}) interface{} { if input == nil { return nil } arr := reflect.ValueOf(input) if arr.Len() == 0 { return nil } return arr.Index(0).Interface() }
[ "func", "arrayFirst", "(", "input", "interface", "{", "}", ")", "interface", "{", "}", "{", "if", "input", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "arr", ":=", "reflect", ".", "ValueOf", "(", "input", ")", "\n\n", "if", "arr", ".", "L...
// arrayFirst returns first item in the array or nil if the // input is nil or empty
[ "arrayFirst", "returns", "first", "item", "in", "the", "array", "or", "nil", "if", "the", "input", "is", "nil", "or", "empty" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L341-L353
train
jwilder/docker-gen
template.go
arrayLast
func arrayLast(input interface{}) interface{} { arr := reflect.ValueOf(input) return arr.Index(arr.Len() - 1).Interface() }
go
func arrayLast(input interface{}) interface{} { arr := reflect.ValueOf(input) return arr.Index(arr.Len() - 1).Interface() }
[ "func", "arrayLast", "(", "input", "interface", "{", "}", ")", "interface", "{", "}", "{", "arr", ":=", "reflect", ".", "ValueOf", "(", "input", ")", "\n", "return", "arr", ".", "Index", "(", "arr", ".", "Len", "(", ")", "-", "1", ")", ".", "Inte...
// arrayLast returns last item in the array
[ "arrayLast", "returns", "last", "item", "in", "the", "array" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L356-L359
train
jwilder/docker-gen
template.go
arrayClosest
func arrayClosest(values []string, input string) string { best := "" for _, v := range values { if strings.Contains(input, v) && len(v) > len(best) { best = v } } return best }
go
func arrayClosest(values []string, input string) string { best := "" for _, v := range values { if strings.Contains(input, v) && len(v) > len(best) { best = v } } return best }
[ "func", "arrayClosest", "(", "values", "[", "]", "string", ",", "input", "string", ")", "string", "{", "best", ":=", "\"", "\"", "\n", "for", "_", ",", "v", ":=", "range", "values", "{", "if", "strings", ".", "Contains", "(", "input", ",", "v", ")"...
// arrayClosest find the longest matching substring in values // that matches input
[ "arrayClosest", "find", "the", "longest", "matching", "substring", "in", "values", "that", "matches", "input" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L363-L371
train
jwilder/docker-gen
template.go
dirList
func dirList(path string) ([]string, error) { names := []string{} files, err := ioutil.ReadDir(path) if err != nil { log.Printf("Template error: %v", err) return names, nil } for _, f := range files { names = append(names, f.Name()) } return names, nil }
go
func dirList(path string) ([]string, error) { names := []string{} files, err := ioutil.ReadDir(path) if err != nil { log.Printf("Template error: %v", err) return names, nil } for _, f := range files { names = append(names, f.Name()) } return names, nil }
[ "func", "dirList", "(", "path", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "names", ":=", "[", "]", "string", "{", "}", "\n", "files", ",", "err", ":=", "ioutil", ".", "ReadDir", "(", "path", ")", "\n", "if", "err", "!=", "...
// dirList returns a list of files in the specified path
[ "dirList", "returns", "a", "list", "of", "files", "in", "the", "specified", "path" ]
4edc190faa34342313589a80e3a736cafb45919b
https://github.com/jwilder/docker-gen/blob/4edc190faa34342313589a80e3a736cafb45919b/template.go#L374-L385
train
gliderlabs/logspout
httpstream/httpstream.go
LogStreamer
func LogStreamer() http.Handler { logs := mux.NewRouter() logsHandler := func(w http.ResponseWriter, req *http.Request) { params := mux.Vars(req) route := new(router.Route) if params["value"] != "" { switch params["predicate"] { case "id": route.FilterID = params["value"] if len(route.ID) > 12 { ...
go
func LogStreamer() http.Handler { logs := mux.NewRouter() logsHandler := func(w http.ResponseWriter, req *http.Request) { params := mux.Vars(req) route := new(router.Route) if params["value"] != "" { switch params["predicate"] { case "id": route.FilterID = params["value"] if len(route.ID) > 12 { ...
[ "func", "LogStreamer", "(", ")", "http", ".", "Handler", "{", "logs", ":=", "mux", ".", "NewRouter", "(", ")", "\n", "logsHandler", ":=", "func", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "params", ":...
// LogStreamer returns a http.Handler that can stream logs
[ "LogStreamer", "returns", "a", "http", ".", "Handler", "that", "can", "stream", "logs" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/httpstream/httpstream.go#L27-L72
train
gliderlabs/logspout
routesapi/routesapi.go
RoutesAPI
func RoutesAPI() http.Handler { routes := router.Routes r := mux.NewRouter() r.HandleFunc("/routes/{id}", func(w http.ResponseWriter, req *http.Request) { params := mux.Vars(req) route, _ := routes.Get(params["id"]) if route == nil { http.NotFound(w, req) return } w.Write(append(marshal(route), '\n'...
go
func RoutesAPI() http.Handler { routes := router.Routes r := mux.NewRouter() r.HandleFunc("/routes/{id}", func(w http.ResponseWriter, req *http.Request) { params := mux.Vars(req) route, _ := routes.Get(params["id"]) if route == nil { http.NotFound(w, req) return } w.Write(append(marshal(route), '\n'...
[ "func", "RoutesAPI", "(", ")", "http", ".", "Handler", "{", "routes", ":=", "router", ".", "Routes", "\n", "r", ":=", "mux", ".", "NewRouter", "(", ")", "\n\n", "r", ".", "HandleFunc", "(", "\"", "\"", ",", "func", "(", "w", "http", ".", "ResponseW...
// RoutesAPI returns a handler for the routes API
[ "RoutesAPI", "returns", "a", "handler", "for", "the", "routes", "API" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/routesapi/routesapi.go#L18-L63
train
gliderlabs/logspout
transports/tls/tls.go
createTLSConfig
func createTLSConfig() (tlsConfig *tls.Config, err error) { tlsConfig = &tls.Config{} // use stronger TLS settings if enabled // TODO: perhaps this should be default setting if os.Getenv(envTLSHardening) == "true" { tlsConfig.InsecureSkipVerify = false tlsConfig.MinVersion = hardenedMinVersion tlsConfig.Ciph...
go
func createTLSConfig() (tlsConfig *tls.Config, err error) { tlsConfig = &tls.Config{} // use stronger TLS settings if enabled // TODO: perhaps this should be default setting if os.Getenv(envTLSHardening) == "true" { tlsConfig.InsecureSkipVerify = false tlsConfig.MinVersion = hardenedMinVersion tlsConfig.Ciph...
[ "func", "createTLSConfig", "(", ")", "(", "tlsConfig", "*", "tls", ".", "Config", ",", "err", "error", ")", "{", "tlsConfig", "=", "&", "tls", ".", "Config", "{", "}", "\n\n", "// use stronger TLS settings if enabled", "// TODO: perhaps this should be default settin...
// createTLSConfig creates the required TLS configuration that we need to establish a TLS connection
[ "createTLSConfig", "creates", "the", "required", "TLS", "configuration", "that", "we", "need", "to", "establish", "a", "TLS", "connection" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/transports/tls/tls.go#L95-L161
train
gliderlabs/logspout
adapters/syslog/syslog.go
NewSyslogAdapter
func NewSyslogAdapter(route *router.Route) (router.LogAdapter, error) { transport, found := router.AdapterTransports.Lookup(route.AdapterTransport("udp")) if !found { return nil, errors.New("bad transport: " + route.Adapter) } conn, err := transport.Dial(route.Address, route.Options) if err != nil { return nil...
go
func NewSyslogAdapter(route *router.Route) (router.LogAdapter, error) { transport, found := router.AdapterTransports.Lookup(route.AdapterTransport("udp")) if !found { return nil, errors.New("bad transport: " + route.Adapter) } conn, err := transport.Dial(route.Address, route.Options) if err != nil { return nil...
[ "func", "NewSyslogAdapter", "(", "route", "*", "router", ".", "Route", ")", "(", "router", ".", "LogAdapter", ",", "error", ")", "{", "transport", ",", "found", ":=", "router", ".", "AdapterTransports", ".", "Lookup", "(", "route", ".", "AdapterTransport", ...
// NewSyslogAdapter returnas a configured syslog.Adapter
[ "NewSyslogAdapter", "returnas", "a", "configured", "syslog", ".", "Adapter" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/adapters/syslog/syslog.go#L70-L120
train
gliderlabs/logspout
adapters/syslog/syslog.go
Render
func (m *Message) Render(tmpl *template.Template) ([]byte, error) { buf := new(bytes.Buffer) err := tmpl.Execute(buf, m) if err != nil { return nil, err } return buf.Bytes(), nil }
go
func (m *Message) Render(tmpl *template.Template) ([]byte, error) { buf := new(bytes.Buffer) err := tmpl.Execute(buf, m) if err != nil { return nil, err } return buf.Bytes(), nil }
[ "func", "(", "m", "*", "Message", ")", "Render", "(", "tmpl", "*", "template", ".", "Template", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "buf", ":=", "new", "(", "bytes", ".", "Buffer", ")", "\n", "err", ":=", "tmpl", ".", "Execute", ...
// Render transforms the log message using the Syslog template
[ "Render", "transforms", "the", "log", "message", "using", "the", "Syslog", "template" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/adapters/syslog/syslog.go#L234-L241
train
gliderlabs/logspout
adapters/syslog/syslog.go
Priority
func (m *Message) Priority() syslog.Priority { switch m.Message.Source { case "stdout": return syslog.LOG_USER | syslog.LOG_INFO case "stderr": return syslog.LOG_USER | syslog.LOG_ERR default: return syslog.LOG_DAEMON | syslog.LOG_INFO } }
go
func (m *Message) Priority() syslog.Priority { switch m.Message.Source { case "stdout": return syslog.LOG_USER | syslog.LOG_INFO case "stderr": return syslog.LOG_USER | syslog.LOG_ERR default: return syslog.LOG_DAEMON | syslog.LOG_INFO } }
[ "func", "(", "m", "*", "Message", ")", "Priority", "(", ")", "syslog", ".", "Priority", "{", "switch", "m", ".", "Message", ".", "Source", "{", "case", "\"", "\"", ":", "return", "syslog", ".", "LOG_USER", "|", "syslog", ".", "LOG_INFO", "\n", "case"...
// Priority returns a syslog.Priority based on the message source
[ "Priority", "returns", "a", "syslog", ".", "Priority", "based", "on", "the", "message", "source" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/adapters/syslog/syslog.go#L244-L253
train
gliderlabs/logspout
adapters/syslog/syslog.go
Timestamp
func (m *Message) Timestamp() string { return m.Message.Time.Format(time.RFC3339) }
go
func (m *Message) Timestamp() string { return m.Message.Time.Format(time.RFC3339) }
[ "func", "(", "m", "*", "Message", ")", "Timestamp", "(", ")", "string", "{", "return", "m", ".", "Message", ".", "Time", ".", "Format", "(", "time", ".", "RFC3339", ")", "\n", "}" ]
// Timestamp returns the message's syslog formatted timestamp
[ "Timestamp", "returns", "the", "message", "s", "syslog", "formatted", "timestamp" ]
29d77641f9664a74fafea2ce655f610d796a63d4
https://github.com/gliderlabs/logspout/blob/29d77641f9664a74fafea2ce655f610d796a63d4/adapters/syslog/syslog.go#L261-L263
train