id
int32
0
25.3k
idx
stringlengths
5
9
nl_tokens
sequencelengths
1
418
pl_tokens
sequencelengths
22
4.98k
6,600
all-6601
[ "GetLiveSpanOk", "returns", "a", "tuple", "with", "the", "LiveSpan", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "and", "a", "boolean", "to", "check", "if", "the", "value", "has", "been", "set", "." ]
[ "func", "(", "w", "*", "WidgetTime", ")", "GetLiveSpanOk", "(", ")", "(", "string", ",", "bool", ")", "{", "if", "w", "==", "nil", "||", "w", ".", "LiveSpan", "==", "nil", "{", "return", "\"", "\"", ",", "<mask>", "\n", "}", "\n", "return", "*", "w", ".", "LiveSpan", ",", "true", "\n", "}" ]
6,601
all-6602
[ "timeoutAndMoveOn", "executes", "the", "long", "running", "function", "pointed", "to", "by", "fp", "and", "times", "out", "after", "timeout", "duration", "." ]
[ "func", "timeoutAndMoveOn", "(", "fp", "loiterFunc", ",", "timeout", "<mask>", ".", "Duration", ")", "{", "ch", ":=", "time", ".", "After", "(", "timeout", ")", "\n", "for", "{", "select", "{", "case", "<-", "ch", ":", "return", "\n", "default", ":", "fp", "(", ")", "\n", "}", "\n", "}", "\n", "}" ]
6,602
all-6603
[ "-----------------", "own", "methods", "-------------------------", "SetValue", "sets", "new", "progress", "value", ".", "If", "value", "exceeds", "ProgressBar", "limits", "then", "the", "limit", "value", "is", "used" ]
[ "func", "(", "b", "*", "ProgressBar", ")", "SetValue", "(", "pos", "int", ")", "{", "b", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "mtx", ".", "Unlock", "(", ")", "\n", "if", "pos", "<", "b", ".", "min", "{", "b", ".", "value", "=", "b", ".", "min", "\n", "}", "else", "if", "pos", ">", "b", ".", "max", "{", "b", ".", "value", "=", "b", ".", "max", "\n", "}", "else", "{", "b", ".", "value", "=", "<mask>", "\n", "}", "\n", "}" ]
6,603
all-6604
[ "mustSanityCheck", "is", "like", "sanityCheck", "but", "panics", "instead", "of", "returning", "a", "negative", "result", "." ]
[ "func", "mustSanityCheck", "(", "fn", "*", "Function", ",", "reporter", "<mask>", ".", "Writer", ")", "{", "if", "!", "sanityCheck", "(", "fn", ",", "reporter", ")", "{", "fn", ".", "WriteTo", "(", "os", ".", "Stderr", ")", "\n", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "}" ]
6,604
all-6605
[ "RunForDashWebSocket", "creates", "a", "port", "forwarder", "for", "the", "dash", "websocket", "." ]
[ "func", "(", "f", "*", "PortForwarder", ")", "RunForDashWebSocket", "(", "localPort", "uint16", ")", "<mask>", "{", "if", "localPort", "==", "0", "{", "localPort", "=", "dashWebSocketLocalPort", "\n", "}", "\n", "return", "f", ".", "Run", "(", "\"", "\"", ",", "localPort", ",", "8081", ")", "\n", "}" ]
6,605
all-6606
[ "CreateArticle", "persists", "the", "posted", "Article", "and", "returns", "it", "back", "to", "the", "client", "as", "an", "acknowledgement", "." ]
[ "func", "CreateArticle", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "<mask>", ":=", "&", "ArticleRequest", "{", "}", "\n", "if", "err", ":=", "render", ".", "Bind", "(", "r", ",", "data", ")", ";", "err", "!=", "nil", "{", "render", ".", "Render", "(", "w", ",", "r", ",", "ErrInvalidRequest", "(", "err", ")", ")", "\n", "return", "\n", "}", "\n\n", "article", ":=", "data", ".", "Article", "\n", "dbNewArticle", "(", "article", ")", "\n\n", "render", ".", "Status", "(", "r", ",", "http", ".", "StatusCreated", ")", "\n", "render", ".", "Render", "(", "w", ",", "r", ",", "NewArticleResponse", "(", "article", ")", ")", "\n", "}" ]
6,606
all-6607
[ "FindOrg", "-" ]
[ "func", "(", "m", "*", "DefaultManager", ")", "FindOrg", "(", "orgName", "string", ")", "(", "cfclient", ".", "Org", ",", "error", ")", "{", "orgs", ",", "err", ":=", "m", ".", "ListOrgs", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "cfclient", ".", "Org", "{", "}", ",", "err", "\n", "}", "\n", "for", "_", ",", "theOrg", ":=", "<mask>", "orgs", "{", "if", "theOrg", ".", "Name", "==", "orgName", "{", "return", "theOrg", ",", "nil", "\n", "}", "\n", "}", "\n", "if", "m", ".", "Peek", "{", "return", "cfclient", ".", "Org", "{", "Name", ":", "orgName", ",", "Guid", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "orgName", ")", ",", "}", ",", "nil", "\n", "}", "\n", "return", "cfclient", ".", "Org", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "orgName", ")", "\n", "}" ]
6,607
all-6608
[ "Start", "starts", "the", "session", ".", "It", "ll", "forever", "keep", "trying", "to", "connect", "to", "ACS", "unless", "the", "context", "is", "cancelled", ".", "If", "the", "context", "is", "cancelled", "Start", "()", "would", "return", "with", "the", "error", "code", "returned", "by", "the", "context", ".", "If", "the", "instance", "is", "deregistered", "Start", "()", "would", "emit", "an", "event", "to", "the", "deregister", "-", "instance", "event", "stream", "and", "sets", "the", "connection", "backoff", "time", "to", "1", "hour", "." ]
[ "func", "(", "acsSession", "*", "session", ")", "Start", "(", ")", "error", "{", "// connectToACS channel is used to indicate the intent to connect to ACS", "// It's processed by the select loop to connect to ACS", "connectToACS", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "// This is required to trigger the first connection to ACS. Subsequent", "// connections are triggered by the handleACSError() method", "go", "func", "(", ")", "{", "connectToACS", "<-", "struct", "{", "}", "{", "}", "\n", "}", "(", ")", "\n", "for", "{", "select", "{", "case", "<-", "connectToACS", ":", "seelog", ".", "Debugf", "(", "\"", "\"", ")", "\n", "// Start a session with ACS", "acsError", ":=", "acsSession", ".", "startSessionOnce", "(", ")", "\n", "// Session with ACS was stopped with some error, start processing the error", "isInactiveInstance", ":=", "isInactiveInstanceError", "(", "acsError", ")", "\n", "if", "isInactiveInstance", "{", "// If the instance was deregistered, send an event to the event stream", "// for the same", "seelog", ".", "Debug", "(", "\"", "\"", ")", "\n", "err", ":=", "acsSession", ".", "deregisterInstanceEventStream", ".", "WriteToEventStream", "(", "struct", "{", "}", "{", "}", ")", "\n", "if", "err", "!=", "nil", "{", "seelog", ".", "Debugf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "}", "\n", "if", "shouldReconnectWithoutBackoff", "(", "acsError", ")", "{", "// If ACS closed the connection, there's no need to backoff,", "// reconnect immediately", "seelog", ".", "Info", "(", "\"", "\"", ")", "\n", "acsSession", ".", "backoff", ".", "Reset", "(", ")", "\n", "sendEmptyMessageOnChannel", "(", "connectToACS", ")", "\n", "}", "else", "{", "// Disconnected unexpectedly from ACS, compute backoff duration to", "// reconnect", "reconnectDelay", ":=", "acsSession", ".", "computeReconnectDelay", "(", "isInactiveInstance", ")", "\n", "seelog", ".", "Infof", "(", "\"", "\"", ",", "reconnectDelay", ".", "<mask>", "(", ")", ")", "\n", "waitComplete", ":=", "acsSession", ".", "waitForDuration", "(", "reconnectDelay", ")", "\n", "if", "waitComplete", "{", "// If the context was not cancelled and we've waited for the", "// wait duration without any errors, send the message to the channel", "// to reconnect to ACS", "sendEmptyMessageOnChannel", "(", "connectToACS", ")", "\n", "}", "else", "{", "// Wait was interrupted. We expect the session to close as canceling", "// the session context is the only way to end up here. Print a message", "// to indicate the same", "seelog", ".", "Info", "(", "\"", "\"", ")", "\n", "}", "\n", "}", "\n", "case", "<-", "acsSession", ".", "ctx", ".", "Done", "(", ")", ":", "seelog", ".", "Debugf", "(", "\"", "\"", ")", "\n", "return", "acsSession", ".", "ctx", ".", "Err", "(", ")", "\n", "}", "\n\n", "}", "\n", "}" ]
6,608
all-6609
[ "Increment", "the", "counter", "by", "one", "." ]
[ "func", "(", "p", "*", "peer", ")", "incr", "(", ")", "(", "result", "int", ")", "{", "c", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "p", ".", "actions", "<-", "func", "(", ")", "{", "defer", "close", "(", "c", ")", "\n", "st", ":=", "p", ".", "st", ".", "incr", "(", ")", "\n", "if", "p", ".", "send", "!=", "nil", "{", "p", ".", "<mask>", ".", "GossipBroadcast", "(", "st", ")", "\n", "}", "else", "{", "p", ".", "logger", ".", "Printf", "(", "\"", "\"", ")", "\n", "}", "\n", "result", "=", "st", ".", "get", "(", ")", "\n", "}", "\n", "<-", "c", "\n", "return", "result", "\n", "}" ]
6,609
all-6610
[ "Return", "timeout", "in", "seconds" ]
[ "func", "samlRequestTimeout", "(", "schemeData", "<mask>", "[", "string", "]", "string", ")", "int", "{", "p", ":=", "schemeData", "[", "\"", "\"", "]", "\n", "timeout", ",", "_", ":=", "strconv", ".", "Atoi", "(", "p", ")", "\n", "return", "timeout", "\n", "}" ]
6,610
all-6611
[ "readJSONFile", "unmarshals", "the", "authentications", "stored", "in", "the", "auth", ".", "json", "file", "and", "returns", "it", "or", "returns", "an", "empty", "dockerConfigFile", "data", "structure", "if", "auth", ".", "json", "does", "not", "exist", "if", "the", "file", "exists", "and", "is", "empty", "readJSONFile", "returns", "an", "error" ]
[ "func", "readJSONFile", "(", "path", "string", ",", "legacyFormat", "bool", ")", "(", "dockerConfigFile", ",", "error", ")", "{", "var", "auths", "dockerConfigFile", "\n\n", "raw", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "<mask>", ")", "\n", "if", "err", "!=", "nil", "{", "if", "os", ".", "IsNotExist", "(", "err", ")", "{", "auths", ".", "AuthConfigs", "=", "map", "[", "string", "]", "dockerAuthConfig", "{", "}", "\n", "return", "auths", ",", "nil", "\n", "}", "\n", "return", "dockerConfigFile", "{", "}", ",", "err", "\n", "}", "\n\n", "if", "legacyFormat", "{", "if", "err", "=", "json", ".", "Unmarshal", "(", "raw", ",", "&", "auths", ".", "AuthConfigs", ")", ";", "err", "!=", "nil", "{", "return", "dockerConfigFile", "{", "}", ",", "errors", ".", "Wrapf", "(", "err", ",", "\"", "\"", ",", "path", ")", "\n", "}", "\n", "return", "auths", ",", "nil", "\n", "}", "\n\n", "if", "err", "=", "json", ".", "Unmarshal", "(", "raw", ",", "&", "auths", ")", ";", "err", "!=", "nil", "{", "return", "dockerConfigFile", "{", "}", ",", "errors", ".", "Wrapf", "(", "err", ",", "\"", "\"", ",", "path", ")", "\n", "}", "\n\n", "return", "auths", ",", "nil", "\n", "}" ]
6,611
all-6612
[ "Value", "returns", "the", "value", "associated", "with", "the", "iterator", "." ]
[ "func", "(", "s", "*", "MergeIterator", ")", "<mask>", "(", ")", "ValueStruct", "{", "if", "len", "(", "s", ".", "h", ")", "==", "0", "{", "return", "ValueStruct", "{", "}", "\n", "}", "\n", "return", "s", ".", "h", "[", "0", "]", ".", "itr", ".", "Value", "(", ")", "\n", "}" ]
6,612
all-6613
[ "HTML", "renders", "the", "HTML", "with", "default", "template", "set", "." ]
[ "func", "(", "ctx", "*", "Context", ")", "HTML", "(", "status", "int", ",", "name", "string", ",", "data", "...", "<mask>", "{", "}", ")", "{", "ctx", ".", "renderHTML", "(", "status", ",", "DEFAULT_TPL_SET_NAME", ",", "name", ",", "data", "...", ")", "\n", "}" ]
6,613
all-6614
[ "URLFormat", "is", "a", "middleware", "that", "parses", "the", "url", "extension", "from", "a", "request", "path", "and", "stores", "it", "on", "the", "context", "as", "a", "string", "under", "the", "key", "middleware", ".", "URLFormatCtxKey", ".", "The", "middleware", "will", "trim", "the", "suffix", "from", "the", "routing", "path", "and", "continue", "routing", ".", "Routers", "should", "not", "include", "a", "url", "parameter", "for", "the", "suffix", "when", "using", "this", "middleware", ".", "Sample", "usage", "..", "for", "url", "paths", ":", "/", "articles", "/", "1", "/", "articles", "/", "1", ".", "json", "and", "/", "articles", "/", "1", ".", "xml", "func", "routes", "()", "http", ".", "Handler", "{", "r", ":", "=", "chi", ".", "NewRouter", "()", "r", ".", "Use", "(", "middleware", ".", "URLFormat", ")", "r", ".", "Get", "(", "/", "articles", "/", "{", "id", "}", "ListArticles", ")", "return", "r", "}", "func", "ListArticles", "(", "w", "http", ".", "ResponseWriter", "r", "*", "http", ".", "Request", ")", "{", "urlFormat", "_", ":", "=", "r", ".", "Context", "()", ".", "Value", "(", "middleware", ".", "URLFormatCtxKey", ")", ".", "(", "string", ")", "switch", "urlFormat", "{", "case", "json", ":", "render", ".", "JSON", "(", "w", "r", "articles", ")", "case", "xml", ":", "render", ".", "XML", "(", "w", "r", "articles", ")", "default", ":", "render", ".", "JSON", "(", "w", "r", "articles", ")", "}", "}" ]
[ "func", "URLFormat", "(", "next", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "fn", ":=", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "ctx", ":=", "r", ".", "Context", "(", ")", "\n\n", "var", "format", "string", "\n", "path", ":=", "r", ".", "URL", ".", "Path", "\n\n", "if", "strings", ".", "Index", "(", "path", ",", "\"", "\"", ")", ">", "0", "{", "base", ":=", "strings", ".", "LastIndex", "(", "<mask>", ",", "\"", "\"", ")", "\n", "idx", ":=", "strings", ".", "Index", "(", "path", "[", "base", ":", "]", ",", "\"", "\"", ")", "\n\n", "if", "idx", ">", "0", "{", "idx", "+=", "base", "\n", "format", "=", "path", "[", "idx", "+", "1", ":", "]", "\n\n", "rctx", ":=", "chi", ".", "RouteContext", "(", "r", ".", "Context", "(", ")", ")", "\n", "rctx", ".", "RoutePath", "=", "path", "[", ":", "idx", "]", "\n", "}", "\n", "}", "\n\n", "r", "=", "r", ".", "WithContext", "(", "context", ".", "WithValue", "(", "ctx", ",", "URLFormatCtxKey", ",", "format", ")", ")", "\n\n", "next", ".", "ServeHTTP", "(", "w", ",", "r", ")", "\n", "}", "\n", "return", "http", ".", "HandlerFunc", "(", "fn", ")", "\n", "}" ]
6,614
all-6615
[ "SetBorderWidth", "is", "a", "wrapper", "around", "gtk_container_set_border_width", "()", "." ]
[ "func", "(", "v", "*", "<mask>", ")", "SetBorderWidth", "(", "borderWidth", "uint", ")", "{", "C", ".", "gtk_container_set_border_width", "(", "v", ".", "native", "(", ")", ",", "C", ".", "guint", "(", "borderWidth", ")", ")", "\n", "}" ]
6,615
all-6616
[ "GetIconName", "is", "a", "wrapper", "around", "gtk_window_get_icon_name", "()", "." ]
[ "func", "(", "v", "*", "Window", ")", "GetIconName", "(", ")", "(", "string", ",", "error", ")", "{", "<mask>", "stringReturn", "(", "C", ".", "gtk_window_get_icon_name", "(", "v", ".", "native", "(", ")", ")", ")", "\n", "}" ]
6,616
all-6617
[ "listen", "listens", "to", "the", "event", "channel" ]
[ "func", "(", "eventStream", "*", "EventStream", ")", "listen", "(", ")", "{", "seelog", ".", "Infof", "(", "\"", "\"", ",", "eventStream", ".", "name", ")", "\n", "for", "{", "select", "{", "case", "event", ":=", "<-", "eventStream", ".", "event", ":", "eventStream", ".", "broadcast", "(", "event", ")", "\n", "case", "<-", "eventStream", ".", "ctx", ".", "Done", "(", ")", ":", "seelog", ".", "Infof", "(", "\"", "\"", ",", "eventStream", ".", "name", ")", "\n\n", "eventStream", ".", "statusLock", ".", "Lock", "(", ")", "\n", "eventStream", ".", "<mask>", "=", "false", "\n", "close", "(", "eventStream", ".", "event", ")", "\n", "eventStream", ".", "statusLock", ".", "Unlock", "(", ")", "\n", "return", "\n", "}", "\n", "}", "\n", "}" ]
6,617
all-6618
[ "GetX", "returns", "the", "X", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "w", "*", "WidgetLayout", ")", "GetX", "(", ")", "float64", "{", "if", "w", "==", "nil", "||", "w", ".", "X", "==", "nil", "{", "<mask>", "0", "\n", "}", "\n", "return", "*", "w", ".", "X", "\n", "}" ]
6,618
all-6619
[ "delete", "named", "query", "objects" ]
[ "func", "DeleteQueries", "(", "n", "int32", ",", "ids", "*", "uint32", ")", "{", "syscall", ".", "Syscall", "(", "gpDeleteQueries", ",", "2", ",", "uintptr", "(", "n", ")", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "<mask>", ")", ")", ",", "0", ")", "\n", "}" ]
6,619
all-6620
[ "WithURL", "if", "set", "the", "request", "url", "will", "be", "modified", "in", "a", "way", "that", "s", "not", "observable", "by", "page", "." ]
[ "func", "(", "p", "ContinueRequestParams", ")", "WithURL", "(", "<mask>", "string", ")", "*", "ContinueRequestParams", "{", "p", ".", "URL", "=", "url", "\n", "return", "&", "p", "\n", "}" ]
6,620
all-6621
[ "Execute", "checks", "if", "the", "provided", "certificate", "has", "embedded", "SCTs", "from", "a", "sufficient", "number", "of", "unique", "CT", "logs", "to", "meet", "Apple", "s", "CT", "log", "policy", "[", "0", "]", "effective", "Oct", "15th", "2018", ".", "The", "number", "of", "required", "SCTs", "from", "different", "logs", "is", "calculated", "based", "on", "the", "Certificate", "s", "lifetime", ".", "If", "the", "number", "of", "required", "SCTs", "are", "not", "embedded", "in", "the", "certificate", "a", "Notice", "level", "LintResult", "is", "returned", ".", "|", "Certificate", "lifetime", "|", "#", "of", "SCTs", "from", "separate", "logs", "|", "-------------------------------------------------------", "|", "Less", "than", "15", "months", "|", "2", "|", "|", "15", "to", "27", "months", "|", "3", "|", "|", "27", "to", "39", "months", "|", "4", "|", "|", "More", "than", "39", "months", "|", "5", "|", "-------------------------------------------------------", "Important", "note", "1", ":", "We", "can", "t", "know", "whether", "additional", "SCTs", "were", "presented", "alongside", "the", "certificate", "via", "OCSP", "stapling", ".", "This", "linter", "assumes", "only", "embedded", "SCTs", "are", "used", "and", "ignores", "the", "portion", "of", "the", "Apple", "policy", "related", "to", "SCTs", "delivered", "via", "OCSP", ".", "This", "is", "one", "limitation", "that", "restricts", "the", "linter", "s", "findings", "to", "Notice", "level", ".", "See", "more", "background", "discussion", "in", "Issue", "226", "[", "1", "]", ".", "Important", "note", "2", ":", "The", "linter", "doesn", "t", "maintain", "a", "list", "of", "Apple", "s", "trusted", "logs", ".", "The", "SCTs", "embedded", "in", "the", "certificate", "may", "not", "be", "from", "log", "s", "Apple", "actually", "trusts", ".", "Similarly", "the", "embedded", "SCT", "signatures", "are", "not", "validated", "in", "any", "way", ".", "[", "0", "]", ":", "https", ":", "//", "support", ".", "apple", ".", "com", "/", "en", "-", "us", "/", "HT205280", "[", "1", "]", ":", "https", ":", "//", "github", ".", "com", "/", "zmap", "/", "zlint", "/", "issues", "/", "226" ]
[ "func", "(", "l", "*", "sctPolicyCount", ")", "Execute", "(", "c", "*", "x509", ".", "Certificate", ")", "*", "LintResult", "{", "// Determine the required number of SCTs from separate logs", "expected", ":=", "appleCTPolicyExpectedSCTs", "(", "c", ")", "\n\n", "// If there are no SCTs then the job is easy. We can return a Notice", "// LintResult immediately.", "if", "len", "(", "c", ".", "SignedCertificateTimestampList", ")", "==", "0", "&&", "expected", ">", "0", "{", "return", "&", "LintResult", "{", "Status", ":", "Notice", ",", "Details", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "expected", ")", ",", "}", "\n", "}", "\n\n", "// Build a map from LogID to SCT so that we can count embedded SCTs by unique", "// log.", "sctsByLogID", ":=", "<mask>", "(", "map", "[", "ct", ".", "SHA256Hash", "]", "*", "ct", ".", "SignedCertificateTimestamp", ")", "\n", "for", "_", ",", "sct", ":=", "range", "c", ".", "SignedCertificateTimestampList", "{", "sctsByLogID", "[", "sct", ".", "LogID", "]", "=", "sct", "\n", "}", "\n\n", "// If the number of embedded SCTs from separate logs meets expected return", "// a Pass result.", "if", "len", "(", "sctsByLogID", ")", ">=", "expected", "{", "return", "&", "LintResult", "{", "Status", ":", "Pass", "}", "\n", "}", "\n\n", "// Otherwise return a Notice result - there weren't enough SCTs embedded in", "// the certificate. More must be provided by OCSP stapling if the certificate", "// is to meet Apple's CT policy.", "return", "&", "LintResult", "{", "Status", ":", "Notice", ",", "Details", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", "+", "\"", "\"", ",", "len", "(", "sctsByLogID", ")", ",", "expected", ")", ",", "}", "\n", "}" ]
6,621
all-6622
[ "DisconnectAll", "is", "used", "to", "remove", "all", "routes", "to", "peers", "." ]
[ "func", "(", "i", "*", "InmemTransport", ")", "DisconnectAll", "(", ")", "{", "i", ".", "Lock", "(", ")", "\n", "defer", "i", ".", "Unlock", "(", ")", "\n", "i", ".", "peers", "=", "make", "(", "<mask>", "[", "ServerAddress", "]", "*", "InmemTransport", ")", "\n\n", "// Handle pipelines", "for", "_", ",", "pipeline", ":=", "range", "i", ".", "pipelines", "{", "pipeline", ".", "Close", "(", ")", "\n", "}", "\n", "i", ".", "pipelines", "=", "nil", "\n", "}" ]
6,622
all-6623
[ "rmdirCommandFunc", "executes", "the", "rmdir", "command", "." ]
[ "func", "rmdirCommandFunc", "(", "c", "*", "cli", ".", "Context", ",", "ki", "client", ".", "KeysAPI", ")", "{", "if", "len", "(", "c", ".", "Args", "(", ")", ")", "==", "0", "{", "handleError", "(", "c", ",", "ExitBadArgs", ",", "errors", ".", "New", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "key", ":=", "c", ".", "Args", "(", ")", "[", "0", "]", "\n\n", "ctx", ",", "cancel", ":=", "contextWithTotalTimeout", "(", "c", ")", "\n", "resp", ",", "err", ":=", "ki", ".", "Delete", "(", "ctx", ",", "key", ",", "&", "<mask>", ".", "DeleteOptions", "{", "Dir", ":", "true", "}", ")", "\n", "cancel", "(", ")", "\n", "if", "err", "!=", "nil", "{", "handleError", "(", "c", ",", "ExitServerError", ",", "err", ")", "\n", "}", "\n\n", "if", "!", "resp", ".", "Node", ".", "Dir", "||", "c", ".", "GlobalString", "(", "\"", "\"", ")", "!=", "\"", "\"", "{", "printResponseKey", "(", "resp", ",", "c", ".", "GlobalString", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "}" ]
6,623
all-6624
[ "If", "no", "limit", "is", "given", "the", "roleIds", "of", "all", "roles", "are", "returned", ".", "Since", "this", "list", "may", "become", "long", "callers", "can", "use", "the", "limit", "and", "continuationToken", "query", "arguments", "to", "page", "through", "the", "responses", ".", "See", "#listRoleIds" ]
[ "func", "(", "auth", "*", "Auth", ")", "ListRoleIds", "(", "continuationToken", ",", "limit", "string", ")", "(", "*", "GetRoleIdsResponse", ",", "error", ")", "{", "v", ":=", "url", ".", "Values", "{", "}", "\n", "if", "continuationToken", "!=", "\"", "\"", "{", "v", ".", "Add", "(", "\"", "\"", ",", "continuationToken", ")", "\n", "}", "\n", "if", "<mask>", "!=", "\"", "\"", "{", "v", ".", "Add", "(", "\"", "\"", ",", "limit", ")", "\n", "}", "\n", "cd", ":=", "tcclient", ".", "Client", "(", "*", "auth", ")", "\n", "responseObject", ",", "_", ",", "err", ":=", "(", "&", "cd", ")", ".", "APICall", "(", "nil", ",", "\"", "\"", ",", "\"", "\"", ",", "new", "(", "GetRoleIdsResponse", ")", ",", "v", ")", "\n", "return", "responseObject", ".", "(", "*", "GetRoleIdsResponse", ")", ",", "err", "\n", "}" ]
6,624
all-6625
[ "NodeUpdateVersion", "updates", "the", "schema", "and", "API", "version", "of", "the", "node", "with", "the", "given", "id", ".", "This", "is", "used", "only", "in", "tests", "." ]
[ "func", "(", "c", "*", "ClusterTx", ")", "NodeUpdateVersion", "(", "id", "int64", ",", "version", "[", "2", "]", "int", ")", "error", "{", "stmt", ":=", "\"", "\"", "\n\n", "result", ",", "err", ":=", "c", ".", "tx", ".", "Exec", "(", "stmt", ",", "version", "[", "0", "]", ",", "version", "[", "1", "]", ",", "id", ")", "\n", "if", "err", "!=", "nil", "{", "return", "<mask>", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "n", ",", "err", ":=", "result", ".", "RowsAffected", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "if", "n", "!=", "1", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
6,625
all-6626
[ "lintHelp", "detects", "issues", "related", "to", "the", "help", "text", "for", "a", "metric", "." ]
[ "func", "lintHelp", "(", "mf", "dto", ".", "MetricFamily", ")", "[", "]", "Problem", "{", "<mask>", "problems", "problems", "\n\n", "// Expect all metrics to have help text available.", "if", "mf", ".", "Help", "==", "nil", "{", "problems", ".", "Add", "(", "mf", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "problems", "\n", "}" ]
6,626
all-6627
[ "safeBase64Scan", "scans", "from", "src", "(", "which", "should", "be", "either", "a", "[]", "byte", "or", "string", ")", "into", "dest", "by", "using", "SafeUnmarshalBase64", "." ]
[ "func", "safeBase64Scan", "(", "src", ",", "dest", "interface", "{", "}", ")", "error", "{", "var", "val", "string", "\n", "switch", "src", ":=", "src", ".", "(", "<mask>", ")", "{", "case", "[", "]", "byte", ":", "val", "=", "string", "(", "src", ")", "\n", "case", "string", ":", "val", "=", "src", "\n", "default", ":", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "dest", ")", "\n", "}", "\n\n", "return", "SafeUnmarshalBase64", "(", "val", ",", "dest", ")", "\n", "}" ]
6,627
all-6628
[ "NewPackageLogger", "wraps", "*", "capnslog", ".", "PackageLogger", "that", "implements", "Logger", "interface", ".", "For", "example", ":", "var", "defaultLogger", "Logger", "defaultLogger", "=", "NewPackageLogger", "(", "go", ".", "etcd", ".", "io", "/", "etcd", "snapshot", ")" ]
[ "func", "NewPackageLogger", "(", "repo", ",", "pkg", "<mask>", ")", "Logger", "{", "return", "&", "packageLogger", "{", "p", ":", "capnslog", ".", "NewPackageLogger", "(", "repo", ",", "pkg", ")", "}", "\n", "}" ]
6,628
all-6629
[ "SplitDatacenter", "is", "a", "convenience", "method", "that", "splits", "out", "the", "datacenter", "path", "from", "the", "supplied", "path", "for", "the", "particle", "." ]
[ "func", "(", "p", "RootPathParticle", ")", "SplitDatacenter", "(", "inventoryPath", "string", ")", "(", "<mask>", ",", "error", ")", "{", "s", ":=", "strings", ".", "SplitN", "(", "inventoryPath", ",", "p", ".", "Delimiter", "(", ")", ",", "2", ")", "\n", "if", "len", "(", "s", ")", "!=", "2", "{", "return", "inventoryPath", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "inventoryPath", ",", "p", ".", "Delimiter", "(", ")", ")", "\n", "}", "\n", "return", "s", "[", "0", "]", ",", "nil", "\n", "}" ]
6,629
all-6630
[ "IsReady", "reflects", "if", "the", "check", "has", "been", "initialied", "and", "metrics", "can", "be", "sent", "to", "Circonus" ]
[ "func", "(", "cm", "*", "CheckManager", ")", "IsReady", "(", ")", "bool", "{", "cm", ".", "initializedmu", ".", "RLock", "(", ")", "\n", "defer", "cm", ".", "initializedmu", ".", "RUnlock", "(", ")", "\n", "<mask>", "cm", ".", "initialized", "\n", "}" ]
6,630
all-6631
[ "RetryRules", "returns", "the", "correct", "time", "to", "delay", "between", "retries", "for", "this", "instance", "of", "a", "retry", ".", "For", "the", "first", "14", "requests", "it", "follows", "an", "exponential", "backoff", "between", "30ms", "and", "1", "minute", ".", "See", "the", "const", "comments", "for", "math", "on", "how", "this", "gets", "us", "to", "around", "24", "hours", "total", "." ]
[ "func", "(", "retrier", "*", "oneDayRetrier", ")", "RetryRules", "(", "r", "*", "request", ".", "Request", ")", "time", ".", "Duration", "{", "// This logic is the same as the default retrier, but duplicated here such", "// that upstream changes do not invalidate the math done above.", "if", "r", ".", "RetryCount", "<=", "submitStateChangeInitialRetries", "{", "delay", ":=", "int", "(", "math", ".", "Pow", "(", "2", ",", "float64", "(", "r", ".", "RetryCount", ")", ")", ")", "*", "(", "rand", ".", "Intn", "(", "30", ")", "+", "30", ")", "\n", "return", "<mask>", ".", "Duration", "(", "delay", ")", "*", "time", ".", "Millisecond", "\n", "}", "\n", "return", "5", "*", "time", ".", "Minute", "\n", "}" ]
6,631
all-6632
[ "Close", "releases", "the", "resources", "of", "the", "Querier", "." ]
[ "func", "(", "q", "*", "mergeQuerier", ")", "Close", "(", ")", "error", "{", "// TODO return multiple errors?", "<mask>", "lastErr", "error", "\n", "for", "_", ",", "querier", ":=", "range", "q", ".", "queriers", "{", "if", "err", ":=", "querier", ".", "Close", "(", ")", ";", "err", "!=", "nil", "{", "lastErr", "=", "err", "\n", "}", "\n", "}", "\n", "return", "lastErr", "\n", "}" ]
6,632
all-6633
[ "globalCDtorName", "demangles", "a", "global", "constructor", "/", "destructor", "symbol", "name", ".", "The", "parameter", "is", "the", "string", "following", "the", "_GLOBAL_", "prefix", "." ]
[ "func", "globalCDtorName", "(", "name", "string", ",", "options", "...", "Option", ")", "(", "AST", ",", "error", ")", "{", "if", "len", "(", "<mask>", ")", "<", "4", "{", "return", "nil", ",", "ErrNotMangledName", "\n", "}", "\n", "switch", "name", "[", "0", "]", "{", "case", "'.'", ",", "'_'", ",", "'$'", ":", "default", ":", "return", "nil", ",", "ErrNotMangledName", "\n", "}", "\n\n", "var", "ctor", "bool", "\n", "switch", "name", "[", "1", "]", "{", "case", "'I'", ":", "ctor", "=", "true", "\n", "case", "'D'", ":", "ctor", "=", "false", "\n", "default", ":", "return", "nil", ",", "ErrNotMangledName", "\n", "}", "\n\n", "if", "name", "[", "2", "]", "!=", "'_'", "{", "return", "nil", ",", "ErrNotMangledName", "\n", "}", "\n\n", "if", "!", "strings", ".", "HasPrefix", "(", "name", "[", "3", ":", "]", ",", "\"", "\"", ")", "{", "return", "&", "GlobalCDtor", "{", "Ctor", ":", "ctor", ",", "Key", ":", "&", "Name", "{", "Name", ":", "name", "}", "}", ",", "nil", "\n", "}", "else", "{", "a", ",", "err", ":=", "doDemangle", "(", "name", "[", "5", ":", "]", ",", "options", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "adjustErr", "(", "err", ",", "5", ")", "\n", "}", "\n", "return", "&", "GlobalCDtor", "{", "Ctor", ":", "ctor", ",", "Key", ":", "a", "}", ",", "nil", "\n", "}", "\n", "}" ]
6,633
all-6634
[ "Len", "returns", "the", "number", "of", "frames", "in", "the", "FrameSet", ".", "If", "a", "frame", "range", "was", "not", "parsed", "this", "will", "always", "return", "1" ]
[ "func", "(", "s", "*", "FileSequence", ")", "Len", "(", ")", "int", "{", "if", "s", ".", "frameSet", "==", "nil", "{", "return", "1", "\n", "}", "\n", "<mask>", "s", ".", "frameSet", ".", "Len", "(", ")", "\n", "}" ]
6,634
all-6635
[ "PipelineReqFromInfo", "converts", "a", "PipelineInfo", "into", "a", "CreatePipelineRequest", "." ]
[ "func", "PipelineReqFromInfo", "(", "pipelineInfo", "*", "ppsclient", ".", "PipelineInfo", ")", "*", "ppsclient", ".", "CreatePipelineRequest", "{", "return", "&", "ppsclient", ".", "CreatePipelineRequest", "{", "Pipeline", ":", "pipelineInfo", ".", "Pipeline", ",", "Transform", ":", "pipelineInfo", ".", "Transform", ",", "ParallelismSpec", ":", "pipelineInfo", ".", "ParallelismSpec", ",", "HashtreeSpec", ":", "pipelineInfo", ".", "HashtreeSpec", ",", "Egress", ":", "pipelineInfo", ".", "Egress", ",", "OutputBranch", ":", "pipelineInfo", ".", "OutputBranch", ",", "ScaleDownThreshold", ":", "pipelineInfo", ".", "ScaleDownThreshold", ",", "ResourceRequests", ":", "pipelineInfo", ".", "ResourceRequests", ",", "ResourceLimits", ":", "pipelineInfo", ".", "ResourceLimits", ",", "Input", ":", "pipelineInfo", ".", "Input", ",", "Description", ":", "pipelineInfo", ".", "Description", ",", "CacheSize", ":", "pipelineInfo", ".", "CacheSize", ",", "EnableStats", ":", "pipelineInfo", ".", "EnableStats", ",", "Batch", ":", "pipelineInfo", ".", "Batch", ",", "MaxQueueSize", ":", "pipelineInfo", ".", "MaxQueueSize", ",", "Service", ":", "pipelineInfo", ".", "<mask>", ",", "ChunkSpec", ":", "pipelineInfo", ".", "ChunkSpec", ",", "DatumTimeout", ":", "pipelineInfo", ".", "DatumTimeout", ",", "JobTimeout", ":", "pipelineInfo", ".", "JobTimeout", ",", "Salt", ":", "pipelineInfo", ".", "Salt", ",", "}", "\n", "}" ]
6,635
all-6636
[ "Run", "starts", "daemon", "and", "all", "services", "within", "." ]
[ "func", "(", "d", "*", "Daemon", ")", "Run", "(", ")", "(", "err", "error", ")", "{", "var", "(", "cl", "*", "cluster", ".", "Cluster", "\n", "tracer", "opentracing", ".", "Tracer", "\n", ")", "\n", "if", "cl", ",", "err", "=", "initCluster", "(", "d", ".", "logger", ",", "d", ".", "opts", ".", "ClusterListenAddr", ",", "d", ".", "opts", ".", "ClusterSeeds", "...", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "if", "err", "=", "d", ".", "initStorage", "(", "d", ".", "logger", ",", "d", ".", "opts", ".", "PostgresTable", ",", "d", ".", "opts", ".", "PostgresSchema", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "interceptor", ":=", "promgrpc", ".", "NewInterceptor", "(", "promgrpc", ".", "InterceptorOpts", "{", "}", ")", "\n\n", "if", "d", ".", "opts", ".", "TracingAgentAddress", "!=", "\"", "\"", "{", "if", "tracer", ",", "d", ".", "tracerCloser", ",", "err", "=", "initJaeger", "(", "constant", ".", "Subsystem", ",", "d", ".", "opts", ".", "ClusterListenAddr", ",", "d", ".", "opts", ".", "TracingAgentAddress", ",", "d", ".", "logger", ".", "Named", "(", "\"", "\"", ")", ",", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "d", ".", "logger", ".", "Info", "(", "\"", "\"", ",", "zap", ".", "String", "(", "\"", "\"", ",", "d", ".", "opts", ".", "TracingAgentAddress", ")", ")", "\n", "}", "else", "{", "tracer", "=", "opentracing", ".", "NoopTracer", "{", "}", "\n", "}", "\n\n", "d", ".", "clientOptions", "=", "[", "]", "grpc", ".", "DialOption", "{", "// User agent is required for example to determine if incoming request is internal.", "grpc", ".", "WithUserAgent", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "constant", ".", "Subsystem", ",", "d", ".", "opts", ".", "Version", ")", ")", ",", "grpc", ".", "WithStatsHandler", "(", "interceptor", ")", ",", "grpc", ".", "WithDialer", "(", "interceptor", ".", "Dialer", "(", "func", "(", "addr", "string", ",", "timeout", "time", ".", "Duration", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "return", "<mask>", ".", "DialTimeout", "(", "\"", "\"", ",", "addr", ",", "timeout", ")", "\n", "}", ")", ")", ",", "grpc", ".", "WithUnaryInterceptor", "(", "unaryClientInterceptors", "(", "interceptor", ".", "UnaryClient", "(", ")", ",", "otgrpc", ".", "OpenTracingClientInterceptor", "(", "tracer", ")", ")", ",", ")", ",", "grpc", ".", "WithStreamInterceptor", "(", "interceptor", ".", "StreamClient", "(", ")", ")", ",", "}", "\n", "d", ".", "serverOptions", "=", "[", "]", "grpc", ".", "ServerOption", "{", "grpc", ".", "StatsHandler", "(", "interceptor", ")", ",", "grpc", ".", "UnaryInterceptor", "(", "unaryServerInterceptors", "(", "otgrpc", ".", "OpenTracingServerInterceptor", "(", "tracer", ")", ",", "errorInterceptor", "(", "d", ".", "logger", ")", ",", "interceptor", ".", "UnaryServer", "(", ")", ",", ")", ")", ",", "}", "\n", "if", "d", ".", "opts", ".", "TLS", "{", "servCreds", ",", "err", ":=", "credentials", ".", "NewServerTLSFromFile", "(", "d", ".", "opts", ".", "TLSCertFile", ",", "d", ".", "opts", ".", "TLSKeyFile", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "d", ".", "serverOptions", "=", "append", "(", "d", ".", "serverOptions", ",", "grpc", ".", "Creds", "(", "servCreds", ")", ")", "\n\n", "clientCreds", ",", "err", ":=", "credentials", ".", "NewClientTLSFromFile", "(", "d", ".", "opts", ".", "TLSCertFile", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "d", ".", "clientOptions", "=", "append", "(", "d", ".", "clientOptions", ",", "grpc", ".", "WithTransportCredentials", "(", "clientCreds", ")", ")", "\n", "}", "else", "{", "d", ".", "clientOptions", "=", "append", "(", "d", ".", "clientOptions", ",", "grpc", ".", "WithInsecure", "(", ")", ")", "\n", "}", "\n\n", "d", ".", "server", "=", "grpc", ".", "NewServer", "(", "d", ".", "serverOptions", "...", ")", "\n\n", "cache", ":=", "cache", ".", "New", "(", "5", "*", "time", ".", "Second", ",", "constant", ".", "Subsystem", ")", "\n", "mnemosyneServer", ",", "err", ":=", "newSessionManager", "(", "sessionManagerOpts", "{", "addr", ":", "d", ".", "opts", ".", "ClusterListenAddr", ",", "cluster", ":", "cl", ",", "logger", ":", "d", ".", "logger", ",", "storage", ":", "d", ".", "storage", ",", "ttc", ":", "d", ".", "opts", ".", "SessionTTC", ",", "cache", ":", "cache", ",", "tracer", ":", "tracer", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "mnemosynerpc", ".", "RegisterSessionManagerServer", "(", "d", ".", "server", ",", "mnemosyneServer", ")", "\n", "grpc_health_v1", ".", "RegisterHealthServer", "(", "d", ".", "server", ",", "health", ".", "NewServer", "(", ")", ")", "\n\n", "if", "!", "d", ".", "opts", ".", "IsTest", "{", "prometheus", ".", "DefaultRegisterer", ".", "Register", "(", "d", ".", "storage", ".", "(", "storage", ".", "InstrumentedStorage", ")", ")", "\n", "prometheus", ".", "DefaultRegisterer", ".", "Register", "(", "cache", ")", "\n", "prometheus", ".", "DefaultRegisterer", ".", "Register", "(", "mnemosyneServer", ")", "\n", "prometheus", ".", "DefaultRegisterer", ".", "Register", "(", "interceptor", ")", "\n", "promgrpc", ".", "RegisterInterceptor", "(", "d", ".", "server", ",", "interceptor", ")", "\n", "}", "\n\n", "ctx", ",", "cancel", ":=", "context", ".", "WithTimeout", "(", "context", ".", "Background", "(", ")", ",", "5", "*", "time", ".", "Second", ")", "\n", "defer", "cancel", "(", ")", "\n\n", "if", "err", "=", "cl", ".", "Connect", "(", "ctx", ",", "d", ".", "clientOptions", "...", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "go", "func", "(", ")", "{", "d", ".", "logger", ".", "Info", "(", "\"", "\"", ",", "zap", ".", "String", "(", "\"", "\"", ",", "d", ".", "rpcListener", ".", "Addr", "(", ")", ".", "String", "(", ")", ")", ")", "\n\n", "if", "err", ":=", "d", ".", "server", ".", "Serve", "(", "d", ".", "rpcListener", ")", ";", "err", "!=", "nil", "{", "if", "err", "==", "grpc", ".", "ErrServerStopped", "{", "d", ".", "logger", ".", "Info", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n\n", "if", "!", "strings", ".", "Contains", "(", "err", ".", "Error", "(", ")", ",", "\"", "\"", ")", "{", "d", ".", "logger", ".", "Error", "(", "\"", "\"", ",", "zap", ".", "Error", "(", "err", ")", ")", "\n", "}", "\n", "}", "\n", "}", "(", ")", "\n\n", "if", "d", ".", "debugListener", "!=", "nil", "{", "go", "func", "(", ")", "{", "d", ".", "logger", ".", "Info", "(", "\"", "\"", ",", "zap", ".", "String", "(", "\"", "\"", ",", "d", ".", "debugListener", ".", "Addr", "(", ")", ".", "String", "(", ")", ")", ")", "\n\n", "mux", ":=", "http", ".", "NewServeMux", "(", ")", "\n", "mux", ".", "Handle", "(", "\"", "\"", ",", "http", ".", "HandlerFunc", "(", "pprof", ".", "Index", ")", ")", "\n", "mux", ".", "Handle", "(", "\"", "\"", ",", "http", ".", "HandlerFunc", "(", "pprof", ".", "Cmdline", ")", ")", "\n", "mux", ".", "Handle", "(", "\"", "\"", ",", "http", ".", "HandlerFunc", "(", "pprof", ".", "Profile", ")", ")", "\n", "mux", ".", "Handle", "(", "\"", "\"", ",", "http", ".", "HandlerFunc", "(", "pprof", ".", "Symbol", ")", ")", "\n", "mux", ".", "Handle", "(", "\"", "\"", ",", "http", ".", "HandlerFunc", "(", "pprof", ".", "Trace", ")", ")", "\n", "mux", ".", "Handle", "(", "\"", "\"", ",", "promhttp", ".", "HandlerFor", "(", "prometheus", ".", "DefaultGatherer", ",", "promhttp", ".", "HandlerOpts", "{", "}", ")", ")", "\n", "mux", ".", "Handle", "(", "\"", "\"", ",", "&", "livenessHandler", "{", "livenessResponse", ":", "livenessResponse", "{", "Version", ":", "d", ".", "opts", ".", "Version", ",", "}", ",", "logger", ":", "d", ".", "logger", ",", "}", ")", "\n", "mux", ".", "Handle", "(", "\"", "\"", ",", "&", "readinessHandler", "{", "livenessResponse", ":", "livenessResponse", "{", "Version", ":", "d", ".", "opts", ".", "Version", ",", "}", ",", "logger", ":", "d", ".", "logger", ",", "postgres", ":", "d", ".", "postgres", ",", "cluster", ":", "cl", ",", "}", ")", "\n", "if", "err", ":=", "http", ".", "Serve", "(", "d", ".", "debugListener", ",", "mux", ")", ";", "err", "!=", "nil", "{", "d", ".", "logger", ".", "Error", "(", "\"", "\"", ",", "zap", ".", "Error", "(", "err", ")", ")", "\n", "}", "\n", "}", "(", ")", "\n", "}", "\n\n", "go", "mnemosyneServer", ".", "cleanup", "(", "d", ".", "done", ")", "\n\n", "return", "\n", "}" ]
6,636
all-6637
[ "HTTPRespondText", "sets", "Content", "-", "Type", "to", "text", "/", "plain", "and", "compresses", "the", "response", "if", "Content", "-", "Encoding", "from", "the", "request", "allows", "it", "." ]
[ "func", "HTTPRespondText", "(", "response", "string", ",", "responseWriter", "http", ".", "ResponseWriter", ",", "request", "*", "http", ".", "Request", ")", "(", "err", "error", ")", "{", "NewHTTPCompressHandlerFromFunc", "(", "func", "(", "responseWriter", "http", ".", "ResponseWriter", ",", "request", "*", "<mask>", ".", "Request", ")", "{", "responseWriter", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "_", ",", "err", "=", "responseWriter", ".", "Write", "(", "[", "]", "byte", "(", "response", ")", ")", "\n", "}", ")", ".", "ServeHTTP", "(", "responseWriter", ",", "request", ")", "\n", "return", "err", "\n", "}" ]
6,637
all-6638
[ "GamepadAxis", "returns", "the", "float", "value", "[", "-", "1", ".", "0", "-", "1", ".", "0", "]", "of", "the", "given", "gamepad", "(", "id", ")", "s", "axis", "(", "axis", ")", ".", "GamepadAxis", "is", "concurrent", "-", "safe", ".", "GamepadAxis", "always", "returns", "0", "on", "mobiles", "." ]
[ "func", "GamepadAxis", "(", "<mask>", "int", ",", "axis", "int", ")", "float64", "{", "return", "uiDriver", "(", ")", ".", "Input", "(", ")", ".", "GamepadAxis", "(", "id", ",", "axis", ")", "\n", "}" ]
6,638
all-6639
[ "this", "method", "does", "C", "+", "2", "*", "Z", "requests", ":", "C", "=", "total", "number", "of", "changes", "Z", "=", "number", "of", "affected", "zones", "(", "1", "login", "+", "1", "commit", ")" ]
[ "func", "(", "d", "*", "dynProviderState", ")", "ApplyChanges", "(", "<mask>", "*", "plan", ".", "Changes", ")", "error", "{", "log", ".", "Debugf", "(", "\"", "\"", ",", "changes", ")", "\n\n", "if", "d", ".", "DryRun", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "changes", ".", "Delete", ")", "\n", "log", ".", "Infof", "(", "\"", "\"", ",", "changes", ".", "Create", ")", "\n", "log", ".", "Infof", "(", "\"", "\"", ",", "merge", "(", "changes", ".", "UpdateOld", ",", "changes", ".", "UpdateNew", ")", ")", "\n", "return", "nil", "\n", "}", "\n\n", "client", ",", "err", ":=", "d", ".", "login", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "client", ".", "Logout", "(", ")", "\n\n", "var", "errs", "[", "]", "error", "\n\n", "needsCommit", ":=", "false", "\n\n", "for", "_", ",", "ep", ":=", "range", "changes", ".", "Delete", "{", "err", ":=", "d", ".", "deleteRecord", "(", "client", ",", "ep", ")", "\n", "if", "err", "!=", "nil", "{", "errs", "=", "append", "(", "errs", ",", "err", ")", "\n", "}", "else", "{", "needsCommit", "=", "true", "\n", "}", "\n", "}", "\n\n", "for", "_", ",", "ep", ":=", "range", "changes", ".", "Create", "{", "err", ":=", "d", ".", "createRecord", "(", "client", ",", "ep", ")", "\n", "if", "err", "!=", "nil", "{", "errs", "=", "append", "(", "errs", ",", "err", ")", "\n", "}", "else", "{", "needsCommit", "=", "true", "\n", "}", "\n", "}", "\n\n", "updates", ":=", "merge", "(", "changes", ".", "UpdateOld", ",", "changes", ".", "UpdateNew", ")", "\n", "log", ".", "Debugf", "(", "\"", "\"", ",", "updates", ")", "\n", "for", "_", ",", "ep", ":=", "range", "updates", "{", "err", ":=", "d", ".", "replaceRecord", "(", "client", ",", "ep", ")", "\n", "if", "err", "!=", "nil", "{", "errs", "=", "append", "(", "errs", ",", "err", ")", "\n", "}", "else", "{", "needsCommit", "=", "true", "\n", "}", "\n", "}", "\n\n", "switch", "len", "(", "errs", ")", "{", "case", "0", ":", "case", "1", ":", "return", "errs", "[", "0", "]", "\n", "default", ":", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "errs", ")", "\n", "}", "\n\n", "if", "needsCommit", "{", "return", "d", ".", "commit", "(", "client", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
6,639
all-6640
[ "InspectContainer", "indicates", "an", "expected", "call", "of", "InspectContainer" ]
[ "func", "(", "mr", "*", "MockDockerMetadataClientMockRecorder", ")", "InspectContainer", "(", "arg0", ",", "arg1", ",", "arg2", "<mask>", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockDockerMetadataClient", ")", "(", "nil", ")", ".", "InspectContainer", ")", ",", "arg0", ",", "arg1", ",", "arg2", ")", "\n", "}" ]
6,640
all-6641
[ "Serialize", "the", "CHD", ".", "The", "serialized", "form", "is", "conducive", "to", "mmapped", "access", ".", "See", "the", "Mmap", "function", "for", "details", "." ]
[ "func", "(", "c", "*", "CHD", ")", "Write", "(", "w", "io", ".", "Writer", ")", "error", "{", "write", ":=", "func", "(", "nd", "...", "interface", "{", "}", ")", "error", "{", "for", "_", ",", "d", ":=", "range", "nd", "{", "if", "err", ":=", "<mask>", ".", "Write", "(", "w", ",", "binary", ".", "LittleEndian", ",", "d", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}", "\n\n", "data", ":=", "[", "]", "interface", "{", "}", "{", "uint32", "(", "len", "(", "c", ".", "r", ")", ")", ",", "c", ".", "r", ",", "uint32", "(", "len", "(", "c", ".", "indices", ")", ")", ",", "c", ".", "indices", ",", "uint32", "(", "len", "(", "c", ".", "keys", ")", ")", ",", "}", "\n\n", "if", "err", ":=", "write", "(", "data", "...", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "for", "i", ":=", "range", "c", ".", "keys", "{", "k", ",", "v", ":=", "c", ".", "keys", "[", "i", "]", ",", "c", ".", "values", "[", "i", "]", "\n", "if", "err", ":=", "write", "(", "uint32", "(", "len", "(", "k", ")", ")", ",", "uint32", "(", "len", "(", "v", ")", ")", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "_", ",", "err", ":=", "w", ".", "Write", "(", "k", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "_", ",", "err", ":=", "w", ".", "Write", "(", "v", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
6,641
all-6642
[ "Sort", "sorts", "Args", "by", "key", "and", "then", "value", "using", "f", "as", "comparison", "function", ".", "For", "example", "args", ".", "Sort", "(", "bytes", ".", "Compare", ")" ]
[ "func", "(", "a", "*", "Args", ")", "Sort", "(", "f", "func", "(", "x", ",", "y", "[", "]", "<mask>", ")", "int", ")", "{", "sort", ".", "SliceStable", "(", "a", ".", "args", ",", "func", "(", "i", ",", "j", "int", ")", "bool", "{", "n", ":=", "f", "(", "a", ".", "args", "[", "i", "]", ".", "key", ",", "a", ".", "args", "[", "j", "]", ".", "key", ")", "\n", "if", "n", "==", "0", "{", "return", "f", "(", "a", ".", "args", "[", "i", "]", ".", "value", ",", "a", ".", "args", "[", "j", "]", ".", "value", ")", "==", "-", "1", "\n", "}", "\n", "return", "n", "==", "-", "1", "\n", "}", ")", "\n", "}" ]
6,642
all-6643
[ "NewPatternForSurface", "is", "a", "wrapper", "around", "cairo_pattern_create_for_surface", "()", "." ]
[ "func", "NewPatternForSurface", "(", "s", "*", "Surface", ")", "(", "*", "<mask>", ",", "error", ")", "{", "c", ":=", "C", ".", "cairo_pattern_create_for_surface", "(", "s", ".", "native", "(", ")", ")", "\n", "return", "newPatternFromNative", "(", "c", ")", "\n", "}" ]
6,643
all-6644
[ "sshVolume", "converts", "a", "secret", "holding", "ssh", "keys", "into", "the", "corresponding", "volume", "and", "mount", ".", "This", "is", "used", "by", "CloneRefs", "to", "attach", "the", "mount", "to", "the", "clonerefs", "container", "." ]
[ "func", "sshVolume", "(", "secret", "string", ")", "(", "coreapi", ".", "Volume", ",", "coreapi", ".", "VolumeMount", ")", "{", "var", "sshKeyMode", "int32", "=", "0400", "// this is octal, so symbolic ref is `u+r`", "\n", "name", ":=", "strings", ".", "Join", "(", "[", "]", "string", "{", "\"", "\"", ",", "secret", "}", ",", "\"", "\"", ")", "\n", "mountPath", ":=", "path", ".", "Join", "(", "\"", "\"", ",", "secret", ")", "\n", "v", ":=", "coreapi", ".", "Volume", "{", "Name", ":", "name", ",", "VolumeSource", ":", "coreapi", ".", "VolumeSource", "{", "Secret", ":", "&", "coreapi", ".", "SecretVolumeSource", "{", "SecretName", ":", "secret", ",", "DefaultMode", ":", "&", "sshKeyMode", ",", "}", ",", "}", ",", "}", "\n\n", "vm", ":=", "coreapi", ".", "VolumeMount", "{", "Name", ":", "<mask>", ",", "MountPath", ":", "mountPath", ",", "ReadOnly", ":", "true", ",", "}", "\n\n", "return", "v", ",", "vm", "\n", "}" ]
6,644
all-6645
[ "UnmarshalEasyJSON", "satisfies", "easyjson", ".", "Unmarshaler", "." ]
[ "func", "(", "t", "*", "RequestStage", ")", "UnmarshalEasyJSON", "(", "in", "*", "jlexer", ".", "Lexer", ")", "{", "switch", "RequestStage", "(", "in", ".", "String", "(", ")", ")", "{", "case", "RequestStageRequest", ":", "*", "t", "=", "RequestStageRequest", "\n", "case", "RequestStageResponse", ":", "*", "t", "=", "RequestStageResponse", "\n\n", "default", ":", "<mask>", ".", "AddError", "(", "errors", ".", "New", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "}" ]
6,645
all-6646
[ "NewWithClient", "creates", "a", "new", "client", "with", "your", "personal", "API", "key", "and", "the", "given", "http", "Client" ]
[ "func", "NewWithClient", "(", "apikey", "string", ",", "client", "*", "http", ".", "Client", ")", "*", "Client", "{", "endpoint", ":=", "Endpoint", "{", "<mask>", ":", "EndpointURL", "}", "\n", "return", "&", "Client", "{", "apikey", ",", "client", ",", "endpoint", "}", "\n", "}" ]
6,646
all-6647
[ "SetProgressPulseStep", "()", "is", "a", "wrapper", "around", "gtk_entry_set_progress_pulse_step", "()", "." ]
[ "func", "(", "v", "*", "<mask>", ")", "SetProgressPulseStep", "(", "fraction", "float64", ")", "{", "C", ".", "gtk_entry_set_progress_pulse_step", "(", "v", ".", "native", "(", ")", ",", "C", ".", "gdouble", "(", "fraction", ")", ")", "\n", "}" ]
6,647
all-6648
[ "WithHandleAuthRequests", "if", "true", "authRequired", "events", "will", "be", "issued", "and", "requests", "will", "be", "paused", "expecting", "a", "call", "to", "continueWithAuth", "." ]
[ "func", "(", "p", "EnableParams", ")", "WithHandleAuthRequests", "(", "handleAuthRequests", "bool", ")", "*", "EnableParams", "{", "p", ".", "HandleAuthRequests", "=", "handleAuthRequests", "\n", "<mask>", "&", "p", "\n", "}" ]
6,648
all-6649
[ "Close", "the", "background", "processing", "of", "the", "storage", "queues", "." ]
[ "func", "(", "s", "*", "<mask>", ")", "Close", "(", ")", "error", "{", "s", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "for", "_", ",", "q", ":=", "range", "s", ".", "queues", "{", "q", ".", "Stop", "(", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
6,649
all-6650
[ "MutateTransaction", "for", "SourceAccount", "sets", "the", "transaction", "s", "SourceAccount", "to", "the", "pubilic", "key", "for", "the", "address", "provided" ]
[ "func", "(", "m", "SourceAccount", ")", "MutateTransaction", "(", "o", "*", "TransactionBuilder", ")", "<mask>", "{", "return", "setAccountId", "(", "m", ".", "AddressOrSeed", ",", "&", "o", ".", "TX", ".", "SourceAccount", ")", "\n", "}" ]
6,650
all-6651
[ "ValidatePolicyConfigurationScope", "checks", "that", "scope", "is", "a", "valid", "name", "for", "a", "signature", ".", "PolicyTransportScopes", "keys", "(", "i", ".", "e", ".", "a", "valid", "PolicyConfigurationIdentity", "()", "or", "PolicyConfigurationNamespaces", "()", "return", "value", ")", ".", "It", "is", "acceptable", "to", "allow", "an", "invalid", "value", "which", "will", "never", "be", "matched", "it", "can", "only", "cause", "user", "confusion", ".", "scope", "passed", "to", "this", "function", "will", "not", "be", "that", "value", "is", "always", "allowed", "." ]
[ "func", "(", "t", "daemonTransport", ")", "ValidatePolicyConfigurationScope", "(", "scope", "string", ")", "error", "{", "// ID values cannot be effectively namespaced, and are clearly invalid host:port values.", "if", "_", ",", "err", ":=", "digest", ".", "Parse", "(", "<mask>", ")", ";", "err", "==", "nil", "{", "return", "errors", ".", "Errorf", "(", "`docker-daemon: can not use algo:digest value %s as a namespace`", ",", "scope", ")", "\n", "}", "\n\n", "// FIXME? We could be verifying the various character set and length restrictions", "// from docker/distribution/reference.regexp.go, but other than that there", "// are few semantically invalid strings.", "return", "nil", "\n", "}" ]
6,651
all-6652
[ "AddHerokuKey", "associates", "a", "Heroku", "key", "with", "the", "user", "s", "API", "token", "to", "allow", "CircleCI", "to", "deploy", "to", "Heroku", "on", "your", "behalf", "The", "API", "token", "being", "used", "must", "be", "a", "user", "API", "token", "NOTE", ":", "It", "doesn", "t", "look", "like", "there", "is", "currently", "a", "way", "to", "dissaccociate", "your", "Heroku", "key", "so", "use", "with", "care" ]
[ "func", "(", "c", "*", "<mask>", ")", "AddHerokuKey", "(", "key", "string", ")", "error", "{", "body", ":=", "struct", "{", "APIKey", "string", "`json:\"apikey\"`", "\n", "}", "{", "APIKey", ":", "key", "}", "\n\n", "return", "c", ".", "request", "(", "\"", "\"", ",", "\"", "\"", ",", "nil", ",", "nil", ",", "body", ")", "\n", "}" ]
6,652
all-6653
[ "const", "char", "*", "pango_layout_get_text", "(", "PangoLayout", "*", "layout", ")", ";" ]
[ "func", "(", "v", "*", "Layout", ")", "GetText", "(", ")", "string", "{", "c", ":=", "C", ".", "pango_layout_get_text", "(", "v", ".", "native", "(", ")", ")", "\n", "return", "C", ".", "GoString", "(", "(", "*", "C", ".", "<mask>", ")", "(", "c", ")", ")", "\n", "}" ]
6,653
all-6654
[ "AddPeer", "implements", "Reactor", "by", "adding", "peer", "to", "the", "address", "book", "(", "if", "inbound", ")", "or", "by", "requesting", "more", "addresses", "(", "if", "outbound", ")", "." ]
[ "func", "(", "r", "*", "PEXReactor", ")", "AddPeer", "(", "p", "*", "Peer", ")", "{", "if", "p", ".", "IsOutbound", "(", ")", "{", "// For outbound peers, the address is already in the books.", "// Either it was added in DialSeeds or when we", "// received the peer's address in r.Receive", "if", "r", ".", "book", ".", "NeedMoreAddrs", "(", ")", "{", "r", ".", "RequestPEX", "(", "p", ")", "\n", "}", "\n", "}", "else", "{", "// For inbound connections, the peer is its own source", "addr", ",", "err", ":=", "NewNetAddressString", "(", "p", ".", "ListenAddr", ")", "\n", "if", "err", "!=", "nil", "{", "// this should never happen", "<mask>", ".", "Error", "(", "\"", "\"", ",", "\"", "\"", ",", "p", ".", "ListenAddr", ",", "\"", "\"", ",", "err", ")", "\n", "return", "\n", "}", "\n", "r", ".", "book", ".", "AddAddress", "(", "addr", ",", "addr", ")", "\n", "}", "\n", "}" ]
6,654
all-6655
[ "UnmarshalJSON", "satisfies", "json", ".", "Unmarshaler", "." ]
[ "func", "(", "t", "*", "WindowState", ")", "UnmarshalJSON", "(", "buf", "[", "]", "<mask>", ")", "error", "{", "return", "easyjson", ".", "Unmarshal", "(", "buf", ",", "t", ")", "\n", "}" ]
6,655
all-6656
[ "WithTimeout", "adds", "the", "timeout", "to", "the", "get", "apps", "params" ]
[ "func", "(", "o", "*", "GetAppsParams", ")", "WithTimeout", "(", "timeout", "<mask>", ".", "Duration", ")", "*", "GetAppsParams", "{", "o", ".", "SetTimeout", "(", "timeout", ")", "\n", "return", "o", "\n", "}" ]
6,656
all-6657
[ "native", "returns", "a", "pointer", "to", "the", "underlying", "GtkStyleContext", "." ]
[ "func", "(", "v", "*", "StyleContext", ")", "native", "(", ")", "*", "C", ".", "GtkStyleContext", "{", "if", "v", "==", "nil", "||", "v", ".", "<mask>", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "p", ":=", "unsafe", ".", "Pointer", "(", "v", ".", "GObject", ")", "\n", "return", "C", ".", "toGtkStyleContext", "(", "p", ")", "\n", "}" ]
6,657
all-6658
[ "SetCursor", "is", "a", "wrapper", "around", "gtk_tree_view_set_cursor", "()", "." ]
[ "func", "(", "v", "*", "TreeView", ")", "SetCursor", "(", "path", "*", "TreePath", ",", "focusColumn", "*", "TreeViewColumn", ",", "startEditing", "bool", ")", "{", "C", ".", "gtk_tree_view_set_cursor", "(", "v", ".", "native", "(", ")", ",", "<mask>", ".", "native", "(", ")", ",", "focusColumn", ".", "native", "(", ")", ",", "gbool", "(", "startEditing", ")", ")", "\n", "}" ]
6,658
all-6659
[ "shouldOverrideIPCMode", "returns", "true", "if", "the", "IPCMode", "of", "the", "container", "needs", "to", "be", "overridden", ".", "It", "also", "returns", "the", "override", "string", "in", "this", "case", ".", "It", "returns", "false", "otherwise" ]
[ "func", "(", "task", "*", "Task", ")", "shouldOverrideIPCMode", "(", "container", "*", "apicontainer", ".", "Container", ",", "dockerContainerMap", "map", "[", "string", "]", "*", "apicontainer", ".", "DockerContainer", ")", "(", "bool", ",", "string", ")", "{", "// All internal containers do not need the same IPCMode. The NamespaceContainerPause", "// needs to be \"shareable\" if ipcMode is \"task\". All other internal containers should", "// defer to the Docker daemon default option (either shareable or private depending on", "// version and configuration)", "if", "container", ".", "IsInternal", "(", ")", "{", "if", "container", ".", "Type", "==", "apicontainer", ".", "ContainerNamespacePause", "{", "// Setting NamespaceContainerPause to be sharable with other containers", "if", "task", ".", "getIPCMode", "(", ")", "==", "ipcModeTask", "{", "return", "true", ",", "ipcModeSharable", "\n", "}", "\n", "}", "\n", "// Defaulting to Docker daemon default option", "return", "false", ",", "\"", "\"", "\n", "}", "\n\n", "switch", "task", ".", "getIPCMode", "(", ")", "{", "// No IPCMode provided in Task Definition, no need to override", "case", "\"", "\"", ":", "return", "false", ",", "\"", "\"", "\n\n", "// IPCMode is none - container will have own private namespace with /dev/shm not mounted", "case", "ipcModeNone", ":", "return", "true", ",", "ipcModeNone", "\n\n", "case", "ipcModeHost", ":", "return", "true", ",", "ipcModeHost", "\n\n", "<mask>", "ipcModeTask", ":", "pauseCont", ",", "ok", ":=", "task", ".", "ContainerByName", "(", "NamespacePauseContainerName", ")", "\n", "if", "!", "ok", "{", "seelog", ".", "Criticalf", "(", "\"", "\"", ",", "task", ".", "Arn", ")", "\n", "task", ".", "SetDesiredStatus", "(", "apitaskstatus", ".", "TaskStopped", ")", "\n", "return", "false", ",", "\"", "\"", "\n", "}", "\n", "pauseDockerID", ",", "ok", ":=", "dockerContainerMap", "[", "pauseCont", ".", "Name", "]", "\n", "if", "!", "ok", "||", "pauseDockerID", "==", "nil", "{", "// Docker container shouldn't be nill or not exist if the Container definition within task exists; implies code-bug", "seelog", ".", "Criticalf", "(", "\"", "\"", ",", "task", ".", "Arn", ")", "\n", "task", ".", "SetDesiredStatus", "(", "apitaskstatus", ".", "TaskStopped", ")", "\n", "return", "false", ",", "\"", "\"", "\n", "}", "\n", "return", "true", ",", "dockerMappingContainerPrefix", "+", "pauseDockerID", ".", "DockerID", "\n\n", "default", ":", "return", "false", ",", "\"", "\"", "\n", "}", "\n", "}" ]
6,659
all-6660
[ "GetBuilds", "lists", "all", "scheduled", "builds", "for", "the", "provided", "job", ".", "In", "newer", "Jenkins", "versions", "this", "also", "includes", "enqueued", "builds", "(", "tested", "in", "2", ".", "73", ".", "2", ")", "." ]
[ "func", "(", "c", "*", "Client", ")", "GetBuilds", "(", "job", "string", ")", "(", "map", "[", "string", "]", "Build", ",", "error", ")", "{", "c", ".", "logger", ".", "Debugf", "(", "\"", "\"", ",", "<mask>", ")", "\n\n", "data", ",", "err", ":=", "c", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "job", ")", ")", "\n", "if", "err", "!=", "nil", "{", "// Ignore 404s so we will not block processing the rest of the jobs.", "if", "_", ",", "isNotFound", ":=", "err", ".", "(", "NotFoundError", ")", ";", "isNotFound", "{", "c", ".", "logger", ".", "WithError", "(", "err", ")", ".", "Warnf", "(", "\"", "\"", ",", "job", ")", "\n", "return", "nil", ",", "nil", "\n", "}", "\n", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "job", ",", "err", ")", "\n", "}", "\n", "page", ":=", "struct", "{", "Builds", "[", "]", "Build", "`json:\"builds\"`", "\n", "}", "{", "}", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "data", ",", "&", "page", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "job", ",", "err", ")", "\n", "}", "\n", "jenkinsBuilds", ":=", "make", "(", "map", "[", "string", "]", "Build", ")", "\n", "for", "_", ",", "jb", ":=", "range", "page", ".", "Builds", "{", "prowJobID", ":=", "jb", ".", "ProwJobID", "(", ")", "\n", "// Ignore builds with missing buildID parameters.", "if", "prowJobID", "==", "\"", "\"", "{", "continue", "\n", "}", "\n", "jenkinsBuilds", "[", "prowJobID", "]", "=", "jb", "\n", "}", "\n", "return", "jenkinsBuilds", ",", "nil", "\n", "}" ]
6,660
all-6661
[ "/", "*", "During", "stage", "planning", "stages", "of", "equal", "precedence", "are", "parsed", "such", "that", "they", "ll", "be", "evaluated", "in", "reverse", "order", ".", "For", "commutative", "operators", "like", "+", "or", "-", "it", "s", "no", "big", "deal", ".", "But", "for", "order", "-", "specific", "operators", "it", "ruins", "the", "expected", "result", "." ]
[ "func", "reorderStages", "(", "rootStage", "*", "evaluationStage", ")", "{", "// traverse every rightStage until we find multiples in a row of the same precedence.", "<mask>", "identicalPrecedences", "[", "]", "*", "evaluationStage", "\n", "var", "currentStage", ",", "nextStage", "*", "evaluationStage", "\n", "var", "precedence", ",", "currentPrecedence", "operatorPrecedence", "\n\n", "nextStage", "=", "rootStage", "\n", "precedence", "=", "findOperatorPrecedenceForSymbol", "(", "rootStage", ".", "symbol", ")", "\n\n", "for", "nextStage", "!=", "nil", "{", "currentStage", "=", "nextStage", "\n", "nextStage", "=", "currentStage", ".", "rightStage", "\n\n", "// left depth first, since this entire method only looks for precedences down the right side of the tree", "if", "currentStage", ".", "leftStage", "!=", "nil", "{", "reorderStages", "(", "currentStage", ".", "leftStage", ")", "\n", "}", "\n\n", "currentPrecedence", "=", "findOperatorPrecedenceForSymbol", "(", "currentStage", ".", "symbol", ")", "\n\n", "if", "currentPrecedence", "==", "precedence", "{", "identicalPrecedences", "=", "append", "(", "identicalPrecedences", ",", "currentStage", ")", "\n", "continue", "\n", "}", "\n\n", "// precedence break.", "// See how many in a row we had, and reorder if there's more than one.", "if", "len", "(", "identicalPrecedences", ")", ">", "1", "{", "mirrorStageSubtree", "(", "identicalPrecedences", ")", "\n", "}", "\n\n", "identicalPrecedences", "=", "[", "]", "*", "evaluationStage", "{", "currentStage", "}", "\n", "precedence", "=", "currentPrecedence", "\n", "}", "\n\n", "if", "len", "(", "identicalPrecedences", ")", ">", "1", "{", "mirrorStageSubtree", "(", "identicalPrecedences", ")", "\n", "}", "\n", "}" ]
6,661
all-6662
[ "WritePackage", "writes", "to", "buf", "a", "human", "-", "readable", "summary", "of", "p", "." ]
[ "func", "WritePackage", "(", "buf", "*", "bytes", ".", "Buffer", ",", "p", "*", "Package", ")", "{", "fmt", ".", "Fprintf", "(", "buf", ",", "\"", "\\n", "\"", ",", "p", ")", "\n\n", "var", "names", "[", "]", "string", "\n", "maxname", ":=", "0", "\n", "for", "name", ":=", "range", "p", ".", "Members", "{", "if", "l", ":=", "len", "(", "name", ")", ";", "l", ">", "maxname", "{", "maxname", "=", "l", "\n", "}", "\n", "names", "=", "append", "(", "names", ",", "name", ")", "\n", "}", "\n\n", "from", ":=", "p", ".", "Pkg", "\n", "sort", ".", "Strings", "(", "names", ")", "\n", "for", "_", ",", "name", ":=", "range", "names", "{", "switch", "mem", ":=", "p", ".", "Members", "[", "name", "]", ".", "(", "type", ")", "{", "case", "*", "NamedConst", ":", "fmt", ".", "Fprintf", "(", "buf", ",", "\"", "\\n", "\"", ",", "maxname", ",", "name", ",", "mem", ".", "Name", "(", ")", ",", "mem", ".", "Value", ".", "RelString", "(", "from", ")", ")", "\n\n", "<mask>", "*", "Function", ":", "fmt", ".", "Fprintf", "(", "buf", ",", "\"", "\\n", "\"", ",", "maxname", ",", "name", ",", "relType", "(", "mem", ".", "Type", "(", ")", ",", "from", ")", ")", "\n\n", "case", "*", "Type", ":", "fmt", ".", "Fprintf", "(", "buf", ",", "\"", "\\n", "\"", ",", "maxname", ",", "name", ",", "relType", "(", "mem", ".", "Type", "(", ")", ".", "Underlying", "(", ")", ",", "from", ")", ")", "\n", "for", "_", ",", "meth", ":=", "range", "typeutil", ".", "IntuitiveMethodSet", "(", "mem", ".", "Type", "(", ")", ",", "&", "p", ".", "Prog", ".", "MethodSets", ")", "{", "fmt", ".", "Fprintf", "(", "buf", ",", "\"", "\\n", "\"", ",", "types", ".", "SelectionString", "(", "meth", ",", "types", ".", "RelativeTo", "(", "from", ")", ")", ")", "\n", "}", "\n\n", "case", "*", "Global", ":", "fmt", ".", "Fprintf", "(", "buf", ",", "\"", "\\n", "\"", ",", "maxname", ",", "name", ",", "relType", "(", "mem", ".", "Type", "(", ")", ".", "(", "*", "types", ".", "Pointer", ")", ".", "Elem", "(", ")", ",", "from", ")", ")", "\n", "}", "\n", "}", "\n\n", "fmt", ".", "Fprintf", "(", "buf", ",", "\"", "\\n", "\"", ")", "\n", "}" ]
6,662
all-6663
[ "Printf", "implements", "zk", ".", "Logger", "." ]
[ "func", "(", "zl", "ZookeeperLogger", ")", "Printf", "(", "s", "string", ",", "i", "...", "interface", "{", "}", ")", "{", "level", ".", "Info", "(", "zl", ".", "logger", ")", ".", "<mask>", "(", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "s", ",", "i", "...", ")", ")", "\n", "}" ]
6,663
all-6664
[ "Relocate", "produces", "a", "VirtualMachineRelocateSpecDiskLocator", "for", "this", "resource", "and", "is", "used", "for", "both", "cloning", "and", "storage", "vMotion", "." ]
[ "func", "(", "r", "*", "DiskSubresource", ")", "Relocate", "(", "l", "object", ".", "VirtualDeviceList", ",", "clone", "bool", ")", "(", "types", ".", "VirtualMachineRelocateSpecDiskLocator", ",", "error", ")", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "r", ")", "\n", "disk", ",", "err", ":=", "r", ".", "findVirtualDisk", "(", "l", ",", "clone", ")", "\n", "var", "relocate", "types", ".", "VirtualMachineRelocateSpecDiskLocator", "\n", "if", "err", "!=", "nil", "{", "return", "relocate", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "// Expand all of the necessary disk settings first. This ensures all backing", "// data is properly populate and updated.", "if", "err", ":=", "r", ".", "expandDiskSettings", "(", "disk", ")", ";", "err", "!=", "nil", "{", "return", "relocate", ",", "err", "\n", "}", "\n\n", "relocate", ".", "DiskId", "=", "disk", ".", "Key", "\n\n", "// Set the datastore for the relocation", "dsID", ":=", "r", ".", "Get", "(", "\"", "\"", ")", ".", "(", "string", ")", "\n", "if", "dsID", "==", "\"", "\"", "{", "// Default to the default datastore", "dsID", "=", "r", ".", "rdd", ".", "Get", "(", "\"", "\"", ")", ".", "(", "string", ")", "\n", "}", "\n", "ds", ",", "err", ":=", "datastore", ".", "FromID", "(", "r", ".", "client", ",", "dsID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "relocate", ",", "err", "\n", "}", "\n", "dsref", ":=", "ds", ".", "Reference", "(", ")", "\n", "relocate", ".", "Datastore", "=", "dsref", "\n\n", "// Add additional backing options if we are cloning.", "if", "r", ".", "rdd", ".", "Id", "(", ")", "==", "\"", "\"", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "r", ")", "\n\n", "backing", ":=", "disk", ".", "Backing", ".", "(", "*", "<mask>", ".", "VirtualDiskFlatVer2BackingInfo", ")", "\n", "backing", ".", "FileName", "=", "ds", ".", "Path", "(", "\"", "\"", ")", "\n", "backing", ".", "Datastore", "=", "&", "dsref", "\n", "relocate", ".", "DiskBackingInfo", "=", "backing", "\n", "}", "\n\n", "// Done!", "log", ".", "Printf", "(", "\"", "\"", ",", "r", ",", "diskRelocateString", "(", "relocate", ")", ")", "\n", "log", ".", "Printf", "(", "\"", "\"", ",", "r", ")", "\n", "return", "relocate", ",", "nil", "\n", "}" ]
6,664
all-6665
[ "SetStringPtr", "sets", "a", "ResourceData", "field", "depending", "on", "if", "a", "*", "string", "exists", "or", "not", ".", "The", "field", "is", "not", "set", "if", "it", "s", "nil", "." ]
[ "func", "SetStringPtr", "(", "d", "*", "schema", ".", "ResourceData", ",", "key", "string", ",", "val", "*", "string", ")", "error", "{", "if", "val", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "err", ":=", "d", ".", "<mask>", "(", "key", ",", "val", ")", "\n", "return", "err", "\n", "}" ]
6,665
all-6666
[ "title", ":", "webhook", "create", "path", ":", "/", "events", "/", "webhooks", "method", ":", "POST", "responses", ":", "200", ":", "Webhook", "created", "401", ":", "Unauthorized", "400", ":", "Invalid", "webhook", "409", ":", "Webhook", "already", "exists" ]
[ "func", "webhookCreate", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "t", "auth", ".", "Token", ")", "error", "{", "var", "webhook", "eventTypes", ".", "Webhook", "\n", "err", ":=", "ParseInput", "(", "r", ",", "&", "webhook", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "webhook", ".", "TeamOwner", "==", "\"", "\"", "{", "webhook", ".", "TeamOwner", ",", "err", "=", "autoTeamOwner", "(", "t", ",", "permission", ".", "PermWebhookCreate", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "ctx", ":=", "permission", ".", "Context", "(", "permTypes", ".", "CtxTeam", ",", "webhook", ".", "TeamOwner", ")", "\n", "if", "!", "permission", ".", "Check", "(", "t", ",", "permission", ".", "PermWebhookCreate", ",", "ctx", ")", "{", "return", "permission", ".", "ErrUnauthorized", "\n", "}", "\n", "evt", ",", "err", ":=", "event", ".", "New", "(", "&", "event", ".", "Opts", "{", "Target", ":", "event", ".", "Target", "{", "Type", ":", "<mask>", ".", "TargetTypeWebhook", ",", "Value", ":", "webhook", ".", "Name", "}", ",", "Kind", ":", "permission", ".", "PermWebhookCreate", ",", "Owner", ":", "t", ",", "CustomData", ":", "event", ".", "FormToCustomData", "(", "InputFields", "(", "r", ")", ")", ",", "Allowed", ":", "event", ".", "Allowed", "(", "permission", ".", "PermWebhookReadEvents", ",", "ctx", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "func", "(", ")", "{", "evt", ".", "Done", "(", "err", ")", "\n", "}", "(", ")", "\n", "err", "=", "servicemanager", ".", "Webhook", ".", "Create", "(", "webhook", ")", "\n", "if", "err", "==", "eventTypes", ".", "ErrWebhookAlreadyExists", "{", "w", ".", "WriteHeader", "(", "http", ".", "StatusConflict", ")", "\n", "}", "\n", "return", "err", "\n", "}" ]
6,666
all-6667
[ "render", "indexed", "primitives", "from", "array", "data", "taking", "parameters", "from", "memory" ]
[ "func", "DrawElementsIndirect", "(", "mode", "uint32", ",", "xtype", "uint32", ",", "indirect", "unsafe", ".", "Pointer", ")", "{", "syscall", ".", "Syscall", "(", "gpDrawElementsIndirect", ",", "3", ",", "uintptr", "(", "<mask>", ")", ",", "uintptr", "(", "xtype", ")", ",", "uintptr", "(", "indirect", ")", ")", "\n", "}" ]
6,667
all-6668
[ "ReadJSON", "deserializes", "JSON", "from", "the", "underlying", "reader", "into", "data", "." ]
[ "func", "(", "r", "ArgReadHelper", ")", "ReadJSON", "(", "data", "<mask>", "{", "}", ")", "error", "{", "return", "r", ".", "read", "(", "func", "(", ")", "error", "{", "// TChannel allows for 0 length values (not valid JSON), so we use a bufio.Reader", "// to check whether data is of 0 length.", "reader", ":=", "bufio", ".", "NewReader", "(", "r", ".", "reader", ")", "\n", "if", "_", ",", "err", ":=", "reader", ".", "Peek", "(", "1", ")", ";", "err", "==", "io", ".", "EOF", "{", "// If the data is 0 length, then we don't try to read anything.", "return", "nil", "\n", "}", "else", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "d", ":=", "json", ".", "NewDecoder", "(", "reader", ")", "\n", "return", "d", ".", "Decode", "(", "data", ")", "\n", "}", ")", "\n", "}" ]
6,668
all-6669
[ "ReadHeader", "simply", "wraps", "csv", ".", "Reader", ".", "Read", "()", "." ]
[ "func", "(", "r", "*", "Reader", ")", "ReadHeader", "(", ")", "(", "columns", "[", "]", "<mask>", ",", "err", "error", ")", "{", "return", "r", ".", "Reader", ".", "Read", "(", ")", "\n", "}" ]
6,669
all-6670
[ "MarshalJSON", "implements", "json", ".", "Marshaler", ".", "It", "will", "encode", "the", "zero", "value", "of", "time", ".", "Time", "if", "this", "time", "is", "invalid", "." ]
[ "func", "(", "t", "Time", ")", "MarshalJSON", "(", ")", "(", "[", "]", "<mask>", ",", "error", ")", "{", "if", "!", "t", ".", "Valid", "{", "return", "(", "time", ".", "Time", "{", "}", ")", ".", "MarshalJSON", "(", ")", "\n", "}", "\n", "return", "t", ".", "Time", ".", "MarshalJSON", "(", ")", "\n", "}" ]
6,670
all-6671
[ "balnic_path", "returns", "the", "string", "/", "loadbalancers", "/", "<lbalid", ">", "/", "balancednics<balnicid", ">" ]
[ "func", "balnicPath", "(", "dcid", ",", "lbalid", ",", "balnicid", "string", ")", "<mask>", "{", "return", "balnicColPath", "(", "dcid", ",", "lbalid", ")", "+", "slash", "(", "balnicid", ")", "\n", "}" ]
6,671
all-6672
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "EmulateNetworkConditionsParams", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "<mask>", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoNetwork58", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
6,672
all-6673
[ "MapValues", "returns", "the", "list", "of", "values", "in", "the", "map", "sorted", "by", "key", "." ]
[ "func", "(", "s", "*", "Scratch", ")", "MapValues", "(", "k", "string", ")", "(", "[", "]", "interface", "{", "}", ",", "error", ")", "{", "s", ".", "init", "(", ")", "\n\n", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n", "if", "s", ".", "values", "==", "nil", "{", "return", "nil", ",", "nil", "\n", "}", "\n\n", "typed", ",", "ok", ":=", "s", ".", "values", "[", "k", "]", ".", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "nil", "\n", "}", "\n\n", "keys", ":=", "<mask>", "(", "[", "]", "string", ",", "0", ",", "len", "(", "typed", ")", ")", "\n", "for", "k", ":=", "range", "typed", "{", "keys", "=", "append", "(", "keys", ",", "k", ")", "\n", "}", "\n", "sort", ".", "Strings", "(", "keys", ")", "\n\n", "sorted", ":=", "make", "(", "[", "]", "interface", "{", "}", ",", "len", "(", "keys", ")", ")", "\n", "for", "i", ",", "k", ":=", "range", "keys", "{", "sorted", "[", "i", "]", "=", "typed", "[", "k", "]", "\n", "}", "\n", "return", "sorted", ",", "nil", "\n", "}" ]
6,673
all-6674
[ "GetNotifyNoData", "returns", "the", "NotifyNoData", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "o", "*", "Options", ")", "GetNotifyNoData", "(", ")", "bool", "{", "if", "o", "==", "nil", "||", "o", ".", "NotifyNoData", "==", "nil", "{", "return", "<mask>", "\n", "}", "\n", "return", "*", "o", ".", "NotifyNoData", "\n", "}" ]
6,674
all-6675
[ "listDatum", "contains", "our", "internal", "implementation", "of", "ListDatum", "which", "is", "shared", "between", "ListDatum", "and", "ListDatumStream", ".", "When", "ListDatum", "is", "removed", "this", "should", "be", "inlined", "into", "ListDatumStream" ]
[ "func", "(", "a", "*", "apiServer", ")", "listDatum", "(", "pachClient", "*", "client", ".", "APIClient", ",", "job", "*", "pps", ".", "Job", ",", "page", ",", "pageSize", "int64", ")", "(", "response", "*", "pps", ".", "ListDatumResponse", ",", "retErr", "error", ")", "{", "if", "err", ":=", "checkLoggedIn", "(", "pachClient", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "response", "=", "&", "pps", ".", "ListDatumResponse", "{", "}", "\n", "ctx", ":=", "pachClient", ".", "Ctx", "(", ")", "\n", "pfsClient", ":=", "pachClient", ".", "PfsAPIClient", "\n\n", "// get information about 'job'", "jobInfo", ",", "err", ":=", "a", ".", "InspectJob", "(", "ctx", ",", "&", "pps", ".", "InspectJobRequest", "{", "Job", ":", "&", "pps", ".", "Job", "{", "ID", ":", "job", ".", "ID", ",", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// authorize ListDatum (must have READER access to all inputs)", "if", "err", ":=", "a", ".", "authorizePipelineOp", "(", "pachClient", ",", "pipelineOpListDatum", ",", "jobInfo", ".", "Input", ",", "jobInfo", ".", "Pipeline", ".", "<mask>", ",", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// helper functions for pagination", "getTotalPages", ":=", "func", "(", "totalSize", "int", ")", "int64", "{", "return", "(", "int64", "(", "totalSize", ")", "+", "pageSize", "-", "1", ")", "/", "pageSize", "// == ceil(totalSize/pageSize)", "\n", "}", "\n", "getPageBounds", ":=", "func", "(", "totalSize", "int", ")", "(", "int", ",", "int", ",", "error", ")", "{", "start", ":=", "int", "(", "page", "*", "pageSize", ")", "\n", "end", ":=", "int", "(", "(", "page", "+", "1", ")", "*", "pageSize", ")", "\n", "switch", "{", "case", "totalSize", "<=", "start", ":", "return", "0", ",", "0", ",", "io", ".", "EOF", "\n", "case", "totalSize", "<=", "end", ":", "return", "start", ",", "totalSize", ",", "nil", "\n", "case", "end", "<", "totalSize", ":", "return", "start", ",", "end", ",", "nil", "\n", "}", "\n", "return", "0", ",", "0", ",", "goerr", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "df", ",", "err", ":=", "workerpkg", ".", "NewDatumFactory", "(", "pachClient", ",", "jobInfo", ".", "Input", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "// If there's no stats commit (job not finished), compute datums using jobInfo", "if", "jobInfo", ".", "StatsCommit", "==", "nil", "{", "start", ":=", "0", "\n", "end", ":=", "df", ".", "Len", "(", ")", "\n", "if", "pageSize", ">", "0", "{", "var", "err", "error", "\n", "start", ",", "end", ",", "err", "=", "getPageBounds", "(", "df", ".", "Len", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "response", ".", "Page", "=", "page", "\n", "response", ".", "TotalPages", "=", "getTotalPages", "(", "df", ".", "Len", "(", ")", ")", "\n", "}", "\n", "var", "datumInfos", "[", "]", "*", "pps", ".", "DatumInfo", "\n", "for", "i", ":=", "start", ";", "i", "<", "end", ";", "i", "++", "{", "datum", ":=", "df", ".", "Datum", "(", "i", ")", "// flattened slice of *worker.Input to job", "\n", "id", ":=", "workerpkg", ".", "HashDatum", "(", "jobInfo", ".", "Pipeline", ".", "Name", ",", "jobInfo", ".", "Salt", ",", "datum", ")", "\n", "datumInfo", ":=", "&", "pps", ".", "DatumInfo", "{", "Datum", ":", "&", "pps", ".", "Datum", "{", "ID", ":", "id", ",", "Job", ":", "jobInfo", ".", "Job", ",", "}", ",", "State", ":", "pps", ".", "DatumState_STARTING", ",", "}", "\n", "for", "_", ",", "input", ":=", "range", "datum", "{", "datumInfo", ".", "Data", "=", "append", "(", "datumInfo", ".", "Data", ",", "input", ".", "FileInfo", ")", "\n", "}", "\n", "datumInfos", "=", "append", "(", "datumInfos", ",", "datumInfo", ")", "\n", "}", "\n", "response", ".", "DatumInfos", "=", "datumInfos", "\n", "return", "response", ",", "nil", "\n", "}", "\n\n", "// There is a stats commit -- job is finished", "// List the files under / in the stats branch to get all the datums", "file", ":=", "&", "pfs", ".", "File", "{", "Commit", ":", "jobInfo", ".", "StatsCommit", ",", "Path", ":", "\"", "\"", ",", "}", "\n\n", "var", "datumFileInfos", "[", "]", "*", "pfs", ".", "FileInfo", "\n", "fs", ",", "err", ":=", "pfsClient", ".", "ListFileStream", "(", "ctx", ",", "&", "pfs", ".", "ListFileRequest", "{", "File", ":", "file", ",", "Full", ":", "true", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}", "\n", "// Omit files at the top level that correspond to aggregate job stats", "blacklist", ":=", "map", "[", "string", "]", "bool", "{", "\"", "\"", ":", "true", ",", "\"", "\"", ":", "true", ",", "\"", "\"", ":", "true", ",", "}", "\n", "pathToDatumHash", ":=", "func", "(", "path", "string", ")", "(", "string", ",", "error", ")", "{", "_", ",", "datumHash", ":=", "filepath", ".", "Split", "(", "path", ")", "\n", "if", "_", ",", "ok", ":=", "blacklist", "[", "datumHash", "]", ";", "ok", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "datumHash", ")", "\n", "}", "\n", "return", "datumHash", ",", "nil", "\n", "}", "\n", "for", "{", "f", ",", "err", ":=", "fs", ".", "Recv", "(", ")", "\n", "if", "err", "==", "io", ".", "EOF", "{", "break", "\n", "}", "else", "if", "err", "!=", "nil", "{", "return", "nil", ",", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}", "\n", "if", "_", ",", "err", ":=", "pathToDatumHash", "(", "f", ".", "File", ".", "Path", ")", ";", "err", "!=", "nil", "{", "// not a datum", "continue", "\n", "}", "\n", "datumFileInfos", "=", "append", "(", "datumFileInfos", ",", "f", ")", "\n", "}", "\n", "var", "egGetDatums", "errgroup", ".", "Group", "\n", "limiter", ":=", "limit", ".", "New", "(", "200", ")", "\n", "datumInfos", ":=", "make", "(", "[", "]", "*", "pps", ".", "DatumInfo", ",", "len", "(", "datumFileInfos", ")", ")", "\n", "for", "index", ",", "fileInfo", ":=", "range", "datumFileInfos", "{", "fileInfo", ":=", "fileInfo", "\n", "index", ":=", "index", "\n", "egGetDatums", ".", "Go", "(", "func", "(", ")", "error", "{", "limiter", ".", "Acquire", "(", ")", "\n", "defer", "limiter", ".", "Release", "(", ")", "\n", "datumHash", ",", "err", ":=", "pathToDatumHash", "(", "fileInfo", ".", "File", ".", "Path", ")", "\n", "if", "err", "!=", "nil", "{", "// not a datum", "return", "nil", "\n", "}", "\n", "datum", ",", "err", ":=", "a", ".", "getDatum", "(", "pachClient", ",", "jobInfo", ".", "StatsCommit", ".", "Repo", ".", "Name", ",", "jobInfo", ".", "StatsCommit", ",", "job", ".", "ID", ",", "datumHash", ",", "df", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "datumInfos", "[", "index", "]", "=", "datum", "\n", "return", "nil", "\n", "}", ")", "\n", "}", "\n", "if", "err", "=", "egGetDatums", ".", "Wait", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "// Sort results (failed first)", "sort", ".", "Slice", "(", "datumInfos", ",", "func", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "datumInfos", "[", "i", "]", ".", "State", "<", "datumInfos", "[", "j", "]", ".", "State", "\n", "}", ")", "\n", "if", "pageSize", ">", "0", "{", "response", ".", "Page", "=", "page", "\n", "response", ".", "TotalPages", "=", "getTotalPages", "(", "len", "(", "datumInfos", ")", ")", "\n", "start", ",", "end", ",", "err", ":=", "getPageBounds", "(", "len", "(", "datumInfos", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "datumInfos", "=", "datumInfos", "[", "start", ":", "end", "]", "\n", "}", "\n", "response", ".", "DatumInfos", "=", "datumInfos", "\n", "return", "response", ",", "nil", "\n", "}" ]
6,675
all-6676
[ "Entomb", "sets", "the", "tomb", "bit", "on", "a", "relayItem", "and", "schedules", "a", "garbage", "collection", ".", "It", "returns", "the", "entombed", "item", "along", "with", "a", "bool", "indicating", "whether", "we", "completed", "a", "relayed", "call", "." ]
[ "func", "(", "r", "*", "relayItems", ")", "Entomb", "(", "id", "uint32", ",", "deleteAfter", "time", ".", "Duration", ")", "(", "relayItem", ",", "bool", ")", "{", "r", ".", "Lock", "(", ")", "\n", "if", "r", ".", "tombs", ">", "_maxRelayTombs", "{", "r", ".", "Unlock", "(", ")", "\n", "r", ".", "logger", ".", "WithFields", "(", "LogField", "{", "\"", "\"", ",", "id", "}", ")", ".", "Warn", "(", "\"", "\"", ")", "\n", "return", "r", ".", "Delete", "(", "id", ")", "\n", "}", "\n", "item", ",", "<mask>", ":=", "r", ".", "items", "[", "id", "]", "\n", "if", "!", "ok", "{", "r", ".", "Unlock", "(", ")", "\n", "r", ".", "logger", ".", "WithFields", "(", "LogField", "{", "\"", "\"", ",", "id", "}", ")", ".", "Warn", "(", "\"", "\"", ")", "\n", "return", "item", ",", "false", "\n", "}", "\n", "if", "item", ".", "tomb", "{", "r", ".", "Unlock", "(", ")", "\n", "r", ".", "logger", ".", "WithFields", "(", "LogField", "{", "\"", "\"", ",", "id", "}", ")", ".", "Warn", "(", "\"", "\"", ")", "\n", "return", "item", ",", "false", "\n", "}", "\n", "r", ".", "tombs", "++", "\n", "item", ".", "tomb", "=", "true", "\n", "r", ".", "items", "[", "id", "]", "=", "item", "\n", "r", ".", "Unlock", "(", ")", "\n\n", "// TODO: We should be clearing these out in batches, rather than creating", "// individual timers for each item.", "time", ".", "AfterFunc", "(", "deleteAfter", ",", "func", "(", ")", "{", "r", ".", "Delete", "(", "id", ")", "}", ")", "\n", "return", "item", ",", "true", "\n", "}" ]
6,676
all-6677
[ "instruct", "the", "GL", "server", "to", "block", "until", "the", "specified", "sync", "object", "becomes", "signaled" ]
[ "func", "WaitSync", "(", "<mask>", "uintptr", ",", "flags", "uint32", ",", "timeout", "uint64", ")", "{", "syscall", ".", "Syscall", "(", "gpWaitSync", ",", "3", ",", "uintptr", "(", "sync", ")", ",", "uintptr", "(", "flags", ")", ",", "uintptr", "(", "timeout", ")", ")", "\n", "}" ]
6,677
all-6678
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "CloseParams", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoPage75", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "<mask>", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
6,678
all-6679
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "GetIsolateIDParams", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoRuntime24", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "<mask>", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
6,679
all-6680
[ "subresourceSchema", "is", "a", "map", "[", "string", "]", "*", "schema", ".", "Schema", "of", "common", "schema", "fields", ".", "This", "includes", "the", "internal_id", "field", "which", "is", "used", "as", "a", "unique", "ID", "for", "the", "lifecycle", "of", "this", "resource", "." ]
[ "func", "subresourceSchema", "(", ")", "map", "[", "string", "]", "*", "schema", ".", "Schema", "{", "return", "map", "[", "string", "]", "*", "schema", ".", "Schema", "{", "\"", "\"", ":", "{", "Type", ":", "schema", ".", "TypeInt", ",", "Computed", ":", "true", ",", "Description", ":", "\"", "\"", ",", "}", ",", "\"", "\"", ":", "{", "<mask>", ":", "schema", ".", "TypeString", ",", "Computed", ":", "true", ",", "Description", ":", "\"", "\"", ",", "}", ",", "}", "\n", "}" ]
6,680
all-6681
[ "executeTemplateFunc", "executes", "the", "given", "template", "in", "the", "context", "of", "the", "parent", ".", "If", "an", "argument", "is", "specified", "it", "will", "be", "used", "as", "the", "context", "instead", ".", "This", "can", "be", "used", "for", "nested", "template", "definitions", "." ]
[ "func", "executeTemplateFunc", "(", "t", "*", "template", ".", "Template", ")", "func", "(", "string", ",", "...", "interface", "{", "}", ")", "(", "string", ",", "error", ")", "{", "return", "func", "(", "s", "string", ",", "data", "...", "interface", "{", "}", ")", "(", "string", ",", "error", ")", "{", "var", "dot", "interface", "{", "}", "\n", "switch", "len", "(", "<mask>", ")", "{", "case", "0", ":", "dot", "=", "nil", "\n", "case", "1", ":", "dot", "=", "data", "[", "0", "]", "\n", "default", ":", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", "+", "\"", "\"", ",", "len", "(", "data", ")", "+", "1", ")", "\n", "}", "\n", "var", "b", "bytes", ".", "Buffer", "\n", "if", "err", ":=", "t", ".", "ExecuteTemplate", "(", "&", "b", ",", "s", ",", "dot", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "return", "b", ".", "String", "(", ")", ",", "nil", "\n", "}", "\n", "}" ]
6,681
all-6682
[ "DerivePublicKeyForPath", "derives", "the", "public", "key", "by", "following", "the", "path", "from", "pubKeyBytes", "using", "the", "given", "chainCode", "." ]
[ "func", "DerivePublicKeyForPath", "(", "pubKeyBytes", "[", "]", "byte", ",", "chainCode", "[", "]", "byte", ",", "path", "string", ")", "[", "]", "byte", "{", "data", ":=", "pubKeyBytes", "\n", "parts", ":=", "strings", ".", "Split", "(", "path", ",", "\"", "\"", ")", "\n", "for", "_", ",", "part", ":=", "range", "<mask>", "{", "prime", ":=", "part", "[", "len", "(", "part", ")", "-", "1", ":", "]", "==", "\"", "\"", "\n", "if", "prime", "{", "panic", "(", "errors", ".", "New", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "i", ",", "err", ":=", "strconv", ".", "Atoi", "(", "part", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "if", "i", "<", "0", "{", "panic", "(", "errors", ".", "New", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "data", ",", "chainCode", "=", "DerivePublicKey", "(", "data", ",", "chainCode", ",", "uint32", "(", "i", ")", ")", "\n", "//printKeyInfo(nil, data, chainCode)", "}", "\n", "return", "data", "\n", "}" ]
6,682
all-6683
[ "RenameImageAlias", "renames", "an", "existing", "image", "alias" ]
[ "func", "(", "r", "*", "ProtocolLXD", ")", "RenameImageAlias", "(", "name", "string", ",", "alias", "api", ".", "ImageAliasesEntryPost", ")", "error", "{", "// Send the request", "_", ",", "_", ",", "err", ":=", "r", ".", "query", "(", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "url", ".", "QueryEscape", "(", "<mask>", ")", ")", ",", "alias", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
6,683
all-6684
[ "newAssignees", "creates", "a", "new", "Label", "for", "each", "label", "in", "the", "issue" ]
[ "func", "newAssignees", "(", "issueID", "int", ",", "gAssignees", "[", "]", "*", "github", ".", "User", ",", "repository", "string", ")", "(", "[", "]", "sql", ".", "Assignee", ",", "error", ")", "{", "assignees", ":=", "[", "]", "sql", ".", "Assignee", "{", "}", "\n", "repository", "=", "strings", ".", "ToLower", "(", "repository", ")", "\n\n", "for", "_", ",", "assignee", ":=", "range", "gAssignees", "{", "if", "assignee", "!=", "nil", "&&", "assignee", ".", "Login", "==", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "assignees", "=", "<mask>", "(", "assignees", ",", "sql", ".", "Assignee", "{", "IssueID", ":", "strconv", ".", "Itoa", "(", "issueID", ")", ",", "Name", ":", "*", "assignee", ".", "Login", ",", "Repository", ":", "repository", ",", "}", ")", "\n", "}", "\n\n", "return", "assignees", ",", "nil", "\n", "}" ]
6,684
all-6685
[ "NthDataWrapped", "acts", "the", "same", "as", "g_list_nth_data", "()", "but", "passes", "retrieved", "value", "before", "returning", "through", "wrap", "function", "set", "by", "DataWrapper", "()", ".", "If", "no", "wrap", "function", "is", "set", "it", "returns", "raw", "unsafe", ".", "Pointer", "." ]
[ "func", "(", "v", "*", "<mask>", ")", "NthData", "(", "n", "uint", ")", "interface", "{", "}", "{", "ptr", ":=", "v", ".", "nthDataRaw", "(", "n", ")", "\n", "if", "v", ".", "dataWrap", "!=", "nil", "{", "return", "v", ".", "dataWrap", "(", "ptr", ")", "\n", "}", "\n", "return", "ptr", "\n", "}" ]
6,685
all-6686
[ "Write", "serializes", "the", "command", "to", "the", "given", "buffered", "output", "satisfies", "the", "Command", "interface", "." ]
[ "func", "(", "c", "MPub", ")", "Write", "(", "w", "*", "bufio", ".", "Writer", ")", "(", "err", "error", ")", "{", "for", "_", ",", "s", ":=", "range", "[", "...", "]", "string", "{", "\"", "\"", ",", "c", ".", "Topic", ",", "\"", "\\n", "\"", ",", "}", "{", "if", "_", ",", "err", "=", "w", ".", "WriteString", "(", "s", ")", ";", "err", "!=", "nil", "{", "err", "=", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "return", "\n", "}", "\n", "}", "\n\n", "var", "size", "uint32", "\n\n", "for", "_", ",", "m", ":=", "range", "c", ".", "Messages", "{", "size", "+=", "uint32", "(", "len", "(", "m", ")", ")", "\n", "}", "\n\n", "if", "err", "=", "binary", ".", "Write", "(", "w", ",", "binary", ".", "BigEndian", ",", "size", ")", ";", "err", "!=", "nil", "{", "err", "=", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "return", "\n", "}", "\n\n", "if", "err", "=", "binary", ".", "Write", "(", "w", ",", "<mask>", ".", "BigEndian", ",", "uint32", "(", "len", "(", "c", ".", "Messages", ")", ")", ")", ";", "err", "!=", "nil", "{", "err", "=", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "return", "\n", "}", "\n\n", "for", "_", ",", "m", ":=", "range", "c", ".", "Messages", "{", "if", "err", "=", "binary", ".", "Write", "(", "w", ",", "binary", ".", "BigEndian", ",", "uint32", "(", "len", "(", "m", ")", ")", ")", ";", "err", "!=", "nil", "{", "err", "=", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "return", "\n", "}", "\n\n", "if", "_", ",", "err", "=", "w", ".", "Write", "(", "m", ")", ";", "err", "!=", "nil", "{", "err", "=", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "return", "\n", "}", "\n", "}", "\n\n", "return", "\n", "}" ]
6,686
all-6687
[ "handle", "is", "the", "workhorse", "the", "will", "actually", "make", "updates", "to", "the", "PR", ".", "The", "algorithm", "goes", "as", ":", "-", "Initially", "we", "build", "an", "approverSet", "-", "Go", "through", "all", "comments", "in", "order", "of", "creation", ".", "-", "(", "Issue", "/", "PR", "comments", "PR", "review", "comments", "and", "PR", "review", "bodies", "are", "considered", "as", "comments", ")", "-", "If", "anyone", "said", "/", "approve", "add", "them", "to", "approverSet", ".", "-", "If", "anyone", "said", "/", "lgtm", "AND", "LgtmActsAsApprove", "is", "enabled", "add", "them", "to", "approverSet", ".", "-", "If", "anyone", "created", "an", "approved", "review", "AND", "ReviewActsAsApprove", "is", "enabled", "add", "them", "to", "approverSet", ".", "-", "Then", "for", "each", "file", "we", "see", "if", "any", "approver", "of", "this", "file", "is", "in", "approverSet", "and", "keep", "track", "of", "files", "without", "approval", "-", "An", "approver", "of", "a", "file", "is", "defined", "as", ":", "-", "Someone", "listed", "as", "an", "approver", "in", "an", "OWNERS", "file", "in", "the", "files", "directory", "OR", "-", "in", "one", "of", "the", "file", "s", "parent", "directories", "-", "Iff", "all", "files", "have", "been", "approved", "the", "bot", "will", "add", "the", "approved", "label", ".", "-", "Iff", "a", "cancel", "command", "is", "found", "that", "reviewer", "will", "be", "removed", "from", "the", "approverSet", "and", "the", "munger", "will", "remove", "the", "approved", "label", "if", "it", "has", "been", "applied" ]
[ "func", "handle", "(", "log", "*", "logrus", ".", "Entry", ",", "ghc", "githubClient", ",", "repo", "approvers", ".", "Repo", ",", "githubConfig", "config", ".", "GitHubOptions", ",", "opts", "*", "plugins", ".", "Approve", ",", "pr", "*", "state", ")", "error", "{", "fetchErr", ":=", "func", "(", "context", "string", ",", "err", "error", ")", "error", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "context", ",", "pr", ".", "org", ",", "pr", ".", "repo", ",", "pr", ".", "number", ",", "err", ")", "\n", "}", "\n\n", "changes", ",", "err", ":=", "ghc", ".", "GetPullRequestChanges", "(", "pr", ".", "org", ",", "pr", ".", "repo", ",", "pr", ".", "<mask>", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fetchErr", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "var", "filenames", "[", "]", "string", "\n", "for", "_", ",", "change", ":=", "range", "changes", "{", "filenames", "=", "append", "(", "filenames", ",", "change", ".", "Filename", ")", "\n", "}", "\n", "issueLabels", ",", "err", ":=", "ghc", ".", "GetIssueLabels", "(", "pr", ".", "org", ",", "pr", ".", "repo", ",", "pr", ".", "number", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fetchErr", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "hasApprovedLabel", ":=", "false", "\n", "for", "_", ",", "label", ":=", "range", "issueLabels", "{", "if", "label", ".", "Name", "==", "labels", ".", "Approved", "{", "hasApprovedLabel", "=", "true", "\n", "break", "\n", "}", "\n", "}", "\n", "botName", ",", "err", ":=", "ghc", ".", "BotName", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fetchErr", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "issueComments", ",", "err", ":=", "ghc", ".", "ListIssueComments", "(", "pr", ".", "org", ",", "pr", ".", "repo", ",", "pr", ".", "number", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fetchErr", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "reviewComments", ",", "err", ":=", "ghc", ".", "ListPullRequestComments", "(", "pr", ".", "org", ",", "pr", ".", "repo", ",", "pr", ".", "number", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fetchErr", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "reviews", ",", "err", ":=", "ghc", ".", "ListReviews", "(", "pr", ".", "org", ",", "pr", ".", "repo", ",", "pr", ".", "number", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fetchErr", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "approversHandler", ":=", "approvers", ".", "NewApprovers", "(", "approvers", ".", "NewOwners", "(", "log", ",", "filenames", ",", "repo", ",", "int64", "(", "pr", ".", "number", ")", ",", ")", ",", ")", "\n", "approversHandler", ".", "AssociatedIssue", ",", "err", "=", "findAssociatedIssue", "(", "pr", ".", "body", ",", "pr", ".", "org", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "WithError", "(", "err", ")", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "approversHandler", ".", "RequireIssue", "=", "opts", ".", "IssueRequired", "\n", "approversHandler", ".", "ManuallyApproved", "=", "humanAddedApproved", "(", "ghc", ",", "log", ",", "pr", ".", "org", ",", "pr", ".", "repo", ",", "pr", ".", "number", ",", "botName", ",", "hasApprovedLabel", ")", "\n\n", "// Author implicitly approves their own PR if config allows it", "if", "opts", ".", "HasSelfApproval", "(", ")", "{", "approversHandler", ".", "AddAuthorSelfApprover", "(", "pr", ".", "author", ",", "pr", ".", "htmlURL", "+", "\"", "\"", ",", "false", ")", "\n", "}", "else", "{", "// Treat the author as an assignee, and suggest them if possible", "approversHandler", ".", "AddAssignees", "(", "pr", ".", "author", ")", "\n", "}", "\n\n", "commentsFromIssueComments", ":=", "commentsFromIssueComments", "(", "issueComments", ")", "\n", "comments", ":=", "append", "(", "commentsFromReviewComments", "(", "reviewComments", ")", ",", "commentsFromIssueComments", "...", ")", "\n", "comments", "=", "append", "(", "comments", ",", "commentsFromReviews", "(", "reviews", ")", "...", ")", "\n", "sort", ".", "SliceStable", "(", "comments", ",", "func", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "comments", "[", "i", "]", ".", "CreatedAt", ".", "Before", "(", "comments", "[", "j", "]", ".", "CreatedAt", ")", "\n", "}", ")", "\n", "approveComments", ":=", "filterComments", "(", "comments", ",", "approvalMatcher", "(", "botName", ",", "opts", ".", "LgtmActsAsApprove", ",", "opts", ".", "ConsiderReviewState", "(", ")", ")", ")", "\n", "addApprovers", "(", "&", "approversHandler", ",", "approveComments", ",", "pr", ".", "author", ",", "opts", ".", "ConsiderReviewState", "(", ")", ")", "\n\n", "for", "_", ",", "user", ":=", "range", "pr", ".", "assignees", "{", "approversHandler", ".", "AddAssignees", "(", "user", ".", "Login", ")", "\n", "}", "\n\n", "notifications", ":=", "filterComments", "(", "commentsFromIssueComments", ",", "notificationMatcher", "(", "botName", ")", ")", "\n", "latestNotification", ":=", "getLast", "(", "notifications", ")", "\n", "newMessage", ":=", "updateNotification", "(", "githubConfig", ".", "LinkURL", ",", "pr", ".", "org", ",", "pr", ".", "repo", ",", "pr", ".", "branch", ",", "latestNotification", ",", "approversHandler", ")", "\n", "if", "newMessage", "!=", "nil", "{", "for", "_", ",", "notif", ":=", "range", "notifications", "{", "if", "err", ":=", "ghc", ".", "DeleteComment", "(", "pr", ".", "org", ",", "pr", ".", "repo", ",", "notif", ".", "ID", ")", ";", "err", "!=", "nil", "{", "log", ".", "WithError", "(", "err", ")", ".", "Errorf", "(", "\"", "\"", ",", "pr", ".", "org", ",", "pr", ".", "repo", ",", "pr", ".", "number", ",", "notif", ".", "ID", ")", "\n", "}", "\n", "}", "\n", "if", "err", ":=", "ghc", ".", "CreateComment", "(", "pr", ".", "org", ",", "pr", ".", "repo", ",", "pr", ".", "number", ",", "*", "newMessage", ")", ";", "err", "!=", "nil", "{", "log", ".", "WithError", "(", "err", ")", ".", "Errorf", "(", "\"", "\"", ",", "pr", ".", "org", ",", "pr", ".", "repo", ",", "pr", ".", "number", ",", "*", "newMessage", ")", "\n", "}", "\n", "}", "\n\n", "if", "!", "approversHandler", ".", "IsApproved", "(", ")", "{", "if", "hasApprovedLabel", "{", "if", "err", ":=", "ghc", ".", "RemoveLabel", "(", "pr", ".", "org", ",", "pr", ".", "repo", ",", "pr", ".", "number", ",", "labels", ".", "Approved", ")", ";", "err", "!=", "nil", "{", "log", ".", "WithError", "(", "err", ")", ".", "Errorf", "(", "\"", "\"", ",", "labels", ".", "Approved", ",", "pr", ".", "org", ",", "pr", ".", "repo", ",", "pr", ".", "number", ")", "\n", "}", "\n", "}", "\n", "}", "else", "if", "!", "hasApprovedLabel", "{", "if", "err", ":=", "ghc", ".", "AddLabel", "(", "pr", ".", "org", ",", "pr", ".", "repo", ",", "pr", ".", "number", ",", "labels", ".", "Approved", ")", ";", "err", "!=", "nil", "{", "log", ".", "WithError", "(", "err", ")", ".", "Errorf", "(", "\"", "\"", ",", "labels", ".", "Approved", ",", "pr", ".", "org", ",", "pr", ".", "repo", ",", "pr", ".", "number", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
6,687
all-6688
[ "Substitute", "attemps", "to", "substitute", "the", "path", "pattern", "variables", "with", "the", "given", "values", ".", "-", "If", "the", "substitution", "succeeds", "it", "returns", "the", "resulting", "path", "and", "the", "list", "of", "variable", "names", "that", "were", "used", "to", "build", "it", ".", "-", "If", "the", "substitution", "fails", "it", "returns", "an", "empty", "string", "and", "the", "list", "of", "variable", "names", "that", "are", "missing", "from", "the", "list", "of", "given", "values", "." ]
[ "func", "(", "p", "*", "PathPattern", ")", "Substitute", "(", "vars", "[", "]", "*", "PathVariable", ")", "(", "string", ",", "[", "]", "string", ")", "{", "values", ":=", "make", "(", "[", "]", "interface", "{", "}", ",", "len", "(", "p", ".", "Variables", ")", ")", "\n", "var", "missing", "[", "]", "string", "\n", "var", "used", "[", "]", "string", "\n", "for", "i", ",", "n", ":=", "range", "p", ".", "Variables", "{", "for", "_", ",", "v", ":=", "<mask>", "vars", "{", "if", "v", ".", "Name", "==", "n", "{", "values", "[", "i", "]", "=", "v", ".", "Value", "\n", "used", "=", "append", "(", "used", ",", "n", ")", "\n", "break", "\n", "}", "\n", "}", "\n", "if", "values", "[", "i", "]", "==", "nil", "{", "missing", "=", "append", "(", "missing", ",", "n", ")", "\n", "}", "\n", "}", "\n", "if", "len", "(", "missing", ")", ">", "0", "{", "return", "\"", "\"", ",", "missing", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "p", ".", "Pattern", ",", "values", "...", ")", ",", "used", "\n", "}" ]
6,688
all-6689
[ "ListTeams", "return", "a", "list", "of", "fake", "teams", "that", "correspond", "to", "the", "fake", "team", "members", "returned", "by", "ListTeamMembers" ]
[ "func", "(", "f", "*", "FakeClient", ")", "ListTeams", "(", "org", "string", ")", "(", "[", "]", "github", ".", "Team", ",", "error", ")", "{", "return", "[", "]", "github", ".", "Team", "{", "{", "ID", ":", "0", ",", "Name", ":", "\"", "\"", ",", "}", ",", "{", "<mask>", ":", "42", ",", "Name", ":", "\"", "\"", ",", "}", ",", "}", ",", "nil", "\n", "}" ]
6,689
all-6690
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "EventTargetInfoChanged", ")", "UnmarshalJSON", "(", "<mask>", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoTarget13", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
6,690
all-6691
[ "newPrefixTree", "creates", "a", "new", "prefixTrie", "." ]
[ "func", "newPrefixTree", "(", "version", "rnet", ".", "IPVersion", ")", "Ranger", "{", "_", ",", "rootNet", ",", "_", ":=", "net", ".", "ParseCIDR", "(", "\"", "\"", ")", "\n", "if", "<mask>", "==", "rnet", ".", "IPv6", "{", "_", ",", "rootNet", ",", "_", "=", "net", ".", "ParseCIDR", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "&", "prefixTrie", "{", "children", ":", "make", "(", "[", "]", "*", "prefixTrie", ",", "2", ",", "2", ")", ",", "numBitsSkipped", ":", "0", ",", "numBitsHandled", ":", "1", ",", "network", ":", "rnet", ".", "NewNetwork", "(", "*", "rootNet", ")", ",", "}", "\n", "}" ]
6,691
all-6692
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "GetHeapObjectIDParams", ")", "UnmarshalJSON", "(", "<mask>", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoHeapprofiler14", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
6,692
all-6693
[ "StructFieldFromJSONName", "returns", "the", "struct", "field", "name", "on", "the", "given", "struct", "value", ".", "Empty", "value", "means", "the", "field", "is", "either", "not", "public", "or", "does", "not", "exist", ".", "This", "can", "be", "used", "to", "map", "JSON", "field", "names", "to", "actual", "struct", "fields", "." ]
[ "func", "StructFieldFromJSONName", "(", "v", "reflect", ".", "Value", ",", "name", "string", ")", "string", "{", "if", "v", ".", "Kind", "(", ")", "!=", "reflect", ".", "Struct", "{", "return", "\"", "\"", "\n", "}", "\n\n", "m", ":=", "getType2jfm", "(", "v", ".", "Type", "(", ")", ")", "\n", "m", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "s", ",", "ok", ":=", "m", ".", "fields", "[", "name", "]", "\n", "if", "!", "<mask>", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "s", "\n", "}" ]
6,693
all-6694
[ "Endpoints", "collects", "endpoints", "of", "all", "nested", "Sources", "and", "returns", "them", "in", "a", "single", "slice", "." ]
[ "func", "(", "ms", "*", "multiSource", ")", "Endpoints", "(", ")", "(", "[", "]", "*", "endpoint", ".", "Endpoint", ",", "error", ")", "{", "<mask>", ":=", "[", "]", "*", "endpoint", ".", "Endpoint", "{", "}", "\n\n", "for", "_", ",", "s", ":=", "range", "ms", ".", "children", "{", "endpoints", ",", "err", ":=", "s", ".", "Endpoints", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "result", "=", "append", "(", "result", ",", "endpoints", "...", ")", "\n", "}", "\n\n", "return", "result", ",", "nil", "\n", "}" ]
6,694
all-6695
[ "HasCreatedBy", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "s", "*", "SyntheticsTest", ")", "HasCreatedBy", "(", ")", "bool", "{", "if", "s", "!=", "nil", "&&", "s", ".", "CreatedBy", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "return", "<mask>", "\n", "}" ]
6,695
all-6696
[ "evalTimestamp", "returns", "the", "immediately", "preceding", "consistently", "slotted", "evaluation", "time", "." ]
[ "func", "(", "g", "*", "Group", ")", "evalTimestamp", "(", ")", "time", ".", "Time", "{", "var", "(", "offset", "=", "int64", "(", "g", ".", "hash", "(", ")", "%", "uint64", "(", "g", ".", "interval", ")", ")", "\n", "now", "=", "time", ".", "Now", "(", ")", ".", "UnixNano", "(", ")", "\n", "adjNow", "=", "<mask>", "-", "offset", "\n", "base", "=", "adjNow", "-", "(", "adjNow", "%", "int64", "(", "g", ".", "interval", ")", ")", "\n", ")", "\n\n", "return", "time", ".", "Unix", "(", "0", ",", "base", "+", "offset", ")", "\n", "}" ]
6,696
all-6697
[ "Field", "allows", "validation", "of", "a", "single", "field", "still", "using", "tag", "style", "validation", "to", "check", "multiple", "errors" ]
[ "func", "(", "v", "*", "Validate", ")", "Field", "(", "f", "<mask>", "{", "}", ",", "tag", "string", ")", "*", "FieldError", "{", "return", "v", ".", "FieldWithValue", "(", "nil", ",", "f", ",", "tag", ")", "\n", "}" ]
6,697
all-6698
[ "initializeResourceFields", "exists", "mainly", "for", "testing", "doStart", "()", "to", "use", "mock", "Control", "object" ]
[ "func", "(", "agent", "*", "ecsAgent", ")", "initializeResourceFields", "(", "credentialsManager", "credentials", ".", "Manager", ")", "{", "agent", ".", "resourceFields", "=", "&", "taskresource", ".", "ResourceFields", "{", "Control", ":", "cgroup", ".", "New", "(", ")", ",", "ResourceFieldsCommon", ":", "&", "taskresource", ".", "ResourceFieldsCommon", "{", "IOUtil", ":", "ioutilwrapper", ".", "NewIOUtil", "(", ")", ",", "ASMClientCreator", ":", "asmfactory", ".", "NewClientCreator", "(", ")", ",", "SSMClientCreator", ":", "ssmfactory", ".", "NewSSMClientCreator", "(", ")", ",", "CredentialsManager", ":", "credentialsManager", ",", "}", ",", "Ctx", ":", "agent", ".", "ctx", ",", "DockerClient", ":", "<mask>", ".", "dockerClient", ",", "NvidiaGPUManager", ":", "gpu", ".", "NewNvidiaGPUManager", "(", ")", ",", "}", "\n", "}" ]
6,698
all-6699
[ "TokenBlacklister", "returns", "a", "handler", "that", "will", "blacklist", "any", "token", "found", "in", "the", "request", ".", "Typically", "to", "be", "used", "around", "logout", "handlers", ".", "If", "handler", "h", "is", "nil", "upon", "successful", "blacklist", "200", "OK", "is", "returned", "." ]
[ "func", "TokenBlacklister", "(", "h", "http", ".", "Handler", ",", "store", "TokenStorage", ",", "secret", "[", "]", "byte", ",", "opts", "...", "TokenOpt", ")", "http", ".", "Handler", "{", "o", ":=", "options", "{", "logger", ":", "handler", ".", "NopLogger", "(", ")", ",", "claimer", ":", "func", "(", "c", "*", "jwt", ".", "StandardClaims", ")", "jwt", ".", "Claims", "{", "return", "c", "}", ",", "expiration", ":", "time", ".", "Hour", "*", "24", "*", "15", ",", "extractor", ":", "request", ".", "MultiExtractor", "{", "headerExtractor", "{", "}", ",", "request", ".", "ArgumentExtractor", "{", "\"", "\"", "}", "}", ",", "}", "\n\n", "o", ".", "apply", "(", "opts", ")", "\n\n", "return", "http", ".", "HandlerFunc", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "claims", ":=", "o", ".", "claimer", "(", "&", "jwt", ".", "StandardClaims", "{", "}", ")", "\n\n", "tokenStr", ",", "err", ":=", "o", ".", "extractor", ".", "ExtractToken", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "o", ".", "logger", ".", "Print", "(", "\"", "\"", ",", "err", ")", "\n\n", "http", ".", "Error", "(", "w", ",", "err", ".", "Error", "(", ")", ",", "http", ".", "StatusBadRequest", ")", "\n", "return", "\n", "}", "\n\n", "token", ",", "err", ":=", "jwt", ".", "ParseWithClaims", "(", "tokenStr", ",", "claims", ",", "func", "(", "token", "*", "jwt", ".", "Token", ")", "(", "<mask>", "{", "}", ",", "error", ")", "{", "if", "_", ",", "ok", ":=", "token", ".", "Method", ".", "(", "*", "jwt", ".", "SigningMethodHMAC", ")", ";", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "token", ".", "Header", "[", "\"", "\"", "]", ")", "\n", "}", "\n\n", "return", "secret", ",", "nil", "\n", "}", ")", "\n\n", "errCode", ":=", "http", ".", "StatusInternalServerError", "\n", "if", "ve", ",", "ok", ":=", "err", ".", "(", "*", "jwt", ".", "ValidationError", ")", ";", "ok", "{", "if", "ve", ".", "Errors", "&", "jwt", ".", "ValidationErrorExpired", "!=", "0", "{", "// No reason to store an expired token", "if", "h", "==", "nil", "{", "w", ".", "WriteHeader", "(", "http", ".", "StatusOK", ")", "\n", "}", "else", "{", "h", ".", "ServeHTTP", "(", "w", ",", "r", ")", "\n", "}", "\n\n", "return", "\n", "}", "else", "if", "ve", ".", "Errors", "&", "jwt", ".", "ValidationErrorNotValidYet", "!=", "0", "{", "err", "=", "nil", "\n", "}", "else", "{", "errCode", "=", "http", ".", "StatusBadRequest", "\n", "}", "\n", "}", "\n\n", "if", "err", "==", "nil", "{", "var", "expiration", "time", ".", "Time", "\n", "if", "v", ",", "ok", ":=", "token", ".", "Claims", ".", "(", "*", "jwt", ".", "StandardClaims", ")", ";", "ok", "{", "expiration", "=", "time", ".", "Unix", "(", "v", ".", "ExpiresAt", ",", "0", ")", "\n", "}", "else", "if", "v", ",", "ok", ":=", "token", ".", "Claims", ".", "(", "jwt", ".", "MapClaims", ")", ";", "ok", "{", "if", "exp", ",", "ok", ":=", "v", "[", "\"", "\"", "]", ".", "(", "int64", ")", ";", "ok", "{", "expiration", "=", "time", ".", "Unix", "(", "exp", ",", "0", ")", "\n", "}", "\n", "}", "\n\n", "if", "expiration", ".", "IsZero", "(", ")", "{", "expiration", "=", "time", ".", "Now", "(", ")", ".", "Add", "(", "o", ".", "expiration", ")", "\n", "}", "\n\n", "err", "=", "store", ".", "Store", "(", "tokenStr", ",", "expiration", ")", "\n", "}", "\n\n", "if", "err", "!=", "nil", "{", "o", ".", "logger", ".", "Print", "(", "\"", "\"", ",", "err", ")", "\n\n", "http", ".", "Error", "(", "w", ",", "err", ".", "Error", "(", ")", ",", "errCode", ")", "\n", "return", "\n", "}", "\n\n", "if", "h", "==", "nil", "{", "w", ".", "WriteHeader", "(", "http", ".", "StatusOK", ")", "\n", "}", "else", "{", "h", ".", "ServeHTTP", "(", "w", ",", "r", ")", "\n", "}", "\n", "}", ")", "\n", "}" ]
6,699
all-6700
[ "StatusString", "returns", "a", "human", "readable", "string", "representation", "of", "this", "object" ]
[ "func", "(", "<mask>", "SSMSecretStatus", ")", "String", "(", ")", "string", "{", "for", "k", ",", "v", ":=", "range", "ssmSecretStatusMap", "{", "if", "v", "==", "as", "{", "return", "k", "\n", "}", "\n", "}", "\n", "return", "\"", "\"", "\n", "}" ]