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 list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
140,900 | mailhog/smtp | protocol.go | ParseCommand | func ParseCommand(line string) *Command {
words := strings.Split(line, " ")
command := strings.ToUpper(words[0])
args := strings.Join(words[1:len(words)], " ")
return &Command{
verb: command,
args: args,
orig: line,
}
} | go | func ParseCommand(line string) *Command {
words := strings.Split(line, " ")
command := strings.ToUpper(words[0])
args := strings.Join(words[1:len(words)], " ")
return &Command{
verb: command,
args: args,
orig: line,
}
} | [
"func",
"ParseCommand",
"(",
"line",
"string",
")",
"*",
"Command",
"{",
"words",
":=",
"strings",
".",
"Split",
"(",
"line",
",",
"\"",
"\"",
")",
"\n",
"command",
":=",
"strings",
".",
"ToUpper",
"(",
"words",
"[",
"0",
"]",
")",
"\n",
"args",
":... | // ParseCommand returns a Command from the line string | [
"ParseCommand",
"returns",
"a",
"Command",
"from",
"the",
"line",
"string"
] | 0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54 | https://github.com/mailhog/smtp/blob/0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54/protocol.go#L23-L33 |
140,901 | mailhog/smtp | protocol.go | NewProtocol | func NewProtocol() *Protocol {
p := &Protocol{
Hostname: "mailhog.example",
Ident: "ESMTP MailHog",
State: INVALID,
MaximumLineLength: -1,
MaximumRecipients: -1,
}
p.resetState()
return p
} | go | func NewProtocol() *Protocol {
p := &Protocol{
Hostname: "mailhog.example",
Ident: "ESMTP MailHog",
State: INVALID,
MaximumLineLength: -1,
MaximumRecipients: -1,
}
p.resetState()
return p
} | [
"func",
"NewProtocol",
"(",
")",
"*",
"Protocol",
"{",
"p",
":=",
"&",
"Protocol",
"{",
"Hostname",
":",
"\"",
"\"",
",",
"Ident",
":",
"\"",
"\"",
",",
"State",
":",
"INVALID",
",",
"MaximumLineLength",
":",
"-",
"1",
",",
"MaximumRecipients",
":",
... | // NewProtocol returns a new SMTP state machine in INVALID state
// handler is called when a message is received and should return a message ID | [
"NewProtocol",
"returns",
"a",
"new",
"SMTP",
"state",
"machine",
"in",
"INVALID",
"state",
"handler",
"is",
"called",
"when",
"a",
"message",
"is",
"received",
"and",
"should",
"return",
"a",
"message",
"ID"
] | 0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54 | https://github.com/mailhog/smtp/blob/0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54/protocol.go#L102-L112 |
140,902 | mailhog/smtp | protocol.go | Start | func (proto *Protocol) Start() *Reply {
proto.logf("Started session, switching to ESTABLISH state")
proto.State = ESTABLISH
return ReplyIdent(proto.Hostname + " " + proto.Ident)
} | go | func (proto *Protocol) Start() *Reply {
proto.logf("Started session, switching to ESTABLISH state")
proto.State = ESTABLISH
return ReplyIdent(proto.Hostname + " " + proto.Ident)
} | [
"func",
"(",
"proto",
"*",
"Protocol",
")",
"Start",
"(",
")",
"*",
"Reply",
"{",
"proto",
".",
"logf",
"(",
"\"",
"\"",
")",
"\n",
"proto",
".",
"State",
"=",
"ESTABLISH",
"\n",
"return",
"ReplyIdent",
"(",
"proto",
".",
"Hostname",
"+",
"\"",
"\"... | // Start begins an SMTP conversation with a 220 reply, placing the state
// machine in ESTABLISH state. | [
"Start",
"begins",
"an",
"SMTP",
"conversation",
"with",
"a",
"220",
"reply",
"placing",
"the",
"state",
"machine",
"in",
"ESTABLISH",
"state",
"."
] | 0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54 | https://github.com/mailhog/smtp/blob/0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54/protocol.go#L131-L135 |
140,903 | mailhog/smtp | protocol.go | ProcessCommand | func (proto *Protocol) ProcessCommand(line string) (reply *Reply) {
line = strings.Trim(line, "\r\n")
proto.logf("Processing line: %s", line)
words := strings.Split(line, " ")
command := strings.ToUpper(words[0])
args := strings.Join(words[1:len(words)], " ")
proto.logf("In state %d, got command '%s', args '%s'"... | go | func (proto *Protocol) ProcessCommand(line string) (reply *Reply) {
line = strings.Trim(line, "\r\n")
proto.logf("Processing line: %s", line)
words := strings.Split(line, " ")
command := strings.ToUpper(words[0])
args := strings.Join(words[1:len(words)], " ")
proto.logf("In state %d, got command '%s', args '%s'"... | [
"func",
"(",
"proto",
"*",
"Protocol",
")",
"ProcessCommand",
"(",
"line",
"string",
")",
"(",
"reply",
"*",
"Reply",
")",
"{",
"line",
"=",
"strings",
".",
"Trim",
"(",
"line",
",",
"\"",
"\\r",
"\\n",
"\"",
")",
"\n",
"proto",
".",
"logf",
"(",
... | // ProcessCommand processes a line of text as a command
// It expects the line string to be a properly formed SMTP verb and arguments | [
"ProcessCommand",
"processes",
"a",
"line",
"of",
"text",
"as",
"a",
"command",
"It",
"expects",
"the",
"line",
"string",
"to",
"be",
"a",
"properly",
"formed",
"SMTP",
"verb",
"and",
"arguments"
] | 0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54 | https://github.com/mailhog/smtp/blob/0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54/protocol.go#L199-L210 |
140,904 | mailhog/smtp | protocol.go | HELO | func (proto *Protocol) HELO(args string) (reply *Reply) {
proto.logf("Got HELO command, switching to MAIL state")
proto.State = MAIL
proto.Message.Helo = args
return ReplyOk("Hello " + args)
} | go | func (proto *Protocol) HELO(args string) (reply *Reply) {
proto.logf("Got HELO command, switching to MAIL state")
proto.State = MAIL
proto.Message.Helo = args
return ReplyOk("Hello " + args)
} | [
"func",
"(",
"proto",
"*",
"Protocol",
")",
"HELO",
"(",
"args",
"string",
")",
"(",
"reply",
"*",
"Reply",
")",
"{",
"proto",
".",
"logf",
"(",
"\"",
"\"",
")",
"\n",
"proto",
".",
"State",
"=",
"MAIL",
"\n",
"proto",
".",
"Message",
".",
"Helo"... | // HELO creates a reply to a HELO command | [
"HELO",
"creates",
"a",
"reply",
"to",
"a",
"HELO",
"command"
] | 0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54 | https://github.com/mailhog/smtp/blob/0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54/protocol.go#L411-L416 |
140,905 | mailhog/smtp | protocol.go | EHLO | func (proto *Protocol) EHLO(args string) (reply *Reply) {
proto.logf("Got EHLO command, switching to MAIL state")
proto.State = MAIL
proto.Message.Helo = args
replyArgs := []string{"Hello " + args, "PIPELINING"}
if proto.TLSHandler != nil && !proto.TLSPending && !proto.TLSUpgraded {
replyArgs = append(replyArgs... | go | func (proto *Protocol) EHLO(args string) (reply *Reply) {
proto.logf("Got EHLO command, switching to MAIL state")
proto.State = MAIL
proto.Message.Helo = args
replyArgs := []string{"Hello " + args, "PIPELINING"}
if proto.TLSHandler != nil && !proto.TLSPending && !proto.TLSUpgraded {
replyArgs = append(replyArgs... | [
"func",
"(",
"proto",
"*",
"Protocol",
")",
"EHLO",
"(",
"args",
"string",
")",
"(",
"reply",
"*",
"Reply",
")",
"{",
"proto",
".",
"logf",
"(",
"\"",
"\"",
")",
"\n",
"proto",
".",
"State",
"=",
"MAIL",
"\n",
"proto",
".",
"Message",
".",
"Helo"... | // EHLO creates a reply to a EHLO command | [
"EHLO",
"creates",
"a",
"reply",
"to",
"a",
"EHLO",
"command"
] | 0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54 | https://github.com/mailhog/smtp/blob/0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54/protocol.go#L419-L438 |
140,906 | mailhog/smtp | protocol.go | STARTTLS | func (proto *Protocol) STARTTLS(args string) (reply *Reply) {
if proto.TLSUpgraded {
return ReplyUnrecognisedCommand()
}
if proto.TLSHandler == nil {
proto.logf("tls handler not found")
return ReplyUnrecognisedCommand()
}
if len(args) > 0 {
return ReplySyntaxError("no parameters allowed")
}
r, callbac... | go | func (proto *Protocol) STARTTLS(args string) (reply *Reply) {
if proto.TLSUpgraded {
return ReplyUnrecognisedCommand()
}
if proto.TLSHandler == nil {
proto.logf("tls handler not found")
return ReplyUnrecognisedCommand()
}
if len(args) > 0 {
return ReplySyntaxError("no parameters allowed")
}
r, callbac... | [
"func",
"(",
"proto",
"*",
"Protocol",
")",
"STARTTLS",
"(",
"args",
"string",
")",
"(",
"reply",
"*",
"Reply",
")",
"{",
"if",
"proto",
".",
"TLSUpgraded",
"{",
"return",
"ReplyUnrecognisedCommand",
"(",
")",
"\n",
"}",
"\n\n",
"if",
"proto",
".",
"TL... | // STARTTLS creates a reply to a STARTTLS command | [
"STARTTLS",
"creates",
"a",
"reply",
"to",
"a",
"STARTTLS",
"command"
] | 0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54 | https://github.com/mailhog/smtp/blob/0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54/protocol.go#L441-L469 |
140,907 | mailhog/smtp | protocol.go | ParseMAIL | func (proto *Protocol) ParseMAIL(mail string) (string, error) {
var match []string
if proto.RejectBrokenMAILSyntax {
match = parseMailRFCRegexp.FindStringSubmatch(mail)
} else {
match = parseMailBrokenRegexp.FindStringSubmatch(mail)
}
if len(match) != 2 {
return "", errors.New("Invalid syntax in MAIL comman... | go | func (proto *Protocol) ParseMAIL(mail string) (string, error) {
var match []string
if proto.RejectBrokenMAILSyntax {
match = parseMailRFCRegexp.FindStringSubmatch(mail)
} else {
match = parseMailBrokenRegexp.FindStringSubmatch(mail)
}
if len(match) != 2 {
return "", errors.New("Invalid syntax in MAIL comman... | [
"func",
"(",
"proto",
"*",
"Protocol",
")",
"ParseMAIL",
"(",
"mail",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"match",
"[",
"]",
"string",
"\n",
"if",
"proto",
".",
"RejectBrokenMAILSyntax",
"{",
"match",
"=",
"parseMailRFCRegexp",
"... | // ParseMAIL returns the forward-path from a MAIL command argument | [
"ParseMAIL",
"returns",
"the",
"forward",
"-",
"path",
"from",
"a",
"MAIL",
"command",
"argument"
] | 0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54 | https://github.com/mailhog/smtp/blob/0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54/protocol.go#L475-L487 |
140,908 | mailhog/smtp | protocol.go | ParseRCPT | func (proto *Protocol) ParseRCPT(rcpt string) (string, error) {
var match []string
if proto.RejectBrokenRCPTSyntax {
match = parseRcptRFCRegexp.FindStringSubmatch(rcpt)
} else {
match = parseRcptBrokenRegexp.FindStringSubmatch(rcpt)
}
if len(match) != 2 {
return "", errors.New("Invalid syntax in RCPT command... | go | func (proto *Protocol) ParseRCPT(rcpt string) (string, error) {
var match []string
if proto.RejectBrokenRCPTSyntax {
match = parseRcptRFCRegexp.FindStringSubmatch(rcpt)
} else {
match = parseRcptBrokenRegexp.FindStringSubmatch(rcpt)
}
if len(match) != 2 {
return "", errors.New("Invalid syntax in RCPT command... | [
"func",
"(",
"proto",
"*",
"Protocol",
")",
"ParseRCPT",
"(",
"rcpt",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"match",
"[",
"]",
"string",
"\n",
"if",
"proto",
".",
"RejectBrokenRCPTSyntax",
"{",
"match",
"=",
"parseRcptRFCRegexp",
"... | // ParseRCPT returns the return-path from a RCPT command argument | [
"ParseRCPT",
"returns",
"the",
"return",
"-",
"path",
"from",
"a",
"RCPT",
"command",
"argument"
] | 0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54 | https://github.com/mailhog/smtp/blob/0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54/protocol.go#L493-L504 |
140,909 | mailhog/smtp | reply.go | Lines | func (r Reply) Lines() []string {
var lines []string
if len(r.lines) == 0 {
l := strconv.Itoa(r.Status)
lines = append(lines, l+"\n")
return lines
}
for i, line := range r.lines {
l := ""
if i == len(r.lines)-1 {
l = strconv.Itoa(r.Status) + " " + line + "\r\n"
} else {
l = strconv.Itoa(r.Status... | go | func (r Reply) Lines() []string {
var lines []string
if len(r.lines) == 0 {
l := strconv.Itoa(r.Status)
lines = append(lines, l+"\n")
return lines
}
for i, line := range r.lines {
l := ""
if i == len(r.lines)-1 {
l = strconv.Itoa(r.Status) + " " + line + "\r\n"
} else {
l = strconv.Itoa(r.Status... | [
"func",
"(",
"r",
"Reply",
")",
"Lines",
"(",
")",
"[",
"]",
"string",
"{",
"var",
"lines",
"[",
"]",
"string",
"\n\n",
"if",
"len",
"(",
"r",
".",
"lines",
")",
"==",
"0",
"{",
"l",
":=",
"strconv",
".",
"Itoa",
"(",
"r",
".",
"Status",
")",... | // Lines returns the formatted SMTP reply | [
"Lines",
"returns",
"the",
"formatted",
"SMTP",
"reply"
] | 0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54 | https://github.com/mailhog/smtp/blob/0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54/reply.go#L15-L35 |
140,910 | mailhog/smtp | reply.go | ReplyOk | func ReplyOk(message ...string) *Reply {
if len(message) == 0 {
message = []string{"Ok"}
}
return &Reply{250, message, nil}
} | go | func ReplyOk(message ...string) *Reply {
if len(message) == 0 {
message = []string{"Ok"}
}
return &Reply{250, message, nil}
} | [
"func",
"ReplyOk",
"(",
"message",
"...",
"string",
")",
"*",
"Reply",
"{",
"if",
"len",
"(",
"message",
")",
"==",
"0",
"{",
"message",
"=",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
"\n",
"}",
"\n",
"return",
"&",
"Reply",
"{",
"250",
",",
"m... | // ReplyOk creates a 250 Ok reply | [
"ReplyOk",
"creates",
"a",
"250",
"Ok",
"reply"
] | 0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54 | https://github.com/mailhog/smtp/blob/0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54/reply.go#L52-L57 |
140,911 | mailhog/smtp | reply.go | ReplySyntaxError | func ReplySyntaxError(response string) *Reply {
if len(response) > 0 {
response = " (" + response + ")"
}
return &Reply{501, []string{"Syntax error" + response}, nil}
} | go | func ReplySyntaxError(response string) *Reply {
if len(response) > 0 {
response = " (" + response + ")"
}
return &Reply{501, []string{"Syntax error" + response}, nil}
} | [
"func",
"ReplySyntaxError",
"(",
"response",
"string",
")",
"*",
"Reply",
"{",
"if",
"len",
"(",
"response",
")",
">",
"0",
"{",
"response",
"=",
"\"",
"\"",
"+",
"response",
"+",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"&",
"Reply",
"{",
"501",
","... | // ReplySyntaxError creates a 501 Syntax error reply | [
"ReplySyntaxError",
"creates",
"a",
"501",
"Syntax",
"error",
"reply"
] | 0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54 | https://github.com/mailhog/smtp/blob/0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54/reply.go#L85-L90 |
140,912 | lann/builder | builder.go | Delete | func Delete(builder interface{}, name string) interface{} {
b := Builder{getBuilderMap(builder).Delete(name)}
return convert(b, builder)
} | go | func Delete(builder interface{}, name string) interface{} {
b := Builder{getBuilderMap(builder).Delete(name)}
return convert(b, builder)
} | [
"func",
"Delete",
"(",
"builder",
"interface",
"{",
"}",
",",
"name",
"string",
")",
"interface",
"{",
"}",
"{",
"b",
":=",
"Builder",
"{",
"getBuilderMap",
"(",
"builder",
")",
".",
"Delete",
"(",
"name",
")",
"}",
"\n",
"return",
"convert",
"(",
"b... | // Delete returns a copy of the given builder with the given named value unset. | [
"Delete",
"returns",
"a",
"copy",
"of",
"the",
"given",
"builder",
"with",
"the",
"given",
"named",
"value",
"unset",
"."
] | 47ae307949d02aa1f1069fdafc00ca08e1dbabac | https://github.com/lann/builder/blob/47ae307949d02aa1f1069fdafc00ca08e1dbabac/builder.go#L48-L51 |
140,913 | lann/builder | registry.go | RegisterType | func RegisterType(builderType reflect.Type, structType reflect.Type) *reflect.Value {
registryMux.Lock()
defer registryMux.Unlock()
structType.NumField() // Panic if structType is not a struct
registry[builderType] = structType
emptyValue := emptyBuilderValue.Convert(builderType)
return &emptyValue
} | go | func RegisterType(builderType reflect.Type, structType reflect.Type) *reflect.Value {
registryMux.Lock()
defer registryMux.Unlock()
structType.NumField() // Panic if structType is not a struct
registry[builderType] = structType
emptyValue := emptyBuilderValue.Convert(builderType)
return &emptyValue
} | [
"func",
"RegisterType",
"(",
"builderType",
"reflect",
".",
"Type",
",",
"structType",
"reflect",
".",
"Type",
")",
"*",
"reflect",
".",
"Value",
"{",
"registryMux",
".",
"Lock",
"(",
")",
"\n",
"defer",
"registryMux",
".",
"Unlock",
"(",
")",
"\n",
"str... | // RegisterType maps the given builderType to a structType.
// This mapping affects the type of slices returned by Get and is required for
// GetStruct to work.
//
// Returns a Value containing an empty instance of the registered builderType.
//
// RegisterType will panic if builderType's underlying type is not Builder... | [
"RegisterType",
"maps",
"the",
"given",
"builderType",
"to",
"a",
"structType",
".",
"This",
"mapping",
"affects",
"the",
"type",
"of",
"slices",
"returned",
"by",
"Get",
"and",
"is",
"required",
"for",
"GetStruct",
"to",
"work",
".",
"Returns",
"a",
"Value"... | 47ae307949d02aa1f1069fdafc00ca08e1dbabac | https://github.com/lann/builder/blob/47ae307949d02aa1f1069fdafc00ca08e1dbabac/registry.go#L21-L28 |
140,914 | lann/builder | registry.go | Register | func Register(builderProto, structProto interface{}) interface{} {
empty := RegisterType(
reflect.TypeOf(builderProto),
reflect.TypeOf(structProto),
).Interface()
return empty
} | go | func Register(builderProto, structProto interface{}) interface{} {
empty := RegisterType(
reflect.TypeOf(builderProto),
reflect.TypeOf(structProto),
).Interface()
return empty
} | [
"func",
"Register",
"(",
"builderProto",
",",
"structProto",
"interface",
"{",
"}",
")",
"interface",
"{",
"}",
"{",
"empty",
":=",
"RegisterType",
"(",
"reflect",
".",
"TypeOf",
"(",
"builderProto",
")",
",",
"reflect",
".",
"TypeOf",
"(",
"structProto",
... | // Register wraps RegisterType, taking instances instead of Types.
//
// Returns an empty instance of the registered builder type which can be used
// as the initial value for builder expressions. See example. | [
"Register",
"wraps",
"RegisterType",
"taking",
"instances",
"instead",
"of",
"Types",
".",
"Returns",
"an",
"empty",
"instance",
"of",
"the",
"registered",
"builder",
"type",
"which",
"can",
"be",
"used",
"as",
"the",
"initial",
"value",
"for",
"builder",
"exp... | 47ae307949d02aa1f1069fdafc00ca08e1dbabac | https://github.com/lann/builder/blob/47ae307949d02aa1f1069fdafc00ca08e1dbabac/registry.go#L34-L40 |
140,915 | lestrrat-go/jsschema | validator/validator.go | Validate | func (v *Validator) Validate(x interface{}) error {
jsv, err := v.validator()
if err != nil {
return err
}
return jsv.Validate(x)
} | go | func (v *Validator) Validate(x interface{}) error {
jsv, err := v.validator()
if err != nil {
return err
}
return jsv.Validate(x)
} | [
"func",
"(",
"v",
"*",
"Validator",
")",
"Validate",
"(",
"x",
"interface",
"{",
"}",
")",
"error",
"{",
"jsv",
",",
"err",
":=",
"v",
".",
"validator",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
... | // Validate takes an arbitrary piece of data and
// validates it against the schema. | [
"Validate",
"takes",
"an",
"arbitrary",
"piece",
"of",
"data",
"and",
"validates",
"it",
"against",
"the",
"schema",
"."
] | 5c81c58ffcc359c4390d440b45f5462edb0107cb | https://github.com/lestrrat-go/jsschema/blob/5c81c58ffcc359c4390d440b45f5462edb0107cb/validator/validator.go#L57-L63 |
140,916 | lestrrat-go/jsschema | primitives.go | UnmarshalJSON | func (t *PrimitiveType) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return err
}
x, err := primitiveFromString(string(data))
if err != nil {
return err
}
*t = x
return nil
} | go | func (t *PrimitiveType) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return err
}
x, err := primitiveFromString(string(data))
if err != nil {
return err
}
*t = x
return nil
} | [
"func",
"(",
"t",
"*",
"PrimitiveType",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"s",
"string",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"s",
")",
";",
"err",
"!=",
"nil",
"{"... | // UnmarshalJSON initializes the primitive type from
// a JSON string. | [
"UnmarshalJSON",
"initializes",
"the",
"primitive",
"type",
"from",
"a",
"JSON",
"string",
"."
] | 5c81c58ffcc359c4390d440b45f5462edb0107cb | https://github.com/lestrrat-go/jsschema/blob/5c81c58ffcc359c4390d440b45f5462edb0107cb/primitives.go#L10-L21 |
140,917 | lestrrat-go/jsschema | primitives.go | String | func (t PrimitiveType) String() string {
var v string
switch t {
case NullType:
v = "null"
case IntegerType:
v = "integer"
case StringType:
v = "string"
case ObjectType:
v = "object"
case ArrayType:
v = "array"
case BooleanType:
v = "boolean"
case NumberType:
v = "number"
default:
v = "<invali... | go | func (t PrimitiveType) String() string {
var v string
switch t {
case NullType:
v = "null"
case IntegerType:
v = "integer"
case StringType:
v = "string"
case ObjectType:
v = "object"
case ArrayType:
v = "array"
case BooleanType:
v = "boolean"
case NumberType:
v = "number"
default:
v = "<invali... | [
"func",
"(",
"t",
"PrimitiveType",
")",
"String",
"(",
")",
"string",
"{",
"var",
"v",
"string",
"\n",
"switch",
"t",
"{",
"case",
"NullType",
":",
"v",
"=",
"\"",
"\"",
"\n",
"case",
"IntegerType",
":",
"v",
"=",
"\"",
"\"",
"\n",
"case",
"StringT... | // String returns the string representation of this primitive type | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"this",
"primitive",
"type"
] | 5c81c58ffcc359c4390d440b45f5462edb0107cb | https://github.com/lestrrat-go/jsschema/blob/5c81c58ffcc359c4390d440b45f5462edb0107cb/primitives.go#L46-L67 |
140,918 | lestrrat-go/jsschema | primitives.go | MarshalJSON | func (t PrimitiveType) MarshalJSON() ([]byte, error) {
switch t {
case NullType, IntegerType, StringType, ObjectType, ArrayType, BooleanType, NumberType:
return json.Marshal(t.String())
default:
return nil, errors.New("unknown primitive type")
}
} | go | func (t PrimitiveType) MarshalJSON() ([]byte, error) {
switch t {
case NullType, IntegerType, StringType, ObjectType, ArrayType, BooleanType, NumberType:
return json.Marshal(t.String())
default:
return nil, errors.New("unknown primitive type")
}
} | [
"func",
"(",
"t",
"PrimitiveType",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"switch",
"t",
"{",
"case",
"NullType",
",",
"IntegerType",
",",
"StringType",
",",
"ObjectType",
",",
"ArrayType",
",",
"BooleanType",
",",
... | // MarshalJSON seriealises the primitive type into a JSON string | [
"MarshalJSON",
"seriealises",
"the",
"primitive",
"type",
"into",
"a",
"JSON",
"string"
] | 5c81c58ffcc359c4390d440b45f5462edb0107cb | https://github.com/lestrrat-go/jsschema/blob/5c81c58ffcc359c4390d440b45f5462edb0107cb/primitives.go#L70-L77 |
140,919 | lestrrat-go/jsschema | primitives.go | UnmarshalJSON | func (pt *PrimitiveTypes) UnmarshalJSON(data []byte) error {
if data[0] != '[' {
var t PrimitiveType
if err := json.Unmarshal(data, &t); err != nil {
return err
}
*pt = PrimitiveTypes{t}
return nil
}
var list []PrimitiveType
if err := json.Unmarshal(data, &list); err != nil {
return err
}
*pt = ... | go | func (pt *PrimitiveTypes) UnmarshalJSON(data []byte) error {
if data[0] != '[' {
var t PrimitiveType
if err := json.Unmarshal(data, &t); err != nil {
return err
}
*pt = PrimitiveTypes{t}
return nil
}
var list []PrimitiveType
if err := json.Unmarshal(data, &list); err != nil {
return err
}
*pt = ... | [
"func",
"(",
"pt",
"*",
"PrimitiveTypes",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"data",
"[",
"0",
"]",
"!=",
"'['",
"{",
"var",
"t",
"PrimitiveType",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"d... | // UnmarshalJSON initializes the list of primitive types | [
"UnmarshalJSON",
"initializes",
"the",
"list",
"of",
"primitive",
"types"
] | 5c81c58ffcc359c4390d440b45f5462edb0107cb | https://github.com/lestrrat-go/jsschema/blob/5c81c58ffcc359c4390d440b45f5462edb0107cb/primitives.go#L80-L98 |
140,920 | lestrrat-go/jsschema | primitives.go | Bool | func (b Bool) Bool() bool {
if b.Initialized {
return b.Val
}
return b.Default
} | go | func (b Bool) Bool() bool {
if b.Initialized {
return b.Val
}
return b.Default
} | [
"func",
"(",
"b",
"Bool",
")",
"Bool",
"(",
")",
"bool",
"{",
"if",
"b",
".",
"Initialized",
"{",
"return",
"b",
".",
"Val",
"\n",
"}",
"\n",
"return",
"b",
".",
"Default",
"\n",
"}"
] | // Bool returns the underlying boolean value for the
// primitive boolean type | [
"Bool",
"returns",
"the",
"underlying",
"boolean",
"value",
"for",
"the",
"primitive",
"boolean",
"type"
] | 5c81c58ffcc359c4390d440b45f5462edb0107cb | https://github.com/lestrrat-go/jsschema/blob/5c81c58ffcc359c4390d440b45f5462edb0107cb/primitives.go#L102-L107 |
140,921 | lestrrat-go/jsschema | primitives.go | Contains | func (pt PrimitiveTypes) Contains(p PrimitiveType) bool {
for _, v := range pt {
if p == v {
return true
}
}
return false
} | go | func (pt PrimitiveTypes) Contains(p PrimitiveType) bool {
for _, v := range pt {
if p == v {
return true
}
}
return false
} | [
"func",
"(",
"pt",
"PrimitiveTypes",
")",
"Contains",
"(",
"p",
"PrimitiveType",
")",
"bool",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"pt",
"{",
"if",
"p",
"==",
"v",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"... | // Contains returns true if the list of primitive types
// contains `p` | [
"Contains",
"returns",
"true",
"if",
"the",
"list",
"of",
"primitive",
"types",
"contains",
"p"
] | 5c81c58ffcc359c4390d440b45f5462edb0107cb | https://github.com/lestrrat-go/jsschema/blob/5c81c58ffcc359c4390d440b45f5462edb0107cb/primitives.go#L111-L118 |
140,922 | lestrrat-go/jsschema | primitives.go | Less | func (pt PrimitiveTypes) Less(i, j int) bool {
return pt[i] < pt[j]
} | go | func (pt PrimitiveTypes) Less(i, j int) bool {
return pt[i] < pt[j]
} | [
"func",
"(",
"pt",
"PrimitiveTypes",
")",
"Less",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"return",
"pt",
"[",
"i",
"]",
"<",
"pt",
"[",
"j",
"]",
"\n",
"}"
] | // Less returns true if the i-th element in the list is
// listed before the j-th element. | [
"Less",
"returns",
"true",
"if",
"the",
"i",
"-",
"th",
"element",
"in",
"the",
"list",
"is",
"listed",
"before",
"the",
"j",
"-",
"th",
"element",
"."
] | 5c81c58ffcc359c4390d440b45f5462edb0107cb | https://github.com/lestrrat-go/jsschema/blob/5c81c58ffcc359c4390d440b45f5462edb0107cb/primitives.go#L127-L129 |
140,923 | lestrrat-go/jsschema | primitives.go | Swap | func (pt PrimitiveTypes) Swap(i, j int) {
pt[i], pt[j] = pt[j], pt[i]
} | go | func (pt PrimitiveTypes) Swap(i, j int) {
pt[i], pt[j] = pt[j], pt[i]
} | [
"func",
"(",
"pt",
"PrimitiveTypes",
")",
"Swap",
"(",
"i",
",",
"j",
"int",
")",
"{",
"pt",
"[",
"i",
"]",
",",
"pt",
"[",
"j",
"]",
"=",
"pt",
"[",
"j",
"]",
",",
"pt",
"[",
"i",
"]",
"\n",
"}"
] | // Swap swaps the elements in positions i and j | [
"Swap",
"swaps",
"the",
"elements",
"in",
"positions",
"i",
"and",
"j"
] | 5c81c58ffcc359c4390d440b45f5462edb0107cb | https://github.com/lestrrat-go/jsschema/blob/5c81c58ffcc359c4390d440b45f5462edb0107cb/primitives.go#L132-L134 |
140,924 | lestrrat-go/jsschema | schema.go | ReadFile | func ReadFile(f string) (*Schema, error) {
in, err := os.Open(f)
if err != nil {
return nil, err
}
defer in.Close()
return Read(in)
} | go | func ReadFile(f string) (*Schema, error) {
in, err := os.Open(f)
if err != nil {
return nil, err
}
defer in.Close()
return Read(in)
} | [
"func",
"ReadFile",
"(",
"f",
"string",
")",
"(",
"*",
"Schema",
",",
"error",
")",
"{",
"in",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"f",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"defer",
"in... | // ReadFile reads the file `f` and parses its content to create
// a new Schema object | [
"ReadFile",
"reads",
"the",
"file",
"f",
"and",
"parses",
"its",
"content",
"to",
"create",
"a",
"new",
"Schema",
"object"
] | 5c81c58ffcc359c4390d440b45f5462edb0107cb | https://github.com/lestrrat-go/jsschema/blob/5c81c58ffcc359c4390d440b45f5462edb0107cb/schema.go#L48-L55 |
140,925 | lestrrat-go/jsschema | schema.go | Decode | func (s *Schema) Decode(in io.Reader) error {
dec := json.NewDecoder(in)
if err := dec.Decode(s); err != nil {
return err
}
s.applyParentSchema()
return nil
} | go | func (s *Schema) Decode(in io.Reader) error {
dec := json.NewDecoder(in)
if err := dec.Decode(s); err != nil {
return err
}
s.applyParentSchema()
return nil
} | [
"func",
"(",
"s",
"*",
"Schema",
")",
"Decode",
"(",
"in",
"io",
".",
"Reader",
")",
"error",
"{",
"dec",
":=",
"json",
".",
"NewDecoder",
"(",
"in",
")",
"\n",
"if",
"err",
":=",
"dec",
".",
"Decode",
"(",
"s",
")",
";",
"err",
"!=",
"nil",
... | // Decode reads from `in` and parses its content to
// initialize the schema object | [
"Decode",
"reads",
"from",
"in",
"and",
"parses",
"its",
"content",
"to",
"initialize",
"the",
"schema",
"object"
] | 5c81c58ffcc359c4390d440b45f5462edb0107cb | https://github.com/lestrrat-go/jsschema/blob/5c81c58ffcc359c4390d440b45f5462edb0107cb/schema.go#L69-L76 |
140,926 | lestrrat-go/jsschema | schema.go | BaseURL | func (s *Schema) BaseURL() *url.URL {
scope := s.Scope()
u, err := url.Parse(scope)
if err != nil {
// XXX hmm, not sure what to do here
u = &url.URL{}
}
return u
} | go | func (s *Schema) BaseURL() *url.URL {
scope := s.Scope()
u, err := url.Parse(scope)
if err != nil {
// XXX hmm, not sure what to do here
u = &url.URL{}
}
return u
} | [
"func",
"(",
"s",
"*",
"Schema",
")",
"BaseURL",
"(",
")",
"*",
"url",
".",
"URL",
"{",
"scope",
":=",
"s",
".",
"Scope",
"(",
")",
"\n",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"scope",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"/... | // BaseURL returns the base URL registered for this schema | [
"BaseURL",
"returns",
"the",
"base",
"URL",
"registered",
"for",
"this",
"schema"
] | 5c81c58ffcc359c4390d440b45f5462edb0107cb | https://github.com/lestrrat-go/jsschema/blob/5c81c58ffcc359c4390d440b45f5462edb0107cb/schema.go#L135-L144 |
140,927 | lestrrat-go/jsschema | schema.go | Root | func (s *Schema) Root() *Schema {
if s.parent == nil {
if pdebug.Enabled {
pdebug.Printf("Schema %p is root", s)
}
return s
}
return s.parent.Root()
} | go | func (s *Schema) Root() *Schema {
if s.parent == nil {
if pdebug.Enabled {
pdebug.Printf("Schema %p is root", s)
}
return s
}
return s.parent.Root()
} | [
"func",
"(",
"s",
"*",
"Schema",
")",
"Root",
"(",
")",
"*",
"Schema",
"{",
"if",
"s",
".",
"parent",
"==",
"nil",
"{",
"if",
"pdebug",
".",
"Enabled",
"{",
"pdebug",
".",
"Printf",
"(",
"\"",
"\"",
",",
"s",
")",
"\n",
"}",
"\n",
"return",
"... | // Root returns the upmost parent schema object within the
// hierarchy of schemas. For example, the `item` element
// in a schema for an array is also a schema, and you could
// reference elements in parent schemas. | [
"Root",
"returns",
"the",
"upmost",
"parent",
"schema",
"object",
"within",
"the",
"hierarchy",
"of",
"schemas",
".",
"For",
"example",
"the",
"item",
"element",
"in",
"a",
"schema",
"for",
"an",
"array",
"is",
"also",
"a",
"schema",
"and",
"you",
"could",... | 5c81c58ffcc359c4390d440b45f5462edb0107cb | https://github.com/lestrrat-go/jsschema/blob/5c81c58ffcc359c4390d440b45f5462edb0107cb/schema.go#L150-L159 |
140,928 | lestrrat-go/jsschema | schema.go | ResolveURL | func (s *Schema) ResolveURL(v string) (u *url.URL, err error) {
if pdebug.Enabled {
g := pdebug.IPrintf("START Schema.ResolveURL '%s'", v)
defer func() {
if err != nil {
g.IRelease("END Schema.ResolveURL '%s': error %s", v, err)
} else {
g.IRelease("END Schema.ResolveURL '%s' -> '%s'", v, u)
}
}... | go | func (s *Schema) ResolveURL(v string) (u *url.URL, err error) {
if pdebug.Enabled {
g := pdebug.IPrintf("START Schema.ResolveURL '%s'", v)
defer func() {
if err != nil {
g.IRelease("END Schema.ResolveURL '%s': error %s", v, err)
} else {
g.IRelease("END Schema.ResolveURL '%s' -> '%s'", v, u)
}
}... | [
"func",
"(",
"s",
"*",
"Schema",
")",
"ResolveURL",
"(",
"v",
"string",
")",
"(",
"u",
"*",
"url",
".",
"URL",
",",
"err",
"error",
")",
"{",
"if",
"pdebug",
".",
"Enabled",
"{",
"g",
":=",
"pdebug",
".",
"IPrintf",
"(",
"\"",
"\"",
",",
"v",
... | // ResolveURL takes a url string, and resolves it if it's
// a relative URL | [
"ResolveURL",
"takes",
"a",
"url",
"string",
"and",
"resolves",
"it",
"if",
"it",
"s",
"a",
"relative",
"URL"
] | 5c81c58ffcc359c4390d440b45f5462edb0107cb | https://github.com/lestrrat-go/jsschema/blob/5c81c58ffcc359c4390d440b45f5462edb0107cb/schema.go#L172-L192 |
140,929 | lestrrat-go/jsschema | schema.go | Resolve | func (s *Schema) Resolve(ctx interface{}) (ref *Schema, err error) {
if s.Reference == "" {
return s, nil
}
if pdebug.Enabled {
g := pdebug.IPrintf("START Schema.Resolve (%s)", s.Reference)
defer func() {
if err != nil {
g.IRelease("END Schema.Resolve (%s): %s", s.Reference, err)
} else {
g.IRel... | go | func (s *Schema) Resolve(ctx interface{}) (ref *Schema, err error) {
if s.Reference == "" {
return s, nil
}
if pdebug.Enabled {
g := pdebug.IPrintf("START Schema.Resolve (%s)", s.Reference)
defer func() {
if err != nil {
g.IRelease("END Schema.Resolve (%s): %s", s.Reference, err)
} else {
g.IRel... | [
"func",
"(",
"s",
"*",
"Schema",
")",
"Resolve",
"(",
"ctx",
"interface",
"{",
"}",
")",
"(",
"ref",
"*",
"Schema",
",",
"err",
"error",
")",
"{",
"if",
"s",
".",
"Reference",
"==",
"\"",
"\"",
"{",
"return",
"s",
",",
"nil",
"\n",
"}",
"\n\n",... | // Resolve returns the schema after it has been resolved.
// If s.Reference is the empty string, the current schema is returned.
//
// `ctx` is an optional context to resolve the reference with. If not
// specified, the root schema as returned by `Root` will be used. | [
"Resolve",
"returns",
"the",
"schema",
"after",
"it",
"has",
"been",
"resolved",
".",
"If",
"s",
".",
"Reference",
"is",
"the",
"empty",
"string",
"the",
"current",
"schema",
"is",
"returned",
".",
"ctx",
"is",
"an",
"optional",
"context",
"to",
"resolve",... | 5c81c58ffcc359c4390d440b45f5462edb0107cb | https://github.com/lestrrat-go/jsschema/blob/5c81c58ffcc359c4390d440b45f5462edb0107cb/schema.go#L204-L269 |
140,930 | lestrrat-go/jsschema | schema.go | IsPropRequired | func (s *Schema) IsPropRequired(pname string) bool {
for _, name := range s.Required {
if name == pname {
return true
}
}
return false
} | go | func (s *Schema) IsPropRequired(pname string) bool {
for _, name := range s.Required {
if name == pname {
return true
}
}
return false
} | [
"func",
"(",
"s",
"*",
"Schema",
")",
"IsPropRequired",
"(",
"pname",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"name",
":=",
"range",
"s",
".",
"Required",
"{",
"if",
"name",
"==",
"pname",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"... | // IsPropRequired can be used to query this schema if a
// given property name is required. | [
"IsPropRequired",
"can",
"be",
"used",
"to",
"query",
"this",
"schema",
"if",
"a",
"given",
"property",
"name",
"is",
"required",
"."
] | 5c81c58ffcc359c4390d440b45f5462edb0107cb | https://github.com/lestrrat-go/jsschema/blob/5c81c58ffcc359c4390d440b45f5462edb0107cb/schema.go#L273-L280 |
140,931 | lestrrat-go/jsschema | schema.go | Scope | func (s *Schema) Scope() string {
if pdebug.Enabled {
g := pdebug.IPrintf("START Schema.Scope")
defer g.IRelease("END Schema.Scope")
}
if s.ID != "" || s.parent == nil {
if pdebug.Enabled {
pdebug.Printf("Returning id '%s'", s.ID)
}
return s.ID
}
return s.parent.Scope()
} | go | func (s *Schema) Scope() string {
if pdebug.Enabled {
g := pdebug.IPrintf("START Schema.Scope")
defer g.IRelease("END Schema.Scope")
}
if s.ID != "" || s.parent == nil {
if pdebug.Enabled {
pdebug.Printf("Returning id '%s'", s.ID)
}
return s.ID
}
return s.parent.Scope()
} | [
"func",
"(",
"s",
"*",
"Schema",
")",
"Scope",
"(",
")",
"string",
"{",
"if",
"pdebug",
".",
"Enabled",
"{",
"g",
":=",
"pdebug",
".",
"IPrintf",
"(",
"\"",
"\"",
")",
"\n",
"defer",
"g",
".",
"IRelease",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
... | // Scope returns the scope ID for this schema | [
"Scope",
"returns",
"the",
"scope",
"ID",
"for",
"this",
"schema"
] | 5c81c58ffcc359c4390d440b45f5462edb0107cb | https://github.com/lestrrat-go/jsschema/blob/5c81c58ffcc359c4390d440b45f5462edb0107cb/schema.go#L283-L296 |
140,932 | lestrrat-go/jsschema | marshal.go | UnmarshalJSON | func (s *Schema) UnmarshalJSON(data []byte) error {
m := map[string]interface{}{}
if err := json.Unmarshal(data, &m); err != nil {
return err
}
return s.Extract(m)
} | go | func (s *Schema) UnmarshalJSON(data []byte) error {
m := map[string]interface{}{}
if err := json.Unmarshal(data, &m); err != nil {
return err
}
return s.Extract(m)
} | [
"func",
"(",
"s",
"*",
"Schema",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"m",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
... | // UnmarshalJSON takes a JSON string and initializes
// the schema | [
"UnmarshalJSON",
"takes",
"a",
"JSON",
"string",
"and",
"initializes",
"the",
"schema"
] | 5c81c58ffcc359c4390d440b45f5462edb0107cb | https://github.com/lestrrat-go/jsschema/blob/5c81c58ffcc359c4390d440b45f5462edb0107cb/marshal.go#L463-L470 |
140,933 | influxdata/usage-client | v1/client.go | Save | func (c *Client) Save(s Saveable) (*http.Response, error) {
u := fmt.Sprintf("%s/api/v1%s", c.URL, s.Path())
b, err := json.Marshal(s)
if err != nil {
return nil, err
}
req, err := http.NewRequest("POST", u, bytes.NewReader(b))
req.Header.Set("Content-Type", "application/json")
if err != nil {
return nil, ... | go | func (c *Client) Save(s Saveable) (*http.Response, error) {
u := fmt.Sprintf("%s/api/v1%s", c.URL, s.Path())
b, err := json.Marshal(s)
if err != nil {
return nil, err
}
req, err := http.NewRequest("POST", u, bytes.NewReader(b))
req.Header.Set("Content-Type", "application/json")
if err != nil {
return nil, ... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Save",
"(",
"s",
"Saveable",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"u",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"URL",
",",
"s",
".",
"Path",
"(",
")",
")... | // Save does all of the heavy lifting of saving a Saveable
// Type to the Usage API. This will take care of things
// like building the full path, setting the `token` on the
// request if one is available, etc... It will also check
// the status code of the response and handle non-successful
// responses by generating ... | [
"Save",
"does",
"all",
"of",
"the",
"heavy",
"lifting",
"of",
"saving",
"a",
"Saveable",
"Type",
"to",
"the",
"Usage",
"API",
".",
"This",
"will",
"take",
"care",
"of",
"things",
"like",
"building",
"the",
"full",
"path",
"setting",
"the",
"token",
"on",... | 6d3895376368aa52a3a81d2a16e90f0f52371967 | https://github.com/influxdata/usage-client/blob/6d3895376368aa52a3a81d2a16e90f0f52371967/v1/client.go#L48-L101 |
140,934 | influxdata/usage-client | v1/registration.go | IsValid | func (r Registration) IsValid() error {
if r.ClusterID == "" || r.Product == "" {
return errors.New("You must supply both a ClusterID and a Product!")
}
return nil
} | go | func (r Registration) IsValid() error {
if r.ClusterID == "" || r.Product == "" {
return errors.New("You must supply both a ClusterID and a Product!")
}
return nil
} | [
"func",
"(",
"r",
"Registration",
")",
"IsValid",
"(",
")",
"error",
"{",
"if",
"r",
".",
"ClusterID",
"==",
"\"",
"\"",
"||",
"r",
".",
"Product",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"r... | // IsValid returns an error if the Registration is not valid.
// This is necessary since there is no server-side validation
// of this data. | [
"IsValid",
"returns",
"an",
"error",
"if",
"the",
"Registration",
"is",
"not",
"valid",
".",
"This",
"is",
"necessary",
"since",
"there",
"is",
"no",
"server",
"-",
"side",
"validation",
"of",
"this",
"data",
"."
] | 6d3895376368aa52a3a81d2a16e90f0f52371967 | https://github.com/influxdata/usage-client/blob/6d3895376368aa52a3a81d2a16e90f0f52371967/v1/registration.go#L22-L27 |
140,935 | influxdata/usage-client | v1/registration.go | RegistrationURL | func (c *Client) RegistrationURL(r Registration) (string, error) {
err := r.IsValid()
if err != nil {
return "", err
}
u, _ := url.Parse(c.URL)
u.Path = "/start"
q := u.Query()
q.Set("cluster_id", r.ClusterID)
q.Set("product", r.Product)
if r.RedirectURL != "" {
q.Set("redirect_url", r.RedirectURL)
}
u... | go | func (c *Client) RegistrationURL(r Registration) (string, error) {
err := r.IsValid()
if err != nil {
return "", err
}
u, _ := url.Parse(c.URL)
u.Path = "/start"
q := u.Query()
q.Set("cluster_id", r.ClusterID)
q.Set("product", r.Product)
if r.RedirectURL != "" {
q.Set("redirect_url", r.RedirectURL)
}
u... | [
"func",
"(",
"c",
"*",
"Client",
")",
"RegistrationURL",
"(",
"r",
"Registration",
")",
"(",
"string",
",",
"error",
")",
"{",
"err",
":=",
"r",
".",
"IsValid",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n"... | // RegistrationURL returns a URL based on the Registration
// data provided. The app can then use this URL to direct
// customers over to the Enterprise application to complete
// their registration. | [
"RegistrationURL",
"returns",
"a",
"URL",
"based",
"on",
"the",
"Registration",
"data",
"provided",
".",
"The",
"app",
"can",
"then",
"use",
"this",
"URL",
"to",
"direct",
"customers",
"over",
"to",
"the",
"Enterprise",
"application",
"to",
"complete",
"their"... | 6d3895376368aa52a3a81d2a16e90f0f52371967 | https://github.com/influxdata/usage-client/blob/6d3895376368aa52a3a81d2a16e90f0f52371967/v1/registration.go#L33-L51 |
140,936 | docker/libtrust | util.go | LoadOrCreateTrustKey | func LoadOrCreateTrustKey(trustKeyPath string) (PrivateKey, error) {
if err := os.MkdirAll(filepath.Dir(trustKeyPath), 0700); err != nil {
return nil, err
}
trustKey, err := LoadKeyFile(trustKeyPath)
if err == ErrKeyFileDoesNotExist {
trustKey, err = GenerateECP256PrivateKey()
if err != nil {
return nil, ... | go | func LoadOrCreateTrustKey(trustKeyPath string) (PrivateKey, error) {
if err := os.MkdirAll(filepath.Dir(trustKeyPath), 0700); err != nil {
return nil, err
}
trustKey, err := LoadKeyFile(trustKeyPath)
if err == ErrKeyFileDoesNotExist {
trustKey, err = GenerateECP256PrivateKey()
if err != nil {
return nil, ... | [
"func",
"LoadOrCreateTrustKey",
"(",
"trustKeyPath",
"string",
")",
"(",
"PrivateKey",
",",
"error",
")",
"{",
"if",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"filepath",
".",
"Dir",
"(",
"trustKeyPath",
")",
",",
"0700",
")",
";",
"err",
"!=",
"nil",
"... | // LoadOrCreateTrustKey will load a PrivateKey from the specified path | [
"LoadOrCreateTrustKey",
"will",
"load",
"a",
"PrivateKey",
"from",
"the",
"specified",
"path"
] | aabc10ec26b754e797f9028f4589c5b7bd90dc20 | https://github.com/docker/libtrust/blob/aabc10ec26b754e797f9028f4589c5b7bd90dc20/util.go#L24-L48 |
140,937 | docker/libtrust | jsonsign.go | Sign | func (js *JSONSignature) Sign(key PrivateKey) error {
protected, err := js.protectedHeader()
if err != nil {
return err
}
signBytes, err := js.signBytes(protected)
if err != nil {
return err
}
sigBytes, algorithm, err := key.Sign(bytes.NewReader(signBytes), crypto.SHA256)
if err != nil {
return err
}
j... | go | func (js *JSONSignature) Sign(key PrivateKey) error {
protected, err := js.protectedHeader()
if err != nil {
return err
}
signBytes, err := js.signBytes(protected)
if err != nil {
return err
}
sigBytes, algorithm, err := key.Sign(bytes.NewReader(signBytes), crypto.SHA256)
if err != nil {
return err
}
j... | [
"func",
"(",
"js",
"*",
"JSONSignature",
")",
"Sign",
"(",
"key",
"PrivateKey",
")",
"error",
"{",
"protected",
",",
"err",
":=",
"js",
".",
"protectedHeader",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"signByte... | // Sign adds a signature using the given private key. | [
"Sign",
"adds",
"a",
"signature",
"using",
"the",
"given",
"private",
"key",
"."
] | aabc10ec26b754e797f9028f4589c5b7bd90dc20 | https://github.com/docker/libtrust/blob/aabc10ec26b754e797f9028f4589c5b7bd90dc20/jsonsign.go#L105-L129 |
140,938 | docker/libtrust | jsonsign.go | SignWithChain | func (js *JSONSignature) SignWithChain(key PrivateKey, chain []*x509.Certificate) error {
// Ensure key.Chain[0] is public key for key
//key.Chain.PublicKey
//key.PublicKey().CryptoPublicKey()
// Verify chain
protected, err := js.protectedHeader()
if err != nil {
return err
}
signBytes, err := js.signBytes(p... | go | func (js *JSONSignature) SignWithChain(key PrivateKey, chain []*x509.Certificate) error {
// Ensure key.Chain[0] is public key for key
//key.Chain.PublicKey
//key.PublicKey().CryptoPublicKey()
// Verify chain
protected, err := js.protectedHeader()
if err != nil {
return err
}
signBytes, err := js.signBytes(p... | [
"func",
"(",
"js",
"*",
"JSONSignature",
")",
"SignWithChain",
"(",
"key",
"PrivateKey",
",",
"chain",
"[",
"]",
"*",
"x509",
".",
"Certificate",
")",
"error",
"{",
"// Ensure key.Chain[0] is public key for key",
"//key.Chain.PublicKey",
"//key.PublicKey().CryptoPublicK... | // SignWithChain adds a signature using the given private key
// and setting the x509 chain. The public key of the first element
// in the chain must be the public key corresponding with the sign key. | [
"SignWithChain",
"adds",
"a",
"signature",
"using",
"the",
"given",
"private",
"key",
"and",
"setting",
"the",
"x509",
"chain",
".",
"The",
"public",
"key",
"of",
"the",
"first",
"element",
"in",
"the",
"chain",
"must",
"be",
"the",
"public",
"key",
"corre... | aabc10ec26b754e797f9028f4589c5b7bd90dc20 | https://github.com/docker/libtrust/blob/aabc10ec26b754e797f9028f4589c5b7bd90dc20/jsonsign.go#L134-L169 |
140,939 | docker/libtrust | jsonsign.go | Verify | func (js *JSONSignature) Verify() ([]PublicKey, error) {
keys := make([]PublicKey, len(js.signatures))
for i, signature := range js.signatures {
signBytes, err := js.signBytes(signature.Protected)
if err != nil {
return nil, err
}
var publicKey PublicKey
if len(signature.Header.Chain) > 0 {
certBytes,... | go | func (js *JSONSignature) Verify() ([]PublicKey, error) {
keys := make([]PublicKey, len(js.signatures))
for i, signature := range js.signatures {
signBytes, err := js.signBytes(signature.Protected)
if err != nil {
return nil, err
}
var publicKey PublicKey
if len(signature.Header.Chain) > 0 {
certBytes,... | [
"func",
"(",
"js",
"*",
"JSONSignature",
")",
"Verify",
"(",
")",
"(",
"[",
"]",
"PublicKey",
",",
"error",
")",
"{",
"keys",
":=",
"make",
"(",
"[",
"]",
"PublicKey",
",",
"len",
"(",
"js",
".",
"signatures",
")",
")",
"\n",
"for",
"i",
",",
"... | // Verify verifies all the signatures and returns the list of
// public keys used to sign. Any x509 chains are not checked. | [
"Verify",
"verifies",
"all",
"the",
"signatures",
"and",
"returns",
"the",
"list",
"of",
"public",
"keys",
"used",
"to",
"sign",
".",
"Any",
"x509",
"chains",
"are",
"not",
"checked",
"."
] | aabc10ec26b754e797f9028f4589c5b7bd90dc20 | https://github.com/docker/libtrust/blob/aabc10ec26b754e797f9028f4589c5b7bd90dc20/jsonsign.go#L173-L213 |
140,940 | docker/libtrust | jsonsign.go | VerifyChains | func (js *JSONSignature) VerifyChains(ca *x509.CertPool) ([][]*x509.Certificate, error) {
chains := make([][]*x509.Certificate, 0, len(js.signatures))
for _, signature := range js.signatures {
signBytes, err := js.signBytes(signature.Protected)
if err != nil {
return nil, err
}
var publicKey PublicKey
if... | go | func (js *JSONSignature) VerifyChains(ca *x509.CertPool) ([][]*x509.Certificate, error) {
chains := make([][]*x509.Certificate, 0, len(js.signatures))
for _, signature := range js.signatures {
signBytes, err := js.signBytes(signature.Protected)
if err != nil {
return nil, err
}
var publicKey PublicKey
if... | [
"func",
"(",
"js",
"*",
"JSONSignature",
")",
"VerifyChains",
"(",
"ca",
"*",
"x509",
".",
"CertPool",
")",
"(",
"[",
"]",
"[",
"]",
"*",
"x509",
".",
"Certificate",
",",
"error",
")",
"{",
"chains",
":=",
"make",
"(",
"[",
"]",
"[",
"]",
"*",
... | // VerifyChains verifies all the signatures and the chains associated
// with each signature and returns the list of verified chains.
// Signatures without an x509 chain are not checked. | [
"VerifyChains",
"verifies",
"all",
"the",
"signatures",
"and",
"the",
"chains",
"associated",
"with",
"each",
"signature",
"and",
"returns",
"the",
"list",
"of",
"verified",
"chains",
".",
"Signatures",
"without",
"an",
"x509",
"chain",
"are",
"not",
"checked",
... | aabc10ec26b754e797f9028f4589c5b7bd90dc20 | https://github.com/docker/libtrust/blob/aabc10ec26b754e797f9028f4589c5b7bd90dc20/jsonsign.go#L218-L279 |
140,941 | docker/libtrust | jsonsign.go | ParseJWS | func ParseJWS(content []byte) (*JSONSignature, error) {
type jsParsed struct {
Payload string `json:"payload"`
Signatures []jsParsedSignature `json:"signatures"`
}
parsed := &jsParsed{}
err := json.Unmarshal(content, parsed)
if err != nil {
return nil, err
}
if len(parsed.Signatures) == 0 {... | go | func ParseJWS(content []byte) (*JSONSignature, error) {
type jsParsed struct {
Payload string `json:"payload"`
Signatures []jsParsedSignature `json:"signatures"`
}
parsed := &jsParsed{}
err := json.Unmarshal(content, parsed)
if err != nil {
return nil, err
}
if len(parsed.Signatures) == 0 {... | [
"func",
"ParseJWS",
"(",
"content",
"[",
"]",
"byte",
")",
"(",
"*",
"JSONSignature",
",",
"error",
")",
"{",
"type",
"jsParsed",
"struct",
"{",
"Payload",
"string",
"`json:\"payload\"`",
"\n",
"Signatures",
"[",
"]",
"jsParsedSignature",
"`json:\"signatures\"`"... | // ParseJWS parses a JWS serialized JSON object into a Json Signature. | [
"ParseJWS",
"parses",
"a",
"JWS",
"serialized",
"JSON",
"object",
"into",
"a",
"Json",
"Signature",
"."
] | aabc10ec26b754e797f9028f4589c5b7bd90dc20 | https://github.com/docker/libtrust/blob/aabc10ec26b754e797f9028f4589c5b7bd90dc20/jsonsign.go#L325-L370 |
140,942 | docker/libtrust | jsonsign.go | NewJSONSignature | func NewJSONSignature(content []byte, signatures ...[]byte) (*JSONSignature, error) {
var dataMap map[string]interface{}
err := json.Unmarshal(content, &dataMap)
if err != nil {
return nil, err
}
js := newJSONSignature()
js.indent = detectJSONIndent(content)
js.payload = joseBase64UrlEncode(content)
// Fin... | go | func NewJSONSignature(content []byte, signatures ...[]byte) (*JSONSignature, error) {
var dataMap map[string]interface{}
err := json.Unmarshal(content, &dataMap)
if err != nil {
return nil, err
}
js := newJSONSignature()
js.indent = detectJSONIndent(content)
js.payload = joseBase64UrlEncode(content)
// Fin... | [
"func",
"NewJSONSignature",
"(",
"content",
"[",
"]",
"byte",
",",
"signatures",
"...",
"[",
"]",
"byte",
")",
"(",
"*",
"JSONSignature",
",",
"error",
")",
"{",
"var",
"dataMap",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"\n",
"err",
":=",
"... | // NewJSONSignature returns a new unsigned JWS from a json byte array.
// JSONSignature will need to be signed before serializing or storing.
// Optionally, one or more signatures can be provided as byte buffers,
// containing serialized JWS signatures, to assemble a fully signed JWS
// package. It is the callers respo... | [
"NewJSONSignature",
"returns",
"a",
"new",
"unsigned",
"JWS",
"from",
"a",
"json",
"byte",
"array",
".",
"JSONSignature",
"will",
"need",
"to",
"be",
"signed",
"before",
"serializing",
"or",
"storing",
".",
"Optionally",
"one",
"or",
"more",
"signatures",
"can... | aabc10ec26b754e797f9028f4589c5b7bd90dc20 | https://github.com/docker/libtrust/blob/aabc10ec26b754e797f9028f4589c5b7bd90dc20/jsonsign.go#L378-L437 |
140,943 | docker/libtrust | jsonsign.go | NewJSONSignatureFromMap | func NewJSONSignatureFromMap(content interface{}) (*JSONSignature, error) {
switch content.(type) {
case map[string]interface{}:
case struct{}:
default:
return nil, errors.New("invalid data type")
}
js := newJSONSignature()
js.indent = " "
payload, err := json.MarshalIndent(content, "", js.indent)
if err... | go | func NewJSONSignatureFromMap(content interface{}) (*JSONSignature, error) {
switch content.(type) {
case map[string]interface{}:
case struct{}:
default:
return nil, errors.New("invalid data type")
}
js := newJSONSignature()
js.indent = " "
payload, err := json.MarshalIndent(content, "", js.indent)
if err... | [
"func",
"NewJSONSignatureFromMap",
"(",
"content",
"interface",
"{",
"}",
")",
"(",
"*",
"JSONSignature",
",",
"error",
")",
"{",
"switch",
"content",
".",
"(",
"type",
")",
"{",
"case",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
":",
"case",
"s... | // NewJSONSignatureFromMap returns a new unsigned JSONSignature from a map or
// struct. JWS will need to be signed before serializing or storing. | [
"NewJSONSignatureFromMap",
"returns",
"a",
"new",
"unsigned",
"JSONSignature",
"from",
"a",
"map",
"or",
"struct",
".",
"JWS",
"will",
"need",
"to",
"be",
"signed",
"before",
"serializing",
"or",
"storing",
"."
] | aabc10ec26b754e797f9028f4589c5b7bd90dc20 | https://github.com/docker/libtrust/blob/aabc10ec26b754e797f9028f4589c5b7bd90dc20/jsonsign.go#L441-L463 |
140,944 | docker/libtrust | jsonsign.go | PrettySignature | func (js *JSONSignature) PrettySignature(signatureKey string) ([]byte, error) {
if len(js.signatures) == 0 {
return nil, errors.New("no signatures")
}
payload, err := joseBase64UrlDecode(js.payload)
if err != nil {
return nil, err
}
payload = payload[:js.formatLength]
sort.Sort(jsSignaturesSorted(js.signatu... | go | func (js *JSONSignature) PrettySignature(signatureKey string) ([]byte, error) {
if len(js.signatures) == 0 {
return nil, errors.New("no signatures")
}
payload, err := joseBase64UrlDecode(js.payload)
if err != nil {
return nil, err
}
payload = payload[:js.formatLength]
sort.Sort(jsSignaturesSorted(js.signatu... | [
"func",
"(",
"js",
"*",
"JSONSignature",
")",
"PrettySignature",
"(",
"signatureKey",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"len",
"(",
"js",
".",
"signatures",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"errors",
".",
... | // PrettySignature formats a json signature into an easy to read
// single json serialized object. | [
"PrettySignature",
"formats",
"a",
"json",
"signature",
"into",
"an",
"easy",
"to",
"read",
"single",
"json",
"serialized",
"object",
"."
] | aabc10ec26b754e797f9028f4589c5b7bd90dc20 | https://github.com/docker/libtrust/blob/aabc10ec26b754e797f9028f4589c5b7bd90dc20/jsonsign.go#L578-L621 |
140,945 | docker/libtrust | jsonsign.go | Signatures | func (js *JSONSignature) Signatures() ([][]byte, error) {
sort.Sort(jsSignaturesSorted(js.signatures))
var sb [][]byte
for _, jsig := range js.signatures {
p, err := json.Marshal(jsig)
if err != nil {
return nil, err
}
sb = append(sb, p)
}
return sb, nil
} | go | func (js *JSONSignature) Signatures() ([][]byte, error) {
sort.Sort(jsSignaturesSorted(js.signatures))
var sb [][]byte
for _, jsig := range js.signatures {
p, err := json.Marshal(jsig)
if err != nil {
return nil, err
}
sb = append(sb, p)
}
return sb, nil
} | [
"func",
"(",
"js",
"*",
"JSONSignature",
")",
"Signatures",
"(",
")",
"(",
"[",
"]",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"sort",
".",
"Sort",
"(",
"jsSignaturesSorted",
"(",
"js",
".",
"signatures",
")",
")",
"\n\n",
"var",
"sb",
"[",
"]",
... | // Signatures provides the signatures on this JWS as opaque blobs, sorted by
// keyID. These blobs can be stored and reassembled with payloads. Internally,
// they are simply marshaled json web signatures but implementations should
// not rely on this. | [
"Signatures",
"provides",
"the",
"signatures",
"on",
"this",
"JWS",
"as",
"opaque",
"blobs",
"sorted",
"by",
"keyID",
".",
"These",
"blobs",
"can",
"be",
"stored",
"and",
"reassembled",
"with",
"payloads",
".",
"Internally",
"they",
"are",
"simply",
"marshaled... | aabc10ec26b754e797f9028f4589c5b7bd90dc20 | https://github.com/docker/libtrust/blob/aabc10ec26b754e797f9028f4589c5b7bd90dc20/jsonsign.go#L627-L641 |
140,946 | docker/libtrust | jsonsign.go | Merge | func (js *JSONSignature) Merge(others ...*JSONSignature) error {
merged := js.signatures
for _, other := range others {
if js.payload != other.payload {
return fmt.Errorf("payloads differ from merge target")
}
merged = append(merged, other.signatures...)
}
js.signatures = merged
return nil
} | go | func (js *JSONSignature) Merge(others ...*JSONSignature) error {
merged := js.signatures
for _, other := range others {
if js.payload != other.payload {
return fmt.Errorf("payloads differ from merge target")
}
merged = append(merged, other.signatures...)
}
js.signatures = merged
return nil
} | [
"func",
"(",
"js",
"*",
"JSONSignature",
")",
"Merge",
"(",
"others",
"...",
"*",
"JSONSignature",
")",
"error",
"{",
"merged",
":=",
"js",
".",
"signatures",
"\n",
"for",
"_",
",",
"other",
":=",
"range",
"others",
"{",
"if",
"js",
".",
"payload",
"... | // Merge combines the signatures from one or more other signatures into the
// method receiver. If the payloads differ for any argument, an error will be
// returned and the receiver will not be modified. | [
"Merge",
"combines",
"the",
"signatures",
"from",
"one",
"or",
"more",
"other",
"signatures",
"into",
"the",
"method",
"receiver",
".",
"If",
"the",
"payloads",
"differ",
"for",
"any",
"argument",
"an",
"error",
"will",
"be",
"returned",
"and",
"the",
"recei... | aabc10ec26b754e797f9028f4589c5b7bd90dc20 | https://github.com/docker/libtrust/blob/aabc10ec26b754e797f9028f4589c5b7bd90dc20/jsonsign.go#L646-L657 |
140,947 | docker/libtrust | key_manager.go | NewClientKeyManager | func NewClientKeyManager(trustKey PrivateKey, clientFile, clientDir string) (*ClientKeyManager, error) {
m := &ClientKeyManager{
key: trustKey,
clientFile: clientFile,
clientDir: clientDir,
}
if err := m.loadKeys(); err != nil {
return nil, err
}
// TODO Start watching file and directory
return m... | go | func NewClientKeyManager(trustKey PrivateKey, clientFile, clientDir string) (*ClientKeyManager, error) {
m := &ClientKeyManager{
key: trustKey,
clientFile: clientFile,
clientDir: clientDir,
}
if err := m.loadKeys(); err != nil {
return nil, err
}
// TODO Start watching file and directory
return m... | [
"func",
"NewClientKeyManager",
"(",
"trustKey",
"PrivateKey",
",",
"clientFile",
",",
"clientDir",
"string",
")",
"(",
"*",
"ClientKeyManager",
",",
"error",
")",
"{",
"m",
":=",
"&",
"ClientKeyManager",
"{",
"key",
":",
"trustKey",
",",
"clientFile",
":",
"... | // NewClientKeyManager loads a new manager from a set of key files
// and managed by the given private key. | [
"NewClientKeyManager",
"loads",
"a",
"new",
"manager",
"from",
"a",
"set",
"of",
"key",
"files",
"and",
"managed",
"by",
"the",
"given",
"private",
"key",
"."
] | aabc10ec26b754e797f9028f4589c5b7bd90dc20 | https://github.com/docker/libtrust/blob/aabc10ec26b754e797f9028f4589c5b7bd90dc20/key_manager.go#L29-L41 |
140,948 | docker/libtrust | key_manager.go | RegisterTLSConfig | func (c *ClientKeyManager) RegisterTLSConfig(tlsConfig *tls.Config) error {
c.clientLock.RLock()
certPool, err := GenerateCACertPool(c.key, c.clients)
if err != nil {
return fmt.Errorf("CA pool generation error: %s", err)
}
c.clientLock.RUnlock()
tlsConfig.ClientCAs = certPool
c.configLock.Lock()
c.configs ... | go | func (c *ClientKeyManager) RegisterTLSConfig(tlsConfig *tls.Config) error {
c.clientLock.RLock()
certPool, err := GenerateCACertPool(c.key, c.clients)
if err != nil {
return fmt.Errorf("CA pool generation error: %s", err)
}
c.clientLock.RUnlock()
tlsConfig.ClientCAs = certPool
c.configLock.Lock()
c.configs ... | [
"func",
"(",
"c",
"*",
"ClientKeyManager",
")",
"RegisterTLSConfig",
"(",
"tlsConfig",
"*",
"tls",
".",
"Config",
")",
"error",
"{",
"c",
".",
"clientLock",
".",
"RLock",
"(",
")",
"\n",
"certPool",
",",
"err",
":=",
"GenerateCACertPool",
"(",
"c",
".",
... | // RegisterTLSConfig registers a tls configuration to manager
// such that any changes to the keys may be reflected in
// the tls client CA pool | [
"RegisterTLSConfig",
"registers",
"a",
"tls",
"configuration",
"to",
"manager",
"such",
"that",
"any",
"changes",
"to",
"the",
"keys",
"may",
"be",
"reflected",
"in",
"the",
"tls",
"client",
"CA",
"pool"
] | aabc10ec26b754e797f9028f4589c5b7bd90dc20 | https://github.com/docker/libtrust/blob/aabc10ec26b754e797f9028f4589c5b7bd90dc20/key_manager.go#L78-L93 |
140,949 | docker/libtrust | key_manager.go | NewIdentityAuthTLSConfig | func NewIdentityAuthTLSConfig(trustKey PrivateKey, clients *ClientKeyManager, addr string, domain string) (*tls.Config, error) {
tlsConfig := newTLSConfig()
tlsConfig.ClientAuth = tls.RequireAndVerifyClientCert
if err := clients.RegisterTLSConfig(tlsConfig); err != nil {
return nil, err
}
// Generate cert
ips... | go | func NewIdentityAuthTLSConfig(trustKey PrivateKey, clients *ClientKeyManager, addr string, domain string) (*tls.Config, error) {
tlsConfig := newTLSConfig()
tlsConfig.ClientAuth = tls.RequireAndVerifyClientCert
if err := clients.RegisterTLSConfig(tlsConfig); err != nil {
return nil, err
}
// Generate cert
ips... | [
"func",
"NewIdentityAuthTLSConfig",
"(",
"trustKey",
"PrivateKey",
",",
"clients",
"*",
"ClientKeyManager",
",",
"addr",
"string",
",",
"domain",
"string",
")",
"(",
"*",
"tls",
".",
"Config",
",",
"error",
")",
"{",
"tlsConfig",
":=",
"newTLSConfig",
"(",
"... | // NewIdentityAuthTLSConfig creates a tls.Config for the server to use for
// libtrust identity authentication for the domain specified | [
"NewIdentityAuthTLSConfig",
"creates",
"a",
"tls",
".",
"Config",
"for",
"the",
"server",
"to",
"use",
"for",
"libtrust",
"identity",
"authentication",
"for",
"the",
"domain",
"specified"
] | aabc10ec26b754e797f9028f4589c5b7bd90dc20 | https://github.com/docker/libtrust/blob/aabc10ec26b754e797f9028f4589c5b7bd90dc20/key_manager.go#L97-L123 |
140,950 | docker/libtrust | key_manager.go | NewCertAuthTLSConfig | func NewCertAuthTLSConfig(caPath, certPath, keyPath string) (*tls.Config, error) {
tlsConfig := newTLSConfig()
cert, err := tls.LoadX509KeyPair(certPath, keyPath)
if err != nil {
return nil, fmt.Errorf("Couldn't load X509 key pair (%s, %s): %s. Key encrypted?", certPath, keyPath, err)
}
tlsConfig.Certificates =... | go | func NewCertAuthTLSConfig(caPath, certPath, keyPath string) (*tls.Config, error) {
tlsConfig := newTLSConfig()
cert, err := tls.LoadX509KeyPair(certPath, keyPath)
if err != nil {
return nil, fmt.Errorf("Couldn't load X509 key pair (%s, %s): %s. Key encrypted?", certPath, keyPath, err)
}
tlsConfig.Certificates =... | [
"func",
"NewCertAuthTLSConfig",
"(",
"caPath",
",",
"certPath",
",",
"keyPath",
"string",
")",
"(",
"*",
"tls",
".",
"Config",
",",
"error",
")",
"{",
"tlsConfig",
":=",
"newTLSConfig",
"(",
")",
"\n\n",
"cert",
",",
"err",
":=",
"tls",
".",
"LoadX509Key... | // NewCertAuthTLSConfig creates a tls.Config for the server to use for
// certificate authentication | [
"NewCertAuthTLSConfig",
"creates",
"a",
"tls",
".",
"Config",
"for",
"the",
"server",
"to",
"use",
"for",
"certificate",
"authentication"
] | aabc10ec26b754e797f9028f4589c5b7bd90dc20 | https://github.com/docker/libtrust/blob/aabc10ec26b754e797f9028f4589c5b7bd90dc20/key_manager.go#L127-L150 |
140,951 | docker/libtrust | key_manager.go | parseAddr | func parseAddr(addr string) ([]net.IP, []string, error) {
host, _, err := net.SplitHostPort(addr)
if err != nil {
return nil, nil, err
}
var domains []string
var ips []net.IP
ip := net.ParseIP(host)
if ip != nil {
ips = []net.IP{ip}
} else {
domains = []string{host}
}
return ips, domains, nil
} | go | func parseAddr(addr string) ([]net.IP, []string, error) {
host, _, err := net.SplitHostPort(addr)
if err != nil {
return nil, nil, err
}
var domains []string
var ips []net.IP
ip := net.ParseIP(host)
if ip != nil {
ips = []net.IP{ip}
} else {
domains = []string{host}
}
return ips, domains, nil
} | [
"func",
"parseAddr",
"(",
"addr",
"string",
")",
"(",
"[",
"]",
"net",
".",
"IP",
",",
"[",
"]",
"string",
",",
"error",
")",
"{",
"host",
",",
"_",
",",
"err",
":=",
"net",
".",
"SplitHostPort",
"(",
"addr",
")",
"\n",
"if",
"err",
"!=",
"nil"... | // parseAddr parses an address into an array of IPs and domains | [
"parseAddr",
"parses",
"an",
"address",
"into",
"an",
"array",
"of",
"IPs",
"and",
"domains"
] | aabc10ec26b754e797f9028f4589c5b7bd90dc20 | https://github.com/docker/libtrust/blob/aabc10ec26b754e797f9028f4589c5b7bd90dc20/key_manager.go#L161-L175 |
140,952 | alexsasharegan/dotenv | dotenv.go | ReadFile | func ReadFile(path string) (map[string]string, error) {
f, err := os.Open(path)
if err != nil {
return nil, err
}
defer f.Close()
return Read(f)
} | go | func ReadFile(path string) (map[string]string, error) {
f, err := os.Open(path)
if err != nil {
return nil, err
}
defer f.Close()
return Read(f)
} | [
"func",
"ReadFile",
"(",
"path",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n"... | // ReadFile reads an env file at a given path, and return values as a map. | [
"ReadFile",
"reads",
"an",
"env",
"file",
"at",
"a",
"given",
"path",
"and",
"return",
"values",
"as",
"a",
"map",
"."
] | 090a4d1b5d42ce7c3577c42f282b55fc45d5eab1 | https://github.com/alexsasharegan/dotenv/blob/090a4d1b5d42ce7c3577c42f282b55fc45d5eab1/dotenv.go#L34-L41 |
140,953 | alexsasharegan/dotenv | dotenv.go | Read | func Read(rd io.Reader) (map[string]string, error) {
scanner := bufio.NewScanner(rd)
envMap := make(map[string]string)
var (
line, k, v string
err error
)
for scanner.Scan() {
line = scanner.Text()
if regexVar.MatchString(line) {
line = regexVar.ReplaceAllStringFunc(line, func(s string) string {
... | go | func Read(rd io.Reader) (map[string]string, error) {
scanner := bufio.NewScanner(rd)
envMap := make(map[string]string)
var (
line, k, v string
err error
)
for scanner.Scan() {
line = scanner.Text()
if regexVar.MatchString(line) {
line = regexVar.ReplaceAllStringFunc(line, func(s string) string {
... | [
"func",
"Read",
"(",
"rd",
"io",
".",
"Reader",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"scanner",
":=",
"bufio",
".",
"NewScanner",
"(",
"rd",
")",
"\n",
"envMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"str... | // Read parses the given reader's contents and return values as a map. | [
"Read",
"parses",
"the",
"given",
"reader",
"s",
"contents",
"and",
"return",
"values",
"as",
"a",
"map",
"."
] | 090a4d1b5d42ce7c3577c42f282b55fc45d5eab1 | https://github.com/alexsasharegan/dotenv/blob/090a4d1b5d42ce7c3577c42f282b55fc45d5eab1/dotenv.go#L44-L73 |
140,954 | alexsasharegan/dotenv | dotenv.go | ParseString | func ParseString(s string) (key, value string, err error) {
s = strings.TrimSpace(s)
if strings.HasPrefix(s, "#") {
err = ErrCommentln
return
}
if s == "" {
err = ErrEmptyln
return
}
if !strings.Contains(s, "=") {
err = ErrInvalidln
return
}
var (
buf bytes.Buffer
quoteType rune... | go | func ParseString(s string) (key, value string, err error) {
s = strings.TrimSpace(s)
if strings.HasPrefix(s, "#") {
err = ErrCommentln
return
}
if s == "" {
err = ErrEmptyln
return
}
if !strings.Contains(s, "=") {
err = ErrInvalidln
return
}
var (
buf bytes.Buffer
quoteType rune... | [
"func",
"ParseString",
"(",
"s",
"string",
")",
"(",
"key",
",",
"value",
"string",
",",
"err",
"error",
")",
"{",
"s",
"=",
"strings",
".",
"TrimSpace",
"(",
"s",
")",
"\n",
"if",
"strings",
".",
"HasPrefix",
"(",
"s",
",",
"\"",
"\"",
")",
"{",... | // ParseString parses a given string into a key, value pair.
// Returns the key, value, and an error. | [
"ParseString",
"parses",
"a",
"given",
"string",
"into",
"a",
"key",
"value",
"pair",
".",
"Returns",
"the",
"key",
"value",
"and",
"an",
"error",
"."
] | 090a4d1b5d42ce7c3577c42f282b55fc45d5eab1 | https://github.com/alexsasharegan/dotenv/blob/090a4d1b5d42ce7c3577c42f282b55fc45d5eab1/dotenv.go#L77-L172 |
140,955 | alexsasharegan/dotenv | dotenv.go | Load | func Load(paths ...string) (err error) {
if len(paths) == 0 {
paths = append(paths, ".env")
}
for _, path := range paths {
err = loadFile(path, false)
if err != nil {
return
}
}
return
} | go | func Load(paths ...string) (err error) {
if len(paths) == 0 {
paths = append(paths, ".env")
}
for _, path := range paths {
err = loadFile(path, false)
if err != nil {
return
}
}
return
} | [
"func",
"Load",
"(",
"paths",
"...",
"string",
")",
"(",
"err",
"error",
")",
"{",
"if",
"len",
"(",
"paths",
")",
"==",
"0",
"{",
"paths",
"=",
"append",
"(",
"paths",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"path",
":=",
"ra... | // Load will load a variadic number of environment config files.
// Will not overwrite currently set env vars. | [
"Load",
"will",
"load",
"a",
"variadic",
"number",
"of",
"environment",
"config",
"files",
".",
"Will",
"not",
"overwrite",
"currently",
"set",
"env",
"vars",
"."
] | 090a4d1b5d42ce7c3577c42f282b55fc45d5eab1 | https://github.com/alexsasharegan/dotenv/blob/090a4d1b5d42ce7c3577c42f282b55fc45d5eab1/dotenv.go#L176-L187 |
140,956 | alexsasharegan/dotenv | dotenv.go | Overload | func Overload(paths ...string) (err error) {
if len(paths) == 0 {
paths = append(paths, ".env")
}
for _, path := range paths {
err = loadFile(path, true)
if err != nil {
return
}
}
return
} | go | func Overload(paths ...string) (err error) {
if len(paths) == 0 {
paths = append(paths, ".env")
}
for _, path := range paths {
err = loadFile(path, true)
if err != nil {
return
}
}
return
} | [
"func",
"Overload",
"(",
"paths",
"...",
"string",
")",
"(",
"err",
"error",
")",
"{",
"if",
"len",
"(",
"paths",
")",
"==",
"0",
"{",
"paths",
"=",
"append",
"(",
"paths",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"path",
":=",
... | // Overload will load a variadic number of environment config files.
// Overwrites currently set env vars. | [
"Overload",
"will",
"load",
"a",
"variadic",
"number",
"of",
"environment",
"config",
"files",
".",
"Overwrites",
"currently",
"set",
"env",
"vars",
"."
] | 090a4d1b5d42ce7c3577c42f282b55fc45d5eab1 | https://github.com/alexsasharegan/dotenv/blob/090a4d1b5d42ce7c3577c42f282b55fc45d5eab1/dotenv.go#L191-L202 |
140,957 | alexsasharegan/dotenv | dotenv.go | loadFile | func loadFile(path string, overload bool) error {
env, err := ReadFile(path)
if err != nil {
return err
}
LoadMap(env, overload)
return nil
} | go | func loadFile(path string, overload bool) error {
env, err := ReadFile(path)
if err != nil {
return err
}
LoadMap(env, overload)
return nil
} | [
"func",
"loadFile",
"(",
"path",
"string",
",",
"overload",
"bool",
")",
"error",
"{",
"env",
",",
"err",
":=",
"ReadFile",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"LoadMap",
"(",
"env",
",",
"overlo... | // loadFile parses the environment config at the given path
// and loads it into the os environment. | [
"loadFile",
"parses",
"the",
"environment",
"config",
"at",
"the",
"given",
"path",
"and",
"loads",
"it",
"into",
"the",
"os",
"environment",
"."
] | 090a4d1b5d42ce7c3577c42f282b55fc45d5eab1 | https://github.com/alexsasharegan/dotenv/blob/090a4d1b5d42ce7c3577c42f282b55fc45d5eab1/dotenv.go#L206-L213 |
140,958 | alexsasharegan/dotenv | dotenv.go | LoadReader | func LoadReader(r io.Reader) error {
env, err := Read(r)
if err != nil {
return err
}
LoadMap(env, false)
return nil
} | go | func LoadReader(r io.Reader) error {
env, err := Read(r)
if err != nil {
return err
}
LoadMap(env, false)
return nil
} | [
"func",
"LoadReader",
"(",
"r",
"io",
".",
"Reader",
")",
"error",
"{",
"env",
",",
"err",
":=",
"Read",
"(",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"LoadMap",
"(",
"env",
",",
"false",
")",
"\n",
"retu... | // LoadReader will load an environment config from a reader interface.
// Will not overwrite currently set env vars. | [
"LoadReader",
"will",
"load",
"an",
"environment",
"config",
"from",
"a",
"reader",
"interface",
".",
"Will",
"not",
"overwrite",
"currently",
"set",
"env",
"vars",
"."
] | 090a4d1b5d42ce7c3577c42f282b55fc45d5eab1 | https://github.com/alexsasharegan/dotenv/blob/090a4d1b5d42ce7c3577c42f282b55fc45d5eab1/dotenv.go#L217-L224 |
140,959 | alexsasharegan/dotenv | dotenv.go | LoadMap | func LoadMap(envMap map[string]string, overload bool) {
currentEnv := make(map[string]bool)
for _, rawEnvLine := range os.Environ() {
currentEnv[strings.Split(rawEnvLine, "=")[0]] = true
}
for key, value := range envMap {
if !currentEnv[key] || overload {
os.Setenv(key, value)
}
}
} | go | func LoadMap(envMap map[string]string, overload bool) {
currentEnv := make(map[string]bool)
for _, rawEnvLine := range os.Environ() {
currentEnv[strings.Split(rawEnvLine, "=")[0]] = true
}
for key, value := range envMap {
if !currentEnv[key] || overload {
os.Setenv(key, value)
}
}
} | [
"func",
"LoadMap",
"(",
"envMap",
"map",
"[",
"string",
"]",
"string",
",",
"overload",
"bool",
")",
"{",
"currentEnv",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"bool",
")",
"\n",
"for",
"_",
",",
"rawEnvLine",
":=",
"range",
"os",
".",
"Environ... | // LoadMap loads a map into the os environment, optionally overwriting existing vars. | [
"LoadMap",
"loads",
"a",
"map",
"into",
"the",
"os",
"environment",
"optionally",
"overwriting",
"existing",
"vars",
"."
] | 090a4d1b5d42ce7c3577c42f282b55fc45d5eab1 | https://github.com/alexsasharegan/dotenv/blob/090a4d1b5d42ce7c3577c42f282b55fc45d5eab1/dotenv.go#L227-L238 |
140,960 | meatballhat/negroni-logrus | middleware.go | ExcludeURL | func (m *Middleware) ExcludeURL(u string) error {
if _, err := url.Parse(u); err != nil {
return err
}
m.excludeURLs = append(m.excludeURLs, u)
return nil
} | go | func (m *Middleware) ExcludeURL(u string) error {
if _, err := url.Parse(u); err != nil {
return err
}
m.excludeURLs = append(m.excludeURLs, u)
return nil
} | [
"func",
"(",
"m",
"*",
"Middleware",
")",
"ExcludeURL",
"(",
"u",
"string",
")",
"error",
"{",
"if",
"_",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"u",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"m",
".",
"excludeUR... | // ExcludeURL adds a new URL u to be ignored during logging. The URL u is parsed, hence the returned error | [
"ExcludeURL",
"adds",
"a",
"new",
"URL",
"u",
"to",
"be",
"ignored",
"during",
"logging",
".",
"The",
"URL",
"u",
"is",
"parsed",
"hence",
"the",
"returned",
"error"
] | 31067281800f66f57548a7a32d9c6c5f963fef83 | https://github.com/meatballhat/negroni-logrus/blob/31067281800f66f57548a7a32d9c6c5f963fef83/middleware.go#L87-L93 |
140,961 | belogik/goes | goes.go | NewConnection | func NewConnection(host string, port string) *Connection {
return &Connection{host, port, http.DefaultClient}
} | go | func NewConnection(host string, port string) *Connection {
return &Connection{host, port, http.DefaultClient}
} | [
"func",
"NewConnection",
"(",
"host",
"string",
",",
"port",
"string",
")",
"*",
"Connection",
"{",
"return",
"&",
"Connection",
"{",
"host",
",",
"port",
",",
"http",
".",
"DefaultClient",
"}",
"\n",
"}"
] | // NewConnection initiates a new Connection to an elasticsearch server
//
// This function is pretty useless for now but might be useful in a near future
// if wee need more features like connection pooling or load balancing. | [
"NewConnection",
"initiates",
"a",
"new",
"Connection",
"to",
"an",
"elasticsearch",
"server",
"This",
"function",
"is",
"pretty",
"useless",
"for",
"now",
"but",
"might",
"be",
"useful",
"in",
"a",
"near",
"future",
"if",
"wee",
"need",
"more",
"features",
... | e54d722c3aff588e4c737fe11c07359019240824 | https://github.com/belogik/goes/blob/e54d722c3aff588e4c737fe11c07359019240824/goes.go#L34-L36 |
140,962 | belogik/goes | goes.go | CreateIndex | func (c *Connection) CreateIndex(name string, mapping interface{}) (*Response, error) {
r := Request{
Conn: c,
Query: mapping,
IndexList: []string{name},
method: "PUT",
}
return r.Run()
} | go | func (c *Connection) CreateIndex(name string, mapping interface{}) (*Response, error) {
r := Request{
Conn: c,
Query: mapping,
IndexList: []string{name},
method: "PUT",
}
return r.Run()
} | [
"func",
"(",
"c",
"*",
"Connection",
")",
"CreateIndex",
"(",
"name",
"string",
",",
"mapping",
"interface",
"{",
"}",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"r",
":=",
"Request",
"{",
"Conn",
":",
"c",
",",
"Query",
":",
"mapping",
","... | // CreateIndex creates a new index represented by a name and a mapping | [
"CreateIndex",
"creates",
"a",
"new",
"index",
"represented",
"by",
"a",
"name",
"and",
"a",
"mapping"
] | e54d722c3aff588e4c737fe11c07359019240824 | https://github.com/belogik/goes/blob/e54d722c3aff588e4c737fe11c07359019240824/goes.go#L44-L53 |
140,963 | belogik/goes | goes.go | DeleteIndex | func (c *Connection) DeleteIndex(name string) (*Response, error) {
r := Request{
Conn: c,
IndexList: []string{name},
method: "DELETE",
}
return r.Run()
} | go | func (c *Connection) DeleteIndex(name string) (*Response, error) {
r := Request{
Conn: c,
IndexList: []string{name},
method: "DELETE",
}
return r.Run()
} | [
"func",
"(",
"c",
"*",
"Connection",
")",
"DeleteIndex",
"(",
"name",
"string",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"r",
":=",
"Request",
"{",
"Conn",
":",
"c",
",",
"IndexList",
":",
"[",
"]",
"string",
"{",
"name",
"}",
",",
"met... | // DeleteIndex deletes an index represented by a name | [
"DeleteIndex",
"deletes",
"an",
"index",
"represented",
"by",
"a",
"name"
] | e54d722c3aff588e4c737fe11c07359019240824 | https://github.com/belogik/goes/blob/e54d722c3aff588e4c737fe11c07359019240824/goes.go#L56-L64 |
140,964 | belogik/goes | goes.go | BulkSend | func (c *Connection) BulkSend(documents []Document) (*Response, error) {
// We do not generate a traditional JSON here (often a one liner)
// Elasticsearch expects one line of JSON per line (EOL = \n)
// plus an extra \n at the very end of the document
//
// More informations about the Bulk JSON format for Elastic... | go | func (c *Connection) BulkSend(documents []Document) (*Response, error) {
// We do not generate a traditional JSON here (often a one liner)
// Elasticsearch expects one line of JSON per line (EOL = \n)
// plus an extra \n at the very end of the document
//
// More informations about the Bulk JSON format for Elastic... | [
"func",
"(",
"c",
"*",
"Connection",
")",
"BulkSend",
"(",
"documents",
"[",
"]",
"Document",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"// We do not generate a traditional JSON here (often a one liner)",
"// Elasticsearch expects one line of JSON per line (EOL = \... | // Bulk adds multiple documents in bulk mode | [
"Bulk",
"adds",
"multiple",
"documents",
"in",
"bulk",
"mode"
] | e54d722c3aff588e4c737fe11c07359019240824 | https://github.com/belogik/goes/blob/e54d722c3aff588e4c737fe11c07359019240824/goes.go#L133-L210 |
140,965 | belogik/goes | goes.go | Search | func (c *Connection) Search(query interface{}, indexList []string, typeList []string, extraArgs url.Values) (*Response, error) {
r := Request{
Conn: c,
Query: query,
IndexList: indexList,
TypeList: typeList,
method: "POST",
api: "_search",
ExtraArgs: extraArgs,
}
return r.Run()
} | go | func (c *Connection) Search(query interface{}, indexList []string, typeList []string, extraArgs url.Values) (*Response, error) {
r := Request{
Conn: c,
Query: query,
IndexList: indexList,
TypeList: typeList,
method: "POST",
api: "_search",
ExtraArgs: extraArgs,
}
return r.Run()
} | [
"func",
"(",
"c",
"*",
"Connection",
")",
"Search",
"(",
"query",
"interface",
"{",
"}",
",",
"indexList",
"[",
"]",
"string",
",",
"typeList",
"[",
"]",
"string",
",",
"extraArgs",
"url",
".",
"Values",
")",
"(",
"*",
"Response",
",",
"error",
")",
... | // Search executes a search query against an index | [
"Search",
"executes",
"a",
"search",
"query",
"against",
"an",
"index"
] | e54d722c3aff588e4c737fe11c07359019240824 | https://github.com/belogik/goes/blob/e54d722c3aff588e4c737fe11c07359019240824/goes.go#L213-L225 |
140,966 | belogik/goes | goes.go | Scan | func (c *Connection) Scan(query interface{}, indexList []string, typeList []string, timeout string, size int) (*Response, error) {
v := url.Values{}
v.Add("search_type", "scan")
v.Add("scroll", timeout)
v.Add("size", strconv.Itoa(size))
r := Request{
Conn: c,
Query: query,
IndexList: indexList,
T... | go | func (c *Connection) Scan(query interface{}, indexList []string, typeList []string, timeout string, size int) (*Response, error) {
v := url.Values{}
v.Add("search_type", "scan")
v.Add("scroll", timeout)
v.Add("size", strconv.Itoa(size))
r := Request{
Conn: c,
Query: query,
IndexList: indexList,
T... | [
"func",
"(",
"c",
"*",
"Connection",
")",
"Scan",
"(",
"query",
"interface",
"{",
"}",
",",
"indexList",
"[",
"]",
"string",
",",
"typeList",
"[",
"]",
"string",
",",
"timeout",
"string",
",",
"size",
"int",
")",
"(",
"*",
"Response",
",",
"error",
... | // Scan starts scroll over an index | [
"Scan",
"starts",
"scroll",
"over",
"an",
"index"
] | e54d722c3aff588e4c737fe11c07359019240824 | https://github.com/belogik/goes/blob/e54d722c3aff588e4c737fe11c07359019240824/goes.go#L260-L277 |
140,967 | belogik/goes | goes.go | Scroll | func (c *Connection) Scroll(scrollId string, timeout string) (*Response, error) {
v := url.Values{}
v.Add("scroll", timeout)
r := Request{
Conn: c,
method: "POST",
api: "_search/scroll",
ExtraArgs: v,
Body: []byte(scrollId),
}
return r.Run()
} | go | func (c *Connection) Scroll(scrollId string, timeout string) (*Response, error) {
v := url.Values{}
v.Add("scroll", timeout)
r := Request{
Conn: c,
method: "POST",
api: "_search/scroll",
ExtraArgs: v,
Body: []byte(scrollId),
}
return r.Run()
} | [
"func",
"(",
"c",
"*",
"Connection",
")",
"Scroll",
"(",
"scrollId",
"string",
",",
"timeout",
"string",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"v",
":=",
"url",
".",
"Values",
"{",
"}",
"\n",
"v",
".",
"Add",
"(",
"\"",
"\"",
",",
... | // Scroll fetches data by scroll id | [
"Scroll",
"fetches",
"data",
"by",
"scroll",
"id"
] | e54d722c3aff588e4c737fe11c07359019240824 | https://github.com/belogik/goes/blob/e54d722c3aff588e4c737fe11c07359019240824/goes.go#L280-L293 |
140,968 | belogik/goes | goes.go | Get | func (c *Connection) Get(index string, documentType string, id string, extraArgs url.Values) (*Response, error) {
r := Request{
Conn: c,
IndexList: []string{index},
method: "GET",
api: documentType + "/" + id,
ExtraArgs: extraArgs,
}
return r.Run()
} | go | func (c *Connection) Get(index string, documentType string, id string, extraArgs url.Values) (*Response, error) {
r := Request{
Conn: c,
IndexList: []string{index},
method: "GET",
api: documentType + "/" + id,
ExtraArgs: extraArgs,
}
return r.Run()
} | [
"func",
"(",
"c",
"*",
"Connection",
")",
"Get",
"(",
"index",
"string",
",",
"documentType",
"string",
",",
"id",
"string",
",",
"extraArgs",
"url",
".",
"Values",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"r",
":=",
"Request",
"{",
"Conn",... | // Get a typed document by its id | [
"Get",
"a",
"typed",
"document",
"by",
"its",
"id"
] | e54d722c3aff588e4c737fe11c07359019240824 | https://github.com/belogik/goes/blob/e54d722c3aff588e4c737fe11c07359019240824/goes.go#L296-L306 |
140,969 | belogik/goes | goes.go | Index | func (c *Connection) Index(d Document, extraArgs url.Values) (*Response, error) {
r := Request{
Conn: c,
Query: d.Fields,
IndexList: []string{d.Index.(string)},
TypeList: []string{d.Type},
ExtraArgs: extraArgs,
method: "POST",
}
if d.Id != nil {
r.method = "PUT"
r.id = d.Id.(string)
}
... | go | func (c *Connection) Index(d Document, extraArgs url.Values) (*Response, error) {
r := Request{
Conn: c,
Query: d.Fields,
IndexList: []string{d.Index.(string)},
TypeList: []string{d.Type},
ExtraArgs: extraArgs,
method: "POST",
}
if d.Id != nil {
r.method = "PUT"
r.id = d.Id.(string)
}
... | [
"func",
"(",
"c",
"*",
"Connection",
")",
"Index",
"(",
"d",
"Document",
",",
"extraArgs",
"url",
".",
"Values",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"r",
":=",
"Request",
"{",
"Conn",
":",
"c",
",",
"Query",
":",
"d",
".",
"Fields"... | // Index indexes a Document
// The extraArgs is a list of url.Values that you can send to elasticsearch as
// URL arguments, for example, to control routing, ttl, version, op_type, etc. | [
"Index",
"indexes",
"a",
"Document",
"The",
"extraArgs",
"is",
"a",
"list",
"of",
"url",
".",
"Values",
"that",
"you",
"can",
"send",
"to",
"elasticsearch",
"as",
"URL",
"arguments",
"for",
"example",
"to",
"control",
"routing",
"ttl",
"version",
"op_type",
... | e54d722c3aff588e4c737fe11c07359019240824 | https://github.com/belogik/goes/blob/e54d722c3aff588e4c737fe11c07359019240824/goes.go#L311-L327 |
140,970 | belogik/goes | goes.go | Run | func (req *Request) Run() (*Response, error) {
body, statusCode, err := req.run()
esResp := &Response{Status: statusCode}
if err != nil {
return esResp, err
}
if req.method != "HEAD" {
err = json.Unmarshal(body, &esResp)
if err != nil {
return esResp, err
}
err = json.Unmarshal(body, &esResp.Raw)
... | go | func (req *Request) Run() (*Response, error) {
body, statusCode, err := req.run()
esResp := &Response{Status: statusCode}
if err != nil {
return esResp, err
}
if req.method != "HEAD" {
err = json.Unmarshal(body, &esResp)
if err != nil {
return esResp, err
}
err = json.Unmarshal(body, &esResp.Raw)
... | [
"func",
"(",
"req",
"*",
"Request",
")",
"Run",
"(",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"body",
",",
"statusCode",
",",
"err",
":=",
"req",
".",
"run",
"(",
")",
"\n",
"esResp",
":=",
"&",
"Response",
"{",
"Status",
":",
"statusCo... | // Run executes an elasticsearch Request. It converts data to Json, sends the
// request and returns the Response obtained | [
"Run",
"executes",
"an",
"elasticsearch",
"Request",
".",
"It",
"converts",
"data",
"to",
"Json",
"sends",
"the",
"request",
"and",
"returns",
"the",
"Response",
"obtained"
] | e54d722c3aff588e4c737fe11c07359019240824 | https://github.com/belogik/goes/blob/e54d722c3aff588e4c737fe11c07359019240824/goes.go#L347-L382 |
140,971 | belogik/goes | goes.go | Url | func (r *Request) Url() string {
path := "/" + strings.Join(r.IndexList, ",")
if len(r.TypeList) > 0 {
path += "/" + strings.Join(r.TypeList, ",")
}
// XXX : for indexing documents using the normal (non bulk) API
if len(r.id) > 0 {
path += "/" + r.id
}
path += "/" + r.api
u := url.URL{
Scheme: "http... | go | func (r *Request) Url() string {
path := "/" + strings.Join(r.IndexList, ",")
if len(r.TypeList) > 0 {
path += "/" + strings.Join(r.TypeList, ",")
}
// XXX : for indexing documents using the normal (non bulk) API
if len(r.id) > 0 {
path += "/" + r.id
}
path += "/" + r.api
u := url.URL{
Scheme: "http... | [
"func",
"(",
"r",
"*",
"Request",
")",
"Url",
"(",
")",
"string",
"{",
"path",
":=",
"\"",
"\"",
"+",
"strings",
".",
"Join",
"(",
"r",
".",
"IndexList",
",",
"\"",
"\"",
")",
"\n\n",
"if",
"len",
"(",
"r",
".",
"TypeList",
")",
">",
"0",
"{"... | // Url builds a Request for a URL | [
"Url",
"builds",
"a",
"Request",
"for",
"a",
"URL"
] | e54d722c3aff588e4c737fe11c07359019240824 | https://github.com/belogik/goes/blob/e54d722c3aff588e4c737fe11c07359019240824/goes.go#L431-L453 |
140,972 | belogik/goes | goes.go | Buckets | func (a Aggregation) Buckets() []Bucket {
result := []Bucket{}
if buckets, ok := a["buckets"]; ok {
for _, bucket := range buckets.([]interface{}) {
result = append(result, bucket.(map[string]interface{}))
}
}
return result
} | go | func (a Aggregation) Buckets() []Bucket {
result := []Bucket{}
if buckets, ok := a["buckets"]; ok {
for _, bucket := range buckets.([]interface{}) {
result = append(result, bucket.(map[string]interface{}))
}
}
return result
} | [
"func",
"(",
"a",
"Aggregation",
")",
"Buckets",
"(",
")",
"[",
"]",
"Bucket",
"{",
"result",
":=",
"[",
"]",
"Bucket",
"{",
"}",
"\n",
"if",
"buckets",
",",
"ok",
":=",
"a",
"[",
"\"",
"\"",
"]",
";",
"ok",
"{",
"for",
"_",
",",
"bucket",
":... | // Buckets returns list of buckets in aggregation | [
"Buckets",
"returns",
"list",
"of",
"buckets",
"in",
"aggregation"
] | e54d722c3aff588e4c737fe11c07359019240824 | https://github.com/belogik/goes/blob/e54d722c3aff588e4c737fe11c07359019240824/goes.go#L456-L465 |
140,973 | belogik/goes | goes.go | Aggregation | func (b Bucket) Aggregation(name string) Aggregation {
if agg, ok := b[name]; ok {
return agg.(map[string]interface{})
} else {
return Aggregation{}
}
} | go | func (b Bucket) Aggregation(name string) Aggregation {
if agg, ok := b[name]; ok {
return agg.(map[string]interface{})
} else {
return Aggregation{}
}
} | [
"func",
"(",
"b",
"Bucket",
")",
"Aggregation",
"(",
"name",
"string",
")",
"Aggregation",
"{",
"if",
"agg",
",",
"ok",
":=",
"b",
"[",
"name",
"]",
";",
"ok",
"{",
"return",
"agg",
".",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",... | // Aggregation returns aggregation by name from bucket | [
"Aggregation",
"returns",
"aggregation",
"by",
"name",
"from",
"bucket"
] | e54d722c3aff588e4c737fe11c07359019240824 | https://github.com/belogik/goes/blob/e54d722c3aff588e4c737fe11c07359019240824/goes.go#L478-L484 |
140,974 | belogik/goes | goes.go | PutMapping | func (c *Connection) PutMapping(typeName string, mapping interface{}, indexes []string) (*Response, error) {
r := Request{
Conn: c,
Query: mapping,
IndexList: indexes,
method: "PUT",
api: "_mappings/" + typeName,
}
return r.Run()
} | go | func (c *Connection) PutMapping(typeName string, mapping interface{}, indexes []string) (*Response, error) {
r := Request{
Conn: c,
Query: mapping,
IndexList: indexes,
method: "PUT",
api: "_mappings/" + typeName,
}
return r.Run()
} | [
"func",
"(",
"c",
"*",
"Connection",
")",
"PutMapping",
"(",
"typeName",
"string",
",",
"mapping",
"interface",
"{",
"}",
",",
"indexes",
"[",
"]",
"string",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"r",
":=",
"Request",
"{",
"Conn",
":",
... | // PutMapping registers a specific mapping for one or more types in one or more indexes | [
"PutMapping",
"registers",
"a",
"specific",
"mapping",
"for",
"one",
"or",
"more",
"types",
"in",
"one",
"or",
"more",
"indexes"
] | e54d722c3aff588e4c737fe11c07359019240824 | https://github.com/belogik/goes/blob/e54d722c3aff588e4c737fe11c07359019240824/goes.go#L487-L498 |
140,975 | belogik/goes | goes.go | DeleteMapping | func (c *Connection) DeleteMapping(typeName string, indexes []string) (*Response, error) {
r := Request{
Conn: c,
IndexList: indexes,
method: "DELETE",
api: "_mappings/" + typeName,
}
return r.Run()
} | go | func (c *Connection) DeleteMapping(typeName string, indexes []string) (*Response, error) {
r := Request{
Conn: c,
IndexList: indexes,
method: "DELETE",
api: "_mappings/" + typeName,
}
return r.Run()
} | [
"func",
"(",
"c",
"*",
"Connection",
")",
"DeleteMapping",
"(",
"typeName",
"string",
",",
"indexes",
"[",
"]",
"string",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"r",
":=",
"Request",
"{",
"Conn",
":",
"c",
",",
"IndexList",
":",
"indexes"... | // DeleteMapping deletes a mapping along with all data in the type | [
"DeleteMapping",
"deletes",
"a",
"mapping",
"along",
"with",
"all",
"data",
"in",
"the",
"type"
] | e54d722c3aff588e4c737fe11c07359019240824 | https://github.com/belogik/goes/blob/e54d722c3aff588e4c737fe11c07359019240824/goes.go#L545-L555 |
140,976 | belogik/goes | goes.go | AddAlias | func (c *Connection) AddAlias(alias string, indexes []string) (*Response, error) {
return c.modifyAlias("add", alias, indexes)
} | go | func (c *Connection) AddAlias(alias string, indexes []string) (*Response, error) {
return c.modifyAlias("add", alias, indexes)
} | [
"func",
"(",
"c",
"*",
"Connection",
")",
"AddAlias",
"(",
"alias",
"string",
",",
"indexes",
"[",
"]",
"string",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"return",
"c",
".",
"modifyAlias",
"(",
"\"",
"\"",
",",
"alias",
",",
"indexes",
"... | // AddAlias creates an alias to one or more indexes | [
"AddAlias",
"creates",
"an",
"alias",
"to",
"one",
"or",
"more",
"indexes"
] | e54d722c3aff588e4c737fe11c07359019240824 | https://github.com/belogik/goes/blob/e54d722c3aff588e4c737fe11c07359019240824/goes.go#L582-L584 |
140,977 | belogik/goes | goes.go | AliasExists | func (c *Connection) AliasExists(alias string) (bool, error) {
r := Request{
Conn: c,
method: "HEAD",
api: "_alias/" + alias,
}
resp, err := r.Run()
return resp.Status == 200, err
} | go | func (c *Connection) AliasExists(alias string) (bool, error) {
r := Request{
Conn: c,
method: "HEAD",
api: "_alias/" + alias,
}
resp, err := r.Run()
return resp.Status == 200, err
} | [
"func",
"(",
"c",
"*",
"Connection",
")",
"AliasExists",
"(",
"alias",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"r",
":=",
"Request",
"{",
"Conn",
":",
"c",
",",
"method",
":",
"\"",
"\"",
",",
"api",
":",
"\"",
"\"",
"+",
"alias",
"... | // AliasExists checks whether alias is defined on the server | [
"AliasExists",
"checks",
"whether",
"alias",
"is",
"defined",
"on",
"the",
"server"
] | e54d722c3aff588e4c737fe11c07359019240824 | https://github.com/belogik/goes/blob/e54d722c3aff588e4c737fe11c07359019240824/goes.go#L592-L603 |
140,978 | containerd/continuity | fs/dtype_linux.go | SupportsDType | func SupportsDType(path string) (bool, error) {
// locate dummy so that we have at least one dirent
dummy, err := locateDummyIfEmpty(path)
if err != nil {
return false, err
}
if dummy != "" {
defer os.Remove(dummy)
}
visited := 0
supportsDType := true
fn := func(ent *syscall.Dirent) bool {
visited++
i... | go | func SupportsDType(path string) (bool, error) {
// locate dummy so that we have at least one dirent
dummy, err := locateDummyIfEmpty(path)
if err != nil {
return false, err
}
if dummy != "" {
defer os.Remove(dummy)
}
visited := 0
supportsDType := true
fn := func(ent *syscall.Dirent) bool {
visited++
i... | [
"func",
"SupportsDType",
"(",
"path",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"// locate dummy so that we have at least one dirent",
"dummy",
",",
"err",
":=",
"locateDummyIfEmpty",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"... | // SupportsDType returns whether the filesystem mounted on path supports d_type | [
"SupportsDType",
"returns",
"whether",
"the",
"filesystem",
"mounted",
"on",
"path",
"supports",
"d_type"
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/fs/dtype_linux.go#L47-L76 |
140,979 | containerd/continuity | hardlinks.go | Add | func (hlm *hardlinkManager) Add(fi os.FileInfo, resource Resource) error {
if _, ok := resource.(Hardlinkable); !ok {
return errNotAHardLink
}
key, err := newHardlinkKey(fi)
if err != nil {
return err
}
hlm.hardlinks[key] = append(hlm.hardlinks[key], resource)
return nil
} | go | func (hlm *hardlinkManager) Add(fi os.FileInfo, resource Resource) error {
if _, ok := resource.(Hardlinkable); !ok {
return errNotAHardLink
}
key, err := newHardlinkKey(fi)
if err != nil {
return err
}
hlm.hardlinks[key] = append(hlm.hardlinks[key], resource)
return nil
} | [
"func",
"(",
"hlm",
"*",
"hardlinkManager",
")",
"Add",
"(",
"fi",
"os",
".",
"FileInfo",
",",
"resource",
"Resource",
")",
"error",
"{",
"if",
"_",
",",
"ok",
":=",
"resource",
".",
"(",
"Hardlinkable",
")",
";",
"!",
"ok",
"{",
"return",
"errNotAHa... | // Add attempts to add the resource to the hardlink manager. If the resource
// cannot be considered as a hardlink candidate, errNotAHardLink is returned. | [
"Add",
"attempts",
"to",
"add",
"the",
"resource",
"to",
"the",
"hardlink",
"manager",
".",
"If",
"the",
"resource",
"cannot",
"be",
"considered",
"as",
"a",
"hardlink",
"candidate",
"errNotAHardLink",
"is",
"returned",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/hardlinks.go#L40-L53 |
140,980 | containerd/continuity | hardlinks.go | Merge | func (hlm *hardlinkManager) Merge() ([]Resource, error) {
var resources []Resource
for key, linked := range hlm.hardlinks {
if len(linked) < 1 {
return nil, fmt.Errorf("no hardlink entrys for dev, inode pair: %#v", key)
}
merged, err := Merge(linked...)
if err != nil {
return nil, fmt.Errorf("error mer... | go | func (hlm *hardlinkManager) Merge() ([]Resource, error) {
var resources []Resource
for key, linked := range hlm.hardlinks {
if len(linked) < 1 {
return nil, fmt.Errorf("no hardlink entrys for dev, inode pair: %#v", key)
}
merged, err := Merge(linked...)
if err != nil {
return nil, fmt.Errorf("error mer... | [
"func",
"(",
"hlm",
"*",
"hardlinkManager",
")",
"Merge",
"(",
")",
"(",
"[",
"]",
"Resource",
",",
"error",
")",
"{",
"var",
"resources",
"[",
"]",
"Resource",
"\n",
"for",
"key",
",",
"linked",
":=",
"range",
"hlm",
".",
"hardlinks",
"{",
"if",
"... | // Merge processes the current state of the hardlink manager and merges any
// shared nodes into hardlinked resources. | [
"Merge",
"processes",
"the",
"current",
"state",
"of",
"the",
"hardlink",
"manager",
"and",
"merges",
"any",
"shared",
"nodes",
"into",
"hardlinked",
"resources",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/hardlinks.go#L57-L73 |
140,981 | containerd/continuity | continuityfs/fuse.go | NewFile | func NewFile(inode uint64, provider FileContentProvider) *File {
return &File{
inode: inode,
provider: provider,
}
} | go | func NewFile(inode uint64, provider FileContentProvider) *File {
return &File{
inode: inode,
provider: provider,
}
} | [
"func",
"NewFile",
"(",
"inode",
"uint64",
",",
"provider",
"FileContentProvider",
")",
"*",
"File",
"{",
"return",
"&",
"File",
"{",
"inode",
":",
"inode",
",",
"provider",
":",
"provider",
",",
"}",
"\n",
"}"
] | // NewFile creates a new file with the given inode and content provider | [
"NewFile",
"creates",
"a",
"new",
"file",
"with",
"the",
"given",
"inode",
"and",
"content",
"provider"
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/continuityfs/fuse.go#L47-L52 |
140,982 | containerd/continuity | continuityfs/fuse.go | Attr | func (f *File) Attr(ctx context.Context, attr *fuse.Attr) (err error) {
// Set attributes from resource metadata
attr.Mode = f.resource.Mode()
attr.Uid = f.uid
attr.Gid = f.gid
if rf, ok := f.resource.(continuity.RegularFile); ok {
attr.Nlink = uint32(len(rf.Paths()))
attr.Size = uint64(rf.Size())
} else {
... | go | func (f *File) Attr(ctx context.Context, attr *fuse.Attr) (err error) {
// Set attributes from resource metadata
attr.Mode = f.resource.Mode()
attr.Uid = f.uid
attr.Gid = f.gid
if rf, ok := f.resource.(continuity.RegularFile); ok {
attr.Nlink = uint32(len(rf.Paths()))
attr.Size = uint64(rf.Size())
} else {
... | [
"func",
"(",
"f",
"*",
"File",
")",
"Attr",
"(",
"ctx",
"context",
".",
"Context",
",",
"attr",
"*",
"fuse",
".",
"Attr",
")",
"(",
"err",
"error",
")",
"{",
"// Set attributes from resource metadata",
"attr",
".",
"Mode",
"=",
"f",
".",
"resource",
".... | // Attr sets the fuse attribute for the file | [
"Attr",
"sets",
"the",
"fuse",
"attribute",
"for",
"the",
"file"
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/continuityfs/fuse.go#L64-L80 |
140,983 | containerd/continuity | continuityfs/fuse.go | Open | func (f *File) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error) {
var dgst digest.Digest
if rf, ok := f.resource.(continuity.RegularFile); ok {
digests := rf.Digests()
if len(digests) > 0 {
dgst = digests[0]
}
}
// TODO(dmcgowan): else check if device can be open... | go | func (f *File) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error) {
var dgst digest.Digest
if rf, ok := f.resource.(continuity.RegularFile); ok {
digests := rf.Digests()
if len(digests) > 0 {
dgst = digests[0]
}
}
// TODO(dmcgowan): else check if device can be open... | [
"func",
"(",
"f",
"*",
"File",
")",
"Open",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"fuse",
".",
"OpenRequest",
",",
"resp",
"*",
"fuse",
".",
"OpenResponse",
")",
"(",
"fs",
".",
"Handle",
",",
"error",
")",
"{",
"var",
"dgst",
"... | // Open opens the file for read
// currently only regular files can be opened | [
"Open",
"opens",
"the",
"file",
"for",
"read",
"currently",
"only",
"regular",
"files",
"can",
"be",
"opened"
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/continuityfs/fuse.go#L84-L102 |
140,984 | containerd/continuity | continuityfs/fuse.go | Attr | func (d *Dir) Attr(ctx context.Context, attr *fuse.Attr) (err error) {
if d.resource == nil {
attr.Mode = os.ModeDir | 0555
} else {
attr.Mode = d.resource.Mode()
}
attr.Uid = d.uid
attr.Gid = d.gid
attr.Inode = d.inode
return nil
} | go | func (d *Dir) Attr(ctx context.Context, attr *fuse.Attr) (err error) {
if d.resource == nil {
attr.Mode = os.ModeDir | 0555
} else {
attr.Mode = d.resource.Mode()
}
attr.Uid = d.uid
attr.Gid = d.gid
attr.Inode = d.inode
return nil
} | [
"func",
"(",
"d",
"*",
"Dir",
")",
"Attr",
"(",
"ctx",
"context",
".",
"Context",
",",
"attr",
"*",
"fuse",
".",
"Attr",
")",
"(",
"err",
"error",
")",
"{",
"if",
"d",
".",
"resource",
"==",
"nil",
"{",
"attr",
".",
"Mode",
"=",
"os",
".",
"M... | // Attr sets the fuse attributes for the directory | [
"Attr",
"sets",
"the",
"fuse",
"attributes",
"for",
"the",
"directory"
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/continuityfs/fuse.go#L171-L183 |
140,985 | containerd/continuity | continuityfs/fuse.go | Lookup | func (d *Dir) Lookup(ctx context.Context, name string) (fs.Node, error) {
node, ok := d.nodes[name]
if !ok {
return nil, fuse.ENOENT
}
return node, nil
} | go | func (d *Dir) Lookup(ctx context.Context, name string) (fs.Node, error) {
node, ok := d.nodes[name]
if !ok {
return nil, fuse.ENOENT
}
return node, nil
} | [
"func",
"(",
"d",
"*",
"Dir",
")",
"Lookup",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"fs",
".",
"Node",
",",
"error",
")",
"{",
"node",
",",
"ok",
":=",
"d",
".",
"nodes",
"[",
"name",
"]",
"\n",
"if",
"!",
"ok... | // Lookup looks up the filesystem node for the name within the directory | [
"Lookup",
"looks",
"up",
"the",
"filesystem",
"node",
"for",
"the",
"name",
"within",
"the",
"directory"
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/continuityfs/fuse.go#L198-L204 |
140,986 | containerd/continuity | continuityfs/fuse.go | ReadDirAll | func (d *Dir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
ents := make([]fuse.Dirent, 0, len(d.nodes))
for name, node := range d.nodes {
if nd, ok := node.(direnter); ok {
de, err := nd.getDirent(name)
if err != nil {
return nil, err
}
ents = append(ents, de)
} else {
logrus.Errorf... | go | func (d *Dir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
ents := make([]fuse.Dirent, 0, len(d.nodes))
for name, node := range d.nodes {
if nd, ok := node.(direnter); ok {
de, err := nd.getDirent(name)
if err != nil {
return nil, err
}
ents = append(ents, de)
} else {
logrus.Errorf... | [
"func",
"(",
"d",
"*",
"Dir",
")",
"ReadDirAll",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"fuse",
".",
"Dirent",
",",
"error",
")",
"{",
"ents",
":=",
"make",
"(",
"[",
"]",
"fuse",
".",
"Dirent",
",",
"0",
",",
"len",
"(",
... | // ReadDirAll reads all the directory entries | [
"ReadDirAll",
"reads",
"all",
"the",
"directory",
"entries"
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/continuityfs/fuse.go#L207-L222 |
140,987 | containerd/continuity | continuityfs/fuse.go | NewDir | func NewDir(inode uint64, provider FileContentProvider) *Dir {
return &Dir{
inode: inode,
nodes: map[string]fs.Node{},
provider: provider,
}
} | go | func NewDir(inode uint64, provider FileContentProvider) *Dir {
return &Dir{
inode: inode,
nodes: map[string]fs.Node{},
provider: provider,
}
} | [
"func",
"NewDir",
"(",
"inode",
"uint64",
",",
"provider",
"FileContentProvider",
")",
"*",
"Dir",
"{",
"return",
"&",
"Dir",
"{",
"inode",
":",
"inode",
",",
"nodes",
":",
"map",
"[",
"string",
"]",
"fs",
".",
"Node",
"{",
"}",
",",
"provider",
":",... | // NewDir creates a new directory object | [
"NewDir",
"creates",
"a",
"new",
"directory",
"object"
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/continuityfs/fuse.go#L233-L239 |
140,988 | containerd/continuity | continuityfs/fuse.go | NewFSFromManifest | func NewFSFromManifest(manifest *continuity.Manifest, mountRoot string, provider FileContentProvider) (fs.FS, error) {
tree := treeRoot{
root: NewDir(0, provider),
}
fi, err := os.Stat(mountRoot)
if err != nil {
return nil, err
}
st, ok := fi.Sys().(*syscall.Stat_t)
if !ok {
return nil, errors.New("could ... | go | func NewFSFromManifest(manifest *continuity.Manifest, mountRoot string, provider FileContentProvider) (fs.FS, error) {
tree := treeRoot{
root: NewDir(0, provider),
}
fi, err := os.Stat(mountRoot)
if err != nil {
return nil, err
}
st, ok := fi.Sys().(*syscall.Stat_t)
if !ok {
return nil, errors.New("could ... | [
"func",
"NewFSFromManifest",
"(",
"manifest",
"*",
"continuity",
".",
"Manifest",
",",
"mountRoot",
"string",
",",
"provider",
"FileContentProvider",
")",
"(",
"fs",
".",
"FS",
",",
"error",
")",
"{",
"tree",
":=",
"treeRoot",
"{",
"root",
":",
"NewDir",
"... | // NewFSFromManifest creates a fuse filesystem using the given manifest
// to create the node tree and the content provider to serve up
// content for regular files. | [
"NewFSFromManifest",
"creates",
"a",
"fuse",
"filesystem",
"using",
"the",
"given",
"manifest",
"to",
"create",
"the",
"node",
"tree",
"and",
"the",
"content",
"provider",
"to",
"serve",
"up",
"content",
"for",
"regular",
"files",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/continuityfs/fuse.go#L269-L322 |
140,989 | containerd/continuity | fs/du.go | DiskUsage | func DiskUsage(ctx context.Context, roots ...string) (Usage, error) {
return diskUsage(ctx, roots...)
} | go | func DiskUsage(ctx context.Context, roots ...string) (Usage, error) {
return diskUsage(ctx, roots...)
} | [
"func",
"DiskUsage",
"(",
"ctx",
"context",
".",
"Context",
",",
"roots",
"...",
"string",
")",
"(",
"Usage",
",",
"error",
")",
"{",
"return",
"diskUsage",
"(",
"ctx",
",",
"roots",
"...",
")",
"\n",
"}"
] | // DiskUsage counts the number of inodes and disk usage for the resources under
// path. | [
"DiskUsage",
"counts",
"the",
"number",
"of",
"inodes",
"and",
"disk",
"usage",
"for",
"the",
"resources",
"under",
"path",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/fs/du.go#L29-L31 |
140,990 | containerd/continuity | fs/du.go | DiffUsage | func DiffUsage(ctx context.Context, a, b string) (Usage, error) {
return diffUsage(ctx, a, b)
} | go | func DiffUsage(ctx context.Context, a, b string) (Usage, error) {
return diffUsage(ctx, a, b)
} | [
"func",
"DiffUsage",
"(",
"ctx",
"context",
".",
"Context",
",",
"a",
",",
"b",
"string",
")",
"(",
"Usage",
",",
"error",
")",
"{",
"return",
"diffUsage",
"(",
"ctx",
",",
"a",
",",
"b",
")",
"\n",
"}"
] | // DiffUsage counts the numbers of inodes and disk usage in the
// diff between the 2 directories. The first path is intended
// as the base directory and the second as the changed directory. | [
"DiffUsage",
"counts",
"the",
"numbers",
"of",
"inodes",
"and",
"disk",
"usage",
"in",
"the",
"diff",
"between",
"the",
"2",
"directories",
".",
"The",
"first",
"path",
"is",
"intended",
"as",
"the",
"base",
"directory",
"and",
"the",
"second",
"as",
"the"... | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/fs/du.go#L36-L38 |
140,991 | containerd/continuity | fs/path.go | compareFileContent | func compareFileContent(p1, p2 string) (bool, error) {
f1, err := os.Open(p1)
if err != nil {
return false, err
}
defer f1.Close()
f2, err := os.Open(p2)
if err != nil {
return false, err
}
defer f2.Close()
b1 := make([]byte, compareChuckSize)
b2 := make([]byte, compareChuckSize)
for {
n1, err1 := f1.... | go | func compareFileContent(p1, p2 string) (bool, error) {
f1, err := os.Open(p1)
if err != nil {
return false, err
}
defer f1.Close()
f2, err := os.Open(p2)
if err != nil {
return false, err
}
defer f2.Close()
b1 := make([]byte, compareChuckSize)
b2 := make([]byte, compareChuckSize)
for {
n1, err1 := f1.... | [
"func",
"compareFileContent",
"(",
"p1",
",",
"p2",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"f1",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"p1",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\... | // compareFileContent compares the content of 2 same sized files
// by comparing each byte. | [
"compareFileContent",
"compares",
"the",
"content",
"of",
"2",
"same",
"sized",
"files",
"by",
"comparing",
"each",
"byte",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/fs/path.go#L153-L183 |
140,992 | containerd/continuity | fs/path.go | RootPath | func RootPath(root, path string) (string, error) {
if path == "" {
return root, nil
}
var linksWalked int // to protect against cycles
for {
i := linksWalked
newpath, err := walkLinks(root, path, &linksWalked)
if err != nil {
return "", err
}
path = newpath
if i == linksWalked {
newpath = filepa... | go | func RootPath(root, path string) (string, error) {
if path == "" {
return root, nil
}
var linksWalked int // to protect against cycles
for {
i := linksWalked
newpath, err := walkLinks(root, path, &linksWalked)
if err != nil {
return "", err
}
path = newpath
if i == linksWalked {
newpath = filepa... | [
"func",
"RootPath",
"(",
"root",
",",
"path",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"path",
"==",
"\"",
"\"",
"{",
"return",
"root",
",",
"nil",
"\n",
"}",
"\n",
"var",
"linksWalked",
"int",
"// to protect against cycles",
"\n",
"... | // RootPath joins a path with a root, evaluating and bounding any
// symlink to the root directory. | [
"RootPath",
"joins",
"a",
"path",
"with",
"a",
"root",
"evaluating",
"and",
"bounding",
"any",
"symlink",
"to",
"the",
"root",
"directory",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/fs/path.go#L230-L250 |
140,993 | containerd/continuity | driver/driver_unix.go | Getxattr | func (d *driver) Getxattr(p string) (map[string][]byte, error) {
xattrs, err := sysx.Listxattr(p)
if err != nil {
return nil, fmt.Errorf("listing %s xattrs: %v", p, err)
}
sort.Strings(xattrs)
m := make(map[string][]byte, len(xattrs))
for _, attr := range xattrs {
value, err := sysx.Getxattr(p, attr)
if e... | go | func (d *driver) Getxattr(p string) (map[string][]byte, error) {
xattrs, err := sysx.Listxattr(p)
if err != nil {
return nil, fmt.Errorf("listing %s xattrs: %v", p, err)
}
sort.Strings(xattrs)
m := make(map[string][]byte, len(xattrs))
for _, attr := range xattrs {
value, err := sysx.Getxattr(p, attr)
if e... | [
"func",
"(",
"d",
"*",
"driver",
")",
"Getxattr",
"(",
"p",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"xattrs",
",",
"err",
":=",
"sysx",
".",
"Listxattr",
"(",
"p",
")",
"\n",
"if",
"err",
"!=",
... | // Getxattr returns all of the extended attributes for the file at path p. | [
"Getxattr",
"returns",
"all",
"of",
"the",
"extended",
"attributes",
"for",
"the",
"file",
"at",
"path",
"p",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/driver/driver_unix.go#L53-L75 |
140,994 | containerd/continuity | driver/driver_unix.go | Setxattr | func (d *driver) Setxattr(path string, attrMap map[string][]byte) error {
for attr, value := range attrMap {
if err := sysx.Setxattr(path, attr, value, 0); err != nil {
return fmt.Errorf("error setting xattr %q on %s: %v", attr, path, err)
}
}
return nil
} | go | func (d *driver) Setxattr(path string, attrMap map[string][]byte) error {
for attr, value := range attrMap {
if err := sysx.Setxattr(path, attr, value, 0); err != nil {
return fmt.Errorf("error setting xattr %q on %s: %v", attr, path, err)
}
}
return nil
} | [
"func",
"(",
"d",
"*",
"driver",
")",
"Setxattr",
"(",
"path",
"string",
",",
"attrMap",
"map",
"[",
"string",
"]",
"[",
"]",
"byte",
")",
"error",
"{",
"for",
"attr",
",",
"value",
":=",
"range",
"attrMap",
"{",
"if",
"err",
":=",
"sysx",
".",
"... | // Setxattr sets all of the extended attributes on file at path, following
// any symbolic links, if necessary. All attributes on the target are
// replaced by the values from attr. If the operation fails to set any
// attribute, those already applied will not be rolled back. | [
"Setxattr",
"sets",
"all",
"of",
"the",
"extended",
"attributes",
"on",
"file",
"at",
"path",
"following",
"any",
"symbolic",
"links",
"if",
"necessary",
".",
"All",
"attributes",
"on",
"the",
"target",
"are",
"replaced",
"by",
"the",
"values",
"from",
"attr... | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/driver/driver_unix.go#L81-L89 |
140,995 | containerd/continuity | driver/driver_unix.go | Readlink | func (d *driver) Readlink(p string) (string, error) {
return os.Readlink(p)
} | go | func (d *driver) Readlink(p string) (string, error) {
return os.Readlink(p)
} | [
"func",
"(",
"d",
"*",
"driver",
")",
"Readlink",
"(",
"p",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"os",
".",
"Readlink",
"(",
"p",
")",
"\n",
"}"
] | // Readlink was forked on Windows to fix a Golang bug, use the "os" package here | [
"Readlink",
"was",
"forked",
"on",
"Windows",
"to",
"fix",
"a",
"Golang",
"bug",
"use",
"the",
"os",
"package",
"here"
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/driver/driver_unix.go#L136-L138 |
140,996 | containerd/continuity | driver/driver_windows.go | Lchmod | func (d *driver) Lchmod(path string, mode os.FileMode) (err error) {
// TODO: Use Window's equivalent
return os.Chmod(path, mode)
} | go | func (d *driver) Lchmod(path string, mode os.FileMode) (err error) {
// TODO: Use Window's equivalent
return os.Chmod(path, mode)
} | [
"func",
"(",
"d",
"*",
"driver",
")",
"Lchmod",
"(",
"path",
"string",
",",
"mode",
"os",
".",
"FileMode",
")",
"(",
"err",
"error",
")",
"{",
"// TODO: Use Window's equivalent",
"return",
"os",
".",
"Chmod",
"(",
"path",
",",
"mode",
")",
"\n",
"}"
] | // Lchmod changes the mode of an file not following symlinks. | [
"Lchmod",
"changes",
"the",
"mode",
"of",
"an",
"file",
"not",
"following",
"symlinks",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/driver/driver_windows.go#L34-L37 |
140,997 | containerd/continuity | driver/driver_windows.go | Readlink | func (d *driver) Readlink(p string) (string, error) {
return sysx.Readlink(p)
} | go | func (d *driver) Readlink(p string) (string, error) {
return sysx.Readlink(p)
} | [
"func",
"(",
"d",
"*",
"driver",
")",
"Readlink",
"(",
"p",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"sysx",
".",
"Readlink",
"(",
"p",
")",
"\n",
"}"
] | // Readlink is forked in order to support Volume paths which are used
// in container layers. | [
"Readlink",
"is",
"forked",
"in",
"order",
"to",
"support",
"Volume",
"paths",
"which",
"are",
"used",
"in",
"container",
"layers",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/driver/driver_windows.go#L41-L43 |
140,998 | containerd/continuity | fs/stat_linux.go | StatATimeAsTime | func StatATimeAsTime(st *syscall.Stat_t) time.Time {
// The int64 conversions ensure the line compiles for 32-bit systems as well.
return time.Unix(int64(st.Atim.Sec), int64(st.Atim.Nsec)) // nolint: unconvert
} | go | func StatATimeAsTime(st *syscall.Stat_t) time.Time {
// The int64 conversions ensure the line compiles for 32-bit systems as well.
return time.Unix(int64(st.Atim.Sec), int64(st.Atim.Nsec)) // nolint: unconvert
} | [
"func",
"StatATimeAsTime",
"(",
"st",
"*",
"syscall",
".",
"Stat_t",
")",
"time",
".",
"Time",
"{",
"// The int64 conversions ensure the line compiles for 32-bit systems as well.",
"return",
"time",
".",
"Unix",
"(",
"int64",
"(",
"st",
".",
"Atim",
".",
"Sec",
")... | // StatATimeAsTime returns st.Atim as a time.Time | [
"StatATimeAsTime",
"returns",
"st",
".",
"Atim",
"as",
"a",
"time",
".",
"Time"
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/fs/stat_linux.go#L40-L43 |
140,999 | containerd/continuity | digests.go | uniqifyDigests | func uniqifyDigests(digests ...digest.Digest) ([]digest.Digest, error) {
sort.Stable(digestSlice(digests)) // stable sort is important for the behavior here.
seen := map[digest.Digest]struct{}{}
algs := map[digest.Algorithm][]digest.Digest{} // detect different digests.
var out []digest.Digest
// uniqify the dige... | go | func uniqifyDigests(digests ...digest.Digest) ([]digest.Digest, error) {
sort.Stable(digestSlice(digests)) // stable sort is important for the behavior here.
seen := map[digest.Digest]struct{}{}
algs := map[digest.Algorithm][]digest.Digest{} // detect different digests.
var out []digest.Digest
// uniqify the dige... | [
"func",
"uniqifyDigests",
"(",
"digests",
"...",
"digest",
".",
"Digest",
")",
"(",
"[",
"]",
"digest",
".",
"Digest",
",",
"error",
")",
"{",
"sort",
".",
"Stable",
"(",
"digestSlice",
"(",
"digests",
")",
")",
"// stable sort is important for the behavior he... | // uniqifyDigests sorts and uniqifies the provided digest, ensuring that the
// digests are not repeated and no two digests with the same algorithm have
// different values. Because a stable sort is used, this has the effect of
// "zipping" digest collections from multiple resources. | [
"uniqifyDigests",
"sorts",
"and",
"uniqifies",
"the",
"provided",
"digest",
"ensuring",
"that",
"the",
"digests",
"are",
"not",
"repeated",
"and",
"no",
"two",
"digests",
"with",
"the",
"same",
"algorithm",
"have",
"different",
"values",
".",
"Because",
"a",
"... | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/digests.go#L55-L78 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.