id int32 0 167k | 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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
141,200 | coreos/go-iptables | iptables/iptables.go | ChangePolicy | func (ipt *IPTables) ChangePolicy(table, chain, target string) error {
return ipt.run("-t", table, "-P", chain, target)
} | go | func (ipt *IPTables) ChangePolicy(table, chain, target string) error {
return ipt.run("-t", table, "-P", chain, target)
} | [
"func",
"(",
"ipt",
"*",
"IPTables",
")",
"ChangePolicy",
"(",
"table",
",",
"chain",
",",
"target",
"string",
")",
"error",
"{",
"return",
"ipt",
".",
"run",
"(",
"\"",
"\"",
",",
"table",
",",
"\"",
"\"",
",",
"chain",
",",
"target",
")",
"\n",
... | // ChangePolicy changes policy on chain to target | [
"ChangePolicy",
"changes",
"policy",
"on",
"chain",
"to",
"target"
] | 78b5fff24e6df8886ef8eca9411f683a884349a5 | https://github.com/coreos/go-iptables/blob/78b5fff24e6df8886ef8eca9411f683a884349a5/iptables/iptables.go#L341-L343 |
141,201 | coreos/go-iptables | iptables/iptables.go | GetIptablesVersion | func (ipt *IPTables) GetIptablesVersion() (int, int, int) {
return ipt.v1, ipt.v2, ipt.v3
} | go | func (ipt *IPTables) GetIptablesVersion() (int, int, int) {
return ipt.v1, ipt.v2, ipt.v3
} | [
"func",
"(",
"ipt",
"*",
"IPTables",
")",
"GetIptablesVersion",
"(",
")",
"(",
"int",
",",
"int",
",",
"int",
")",
"{",
"return",
"ipt",
".",
"v1",
",",
"ipt",
".",
"v2",
",",
"ipt",
".",
"v3",
"\n",
"}"
] | // Return version components of the underlying iptables command | [
"Return",
"version",
"components",
"of",
"the",
"underlying",
"iptables",
"command"
] | 78b5fff24e6df8886ef8eca9411f683a884349a5 | https://github.com/coreos/go-iptables/blob/78b5fff24e6df8886ef8eca9411f683a884349a5/iptables/iptables.go#L351-L353 |
141,202 | coreos/go-iptables | iptables/iptables.go | run | func (ipt *IPTables) run(args ...string) error {
return ipt.runWithOutput(args, nil)
} | go | func (ipt *IPTables) run(args ...string) error {
return ipt.runWithOutput(args, nil)
} | [
"func",
"(",
"ipt",
"*",
"IPTables",
")",
"run",
"(",
"args",
"...",
"string",
")",
"error",
"{",
"return",
"ipt",
".",
"runWithOutput",
"(",
"args",
",",
"nil",
")",
"\n",
"}"
] | // run runs an iptables command with the given arguments, ignoring
// any stdout output | [
"run",
"runs",
"an",
"iptables",
"command",
"with",
"the",
"given",
"arguments",
"ignoring",
"any",
"stdout",
"output"
] | 78b5fff24e6df8886ef8eca9411f683a884349a5 | https://github.com/coreos/go-iptables/blob/78b5fff24e6df8886ef8eca9411f683a884349a5/iptables/iptables.go#L357-L359 |
141,203 | coreos/go-iptables | iptables/iptables.go | runWithOutput | func (ipt *IPTables) runWithOutput(args []string, stdout io.Writer) error {
args = append([]string{ipt.path}, args...)
if ipt.hasWait {
args = append(args, "--wait")
} else {
fmu, err := newXtablesFileLock()
if err != nil {
return err
}
ul, err := fmu.tryLock()
if err != nil {
return err
}
defe... | go | func (ipt *IPTables) runWithOutput(args []string, stdout io.Writer) error {
args = append([]string{ipt.path}, args...)
if ipt.hasWait {
args = append(args, "--wait")
} else {
fmu, err := newXtablesFileLock()
if err != nil {
return err
}
ul, err := fmu.tryLock()
if err != nil {
return err
}
defe... | [
"func",
"(",
"ipt",
"*",
"IPTables",
")",
"runWithOutput",
"(",
"args",
"[",
"]",
"string",
",",
"stdout",
"io",
".",
"Writer",
")",
"error",
"{",
"args",
"=",
"append",
"(",
"[",
"]",
"string",
"{",
"ipt",
".",
"path",
"}",
",",
"args",
"...",
"... | // runWithOutput runs an iptables command with the given arguments,
// writing any stdout output to the given writer | [
"runWithOutput",
"runs",
"an",
"iptables",
"command",
"with",
"the",
"given",
"arguments",
"writing",
"any",
"stdout",
"output",
"to",
"the",
"given",
"writer"
] | 78b5fff24e6df8886ef8eca9411f683a884349a5 | https://github.com/coreos/go-iptables/blob/78b5fff24e6df8886ef8eca9411f683a884349a5/iptables/iptables.go#L363-L397 |
141,204 | coreos/go-iptables | iptables/iptables.go | filterRuleOutput | func filterRuleOutput(rule string) string {
out := rule
// work around an output difference in nftables mode where counters
// are output in iptables-save format, rather than iptables -S format
// The string begins with "[0:0]"
//
// Fixes #49
if groups := counterRegex.FindStringSubmatch(out); groups != nil {
... | go | func filterRuleOutput(rule string) string {
out := rule
// work around an output difference in nftables mode where counters
// are output in iptables-save format, rather than iptables -S format
// The string begins with "[0:0]"
//
// Fixes #49
if groups := counterRegex.FindStringSubmatch(out); groups != nil {
... | [
"func",
"filterRuleOutput",
"(",
"rule",
"string",
")",
"string",
"{",
"out",
":=",
"rule",
"\n\n",
"// work around an output difference in nftables mode where counters",
"// are output in iptables-save format, rather than iptables -S format",
"// The string begins with \"[0:0]\"",
"//... | // filterRuleOutput works around some inconsistencies in output.
// For example, when iptables is in legacy vs. nftables mode, it produces
// different results. | [
"filterRuleOutput",
"works",
"around",
"some",
"inconsistencies",
"in",
"output",
".",
"For",
"example",
"when",
"iptables",
"is",
"in",
"legacy",
"vs",
".",
"nftables",
"mode",
"it",
"produces",
"different",
"results",
"."
] | 78b5fff24e6df8886ef8eca9411f683a884349a5 | https://github.com/coreos/go-iptables/blob/78b5fff24e6df8886ef8eca9411f683a884349a5/iptables/iptables.go#L517-L532 |
141,205 | coreos/go-iptables | iptables/lock.go | Unlock | func (l *fileLock) Unlock() error {
defer l.mu.Unlock()
return syscall.Close(l.fd)
} | go | func (l *fileLock) Unlock() error {
defer l.mu.Unlock()
return syscall.Close(l.fd)
} | [
"func",
"(",
"l",
"*",
"fileLock",
")",
"Unlock",
"(",
")",
"error",
"{",
"defer",
"l",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"return",
"syscall",
".",
"Close",
"(",
"l",
".",
"fd",
")",
"\n",
"}"
] | // Unlock closes the underlying file, which implicitly unlocks it as well. It
// also unlocks the associated mutex. | [
"Unlock",
"closes",
"the",
"underlying",
"file",
"which",
"implicitly",
"unlocks",
"it",
"as",
"well",
".",
"It",
"also",
"unlocks",
"the",
"associated",
"mutex",
"."
] | 78b5fff24e6df8886ef8eca9411f683a884349a5 | https://github.com/coreos/go-iptables/blob/78b5fff24e6df8886ef8eca9411f683a884349a5/iptables/lock.go#L71-L74 |
141,206 | coreos/go-iptables | iptables/lock.go | newXtablesFileLock | func newXtablesFileLock() (*fileLock, error) {
fd, err := syscall.Open(xtablesLockFilePath, os.O_CREATE, defaultFilePerm)
if err != nil {
return nil, err
}
return &fileLock{fd: fd}, nil
} | go | func newXtablesFileLock() (*fileLock, error) {
fd, err := syscall.Open(xtablesLockFilePath, os.O_CREATE, defaultFilePerm)
if err != nil {
return nil, err
}
return &fileLock{fd: fd}, nil
} | [
"func",
"newXtablesFileLock",
"(",
")",
"(",
"*",
"fileLock",
",",
"error",
")",
"{",
"fd",
",",
"err",
":=",
"syscall",
".",
"Open",
"(",
"xtablesLockFilePath",
",",
"os",
".",
"O_CREATE",
",",
"defaultFilePerm",
")",
"\n",
"if",
"err",
"!=",
"nil",
"... | // newXtablesFileLock opens a new lock on the xtables lockfile without
// acquiring the lock | [
"newXtablesFileLock",
"opens",
"a",
"new",
"lock",
"on",
"the",
"xtables",
"lockfile",
"without",
"acquiring",
"the",
"lock"
] | 78b5fff24e6df8886ef8eca9411f683a884349a5 | https://github.com/coreos/go-iptables/blob/78b5fff24e6df8886ef8eca9411f683a884349a5/iptables/lock.go#L78-L84 |
141,207 | edsrzf/mmap-go | mmap.go | Map | func Map(f *os.File, prot, flags int) (MMap, error) {
return MapRegion(f, -1, prot, flags, 0)
} | go | func Map(f *os.File, prot, flags int) (MMap, error) {
return MapRegion(f, -1, prot, flags, 0)
} | [
"func",
"Map",
"(",
"f",
"*",
"os",
".",
"File",
",",
"prot",
",",
"flags",
"int",
")",
"(",
"MMap",
",",
"error",
")",
"{",
"return",
"MapRegion",
"(",
"f",
",",
"-",
"1",
",",
"prot",
",",
"flags",
",",
"0",
")",
"\n",
"}"
] | // Map maps an entire file into memory.
// If ANON is set in flags, f is ignored. | [
"Map",
"maps",
"an",
"entire",
"file",
"into",
"memory",
".",
"If",
"ANON",
"is",
"set",
"in",
"flags",
"f",
"is",
"ignored",
"."
] | 904c4ced31cdffe19e971afa0b3d319ff06d9c72 | https://github.com/edsrzf/mmap-go/blob/904c4ced31cdffe19e971afa0b3d319ff06d9c72/mmap.go#L48-L50 |
141,208 | edsrzf/mmap-go | mmap.go | MapRegion | func MapRegion(f *os.File, length int, prot, flags int, offset int64) (MMap, error) {
if offset%int64(os.Getpagesize()) != 0 {
return nil, errors.New("offset parameter must be a multiple of the system's page size")
}
var fd uintptr
if flags&ANON == 0 {
fd = uintptr(f.Fd())
if length < 0 {
fi, err := f.Sta... | go | func MapRegion(f *os.File, length int, prot, flags int, offset int64) (MMap, error) {
if offset%int64(os.Getpagesize()) != 0 {
return nil, errors.New("offset parameter must be a multiple of the system's page size")
}
var fd uintptr
if flags&ANON == 0 {
fd = uintptr(f.Fd())
if length < 0 {
fi, err := f.Sta... | [
"func",
"MapRegion",
"(",
"f",
"*",
"os",
".",
"File",
",",
"length",
"int",
",",
"prot",
",",
"flags",
"int",
",",
"offset",
"int64",
")",
"(",
"MMap",
",",
"error",
")",
"{",
"if",
"offset",
"%",
"int64",
"(",
"os",
".",
"Getpagesize",
"(",
")"... | // MapRegion maps part of a file into memory.
// The offset parameter must be a multiple of the system's page size.
// If length < 0, the entire file will be mapped.
// If ANON is set in flags, f is ignored. | [
"MapRegion",
"maps",
"part",
"of",
"a",
"file",
"into",
"memory",
".",
"The",
"offset",
"parameter",
"must",
"be",
"a",
"multiple",
"of",
"the",
"system",
"s",
"page",
"size",
".",
"If",
"length",
"<",
"0",
"the",
"entire",
"file",
"will",
"be",
"mappe... | 904c4ced31cdffe19e971afa0b3d319ff06d9c72 | https://github.com/edsrzf/mmap-go/blob/904c4ced31cdffe19e971afa0b3d319ff06d9c72/mmap.go#L56-L78 |
141,209 | matrix-org/gomatrix | events.go | Body | func (event *Event) Body() (body string, ok bool) {
value, exists := event.Content["body"]
if !exists {
return
}
body, ok = value.(string)
return
} | go | func (event *Event) Body() (body string, ok bool) {
value, exists := event.Content["body"]
if !exists {
return
}
body, ok = value.(string)
return
} | [
"func",
"(",
"event",
"*",
"Event",
")",
"Body",
"(",
")",
"(",
"body",
"string",
",",
"ok",
"bool",
")",
"{",
"value",
",",
"exists",
":=",
"event",
".",
"Content",
"[",
"\"",
"\"",
"]",
"\n",
"if",
"!",
"exists",
"{",
"return",
"\n",
"}",
"\n... | // Body returns the value of the "body" key in the event content if it is
// present and is a string. | [
"Body",
"returns",
"the",
"value",
"of",
"the",
"body",
"key",
"in",
"the",
"event",
"content",
"if",
"it",
"is",
"present",
"and",
"is",
"a",
"string",
"."
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/events.go#L23-L30 |
141,210 | matrix-org/gomatrix | events.go | MessageType | func (event *Event) MessageType() (msgtype string, ok bool) {
value, exists := event.Content["msgtype"]
if !exists {
return
}
msgtype, ok = value.(string)
return
} | go | func (event *Event) MessageType() (msgtype string, ok bool) {
value, exists := event.Content["msgtype"]
if !exists {
return
}
msgtype, ok = value.(string)
return
} | [
"func",
"(",
"event",
"*",
"Event",
")",
"MessageType",
"(",
")",
"(",
"msgtype",
"string",
",",
"ok",
"bool",
")",
"{",
"value",
",",
"exists",
":=",
"event",
".",
"Content",
"[",
"\"",
"\"",
"]",
"\n",
"if",
"!",
"exists",
"{",
"return",
"\n",
... | // MessageType returns the value of the "msgtype" key in the event content if
// it is present and is a string. | [
"MessageType",
"returns",
"the",
"value",
"of",
"the",
"msgtype",
"key",
"in",
"the",
"event",
"content",
"if",
"it",
"is",
"present",
"and",
"is",
"a",
"string",
"."
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/events.go#L34-L41 |
141,211 | matrix-org/gomatrix | events.go | GetHTMLMessage | func GetHTMLMessage(msgtype, htmlText string) HTMLMessage {
return HTMLMessage{
Body: html.UnescapeString(htmlRegex.ReplaceAllLiteralString(htmlText, "")),
MsgType: msgtype,
Format: "org.matrix.custom.html",
FormattedBody: htmlText,
}
} | go | func GetHTMLMessage(msgtype, htmlText string) HTMLMessage {
return HTMLMessage{
Body: html.UnescapeString(htmlRegex.ReplaceAllLiteralString(htmlText, "")),
MsgType: msgtype,
Format: "org.matrix.custom.html",
FormattedBody: htmlText,
}
} | [
"func",
"GetHTMLMessage",
"(",
"msgtype",
",",
"htmlText",
"string",
")",
"HTMLMessage",
"{",
"return",
"HTMLMessage",
"{",
"Body",
":",
"html",
".",
"UnescapeString",
"(",
"htmlRegex",
".",
"ReplaceAllLiteralString",
"(",
"htmlText",
",",
"\"",
"\"",
")",
")"... | // GetHTMLMessage returns an HTMLMessage with the body set to a stripped version of the provided HTML, in addition
// to the provided HTML. | [
"GetHTMLMessage",
"returns",
"an",
"HTMLMessage",
"with",
"the",
"body",
"set",
"to",
"a",
"stripped",
"version",
"of",
"the",
"provided",
"HTML",
"in",
"addition",
"to",
"the",
"provided",
"HTML",
"."
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/events.go#L106-L113 |
141,212 | matrix-org/gomatrix | room.go | GetMembershipState | func (room Room) GetMembershipState(userID string) string {
state := "leave"
event := room.GetStateEvent("m.room.member", userID)
if event != nil {
membershipState, found := event.Content["membership"]
if found {
mState, isString := membershipState.(string)
if isString {
state = mState
}
}
}
ret... | go | func (room Room) GetMembershipState(userID string) string {
state := "leave"
event := room.GetStateEvent("m.room.member", userID)
if event != nil {
membershipState, found := event.Content["membership"]
if found {
mState, isString := membershipState.(string)
if isString {
state = mState
}
}
}
ret... | [
"func",
"(",
"room",
"Room",
")",
"GetMembershipState",
"(",
"userID",
"string",
")",
"string",
"{",
"state",
":=",
"\"",
"\"",
"\n",
"event",
":=",
"room",
".",
"GetStateEvent",
"(",
"\"",
"\"",
",",
"userID",
")",
"\n",
"if",
"event",
"!=",
"nil",
... | // GetMembershipState returns the membership state of the given user ID in this room. If there is
// no entry for this member, 'leave' is returned for consistency with left users. | [
"GetMembershipState",
"returns",
"the",
"membership",
"state",
"of",
"the",
"given",
"user",
"ID",
"in",
"this",
"room",
".",
"If",
"there",
"is",
"no",
"entry",
"for",
"this",
"member",
"leave",
"is",
"returned",
"for",
"consistency",
"with",
"left",
"users... | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/room.go#L28-L41 |
141,213 | matrix-org/gomatrix | room.go | NewRoom | func NewRoom(roomID string) *Room {
// Init the State map and return a pointer to the Room
return &Room{
ID: roomID,
State: make(map[string]map[string]*Event),
}
} | go | func NewRoom(roomID string) *Room {
// Init the State map and return a pointer to the Room
return &Room{
ID: roomID,
State: make(map[string]map[string]*Event),
}
} | [
"func",
"NewRoom",
"(",
"roomID",
"string",
")",
"*",
"Room",
"{",
"// Init the State map and return a pointer to the Room",
"return",
"&",
"Room",
"{",
"ID",
":",
"roomID",
",",
"State",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"map",
"[",
"string",
"]"... | // NewRoom creates a new Room with the given ID | [
"NewRoom",
"creates",
"a",
"new",
"Room",
"with",
"the",
"given",
"ID"
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/room.go#L44-L50 |
141,214 | matrix-org/gomatrix | responses.go | HasSingleStageFlow | func (r RespUserInteractive) HasSingleStageFlow(stageName string) bool {
for _, f := range r.Flows {
if len(f.Stages) == 1 && f.Stages[0] == stageName {
return true
}
}
return false
} | go | func (r RespUserInteractive) HasSingleStageFlow(stageName string) bool {
for _, f := range r.Flows {
if len(f.Stages) == 1 && f.Stages[0] == stageName {
return true
}
}
return false
} | [
"func",
"(",
"r",
"RespUserInteractive",
")",
"HasSingleStageFlow",
"(",
"stageName",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"f",
":=",
"range",
"r",
".",
"Flows",
"{",
"if",
"len",
"(",
"f",
".",
"Stages",
")",
"==",
"1",
"&&",
"f",
".",
"St... | // HasSingleStageFlow returns true if there exists at least 1 Flow with a single stage of stageName. | [
"HasSingleStageFlow",
"returns",
"true",
"if",
"there",
"exists",
"at",
"least",
"1",
"Flow",
"with",
"a",
"single",
"stage",
"of",
"stageName",
"."
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/responses.go#L94-L101 |
141,215 | matrix-org/gomatrix | client.go | SetCredentials | func (cli *Client) SetCredentials(userID, accessToken string) {
cli.AccessToken = accessToken
cli.UserID = userID
} | go | func (cli *Client) SetCredentials(userID, accessToken string) {
cli.AccessToken = accessToken
cli.UserID = userID
} | [
"func",
"(",
"cli",
"*",
"Client",
")",
"SetCredentials",
"(",
"userID",
",",
"accessToken",
"string",
")",
"{",
"cli",
".",
"AccessToken",
"=",
"accessToken",
"\n",
"cli",
".",
"UserID",
"=",
"userID",
"\n",
"}"
] | // SetCredentials sets the user ID and access token on this client instance. | [
"SetCredentials",
"sets",
"the",
"user",
"ID",
"and",
"access",
"token",
"on",
"this",
"client",
"instance",
"."
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/client.go#L99-L102 |
141,216 | matrix-org/gomatrix | client.go | MakeRequest | func (cli *Client) MakeRequest(method string, httpURL string, reqBody interface{}, resBody interface{}) ([]byte, error) {
var req *http.Request
var err error
if reqBody != nil {
var jsonStr []byte
jsonStr, err = json.Marshal(reqBody)
if err != nil {
return nil, err
}
req, err = http.NewRequest(method, h... | go | func (cli *Client) MakeRequest(method string, httpURL string, reqBody interface{}, resBody interface{}) ([]byte, error) {
var req *http.Request
var err error
if reqBody != nil {
var jsonStr []byte
jsonStr, err = json.Marshal(reqBody)
if err != nil {
return nil, err
}
req, err = http.NewRequest(method, h... | [
"func",
"(",
"cli",
"*",
"Client",
")",
"MakeRequest",
"(",
"method",
"string",
",",
"httpURL",
"string",
",",
"reqBody",
"interface",
"{",
"}",
",",
"resBody",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"req",
... | // MakeRequest makes a JSON HTTP request to the given URL.
// If "resBody" is not nil, the response body will be json.Unmarshalled into it.
//
// Returns the HTTP body as bytes on 2xx with a nil error. Returns an error if the response is not 2xx along
// with the HTTP body bytes if it got that far. This error is an HTT... | [
"MakeRequest",
"makes",
"a",
"JSON",
"HTTP",
"request",
"to",
"the",
"given",
"URL",
".",
"If",
"resBody",
"is",
"not",
"nil",
"the",
"response",
"body",
"will",
"be",
"json",
".",
"Unmarshalled",
"into",
"it",
".",
"Returns",
"the",
"HTTP",
"body",
"as"... | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/client.go#L191-L248 |
141,217 | matrix-org/gomatrix | client.go | UploadLink | func (cli *Client) UploadLink(link string) (*RespMediaUpload, error) {
res, err := cli.Client.Get(link)
if res != nil {
defer res.Body.Close()
}
if err != nil {
return nil, err
}
return cli.UploadToContentRepo(res.Body, res.Header.Get("Content-Type"), res.ContentLength)
} | go | func (cli *Client) UploadLink(link string) (*RespMediaUpload, error) {
res, err := cli.Client.Get(link)
if res != nil {
defer res.Body.Close()
}
if err != nil {
return nil, err
}
return cli.UploadToContentRepo(res.Body, res.Header.Get("Content-Type"), res.ContentLength)
} | [
"func",
"(",
"cli",
"*",
"Client",
")",
"UploadLink",
"(",
"link",
"string",
")",
"(",
"*",
"RespMediaUpload",
",",
"error",
")",
"{",
"res",
",",
"err",
":=",
"cli",
".",
"Client",
".",
"Get",
"(",
"link",
")",
"\n",
"if",
"res",
"!=",
"nil",
"{... | // UploadLink uploads an HTTP URL and then returns an MXC URI. | [
"UploadLink",
"uploads",
"an",
"HTTP",
"URL",
"and",
"then",
"returns",
"an",
"MXC",
"URI",
"."
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/client.go#L587-L596 |
141,218 | matrix-org/gomatrix | client.go | NewClient | func NewClient(homeserverURL, userID, accessToken string) (*Client, error) {
hsURL, err := url.Parse(homeserverURL)
if err != nil {
return nil, err
}
// By default, use an in-memory store which will never save filter ids / next batch tokens to disk.
// The client will work with this storer: it just won't remembe... | go | func NewClient(homeserverURL, userID, accessToken string) (*Client, error) {
hsURL, err := url.Parse(homeserverURL)
if err != nil {
return nil, err
}
// By default, use an in-memory store which will never save filter ids / next batch tokens to disk.
// The client will work with this storer: it just won't remembe... | [
"func",
"NewClient",
"(",
"homeserverURL",
",",
"userID",
",",
"accessToken",
"string",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"hsURL",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"homeserverURL",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"... | // NewClient creates a new Matrix Client ready for syncing | [
"NewClient",
"creates",
"a",
"new",
"Matrix",
"Client",
"ready",
"for",
"syncing"
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/client.go#L687-L708 |
141,219 | matrix-org/gomatrix | userids.go | escape | func escape(buf *bytes.Buffer, b byte) {
buf.WriteByte('_')
if b == '_' {
buf.WriteByte('_') // another _
} else {
buf.WriteByte(b + 0x20) // ASCII shift A-Z to a-z
}
} | go | func escape(buf *bytes.Buffer, b byte) {
buf.WriteByte('_')
if b == '_' {
buf.WriteByte('_') // another _
} else {
buf.WriteByte(b + 0x20) // ASCII shift A-Z to a-z
}
} | [
"func",
"escape",
"(",
"buf",
"*",
"bytes",
".",
"Buffer",
",",
"b",
"byte",
")",
"{",
"buf",
".",
"WriteByte",
"(",
"'_'",
")",
"\n",
"if",
"b",
"==",
"'_'",
"{",
"buf",
".",
"WriteByte",
"(",
"'_'",
")",
"// another _",
"\n",
"}",
"else",
"{",
... | // escape the given alpha character and writes it to the buffer | [
"escape",
"the",
"given",
"alpha",
"character",
"and",
"writes",
"it",
"to",
"the",
"buffer"
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/userids.go#L22-L29 |
141,220 | matrix-org/gomatrix | sync.go | NewDefaultSyncer | func NewDefaultSyncer(userID string, store Storer) *DefaultSyncer {
return &DefaultSyncer{
UserID: userID,
Store: store,
listeners: make(map[string][]OnEventListener),
}
} | go | func NewDefaultSyncer(userID string, store Storer) *DefaultSyncer {
return &DefaultSyncer{
UserID: userID,
Store: store,
listeners: make(map[string][]OnEventListener),
}
} | [
"func",
"NewDefaultSyncer",
"(",
"userID",
"string",
",",
"store",
"Storer",
")",
"*",
"DefaultSyncer",
"{",
"return",
"&",
"DefaultSyncer",
"{",
"UserID",
":",
"userID",
",",
"Store",
":",
"store",
",",
"listeners",
":",
"make",
"(",
"map",
"[",
"string",... | // NewDefaultSyncer returns an instantiated DefaultSyncer | [
"NewDefaultSyncer",
"returns",
"an",
"instantiated",
"DefaultSyncer"
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/sync.go#L35-L41 |
141,221 | matrix-org/gomatrix | sync.go | OnEventType | func (s *DefaultSyncer) OnEventType(eventType string, callback OnEventListener) {
_, exists := s.listeners[eventType]
if !exists {
s.listeners[eventType] = []OnEventListener{}
}
s.listeners[eventType] = append(s.listeners[eventType], callback)
} | go | func (s *DefaultSyncer) OnEventType(eventType string, callback OnEventListener) {
_, exists := s.listeners[eventType]
if !exists {
s.listeners[eventType] = []OnEventListener{}
}
s.listeners[eventType] = append(s.listeners[eventType], callback)
} | [
"func",
"(",
"s",
"*",
"DefaultSyncer",
")",
"OnEventType",
"(",
"eventType",
"string",
",",
"callback",
"OnEventListener",
")",
"{",
"_",
",",
"exists",
":=",
"s",
".",
"listeners",
"[",
"eventType",
"]",
"\n",
"if",
"!",
"exists",
"{",
"s",
".",
"lis... | // OnEventType allows callers to be notified when there are new events for the given event type.
// There are no duplicate checks. | [
"OnEventType",
"allows",
"callers",
"to",
"be",
"notified",
"when",
"there",
"are",
"new",
"events",
"for",
"the",
"given",
"event",
"type",
".",
"There",
"are",
"no",
"duplicate",
"checks",
"."
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/sync.go#L91-L97 |
141,222 | matrix-org/gomatrix | sync.go | shouldProcessResponse | func (s *DefaultSyncer) shouldProcessResponse(resp *RespSync, since string) bool {
if since == "" {
return false
}
// This is a horrible hack because /sync will return the most recent messages for a room
// as soon as you /join it. We do NOT want to process those events in that particular room
// because they ma... | go | func (s *DefaultSyncer) shouldProcessResponse(resp *RespSync, since string) bool {
if since == "" {
return false
}
// This is a horrible hack because /sync will return the most recent messages for a room
// as soon as you /join it. We do NOT want to process those events in that particular room
// because they ma... | [
"func",
"(",
"s",
"*",
"DefaultSyncer",
")",
"shouldProcessResponse",
"(",
"resp",
"*",
"RespSync",
",",
"since",
"string",
")",
"bool",
"{",
"if",
"since",
"==",
"\"",
"\"",
"{",
"return",
"false",
"\n",
"}",
"\n",
"// This is a horrible hack because /sync wi... | // shouldProcessResponse returns true if the response should be processed. May modify the response to remove
// stuff that shouldn't be processed. | [
"shouldProcessResponse",
"returns",
"true",
"if",
"the",
"response",
"should",
"be",
"processed",
".",
"May",
"modify",
"the",
"response",
"to",
"remove",
"stuff",
"that",
"shouldn",
"t",
"be",
"processed",
"."
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/sync.go#L101-L134 |
141,223 | matrix-org/gomatrix | store.go | SaveFilterID | func (s *InMemoryStore) SaveFilterID(userID, filterID string) {
s.Filters[userID] = filterID
} | go | func (s *InMemoryStore) SaveFilterID(userID, filterID string) {
s.Filters[userID] = filterID
} | [
"func",
"(",
"s",
"*",
"InMemoryStore",
")",
"SaveFilterID",
"(",
"userID",
",",
"filterID",
"string",
")",
"{",
"s",
".",
"Filters",
"[",
"userID",
"]",
"=",
"filterID",
"\n",
"}"
] | // SaveFilterID to memory. | [
"SaveFilterID",
"to",
"memory",
"."
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/store.go#L29-L31 |
141,224 | matrix-org/gomatrix | store.go | SaveNextBatch | func (s *InMemoryStore) SaveNextBatch(userID, nextBatchToken string) {
s.NextBatch[userID] = nextBatchToken
} | go | func (s *InMemoryStore) SaveNextBatch(userID, nextBatchToken string) {
s.NextBatch[userID] = nextBatchToken
} | [
"func",
"(",
"s",
"*",
"InMemoryStore",
")",
"SaveNextBatch",
"(",
"userID",
",",
"nextBatchToken",
"string",
")",
"{",
"s",
".",
"NextBatch",
"[",
"userID",
"]",
"=",
"nextBatchToken",
"\n",
"}"
] | // SaveNextBatch to memory. | [
"SaveNextBatch",
"to",
"memory",
"."
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/store.go#L39-L41 |
141,225 | matrix-org/gomatrix | store.go | SaveRoom | func (s *InMemoryStore) SaveRoom(room *Room) {
s.Rooms[room.ID] = room
} | go | func (s *InMemoryStore) SaveRoom(room *Room) {
s.Rooms[room.ID] = room
} | [
"func",
"(",
"s",
"*",
"InMemoryStore",
")",
"SaveRoom",
"(",
"room",
"*",
"Room",
")",
"{",
"s",
".",
"Rooms",
"[",
"room",
".",
"ID",
"]",
"=",
"room",
"\n",
"}"
] | // SaveRoom to memory. | [
"SaveRoom",
"to",
"memory",
"."
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/store.go#L49-L51 |
141,226 | matrix-org/gomatrix | store.go | NewInMemoryStore | func NewInMemoryStore() *InMemoryStore {
return &InMemoryStore{
Filters: make(map[string]string),
NextBatch: make(map[string]string),
Rooms: make(map[string]*Room),
}
} | go | func NewInMemoryStore() *InMemoryStore {
return &InMemoryStore{
Filters: make(map[string]string),
NextBatch: make(map[string]string),
Rooms: make(map[string]*Room),
}
} | [
"func",
"NewInMemoryStore",
"(",
")",
"*",
"InMemoryStore",
"{",
"return",
"&",
"InMemoryStore",
"{",
"Filters",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
",",
"NextBatch",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"... | // NewInMemoryStore constructs a new InMemoryStore. | [
"NewInMemoryStore",
"constructs",
"a",
"new",
"InMemoryStore",
"."
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/store.go#L59-L65 |
141,227 | matrix-org/gomatrix | filter.go | Validate | func (filter *Filter) Validate() error {
if filter.EventFormat != "client" && filter.EventFormat != "federation" {
return errors.New("Bad event_format value. Must be one of [\"client\", \"federation\"]")
}
return nil
} | go | func (filter *Filter) Validate() error {
if filter.EventFormat != "client" && filter.EventFormat != "federation" {
return errors.New("Bad event_format value. Must be one of [\"client\", \"federation\"]")
}
return nil
} | [
"func",
"(",
"filter",
"*",
"Filter",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"filter",
".",
"EventFormat",
"!=",
"\"",
"\"",
"&&",
"filter",
".",
"EventFormat",
"!=",
"\"",
"\"",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\\\"",
"\\\"",... | // Validate checks if the filter contains valid property values | [
"Validate",
"checks",
"if",
"the",
"filter",
"contains",
"valid",
"property",
"values"
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/filter.go#L53-L58 |
141,228 | matrix-org/gomatrix | filter.go | DefaultFilter | func DefaultFilter() Filter {
return Filter{
AccountData: DefaultFilterPart(),
EventFields: nil,
EventFormat: "client",
Presence: DefaultFilterPart(),
Room: RoomFilter{
AccountData: DefaultFilterPart(),
Ephemeral: DefaultFilterPart(),
IncludeLeave: false,
NotRooms: nil,
Rooms: ... | go | func DefaultFilter() Filter {
return Filter{
AccountData: DefaultFilterPart(),
EventFields: nil,
EventFormat: "client",
Presence: DefaultFilterPart(),
Room: RoomFilter{
AccountData: DefaultFilterPart(),
Ephemeral: DefaultFilterPart(),
IncludeLeave: false,
NotRooms: nil,
Rooms: ... | [
"func",
"DefaultFilter",
"(",
")",
"Filter",
"{",
"return",
"Filter",
"{",
"AccountData",
":",
"DefaultFilterPart",
"(",
")",
",",
"EventFields",
":",
"nil",
",",
"EventFormat",
":",
"\"",
"\"",
",",
"Presence",
":",
"DefaultFilterPart",
"(",
")",
",",
"Ro... | // DefaultFilter returns the default filter used by the Matrix server if no filter is provided in the request | [
"DefaultFilter",
"returns",
"the",
"default",
"filter",
"used",
"by",
"the",
"Matrix",
"server",
"if",
"no",
"filter",
"is",
"provided",
"in",
"the",
"request"
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/filter.go#L61-L77 |
141,229 | matrix-org/gomatrix | filter.go | DefaultFilterPart | func DefaultFilterPart() FilterPart {
return FilterPart{
NotRooms: nil,
Rooms: nil,
Limit: 20,
NotSenders: nil,
NotTypes: nil,
Senders: nil,
Types: nil,
}
} | go | func DefaultFilterPart() FilterPart {
return FilterPart{
NotRooms: nil,
Rooms: nil,
Limit: 20,
NotSenders: nil,
NotTypes: nil,
Senders: nil,
Types: nil,
}
} | [
"func",
"DefaultFilterPart",
"(",
")",
"FilterPart",
"{",
"return",
"FilterPart",
"{",
"NotRooms",
":",
"nil",
",",
"Rooms",
":",
"nil",
",",
"Limit",
":",
"20",
",",
"NotSenders",
":",
"nil",
",",
"NotTypes",
":",
"nil",
",",
"Senders",
":",
"nil",
",... | // DefaultFilterPart returns the default filter part used by the Matrix server if no filter is provided in the request | [
"DefaultFilterPart",
"returns",
"the",
"default",
"filter",
"part",
"used",
"by",
"the",
"Matrix",
"server",
"if",
"no",
"filter",
"is",
"provided",
"in",
"the",
"request"
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/filter.go#L80-L90 |
141,230 | go-ozzo/ozzo-validation | error.go | MarshalJSON | func (es Errors) MarshalJSON() ([]byte, error) {
errs := map[string]interface{}{}
for key, err := range es {
if ms, ok := err.(json.Marshaler); ok {
errs[key] = ms
} else {
errs[key] = err.Error()
}
}
return json.Marshal(errs)
} | go | func (es Errors) MarshalJSON() ([]byte, error) {
errs := map[string]interface{}{}
for key, err := range es {
if ms, ok := err.(json.Marshaler); ok {
errs[key] = ms
} else {
errs[key] = err.Error()
}
}
return json.Marshal(errs)
} | [
"func",
"(",
"es",
"Errors",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"errs",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"for",
"key",
",",
"err",
":=",
"range",
"es",
"{",
"if",
... | // MarshalJSON converts the Errors into a valid JSON. | [
"MarshalJSON",
"converts",
"the",
"Errors",
"into",
"a",
"valid",
"JSON",
"."
] | 2f76ea62300c36e72bd56c804484cb6db53b69a5 | https://github.com/go-ozzo/ozzo-validation/blob/2f76ea62300c36e72bd56c804484cb6db53b69a5/error.go#L65-L75 |
141,231 | go-ozzo/ozzo-validation | error.go | Filter | func (es Errors) Filter() error {
for key, value := range es {
if value == nil {
delete(es, key)
}
}
if len(es) == 0 {
return nil
}
return es
} | go | func (es Errors) Filter() error {
for key, value := range es {
if value == nil {
delete(es, key)
}
}
if len(es) == 0 {
return nil
}
return es
} | [
"func",
"(",
"es",
"Errors",
")",
"Filter",
"(",
")",
"error",
"{",
"for",
"key",
",",
"value",
":=",
"range",
"es",
"{",
"if",
"value",
"==",
"nil",
"{",
"delete",
"(",
"es",
",",
"key",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"len",
"(",
"es... | // Filter removes all nils from Errors and returns back the updated Errors as an error.
// If the length of Errors becomes 0, it will return nil. | [
"Filter",
"removes",
"all",
"nils",
"from",
"Errors",
"and",
"returns",
"back",
"the",
"updated",
"Errors",
"as",
"an",
"error",
".",
"If",
"the",
"length",
"of",
"Errors",
"becomes",
"0",
"it",
"will",
"return",
"nil",
"."
] | 2f76ea62300c36e72bd56c804484cb6db53b69a5 | https://github.com/go-ozzo/ozzo-validation/blob/2f76ea62300c36e72bd56c804484cb6db53b69a5/error.go#L79-L89 |
141,232 | go-ozzo/ozzo-validation | string.go | NewStringRule | func NewStringRule(validator stringValidator, message string) *StringRule {
return &StringRule{
validate: validator,
message: message,
}
} | go | func NewStringRule(validator stringValidator, message string) *StringRule {
return &StringRule{
validate: validator,
message: message,
}
} | [
"func",
"NewStringRule",
"(",
"validator",
"stringValidator",
",",
"message",
"string",
")",
"*",
"StringRule",
"{",
"return",
"&",
"StringRule",
"{",
"validate",
":",
"validator",
",",
"message",
":",
"message",
",",
"}",
"\n",
"}"
] | // NewStringRule creates a new validation rule using a function that takes a string value and returns a bool.
// The rule returned will use the function to check if a given string or byte slice is valid or not.
// An empty value is considered to be valid. Please use the Required rule to make sure a value is not empty. | [
"NewStringRule",
"creates",
"a",
"new",
"validation",
"rule",
"using",
"a",
"function",
"that",
"takes",
"a",
"string",
"value",
"and",
"returns",
"a",
"bool",
".",
"The",
"rule",
"returned",
"will",
"use",
"the",
"function",
"to",
"check",
"if",
"a",
"giv... | 2f76ea62300c36e72bd56c804484cb6db53b69a5 | https://github.com/go-ozzo/ozzo-validation/blob/2f76ea62300c36e72bd56c804484cb6db53b69a5/string.go#L20-L25 |
141,233 | go-ozzo/ozzo-validation | date.go | Error | func (r *DateRule) Error(message string) *DateRule {
r.message = message
return r
} | go | func (r *DateRule) Error(message string) *DateRule {
r.message = message
return r
} | [
"func",
"(",
"r",
"*",
"DateRule",
")",
"Error",
"(",
"message",
"string",
")",
"*",
"DateRule",
"{",
"r",
".",
"message",
"=",
"message",
"\n",
"return",
"r",
"\n",
"}"
] | // Error sets the error message that is used when the value being validated is not a valid date. | [
"Error",
"sets",
"the",
"error",
"message",
"that",
"is",
"used",
"when",
"the",
"value",
"being",
"validated",
"is",
"not",
"a",
"valid",
"date",
"."
] | 2f76ea62300c36e72bd56c804484cb6db53b69a5 | https://github.com/go-ozzo/ozzo-validation/blob/2f76ea62300c36e72bd56c804484cb6db53b69a5/date.go#L39-L42 |
141,234 | go-ozzo/ozzo-validation | date.go | Min | func (r *DateRule) Min(min time.Time) *DateRule {
r.min = min
return r
} | go | func (r *DateRule) Min(min time.Time) *DateRule {
r.min = min
return r
} | [
"func",
"(",
"r",
"*",
"DateRule",
")",
"Min",
"(",
"min",
"time",
".",
"Time",
")",
"*",
"DateRule",
"{",
"r",
".",
"min",
"=",
"min",
"\n",
"return",
"r",
"\n",
"}"
] | // Min sets the minimum date range. A zero value means skipping the minimum range validation. | [
"Min",
"sets",
"the",
"minimum",
"date",
"range",
".",
"A",
"zero",
"value",
"means",
"skipping",
"the",
"minimum",
"range",
"validation",
"."
] | 2f76ea62300c36e72bd56c804484cb6db53b69a5 | https://github.com/go-ozzo/ozzo-validation/blob/2f76ea62300c36e72bd56c804484cb6db53b69a5/date.go#L51-L54 |
141,235 | go-ozzo/ozzo-validation | date.go | Max | func (r *DateRule) Max(max time.Time) *DateRule {
r.max = max
return r
} | go | func (r *DateRule) Max(max time.Time) *DateRule {
r.max = max
return r
} | [
"func",
"(",
"r",
"*",
"DateRule",
")",
"Max",
"(",
"max",
"time",
".",
"Time",
")",
"*",
"DateRule",
"{",
"r",
".",
"max",
"=",
"max",
"\n",
"return",
"r",
"\n",
"}"
] | // Max sets the maximum date range. A zero value means skipping the maximum range validation. | [
"Max",
"sets",
"the",
"maximum",
"date",
"range",
".",
"A",
"zero",
"value",
"means",
"skipping",
"the",
"maximum",
"range",
"validation",
"."
] | 2f76ea62300c36e72bd56c804484cb6db53b69a5 | https://github.com/go-ozzo/ozzo-validation/blob/2f76ea62300c36e72bd56c804484cb6db53b69a5/date.go#L57-L60 |
141,236 | go-ozzo/ozzo-validation | date.go | Validate | func (r *DateRule) Validate(value interface{}) error {
value, isNil := Indirect(value)
if isNil || IsEmpty(value) {
return nil
}
str, err := EnsureString(value)
if err != nil {
return err
}
date, err := time.Parse(r.layout, str)
if err != nil {
return errors.New(r.message)
}
if !r.min.IsZero() && r.m... | go | func (r *DateRule) Validate(value interface{}) error {
value, isNil := Indirect(value)
if isNil || IsEmpty(value) {
return nil
}
str, err := EnsureString(value)
if err != nil {
return err
}
date, err := time.Parse(r.layout, str)
if err != nil {
return errors.New(r.message)
}
if !r.min.IsZero() && r.m... | [
"func",
"(",
"r",
"*",
"DateRule",
")",
"Validate",
"(",
"value",
"interface",
"{",
"}",
")",
"error",
"{",
"value",
",",
"isNil",
":=",
"Indirect",
"(",
"value",
")",
"\n",
"if",
"isNil",
"||",
"IsEmpty",
"(",
"value",
")",
"{",
"return",
"nil",
"... | // Validate checks if the given value is a valid date. | [
"Validate",
"checks",
"if",
"the",
"given",
"value",
"is",
"a",
"valid",
"date",
"."
] | 2f76ea62300c36e72bd56c804484cb6db53b69a5 | https://github.com/go-ozzo/ozzo-validation/blob/2f76ea62300c36e72bd56c804484cb6db53b69a5/date.go#L63-L84 |
141,237 | go-ozzo/ozzo-validation | util.go | EnsureString | func EnsureString(value interface{}) (string, error) {
v := reflect.ValueOf(value)
if v.Kind() == reflect.String {
return v.String(), nil
}
if v.Type() == bytesType {
return string(v.Interface().([]byte)), nil
}
return "", errors.New("must be either a string or byte slice")
} | go | func EnsureString(value interface{}) (string, error) {
v := reflect.ValueOf(value)
if v.Kind() == reflect.String {
return v.String(), nil
}
if v.Type() == bytesType {
return string(v.Interface().([]byte)), nil
}
return "", errors.New("must be either a string or byte slice")
} | [
"func",
"EnsureString",
"(",
"value",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"error",
")",
"{",
"v",
":=",
"reflect",
".",
"ValueOf",
"(",
"value",
")",
"\n",
"if",
"v",
".",
"Kind",
"(",
")",
"==",
"reflect",
".",
"String",
"{",
"return",... | // EnsureString ensures the given value is a string.
// If the value is a byte slice, it will be typecast into a string.
// An error is returned otherwise. | [
"EnsureString",
"ensures",
"the",
"given",
"value",
"is",
"a",
"string",
".",
"If",
"the",
"value",
"is",
"a",
"byte",
"slice",
"it",
"will",
"be",
"typecast",
"into",
"a",
"string",
".",
"An",
"error",
"is",
"returned",
"otherwise",
"."
] | 2f76ea62300c36e72bd56c804484cb6db53b69a5 | https://github.com/go-ozzo/ozzo-validation/blob/2f76ea62300c36e72bd56c804484cb6db53b69a5/util.go#L23-L32 |
141,238 | go-ozzo/ozzo-validation | util.go | StringOrBytes | func StringOrBytes(value interface{}) (isString bool, str string, isBytes bool, bs []byte) {
v := reflect.ValueOf(value)
if v.Kind() == reflect.String {
str = v.String()
isString = true
} else if v.Kind() == reflect.Slice && v.Type() == bytesType {
bs = v.Interface().([]byte)
isBytes = true
}
return
} | go | func StringOrBytes(value interface{}) (isString bool, str string, isBytes bool, bs []byte) {
v := reflect.ValueOf(value)
if v.Kind() == reflect.String {
str = v.String()
isString = true
} else if v.Kind() == reflect.Slice && v.Type() == bytesType {
bs = v.Interface().([]byte)
isBytes = true
}
return
} | [
"func",
"StringOrBytes",
"(",
"value",
"interface",
"{",
"}",
")",
"(",
"isString",
"bool",
",",
"str",
"string",
",",
"isBytes",
"bool",
",",
"bs",
"[",
"]",
"byte",
")",
"{",
"v",
":=",
"reflect",
".",
"ValueOf",
"(",
"value",
")",
"\n",
"if",
"v... | // StringOrBytes typecasts a value into a string or byte slice.
// Boolean flags are returned to indicate if the typecasting succeeds or not. | [
"StringOrBytes",
"typecasts",
"a",
"value",
"into",
"a",
"string",
"or",
"byte",
"slice",
".",
"Boolean",
"flags",
"are",
"returned",
"to",
"indicate",
"if",
"the",
"typecasting",
"succeeds",
"or",
"not",
"."
] | 2f76ea62300c36e72bd56c804484cb6db53b69a5 | https://github.com/go-ozzo/ozzo-validation/blob/2f76ea62300c36e72bd56c804484cb6db53b69a5/util.go#L36-L46 |
141,239 | go-ozzo/ozzo-validation | util.go | LengthOfValue | func LengthOfValue(value interface{}) (int, error) {
v := reflect.ValueOf(value)
switch v.Kind() {
case reflect.String, reflect.Slice, reflect.Map, reflect.Array:
return v.Len(), nil
}
return 0, fmt.Errorf("cannot get the length of %v", v.Kind())
} | go | func LengthOfValue(value interface{}) (int, error) {
v := reflect.ValueOf(value)
switch v.Kind() {
case reflect.String, reflect.Slice, reflect.Map, reflect.Array:
return v.Len(), nil
}
return 0, fmt.Errorf("cannot get the length of %v", v.Kind())
} | [
"func",
"LengthOfValue",
"(",
"value",
"interface",
"{",
"}",
")",
"(",
"int",
",",
"error",
")",
"{",
"v",
":=",
"reflect",
".",
"ValueOf",
"(",
"value",
")",
"\n",
"switch",
"v",
".",
"Kind",
"(",
")",
"{",
"case",
"reflect",
".",
"String",
",",
... | // LengthOfValue returns the length of a value that is a string, slice, map, or array.
// An error is returned for all other types. | [
"LengthOfValue",
"returns",
"the",
"length",
"of",
"a",
"value",
"that",
"is",
"a",
"string",
"slice",
"map",
"or",
"array",
".",
"An",
"error",
"is",
"returned",
"for",
"all",
"other",
"types",
"."
] | 2f76ea62300c36e72bd56c804484cb6db53b69a5 | https://github.com/go-ozzo/ozzo-validation/blob/2f76ea62300c36e72bd56c804484cb6db53b69a5/util.go#L50-L57 |
141,240 | go-ozzo/ozzo-validation | util.go | ToInt | func ToInt(value interface{}) (int64, error) {
v := reflect.ValueOf(value)
switch v.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return v.Int(), nil
}
return 0, fmt.Errorf("cannot convert %v to int64", v.Kind())
} | go | func ToInt(value interface{}) (int64, error) {
v := reflect.ValueOf(value)
switch v.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return v.Int(), nil
}
return 0, fmt.Errorf("cannot convert %v to int64", v.Kind())
} | [
"func",
"ToInt",
"(",
"value",
"interface",
"{",
"}",
")",
"(",
"int64",
",",
"error",
")",
"{",
"v",
":=",
"reflect",
".",
"ValueOf",
"(",
"value",
")",
"\n",
"switch",
"v",
".",
"Kind",
"(",
")",
"{",
"case",
"reflect",
".",
"Int",
",",
"reflec... | // ToInt converts the given value to an int64.
// An error is returned for all incompatible types. | [
"ToInt",
"converts",
"the",
"given",
"value",
"to",
"an",
"int64",
".",
"An",
"error",
"is",
"returned",
"for",
"all",
"incompatible",
"types",
"."
] | 2f76ea62300c36e72bd56c804484cb6db53b69a5 | https://github.com/go-ozzo/ozzo-validation/blob/2f76ea62300c36e72bd56c804484cb6db53b69a5/util.go#L61-L68 |
141,241 | go-ozzo/ozzo-validation | util.go | ToUint | func ToUint(value interface{}) (uint64, error) {
v := reflect.ValueOf(value)
switch v.Kind() {
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
return v.Uint(), nil
}
return 0, fmt.Errorf("cannot convert %v to uint64", v.Kind())
} | go | func ToUint(value interface{}) (uint64, error) {
v := reflect.ValueOf(value)
switch v.Kind() {
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
return v.Uint(), nil
}
return 0, fmt.Errorf("cannot convert %v to uint64", v.Kind())
} | [
"func",
"ToUint",
"(",
"value",
"interface",
"{",
"}",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"v",
":=",
"reflect",
".",
"ValueOf",
"(",
"value",
")",
"\n",
"switch",
"v",
".",
"Kind",
"(",
")",
"{",
"case",
"reflect",
".",
"Uint",
",",
"ref... | // ToUint converts the given value to an uint64.
// An error is returned for all incompatible types. | [
"ToUint",
"converts",
"the",
"given",
"value",
"to",
"an",
"uint64",
".",
"An",
"error",
"is",
"returned",
"for",
"all",
"incompatible",
"types",
"."
] | 2f76ea62300c36e72bd56c804484cb6db53b69a5 | https://github.com/go-ozzo/ozzo-validation/blob/2f76ea62300c36e72bd56c804484cb6db53b69a5/util.go#L72-L79 |
141,242 | go-ozzo/ozzo-validation | util.go | ToFloat | func ToFloat(value interface{}) (float64, error) {
v := reflect.ValueOf(value)
switch v.Kind() {
case reflect.Float32, reflect.Float64:
return v.Float(), nil
}
return 0, fmt.Errorf("cannot convert %v to float64", v.Kind())
} | go | func ToFloat(value interface{}) (float64, error) {
v := reflect.ValueOf(value)
switch v.Kind() {
case reflect.Float32, reflect.Float64:
return v.Float(), nil
}
return 0, fmt.Errorf("cannot convert %v to float64", v.Kind())
} | [
"func",
"ToFloat",
"(",
"value",
"interface",
"{",
"}",
")",
"(",
"float64",
",",
"error",
")",
"{",
"v",
":=",
"reflect",
".",
"ValueOf",
"(",
"value",
")",
"\n",
"switch",
"v",
".",
"Kind",
"(",
")",
"{",
"case",
"reflect",
".",
"Float32",
",",
... | // ToFloat converts the given value to a float64.
// An error is returned for all incompatible types. | [
"ToFloat",
"converts",
"the",
"given",
"value",
"to",
"a",
"float64",
".",
"An",
"error",
"is",
"returned",
"for",
"all",
"incompatible",
"types",
"."
] | 2f76ea62300c36e72bd56c804484cb6db53b69a5 | https://github.com/go-ozzo/ozzo-validation/blob/2f76ea62300c36e72bd56c804484cb6db53b69a5/util.go#L83-L90 |
141,243 | go-ozzo/ozzo-validation | validation.go | validateMap | func validateMap(rv reflect.Value) error {
errs := Errors{}
for _, key := range rv.MapKeys() {
if mv := rv.MapIndex(key).Interface(); mv != nil {
if err := mv.(Validatable).Validate(); err != nil {
errs[fmt.Sprintf("%v", key.Interface())] = err
}
}
}
if len(errs) > 0 {
return errs
}
return nil
} | go | func validateMap(rv reflect.Value) error {
errs := Errors{}
for _, key := range rv.MapKeys() {
if mv := rv.MapIndex(key).Interface(); mv != nil {
if err := mv.(Validatable).Validate(); err != nil {
errs[fmt.Sprintf("%v", key.Interface())] = err
}
}
}
if len(errs) > 0 {
return errs
}
return nil
} | [
"func",
"validateMap",
"(",
"rv",
"reflect",
".",
"Value",
")",
"error",
"{",
"errs",
":=",
"Errors",
"{",
"}",
"\n",
"for",
"_",
",",
"key",
":=",
"range",
"rv",
".",
"MapKeys",
"(",
")",
"{",
"if",
"mv",
":=",
"rv",
".",
"MapIndex",
"(",
"key",... | // validateMap validates a map of validatable elements | [
"validateMap",
"validates",
"a",
"map",
"of",
"validatable",
"elements"
] | 2f76ea62300c36e72bd56c804484cb6db53b69a5 | https://github.com/go-ozzo/ozzo-validation/blob/2f76ea62300c36e72bd56c804484cb6db53b69a5/validation.go#L84-L97 |
141,244 | go-ozzo/ozzo-validation | minmax.go | Min | func Min(min interface{}) *ThresholdRule {
return &ThresholdRule{
threshold: min,
operator: greaterEqualThan,
message: fmt.Sprintf("must be no less than %v", min),
}
} | go | func Min(min interface{}) *ThresholdRule {
return &ThresholdRule{
threshold: min,
operator: greaterEqualThan,
message: fmt.Sprintf("must be no less than %v", min),
}
} | [
"func",
"Min",
"(",
"min",
"interface",
"{",
"}",
")",
"*",
"ThresholdRule",
"{",
"return",
"&",
"ThresholdRule",
"{",
"threshold",
":",
"min",
",",
"operator",
":",
"greaterEqualThan",
",",
"message",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
... | // Min is a validation rule that checks if a value is greater or equal than the specified value.
// By calling Exclusive, the rule will check if the value is strictly greater than the specified value.
// Note that the value being checked and the threshold value must be of the same type.
// Only int, uint, float and tim... | [
"Min",
"is",
"a",
"validation",
"rule",
"that",
"checks",
"if",
"a",
"value",
"is",
"greater",
"or",
"equal",
"than",
"the",
"specified",
"value",
".",
"By",
"calling",
"Exclusive",
"the",
"rule",
"will",
"check",
"if",
"the",
"value",
"is",
"strictly",
... | 2f76ea62300c36e72bd56c804484cb6db53b69a5 | https://github.com/go-ozzo/ozzo-validation/blob/2f76ea62300c36e72bd56c804484cb6db53b69a5/minmax.go#L32-L38 |
141,245 | go-ozzo/ozzo-validation | minmax.go | Max | func Max(max interface{}) *ThresholdRule {
return &ThresholdRule{
threshold: max,
operator: lessEqualThan,
message: fmt.Sprintf("must be no greater than %v", max),
}
} | go | func Max(max interface{}) *ThresholdRule {
return &ThresholdRule{
threshold: max,
operator: lessEqualThan,
message: fmt.Sprintf("must be no greater than %v", max),
}
} | [
"func",
"Max",
"(",
"max",
"interface",
"{",
"}",
")",
"*",
"ThresholdRule",
"{",
"return",
"&",
"ThresholdRule",
"{",
"threshold",
":",
"max",
",",
"operator",
":",
"lessEqualThan",
",",
"message",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ma... | // Max is a validation rule that checks if a value is less or equal than the specified value.
// By calling Exclusive, the rule will check if the value is strictly less than the specified value.
// Note that the value being checked and the threshold value must be of the same type.
// Only int, uint, float and time.Time... | [
"Max",
"is",
"a",
"validation",
"rule",
"that",
"checks",
"if",
"a",
"value",
"is",
"less",
"or",
"equal",
"than",
"the",
"specified",
"value",
".",
"By",
"calling",
"Exclusive",
"the",
"rule",
"will",
"check",
"if",
"the",
"value",
"is",
"strictly",
"le... | 2f76ea62300c36e72bd56c804484cb6db53b69a5 | https://github.com/go-ozzo/ozzo-validation/blob/2f76ea62300c36e72bd56c804484cb6db53b69a5/minmax.go#L45-L51 |
141,246 | go-ozzo/ozzo-validation | minmax.go | Exclusive | func (r *ThresholdRule) Exclusive() *ThresholdRule {
if r.operator == greaterEqualThan {
r.operator = greaterThan
r.message = fmt.Sprintf("must be greater than %v", r.threshold)
} else if r.operator == lessEqualThan {
r.operator = lessThan
r.message = fmt.Sprintf("must be less than %v", r.threshold)
}
retur... | go | func (r *ThresholdRule) Exclusive() *ThresholdRule {
if r.operator == greaterEqualThan {
r.operator = greaterThan
r.message = fmt.Sprintf("must be greater than %v", r.threshold)
} else if r.operator == lessEqualThan {
r.operator = lessThan
r.message = fmt.Sprintf("must be less than %v", r.threshold)
}
retur... | [
"func",
"(",
"r",
"*",
"ThresholdRule",
")",
"Exclusive",
"(",
")",
"*",
"ThresholdRule",
"{",
"if",
"r",
".",
"operator",
"==",
"greaterEqualThan",
"{",
"r",
".",
"operator",
"=",
"greaterThan",
"\n",
"r",
".",
"message",
"=",
"fmt",
".",
"Sprintf",
"... | // Exclusive sets the comparison to exclude the boundary value. | [
"Exclusive",
"sets",
"the",
"comparison",
"to",
"exclude",
"the",
"boundary",
"value",
"."
] | 2f76ea62300c36e72bd56c804484cb6db53b69a5 | https://github.com/go-ozzo/ozzo-validation/blob/2f76ea62300c36e72bd56c804484cb6db53b69a5/minmax.go#L54-L63 |
141,247 | go-ozzo/ozzo-validation | length.go | Length | func Length(min, max int) *LengthRule {
message := "the value must be empty"
if min == 0 && max > 0 {
message = fmt.Sprintf("the length must be no more than %v", max)
} else if min > 0 && max == 0 {
message = fmt.Sprintf("the length must be no less than %v", min)
} else if min > 0 && max > 0 {
if min == max {... | go | func Length(min, max int) *LengthRule {
message := "the value must be empty"
if min == 0 && max > 0 {
message = fmt.Sprintf("the length must be no more than %v", max)
} else if min > 0 && max == 0 {
message = fmt.Sprintf("the length must be no less than %v", min)
} else if min > 0 && max > 0 {
if min == max {... | [
"func",
"Length",
"(",
"min",
",",
"max",
"int",
")",
"*",
"LengthRule",
"{",
"message",
":=",
"\"",
"\"",
"\n",
"if",
"min",
"==",
"0",
"&&",
"max",
">",
"0",
"{",
"message",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"max",
")",
"\n",
... | // Length returns a validation rule that checks if a value's length is within the specified range.
// If max is 0, it means there is no upper bound for the length.
// This rule should only be used for validating strings, slices, maps, and arrays.
// An empty value is considered valid. Use the Required rule to make sure... | [
"Length",
"returns",
"a",
"validation",
"rule",
"that",
"checks",
"if",
"a",
"value",
"s",
"length",
"is",
"within",
"the",
"specified",
"range",
".",
"If",
"max",
"is",
"0",
"it",
"means",
"there",
"is",
"no",
"upper",
"bound",
"for",
"the",
"length",
... | 2f76ea62300c36e72bd56c804484cb6db53b69a5 | https://github.com/go-ozzo/ozzo-validation/blob/2f76ea62300c36e72bd56c804484cb6db53b69a5/length.go#L17-L35 |
141,248 | go-ozzo/ozzo-validation | length.go | RuneLength | func RuneLength(min, max int) *LengthRule {
r := Length(min, max)
r.rune = true
return r
} | go | func RuneLength(min, max int) *LengthRule {
r := Length(min, max)
r.rune = true
return r
} | [
"func",
"RuneLength",
"(",
"min",
",",
"max",
"int",
")",
"*",
"LengthRule",
"{",
"r",
":=",
"Length",
"(",
"min",
",",
"max",
")",
"\n",
"r",
".",
"rune",
"=",
"true",
"\n",
"return",
"r",
"\n",
"}"
] | // RuneLength returns a validation rule that checks if a string's rune length is within the specified range.
// If max is 0, it means there is no upper bound for the length.
// This rule should only be used for validating strings, slices, maps, and arrays.
// An empty value is considered valid. Use the Required rule to... | [
"RuneLength",
"returns",
"a",
"validation",
"rule",
"that",
"checks",
"if",
"a",
"string",
"s",
"rune",
"length",
"is",
"within",
"the",
"specified",
"range",
".",
"If",
"max",
"is",
"0",
"it",
"means",
"there",
"is",
"no",
"upper",
"bound",
"for",
"the"... | 2f76ea62300c36e72bd56c804484cb6db53b69a5 | https://github.com/go-ozzo/ozzo-validation/blob/2f76ea62300c36e72bd56c804484cb6db53b69a5/length.go#L42-L46 |
141,249 | go-ozzo/ozzo-validation | struct.go | Field | func Field(fieldPtr interface{}, rules ...Rule) *FieldRules {
return &FieldRules{
fieldPtr: fieldPtr,
rules: rules,
}
} | go | func Field(fieldPtr interface{}, rules ...Rule) *FieldRules {
return &FieldRules{
fieldPtr: fieldPtr,
rules: rules,
}
} | [
"func",
"Field",
"(",
"fieldPtr",
"interface",
"{",
"}",
",",
"rules",
"...",
"Rule",
")",
"*",
"FieldRules",
"{",
"return",
"&",
"FieldRules",
"{",
"fieldPtr",
":",
"fieldPtr",
",",
"rules",
":",
"rules",
",",
"}",
"\n",
"}"
] | // Field specifies a struct field and the corresponding validation rules.
// The struct field must be specified as a pointer to it. | [
"Field",
"specifies",
"a",
"struct",
"field",
"and",
"the",
"corresponding",
"validation",
"rules",
".",
"The",
"struct",
"field",
"must",
"be",
"specified",
"as",
"a",
"pointer",
"to",
"it",
"."
] | 2f76ea62300c36e72bd56c804484cb6db53b69a5 | https://github.com/go-ozzo/ozzo-validation/blob/2f76ea62300c36e72bd56c804484cb6db53b69a5/struct.go#L109-L114 |
141,250 | go-ozzo/ozzo-validation | struct.go | findStructField | func findStructField(structValue reflect.Value, fieldValue reflect.Value) *reflect.StructField {
ptr := fieldValue.Pointer()
for i := structValue.NumField() - 1; i >= 0; i-- {
sf := structValue.Type().Field(i)
if ptr == structValue.Field(i).UnsafeAddr() {
// do additional type comparison because it's possible ... | go | func findStructField(structValue reflect.Value, fieldValue reflect.Value) *reflect.StructField {
ptr := fieldValue.Pointer()
for i := structValue.NumField() - 1; i >= 0; i-- {
sf := structValue.Type().Field(i)
if ptr == structValue.Field(i).UnsafeAddr() {
// do additional type comparison because it's possible ... | [
"func",
"findStructField",
"(",
"structValue",
"reflect",
".",
"Value",
",",
"fieldValue",
"reflect",
".",
"Value",
")",
"*",
"reflect",
".",
"StructField",
"{",
"ptr",
":=",
"fieldValue",
".",
"Pointer",
"(",
")",
"\n",
"for",
"i",
":=",
"structValue",
".... | // findStructField looks for a field in the given struct.
// The field being looked for should be a pointer to the actual struct field.
// If found, the field info will be returned. Otherwise, nil will be returned. | [
"findStructField",
"looks",
"for",
"a",
"field",
"in",
"the",
"given",
"struct",
".",
"The",
"field",
"being",
"looked",
"for",
"should",
"be",
"a",
"pointer",
"to",
"the",
"actual",
"struct",
"field",
".",
"If",
"found",
"the",
"field",
"info",
"will",
... | 2f76ea62300c36e72bd56c804484cb6db53b69a5 | https://github.com/go-ozzo/ozzo-validation/blob/2f76ea62300c36e72bd56c804484cb6db53b69a5/struct.go#L119-L144 |
141,251 | go-ozzo/ozzo-validation | struct.go | getErrorFieldName | func getErrorFieldName(f *reflect.StructField) string {
if tag := f.Tag.Get(ErrorTag); tag != "" {
if cps := strings.SplitN(tag, ",", 2); cps[0] != "" {
return cps[0]
}
}
return f.Name
} | go | func getErrorFieldName(f *reflect.StructField) string {
if tag := f.Tag.Get(ErrorTag); tag != "" {
if cps := strings.SplitN(tag, ",", 2); cps[0] != "" {
return cps[0]
}
}
return f.Name
} | [
"func",
"getErrorFieldName",
"(",
"f",
"*",
"reflect",
".",
"StructField",
")",
"string",
"{",
"if",
"tag",
":=",
"f",
".",
"Tag",
".",
"Get",
"(",
"ErrorTag",
")",
";",
"tag",
"!=",
"\"",
"\"",
"{",
"if",
"cps",
":=",
"strings",
".",
"SplitN",
"("... | // getErrorFieldName returns the name that should be used to represent the validation error of a struct field. | [
"getErrorFieldName",
"returns",
"the",
"name",
"that",
"should",
"be",
"used",
"to",
"represent",
"the",
"validation",
"error",
"of",
"a",
"struct",
"field",
"."
] | 2f76ea62300c36e72bd56c804484cb6db53b69a5 | https://github.com/go-ozzo/ozzo-validation/blob/2f76ea62300c36e72bd56c804484cb6db53b69a5/struct.go#L147-L154 |
141,252 | containers/storage | drivers/btrfs/btrfs.go | Metadata | func (d *Driver) Metadata(id string) (map[string]string, error) {
return nil, nil
} | go | func (d *Driver) Metadata(id string) (map[string]string, error) {
return nil, nil
} | [
"func",
"(",
"d",
"*",
"Driver",
")",
"Metadata",
"(",
"id",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}"
] | // Metadata returns empty metadata for this driver. | [
"Metadata",
"returns",
"empty",
"metadata",
"for",
"this",
"driver",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/btrfs/btrfs.go#L153-L155 |
141,253 | containers/storage | drivers/btrfs/btrfs.go | Remove | func (d *Driver) Remove(id string) error {
dir := d.subvolumesDirID(id)
if _, err := os.Stat(dir); err != nil {
return err
}
quotasDir := d.quotasDirID(id)
if _, err := os.Stat(quotasDir); err == nil {
if err := os.Remove(quotasDir); err != nil {
return err
}
} else if !os.IsNotExist(err) {
return err
... | go | func (d *Driver) Remove(id string) error {
dir := d.subvolumesDirID(id)
if _, err := os.Stat(dir); err != nil {
return err
}
quotasDir := d.quotasDirID(id)
if _, err := os.Stat(quotasDir); err == nil {
if err := os.Remove(quotasDir); err != nil {
return err
}
} else if !os.IsNotExist(err) {
return err
... | [
"func",
"(",
"d",
"*",
"Driver",
")",
"Remove",
"(",
"id",
"string",
")",
"error",
"{",
"dir",
":=",
"d",
".",
"subvolumesDirID",
"(",
"id",
")",
"\n",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"dir",
")",
";",
"err",
"!=",
"nil",
... | // Remove the filesystem with given id. | [
"Remove",
"the",
"filesystem",
"with",
"given",
"id",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/btrfs/btrfs.go#L612-L639 |
141,254 | containers/storage | drivers/overlay/overlay.go | Metadata | func (d *Driver) Metadata(id string) (map[string]string, error) {
dir := d.dir(id)
if _, err := os.Stat(dir); err != nil {
return nil, err
}
metadata := map[string]string{
"WorkDir": path.Join(dir, "work"),
"MergedDir": path.Join(dir, "merged"),
"UpperDir": path.Join(dir, "diff"),
}
lowerDirs, err :=... | go | func (d *Driver) Metadata(id string) (map[string]string, error) {
dir := d.dir(id)
if _, err := os.Stat(dir); err != nil {
return nil, err
}
metadata := map[string]string{
"WorkDir": path.Join(dir, "work"),
"MergedDir": path.Join(dir, "merged"),
"UpperDir": path.Join(dir, "diff"),
}
lowerDirs, err :=... | [
"func",
"(",
"d",
"*",
"Driver",
")",
"Metadata",
"(",
"id",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"dir",
":=",
"d",
".",
"dir",
"(",
"id",
")",
"\n",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
... | // Metadata returns meta data about the overlay driver such as
// LowerDir, UpperDir, WorkDir and MergeDir used to store data. | [
"Metadata",
"returns",
"meta",
"data",
"about",
"the",
"overlay",
"driver",
"such",
"as",
"LowerDir",
"UpperDir",
"WorkDir",
"and",
"MergeDir",
"used",
"to",
"store",
"data",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/overlay/overlay.go#L397-L418 |
141,255 | containers/storage | drivers/overlay/overlay.go | recreateSymlinks | func (d *Driver) recreateSymlinks() error {
// List all the directories under the home directory
dirs, err := ioutil.ReadDir(d.home)
if err != nil {
return fmt.Errorf("error reading driver home directory %q: %v", d.home, err)
}
// This makes the link directory if it doesn't exist
rootUID, rootGID, err := idtool... | go | func (d *Driver) recreateSymlinks() error {
// List all the directories under the home directory
dirs, err := ioutil.ReadDir(d.home)
if err != nil {
return fmt.Errorf("error reading driver home directory %q: %v", d.home, err)
}
// This makes the link directory if it doesn't exist
rootUID, rootGID, err := idtool... | [
"func",
"(",
"d",
"*",
"Driver",
")",
"recreateSymlinks",
"(",
")",
"error",
"{",
"// List all the directories under the home directory",
"dirs",
",",
"err",
":=",
"ioutil",
".",
"ReadDir",
"(",
"d",
".",
"home",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"... | // recreateSymlinks goes through the driver's home directory and checks if the diff directory
// under each layer has a symlink created for it under the linkDir. If the symlink does not
// exist, it creates them | [
"recreateSymlinks",
"goes",
"through",
"the",
"driver",
"s",
"home",
"directory",
"and",
"checks",
"if",
"the",
"diff",
"directory",
"under",
"each",
"layer",
"has",
"a",
"symlink",
"created",
"for",
"it",
"under",
"the",
"linkDir",
".",
"If",
"the",
"symlin... | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/overlay/overlay.go#L699-L736 |
141,256 | containers/storage | drivers/overlay/overlay.go | UpdateLayerIDMap | func (d *Driver) UpdateLayerIDMap(id string, toContainer, toHost *idtools.IDMappings, mountLabel string) error {
var err error
dir := d.dir(id)
diffDir := filepath.Join(dir, "diff")
rootUID, rootGID := 0, 0
if toHost != nil {
rootUID, rootGID, err = idtools.GetRootUIDGID(toHost.UIDs(), toHost.GIDs())
if err !... | go | func (d *Driver) UpdateLayerIDMap(id string, toContainer, toHost *idtools.IDMappings, mountLabel string) error {
var err error
dir := d.dir(id)
diffDir := filepath.Join(dir, "diff")
rootUID, rootGID := 0, 0
if toHost != nil {
rootUID, rootGID, err = idtools.GetRootUIDGID(toHost.UIDs(), toHost.GIDs())
if err !... | [
"func",
"(",
"d",
"*",
"Driver",
")",
"UpdateLayerIDMap",
"(",
"id",
"string",
",",
"toContainer",
",",
"toHost",
"*",
"idtools",
".",
"IDMappings",
",",
"mountLabel",
"string",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"dir",
":=",
"d",
".",
"di... | // UpdateLayerIDMap updates ID mappings in a from matching the ones specified
// by toContainer to those specified by toHost. | [
"UpdateLayerIDMap",
"updates",
"ID",
"mappings",
"in",
"a",
"from",
"matching",
"the",
"ones",
"specified",
"by",
"toContainer",
"to",
"those",
"specified",
"by",
"toHost",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/overlay/overlay.go#L1069-L1122 |
141,257 | containers/storage | drivers/aufs/aufs.go | Metadata | func (a *Driver) Metadata(id string) (map[string]string, error) {
return nil, nil
} | go | func (a *Driver) Metadata(id string) (map[string]string, error) {
return nil, nil
} | [
"func",
"(",
"a",
"*",
"Driver",
")",
"Metadata",
"(",
"id",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}"
] | // Metadata not implemented | [
"Metadata",
"not",
"implemented"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/aufs/aufs.go#L238-L240 |
141,258 | containers/storage | drivers/aufs/aufs.go | CreateFromTemplate | func (a *Driver) CreateFromTemplate(id, template string, templateIDMappings *idtools.IDMappings, parent string, parentIDMappings *idtools.IDMappings, opts *graphdriver.CreateOpts, readWrite bool) error {
return graphdriver.NaiveCreateFromTemplate(a, id, template, templateIDMappings, parent, parentIDMappings, opts, rea... | go | func (a *Driver) CreateFromTemplate(id, template string, templateIDMappings *idtools.IDMappings, parent string, parentIDMappings *idtools.IDMappings, opts *graphdriver.CreateOpts, readWrite bool) error {
return graphdriver.NaiveCreateFromTemplate(a, id, template, templateIDMappings, parent, parentIDMappings, opts, rea... | [
"func",
"(",
"a",
"*",
"Driver",
")",
"CreateFromTemplate",
"(",
"id",
",",
"template",
"string",
",",
"templateIDMappings",
"*",
"idtools",
".",
"IDMappings",
",",
"parent",
"string",
",",
"parentIDMappings",
"*",
"idtools",
".",
"IDMappings",
",",
"opts",
... | // CreateFromTemplate creates a layer with the same contents and parent as another layer. | [
"CreateFromTemplate",
"creates",
"a",
"layer",
"with",
"the",
"same",
"contents",
"and",
"parent",
"as",
"another",
"layer",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/aufs/aufs.go#L257-L259 |
141,259 | containers/storage | drivers/aufs/aufs.go | Put | func (a *Driver) Put(id string) error {
a.locker.Lock(id)
defer a.locker.Unlock(id)
a.pathCacheLock.Lock()
m, exists := a.pathCache[id]
if !exists {
m = a.getMountpoint(id)
a.pathCache[id] = m
}
a.pathCacheLock.Unlock()
if count := a.ctr.Decrement(m); count > 0 {
return nil
}
err := a.unmount(m)
if er... | go | func (a *Driver) Put(id string) error {
a.locker.Lock(id)
defer a.locker.Unlock(id)
a.pathCacheLock.Lock()
m, exists := a.pathCache[id]
if !exists {
m = a.getMountpoint(id)
a.pathCache[id] = m
}
a.pathCacheLock.Unlock()
if count := a.ctr.Decrement(m); count > 0 {
return nil
}
err := a.unmount(m)
if er... | [
"func",
"(",
"a",
"*",
"Driver",
")",
"Put",
"(",
"id",
"string",
")",
"error",
"{",
"a",
".",
"locker",
".",
"Lock",
"(",
"id",
")",
"\n",
"defer",
"a",
".",
"locker",
".",
"Unlock",
"(",
"id",
")",
"\n",
"a",
".",
"pathCacheLock",
".",
"Lock"... | // Put unmounts and updates list of active mounts. | [
"Put",
"unmounts",
"and",
"updates",
"list",
"of",
"active",
"mounts",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/aufs/aufs.go#L461-L480 |
141,260 | containers/storage | pkg/chrootarchive/archive.go | NewArchiverWithChown | func NewArchiverWithChown(tarIDMappings *idtools.IDMappings, chownOpts *idtools.IDPair, untarIDMappings *idtools.IDMappings) *archive.Archiver {
archiver := archive.NewArchiverWithChown(tarIDMappings, chownOpts, untarIDMappings)
archiver.Untar = Untar
return archiver
} | go | func NewArchiverWithChown(tarIDMappings *idtools.IDMappings, chownOpts *idtools.IDPair, untarIDMappings *idtools.IDMappings) *archive.Archiver {
archiver := archive.NewArchiverWithChown(tarIDMappings, chownOpts, untarIDMappings)
archiver.Untar = Untar
return archiver
} | [
"func",
"NewArchiverWithChown",
"(",
"tarIDMappings",
"*",
"idtools",
".",
"IDMappings",
",",
"chownOpts",
"*",
"idtools",
".",
"IDPair",
",",
"untarIDMappings",
"*",
"idtools",
".",
"IDMappings",
")",
"*",
"archive",
".",
"Archiver",
"{",
"archiver",
":=",
"a... | // NewArchiverWithChown returns a new Archiver which uses chrootarchive.Untar and the provided ID mapping configuration on both ends | [
"NewArchiverWithChown",
"returns",
"a",
"new",
"Archiver",
"which",
"uses",
"chrootarchive",
".",
"Untar",
"and",
"the",
"provided",
"ID",
"mapping",
"configuration",
"on",
"both",
"ends"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/chrootarchive/archive.go#L26-L30 |
141,261 | containers/storage | pkg/chrootarchive/archive.go | CopyFileWithTarAndChown | func CopyFileWithTarAndChown(chownOpts *idtools.IDPair, hasher io.Writer, uidmap []idtools.IDMap, gidmap []idtools.IDMap) func(src, dest string) error {
untarMappings := idtools.NewIDMappingsFromMaps(uidmap, gidmap)
archiver := NewArchiverWithChown(nil, chownOpts, untarMappings)
if hasher != nil {
originalUntar :=... | go | func CopyFileWithTarAndChown(chownOpts *idtools.IDPair, hasher io.Writer, uidmap []idtools.IDMap, gidmap []idtools.IDMap) func(src, dest string) error {
untarMappings := idtools.NewIDMappingsFromMaps(uidmap, gidmap)
archiver := NewArchiverWithChown(nil, chownOpts, untarMappings)
if hasher != nil {
originalUntar :=... | [
"func",
"CopyFileWithTarAndChown",
"(",
"chownOpts",
"*",
"idtools",
".",
"IDPair",
",",
"hasher",
"io",
".",
"Writer",
",",
"uidmap",
"[",
"]",
"idtools",
".",
"IDMap",
",",
"gidmap",
"[",
"]",
"idtools",
".",
"IDMap",
")",
"func",
"(",
"src",
",",
"d... | // CopyFileWithTarAndChown returns a function which copies a single file from outside
// of any container into our working container, mapping permissions using the
// container's ID maps, possibly overridden using the passed-in chownOpts | [
"CopyFileWithTarAndChown",
"returns",
"a",
"function",
"which",
"copies",
"a",
"single",
"file",
"from",
"outside",
"of",
"any",
"container",
"into",
"our",
"working",
"container",
"mapping",
"permissions",
"using",
"the",
"container",
"s",
"ID",
"maps",
"possibly... | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/chrootarchive/archive.go#L86-L123 |
141,262 | containers/storage | pkg/chrootarchive/archive.go | CopyWithTarAndChown | func CopyWithTarAndChown(chownOpts *idtools.IDPair, hasher io.Writer, uidmap []idtools.IDMap, gidmap []idtools.IDMap) func(src, dest string) error {
untarMappings := idtools.NewIDMappingsFromMaps(uidmap, gidmap)
archiver := NewArchiverWithChown(nil, chownOpts, untarMappings)
if hasher != nil {
originalUntar := arc... | go | func CopyWithTarAndChown(chownOpts *idtools.IDPair, hasher io.Writer, uidmap []idtools.IDMap, gidmap []idtools.IDMap) func(src, dest string) error {
untarMappings := idtools.NewIDMappingsFromMaps(uidmap, gidmap)
archiver := NewArchiverWithChown(nil, chownOpts, untarMappings)
if hasher != nil {
originalUntar := arc... | [
"func",
"CopyWithTarAndChown",
"(",
"chownOpts",
"*",
"idtools",
".",
"IDPair",
",",
"hasher",
"io",
".",
"Writer",
",",
"uidmap",
"[",
"]",
"idtools",
".",
"IDMap",
",",
"gidmap",
"[",
"]",
"idtools",
".",
"IDMap",
")",
"func",
"(",
"src",
",",
"dest"... | // CopyWithTarAndChown returns a function which copies a directory tree from outside of
// any container into our working container, mapping permissions using the
// container's ID maps, possibly overridden using the passed-in chownOpts | [
"CopyWithTarAndChown",
"returns",
"a",
"function",
"which",
"copies",
"a",
"directory",
"tree",
"from",
"outside",
"of",
"any",
"container",
"into",
"our",
"working",
"container",
"mapping",
"permissions",
"using",
"the",
"container",
"s",
"ID",
"maps",
"possibly"... | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/chrootarchive/archive.go#L128-L138 |
141,263 | containers/storage | utils.go | ParseIDMapping | func ParseIDMapping(UIDMapSlice, GIDMapSlice []string, subUIDMap, subGIDMap string) (*IDMappingOptions, error) {
options := IDMappingOptions{
HostUIDMapping: true,
HostGIDMapping: true,
}
if subGIDMap == "" && subUIDMap != "" {
subGIDMap = subUIDMap
}
if subUIDMap == "" && subGIDMap != "" {
subUIDMap = sub... | go | func ParseIDMapping(UIDMapSlice, GIDMapSlice []string, subUIDMap, subGIDMap string) (*IDMappingOptions, error) {
options := IDMappingOptions{
HostUIDMapping: true,
HostGIDMapping: true,
}
if subGIDMap == "" && subUIDMap != "" {
subGIDMap = subUIDMap
}
if subUIDMap == "" && subGIDMap != "" {
subUIDMap = sub... | [
"func",
"ParseIDMapping",
"(",
"UIDMapSlice",
",",
"GIDMapSlice",
"[",
"]",
"string",
",",
"subUIDMap",
",",
"subGIDMap",
"string",
")",
"(",
"*",
"IDMappingOptions",
",",
"error",
")",
"{",
"options",
":=",
"IDMappingOptions",
"{",
"HostUIDMapping",
":",
"tru... | // ParseIDMapping takes idmappings and subuid and subgid maps and returns a storage mapping | [
"ParseIDMapping",
"takes",
"idmappings",
"and",
"subuid",
"and",
"subgid",
"maps",
"and",
"returns",
"a",
"storage",
"mapping"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/utils.go#L20-L69 |
141,264 | containers/storage | utils.go | GetRootlessRuntimeDir | func GetRootlessRuntimeDir(rootlessUid int) (string, error) {
runtimeDir := os.Getenv("XDG_RUNTIME_DIR")
if runtimeDir == "" {
tmpDir := fmt.Sprintf("/run/user/%d", rootlessUid)
st, err := system.Stat(tmpDir)
if err == nil && int(st.UID()) == os.Getuid() && st.Mode()&0700 == 0700 && st.Mode()&0066 == 0000 {
... | go | func GetRootlessRuntimeDir(rootlessUid int) (string, error) {
runtimeDir := os.Getenv("XDG_RUNTIME_DIR")
if runtimeDir == "" {
tmpDir := fmt.Sprintf("/run/user/%d", rootlessUid)
st, err := system.Stat(tmpDir)
if err == nil && int(st.UID()) == os.Getuid() && st.Mode()&0700 == 0700 && st.Mode()&0066 == 0000 {
... | [
"func",
"GetRootlessRuntimeDir",
"(",
"rootlessUid",
"int",
")",
"(",
"string",
",",
"error",
")",
"{",
"runtimeDir",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n",
"if",
"runtimeDir",
"==",
"\"",
"\"",
"{",
"tmpDir",
":=",
"fmt",
".",
"Sprintf... | // GetRootlessRuntimeDir returns the runtime directory when running as non root | [
"GetRootlessRuntimeDir",
"returns",
"the",
"runtime",
"directory",
"when",
"running",
"as",
"non",
"root"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/utils.go#L72-L96 |
141,265 | containers/storage | utils.go | getRootlessDirInfo | func getRootlessDirInfo(rootlessUid int) (string, string, error) {
rootlessRuntime, err := GetRootlessRuntimeDir(rootlessUid)
if err != nil {
return "", "", err
}
dataDir := os.Getenv("XDG_DATA_HOME")
if dataDir == "" {
home, err := homeDir()
if err != nil {
return "", "", errors.Wrapf(err, "neither XDG_... | go | func getRootlessDirInfo(rootlessUid int) (string, string, error) {
rootlessRuntime, err := GetRootlessRuntimeDir(rootlessUid)
if err != nil {
return "", "", err
}
dataDir := os.Getenv("XDG_DATA_HOME")
if dataDir == "" {
home, err := homeDir()
if err != nil {
return "", "", errors.Wrapf(err, "neither XDG_... | [
"func",
"getRootlessDirInfo",
"(",
"rootlessUid",
"int",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"rootlessRuntime",
",",
"err",
":=",
"GetRootlessRuntimeDir",
"(",
"rootlessUid",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
... | // getRootlessDirInfo returns the parent path of where the storage for containers and
// volumes will be in rootless mode | [
"getRootlessDirInfo",
"returns",
"the",
"parent",
"path",
"of",
"where",
"the",
"storage",
"for",
"containers",
"and",
"volumes",
"will",
"be",
"in",
"rootless",
"mode"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/utils.go#L100-L121 |
141,266 | containers/storage | utils.go | getRootlessStorageOpts | func getRootlessStorageOpts(rootlessUid int) (StoreOptions, error) {
var opts StoreOptions
dataDir, rootlessRuntime, err := getRootlessDirInfo(rootlessUid)
if err != nil {
return opts, err
}
opts.RunRoot = rootlessRuntime
opts.GraphRoot = filepath.Join(dataDir, "containers", "storage")
if path, err := exec.Lo... | go | func getRootlessStorageOpts(rootlessUid int) (StoreOptions, error) {
var opts StoreOptions
dataDir, rootlessRuntime, err := getRootlessDirInfo(rootlessUid)
if err != nil {
return opts, err
}
opts.RunRoot = rootlessRuntime
opts.GraphRoot = filepath.Join(dataDir, "containers", "storage")
if path, err := exec.Lo... | [
"func",
"getRootlessStorageOpts",
"(",
"rootlessUid",
"int",
")",
"(",
"StoreOptions",
",",
"error",
")",
"{",
"var",
"opts",
"StoreOptions",
"\n\n",
"dataDir",
",",
"rootlessRuntime",
",",
"err",
":=",
"getRootlessDirInfo",
"(",
"rootlessUid",
")",
"\n",
"if",
... | // getRootlessStorageOpts returns the storage opts for containers running as non root | [
"getRootlessStorageOpts",
"returns",
"the",
"storage",
"opts",
"for",
"containers",
"running",
"as",
"non",
"root"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/utils.go#L124-L140 |
141,267 | containers/storage | utils.go | DefaultStoreOptions | func DefaultStoreOptions(rootless bool, rootlessUid int) (StoreOptions, error) {
var (
defaultRootlessRunRoot string
defaultRootlessGraphRoot string
err error
)
storageOpts := defaultStoreOptions
if rootless && rootlessUid != 0 {
storageOpts, err = getRootlessStorageOpts(rootlessUid)
... | go | func DefaultStoreOptions(rootless bool, rootlessUid int) (StoreOptions, error) {
var (
defaultRootlessRunRoot string
defaultRootlessGraphRoot string
err error
)
storageOpts := defaultStoreOptions
if rootless && rootlessUid != 0 {
storageOpts, err = getRootlessStorageOpts(rootlessUid)
... | [
"func",
"DefaultStoreOptions",
"(",
"rootless",
"bool",
",",
"rootlessUid",
"int",
")",
"(",
"StoreOptions",
",",
"error",
")",
"{",
"var",
"(",
"defaultRootlessRunRoot",
"string",
"\n",
"defaultRootlessGraphRoot",
"string",
"\n",
"err",
"error",
"\n",
")",
"\n"... | // DefaultStoreOptions returns the default storage ops for containers | [
"DefaultStoreOptions",
"returns",
"the",
"default",
"storage",
"ops",
"for",
"containers"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/utils.go#L178-L238 |
141,268 | containers/storage | pkg/ostree/ostree.go | ConvertToOSTree | func ConvertToOSTree(repoLocation, root, id string) error {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
repo, err := otbuiltin.OpenRepo(repoLocation)
if err != nil {
return errors.Wrap(err, "could not open the OSTree repository")
}
skip, whiteouts, err := fixFiles(root, os.Getuid() != 0)
if err != n... | go | func ConvertToOSTree(repoLocation, root, id string) error {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
repo, err := otbuiltin.OpenRepo(repoLocation)
if err != nil {
return errors.Wrap(err, "could not open the OSTree repository")
}
skip, whiteouts, err := fixFiles(root, os.Getuid() != 0)
if err != n... | [
"func",
"ConvertToOSTree",
"(",
"repoLocation",
",",
"root",
",",
"id",
"string",
")",
"error",
"{",
"runtime",
".",
"LockOSThread",
"(",
")",
"\n",
"defer",
"runtime",
".",
"UnlockOSThread",
"(",
")",
"\n",
"repo",
",",
"err",
":=",
"otbuiltin",
".",
"O... | // Create prepares the filesystem for the OSTREE driver and copies the directory for the given id under the parent. | [
"Create",
"prepares",
"the",
"filesystem",
"for",
"the",
"OSTREE",
"driver",
"and",
"copies",
"the",
"directory",
"for",
"the",
"given",
"id",
"under",
"the",
"parent",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/ostree/ostree.go#L80-L141 |
141,269 | containers/storage | pkg/archive/copy.go | CopyInfoDestinationPath | func CopyInfoDestinationPath(path string) (info CopyInfo, err error) {
maxSymlinkIter := 10 // filepath.EvalSymlinks uses 255, but 10 already seems like a lot.
path = normalizePath(path)
originalPath := path
stat, err := os.Lstat(path)
if err == nil && stat.Mode()&os.ModeSymlink == 0 {
// The path exists and i... | go | func CopyInfoDestinationPath(path string) (info CopyInfo, err error) {
maxSymlinkIter := 10 // filepath.EvalSymlinks uses 255, but 10 already seems like a lot.
path = normalizePath(path)
originalPath := path
stat, err := os.Lstat(path)
if err == nil && stat.Mode()&os.ModeSymlink == 0 {
// The path exists and i... | [
"func",
"CopyInfoDestinationPath",
"(",
"path",
"string",
")",
"(",
"info",
"CopyInfo",
",",
"err",
"error",
")",
"{",
"maxSymlinkIter",
":=",
"10",
"// filepath.EvalSymlinks uses 255, but 10 already seems like a lot.",
"\n",
"path",
"=",
"normalizePath",
"(",
"path",
... | // CopyInfoDestinationPath stats the given path to create a CopyInfo
// struct representing that resource for the destination of an archive copy
// operation. The given path should be an absolute local path. | [
"CopyInfoDestinationPath",
"stats",
"the",
"given",
"path",
"to",
"create",
"a",
"CopyInfo",
"struct",
"representing",
"that",
"resource",
"for",
"the",
"destination",
"of",
"an",
"archive",
"copy",
"operation",
".",
"The",
"given",
"path",
"should",
"be",
"an",... | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/archive/copy.go#L165-L238 |
141,270 | containers/storage | pkg/archive/copy.go | CopyResource | func CopyResource(srcPath, dstPath string, followLink bool) error {
var (
srcInfo CopyInfo
err error
)
// Ensure in platform semantics
srcPath = normalizePath(srcPath)
dstPath = normalizePath(dstPath)
// Clean the source and destination paths.
srcPath = PreserveTrailingDotOrSeparator(filepath.Clean(src... | go | func CopyResource(srcPath, dstPath string, followLink bool) error {
var (
srcInfo CopyInfo
err error
)
// Ensure in platform semantics
srcPath = normalizePath(srcPath)
dstPath = normalizePath(dstPath)
// Clean the source and destination paths.
srcPath = PreserveTrailingDotOrSeparator(filepath.Clean(src... | [
"func",
"CopyResource",
"(",
"srcPath",
",",
"dstPath",
"string",
",",
"followLink",
"bool",
")",
"error",
"{",
"var",
"(",
"srcInfo",
"CopyInfo",
"\n",
"err",
"error",
"\n",
")",
"\n\n",
"// Ensure in platform semantics",
"srcPath",
"=",
"normalizePath",
"(",
... | // CopyResource performs an archive copy from the given source path to the
// given destination path. The source path MUST exist and the destination
// path's parent directory must exist. | [
"CopyResource",
"performs",
"an",
"archive",
"copy",
"from",
"the",
"given",
"source",
"path",
"to",
"the",
"given",
"destination",
"path",
".",
"The",
"source",
"path",
"MUST",
"exist",
"and",
"the",
"destination",
"path",
"s",
"parent",
"directory",
"must",
... | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/archive/copy.go#L357-L382 |
141,271 | containers/storage | pkg/archive/copy.go | ResolveHostSourcePath | func ResolveHostSourcePath(path string, followLink bool) (resolvedPath, rebaseName string, err error) {
if followLink {
resolvedPath, err = filepath.EvalSymlinks(path)
if err != nil {
return
}
resolvedPath, rebaseName = GetRebaseName(path, resolvedPath)
} else {
dirPath, basePath := filepath.Split(path)... | go | func ResolveHostSourcePath(path string, followLink bool) (resolvedPath, rebaseName string, err error) {
if followLink {
resolvedPath, err = filepath.EvalSymlinks(path)
if err != nil {
return
}
resolvedPath, rebaseName = GetRebaseName(path, resolvedPath)
} else {
dirPath, basePath := filepath.Split(path)... | [
"func",
"ResolveHostSourcePath",
"(",
"path",
"string",
",",
"followLink",
"bool",
")",
"(",
"resolvedPath",
",",
"rebaseName",
"string",
",",
"err",
"error",
")",
"{",
"if",
"followLink",
"{",
"resolvedPath",
",",
"err",
"=",
"filepath",
".",
"EvalSymlinks",
... | // ResolveHostSourcePath decides real path need to be copied with parameters such as
// whether to follow symbol link or not, if followLink is true, resolvedPath will return
// link target of any symbol link file, else it will only resolve symlink of directory
// but return symbol link file itself without resolving. | [
"ResolveHostSourcePath",
"decides",
"real",
"path",
"need",
"to",
"be",
"copied",
"with",
"parameters",
"such",
"as",
"whether",
"to",
"follow",
"symbol",
"link",
"or",
"not",
"if",
"followLink",
"is",
"true",
"resolvedPath",
"will",
"return",
"link",
"target",
... | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/archive/copy.go#L412-L437 |
141,272 | containers/storage | pkg/archive/copy.go | GetRebaseName | func GetRebaseName(path, resolvedPath string) (string, string) {
// linkTarget will have been cleaned (no trailing path separators and dot) so
// we can manually join it with them
var rebaseName string
if specifiesCurrentDir(path) && !specifiesCurrentDir(resolvedPath) {
resolvedPath += string(filepath.Separator) ... | go | func GetRebaseName(path, resolvedPath string) (string, string) {
// linkTarget will have been cleaned (no trailing path separators and dot) so
// we can manually join it with them
var rebaseName string
if specifiesCurrentDir(path) && !specifiesCurrentDir(resolvedPath) {
resolvedPath += string(filepath.Separator) ... | [
"func",
"GetRebaseName",
"(",
"path",
",",
"resolvedPath",
"string",
")",
"(",
"string",
",",
"string",
")",
"{",
"// linkTarget will have been cleaned (no trailing path separators and dot) so",
"// we can manually join it with them",
"var",
"rebaseName",
"string",
"\n",
"if"... | // GetRebaseName normalizes and compares path and resolvedPath,
// return completed resolved path and rebased file name | [
"GetRebaseName",
"normalizes",
"and",
"compares",
"path",
"and",
"resolvedPath",
"return",
"completed",
"resolved",
"path",
"and",
"rebased",
"file",
"name"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/archive/copy.go#L441-L461 |
141,273 | containers/storage | drivers/driver.go | isDriverNotSupported | func isDriverNotSupported(err error) bool {
cause := errors.Cause(err)
return cause == ErrNotSupported || cause == ErrPrerequisites || cause == ErrIncompatibleFS
} | go | func isDriverNotSupported(err error) bool {
cause := errors.Cause(err)
return cause == ErrNotSupported || cause == ErrPrerequisites || cause == ErrIncompatibleFS
} | [
"func",
"isDriverNotSupported",
"(",
"err",
"error",
")",
"bool",
"{",
"cause",
":=",
"errors",
".",
"Cause",
"(",
"err",
")",
"\n",
"return",
"cause",
"==",
"ErrNotSupported",
"||",
"cause",
"==",
"ErrPrerequisites",
"||",
"cause",
"==",
"ErrIncompatibleFS",
... | // isDriverNotSupported returns true if the error initializing
// the graph driver is a non-supported error. | [
"isDriverNotSupported",
"returns",
"true",
"if",
"the",
"error",
"initializing",
"the",
"graph",
"driver",
"is",
"a",
"non",
"-",
"supported",
"error",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/driver.go#L302-L305 |
141,274 | containers/storage | drivers/driver.go | scanPriorDrivers | func scanPriorDrivers(root string) map[string]bool {
driversMap := make(map[string]bool)
for driver := range drivers {
p := filepath.Join(root, driver)
if _, err := os.Stat(p); err == nil && driver != "vfs" {
driversMap[driver] = true
}
}
return driversMap
} | go | func scanPriorDrivers(root string) map[string]bool {
driversMap := make(map[string]bool)
for driver := range drivers {
p := filepath.Join(root, driver)
if _, err := os.Stat(p); err == nil && driver != "vfs" {
driversMap[driver] = true
}
}
return driversMap
} | [
"func",
"scanPriorDrivers",
"(",
"root",
"string",
")",
"map",
"[",
"string",
"]",
"bool",
"{",
"driversMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"bool",
")",
"\n\n",
"for",
"driver",
":=",
"range",
"drivers",
"{",
"p",
":=",
"filepath",
".",... | // scanPriorDrivers returns an un-ordered scan of directories of prior storage drivers | [
"scanPriorDrivers",
"returns",
"an",
"un",
"-",
"ordered",
"scan",
"of",
"directories",
"of",
"prior",
"storage",
"drivers"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/driver.go#L308-L318 |
141,275 | containers/storage | lockfile_unix.go | openLock | func openLock(path string, ro bool) (int, error) {
if ro {
return unix.Open(path, os.O_RDONLY, 0)
}
return unix.Open(path, os.O_RDWR|os.O_CREATE, unix.S_IRUSR|unix.S_IWUSR)
} | go | func openLock(path string, ro bool) (int, error) {
if ro {
return unix.Open(path, os.O_RDONLY, 0)
}
return unix.Open(path, os.O_RDWR|os.O_CREATE, unix.S_IRUSR|unix.S_IWUSR)
} | [
"func",
"openLock",
"(",
"path",
"string",
",",
"ro",
"bool",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"ro",
"{",
"return",
"unix",
".",
"Open",
"(",
"path",
",",
"os",
".",
"O_RDONLY",
",",
"0",
")",
"\n",
"}",
"\n",
"return",
"unix",
".... | // openLock opens the file at path and returns the corresponding file
// descriptor. Note that the path is opened read-only when ro is set. If ro
// is unset, openLock will open the path read-write and create the file if
// necessary. | [
"openLock",
"opens",
"the",
"file",
"at",
"path",
"and",
"returns",
"the",
"corresponding",
"file",
"descriptor",
".",
"Note",
"that",
"the",
"path",
"is",
"opened",
"read",
"-",
"only",
"when",
"ro",
"is",
"set",
".",
"If",
"ro",
"is",
"unset",
"openLoc... | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/lockfile_unix.go#L34-L39 |
141,276 | containers/storage | lockfile_unix.go | Unlock | func (l *lockfile) Unlock() {
lk := unix.Flock_t{
Type: unix.F_UNLCK,
Whence: int16(os.SEEK_SET),
Start: 0,
Len: 0,
Pid: int32(os.Getpid()),
}
l.stateMutex.Lock()
if l.locked == false {
// Panic when unlocking an unlocked lock. That's a violation
// of the lock semantics and will reveal such... | go | func (l *lockfile) Unlock() {
lk := unix.Flock_t{
Type: unix.F_UNLCK,
Whence: int16(os.SEEK_SET),
Start: 0,
Len: 0,
Pid: int32(os.Getpid()),
}
l.stateMutex.Lock()
if l.locked == false {
// Panic when unlocking an unlocked lock. That's a violation
// of the lock semantics and will reveal such... | [
"func",
"(",
"l",
"*",
"lockfile",
")",
"Unlock",
"(",
")",
"{",
"lk",
":=",
"unix",
".",
"Flock_t",
"{",
"Type",
":",
"unix",
".",
"F_UNLCK",
",",
"Whence",
":",
"int16",
"(",
"os",
".",
"SEEK_SET",
")",
",",
"Start",
":",
"0",
",",
"Len",
":"... | // Unlock unlocks the lockfile. | [
"Unlock",
"unlocks",
"the",
"lockfile",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/lockfile_unix.go#L132-L170 |
141,277 | containers/storage | lockfile_unix.go | Locked | func (l *lockfile) Locked() bool {
l.stateMutex.Lock()
defer l.stateMutex.Unlock()
return l.locked && (l.locktype == unix.F_WRLCK)
} | go | func (l *lockfile) Locked() bool {
l.stateMutex.Lock()
defer l.stateMutex.Unlock()
return l.locked && (l.locktype == unix.F_WRLCK)
} | [
"func",
"(",
"l",
"*",
"lockfile",
")",
"Locked",
"(",
")",
"bool",
"{",
"l",
".",
"stateMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"l",
".",
"stateMutex",
".",
"Unlock",
"(",
")",
"\n",
"return",
"l",
".",
"locked",
"&&",
"(",
"l",
".",
"lo... | // Locked checks if lockfile is locked for writing by a thread in this process. | [
"Locked",
"checks",
"if",
"lockfile",
"is",
"locked",
"for",
"writing",
"by",
"a",
"thread",
"in",
"this",
"process",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/lockfile_unix.go#L173-L177 |
141,278 | containers/storage | lockfile_unix.go | Touch | func (l *lockfile) Touch() error {
l.stateMutex.Lock()
if !l.locked || (l.locktype != unix.F_WRLCK) {
panic("attempted to update last-writer in lockfile without the write lock")
}
l.stateMutex.Unlock()
l.lw = stringid.GenerateRandomID()
id := []byte(l.lw)
_, err := unix.Seek(int(l.fd), 0, os.SEEK_SET)
if err ... | go | func (l *lockfile) Touch() error {
l.stateMutex.Lock()
if !l.locked || (l.locktype != unix.F_WRLCK) {
panic("attempted to update last-writer in lockfile without the write lock")
}
l.stateMutex.Unlock()
l.lw = stringid.GenerateRandomID()
id := []byte(l.lw)
_, err := unix.Seek(int(l.fd), 0, os.SEEK_SET)
if err ... | [
"func",
"(",
"l",
"*",
"lockfile",
")",
"Touch",
"(",
")",
"error",
"{",
"l",
".",
"stateMutex",
".",
"Lock",
"(",
")",
"\n",
"if",
"!",
"l",
".",
"locked",
"||",
"(",
"l",
".",
"locktype",
"!=",
"unix",
".",
"F_WRLCK",
")",
"{",
"panic",
"(",
... | // Touch updates the lock file with the UID of the user. | [
"Touch",
"updates",
"the",
"lock",
"file",
"with",
"the",
"UID",
"of",
"the",
"user",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/lockfile_unix.go#L180-L204 |
141,279 | containers/storage | lockfile_unix.go | Modified | func (l *lockfile) Modified() (bool, error) {
id := []byte(l.lw)
l.stateMutex.Lock()
if !l.locked {
panic("attempted to check last-writer in lockfile without locking it first")
}
l.stateMutex.Unlock()
_, err := unix.Seek(int(l.fd), 0, os.SEEK_SET)
if err != nil {
return true, err
}
n, err := unix.Read(int(... | go | func (l *lockfile) Modified() (bool, error) {
id := []byte(l.lw)
l.stateMutex.Lock()
if !l.locked {
panic("attempted to check last-writer in lockfile without locking it first")
}
l.stateMutex.Unlock()
_, err := unix.Seek(int(l.fd), 0, os.SEEK_SET)
if err != nil {
return true, err
}
n, err := unix.Read(int(... | [
"func",
"(",
"l",
"*",
"lockfile",
")",
"Modified",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"id",
":=",
"[",
"]",
"byte",
"(",
"l",
".",
"lw",
")",
"\n",
"l",
".",
"stateMutex",
".",
"Lock",
"(",
")",
"\n",
"if",
"!",
"l",
".",
"lock... | // Modified indicates if the lockfile has been updated since the last time it
// was loaded. | [
"Modified",
"indicates",
"if",
"the",
"lockfile",
"has",
"been",
"updated",
"since",
"the",
"last",
"time",
"it",
"was",
"loaded",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/lockfile_unix.go#L208-L229 |
141,280 | containers/storage | pkg/idtools/parser.go | ParseIDMap | func ParseIDMap(mapSpec []string, mapSetting string) (idmap []IDMap, err error) {
stdErr := fmt.Errorf("error initializing ID mappings: %s setting is malformed", mapSetting)
for _, idMapSpec := range mapSpec {
idSpec := strings.Fields(strings.Map(nonDigitsToWhitespace, idMapSpec))
if len(idSpec)%3 != 0 {
retur... | go | func ParseIDMap(mapSpec []string, mapSetting string) (idmap []IDMap, err error) {
stdErr := fmt.Errorf("error initializing ID mappings: %s setting is malformed", mapSetting)
for _, idMapSpec := range mapSpec {
idSpec := strings.Fields(strings.Map(nonDigitsToWhitespace, idMapSpec))
if len(idSpec)%3 != 0 {
retur... | [
"func",
"ParseIDMap",
"(",
"mapSpec",
"[",
"]",
"string",
",",
"mapSetting",
"string",
")",
"(",
"idmap",
"[",
"]",
"IDMap",
",",
"err",
"error",
")",
"{",
"stdErr",
":=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"mapSetting",
")",
"\n",
"for",
... | // ParseIDMap parses idmap triples from string. | [
"ParseIDMap",
"parses",
"idmap",
"triples",
"from",
"string",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/idtools/parser.go#L35-L63 |
141,281 | containers/storage | pkg/system/meminfo_solaris.go | getTotalMem | func getTotalMem() int64 {
pagesize := C.sysconf(C._SC_PAGESIZE)
npages := C.sysconf(C._SC_PHYS_PAGES)
return int64(pagesize * npages)
} | go | func getTotalMem() int64 {
pagesize := C.sysconf(C._SC_PAGESIZE)
npages := C.sysconf(C._SC_PHYS_PAGES)
return int64(pagesize * npages)
} | [
"func",
"getTotalMem",
"(",
")",
"int64",
"{",
"pagesize",
":=",
"C",
".",
"sysconf",
"(",
"C",
".",
"_SC_PAGESIZE",
")",
"\n",
"npages",
":=",
"C",
".",
"sysconf",
"(",
"C",
".",
"_SC_PHYS_PAGES",
")",
"\n",
"return",
"int64",
"(",
"pagesize",
"*",
... | // Get the system memory info using sysconf same as prtconf | [
"Get",
"the",
"system",
"memory",
"info",
"using",
"sysconf",
"same",
"as",
"prtconf"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/system/meminfo_solaris.go#L70-L74 |
141,282 | containers/storage | pkg/pools/pools.go | newBufioReaderPoolWithSize | func newBufioReaderPoolWithSize(size int) *BufioReaderPool {
pool := &sync.Pool{
New: func() interface{} { return bufio.NewReaderSize(nil, size) },
}
return &BufioReaderPool{pool: pool}
} | go | func newBufioReaderPoolWithSize(size int) *BufioReaderPool {
pool := &sync.Pool{
New: func() interface{} { return bufio.NewReaderSize(nil, size) },
}
return &BufioReaderPool{pool: pool}
} | [
"func",
"newBufioReaderPoolWithSize",
"(",
"size",
"int",
")",
"*",
"BufioReaderPool",
"{",
"pool",
":=",
"&",
"sync",
".",
"Pool",
"{",
"New",
":",
"func",
"(",
")",
"interface",
"{",
"}",
"{",
"return",
"bufio",
".",
"NewReaderSize",
"(",
"nil",
",",
... | // newBufioReaderPoolWithSize is unexported because new pools should be
// added here to be shared where required. | [
"newBufioReaderPoolWithSize",
"is",
"unexported",
"because",
"new",
"pools",
"should",
"be",
"added",
"here",
"to",
"be",
"shared",
"where",
"required",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/pools/pools.go#L41-L46 |
141,283 | containers/storage | pkg/pools/pools.go | Copy | func Copy(dst io.Writer, src io.Reader) (written int64, err error) {
buf := BufioReader32KPool.Get(src)
written, err = io.Copy(dst, buf)
BufioReader32KPool.Put(buf)
return
} | go | func Copy(dst io.Writer, src io.Reader) (written int64, err error) {
buf := BufioReader32KPool.Get(src)
written, err = io.Copy(dst, buf)
BufioReader32KPool.Put(buf)
return
} | [
"func",
"Copy",
"(",
"dst",
"io",
".",
"Writer",
",",
"src",
"io",
".",
"Reader",
")",
"(",
"written",
"int64",
",",
"err",
"error",
")",
"{",
"buf",
":=",
"BufioReader32KPool",
".",
"Get",
"(",
"src",
")",
"\n",
"written",
",",
"err",
"=",
"io",
... | // Copy is a convenience wrapper which uses a buffer to avoid allocation in io.Copy. | [
"Copy",
"is",
"a",
"convenience",
"wrapper",
"which",
"uses",
"a",
"buffer",
"to",
"avoid",
"allocation",
"in",
"io",
".",
"Copy",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/pools/pools.go#L62-L67 |
141,284 | containers/storage | drivers/quota/projectquota.go | setProjectID | func setProjectID(targetPath string, projectID uint32) error {
dir, err := openDir(targetPath)
if err != nil {
return err
}
defer closeDir(dir)
var fsx C.struct_fsxattr
_, _, errno := unix.Syscall(unix.SYS_IOCTL, getDirFd(dir), C.FS_IOC_FSGETXATTR,
uintptr(unsafe.Pointer(&fsx)))
if errno != 0 {
return fmt... | go | func setProjectID(targetPath string, projectID uint32) error {
dir, err := openDir(targetPath)
if err != nil {
return err
}
defer closeDir(dir)
var fsx C.struct_fsxattr
_, _, errno := unix.Syscall(unix.SYS_IOCTL, getDirFd(dir), C.FS_IOC_FSGETXATTR,
uintptr(unsafe.Pointer(&fsx)))
if errno != 0 {
return fmt... | [
"func",
"setProjectID",
"(",
"targetPath",
"string",
",",
"projectID",
"uint32",
")",
"error",
"{",
"dir",
",",
"err",
":=",
"openDir",
"(",
"targetPath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"closeDir",
... | // setProjectID - set the project id of path on xfs | [
"setProjectID",
"-",
"set",
"the",
"project",
"id",
"of",
"path",
"on",
"xfs"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/quota/projectquota.go#L244-L266 |
141,285 | containers/storage | drivers/quota/projectquota.go | findNextProjectID | func (q *Control) findNextProjectID(home string) error {
files, err := ioutil.ReadDir(home)
if err != nil {
return fmt.Errorf("read directory failed : %s", home)
}
for _, file := range files {
if !file.IsDir() {
continue
}
path := filepath.Join(home, file.Name())
projid, err := getProjectID(path)
if ... | go | func (q *Control) findNextProjectID(home string) error {
files, err := ioutil.ReadDir(home)
if err != nil {
return fmt.Errorf("read directory failed : %s", home)
}
for _, file := range files {
if !file.IsDir() {
continue
}
path := filepath.Join(home, file.Name())
projid, err := getProjectID(path)
if ... | [
"func",
"(",
"q",
"*",
"Control",
")",
"findNextProjectID",
"(",
"home",
"string",
")",
"error",
"{",
"files",
",",
"err",
":=",
"ioutil",
".",
"ReadDir",
"(",
"home",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"... | // findNextProjectID - find the next project id to be used for containers
// by scanning driver home directory to find used project ids | [
"findNextProjectID",
"-",
"find",
"the",
"next",
"project",
"id",
"to",
"be",
"used",
"for",
"containers",
"by",
"scanning",
"driver",
"home",
"directory",
"to",
"find",
"used",
"project",
"ids"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/quota/projectquota.go#L270-L293 |
141,286 | containers/storage | drivers/template.go | NaiveCreateFromTemplate | func NaiveCreateFromTemplate(d TemplateDriver, id, template string, templateIDMappings *idtools.IDMappings, parent string, parentIDMappings *idtools.IDMappings, opts *CreateOpts, readWrite bool) error {
var err error
if readWrite {
err = d.CreateReadWrite(id, parent, opts)
} else {
err = d.Create(id, parent, opt... | go | func NaiveCreateFromTemplate(d TemplateDriver, id, template string, templateIDMappings *idtools.IDMappings, parent string, parentIDMappings *idtools.IDMappings, opts *CreateOpts, readWrite bool) error {
var err error
if readWrite {
err = d.CreateReadWrite(id, parent, opts)
} else {
err = d.Create(id, parent, opt... | [
"func",
"NaiveCreateFromTemplate",
"(",
"d",
"TemplateDriver",
",",
"id",
",",
"template",
"string",
",",
"templateIDMappings",
"*",
"idtools",
".",
"IDMappings",
",",
"parent",
"string",
",",
"parentIDMappings",
"*",
"idtools",
".",
"IDMappings",
",",
"opts",
"... | // CreateFromTemplate creates a layer with the same contents and parent as
// another layer. Internally, it may even depend on that other layer
// continuing to exist, as if it were actually a child of the child layer. | [
"CreateFromTemplate",
"creates",
"a",
"layer",
"with",
"the",
"same",
"contents",
"and",
"parent",
"as",
"another",
"layer",
".",
"Internally",
"it",
"may",
"even",
"depend",
"on",
"that",
"other",
"layer",
"continuing",
"to",
"exist",
"as",
"if",
"it",
"wer... | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/template.go#L21-L45 |
141,287 | containers/storage | pkg/stringutils/stringutils.go | GenerateRandomASCIIString | func GenerateRandomASCIIString(n int) string {
chars := "abcdefghijklmnopqrstuvwxyz" +
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"~!@#$%^&*()-_+={}[]\\|<,>.?/\"';:` "
res := make([]byte, n)
for i := 0; i < n; i++ {
res[i] = chars[rand.Intn(len(chars))]
}
return string(res)
} | go | func GenerateRandomASCIIString(n int) string {
chars := "abcdefghijklmnopqrstuvwxyz" +
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"~!@#$%^&*()-_+={}[]\\|<,>.?/\"';:` "
res := make([]byte, n)
for i := 0; i < n; i++ {
res[i] = chars[rand.Intn(len(chars))]
}
return string(res)
} | [
"func",
"GenerateRandomASCIIString",
"(",
"n",
"int",
")",
"string",
"{",
"chars",
":=",
"\"",
"\"",
"+",
"\"",
"\"",
"+",
"\"",
"\\\\",
"\\\"",
"\"",
"\n",
"res",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"n",
")",
"\n",
"for",
"i",
":=",
"0",
... | // GenerateRandomASCIIString generates an ASCII random string with length n. | [
"GenerateRandomASCIIString",
"generates",
"an",
"ASCII",
"random",
"string",
"with",
"length",
"n",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/stringutils/stringutils.go#L22-L31 |
141,288 | containers/storage | pkg/stringutils/stringutils.go | Truncate | func Truncate(s string, maxlen int) string {
r := []rune(s)
if len(r) <= maxlen {
return s
}
return string(r[:maxlen])
} | go | func Truncate(s string, maxlen int) string {
r := []rune(s)
if len(r) <= maxlen {
return s
}
return string(r[:maxlen])
} | [
"func",
"Truncate",
"(",
"s",
"string",
",",
"maxlen",
"int",
")",
"string",
"{",
"r",
":=",
"[",
"]",
"rune",
"(",
"s",
")",
"\n",
"if",
"len",
"(",
"r",
")",
"<=",
"maxlen",
"{",
"return",
"s",
"\n",
"}",
"\n",
"return",
"string",
"(",
"r",
... | // Truncate truncates a string to maxlen. | [
"Truncate",
"truncates",
"a",
"string",
"to",
"maxlen",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/stringutils/stringutils.go#L47-L53 |
141,289 | containers/storage | pkg/stringutils/stringutils.go | InSlice | func InSlice(slice []string, s string) bool {
for _, ss := range slice {
if strings.ToLower(s) == strings.ToLower(ss) {
return true
}
}
return false
} | go | func InSlice(slice []string, s string) bool {
for _, ss := range slice {
if strings.ToLower(s) == strings.ToLower(ss) {
return true
}
}
return false
} | [
"func",
"InSlice",
"(",
"slice",
"[",
"]",
"string",
",",
"s",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"ss",
":=",
"range",
"slice",
"{",
"if",
"strings",
".",
"ToLower",
"(",
"s",
")",
"==",
"strings",
".",
"ToLower",
"(",
"ss",
")",
"{",
... | // InSlice tests whether a string is contained in a slice of strings or not.
// Comparison is case insensitive | [
"InSlice",
"tests",
"whether",
"a",
"string",
"is",
"contained",
"in",
"a",
"slice",
"of",
"strings",
"or",
"not",
".",
"Comparison",
"is",
"case",
"insensitive"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/stringutils/stringutils.go#L57-L64 |
141,290 | containers/storage | pkg/stringutils/stringutils.go | ShellQuoteArguments | func ShellQuoteArguments(args []string) string {
var buf bytes.Buffer
for i, arg := range args {
if i != 0 {
buf.WriteByte(' ')
}
quote(arg, &buf)
}
return buf.String()
} | go | func ShellQuoteArguments(args []string) string {
var buf bytes.Buffer
for i, arg := range args {
if i != 0 {
buf.WriteByte(' ')
}
quote(arg, &buf)
}
return buf.String()
} | [
"func",
"ShellQuoteArguments",
"(",
"args",
"[",
"]",
"string",
")",
"string",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"for",
"i",
",",
"arg",
":=",
"range",
"args",
"{",
"if",
"i",
"!=",
"0",
"{",
"buf",
".",
"WriteByte",
"(",
"' '",
")",... | // ShellQuoteArguments takes a list of strings and escapes them so they will be
// handled right when passed as arguments to a program via a shell | [
"ShellQuoteArguments",
"takes",
"a",
"list",
"of",
"strings",
"and",
"escapes",
"them",
"so",
"they",
"will",
"be",
"handled",
"right",
"when",
"passed",
"as",
"arguments",
"to",
"a",
"program",
"via",
"a",
"shell"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/stringutils/stringutils.go#L90-L99 |
141,291 | containers/storage | pkg/system/exitcode.go | ProcessExitCode | func ProcessExitCode(err error) (exitCode int) {
if err != nil {
var exiterr error
if exitCode, exiterr = GetExitCode(err); exiterr != nil {
// TODO: Fix this so we check the error's text.
// we've failed to retrieve exit code, so we set it to 127
exitCode = 127
}
}
return
} | go | func ProcessExitCode(err error) (exitCode int) {
if err != nil {
var exiterr error
if exitCode, exiterr = GetExitCode(err); exiterr != nil {
// TODO: Fix this so we check the error's text.
// we've failed to retrieve exit code, so we set it to 127
exitCode = 127
}
}
return
} | [
"func",
"ProcessExitCode",
"(",
"err",
"error",
")",
"(",
"exitCode",
"int",
")",
"{",
"if",
"err",
"!=",
"nil",
"{",
"var",
"exiterr",
"error",
"\n",
"if",
"exitCode",
",",
"exiterr",
"=",
"GetExitCode",
"(",
"err",
")",
";",
"exiterr",
"!=",
"nil",
... | // ProcessExitCode process the specified error and returns the exit status code
// if the error was of type exec.ExitError, returns nothing otherwise. | [
"ProcessExitCode",
"process",
"the",
"specified",
"error",
"and",
"returns",
"the",
"exit",
"status",
"code",
"if",
"the",
"error",
"was",
"of",
"type",
"exec",
".",
"ExitError",
"returns",
"nothing",
"otherwise",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/system/exitcode.go#L23-L33 |
141,292 | containers/storage | drivers/vfs/driver.go | Create | func (d *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) error {
return d.create(id, parent, opts, true)
} | go | func (d *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) error {
return d.create(id, parent, opts, true)
} | [
"func",
"(",
"d",
"*",
"Driver",
")",
"Create",
"(",
"id",
",",
"parent",
"string",
",",
"opts",
"*",
"graphdriver",
".",
"CreateOpts",
")",
"error",
"{",
"return",
"d",
".",
"create",
"(",
"id",
",",
"parent",
",",
"opts",
",",
"true",
")",
"\n",
... | // Create prepares the filesystem for the VFS driver and copies the directory for the given id under the parent. | [
"Create",
"prepares",
"the",
"filesystem",
"for",
"the",
"VFS",
"driver",
"and",
"copies",
"the",
"directory",
"for",
"the",
"given",
"id",
"under",
"the",
"parent",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/vfs/driver.go#L117-L119 |
141,293 | containers/storage | drivers/vfs/driver.go | AdditionalImageStores | func (d *Driver) AdditionalImageStores() []string {
if len(d.homes) > 1 {
return d.homes[1:]
}
return nil
} | go | func (d *Driver) AdditionalImageStores() []string {
if len(d.homes) > 1 {
return d.homes[1:]
}
return nil
} | [
"func",
"(",
"d",
"*",
"Driver",
")",
"AdditionalImageStores",
"(",
")",
"[",
"]",
"string",
"{",
"if",
"len",
"(",
"d",
".",
"homes",
")",
">",
"1",
"{",
"return",
"d",
".",
"homes",
"[",
"1",
":",
"]",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
... | // AdditionalImageStores returns additional image stores supported by the driver | [
"AdditionalImageStores",
"returns",
"additional",
"image",
"stores",
"supported",
"by",
"the",
"driver"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/vfs/driver.go#L221-L226 |
141,294 | containers/storage | images.go | recomputeDigests | func (image *Image) recomputeDigests() error {
validDigests := make([]digest.Digest, 0, len(image.BigDataDigests)+1)
digests := make(map[digest.Digest]struct{})
if image.Digest != "" {
if err := image.Digest.Validate(); err != nil {
return errors.Wrapf(err, "error validating image digest %q", string(image.Diges... | go | func (image *Image) recomputeDigests() error {
validDigests := make([]digest.Digest, 0, len(image.BigDataDigests)+1)
digests := make(map[digest.Digest]struct{})
if image.Digest != "" {
if err := image.Digest.Validate(); err != nil {
return errors.Wrapf(err, "error validating image digest %q", string(image.Diges... | [
"func",
"(",
"image",
"*",
"Image",
")",
"recomputeDigests",
"(",
")",
"error",
"{",
"validDigests",
":=",
"make",
"(",
"[",
"]",
"digest",
".",
"Digest",
",",
"0",
",",
"len",
"(",
"image",
".",
"BigDataDigests",
")",
"+",
"1",
")",
"\n",
"digests",... | // recomputeDigests takes a fixed digest and a name-to-digest map and builds a
// list of the unique values that would identify the image. | [
"recomputeDigests",
"takes",
"a",
"fixed",
"digest",
"and",
"a",
"name",
"-",
"to",
"-",
"digest",
"map",
"and",
"builds",
"a",
"list",
"of",
"the",
"unique",
"values",
"that",
"would",
"identify",
"the",
"image",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/images.go#L207-L235 |
141,295 | containers/storage | drivers/windows/windows.go | InitFilter | func InitFilter(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (graphdriver.Driver, error) {
logrus.Debugf("WindowsGraphDriver InitFilter at %s", home)
for _, option := range options {
if strings.HasPrefix(option, "windows.mountopt=") {
return nil, fmt.Errorf("windows driver does not support m... | go | func InitFilter(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (graphdriver.Driver, error) {
logrus.Debugf("WindowsGraphDriver InitFilter at %s", home)
for _, option := range options {
if strings.HasPrefix(option, "windows.mountopt=") {
return nil, fmt.Errorf("windows driver does not support m... | [
"func",
"InitFilter",
"(",
"home",
"string",
",",
"options",
"[",
"]",
"string",
",",
"uidMaps",
",",
"gidMaps",
"[",
"]",
"idtools",
".",
"IDMap",
")",
"(",
"graphdriver",
".",
"Driver",
",",
"error",
")",
"{",
"logrus",
".",
"Debugf",
"(",
"\"",
"\... | // InitFilter returns a new Windows storage filter driver. | [
"InitFilter",
"returns",
"a",
"new",
"Windows",
"storage",
"filter",
"driver",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/windows/windows.go#L86-L118 |
141,296 | containers/storage | drivers/windows/windows.go | Put | func (d *Driver) Put(id string) error {
panicIfUsedByLcow()
logrus.Debugf("WindowsGraphDriver Put() id %s", id)
rID, err := d.resolveID(id)
if err != nil {
return err
}
if count := d.ctr.Decrement(rID); count > 0 {
return nil
}
d.cacheMu.Lock()
_, exists := d.cache[rID]
delete(d.cache, rID)
d.cacheMu.Un... | go | func (d *Driver) Put(id string) error {
panicIfUsedByLcow()
logrus.Debugf("WindowsGraphDriver Put() id %s", id)
rID, err := d.resolveID(id)
if err != nil {
return err
}
if count := d.ctr.Decrement(rID); count > 0 {
return nil
}
d.cacheMu.Lock()
_, exists := d.cache[rID]
delete(d.cache, rID)
d.cacheMu.Un... | [
"func",
"(",
"d",
"*",
"Driver",
")",
"Put",
"(",
"id",
"string",
")",
"error",
"{",
"panicIfUsedByLcow",
"(",
")",
"\n",
"logrus",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"id",
")",
"\n\n",
"rID",
",",
"err",
":=",
"d",
".",
"resolveID",
"(",
"id",... | // Put adds a new layer to the driver. | [
"Put",
"adds",
"a",
"new",
"layer",
"to",
"the",
"driver",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/windows/windows.go#L432-L457 |
141,297 | containers/storage | drivers/windows/windows.go | Diff | func (d *Driver) Diff(id string, idMappings *idtools.IDMappings, parent string, parentMappings *idtools.IDMappings, mountLabel string) (_ io.ReadCloser, err error) {
panicIfUsedByLcow()
rID, err := d.resolveID(id)
if err != nil {
return
}
layerChain, err := d.getLayerChain(rID)
if err != nil {
return
}
//... | go | func (d *Driver) Diff(id string, idMappings *idtools.IDMappings, parent string, parentMappings *idtools.IDMappings, mountLabel string) (_ io.ReadCloser, err error) {
panicIfUsedByLcow()
rID, err := d.resolveID(id)
if err != nil {
return
}
layerChain, err := d.getLayerChain(rID)
if err != nil {
return
}
//... | [
"func",
"(",
"d",
"*",
"Driver",
")",
"Diff",
"(",
"id",
"string",
",",
"idMappings",
"*",
"idtools",
".",
"IDMappings",
",",
"parent",
"string",
",",
"parentMappings",
"*",
"idtools",
".",
"IDMappings",
",",
"mountLabel",
"string",
")",
"(",
"_",
"io",
... | // Diff produces an archive of the changes between the specified
// layer and its parent layer which may be "".
// The layer should be mounted when calling this function | [
"Diff",
"produces",
"an",
"archive",
"of",
"the",
"changes",
"between",
"the",
"specified",
"layer",
"and",
"its",
"parent",
"layer",
"which",
"may",
"be",
".",
"The",
"layer",
"should",
"be",
"mounted",
"when",
"calling",
"this",
"function"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/windows/windows.go#L491-L523 |
141,298 | containers/storage | drivers/windows/windows.go | ApplyDiff | func (d *Driver) ApplyDiff(id string, idMappings *idtools.IDMappings, parent, mountLabel string, diff io.Reader) (int64, error) {
panicIfUsedByLcow()
var layerChain []string
if parent != "" {
rPId, err := d.resolveID(parent)
if err != nil {
return 0, err
}
parentChain, err := d.getLayerChain(rPId)
if er... | go | func (d *Driver) ApplyDiff(id string, idMappings *idtools.IDMappings, parent, mountLabel string, diff io.Reader) (int64, error) {
panicIfUsedByLcow()
var layerChain []string
if parent != "" {
rPId, err := d.resolveID(parent)
if err != nil {
return 0, err
}
parentChain, err := d.getLayerChain(rPId)
if er... | [
"func",
"(",
"d",
"*",
"Driver",
")",
"ApplyDiff",
"(",
"id",
"string",
",",
"idMappings",
"*",
"idtools",
".",
"IDMappings",
",",
"parent",
",",
"mountLabel",
"string",
",",
"diff",
"io",
".",
"Reader",
")",
"(",
"int64",
",",
"error",
")",
"{",
"pa... | // ApplyDiff extracts the changeset from the given diff into the
// layer with the specified id and parent, returning the size of the
// new layer in bytes.
// The layer should not be mounted when calling this function | [
"ApplyDiff",
"extracts",
"the",
"changeset",
"from",
"the",
"given",
"diff",
"into",
"the",
"layer",
"with",
"the",
"specified",
"id",
"and",
"parent",
"returning",
"the",
"size",
"of",
"the",
"new",
"layer",
"in",
"bytes",
".",
"The",
"layer",
"should",
"... | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/windows/windows.go#L584-L614 |
141,299 | containers/storage | drivers/windows/windows.go | Metadata | func (d *Driver) Metadata(id string) (map[string]string, error) {
panicIfUsedByLcow()
m := make(map[string]string)
m["dir"] = d.dir(id)
return m, nil
} | go | func (d *Driver) Metadata(id string) (map[string]string, error) {
panicIfUsedByLcow()
m := make(map[string]string)
m["dir"] = d.dir(id)
return m, nil
} | [
"func",
"(",
"d",
"*",
"Driver",
")",
"Metadata",
"(",
"id",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"panicIfUsedByLcow",
"(",
")",
"\n",
"m",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"... | // Metadata returns custom driver information. | [
"Metadata",
"returns",
"custom",
"driver",
"information",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/windows/windows.go#L641-L646 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.