id
int32
0
25.3k
idx
stringlengths
5
9
nl_tokens
listlengths
1
418
pl_tokens
listlengths
22
4.98k
21,100
all-21101
[ "hostSystemNameFromID", "returns", "the", "name", "of", "a", "host", "via", "its", "its", "managed", "object", "reference", "ID", "." ]
[ "func", "hostSystemNameFromID", "(", "client", "*", "govmomi", ".", "Client", ",", "id", "string", ")", "(", "string", ",", "error", ")", "{", "hs", ",", "err", ":=", "FromID", "(", "client", ",", "id", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "return", "hs", ".", "<mask>", "(", ")", ",", "nil", "\n", "}" ]
21,101
all-21102
[ "Out", "returns", "the", "data", "to", "be", "sent", "to", "the", "server", "in", "the", "current", "step", "." ]
[ "func", "(", "c", "*", "Client", ")", "Out", "(", ")", "[", "]", "byte", "{", "if", "c", ".", "out", ".", "Len", "(", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "return", "c", ".", "<mask>", ".", "Bytes", "(", ")", "\n", "}" ]
21,102
all-21103
[ "Records", "gets", "the", "current", "records", ".", "Returns", "the", "current", "records", "or", "an", "error", "if", "the", "operation", "failed", "." ]
[ "func", "(", "p", "*", "AlibabaCloudProvider", ")", "Records", "(", ")", "(", "endpoints", "[", "]", "*", "endpoint", ".", "Endpoint", ",", "err", "error", ")", "{", "if", "p", ".", "privateZone", "{", "endpoints", ",", "<mask>", "=", "p", ".", "privateZoneRecords", "(", ")", "\n", "}", "else", "{", "endpoints", ",", "err", "=", "p", ".", "recordsForDNS", "(", ")", "\n", "}", "\n", "return", "endpoints", ",", "err", "\n", "}" ]
21,103
all-21104
[ "Draw", "draws", "the", "current", "game", "to", "the", "given", "screen", "." ]
[ "func", "(", "g", "*", "Game", ")", "Draw", "(", "screen", "*", "ebiten", ".", "Image", ")", "{", "if", "g", ".", "boardImage", "==", "nil", "{", "w", ",", "h", ":=", "g", ".", "<mask>", ".", "Size", "(", ")", "\n", "g", ".", "boardImage", ",", "_", "=", "ebiten", ".", "NewImage", "(", "w", ",", "h", ",", "ebiten", ".", "FilterDefault", ")", "\n", "}", "\n", "screen", ".", "Fill", "(", "backgroundColor", ")", "\n", "g", ".", "board", ".", "Draw", "(", "g", ".", "boardImage", ")", "\n", "op", ":=", "&", "ebiten", ".", "DrawImageOptions", "{", "}", "\n", "sw", ",", "sh", ":=", "screen", ".", "Size", "(", ")", "\n", "bw", ",", "bh", ":=", "g", ".", "boardImage", ".", "Size", "(", ")", "\n", "x", ":=", "(", "sw", "-", "bw", ")", "/", "2", "\n", "y", ":=", "(", "sh", "-", "bh", ")", "/", "2", "\n", "op", ".", "GeoM", ".", "Translate", "(", "float64", "(", "x", ")", ",", "float64", "(", "y", ")", ")", "\n", "screen", ".", "DrawImage", "(", "g", ".", "boardImage", ",", "op", ")", "\n", "}" ]
21,104
all-21105
[ "Returns", "a", "Typed", "helper", "at", "the", "key", "or", "the", "specified", "default", "if", "the", "key", "doesn", "t", "exist", "or", "if", "the", "key", "isn", "t", "a", "map", "[", "string", "]", "interface", "{}" ]
[ "func", "(", "t", "Typed", ")", "ObjectOr", "(", "key", "string", ",", "d", "map", "[", "string", "]", "<mask>", "{", "}", ")", "Typed", "{", "if", "value", ",", "exists", ":=", "t", ".", "ObjectIf", "(", "key", ")", ";", "exists", "{", "return", "value", "\n", "}", "\n", "return", "Typed", "(", "d", ")", "\n", "}" ]
21,105
all-21106
[ "GetMinOk", "returns", "a", "tuple", "with", "the", "Min", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "and", "a", "boolean", "to", "check", "if", "the", "value", "has", "been", "set", "." ]
[ "func", "(", "w", "*", "WidgetAxis", ")", "GetMinOk", "(", ")", "(", "string", ",", "bool", ")", "{", "if", "w", "==", "nil", "||", "w", ".", "Min", "==", "nil", "{", "return", "\"", "\"", ",", "<mask>", "\n", "}", "\n", "return", "*", "w", ".", "Min", ",", "true", "\n", "}" ]
21,106
all-21107
[ "requirementsForImageRef", "selects", "the", "appropriate", "requirements", "for", "ref", "." ]
[ "func", "(", "pc", "*", "PolicyContext", ")", "requirementsForImageRef", "(", "ref", "types", ".", "ImageReference", ")", "PolicyRequirements", "{", "// Do we have a PolicyTransportScopes for this transport?", "transportName", ":=", "ref", ".", "Transport", "(", ")", ".", "<mask>", "(", ")", "\n", "if", "transportScopes", ",", "ok", ":=", "pc", ".", "Policy", ".", "Transports", "[", "transportName", "]", ";", "ok", "{", "// Look for a full match.", "identity", ":=", "ref", ".", "PolicyConfigurationIdentity", "(", ")", "\n", "if", "req", ",", "ok", ":=", "transportScopes", "[", "identity", "]", ";", "ok", "{", "logrus", ".", "Debugf", "(", "` Using transport \"%s\" policy section %s`", ",", "transportName", ",", "identity", ")", "\n", "return", "req", "\n", "}", "\n\n", "// Look for a match of the possible parent namespaces.", "for", "_", ",", "name", ":=", "range", "ref", ".", "PolicyConfigurationNamespaces", "(", ")", "{", "if", "req", ",", "ok", ":=", "transportScopes", "[", "name", "]", ";", "ok", "{", "logrus", ".", "Debugf", "(", "` Using transport \"%s\" specific policy section %s`", ",", "transportName", ",", "name", ")", "\n", "return", "req", "\n", "}", "\n", "}", "\n\n", "// Look for a default match for the transport.", "if", "req", ",", "ok", ":=", "transportScopes", "[", "\"", "\"", "]", ";", "ok", "{", "logrus", ".", "Debugf", "(", "` Using transport \"%s\" policy section \"\"`", ",", "transportName", ")", "\n", "return", "req", "\n", "}", "\n", "}", "\n\n", "logrus", ".", "Debugf", "(", "\"", "\"", ")", "\n", "return", "pc", ".", "Policy", ".", "Default", "\n", "}" ]
21,107
all-21108
[ "FirehoseWithoutReconnect", "functions", "identically", "to", "Firehose", "but", "without", "any", "reconnect", "attempts", "when", "errors", "occur", "." ]
[ "func", "(", "c", "*", "<mask>", ")", "FirehoseWithoutReconnect", "(", "subscriptionId", "string", ",", "authToken", "string", ",", ")", "(", "<-", "chan", "*", "events", ".", "Envelope", ",", "<-", "chan", "error", ")", "{", "return", "c", ".", "firehose", "(", "newFirehose", "(", "subscriptionId", ",", "authToken", ",", "WithRetry", "(", "false", ")", ",", ")", ")", "\n", "}" ]
21,108
all-21109
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "SetRuleSelectorParams", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoCss16", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "<mask>", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
21,109
all-21110
[ "HasShowErrors", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "t", "*", "TraceServiceDefinition", ")", "HasShowErrors", "(", ")", "bool", "{", "if", "t", "!=", "nil", "&&", "t", ".", "ShowErrors", "!=", "nil", "{", "return", "<mask>", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
21,110
all-21111
[ "Patch", "applies", "patch", "to", "old", "according", "to", "the", "bspatch", "algorithm", "and", "writes", "the", "result", "to", "new", "." ]
[ "func", "Patch", "(", "old", "io", ".", "Reader", ",", "new", "io", ".", "Writer", ",", "patch", "io", ".", "Reader", ")", "error", "{", "var", "hdr", "header", "\n", "err", ":=", "binary", ".", "Read", "(", "patch", ",", "signMagLittleEndian", "{", "}", ",", "&", "hdr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "hdr", ".", "Magic", "!=", "magic", "{", "return", "ErrCorrupt", "\n", "}", "\n", "if", "hdr", ".", "CtrlLen", "<", "0", "||", "hdr", ".", "DiffLen", "<", "0", "||", "hdr", ".", "NewSize", "<", "0", "{", "return", "ErrCorrupt", "\n", "}", "\n\n", "ctrlbuf", ":=", "make", "(", "[", "]", "byte", ",", "hdr", ".", "CtrlLen", ")", "\n", "_", ",", "err", "=", "io", ".", "ReadFull", "(", "patch", ",", "ctrlbuf", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "cpfbz2", ":=", "bzip2", ".", "NewReader", "(", "bytes", ".", "NewReader", "(", "ctrlbuf", ")", ")", "\n\n", "diffbuf", ":=", "make", "(", "[", "]", "byte", ",", "hdr", ".", "DiffLen", ")", "\n", "_", ",", "err", "=", "io", ".", "ReadFull", "(", "patch", ",", "diffbuf", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "dpfbz2", ":=", "bzip2", ".", "NewReader", "(", "bytes", ".", "NewReader", "(", "diffbuf", ")", ")", "\n\n", "// The entire rest of the file is the extra block.", "epfbz2", ":=", "bzip2", ".", "NewReader", "(", "<mask>", ")", "\n\n", "obuf", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "old", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "nbuf", ":=", "make", "(", "[", "]", "byte", ",", "hdr", ".", "NewSize", ")", "\n\n", "var", "oldpos", ",", "newpos", "int64", "\n", "for", "newpos", "<", "hdr", ".", "NewSize", "{", "var", "ctrl", "struct", "{", "Add", ",", "Copy", ",", "Seek", "int64", "}", "\n", "err", "=", "binary", ".", "Read", "(", "cpfbz2", ",", "signMagLittleEndian", "{", "}", ",", "&", "ctrl", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Sanity-check", "if", "newpos", "+", "ctrl", ".", "Add", ">", "hdr", ".", "NewSize", "{", "return", "ErrCorrupt", "\n", "}", "\n\n", "// Read diff string", "_", ",", "err", "=", "io", ".", "ReadFull", "(", "dpfbz2", ",", "nbuf", "[", "newpos", ":", "newpos", "+", "ctrl", ".", "Add", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ErrCorrupt", "\n", "}", "\n\n", "// Add old data to diff string", "for", "i", ":=", "int64", "(", "0", ")", ";", "i", "<", "ctrl", ".", "Add", ";", "i", "++", "{", "if", "oldpos", "+", "i", ">=", "0", "&&", "oldpos", "+", "i", "<", "int64", "(", "len", "(", "obuf", ")", ")", "{", "nbuf", "[", "newpos", "+", "i", "]", "+=", "obuf", "[", "oldpos", "+", "i", "]", "\n", "}", "\n", "}", "\n\n", "// Adjust pointers", "newpos", "+=", "ctrl", ".", "Add", "\n", "oldpos", "+=", "ctrl", ".", "Add", "\n\n", "// Sanity-check", "if", "newpos", "+", "ctrl", ".", "Copy", ">", "hdr", ".", "NewSize", "{", "return", "ErrCorrupt", "\n", "}", "\n\n", "// Read extra string", "_", ",", "err", "=", "io", ".", "ReadFull", "(", "epfbz2", ",", "nbuf", "[", "newpos", ":", "newpos", "+", "ctrl", ".", "Copy", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ErrCorrupt", "\n", "}", "\n\n", "// Adjust pointers", "newpos", "+=", "ctrl", ".", "Copy", "\n", "oldpos", "+=", "ctrl", ".", "Seek", "\n", "}", "\n\n", "// Write the new file", "for", "len", "(", "nbuf", ")", ">", "0", "{", "n", ",", "err", ":=", "new", ".", "Write", "(", "nbuf", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "nbuf", "=", "nbuf", "[", "n", ":", "]", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
21,111
all-21112
[ "Offsets", "returns", "the", "latest", "stashed", "offsets", "by", "topic", "-", "partition" ]
[ "func", "(", "s", "*", "OffsetStash", ")", "Offsets", "(", ")", "map", "[", "string", "]", "int64", "{", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "res", ":=", "make", "(", "map", "[", "string", "]", "int64", ",", "len", "(", "s", ".", "offsets", ")", ")", "\n", "for", "tp", ",", "info", ":=", "range", "s", ".", "offsets", "{", "res", "[", "tp", ".", "String", "(", ")", "]", "=", "info", ".", "Offset", "\n", "}", "\n", "return", "<mask>", "\n", "}" ]
21,112
all-21113
[ "GetAuthconfig", "retrieves", "the", "correct", "auth", "configuration", "for", "the", "given", "repository" ]
[ "func", "(", "authProvider", "*", "ecrAuthProvider", ")", "GetAuthconfig", "(", "image", "string", ",", "registryAuthData", "*", "apicontainer", ".", "RegistryAuthenticationData", ")", "(", "types", ".", "AuthConfig", ",", "error", ")", "{", "if", "registryAuthData", "==", "nil", "{", "return", "types", ".", "AuthConfig", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "authData", ":=", "registryAuthData", ".", "ECRAuthData", "\n\n", "if", "authData", "==", "nil", "{", "return", "<mask>", ".", "AuthConfig", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// First try to get the token from cache, if the token does not exist,", "// then call ECR api to get the new token", "key", ":=", "cacheKey", "{", "region", ":", "authData", ".", "Region", ",", "endpointOverride", ":", "authData", ".", "EndpointOverride", ",", "registryID", ":", "authData", ".", "RegistryID", ",", "}", "\n\n", "// If the container is using execution role credentials to pull,", "// add the roleARN as part of the cache key so that docker auth for", "// containers pull with the same role can be cached", "if", "authData", ".", "GetPullCredentials", "(", ")", "!=", "(", "credentials", ".", "IAMRoleCredentials", "{", "}", ")", "{", "key", ".", "roleARN", "=", "authData", ".", "GetPullCredentials", "(", ")", ".", "RoleArn", "\n", "}", "\n\n", "// Try to get the auth config from cache", "auth", ":=", "authProvider", ".", "getAuthConfigFromCache", "(", "key", ")", "\n", "if", "auth", "!=", "nil", "{", "return", "*", "auth", ",", "nil", "\n", "}", "\n\n", "// Get the auth config from ECR", "return", "authProvider", ".", "getAuthConfigFromECR", "(", "image", ",", "key", ",", "authData", ")", "\n", "}" ]
21,113
all-21114
[ "SetParams", "sets", "r", ".", "Params", "to", "the", "JSON", "representation", "of", "v", ".", "If", "JSON", "marshaling", "fails", "it", "returns", "an", "error", "." ]
[ "func", "(", "r", "*", "<mask>", ")", "SetParams", "(", "v", "interface", "{", "}", ")", "error", "{", "b", ",", "err", ":=", "json", ".", "Marshal", "(", "v", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "r", ".", "Params", "=", "(", "*", "json", ".", "RawMessage", ")", "(", "&", "b", ")", "\n", "return", "nil", "\n", "}" ]
21,114
all-21115
[ "IsHash", "checks", "is", "provided", "string", "a", "valid", "hash", "." ]
[ "func", "(", "s", "MD5Hasher", ")", "IsHash", "(", "h", "string", ")", "bool", "{", "if", "len", "(", "h", ")", "!=", "s", ".", "HashLength", "{", "return", "false", "\n", "}", "\n", "var", "found", "bool", "\n", "for", "_", ",", "c", ":=", "range", "h", "{", "found", "=", "false", "\n", "for", "_", ",", "m", ":=", "range", "hexChars", "{", "if", "c", "==", "m", "{", "<mask>", "=", "true", "\n", "break", "\n", "}", "\n", "}", "\n", "if", "!", "found", "{", "return", "false", "\n", "}", "\n", "}", "\n", "return", "true", "\n", "}" ]
21,115
all-21116
[ "IsFinished", "()", "is", "a", "wrapper", "around", "gtk_print_operation_is_finished", "()", "." ]
[ "func", "(", "po", "*", "PrintOperation", ")", "IsFinished", "(", ")", "bool", "{", "c", ":=", "C", ".", "gtk_print_operation_is_finished", "(", "<mask>", ".", "native", "(", ")", ")", "\n", "return", "gobool", "(", "c", ")", "\n", "}" ]
21,116
all-21117
[ "ProcessServiceCheckResult", "creates", "a", "new", "PROCESS_SERVICE_CHECK_RESULT", "Nagios", "command", ".", "This", "is", "used", "to", "submit", "a", "passive", "check", "result", "for", "a", "particular", "service", ".", "The", "return_code", "field", "should", "be", "one", "of", "the", "following", ":", "0", "=", "OK", "1", "=", "WARNING", "2", "=", "CRITICAL", "3", "=", "UNKNOWN", ".", "The", "plugin_output", "field", "contains", "text", "output", "from", "the", "service", "check", "along", "with", "optional", "performance", "data", "." ]
[ "func", "ProcessServiceCheckResult", "(", "host_name", "string", ",", "service_description", "<mask>", ",", "return_code", "int", ",", "plugin_output", "string", ",", ")", "*", "livestatus", ".", "Command", "{", "return", "livestatus", ".", "NewCommand", "(", "\"", "\"", ",", "stringifyArg", "(", "\"", "\"", ",", "\"", "\"", ",", "host_name", ")", ",", "stringifyArg", "(", "\"", "\"", ",", "\"", "\"", ",", "service_description", ")", ",", "stringifyArg", "(", "\"", "\"", ",", "\"", "\"", ",", "return_code", ")", ",", "stringifyArg", "(", "\"", "\"", ",", "\"", "\"", ",", "plugin_output", ")", ",", ")", "\n", "}" ]
21,117
all-21118
[ "SetNline", "sets", "the", "number", "of", "line", "where", "secret", "should", "be", "found", "." ]
[ "func", "(", "x", "*", "<mask>", ")", "SetNline", "(", "nLine", "int", ")", "error", "{", "x", ".", "Nline", "=", "&", "nLine", "\n", "return", "nil", "\n", "}" ]
21,118
all-21119
[ "TargetEntryNew", "is", "a", "wrapper", "around", "gtk_target_entry_new", "()", "." ]
[ "func", "TargetEntryNew", "(", "target", "string", ",", "<mask>", "TargetFlags", ",", "info", "uint", ")", "(", "*", "TargetEntry", ",", "error", ")", "{", "cstr", ":=", "C", ".", "CString", "(", "target", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cstr", ")", ")", "\n", "c", ":=", "C", ".", "gtk_target_entry_new", "(", "(", "*", "C", ".", "gchar", ")", "(", "cstr", ")", ",", "C", ".", "guint", "(", "flags", ")", ",", "C", ".", "guint", "(", "info", ")", ")", "\n", "if", "c", "==", "nil", "{", "return", "nil", ",", "nilPtrErr", "\n", "}", "\n", "t", ":=", "(", "*", "TargetEntry", ")", "(", "unsafe", ".", "Pointer", "(", "c", ")", ")", "\n", "// causes setFinilizer error", "//\truntime.SetFinalizer(t, (*TargetEntry).free)", "return", "t", ",", "nil", "\n", "}" ]
21,119
all-21120
[ "DeleteResourcePolicy", "mocks", "base", "method" ]
[ "func", "(", "m", "*", "MockSecretsManagerAPI", ")", "DeleteResourcePolicy", "(", "arg0", "*", "secretsmanager", ".", "DeleteResourcePolicyInput", ")", "(", "*", "secretsmanager", ".", "DeleteResourcePolicyOutput", ",", "error", ")", "{", "<mask>", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "*", "secretsmanager", ".", "DeleteResourcePolicyOutput", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
21,120
all-21121
[ "Reset", "resets", "the", "GeoM", "as", "identity", "." ]
[ "func", "(", "g", "*", "GeoM", ")", "Reset", "(", ")", "{", "g", ".", "a_1", "=", "0", "\n", "g", ".", "b", "=", "0", "\n", "g", ".", "c", "=", "0", "\n", "g", ".", "d_1", "=", "0", "\n", "g", ".", "<mask>", "=", "0", "\n", "g", ".", "ty", "=", "0", "\n", "}" ]
21,121
all-21122
[ "writeByte", "writes", "c", "to", "the", "end", "of", "the", "window" ]
[ "func", "(", "w", "*", "<mask>", ")", "writeByte", "(", "c", "byte", ")", "{", "w", ".", "buf", "[", "w", ".", "w", "]", "=", "c", "\n", "w", ".", "w", "=", "(", "w", ".", "w", "+", "1", ")", "&", "w", ".", "mask", "\n", "}" ]
21,122
all-21123
[ "ListenAndServe", "starts", "the", "AWS", "Lambda", "runtime", "(", "aws", "-", "lambda", "-", "go", "lambda", ".", "Start", ")", "with", "a", "given", "handler", "." ]
[ "func", "ListenAndServe", "(", "handler", "<mask>", ".", "Handler", ",", "opts", "*", "Options", ")", "{", "if", "handler", "==", "nil", "{", "handler", "=", "http", ".", "DefaultServeMux", "\n", "}", "\n", "if", "opts", "==", "nil", "{", "opts", "=", "defaultOptions", "\n", "}", "\n", "opts", ".", "setBinaryContentTypeMap", "(", ")", "\n", "lambda", ".", "Start", "(", "func", "(", "ctx", "context", ".", "Context", ",", "event", "events", ".", "APIGatewayProxyRequest", ")", "(", "events", ".", "APIGatewayProxyResponse", ",", "error", ")", "{", "return", "handleEvent", "(", "ctx", ",", "event", ",", "handler", ",", "opts", ")", "\n", "}", ")", "\n", "}" ]
21,123
all-21124
[ "retrieve", "the", "index", "of", "a", "named", "uniform", "block" ]
[ "func", "GetUniformIndices", "(", "<mask>", "uint32", ",", "uniformCount", "int32", ",", "uniformNames", "*", "*", "uint8", ",", "uniformIndices", "*", "uint32", ")", "{", "syscall", ".", "Syscall6", "(", "gpGetUniformIndices", ",", "4", ",", "uintptr", "(", "program", ")", ",", "uintptr", "(", "uniformCount", ")", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "uniformNames", ")", ")", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "uniformIndices", ")", ")", ",", "0", ",", "0", ")", "\n", "}" ]
21,124
all-21125
[ "getRBDFilesystem", "returns", "the", "filesystem", "the", "RBD", "storage", "volume", "is", "supposed", "to", "be", "created", "with" ]
[ "func", "(", "s", "*", "storageCeph", ")", "getRBDFilesystem", "(", ")", "string", "{", "if", "s", ".", "volume", ".", "Config", "[", "\"", "\"", "]", "!=", "\"", "\"", "{", "return", "s", ".", "volume", ".", "Config", "[", "\"", "\"", "]", "\n", "}", "\n\n", "if", "s", ".", "pool", ".", "Config", "[", "\"", "\"", "]", "!=", "\"", "\"", "{", "<mask>", "s", ".", "pool", ".", "Config", "[", "\"", "\"", "]", "\n", "}", "\n\n", "return", "\"", "\"", "\n", "}" ]
21,125
all-21126
[ "Preallocate", "tries", "to", "allocate", "the", "space", "for", "given", "file", ".", "This", "operation", "is", "only", "supported", "on", "linux", "by", "a", "few", "filesystems", "(", "btrfs", "ext4", "etc", ".", ")", ".", "If", "the", "operation", "is", "unsupported", "no", "error", "will", "be", "returned", ".", "Otherwise", "the", "error", "encountered", "will", "be", "returned", "." ]
[ "func", "Preallocate", "(", "f", "*", "os", ".", "<mask>", ",", "sizeInBytes", "int64", ",", "extendFile", "bool", ")", "error", "{", "if", "sizeInBytes", "==", "0", "{", "// fallocate will return EINVAL if length is 0; skip", "return", "nil", "\n", "}", "\n", "if", "extendFile", "{", "return", "preallocExtend", "(", "f", ",", "sizeInBytes", ")", "\n", "}", "\n", "return", "preallocFixed", "(", "f", ",", "sizeInBytes", ")", "\n", "}" ]
21,126
all-21127
[ "New", "creates", "Cmp", "for", "multiple", "comparison", "mode", "." ]
[ "func", "NewMultiple", "(", "buf", "[", "]", "byte", ",", "options", "<mask>", ",", "h", "hash", ".", "Hash", ",", "compareOnMatch", "bool", ")", "*", "Cmp", "{", "c", ":=", "&", "Cmp", "{", "Opt", ":", "options", ",", "hashType", ":", "h", ",", "hashMatchCompare", ":", "compareOnMatch", ",", "hashTable", ":", "map", "[", "string", "]", "hashSum", "{", "}", ",", "buf", ":", "buf", ",", "}", "\n", "if", "c", ".", "buf", "==", "nil", "||", "len", "(", "c", ".", "buf", ")", "==", "0", "{", "c", ".", "buf", "=", "make", "(", "[", "]", "byte", ",", "defaultBufSize", ")", "\n", "}", "\n", "c", ".", "debugf", "(", "\"", "\\n", "\"", ",", "len", "(", "c", ".", "buf", ")", ")", "\n", "return", "c", "\n", "}" ]
21,127
all-21128
[ "mergeChunk", "merges", "the", "datum", "hashtrees", "into", "a", "chunk", "hashtree", "and", "stores", "it", "." ]
[ "func", "(", "a", "*", "APIServer", ")", "mergeChunk", "(", "logger", "*", "taggedLogger", ",", "high", "int64", ",", "result", "*", "processResult", ")", "(", "retErr", "error", ")", "{", "logger", ".", "Logf", "(", "\"", "\"", ")", "\n", "defer", "func", "(", "start", "time", ".", "Time", ")", "{", "if", "retErr", "!=", "nil", "{", "logger", ".", "Logf", "(", "\"", "\"", ",", "time", ".", "Since", "(", "start", ")", ",", "retErr", ")", "\n", "}", "else", "{", "logger", ".", "Logf", "(", "\"", "\"", ",", "time", ".", "Since", "(", "start", ")", ")", "\n", "}", "\n", "}", "(", "time", ".", "Now", "(", ")", ")", "\n", "buf", ":=", "&", "bytes", ".", "<mask>", "{", "}", "\n", "if", "result", ".", "datumsFailed", "<=", "0", "{", "if", "err", ":=", "a", ".", "datumCache", ".", "Merge", "(", "hashtree", ".", "NewWriter", "(", "buf", ")", ",", "nil", ",", "nil", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "if", "err", ":=", "a", ".", "chunkCache", ".", "Put", "(", "high", ",", "buf", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "a", ".", "pipelineInfo", ".", "EnableStats", "{", "buf", ".", "Reset", "(", ")", "\n", "if", "err", ":=", "a", ".", "datumStatsCache", ".", "Merge", "(", "hashtree", ".", "NewWriter", "(", "buf", ")", ",", "nil", ",", "nil", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "a", ".", "chunkStatsCache", ".", "Put", "(", "high", ",", "buf", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
21,128
all-21129
[ "Parent", "is", "a", "wrapper", "around", "g_type_parent", "()", "." ]
[ "func", "(", "t", "Type", ")", "Parent", "(", ")", "Type", "{", "return", "<mask>", "(", "C", ".", "g_type_parent", "(", "C", ".", "GType", "(", "t", ")", ")", ")", "\n", "}" ]
21,129
all-21130
[ "Replace", "replaces", "the", "previous", "input", "with", "whatever", "is", "specified", "and", "moves", "the", "cursor", "to", "the", "end", "position" ]
[ "func", "(", "c", "*", "Cursor", ")", "Replace", "(", "input", "string", ")", "{", "c", ".", "input", "=", "[", "]", "rune", "(", "<mask>", ")", "\n", "c", ".", "End", "(", ")", "\n", "}" ]
21,130
all-21131
[ "Less", "helps", "implement", "sort", ".", "Interface", "for", "virtualDiskSubresourceSorter", "." ]
[ "func", "(", "s", "virtualDiskSubresourceSorter", ")", "Less", "(", "i", ",", "j", "int", ")", "bool", "{", "mi", ":=", "s", "[", "i", "]", ".", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "mj", ":=", "s", "[", "j", "]", ".", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "return", "<mask>", "[", "\"", "\"", "]", ".", "(", "int", ")", "<", "mj", "[", "\"", "\"", "]", ".", "(", "int", ")", "\n", "}" ]
21,131
all-21132
[ "Returns", "true", "if", "parameter", "with", "given", "name", "is", "mandatory" ]
[ "func", "mandatory", "(", "a", "gen", ".", "Action", ",", "param", "string", ")", "bool", "{", "for", "_", ",", "p", ":=", "range", "a", ".", "Params", "{", "if", "p", ".", "<mask>", "==", "param", "{", "return", "p", ".", "Mandatory", "\n", "}", "\n", "}", "\n", "panic", "(", "\"", "\"", "+", "param", "+", "\"", "\"", "+", "a", ".", "Name", ")", "\n", "}" ]
21,132
all-21133
[ "title", ":", "webhook", "list", "path", ":", "/", "events", "/", "webhooks", "method", ":", "GET", "produce", ":", "application", "/", "json", "responses", ":", "200", ":", "List", "webhooks", "204", ":", "No", "content" ]
[ "func", "webhookList", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "t", "auth", ".", "Token", ")", "error", "{", "ctxs", ":=", "permission", ".", "ContextsForPermission", "(", "t", ",", "permission", ".", "PermWebhookRead", ",", "permTypes", ".", "CtxTeam", ")", "\n", "var", "teams", "[", "]", "string", "\n", "for", "_", ",", "c", ":=", "range", "ctxs", "{", "if", "c", ".", "CtxType", "==", "permTypes", ".", "CtxGlobal", "{", "teams", "=", "nil", "\n", "break", "\n", "}", "\n", "teams", "=", "<mask>", "(", "teams", ",", "c", ".", "Value", ")", "\n", "}", "\n", "webhooks", ",", "err", ":=", "servicemanager", ".", "Webhook", ".", "List", "(", "teams", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "len", "(", "webhooks", ")", "==", "0", "{", "w", ".", "WriteHeader", "(", "http", ".", "StatusNoContent", ")", "\n", "return", "nil", "\n", "}", "\n", "w", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "return", "json", ".", "NewEncoder", "(", "w", ")", ".", "Encode", "(", "webhooks", ")", "\n", "}" ]
21,133
all-21134
[ "MergeProfiles", "merges", "two", "coverage", "profiles", ".", "The", "profiles", "are", "expected", "to", "be", "similar", "-", "that", "is", "from", "multiple", "invocations", "of", "a", "single", "binary", "or", "multiple", "binaries", "using", "the", "same", "codebase", ".", "In", "particular", "any", "source", "files", "with", "the", "same", "path", "must", "have", "had", "identical", "content", "when", "building", "the", "binaries", ".", "MergeProfiles", "expects", "its", "arguments", "to", "be", "sorted", ":", "Profiles", "in", "alphabetical", "order", "and", "lines", "in", "files", "in", "the", "order", "those", "lines", "appear", ".", "These", "are", "standard", "constraints", "for", "Go", "coverage", "profiles", ".", "The", "resulting", "profile", "will", "also", "obey", "these", "constraints", "." ]
[ "func", "MergeProfiles", "(", "a", "[", "]", "*", "cover", ".", "Profile", ",", "b", "[", "]", "*", "cover", ".", "Profile", ")", "(", "[", "]", "*", "cover", ".", "Profile", ",", "error", ")", "{", "var", "result", "[", "]", "*", "cover", ".", "Profile", "\n", "files", ":=", "make", "(", "map", "[", "string", "]", "*", "cover", ".", "Profile", ",", "len", "(", "a", ")", ")", "\n", "for", "_", ",", "profile", ":=", "range", "a", "{", "np", ":=", "deepCopyProfile", "(", "*", "profile", ")", "\n", "result", "=", "append", "(", "result", ",", "&", "np", ")", "\n", "files", "[", "np", ".", "FileName", "]", "=", "&", "np", "\n", "}", "\n\n", "needsSort", ":=", "false", "\n", "// Now merge b into the result", "for", "_", ",", "profile", ":=", "range", "b", "{", "dest", ",", "ok", ":=", "files", "[", "profile", ".", "FileName", "]", "\n", "if", "ok", "{", "if", "err", ":=", "ensureProfilesMatch", "(", "profile", ",", "dest", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "profile", ".", "FileName", ",", "err", ")", "\n", "}", "\n", "for", "i", ",", "block", ":=", "range", "profile", ".", "Blocks", "{", "db", ":=", "&", "dest", ".", "Blocks", "[", "i", "]", "\n", "<mask>", ".", "Count", "+=", "block", ".", "Count", "\n", "}", "\n", "}", "else", "{", "// If we get some file we haven't seen before, we just append it.", "// We need to sort this later to ensure the resulting profile is still correctly sorted.", "np", ":=", "deepCopyProfile", "(", "*", "profile", ")", "\n", "files", "[", "np", ".", "FileName", "]", "=", "&", "np", "\n", "result", "=", "append", "(", "result", ",", "&", "np", ")", "\n", "needsSort", "=", "true", "\n", "}", "\n", "}", "\n", "if", "needsSort", "{", "sort", ".", "Slice", "(", "result", ",", "func", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "result", "[", "i", "]", ".", "FileName", "<", "result", "[", "j", "]", ".", "FileName", "}", ")", "\n", "}", "\n", "return", "result", ",", "nil", "\n", "}" ]
21,134
all-21135
[ "RunInBackground", "runs", "f", "in", "a", "background", "goroutine", "in", "this", "process", ".", "f", "is", "provided", "a", "context", "that", "may", "outlast", "the", "context", "provided", "to", "RunInBackground", ".", "This", "is", "only", "valid", "to", "invoke", "from", "a", "service", "set", "to", "basic", "or", "manual", "scaling", "." ]
[ "func", "RunInBackground", "(", "c", "context", ".", "Context", ",", "f", "func", "(", "c", "<mask>", ".", "Context", ")", ")", "error", "{", "req", ":=", "&", "pb", ".", "StartBackgroundRequestRequest", "{", "}", "\n", "res", ":=", "&", "pb", ".", "StartBackgroundRequestResponse", "{", "}", "\n", "if", "err", ":=", "internal", ".", "Call", "(", "c", ",", "\"", "\"", ",", "\"", "\"", ",", "req", ",", "res", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "sendc", "<-", "send", "{", "res", ".", "GetRequestId", "(", ")", ",", "f", "}", "\n", "return", "nil", "\n", "}" ]
21,135
all-21136
[ "GetString", "returns", "the", "value", "of", "the", "given", "key", "which", "must", "be", "of", "type", "String", "." ]
[ "func", "(", "m", "*", "Map", ")", "GetString", "(", "<mask>", "string", ")", "string", "{", "m", ".", "schema", ".", "assertKeyType", "(", "name", ",", "String", ")", "\n", "return", "m", ".", "GetRaw", "(", "name", ")", "\n", "}" ]
21,136
all-21137
[ "ImageID", "computes", "an", "ID", "which", "can", "uniquely", "identify", "this", "image", "by", "its", "contents", "." ]
[ "func", "(", "m", "*", "Schema1", ")", "ImageID", "(", "diffIDs", "[", "]", "digest", ".", "Digest", ")", "(", "string", ",", "error", ")", "{", "<mask>", ",", "err", ":=", "m", ".", "ToSchema2Config", "(", "diffIDs", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "return", "digest", ".", "FromBytes", "(", "image", ")", ".", "Hex", "(", ")", ",", "nil", "\n", "}" ]
21,137
all-21138
[ "LedgerKey", "returns", "the", "key", "for", "the", "ledger", "entry", "that", "was", "changed", "in", "change", "." ]
[ "func", "(", "change", "*", "LedgerEntryChange", ")", "LedgerKey", "(", ")", "LedgerKey", "{", "switch", "change", ".", "Type", "{", "case", "LedgerEntryChangeTypeLedgerEntryCreated", ":", "change", ":=", "change", ".", "MustCreated", "(", ")", "\n", "return", "change", ".", "LedgerKey", "(", ")", "\n", "case", "LedgerEntryChangeTypeLedgerEntryRemoved", ":", "return", "change", ".", "MustRemoved", "(", ")", "\n", "case", "LedgerEntryChangeTypeLedgerEntryUpdated", ":", "change", ":=", "change", ".", "MustUpdated", "(", ")", "\n", "return", "change", ".", "LedgerKey", "(", ")", "\n", "case", "LedgerEntryChangeTypeLedgerEntryState", ":", "change", ":=", "<mask>", ".", "MustState", "(", ")", "\n", "return", "change", ".", "LedgerKey", "(", ")", "\n", "default", ":", "panic", "(", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "change", ".", "Type", ")", ")", "\n", "}", "\n", "}" ]
21,138
all-21139
[ "netifKey", "renders", "a", "specific", "network_interface", "key", "for", "a", "specific", "resource", "index", "." ]
[ "func", "netifKey", "(", "<mask>", "string", ",", "n", "int", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "cNetifKeyPrefix", ",", "n", ",", "key", ")", "\n", "}" ]
21,139
all-21140
[ "NewOutgoingChatAction", "creates", "a", "new", "outgoing", "chat", "action", "." ]
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "NewOutgoingChatAction", "(", "recipient", "Recipient", ",", "action", "ChatAction", ")", "*", "OutgoingChatAction", "{", "return", "&", "OutgoingChatAction", "{", "outgoingBase", ":", "outgoingBase", "{", "api", ":", "api", ",", "Recipient", ":", "recipient", ",", "}", ",", "Action", ":", "<mask>", ",", "}", "\n", "}" ]
21,140
all-21141
[ "GetQueryOk", "returns", "a", "tuple", "with", "the", "Query", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "and", "a", "boolean", "to", "check", "if", "the", "value", "has", "been", "set", "." ]
[ "func", "(", "w", "*", "WidgetEvent", ")", "GetQueryOk", "(", ")", "(", "string", ",", "bool", ")", "{", "if", "w", "==", "nil", "||", "w", ".", "Query", "==", "nil", "{", "return", "\"", "\"", ",", "<mask>", "\n", "}", "\n", "return", "*", "w", ".", "Query", ",", "true", "\n", "}" ]
21,141
all-21142
[ "New", "archive", "If", "the", "exentions", "of", "the", "target", "file", "is", ".", "zip", "the", "archive", "will", "be", "in", "the", "zip", "format", "otherwise", "it", "will", "be", "a", "tar", ".", "gz", "archive", "." ]
[ "func", "New", "(", "file", "*", "os", ".", "<mask>", ")", "Archive", "{", "if", "filepath", ".", "Ext", "(", "file", ".", "Name", "(", ")", ")", "==", "\"", "\"", "{", "return", "zip", ".", "New", "(", "file", ")", "\n", "}", "\n", "return", "tar", ".", "New", "(", "file", ")", "\n", "}" ]
21,142
all-21143
[ "SetBodyWriter", "sets", "the", "body", "of", "the", "message", ".", "It", "can", "be", "useful", "with", "the", "text", "/", "template", "or", "html", "/", "template", "packages", "." ]
[ "func", "(", "m", "*", "Message", ")", "SetBodyWriter", "(", "contentType", "string", ",", "f", "func", "(", "io", ".", "Writer", ")", "error", ",", "<mask>", "...", "PartSetting", ")", "{", "m", ".", "parts", "=", "[", "]", "*", "part", "{", "m", ".", "newPart", "(", "contentType", ",", "f", ",", "settings", ")", "}", "\n", "}" ]
21,143
all-21144
[ "GetProperty", "returns", "the", "Property", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "s", "*", "SyntheticsAssertion", ")", "GetProperty", "(", ")", "string", "{", "if", "s", "==", "nil", "||", "s", ".", "Property", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "<mask>", "*", "s", ".", "Property", "\n", "}" ]
21,144
all-21145
[ "Startup", "is", "not", "required", "to", "use", "the", "ReplGroupStore", ";", "it", "will", "automatically", "connect", "to", "backend", "stores", "as", "needed", ".", "However", "if", "you", "d", "like", "to", "use", "the", "ring", "service", "to", "receive", "ring", "updates", "and", "have", "the", "ReplGroupStore", "automatically", "update", "itself", "accordingly", "Startup", "will", "launch", "a", "connector", "to", "that", "service", ".", "Otherwise", "you", "will", "need", "to", "call", "SetRing", "yourself", "to", "inform", "the", "ReplGroupStore", "of", "which", "backends", "to", "connect", "to", "." ]
[ "func", "(", "rs", "*", "ReplGroupStore", ")", "Startup", "(", "ctx", "context", ".", "Context", ")", "error", "{", "rs", ".", "ringLock", ".", "Lock", "(", ")", "\n", "if", "rs", ".", "ringServerExitChan", "==", "nil", "{", "rs", ".", "ringServerExitChan", "=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "go", "rs", ".", "ringServerConnector", "(", "rs", ".", "ringServerExitChan", ")", "\n", "}", "\n", "<mask>", ".", "ringLock", ".", "Unlock", "(", ")", "\n", "return", "nil", "\n", "}" ]
21,145
all-21146
[ "Names", "returns", "the", "names", "of", "all", "variables", "within", "the", "template", "." ]
[ "func", "(", "self", "*", "UriTemplate", ")", "Names", "(", ")", "[", "]", "string", "{", "names", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "self", ".", "parts", ")", ")", "\n\n", "for", "_", ",", "p", ":=", "range", "self", ".", "parts", "{", "if", "len", "(", "p", ".", "raw", ")", ">", "0", "||", "len", "(", "p", ".", "terms", ")", "==", "0", "{", "continue", "\n", "}", "\n\n", "for", "_", ",", "term", ":=", "range", "p", ".", "<mask>", "{", "names", "=", "append", "(", "names", ",", "term", ".", "name", ")", "\n", "}", "\n", "}", "\n\n", "return", "names", "\n", "}" ]
21,146
all-21147
[ "Download", "renders", "a", "file", "attachment", "automatically", "setting", "following", "headers", ":", "Content", "-", "Type", "Content", "-", "Length", "Content", "-", "Disposition", "Content", "-", "Type", "is", "set", "using", "mime#TypeByExtension", "with", "the", "filename", "s", "extension", ".", "Content", "-", "Type", "will", "default", "to", "application", "/", "octet", "-", "stream", "if", "using", "a", "filename", "with", "an", "unknown", "extension", "." ]
[ "func", "(", "e", "*", "Engine", ")", "Download", "(", "ctx", "context", ".", "Context", ",", "<mask>", "string", ",", "r", "io", ".", "Reader", ")", "Renderer", "{", "return", "Download", "(", "ctx", ",", "name", ",", "r", ")", "\n", "}" ]
21,147
all-21148
[ "Get", "gets", "a", "key", "s", "value", "by", "returning", "an", "io", ".", "ReadCloser", "that", "should", "be", "closed", "when", "done", "." ]
[ "func", "(", "c", "*", "Cache", ")", "Get", "(", "key", "string", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "!", "c", ".", "keys", "[", "key", "]", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "key", ")", "\n", "}", "\n", "f", ",", "err", ":=", "os", ".", "Open", "(", "filepath", ".", "Join", "(", "c", ".", "root", ",", "<mask>", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "f", ",", "nil", "\n", "}" ]
21,148
all-21149
[ "decodeConfiguration", "deserializes", "a", "Configuration", "using", "MsgPack", "or", "panics", "on", "errors", "." ]
[ "func", "decodeConfiguration", "(", "buf", "[", "]", "byte", ")", "<mask>", "{", "var", "configuration", "Configuration", "\n", "if", "err", ":=", "decodeMsgPack", "(", "buf", ",", "&", "configuration", ")", ";", "err", "!=", "nil", "{", "panic", "(", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", ")", "\n", "}", "\n", "return", "configuration", "\n", "}" ]
21,149
all-21150
[ "Stop", "shuts", "down", "the", "notification", "handler", "." ]
[ "func", "(", "n", "*", "Manager", ")", "Stop", "(", ")", "{", "level", ".", "Info", "(", "n", ".", "logger", ")", ".", "<mask>", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "n", ".", "cancel", "(", ")", "\n", "}" ]
21,150
all-21151
[ "flattenClusterVMHostRuleInfo", "saves", "a", "ClusterVmHostRuleInfo", "into", "the", "supplied", "ResourceData", "." ]
[ "func", "flattenClusterVMHostRuleInfo", "(", "d", "*", "schema", ".", "ResourceData", ",", "obj", "*", "types", ".", "ClusterVmHostRuleInfo", ")", "error", "{", "return", "structure", ".", "SetBatch", "(", "d", ",", "map", "[", "string", "]", "<mask>", "{", "}", "{", "\"", "\"", ":", "obj", ".", "Enabled", ",", "\"", "\"", ":", "obj", ".", "Mandatory", ",", "\"", "\"", ":", "obj", ".", "Name", ",", "\"", "\"", ":", "obj", ".", "AffineHostGroupName", ",", "\"", "\"", ":", "obj", ".", "AntiAffineHostGroupName", ",", "\"", "\"", ":", "obj", ".", "VmGroupName", ",", "}", ")", "\n", "}" ]
21,151
all-21152
[ "GetPaperHeight", "()", "is", "a", "wrapper", "around", "gtk_page_setup_get_paper_height", "()", "." ]
[ "func", "(", "ps", "*", "PageSetup", ")", "GetPaperHeight", "(", "<mask>", "Unit", ")", "float64", "{", "c", ":=", "C", ".", "gtk_page_setup_get_paper_height", "(", "ps", ".", "native", "(", ")", ",", "C", ".", "GtkUnit", "(", "unit", ")", ")", "\n", "return", "float64", "(", "c", ")", "\n", "}" ]
21,152
all-21153
[ "UnmarshalYAML", "implements", "the", "yaml", ".", "Unmarshaler", "interface", "." ]
[ "func", "(", "c", "*", "SDConfig", ")", "UnmarshalYAML", "(", "unmarshal", "func", "(", "interface", "{", "}", ")", "error", ")", "error", "{", "*", "c", "=", "DefaultSDConfig", "\n", "<mask>", "plain", "SDConfig", "\n", "err", ":=", "unmarshal", "(", "(", "*", "plain", ")", "(", "c", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "strings", ".", "TrimSpace", "(", "c", ".", "Server", ")", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
21,153
all-21154
[ "newWritableChunk", "creates", "a", "new", "writable", "chunk", "around", "a", "checksum", "and", "a", "buffer", "to", "hold", "data" ]
[ "func", "newWritableChunk", "(", "checksum", "Checksum", ",", "contents", "*", "typed", ".", "WriteBuffer", ")", "*", "writableChunk", "{", "return", "&", "writableChunk", "{", "<mask>", ":", "0", ",", "sizeRef", ":", "contents", ".", "DeferUint16", "(", ")", ",", "checksum", ":", "checksum", ",", "contents", ":", "contents", ",", "}", "\n", "}" ]
21,154
all-21155
[ "JobSummary", "produces", "a", "JobSummary", "instance", "with", "values", "populated", "from", "the", "import", "result", ".", "The", "summary", "object", "won", "t", "have", "its", "Description", "populated", "since", "import", "results", "do", "not", "include", "descriptions", "." ]
[ "func", "(", "r", "*", "jobImportResult", ")", "JobSummary", "(", ")", "*", "JobSummary", "{", "return", "&", "JobSummary", "{", "ID", ":", "r", ".", "ID", ",", "Name", ":", "r", ".", "<mask>", ",", "GroupName", ":", "r", ".", "GroupName", ",", "ProjectName", ":", "r", ".", "ProjectName", ",", "}", "\n", "}" ]
21,155
all-21156
[ "JobPath", "returns", "a", "link", "to", "the", "GCS", "directory", "for", "the", "job", "specified", "in", "src" ]
[ "func", "(", "s", "*", "Spyglass", ")", "JobPath", "(", "src", "string", ")", "(", "string", ",", "error", ")", "{", "src", "=", "strings", ".", "TrimSuffix", "(", "src", ",", "\"", "\"", ")", "\n", "keyType", ",", "key", ",", "err", ":=", "splitSrc", "(", "src", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "src", ")", "\n", "}", "\n", "split", ":=", "strings", ".", "Split", "(", "key", ",", "\"", "\"", ")", "\n", "switch", "keyType", "{", "case", "gcsKeyType", ":", "if", "len", "(", "split", ")", "<", "4", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "key", ")", "\n", "}", "\n", "// see https://github.com/kubernetes/test-infra/tree/master/gubernator", "bktName", ":=", "split", "[", "0", "]", "\n", "logType", ":=", "split", "[", "1", "]", "\n", "jobName", ":=", "split", "[", "len", "(", "split", ")", "-", "2", "]", "\n", "if", "logType", "==", "gcs", ".", "NonPRLogs", "{", "return", "path", ".", "Dir", "(", "key", ")", ",", "nil", "\n", "}", "else", "if", "logType", "==", "gcs", ".", "PRLogs", "{", "return", "path", ".", "Join", "(", "bktName", ",", "gcs", ".", "PRLogs", ",", "\"", "\"", ",", "jobName", ")", ",", "nil", "\n", "}", "\n", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "key", ")", "\n", "case", "prowKeyType", ":", "if", "len", "(", "split", ")", "<", "2", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "key", ")", "\n", "}", "\n", "jobName", ":=", "split", "[", "0", "]", "\n", "buildID", ":=", "split", "[", "1", "]", "\n", "job", ",", "err", ":=", "s", ".", "jobAgent", ".", "GetProwJob", "(", "jobName", ",", "buildID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "<mask>", ",", "err", ")", "\n", "}", "\n", "if", "job", ".", "Spec", ".", "DecorationConfig", "==", "nil", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "jobName", ")", "\n", "}", "\n", "if", "job", ".", "Spec", ".", "DecorationConfig", ".", "GCSConfiguration", "==", "nil", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "jobName", ")", "\n", "}", "\n", "bktName", ":=", "job", ".", "Spec", ".", "DecorationConfig", ".", "GCSConfiguration", ".", "Bucket", "\n", "if", "job", ".", "Spec", ".", "Type", "==", "prowapi", ".", "PresubmitJob", "{", "return", "path", ".", "Join", "(", "bktName", ",", "gcs", ".", "PRLogs", ",", "\"", "\"", ",", "jobName", ")", ",", "nil", "\n", "}", "\n", "return", "path", ".", "Join", "(", "bktName", ",", "gcs", ".", "NonPRLogs", ",", "jobName", ")", ",", "nil", "\n", "default", ":", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "src", ")", "\n", "}", "\n", "}" ]
21,156
all-21157
[ "Backoff", "causes", "the", "current", "thread", "/", "routine", "to", "sleep", "for", "NextDuration", "." ]
[ "func", "(", "b", "*", "Backoff", ")", "Backoff", "(", ")", "{", "time", ".", "Sleep", "(", "b", ".", "NextDuration", ")", "\n", "b", ".", "<mask>", "++", "\n", "b", ".", "LastDuration", "=", "b", ".", "NextDuration", "\n", "b", ".", "NextDuration", "=", "b", ".", "getNextDuration", "(", ")", "\n", "}" ]
21,157
all-21158
[ "NewClientWithFields", "creates", "a", "new", "fully", "operational", "GitHub", "client", ".", "With", "added", "logging", "fields", ".", "getToken", "is", "a", "generator", "for", "the", "GitHub", "access", "token", "to", "use", ".", "bases", "is", "a", "variadic", "slice", "of", "endpoints", "to", "use", "in", "order", "of", "preference", ".", "An", "endpoint", "is", "used", "when", "all", "preceding", "endpoints", "have", "returned", "a", "conn", "err", ".", "This", "should", "be", "used", "when", "using", "the", "ghproxy", "GitHub", "proxy", "cache", "to", "allow", "this", "client", "to", "bypass", "the", "cache", "if", "it", "is", "temporarily", "unavailable", "." ]
[ "func", "NewClientWithFields", "(", "fields", "logrus", ".", "Fields", ",", "getToken", "func", "(", ")", "[", "]", "byte", ",", "graphqlEndpoint", "string", ",", "bases", "...", "string", ")", "*", "Client", "{", "return", "&", "Client", "{", "logger", ":", "logrus", ".", "WithFields", "(", "fields", ")", ".", "WithField", "(", "\"", "\"", ",", "\"", "\"", ")", ",", "<mask>", ":", "&", "standardTime", "{", "}", ",", "gqlc", ":", "githubql", ".", "NewEnterpriseClient", "(", "graphqlEndpoint", ",", "&", "http", ".", "Client", "{", "Timeout", ":", "maxRequestTime", ",", "Transport", ":", "&", "oauth2", ".", "Transport", "{", "Source", ":", "newReloadingTokenSource", "(", "getToken", ")", "}", ",", "}", ")", ",", "client", ":", "&", "http", ".", "Client", "{", "Timeout", ":", "maxRequestTime", "}", ",", "bases", ":", "bases", ",", "getToken", ":", "getToken", ",", "dry", ":", "false", ",", "}", "\n", "}" ]
21,158
all-21159
[ "Setup", "implements", "storage", "interface", "." ]
[ "func", "(", "s", "*", "Storage", ")", "Setup", "(", ")", "error", "{", "query", ":=", "fmt", ".", "Sprintf", "(", "`\n\t\tCREATE SCHEMA IF NOT EXISTS %s;\n\t\tCREATE TABLE IF NOT EXISTS %s.%s (\n\t\t\taccess_token BYTEA PRIMARY KEY,\n\t\t\trefresh_token BYTEA,\n\t\t\tsubject_id TEXT NOT NULL,\n\t\t\tsubject_client TEXT,\n\t\t\tbag bytea NOT NULL,\n\t\t\texpire_at TIMESTAMPTZ NOT NULL DEFAULT (NOW() + '%d seconds')\n\n\t\t);\n\t\tCREATE INDEX ON %s.%s (refresh_token);\n\t\tCREATE INDEX ON %s.%s (subject_id);\n\t\tCREATE INDEX ON %s.%s (expire_at DESC);\n\t`", ",", "s", ".", "schema", ",", "s", ".", "schema", ",", "s", ".", "table", ",", "int64", "(", "s", ".", "ttl", ".", "Seconds", "(", ")", ")", ",", "s", ".", "schema", ",", "s", ".", "table", ",", "s", ".", "schema", ",", "s", ".", "table", ",", "s", ".", "schema", ",", "s", ".", "table", ",", ")", "\n", "_", ",", "err", ":=", "s", ".", "<mask>", ".", "Exec", "(", "query", ")", "\n\n", "return", "err", "\n", "}" ]
21,159
all-21160
[ "Columns", "returns", "the", "list", "of", "the", "record", "columns", "." ]
[ "func", "(", "r", "Record", ")", "Columns", "(", ")", "[", "]", "string", "{", "cols", ":=", "[", "]", "string", "{", "}", "\n", "for", "k", ":=", "range", "r", "{", "cols", "=", "append", "(", "cols", ",", "k", ")", "\n", "}", "\n", "<mask>", ".", "Strings", "(", "cols", ")", "\n\n", "return", "cols", "\n", "}" ]
21,160
all-21161
[ "Implement", "the", "io", ".", "Reader", "interface" ]
[ "func", "(", "f", "FileEntry", ")", "Read", "(", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "file", ":=", "f", ".", "pbo", ".", "file", "\n\n", "offset", ",", "err", ":=", "file", ".", "Seek", "(", "0", ",", "os", ".", "SEEK_CUR", ")", "\n", "if", "offset", ">=", "f", ".", "dataOffset", "+", "int64", "(", "f", ".", "DataBlockSize", ")", "{", "return", "0", ",", "io", ".", "EOF", "\n", "}", "\n\n", "// If the offset in the file we're in + length of the buffer is greater than the end of the file,", "// then instead read in fileEndOffset - currentOffset bytes", "if", "<mask>", "+", "int64", "(", "len", "(", "p", ")", ")", ">", "f", ".", "dataOffset", "+", "int64", "(", "f", ".", "DataBlockSize", ")", "{", "remainingBytes", ":=", "(", "f", ".", "dataOffset", "+", "int64", "(", "f", ".", "DataBlockSize", ")", ")", "-", "offset", "\n\n", "return", "file", ".", "Read", "(", "p", "[", ":", "remainingBytes", "]", ")", "\n", "}", "\n\n", "return", "file", ".", "Read", "(", "p", ")", "\n", "}" ]
21,161
all-21162
[ "Do", "executes", "Input", ".", "setIgnoreInputEvents", "against", "the", "provided", "context", "." ]
[ "func", "(", "p", "*", "SetIgnoreInputEventsParams", ")", "Do", "(", "ctx", "context", ".", "<mask>", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandSetIgnoreInputEvents", ",", "p", ",", "nil", ")", "\n", "}" ]
21,162
all-21163
[ "TODO", ":", "TEST" ]
[ "func", "(", "cdc", "*", "Codec", ")", "encodeReflectJSONMap", "(", "w", "io", ".", "<mask>", ",", "info", "*", "TypeInfo", ",", "rv", "reflect", ".", "Value", ",", "fopts", "FieldOptions", ")", "(", "err", "error", ")", "{", "if", "printLog", "{", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n", "defer", "func", "(", ")", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "err", ")", "\n", "}", "(", ")", "\n", "}", "\n\n", "// Part 1.", "err", "=", "writeStr", "(", "w", ",", "`{`", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "// Part 2.", "defer", "func", "(", ")", "{", "if", "err", "==", "nil", "{", "err", "=", "writeStr", "(", "w", ",", "`}`", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "// Ensure that the map key type is a string.", "if", "rv", ".", "Type", "(", ")", ".", "Key", "(", ")", ".", "Kind", "(", ")", "!=", "reflect", ".", "String", "{", "err", "=", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n\n", "var", "writeComma", "=", "false", "\n", "for", "_", ",", "krv", ":=", "range", "rv", ".", "MapKeys", "(", ")", "{", "// Get dereferenced object value and info.", "var", "vrv", ",", "_", ",", "isNil", "=", "derefPointers", "(", "rv", ".", "MapIndex", "(", "krv", ")", ")", "\n\n", "// Add a comma if we need to.", "if", "writeComma", "{", "err", "=", "writeStr", "(", "w", ",", "`,`", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "writeComma", "=", "false", "\n", "}", "\n", "// Write field name.", "err", "=", "invokeStdlibJSONMarshal", "(", "w", ",", "krv", ".", "Interface", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "// Write colon.", "err", "=", "writeStr", "(", "w", ",", "`:`", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "// Write field value.", "if", "isNil", "{", "err", "=", "writeStr", "(", "w", ",", "`null`", ")", "\n", "}", "else", "{", "var", "vinfo", "*", "TypeInfo", "\n", "vinfo", ",", "err", "=", "cdc", ".", "getTypeInfo_wlock", "(", "vrv", ".", "Type", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "err", "=", "cdc", ".", "encodeReflectJSON", "(", "w", ",", "vinfo", ",", "vrv", ",", "fopts", ")", "// pass through fopts", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "writeComma", "=", "true", "\n", "}", "\n", "return", "\n\n", "}" ]
21,163
all-21164
[ "Set", "is", "required", "for", "kingpin", "interfaces", "to", "allow", "command", "line", "params", "to", "be", "set", "to", "our", "map", "datatype" ]
[ "func", "(", "o", "*", "ListUint8Option", ")", "<mask>", "(", "value", "string", ")", "error", "{", "val", ":=", "Uint8Option", "{", "}", "\n", "val", ".", "Set", "(", "value", ")", "\n", "*", "o", "=", "append", "(", "*", "o", ",", "val", ")", "\n", "return", "nil", "\n", "}" ]
21,164
all-21165
[ "initTables", "replaces", "s", ".", "tables", "with", "given", "tables", ".", "This", "is", "done", "during", "loading", "." ]
[ "func", "(", "s", "*", "levelHandler", ")", "initTables", "(", "tables", "[", "]", "*", "table", ".", "Table", ")", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n\n", "s", ".", "tables", "=", "tables", "\n", "s", ".", "totalSize", "=", "0", "\n", "for", "_", ",", "t", ":=", "range", "tables", "{", "s", ".", "totalSize", "+=", "t", ".", "Size", "(", ")", "\n", "}", "\n\n", "if", "s", ".", "level", "==", "0", "{", "// Key range will overlap. Just sort by fileID in ascending order", "// because newer tables are at the end of level 0.", "<mask>", ".", "Slice", "(", "s", ".", "tables", ",", "func", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "s", ".", "tables", "[", "i", "]", ".", "ID", "(", ")", "<", "s", ".", "tables", "[", "j", "]", ".", "ID", "(", ")", "\n", "}", ")", "\n", "}", "else", "{", "// Sort tables by keys.", "sort", ".", "Slice", "(", "s", ".", "tables", ",", "func", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "y", ".", "CompareKeys", "(", "s", ".", "tables", "[", "i", "]", ".", "Smallest", "(", ")", ",", "s", ".", "tables", "[", "j", "]", ".", "Smallest", "(", ")", ")", "<", "0", "\n", "}", ")", "\n", "}", "\n", "}" ]
21,165
all-21166
[ "SetLimits", "set", "new", "ProgressBar", "limits", ".", "The", "current", "value", "is", "adjusted", "if", "it", "exceeds", "new", "limits" ]
[ "func", "(", "b", "*", "ProgressBar", ")", "SetLimits", "(", "min", ",", "max", "int", ")", "{", "b", ".", "min", "=", "min", "\n", "b", ".", "max", "=", "<mask>", "\n\n", "if", "b", ".", "value", "<", "b", ".", "min", "{", "b", ".", "value", "=", "min", "\n", "}", "\n", "if", "b", ".", "value", ">", "b", ".", "max", "{", "b", ".", "value", "=", "max", "\n", "}", "\n", "}" ]
21,166
all-21167
[ "Draw", "draws", "the", "board", "to", "the", "given", "boardImage", "." ]
[ "func", "(", "b", "*", "Board", ")", "Draw", "(", "boardImage", "*", "ebiten", ".", "<mask>", ")", "{", "boardImage", ".", "Fill", "(", "frameColor", ")", "\n", "for", "j", ":=", "0", ";", "j", "<", "b", ".", "size", ";", "j", "++", "{", "for", "i", ":=", "0", ";", "i", "<", "b", ".", "size", ";", "i", "++", "{", "v", ":=", "0", "\n", "op", ":=", "&", "ebiten", ".", "DrawImageOptions", "{", "}", "\n", "x", ":=", "i", "*", "tileSize", "+", "(", "i", "+", "1", ")", "*", "tileMargin", "\n", "y", ":=", "j", "*", "tileSize", "+", "(", "j", "+", "1", ")", "*", "tileMargin", "\n", "op", ".", "GeoM", ".", "Translate", "(", "float64", "(", "x", ")", ",", "float64", "(", "y", ")", ")", "\n", "r", ",", "g", ",", "b", ",", "a", ":=", "colorToScale", "(", "tileBackgroundColor", "(", "v", ")", ")", "\n", "op", ".", "ColorM", ".", "Scale", "(", "r", ",", "g", ",", "b", ",", "a", ")", "\n", "boardImage", ".", "DrawImage", "(", "tileImage", ",", "op", ")", "\n", "}", "\n", "}", "\n", "animatingTiles", ":=", "map", "[", "*", "Tile", "]", "struct", "{", "}", "{", "}", "\n", "nonAnimatingTiles", ":=", "map", "[", "*", "Tile", "]", "struct", "{", "}", "{", "}", "\n", "for", "t", ":=", "range", "b", ".", "tiles", "{", "if", "t", ".", "IsMoving", "(", ")", "{", "animatingTiles", "[", "t", "]", "=", "struct", "{", "}", "{", "}", "\n", "}", "else", "{", "nonAnimatingTiles", "[", "t", "]", "=", "struct", "{", "}", "{", "}", "\n", "}", "\n", "}", "\n", "for", "t", ":=", "range", "nonAnimatingTiles", "{", "t", ".", "Draw", "(", "boardImage", ")", "\n", "}", "\n", "for", "t", ":=", "range", "animatingTiles", "{", "t", ".", "Draw", "(", "boardImage", ")", "\n", "}", "\n", "}" ]
21,167
all-21168
[ "doRequestWithRetries", "performs", "an", "HTTP", "request", "repeatedly", "for", "maxTime", "or", "until", "no", "error", "and", "no", "acceptable", "HTTP", "response", "code", "was", "returned", "." ]
[ "func", "(", "client", "*", "Client", ")", "doRequestWithRetries", "(", "req", "*", "http", ".", "Request", ",", "maxTime", "time", ".", "Duration", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "var", "(", "err", "error", "\n", "resp", "*", "http", ".", "Response", "\n", "bo", "=", "backoff", ".", "NewExponentialBackOff", "(", ")", "\n", "body", "[", "]", "byte", "\n", ")", "\n\n", "bo", ".", "MaxElapsedTime", "=", "maxTime", "\n\n", "// Save the body for retries", "if", "req", ".", "Body", "!=", "nil", "{", "body", ",", "err", "=", "ioutil", ".", "ReadAll", "(", "req", ".", "Body", ")", "\n", "if", "err", "!=", "nil", "{", "return", "resp", ",", "err", "\n", "}", "\n", "}", "\n\n", "operation", ":=", "func", "(", ")", "error", "{", "if", "body", "!=", "nil", "{", "r", ":=", "<mask>", ".", "NewReader", "(", "body", ")", "\n", "req", ".", "Body", "=", "ioutil", ".", "NopCloser", "(", "r", ")", "\n", "}", "\n\n", "resp", ",", "err", "=", "client", ".", "HttpClient", ".", "Do", "(", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "resp", ".", "StatusCode", ">=", "200", "&&", "resp", ".", "StatusCode", "<", "300", "{", "// 2xx all done", "return", "nil", "\n", "}", "else", "if", "resp", ".", "StatusCode", ">=", "400", "&&", "resp", ".", "StatusCode", "<", "500", "{", "// 4xx are not retryable", "return", "nil", "\n", "}", "\n\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "resp", ".", "StatusCode", ")", "\n", "}", "\n\n", "err", "=", "backoff", ".", "Retry", "(", "operation", ",", "bo", ")", "\n\n", "return", "resp", ",", "err", "\n", "}" ]
21,168
all-21169
[ "podPort", "extracts", "the", "proper", "port", "for", "the", "address", "from", "the", "given", "pod", "for", "a", "non", "-", "empty", "annotation", ".", "Pre", "-", "condition", ":", "annotation", "is", "non", "-", "empty" ]
[ "func", "podPort", "(", "pod", "*", "corev1", ".", "Pod", ",", "annotation", "string", ",", "host", "bool", ")", "(", "int32", ",", "error", ")", "{", "// First look for a matching port matching the value of the annotation.", "for", "_", ",", "container", ":=", "range", "pod", ".", "Spec", ".", "Containers", "{", "for", "_", ",", "portDef", ":=", "<mask>", "container", ".", "Ports", "{", "if", "portDef", ".", "Name", "==", "annotation", "{", "if", "host", "{", "// It is possible for HostPort to be zero, if that is the", "// case then we ignore this port.", "if", "portDef", ".", "HostPort", "==", "0", "{", "continue", "\n", "}", "\n\n", "return", "portDef", ".", "HostPort", ",", "nil", "\n", "}", "\n\n", "return", "portDef", ".", "ContainerPort", ",", "nil", "\n", "}", "\n", "}", "\n", "}", "\n\n", "// Otherwise assume that the port is a numeric value.", "v", ",", "err", ":=", "strconv", ".", "ParseInt", "(", "annotation", ",", "0", ",", "32", ")", "\n", "return", "int32", "(", "v", ")", ",", "err", "\n", "}" ]
21,169
all-21170
[ "Exec", "executes", "the", "drawTrianglesCommand", "." ]
[ "func", "(", "c", "*", "drawTrianglesCommand", ")", "Exec", "(", "indexOffset", "int", ")", "error", "{", "// TODO: Is it ok not to bind any framebuffer here?", "if", "c", ".", "nindices", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "c", ".", "dst", ".", "<mask>", ".", "SetAsDestination", "(", ")", "\n", "c", ".", "src", ".", "image", ".", "SetAsSource", "(", ")", "\n", "if", "err", ":=", "theGraphicsDriver", ".", "Draw", "(", "c", ".", "nindices", ",", "indexOffset", ",", "c", ".", "mode", ",", "c", ".", "color", ",", "c", ".", "filter", ",", "c", ".", "address", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "nil", "\n", "}" ]
21,170
all-21171
[ "Handle", "increments", "Prometheus", "counter", "metrics", "based", "on", "record", "log", "level", "." ]
[ "func", "(", "h", "*", "Handler", ")", "Handle", "(", "record", "*", "logging", ".", "Record", ")", "error", "{", "switch", "record", ".", "Level", "{", "<mask>", "logging", ".", "EMERGENCY", ":", "h", ".", "Counter", ".", "emergencyCounter", ".", "Inc", "(", ")", "\n", "case", "logging", ".", "ALERT", ":", "h", ".", "Counter", ".", "alertCounter", ".", "Inc", "(", ")", "\n", "case", "logging", ".", "CRITICAL", ":", "h", ".", "Counter", ".", "criticalCounter", ".", "Inc", "(", ")", "\n", "case", "logging", ".", "ERROR", ":", "h", ".", "Counter", ".", "errorCounter", ".", "Inc", "(", ")", "\n", "case", "logging", ".", "WARNING", ":", "h", ".", "Counter", ".", "warningCounter", ".", "Inc", "(", ")", "\n", "case", "logging", ".", "NOTICE", ":", "h", ".", "Counter", ".", "noticeCounter", ".", "Inc", "(", ")", "\n", "case", "logging", ".", "INFO", ":", "h", ".", "Counter", ".", "infoCounter", ".", "Inc", "(", ")", "\n", "case", "logging", ".", "DEBUG", ":", "h", ".", "Counter", ".", "debugCounter", ".", "Inc", "(", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
21,171
all-21172
[ "SetMediaText", "modifies", "the", "rule", "selector", ".", "See", ":", "https", ":", "//", "chromedevtools", ".", "github", ".", "io", "/", "devtools", "-", "protocol", "/", "tot", "/", "CSS#method", "-", "setMediaText", "parameters", ":", "styleSheetID", "range", "text" ]
[ "func", "SetMediaText", "(", "styleSheetID", "StyleSheetID", ",", "rangeVal", "*", "SourceRange", ",", "text", "string", ")", "*", "SetMediaTextParams", "{", "return", "&", "SetMediaTextParams", "{", "StyleSheetID", ":", "styleSheetID", ",", "Range", ":", "rangeVal", ",", "<mask>", ":", "text", ",", "}", "\n", "}" ]
21,172
all-21173
[ "render", "multiple", "sets", "of", "primitives", "from", "array", "data" ]
[ "func", "MultiDrawArrays", "(", "mode", "uint32", ",", "first", "*", "int32", ",", "count", "*", "int32", ",", "drawcount", "int32", ")", "{", "C", ".", "glowMultiDrawArrays", "(", "gpMultiDrawArrays", ",", "(", "C", ".", "GLenum", ")", "(", "mode", ")", ",", "(", "*", "C", ".", "GLint", ")", "(", "unsafe", ".", "Pointer", "(", "first", ")", ")", ",", "(", "*", "C", ".", "GLsizei", ")", "(", "unsafe", ".", "Pointer", "(", "<mask>", ")", ")", ",", "(", "C", ".", "GLsizei", ")", "(", "drawcount", ")", ")", "\n", "}" ]
21,173
all-21174
[ "ListFirewallRules", "lists", "all", "firewall", "rules" ]
[ "func", "(", "c", "*", "<mask>", ")", "ListFirewallRules", "(", "dcID", "string", ",", "serverID", "string", ",", "nicID", "string", ")", "(", "*", "FirewallRules", ",", "error", ")", "{", "url", ":=", "fwruleColPath", "(", "dcID", ",", "serverID", ",", "nicID", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "FirewallRules", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Get", "(", "url", ",", "ret", ",", "http", ".", "StatusOK", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
21,174
all-21175
[ "GetOrderDir", "returns", "the", "OrderDir", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "c", "*", "ChangeRequest", ")", "GetOrderDir", "(", ")", "<mask>", "{", "if", "c", "==", "nil", "||", "c", ".", "OrderDir", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "c", ".", "OrderDir", "\n", "}" ]
21,175
all-21176
[ "/", "*", "ClearLoggers", "will", "shut", "down", "and", "remove", "any", "loggers", "added", "to", "the", "Base", ".", "If", "an", "error", "occurs", "while", "shutting", "down", "one", "of", "the", "loggers", "the", "list", "will", "not", "be", "cleared", "but", "any", "loggers", "that", "have", "already", "been", "shut", "down", "before", "the", "error", "occurred", "will", "remain", "shut", "down", "." ]
[ "func", "(", "b", "*", "Base", ")", "ClearLoggers", "(", ")", "error", "{", "for", "_", ",", "logger", ":=", "range", "b", ".", "loggers", "{", "err", ":=", "logger", ".", "ShutdownLogger", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "b", ".", "loggers", "=", "make", "(", "[", "]", "Logger", ",", "0", ")", "\n", "b", ".", "hookPreQueue", "=", "<mask>", "(", "[", "]", "HookPreQueue", ",", "0", ")", "\n\n", "return", "nil", "\n", "}" ]
21,176
all-21177
[ "GetLineWidth", "returns", "the", "LineWidth", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "t", "*", "TimeseriesRequestStyle", ")", "GetLineWidth", "(", ")", "string", "{", "if", "t", "==", "nil", "||", "t", ".", "LineWidth", "==", "nil", "{", "<mask>", "\"", "\"", "\n", "}", "\n", "return", "*", "t", ".", "LineWidth", "\n", "}" ]
21,177
all-21178
[ "EtagCheck", "validates", "the", "hash", "of", "the", "current", "state", "with", "the", "hash", "provided", "by", "the", "client" ]
[ "func", "EtagCheck", "(", "r", "*", "<mask>", ".", "Request", ",", "data", "interface", "{", "}", ")", "error", "{", "match", ":=", "r", ".", "Header", ".", "Get", "(", "\"", "\"", ")", "\n", "if", "match", "==", "\"", "\"", "{", "return", "nil", "\n", "}", "\n\n", "hash", ",", "err", ":=", "EtagHash", "(", "data", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "hash", "!=", "match", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "hash", ",", "match", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
21,178
all-21179
[ "AgentMetadataHandler", "creates", "response", "for", "v1", "/", "metadata", "API", "." ]
[ "func", "AgentMetadataHandler", "(", "containerInstanceArn", "*", "string", ",", "cfg", "*", "config", ".", "Config", ")", "func", "(", "<mask>", ".", "ResponseWriter", ",", "*", "http", ".", "Request", ")", "{", "return", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "resp", ":=", "&", "MetadataResponse", "{", "Cluster", ":", "cfg", ".", "Cluster", ",", "ContainerInstanceArn", ":", "containerInstanceArn", ",", "Version", ":", "agentversion", ".", "String", "(", ")", ",", "}", "\n", "responseJSON", ",", "_", ":=", "json", ".", "Marshal", "(", "resp", ")", "\n", "utils", ".", "WriteJSONToResponse", "(", "w", ",", "http", ".", "StatusOK", ",", "responseJSON", ",", "utils", ".", "RequestTypeAgentMetadata", ")", "\n", "}", "\n", "}" ]
21,179
all-21180
[ "/", "*", "LoadConfiguration", "takes", "a", "path", "treats", "it", "as", "a", "file", "and", "scans", "it", "for", "an", "ini", "configuration", "." ]
[ "func", "LoadConfiguration", "(", "path", "string", ")", "(", "*", "Config", ",", "error", ")", "{", "config", ":=", "new", "(", "Config", ")", "\n", "err", ":=", "config", ".", "InitializeFromPath", "(", "<mask>", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "config", ",", "nil", "\n", "}" ]
21,180
all-21181
[ "NewReader", "returns", "a", "reader", "that", "reads", "typed", "values", "from", "the", "reader", "." ]
[ "func", "NewReader", "(", "reader", "<mask>", ".", "Reader", ")", "*", "Reader", "{", "r", ":=", "readerPool", ".", "Get", "(", ")", ".", "(", "*", "Reader", ")", "\n", "r", ".", "reader", "=", "reader", "\n", "r", ".", "err", "=", "nil", "\n", "return", "r", "\n", "}" ]
21,181
all-21182
[ "SetPrintPages", "()", "is", "a", "wrapper", "around", "gtk_print_settings_set_print_pages", "()", "." ]
[ "func", "(", "ps", "*", "PrintSettings", ")", "SetPrintPages", "(", "pages", "PrintPages", ")", "{", "C", ".", "gtk_print_settings_set_print_pages", "(", "ps", ".", "native", "(", ")", ",", "C", ".", "GtkPrintPages", "(", "<mask>", ")", ")", "\n", "}" ]
21,182
all-21183
[ "createFiles", "creates", "all", "the", "log", "files", "for", "severity", "from", "sev", "down", "to", "infoLog", ".", "l", ".", "mu", "is", "held", "." ]
[ "func", "(", "l", "*", "Log", ")", "createFiles", "(", "sev", "Severity", ")", "error", "{", "<mask>", ":=", "time", ".", "Now", "(", ")", "\n", "// Files are created in decreasing severity order, so as soon as we find one", "// has already been created, we can stop.", "for", "s", ":=", "sev", ";", "s", ">=", "InfoLog", "&&", "l", ".", "file", "[", "s", "]", "==", "nil", ";", "s", "--", "{", "w", ",", "err", ":=", "newFlushSyncWriter", "(", "l", ",", "s", ",", "now", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "l", ".", "file", "[", "s", "]", "=", "w", "\n", "}", "\n", "return", "nil", "\n", "}" ]
21,183
all-21184
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "GetRequestPostDataReturns", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "<mask>", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoNetwork32", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
21,184
all-21185
[ "tickHeartbeat", "is", "run", "by", "leaders", "to", "send", "a", "MsgBeat", "after", "r", ".", "heartbeatTimeout", "." ]
[ "func", "(", "r", "*", "raft", ")", "tickHeartbeat", "(", ")", "{", "r", ".", "heartbeatElapsed", "++", "\n", "r", ".", "electionElapsed", "++", "\n\n", "if", "r", ".", "electionElapsed", ">=", "r", ".", "electionTimeout", "{", "r", ".", "electionElapsed", "=", "0", "\n", "if", "r", ".", "checkQuorum", "{", "r", ".", "Step", "(", "pb", ".", "<mask>", "{", "From", ":", "r", ".", "id", ",", "Type", ":", "pb", ".", "MsgCheckQuorum", "}", ")", "\n", "}", "\n", "// If current leader cannot transfer leadership in electionTimeout, it becomes leader again.", "if", "r", ".", "state", "==", "StateLeader", "&&", "r", ".", "leadTransferee", "!=", "None", "{", "r", ".", "abortLeaderTransfer", "(", ")", "\n", "}", "\n", "}", "\n\n", "if", "r", ".", "state", "!=", "StateLeader", "{", "return", "\n", "}", "\n\n", "if", "r", ".", "heartbeatElapsed", ">=", "r", ".", "heartbeatTimeout", "{", "r", ".", "heartbeatElapsed", "=", "0", "\n", "r", ".", "Step", "(", "pb", ".", "Message", "{", "From", ":", "r", ".", "id", ",", "Type", ":", "pb", ".", "MsgBeat", "}", ")", "\n", "}", "\n", "}" ]
21,185
all-21186
[ "Specify", "the", "value", "of", "a", "uniform", "variable", "for", "a", "specified", "program", "object" ]
[ "func", "ProgramUniform3f", "(", "program", "uint32", ",", "<mask>", "int32", ",", "v0", "float32", ",", "v1", "float32", ",", "v2", "float32", ")", "{", "C", ".", "glowProgramUniform3f", "(", "gpProgramUniform3f", ",", "(", "C", ".", "GLuint", ")", "(", "program", ")", ",", "(", "C", ".", "GLint", ")", "(", "location", ")", ",", "(", "C", ".", "GLfloat", ")", "(", "v0", ")", ",", "(", "C", ".", "GLfloat", ")", "(", "v1", ")", ",", "(", "C", ".", "GLfloat", ")", "(", "v2", ")", ")", "\n", "}" ]
21,186
all-21187
[ "NodeRemove", "removes", "the", "node", "with", "the", "given", "id", "." ]
[ "func", "(", "c", "*", "ClusterTx", ")", "NodeRemove", "(", "id", "int64", ")", "error", "{", "result", ",", "err", ":=", "c", ".", "<mask>", ".", "Exec", "(", "\"", "\"", ",", "id", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "n", ",", "err", ":=", "result", ".", "RowsAffected", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "n", "!=", "1", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "n", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
21,187
all-21188
[ "ServerConfig", "generates", "a", "tls", ".", "Config", "object", "for", "use", "by", "an", "HTTP", "server", "." ]
[ "func", "(", "<mask>", "TLSInfo", ")", "ServerConfig", "(", ")", "(", "*", "tls", ".", "Config", ",", "error", ")", "{", "cfg", ",", "err", ":=", "info", ".", "baseConfig", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "cfg", ".", "ClientAuth", "=", "tls", ".", "NoClientCert", "\n", "if", "info", ".", "TrustedCAFile", "!=", "\"", "\"", "||", "info", ".", "ClientCertAuth", "{", "cfg", ".", "ClientAuth", "=", "tls", ".", "RequireAndVerifyClientCert", "\n", "}", "\n\n", "cs", ":=", "info", ".", "cafiles", "(", ")", "\n", "if", "len", "(", "cs", ")", ">", "0", "{", "cp", ",", "err", ":=", "tlsutil", ".", "NewCertPool", "(", "cs", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "cfg", ".", "ClientCAs", "=", "cp", "\n", "}", "\n\n", "// \"h2\" NextProtos is necessary for enabling HTTP2 for go's HTTP server", "cfg", ".", "NextProtos", "=", "[", "]", "string", "{", "\"", "\"", "}", "\n\n", "return", "cfg", ",", "nil", "\n", "}" ]
21,188
all-21189
[ "Shutdown", "will", "close", "any", "existing", "connections", ";", "note", "that", "Startup", "may", "automatically", "get", "called", "with", "any", "further", "activity", "but", "it", "will", "use", "a", "new", "connection", ".", "To", "ensure", "the", "groupStore", "has", "no", "further", "activity", "use", "Close", "." ]
[ "func", "(", "stor", "*", "groupStore", ")", "Shutdown", "(", "ctx", "context", ".", "<mask>", ")", "error", "{", "stor", ".", "lock", ".", "Lock", "(", ")", "\n", "err", ":=", "stor", ".", "shutdown", "(", ")", "\n", "stor", ".", "lock", ".", "Unlock", "(", ")", "\n", "return", "err", "\n", "}" ]
21,189
all-21190
[ "ObjectStat", "gets", "stats", "for", "the", "DAG", "object", "named", "by", "key", ".", "It", "returns", "the", "stats", "of", "the", "requested", "Object", "or", "an", "error", "." ]
[ "func", "(", "s", "*", "Shell", ")", "ObjectStat", "(", "key", "string", ")", "(", "*", "ObjectStats", ",", "error", ")", "{", "<mask>", "stat", "ObjectStats", "\n", "err", ":=", "s", ".", "Request", "(", "\"", "\"", ",", "key", ")", ".", "Exec", "(", "context", ".", "Background", "(", ")", ",", "&", "stat", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "stat", ",", "nil", "\n", "}" ]
21,190
all-21191
[ "NewStmt", "return", "a", "new", "statement", "code", "snippet", "for", "running", "the", "given", "kind", "of", "query", "against", "the", "given", "database", "entity", "." ]
[ "func", "NewStmt", "(", "database", ",", "pkg", ",", "entity", ",", "kind", "string", ",", "config", "map", "[", "string", "]", "string", ")", "(", "*", "Stmt", ",", "error", ")", "{", "packages", ",", "err", ":=", "Packages", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "stmt", ":=", "&", "Stmt", "{", "db", ":", "<mask>", ",", "pkg", ":", "pkg", ",", "entity", ":", "entity", ",", "kind", ":", "kind", ",", "config", ":", "config", ",", "packages", ":", "packages", ",", "}", "\n\n", "return", "stmt", ",", "nil", "\n", "}" ]
21,191
all-21192
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "EventJavascriptDialogOpening", ")", "UnmarshalJSON", "(", "data", "[", "]", "<mask>", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoPage56", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
21,192
all-21193
[ "ShouldCreateWithSSMSecret", "returns", "true", "if", "this", "container", "needs", "to", "get", "secret", "value", "from", "SSM", "Parameter", "Store" ]
[ "func", "(", "c", "*", "Container", ")", "ShouldCreateWithSSMSecret", "(", ")", "bool", "{", "c", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "lock", ".", "RUnlock", "(", ")", "\n\n", "// Secrets field will be nil if there is no secrets for container", "if", "c", ".", "Secrets", "==", "nil", "{", "return", "false", "\n", "}", "\n\n", "for", "_", ",", "secret", ":=", "range", "c", ".", "Secrets", "{", "if", "<mask>", ".", "Provider", "==", "SecretProviderSSM", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
21,193
all-21194
[ "MustGenerateRandomBytes", "generates", "random", "bytes", "or", "panics", "if", "it", "can", "t" ]
[ "func", "MustGenerateRandomBytes", "(", "length", "int", ")", "[", "]", "byte", "{", "res", ",", "err", ":=", "GenerateRandomBytes", "(", "<mask>", ")", "\n\n", "if", "err", "!=", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "res", "\n", "}" ]
21,194
all-21195
[ "Failf", "outputs", "formatted", "Failed", "log" ]
[ "func", "(", "g", "*", "Glg", ")", "Failf", "(", "<mask>", "string", ",", "val", "...", "interface", "{", "}", ")", "error", "{", "return", "g", ".", "out", "(", "FAIL", ",", "format", ",", "val", "...", ")", "\n", "}" ]
21,195
all-21196
[ "AccelMapLookupEntry", "is", "a", "wrapper", "around", "gtk_accel_map_lookup_entry", "()", "." ]
[ "func", "AccelMapLookupEntry", "(", "path", "string", ")", "*", "AccelKey", "{", "cstr", ":=", "C", ".", "CString", "(", "path", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cstr", ")", ")", "\n\n", "<mask>", "v", "*", "C", ".", "struct__GtkAccelKey", "\n\n", "C", ".", "gtk_accel_map_lookup_entry", "(", "(", "*", "C", ".", "gchar", ")", "(", "cstr", ")", ",", "v", ")", "\n", "return", "wrapAccelKey", "(", "v", ")", "\n", "}" ]
21,196
all-21197
[ "IsRunningImageAllowed", "returns", "true", "iff", "the", "policy", "allows", "running", "the", "image", ".", "If", "it", "returns", "false", "err", "must", "be", "non", "-", "nil", "and", "should", "be", "an", "PolicyRequirementError", "if", "evaluation", "succeeded", "but", "the", "result", "was", "rejection", ".", "WARNING", ":", "This", "validates", "signatures", "and", "the", "manifest", "but", "does", "not", "download", "or", "validate", "the", "layers", ".", "Users", "must", "validate", "that", "the", "layers", "match", "their", "expected", "digests", "." ]
[ "func", "(", "pc", "*", "PolicyContext", ")", "IsRunningImageAllowed", "(", "ctx", "context", ".", "Context", ",", "image", "types", ".", "UnparsedImage", ")", "(", "res", "bool", ",", "finalErr", "error", ")", "{", "if", "err", ":=", "pc", ".", "changeState", "(", "pcReady", ",", "pcInUse", ")", ";", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "defer", "func", "(", ")", "{", "if", "err", ":=", "pc", ".", "changeState", "(", "pcInUse", ",", "pcReady", ")", ";", "err", "!=", "nil", "{", "res", "=", "false", "\n", "finalErr", "=", "err", "\n", "}", "\n", "}", "(", ")", "\n\n", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "policyIdentityLogName", "(", "image", ".", "Reference", "(", ")", ")", ")", "\n", "reqs", ":=", "pc", ".", "requirementsForImageRef", "(", "image", ".", "Reference", "(", ")", ")", "\n\n", "if", "len", "(", "reqs", ")", "==", "0", "{", "return", "false", ",", "PolicyRequirementError", "(", "\"", "\"", ")", "\n", "}", "\n\n", "for", "reqNumber", ",", "req", ":=", "<mask>", "reqs", "{", "// FIXME: supply state", "allowed", ",", "err", ":=", "req", ".", "isRunningImageAllowed", "(", "ctx", ",", "image", ")", "\n", "if", "!", "allowed", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "reqNumber", ")", "\n", "return", "false", ",", "err", "\n", "}", "\n", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "reqNumber", ")", "\n", "}", "\n", "// We have tested that len(reqs) != 0, so at least one req must have explicitly allowed this image.", "logrus", ".", "Debugf", "(", "\"", "\"", ")", "\n", "return", "true", ",", "nil", "\n", "}" ]
21,197
all-21198
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "GetTargetInfoParams", ")", "UnmarshalJSON", "(", "<mask>", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoTarget9", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
21,198
all-21199
[ "CreateNetwork", "defines", "a", "new", "network", "using", "the", "provided", "Network", "struct" ]
[ "func", "(", "r", "*", "ProtocolLXD", ")", "CreateNetwork", "(", "network", "api", ".", "NetworksPost", ")", "error", "{", "if", "!", "r", ".", "HasExtension", "(", "\"", "\"", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\\\"", "\\\"", "\"", ")", "\n", "}", "\n\n", "// Send the request", "_", ",", "_", ",", "err", ":=", "r", ".", "query", "(", "\"", "\"", ",", "\"", "\"", ",", "<mask>", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
21,199
all-21200
[ "UpdateImage", "updates", "the", "image", "definition" ]
[ "func", "(", "r", "*", "ProtocolLXD", ")", "UpdateImage", "(", "fingerprint", "string", ",", "image", "api", ".", "ImagePut", ",", "ETag", "string", ")", "error", "{", "// Send the request", "_", ",", "_", ",", "err", ":=", "r", ".", "<mask>", "(", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "url", ".", "QueryEscape", "(", "fingerprint", ")", ")", ",", "image", ",", "ETag", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]