id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
131,500 | tendermint/tendermint | consensus/types/round_state.go | StringShort | func (rs *RoundState) StringShort() string {
return fmt.Sprintf(`RoundState{H:%v R:%v S:%v ST:%v}`,
rs.Height, rs.Round, rs.Step, rs.StartTime)
} | go | func (rs *RoundState) StringShort() string {
return fmt.Sprintf(`RoundState{H:%v R:%v S:%v ST:%v}`,
rs.Height, rs.Round, rs.Step, rs.StartTime)
} | [
"func",
"(",
"rs",
"*",
"RoundState",
")",
"StringShort",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"`RoundState{H:%v R:%v S:%v ST:%v}`",
",",
"rs",
".",
"Height",
",",
"rs",
".",
"Round",
",",
"rs",
".",
"Step",
",",
"rs",
".",
"S... | // StringShort returns a string | [
"StringShort",
"returns",
"a",
"string"
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/types/round_state.go#L197-L200 |
131,501 | tendermint/tendermint | types/validator.go | CompareProposerPriority | func (v *Validator) CompareProposerPriority(other *Validator) *Validator {
if v == nil {
return other
}
if v.ProposerPriority > other.ProposerPriority {
return v
} else if v.ProposerPriority < other.ProposerPriority {
return other
} else {
result := bytes.Compare(v.Address, other.Address)
if result < 0 {... | go | func (v *Validator) CompareProposerPriority(other *Validator) *Validator {
if v == nil {
return other
}
if v.ProposerPriority > other.ProposerPriority {
return v
} else if v.ProposerPriority < other.ProposerPriority {
return other
} else {
result := bytes.Compare(v.Address, other.Address)
if result < 0 {... | [
"func",
"(",
"v",
"*",
"Validator",
")",
"CompareProposerPriority",
"(",
"other",
"*",
"Validator",
")",
"*",
"Validator",
"{",
"if",
"v",
"==",
"nil",
"{",
"return",
"other",
"\n",
"}",
"\n",
"if",
"v",
".",
"ProposerPriority",
">",
"other",
".",
"Pro... | // Returns the one with higher ProposerPriority. | [
"Returns",
"the",
"one",
"with",
"higher",
"ProposerPriority",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/validator.go#L40-L59 |
131,502 | tendermint/tendermint | types/validator.go | ValidatorListString | func ValidatorListString(vals []*Validator) string {
chunks := make([]string, len(vals))
for i, val := range vals {
chunks[i] = fmt.Sprintf("%s:%d", val.Address, val.VotingPower)
}
return strings.Join(chunks, ",")
} | go | func ValidatorListString(vals []*Validator) string {
chunks := make([]string, len(vals))
for i, val := range vals {
chunks[i] = fmt.Sprintf("%s:%d", val.Address, val.VotingPower)
}
return strings.Join(chunks, ",")
} | [
"func",
"ValidatorListString",
"(",
"vals",
"[",
"]",
"*",
"Validator",
")",
"string",
"{",
"chunks",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"vals",
")",
")",
"\n",
"for",
"i",
",",
"val",
":=",
"range",
"vals",
"{",
"chunks",
"[",... | // ValidatorListString returns a prettified validator list for logging purposes. | [
"ValidatorListString",
"returns",
"a",
"prettified",
"validator",
"list",
"for",
"logging",
"purposes",
"."
] | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/validator.go#L73-L80 |
131,503 | tendermint/tendermint | types/validator.go | Bytes | func (v *Validator) Bytes() []byte {
return cdcEncode(struct {
PubKey crypto.PubKey
VotingPower int64
}{
v.PubKey,
v.VotingPower,
})
} | go | func (v *Validator) Bytes() []byte {
return cdcEncode(struct {
PubKey crypto.PubKey
VotingPower int64
}{
v.PubKey,
v.VotingPower,
})
} | [
"func",
"(",
"v",
"*",
"Validator",
")",
"Bytes",
"(",
")",
"[",
"]",
"byte",
"{",
"return",
"cdcEncode",
"(",
"struct",
"{",
"PubKey",
"crypto",
".",
"PubKey",
"\n",
"VotingPower",
"int64",
"\n",
"}",
"{",
"v",
".",
"PubKey",
",",
"v",
".",
"Votin... | // Bytes computes the unique encoding of a validator with a given voting power.
// These are the bytes that gets hashed in consensus. It excludes address
// as its redundant with the pubkey. This also excludes ProposerPriority
// which changes every round. | [
"Bytes",
"computes",
"the",
"unique",
"encoding",
"of",
"a",
"validator",
"with",
"a",
"given",
"voting",
"power",
".",
"These",
"are",
"the",
"bytes",
"that",
"gets",
"hashed",
"in",
"consensus",
".",
"It",
"excludes",
"address",
"as",
"its",
"redundant",
... | 4253e67c07c69be6d7f7263ab03944ce30a9fc90 | https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/validator.go#L86-L94 |
131,504 | go-sql-driver/mysql | utils.go | DeregisterTLSConfig | func DeregisterTLSConfig(key string) {
tlsConfigLock.Lock()
if tlsConfigRegistry != nil {
delete(tlsConfigRegistry, key)
}
tlsConfigLock.Unlock()
} | go | func DeregisterTLSConfig(key string) {
tlsConfigLock.Lock()
if tlsConfigRegistry != nil {
delete(tlsConfigRegistry, key)
}
tlsConfigLock.Unlock()
} | [
"func",
"DeregisterTLSConfig",
"(",
"key",
"string",
")",
"{",
"tlsConfigLock",
".",
"Lock",
"(",
")",
"\n",
"if",
"tlsConfigRegistry",
"!=",
"nil",
"{",
"delete",
"(",
"tlsConfigRegistry",
",",
"key",
")",
"\n",
"}",
"\n",
"tlsConfigLock",
".",
"Unlock",
... | // DeregisterTLSConfig removes the tls.Config associated with key. | [
"DeregisterTLSConfig",
"removes",
"the",
"tls",
".",
"Config",
"associated",
"with",
"key",
"."
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/utils.go#L74-L80 |
131,505 | go-sql-driver/mysql | utils.go | readBool | func readBool(input string) (value bool, valid bool) {
switch input {
case "1", "true", "TRUE", "True":
return true, true
case "0", "false", "FALSE", "False":
return false, true
}
// Not a valid bool value
return
} | go | func readBool(input string) (value bool, valid bool) {
switch input {
case "1", "true", "TRUE", "True":
return true, true
case "0", "false", "FALSE", "False":
return false, true
}
// Not a valid bool value
return
} | [
"func",
"readBool",
"(",
"input",
"string",
")",
"(",
"value",
"bool",
",",
"valid",
"bool",
")",
"{",
"switch",
"input",
"{",
"case",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
":",
"return",
"true",
",",
"true",
"\n",
"case"... | // Returns the bool value of the input.
// The 2nd return value indicates if the input was a valid bool value | [
"Returns",
"the",
"bool",
"value",
"of",
"the",
"input",
".",
"The",
"2nd",
"return",
"value",
"indicates",
"if",
"the",
"input",
"was",
"a",
"valid",
"bool",
"value"
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/utils.go#L93-L103 |
131,506 | go-sql-driver/mysql | utils.go | stringToInt | func stringToInt(b []byte) int {
val := 0
for i := range b {
val *= 10
val += int(b[i] - 0x30)
}
return val
} | go | func stringToInt(b []byte) int {
val := 0
for i := range b {
val *= 10
val += int(b[i] - 0x30)
}
return val
} | [
"func",
"stringToInt",
"(",
"b",
"[",
"]",
"byte",
")",
"int",
"{",
"val",
":=",
"0",
"\n",
"for",
"i",
":=",
"range",
"b",
"{",
"val",
"*=",
"10",
"\n",
"val",
"+=",
"int",
"(",
"b",
"[",
"i",
"]",
"-",
"0x30",
")",
"\n",
"}",
"\n",
"retur... | // treats string value as unsigned integer representation | [
"treats",
"string",
"value",
"as",
"unsigned",
"integer",
"representation"
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/utils.go#L423-L430 |
131,507 | go-sql-driver/mysql | utils.go | skipLengthEncodedString | func skipLengthEncodedString(b []byte) (int, error) {
// Get length
num, _, n := readLengthEncodedInteger(b)
if num < 1 {
return n, nil
}
n += int(num)
// Check data length
if len(b) >= n {
return n, nil
}
return n, io.EOF
} | go | func skipLengthEncodedString(b []byte) (int, error) {
// Get length
num, _, n := readLengthEncodedInteger(b)
if num < 1 {
return n, nil
}
n += int(num)
// Check data length
if len(b) >= n {
return n, nil
}
return n, io.EOF
} | [
"func",
"skipLengthEncodedString",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"// Get length",
"num",
",",
"_",
",",
"n",
":=",
"readLengthEncodedInteger",
"(",
"b",
")",
"\n",
"if",
"num",
"<",
"1",
"{",
"return",
"n",
",",... | // returns the number of bytes skipped and an error, in case the string is
// longer than the input slice | [
"returns",
"the",
"number",
"of",
"bytes",
"skipped",
"and",
"an",
"error",
"in",
"case",
"the",
"string",
"is",
"longer",
"than",
"the",
"input",
"slice"
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/utils.go#L453-L467 |
131,508 | go-sql-driver/mysql | utils.go | appendLengthEncodedInteger | func appendLengthEncodedInteger(b []byte, n uint64) []byte {
switch {
case n <= 250:
return append(b, byte(n))
case n <= 0xffff:
return append(b, 0xfc, byte(n), byte(n>>8))
case n <= 0xffffff:
return append(b, 0xfd, byte(n), byte(n>>8), byte(n>>16))
}
return append(b, 0xfe, byte(n), byte(n>>8), byte(n>>16... | go | func appendLengthEncodedInteger(b []byte, n uint64) []byte {
switch {
case n <= 250:
return append(b, byte(n))
case n <= 0xffff:
return append(b, 0xfc, byte(n), byte(n>>8))
case n <= 0xffffff:
return append(b, 0xfd, byte(n), byte(n>>8), byte(n>>16))
}
return append(b, 0xfe, byte(n), byte(n>>8), byte(n>>16... | [
"func",
"appendLengthEncodedInteger",
"(",
"b",
"[",
"]",
"byte",
",",
"n",
"uint64",
")",
"[",
"]",
"byte",
"{",
"switch",
"{",
"case",
"n",
"<=",
"250",
":",
"return",
"append",
"(",
"b",
",",
"byte",
"(",
"n",
")",
")",
"\n\n",
"case",
"n",
"<... | // encodes a uint64 value and appends it to the given bytes slice | [
"encodes",
"a",
"uint64",
"value",
"and",
"appends",
"it",
"to",
"the",
"given",
"bytes",
"slice"
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/utils.go#L502-L515 |
131,509 | go-sql-driver/mysql | utils.go | escapeStringBackslash | func escapeStringBackslash(buf []byte, v string) []byte {
pos := len(buf)
buf = reserveBuffer(buf, len(v)*2)
for i := 0; i < len(v); i++ {
c := v[i]
switch c {
case '\x00':
buf[pos] = '\\'
buf[pos+1] = '0'
pos += 2
case '\n':
buf[pos] = '\\'
buf[pos+1] = 'n'
pos += 2
case '\r':
buf[po... | go | func escapeStringBackslash(buf []byte, v string) []byte {
pos := len(buf)
buf = reserveBuffer(buf, len(v)*2)
for i := 0; i < len(v); i++ {
c := v[i]
switch c {
case '\x00':
buf[pos] = '\\'
buf[pos+1] = '0'
pos += 2
case '\n':
buf[pos] = '\\'
buf[pos+1] = 'n'
pos += 2
case '\r':
buf[po... | [
"func",
"escapeStringBackslash",
"(",
"buf",
"[",
"]",
"byte",
",",
"v",
"string",
")",
"[",
"]",
"byte",
"{",
"pos",
":=",
"len",
"(",
"buf",
")",
"\n",
"buf",
"=",
"reserveBuffer",
"(",
"buf",
",",
"len",
"(",
"v",
")",
"*",
"2",
")",
"\n\n",
... | // escapeStringBackslash is similar to escapeBytesBackslash but for string. | [
"escapeStringBackslash",
"is",
"similar",
"to",
"escapeBytesBackslash",
"but",
"for",
"string",
"."
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/utils.go#L579-L621 |
131,510 | go-sql-driver/mysql | utils.go | escapeStringQuotes | func escapeStringQuotes(buf []byte, v string) []byte {
pos := len(buf)
buf = reserveBuffer(buf, len(v)*2)
for i := 0; i < len(v); i++ {
c := v[i]
if c == '\'' {
buf[pos] = '\''
buf[pos+1] = '\''
pos += 2
} else {
buf[pos] = c
pos++
}
}
return buf[:pos]
} | go | func escapeStringQuotes(buf []byte, v string) []byte {
pos := len(buf)
buf = reserveBuffer(buf, len(v)*2)
for i := 0; i < len(v); i++ {
c := v[i]
if c == '\'' {
buf[pos] = '\''
buf[pos+1] = '\''
pos += 2
} else {
buf[pos] = c
pos++
}
}
return buf[:pos]
} | [
"func",
"escapeStringQuotes",
"(",
"buf",
"[",
"]",
"byte",
",",
"v",
"string",
")",
"[",
"]",
"byte",
"{",
"pos",
":=",
"len",
"(",
"buf",
")",
"\n",
"buf",
"=",
"reserveBuffer",
"(",
"buf",
",",
"len",
"(",
"v",
")",
"*",
"2",
")",
"\n\n",
"f... | // escapeStringQuotes is similar to escapeBytesQuotes but for string. | [
"escapeStringQuotes",
"is",
"similar",
"to",
"escapeBytesQuotes",
"but",
"for",
"string",
"."
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/utils.go#L647-L664 |
131,511 | go-sql-driver/mysql | utils.go | Set | func (ab *atomicBool) Set(value bool) {
if value {
atomic.StoreUint32(&ab.value, 1)
} else {
atomic.StoreUint32(&ab.value, 0)
}
} | go | func (ab *atomicBool) Set(value bool) {
if value {
atomic.StoreUint32(&ab.value, 1)
} else {
atomic.StoreUint32(&ab.value, 0)
}
} | [
"func",
"(",
"ab",
"*",
"atomicBool",
")",
"Set",
"(",
"value",
"bool",
")",
"{",
"if",
"value",
"{",
"atomic",
".",
"StoreUint32",
"(",
"&",
"ab",
".",
"value",
",",
"1",
")",
"\n",
"}",
"else",
"{",
"atomic",
".",
"StoreUint32",
"(",
"&",
"ab",... | // Set sets the value of the bool regardless of the previous value | [
"Set",
"sets",
"the",
"value",
"of",
"the",
"bool",
"regardless",
"of",
"the",
"previous",
"value"
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/utils.go#L693-L699 |
131,512 | go-sql-driver/mysql | utils.go | TrySet | func (ab *atomicBool) TrySet(value bool) bool {
if value {
return atomic.SwapUint32(&ab.value, 1) == 0
}
return atomic.SwapUint32(&ab.value, 0) > 0
} | go | func (ab *atomicBool) TrySet(value bool) bool {
if value {
return atomic.SwapUint32(&ab.value, 1) == 0
}
return atomic.SwapUint32(&ab.value, 0) > 0
} | [
"func",
"(",
"ab",
"*",
"atomicBool",
")",
"TrySet",
"(",
"value",
"bool",
")",
"bool",
"{",
"if",
"value",
"{",
"return",
"atomic",
".",
"SwapUint32",
"(",
"&",
"ab",
".",
"value",
",",
"1",
")",
"==",
"0",
"\n",
"}",
"\n",
"return",
"atomic",
"... | // TrySet sets the value of the bool and returns whether the value changed | [
"TrySet",
"sets",
"the",
"value",
"of",
"the",
"bool",
"and",
"returns",
"whether",
"the",
"value",
"changed"
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/utils.go#L702-L707 |
131,513 | go-sql-driver/mysql | utils.go | Value | func (ae *atomicError) Value() error {
if v := ae.value.Load(); v != nil {
// this will panic if the value doesn't implement the error interface
return v.(error)
}
return nil
} | go | func (ae *atomicError) Value() error {
if v := ae.value.Load(); v != nil {
// this will panic if the value doesn't implement the error interface
return v.(error)
}
return nil
} | [
"func",
"(",
"ae",
"*",
"atomicError",
")",
"Value",
"(",
")",
"error",
"{",
"if",
"v",
":=",
"ae",
".",
"value",
".",
"Load",
"(",
")",
";",
"v",
"!=",
"nil",
"{",
"// this will panic if the value doesn't implement the error interface",
"return",
"v",
".",
... | // Value returns the current error value | [
"Value",
"returns",
"the",
"current",
"error",
"value"
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/utils.go#L722-L728 |
131,514 | go-sql-driver/mysql | packets.go | readResultOK | func (mc *mysqlConn) readResultOK() error {
data, err := mc.readPacket()
if err != nil {
return err
}
if data[0] == iOK {
return mc.handleOkPacket(data)
}
return mc.handleErrorPacket(data)
} | go | func (mc *mysqlConn) readResultOK() error {
data, err := mc.readPacket()
if err != nil {
return err
}
if data[0] == iOK {
return mc.handleOkPacket(data)
}
return mc.handleErrorPacket(data)
} | [
"func",
"(",
"mc",
"*",
"mysqlConn",
")",
"readResultOK",
"(",
")",
"error",
"{",
"data",
",",
"err",
":=",
"mc",
".",
"readPacket",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"data",
"[",
"0",
"]",
... | // Returns error if Packet is not an 'Result OK'-Packet | [
"Returns",
"error",
"if",
"Packet",
"is",
"not",
"an",
"Result",
"OK",
"-",
"Packet"
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/packets.go#L512-L522 |
131,515 | go-sql-driver/mysql | packets.go | readUntilEOF | func (mc *mysqlConn) readUntilEOF() error {
for {
data, err := mc.readPacket()
if err != nil {
return err
}
switch data[0] {
case iERR:
return mc.handleErrorPacket(data)
case iEOF:
if len(data) == 5 {
mc.status = readStatus(data[3:])
}
return nil
}
}
} | go | func (mc *mysqlConn) readUntilEOF() error {
for {
data, err := mc.readPacket()
if err != nil {
return err
}
switch data[0] {
case iERR:
return mc.handleErrorPacket(data)
case iEOF:
if len(data) == 5 {
mc.status = readStatus(data[3:])
}
return nil
}
}
} | [
"func",
"(",
"mc",
"*",
"mysqlConn",
")",
"readUntilEOF",
"(",
")",
"error",
"{",
"for",
"{",
"data",
",",
"err",
":=",
"mc",
".",
"readPacket",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"switch",
"data",
... | // Reads Packets until EOF-Packet or an Error appears. Returns count of Packets read | [
"Reads",
"Packets",
"until",
"EOF",
"-",
"Packet",
"or",
"an",
"Error",
"appears",
".",
"Returns",
"count",
"of",
"Packets",
"read"
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/packets.go#L793-L810 |
131,516 | go-sql-driver/mysql | buffer.go | newBuffer | func newBuffer(nc net.Conn) buffer {
fg := make([]byte, defaultBufSize)
return buffer{
buf: fg,
nc: nc,
dbuf: [2][]byte{fg, nil},
}
} | go | func newBuffer(nc net.Conn) buffer {
fg := make([]byte, defaultBufSize)
return buffer{
buf: fg,
nc: nc,
dbuf: [2][]byte{fg, nil},
}
} | [
"func",
"newBuffer",
"(",
"nc",
"net",
".",
"Conn",
")",
"buffer",
"{",
"fg",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"defaultBufSize",
")",
"\n",
"return",
"buffer",
"{",
"buf",
":",
"fg",
",",
"nc",
":",
"nc",
",",
"dbuf",
":",
"[",
"2",
"]... | // newBuffer allocates and returns a new buffer. | [
"newBuffer",
"allocates",
"and",
"returns",
"a",
"new",
"buffer",
"."
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/buffer.go#L37-L44 |
131,517 | go-sql-driver/mysql | buffer.go | fill | func (b *buffer) fill(need int) error {
n := b.length
// fill data into its double-buffering target: if we've called
// flip on this buffer, we'll be copying to the background buffer,
// and then filling it with network data; otherwise we'll just move
// the contents of the current buffer to the front before filli... | go | func (b *buffer) fill(need int) error {
n := b.length
// fill data into its double-buffering target: if we've called
// flip on this buffer, we'll be copying to the background buffer,
// and then filling it with network data; otherwise we'll just move
// the contents of the current buffer to the front before filli... | [
"func",
"(",
"b",
"*",
"buffer",
")",
"fill",
"(",
"need",
"int",
")",
"error",
"{",
"n",
":=",
"b",
".",
"length",
"\n",
"// fill data into its double-buffering target: if we've called",
"// flip on this buffer, we'll be copying to the background buffer,",
"// and then fil... | // fill reads into the buffer until at least _need_ bytes are in it | [
"fill",
"reads",
"into",
"the",
"buffer",
"until",
"at",
"least",
"_need_",
"bytes",
"are",
"in",
"it"
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/buffer.go#L54-L112 |
131,518 | go-sql-driver/mysql | buffer.go | readNext | func (b *buffer) readNext(need int) ([]byte, error) {
if b.length < need {
// refill
if err := b.fill(need); err != nil {
return nil, err
}
}
offset := b.idx
b.idx += need
b.length -= need
return b.buf[offset:b.idx], nil
} | go | func (b *buffer) readNext(need int) ([]byte, error) {
if b.length < need {
// refill
if err := b.fill(need); err != nil {
return nil, err
}
}
offset := b.idx
b.idx += need
b.length -= need
return b.buf[offset:b.idx], nil
} | [
"func",
"(",
"b",
"*",
"buffer",
")",
"readNext",
"(",
"need",
"int",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"b",
".",
"length",
"<",
"need",
"{",
"// refill",
"if",
"err",
":=",
"b",
".",
"fill",
"(",
"need",
")",
";",
"er... | // returns next N bytes from buffer.
// The returned slice is only guaranteed to be valid until the next read | [
"returns",
"next",
"N",
"bytes",
"from",
"buffer",
".",
"The",
"returned",
"slice",
"is",
"only",
"guaranteed",
"to",
"be",
"valid",
"until",
"the",
"next",
"read"
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/buffer.go#L116-L128 |
131,519 | go-sql-driver/mysql | buffer.go | store | func (b *buffer) store(buf []byte) error {
if b.length > 0 {
return ErrBusyBuffer
} else if cap(buf) <= maxPacketSize && cap(buf) > cap(b.buf) {
b.buf = buf[:cap(buf)]
}
return nil
} | go | func (b *buffer) store(buf []byte) error {
if b.length > 0 {
return ErrBusyBuffer
} else if cap(buf) <= maxPacketSize && cap(buf) > cap(b.buf) {
b.buf = buf[:cap(buf)]
}
return nil
} | [
"func",
"(",
"b",
"*",
"buffer",
")",
"store",
"(",
"buf",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"b",
".",
"length",
">",
"0",
"{",
"return",
"ErrBusyBuffer",
"\n",
"}",
"else",
"if",
"cap",
"(",
"buf",
")",
"<=",
"maxPacketSize",
"&&",
"cap... | // store stores buf, an updated buffer, if its suitable to do so. | [
"store",
"stores",
"buf",
"an",
"updated",
"buffer",
"if",
"its",
"suitable",
"to",
"do",
"so",
"."
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/buffer.go#L175-L182 |
131,520 | go-sql-driver/mysql | dsn.go | NewConfig | func NewConfig() *Config {
return &Config{
Collation: defaultCollation,
Loc: time.UTC,
MaxAllowedPacket: defaultMaxAllowedPacket,
AllowNativePasswords: true,
}
} | go | func NewConfig() *Config {
return &Config{
Collation: defaultCollation,
Loc: time.UTC,
MaxAllowedPacket: defaultMaxAllowedPacket,
AllowNativePasswords: true,
}
} | [
"func",
"NewConfig",
"(",
")",
"*",
"Config",
"{",
"return",
"&",
"Config",
"{",
"Collation",
":",
"defaultCollation",
",",
"Loc",
":",
"time",
".",
"UTC",
",",
"MaxAllowedPacket",
":",
"defaultMaxAllowedPacket",
",",
"AllowNativePasswords",
":",
"true",
",",
... | // NewConfig creates a new Config and sets default values. | [
"NewConfig",
"creates",
"a",
"new",
"Config",
"and",
"sets",
"default",
"values",
"."
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/dsn.go#L67-L74 |
131,521 | go-sql-driver/mysql | connection.go | handleParams | func (mc *mysqlConn) handleParams() (err error) {
for param, val := range mc.cfg.Params {
switch param {
// Charset
case "charset":
charsets := strings.Split(val, ",")
for i := range charsets {
// ignore errors here - a charset may not exist
err = mc.exec("SET NAMES " + charsets[i])
if err == n... | go | func (mc *mysqlConn) handleParams() (err error) {
for param, val := range mc.cfg.Params {
switch param {
// Charset
case "charset":
charsets := strings.Split(val, ",")
for i := range charsets {
// ignore errors here - a charset may not exist
err = mc.exec("SET NAMES " + charsets[i])
if err == n... | [
"func",
"(",
"mc",
"*",
"mysqlConn",
")",
"handleParams",
"(",
")",
"(",
"err",
"error",
")",
"{",
"for",
"param",
",",
"val",
":=",
"range",
"mc",
".",
"cfg",
".",
"Params",
"{",
"switch",
"param",
"{",
"// Charset",
"case",
"\"",
"\"",
":",
"char... | // Handles parameters set in DSN after the connection is established | [
"Handles",
"parameters",
"set",
"in",
"DSN",
"after",
"the",
"connection",
"is",
"established"
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/connection.go#L48-L75 |
131,522 | go-sql-driver/mysql | connection.go | exec | func (mc *mysqlConn) exec(query string) error {
// Send command
if err := mc.writeCommandPacketStr(comQuery, query); err != nil {
return mc.markBadConn(err)
}
// Read Result
resLen, err := mc.readResultSetHeaderPacket()
if err != nil {
return err
}
if resLen > 0 {
// columns
if err := mc.readUntilEOF(... | go | func (mc *mysqlConn) exec(query string) error {
// Send command
if err := mc.writeCommandPacketStr(comQuery, query); err != nil {
return mc.markBadConn(err)
}
// Read Result
resLen, err := mc.readResultSetHeaderPacket()
if err != nil {
return err
}
if resLen > 0 {
// columns
if err := mc.readUntilEOF(... | [
"func",
"(",
"mc",
"*",
"mysqlConn",
")",
"exec",
"(",
"query",
"string",
")",
"error",
"{",
"// Send command",
"if",
"err",
":=",
"mc",
".",
"writeCommandPacketStr",
"(",
"comQuery",
",",
"query",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"mc",
"."... | // Internal function to execute commands | [
"Internal",
"function",
"to",
"execute",
"commands"
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/connection.go#L336-L361 |
131,523 | go-sql-driver/mysql | connection.go | getSystemVar | func (mc *mysqlConn) getSystemVar(name string) ([]byte, error) {
// Send command
if err := mc.writeCommandPacketStr(comQuery, "SELECT @@"+name); err != nil {
return nil, err
}
// Read Result
resLen, err := mc.readResultSetHeaderPacket()
if err == nil {
rows := new(textRows)
rows.mc = mc
rows.rs.columns =... | go | func (mc *mysqlConn) getSystemVar(name string) ([]byte, error) {
// Send command
if err := mc.writeCommandPacketStr(comQuery, "SELECT @@"+name); err != nil {
return nil, err
}
// Read Result
resLen, err := mc.readResultSetHeaderPacket()
if err == nil {
rows := new(textRows)
rows.mc = mc
rows.rs.columns =... | [
"func",
"(",
"mc",
"*",
"mysqlConn",
")",
"getSystemVar",
"(",
"name",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// Send command",
"if",
"err",
":=",
"mc",
".",
"writeCommandPacketStr",
"(",
"comQuery",
",",
"\"",
"\"",
"+",
"name"... | // Gets the value of the given MySQL System Variable
// The returned byte slice is only valid until the next read | [
"Gets",
"the",
"value",
"of",
"the",
"given",
"MySQL",
"System",
"Variable",
"The",
"returned",
"byte",
"slice",
"is",
"only",
"valid",
"until",
"the",
"next",
"read"
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/connection.go#L414-L440 |
131,524 | go-sql-driver/mysql | connection.go | cancel | func (mc *mysqlConn) cancel(err error) {
mc.canceled.Set(err)
mc.cleanup()
} | go | func (mc *mysqlConn) cancel(err error) {
mc.canceled.Set(err)
mc.cleanup()
} | [
"func",
"(",
"mc",
"*",
"mysqlConn",
")",
"cancel",
"(",
"err",
"error",
")",
"{",
"mc",
".",
"canceled",
".",
"Set",
"(",
"err",
")",
"\n",
"mc",
".",
"cleanup",
"(",
")",
"\n",
"}"
] | // finish is called when the query has canceled. | [
"finish",
"is",
"called",
"when",
"the",
"query",
"has",
"canceled",
"."
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/connection.go#L443-L446 |
131,525 | go-sql-driver/mysql | connection.go | finish | func (mc *mysqlConn) finish() {
if !mc.watching || mc.finished == nil {
return
}
select {
case mc.finished <- struct{}{}:
mc.watching = false
case <-mc.closech:
}
} | go | func (mc *mysqlConn) finish() {
if !mc.watching || mc.finished == nil {
return
}
select {
case mc.finished <- struct{}{}:
mc.watching = false
case <-mc.closech:
}
} | [
"func",
"(",
"mc",
"*",
"mysqlConn",
")",
"finish",
"(",
")",
"{",
"if",
"!",
"mc",
".",
"watching",
"||",
"mc",
".",
"finished",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"select",
"{",
"case",
"mc",
".",
"finished",
"<-",
"struct",
"{",
"}",... | // finish is called when the query has succeeded. | [
"finish",
"is",
"called",
"when",
"the",
"query",
"has",
"succeeded",
"."
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/connection.go#L449-L458 |
131,526 | go-sql-driver/mysql | connection.go | Ping | func (mc *mysqlConn) Ping(ctx context.Context) (err error) {
if mc.closed.IsSet() {
errLog.Print(ErrInvalidConn)
return driver.ErrBadConn
}
if err = mc.watchCancel(ctx); err != nil {
return
}
defer mc.finish()
if err = mc.writeCommandPacket(comPing); err != nil {
return mc.markBadConn(err)
}
return m... | go | func (mc *mysqlConn) Ping(ctx context.Context) (err error) {
if mc.closed.IsSet() {
errLog.Print(ErrInvalidConn)
return driver.ErrBadConn
}
if err = mc.watchCancel(ctx); err != nil {
return
}
defer mc.finish()
if err = mc.writeCommandPacket(comPing); err != nil {
return mc.markBadConn(err)
}
return m... | [
"func",
"(",
"mc",
"*",
"mysqlConn",
")",
"Ping",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"err",
"error",
")",
"{",
"if",
"mc",
".",
"closed",
".",
"IsSet",
"(",
")",
"{",
"errLog",
".",
"Print",
"(",
"ErrInvalidConn",
")",
"\n",
"return",... | // Ping implements driver.Pinger interface | [
"Ping",
"implements",
"driver",
".",
"Pinger",
"interface"
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/connection.go#L461-L477 |
131,527 | go-sql-driver/mysql | connection.go | BeginTx | func (mc *mysqlConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
if err := mc.watchCancel(ctx); err != nil {
return nil, err
}
defer mc.finish()
if sql.IsolationLevel(opts.Isolation) != sql.LevelDefault {
level, err := mapIsolationLevel(opts.Isolation)
if err != nil {
return n... | go | func (mc *mysqlConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
if err := mc.watchCancel(ctx); err != nil {
return nil, err
}
defer mc.finish()
if sql.IsolationLevel(opts.Isolation) != sql.LevelDefault {
level, err := mapIsolationLevel(opts.Isolation)
if err != nil {
return n... | [
"func",
"(",
"mc",
"*",
"mysqlConn",
")",
"BeginTx",
"(",
"ctx",
"context",
".",
"Context",
",",
"opts",
"driver",
".",
"TxOptions",
")",
"(",
"driver",
".",
"Tx",
",",
"error",
")",
"{",
"if",
"err",
":=",
"mc",
".",
"watchCancel",
"(",
"ctx",
")"... | // BeginTx implements driver.ConnBeginTx interface | [
"BeginTx",
"implements",
"driver",
".",
"ConnBeginTx",
"interface"
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/connection.go#L480-L498 |
131,528 | go-sql-driver/mysql | driver_go110.go | NewConnector | func NewConnector(cfg *Config) (driver.Connector, error) {
cfg = cfg.Clone()
// normalize the contents of cfg so calls to NewConnector have the same
// behavior as MySQLDriver.OpenConnector
if err := cfg.normalize(); err != nil {
return nil, err
}
return &connector{cfg: cfg}, nil
} | go | func NewConnector(cfg *Config) (driver.Connector, error) {
cfg = cfg.Clone()
// normalize the contents of cfg so calls to NewConnector have the same
// behavior as MySQLDriver.OpenConnector
if err := cfg.normalize(); err != nil {
return nil, err
}
return &connector{cfg: cfg}, nil
} | [
"func",
"NewConnector",
"(",
"cfg",
"*",
"Config",
")",
"(",
"driver",
".",
"Connector",
",",
"error",
")",
"{",
"cfg",
"=",
"cfg",
".",
"Clone",
"(",
")",
"\n",
"// normalize the contents of cfg so calls to NewConnector have the same",
"// behavior as MySQLDriver.Ope... | // NewConnector returns new driver.Connector. | [
"NewConnector",
"returns",
"new",
"driver",
".",
"Connector",
"."
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/driver_go110.go#L18-L26 |
131,529 | go-sql-driver/mysql | driver_go110.go | OpenConnector | func (d MySQLDriver) OpenConnector(dsn string) (driver.Connector, error) {
cfg, err := ParseDSN(dsn)
if err != nil {
return nil, err
}
return &connector{
cfg: cfg,
}, nil
} | go | func (d MySQLDriver) OpenConnector(dsn string) (driver.Connector, error) {
cfg, err := ParseDSN(dsn)
if err != nil {
return nil, err
}
return &connector{
cfg: cfg,
}, nil
} | [
"func",
"(",
"d",
"MySQLDriver",
")",
"OpenConnector",
"(",
"dsn",
"string",
")",
"(",
"driver",
".",
"Connector",
",",
"error",
")",
"{",
"cfg",
",",
"err",
":=",
"ParseDSN",
"(",
"dsn",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
"... | // OpenConnector implements driver.DriverContext. | [
"OpenConnector",
"implements",
"driver",
".",
"DriverContext",
"."
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/driver_go110.go#L29-L37 |
131,530 | go-sql-driver/mysql | auth.go | DeregisterServerPubKey | func DeregisterServerPubKey(name string) {
serverPubKeyLock.Lock()
if serverPubKeyRegistry != nil {
delete(serverPubKeyRegistry, name)
}
serverPubKeyLock.Unlock()
} | go | func DeregisterServerPubKey(name string) {
serverPubKeyLock.Lock()
if serverPubKeyRegistry != nil {
delete(serverPubKeyRegistry, name)
}
serverPubKeyLock.Unlock()
} | [
"func",
"DeregisterServerPubKey",
"(",
"name",
"string",
")",
"{",
"serverPubKeyLock",
".",
"Lock",
"(",
")",
"\n",
"if",
"serverPubKeyRegistry",
"!=",
"nil",
"{",
"delete",
"(",
"serverPubKeyRegistry",
",",
"name",
")",
"\n",
"}",
"\n",
"serverPubKeyLock",
".... | // DeregisterServerPubKey removes the public key registered with the given name. | [
"DeregisterServerPubKey",
"removes",
"the",
"public",
"key",
"registered",
"with",
"the",
"given",
"name",
"."
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/auth.go#L67-L73 |
131,531 | go-sql-driver/mysql | auth.go | newMyRnd | func newMyRnd(seed1, seed2 uint32) *myRnd {
return &myRnd{
seed1: seed1 % myRndMaxVal,
seed2: seed2 % myRndMaxVal,
}
} | go | func newMyRnd(seed1, seed2 uint32) *myRnd {
return &myRnd{
seed1: seed1 % myRndMaxVal,
seed2: seed2 % myRndMaxVal,
}
} | [
"func",
"newMyRnd",
"(",
"seed1",
",",
"seed2",
"uint32",
")",
"*",
"myRnd",
"{",
"return",
"&",
"myRnd",
"{",
"seed1",
":",
"seed1",
"%",
"myRndMaxVal",
",",
"seed2",
":",
"seed2",
"%",
"myRndMaxVal",
",",
"}",
"\n",
"}"
] | // Pseudo random number generator | [
"Pseudo",
"random",
"number",
"generator"
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/auth.go#L93-L98 |
131,532 | go-sql-driver/mysql | auth.go | pwHash | func pwHash(password []byte) (result [2]uint32) {
var add uint32 = 7
var tmp uint32
result[0] = 1345345333
result[1] = 0x12345671
for _, c := range password {
// skip spaces and tabs in password
if c == ' ' || c == '\t' {
continue
}
tmp = uint32(c)
result[0] ^= (((result[0] & 63) + add) * tmp) + (r... | go | func pwHash(password []byte) (result [2]uint32) {
var add uint32 = 7
var tmp uint32
result[0] = 1345345333
result[1] = 0x12345671
for _, c := range password {
// skip spaces and tabs in password
if c == ' ' || c == '\t' {
continue
}
tmp = uint32(c)
result[0] ^= (((result[0] & 63) + add) * tmp) + (r... | [
"func",
"pwHash",
"(",
"password",
"[",
"]",
"byte",
")",
"(",
"result",
"[",
"2",
"]",
"uint32",
")",
"{",
"var",
"add",
"uint32",
"=",
"7",
"\n",
"var",
"tmp",
"uint32",
"\n\n",
"result",
"[",
"0",
"]",
"=",
"1345345333",
"\n",
"result",
"[",
"... | // Generate binary hash from byte string using insecure pre 4.1 method | [
"Generate",
"binary",
"hash",
"from",
"byte",
"string",
"using",
"insecure",
"pre",
"4",
".",
"1",
"method"
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/auth.go#L111-L135 |
131,533 | go-sql-driver/mysql | auth.go | scrambleOldPassword | func scrambleOldPassword(scramble []byte, password string) []byte {
if len(password) == 0 {
return nil
}
scramble = scramble[:8]
hashPw := pwHash([]byte(password))
hashSc := pwHash(scramble)
r := newMyRnd(hashPw[0]^hashSc[0], hashPw[1]^hashSc[1])
var out [8]byte
for i := range out {
out[i] = r.NextByte(... | go | func scrambleOldPassword(scramble []byte, password string) []byte {
if len(password) == 0 {
return nil
}
scramble = scramble[:8]
hashPw := pwHash([]byte(password))
hashSc := pwHash(scramble)
r := newMyRnd(hashPw[0]^hashSc[0], hashPw[1]^hashSc[1])
var out [8]byte
for i := range out {
out[i] = r.NextByte(... | [
"func",
"scrambleOldPassword",
"(",
"scramble",
"[",
"]",
"byte",
",",
"password",
"string",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"password",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"scramble",
"=",
"scramble",
"[",
":",
"8"... | // Hash password using insecure pre 4.1 method | [
"Hash",
"password",
"using",
"insecure",
"pre",
"4",
".",
"1",
"method"
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/auth.go#L138-L161 |
131,534 | go-sql-driver/mysql | infile.go | DeregisterLocalFile | func DeregisterLocalFile(filePath string) {
fileRegisterLock.Lock()
delete(fileRegister, strings.Trim(filePath, `"`))
fileRegisterLock.Unlock()
} | go | func DeregisterLocalFile(filePath string) {
fileRegisterLock.Lock()
delete(fileRegister, strings.Trim(filePath, `"`))
fileRegisterLock.Unlock()
} | [
"func",
"DeregisterLocalFile",
"(",
"filePath",
"string",
")",
"{",
"fileRegisterLock",
".",
"Lock",
"(",
")",
"\n",
"delete",
"(",
"fileRegister",
",",
"strings",
".",
"Trim",
"(",
"filePath",
",",
"`\"`",
")",
")",
"\n",
"fileRegisterLock",
".",
"Unlock",
... | // DeregisterLocalFile removes the given filepath from the whitelist. | [
"DeregisterLocalFile",
"removes",
"the",
"given",
"filepath",
"from",
"the",
"whitelist",
"."
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/infile.go#L49-L53 |
131,535 | go-sql-driver/mysql | infile.go | DeregisterReaderHandler | func DeregisterReaderHandler(name string) {
readerRegisterLock.Lock()
delete(readerRegister, name)
readerRegisterLock.Unlock()
} | go | func DeregisterReaderHandler(name string) {
readerRegisterLock.Lock()
delete(readerRegister, name)
readerRegisterLock.Unlock()
} | [
"func",
"DeregisterReaderHandler",
"(",
"name",
"string",
")",
"{",
"readerRegisterLock",
".",
"Lock",
"(",
")",
"\n",
"delete",
"(",
"readerRegister",
",",
"name",
")",
"\n",
"readerRegisterLock",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // DeregisterReaderHandler removes the ReaderHandler function with
// the given name from the registry. | [
"DeregisterReaderHandler",
"removes",
"the",
"ReaderHandler",
"function",
"with",
"the",
"given",
"name",
"from",
"the",
"registry",
"."
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/infile.go#L83-L87 |
131,536 | go-sql-driver/mysql | errors.go | SetLogger | func SetLogger(logger Logger) error {
if logger == nil {
return errors.New("logger is nil")
}
errLog = logger
return nil
} | go | func SetLogger(logger Logger) error {
if logger == nil {
return errors.New("logger is nil")
}
errLog = logger
return nil
} | [
"func",
"SetLogger",
"(",
"logger",
"Logger",
")",
"error",
"{",
"if",
"logger",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"errLog",
"=",
"logger",
"\n",
"return",
"nil",
"\n",
"}"
] | // SetLogger is used to set the logger for critical errors.
// The initial logger is os.Stderr. | [
"SetLogger",
"is",
"used",
"to",
"set",
"the",
"logger",
"for",
"critical",
"errors",
".",
"The",
"initial",
"logger",
"is",
"os",
".",
"Stderr",
"."
] | d0a548181995c293eb09c61ef80099ba1cdbe8f5 | https://github.com/go-sql-driver/mysql/blob/d0a548181995c293eb09c61ef80099ba1cdbe8f5/errors.go#L49-L55 |
131,537 | weaveworks/flux | policy/policy.go | Has | func (s Set) Has(needle Policy) bool {
for p, v := range s {
if p == needle {
if Boolean(needle) {
return v == "true"
}
return true
}
}
return false
} | go | func (s Set) Has(needle Policy) bool {
for p, v := range s {
if p == needle {
if Boolean(needle) {
return v == "true"
}
return true
}
}
return false
} | [
"func",
"(",
"s",
"Set",
")",
"Has",
"(",
"needle",
"Policy",
")",
"bool",
"{",
"for",
"p",
",",
"v",
":=",
"range",
"s",
"{",
"if",
"p",
"==",
"needle",
"{",
"if",
"Boolean",
"(",
"needle",
")",
"{",
"return",
"v",
"==",
"\"",
"\"",
"\n",
"}... | // Has returns true if a resource has a particular policy present, and
// for boolean policies, if it is set to true. | [
"Has",
"returns",
"true",
"if",
"a",
"resource",
"has",
"a",
"particular",
"policy",
"present",
"and",
"for",
"boolean",
"policies",
"if",
"it",
"is",
"set",
"to",
"true",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/policy/policy.go#L106-L116 |
131,538 | weaveworks/flux | git/operations.go | push | func push(ctx context.Context, workingDir, upstream string, refs []string) error {
args := append([]string{"push", upstream}, refs...)
if err := execGitCmd(ctx, args, gitCmdConfig{dir: workingDir}); err != nil {
return errors.Wrap(err, fmt.Sprintf("git push %s %s", upstream, refs))
}
return nil
} | go | func push(ctx context.Context, workingDir, upstream string, refs []string) error {
args := append([]string{"push", upstream}, refs...)
if err := execGitCmd(ctx, args, gitCmdConfig{dir: workingDir}); err != nil {
return errors.Wrap(err, fmt.Sprintf("git push %s %s", upstream, refs))
}
return nil
} | [
"func",
"push",
"(",
"ctx",
"context",
".",
"Context",
",",
"workingDir",
",",
"upstream",
"string",
",",
"refs",
"[",
"]",
"string",
")",
"error",
"{",
"args",
":=",
"append",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"upstream",
"}",
",",
"r... | // push the refs given to the upstream repo | [
"push",
"the",
"refs",
"given",
"to",
"the",
"upstream",
"repo"
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/git/operations.go#L115-L121 |
131,539 | weaveworks/flux | git/operations.go | fetch | func fetch(ctx context.Context, workingDir, upstream string, refspec ...string) error {
args := append([]string{"fetch", "--tags", upstream}, refspec...)
// In git <=2.20 the error started with an uppercase, in 2.21 this
// was changed to be consistent with all other die() and error()
// messages, cast to lowercase... | go | func fetch(ctx context.Context, workingDir, upstream string, refspec ...string) error {
args := append([]string{"fetch", "--tags", upstream}, refspec...)
// In git <=2.20 the error started with an uppercase, in 2.21 this
// was changed to be consistent with all other die() and error()
// messages, cast to lowercase... | [
"func",
"fetch",
"(",
"ctx",
"context",
".",
"Context",
",",
"workingDir",
",",
"upstream",
"string",
",",
"refspec",
"...",
"string",
")",
"error",
"{",
"args",
":=",
"append",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"upstrea... | // fetch updates refs from the upstream. | [
"fetch",
"updates",
"refs",
"from",
"the",
"upstream",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/git/operations.go#L124-L135 |
131,540 | weaveworks/flux | git/operations.go | getNotesRef | func getNotesRef(ctx context.Context, workingDir, ref string) (string, error) {
out := &bytes.Buffer{}
args := []string{"notes", "--ref", ref, "get-ref"}
if err := execGitCmd(ctx, args, gitCmdConfig{dir: workingDir, out: out}); err != nil {
return "", err
}
return strings.TrimSpace(out.String()), nil
} | go | func getNotesRef(ctx context.Context, workingDir, ref string) (string, error) {
out := &bytes.Buffer{}
args := []string{"notes", "--ref", ref, "get-ref"}
if err := execGitCmd(ctx, args, gitCmdConfig{dir: workingDir, out: out}); err != nil {
return "", err
}
return strings.TrimSpace(out.String()), nil
} | [
"func",
"getNotesRef",
"(",
"ctx",
"context",
".",
"Context",
",",
"workingDir",
",",
"ref",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"out",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"args",
":=",
"[",
"]",
"string",
"{",
"\""... | // Get the full ref for a shorthand notes ref. | [
"Get",
"the",
"full",
"ref",
"for",
"a",
"shorthand",
"notes",
"ref",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/git/operations.go#L149-L156 |
131,541 | weaveworks/flux | git/operations.go | onelinelog | func onelinelog(ctx context.Context, workingDir, refspec string, subdirs []string) ([]Commit, error) {
out := &bytes.Buffer{}
args := []string{"log", "--pretty=format:%GK|%H|%s", refspec}
args = append(args, "--")
if len(subdirs) > 0 {
args = append(args, subdirs...)
}
if err := execGitCmd(ctx, args, gitCmdCon... | go | func onelinelog(ctx context.Context, workingDir, refspec string, subdirs []string) ([]Commit, error) {
out := &bytes.Buffer{}
args := []string{"log", "--pretty=format:%GK|%H|%s", refspec}
args = append(args, "--")
if len(subdirs) > 0 {
args = append(args, subdirs...)
}
if err := execGitCmd(ctx, args, gitCmdCon... | [
"func",
"onelinelog",
"(",
"ctx",
"context",
".",
"Context",
",",
"workingDir",
",",
"refspec",
"string",
",",
"subdirs",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"Commit",
",",
"error",
")",
"{",
"out",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
... | // Return the revisions and one-line log commit messages | [
"Return",
"the",
"revisions",
"and",
"one",
"-",
"line",
"log",
"commit",
"messages"
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/git/operations.go#L213-L226 |
131,542 | weaveworks/flux | git/operations.go | moveTagAndPush | func moveTagAndPush(ctx context.Context, workingDir, tag, upstream string, tagAction TagAction) error {
args := []string{"tag", "--force", "-a", "-m", tagAction.Message}
var env []string
if tagAction.SigningKey != "" {
args = append(args, fmt.Sprintf("--local-user=%s", tagAction.SigningKey))
}
args = append(args... | go | func moveTagAndPush(ctx context.Context, workingDir, tag, upstream string, tagAction TagAction) error {
args := []string{"tag", "--force", "-a", "-m", tagAction.Message}
var env []string
if tagAction.SigningKey != "" {
args = append(args, fmt.Sprintf("--local-user=%s", tagAction.SigningKey))
}
args = append(args... | [
"func",
"moveTagAndPush",
"(",
"ctx",
"context",
".",
"Context",
",",
"workingDir",
",",
"tag",
",",
"upstream",
"string",
",",
"tagAction",
"TagAction",
")",
"error",
"{",
"args",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
... | // Move the tag to the ref given and push that tag upstream | [
"Move",
"the",
"tag",
"to",
"the",
"ref",
"given",
"and",
"push",
"that",
"tag",
"upstream"
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/git/operations.go#L249-L264 |
131,543 | weaveworks/flux | git/operations.go | traceGitCommand | func traceGitCommand(args []string, config gitCmdConfig, stdout string, stderr string) string {
for _, exemptedCommand := range exemptedTraceCommands {
if exemptedCommand == args[0] {
return ""
}
}
prepare := func(input string) string {
output := strings.Trim(input, "\x00")
output = strings.TrimSuffix(ou... | go | func traceGitCommand(args []string, config gitCmdConfig, stdout string, stderr string) string {
for _, exemptedCommand := range exemptedTraceCommands {
if exemptedCommand == args[0] {
return ""
}
}
prepare := func(input string) string {
output := strings.Trim(input, "\x00")
output = strings.TrimSuffix(ou... | [
"func",
"traceGitCommand",
"(",
"args",
"[",
"]",
"string",
",",
"config",
"gitCmdConfig",
",",
"stdout",
"string",
",",
"stderr",
"string",
")",
"string",
"{",
"for",
"_",
",",
"exemptedCommand",
":=",
"range",
"exemptedTraceCommands",
"{",
"if",
"exemptedCom... | // traceGitCommand returns a log line that can be useful when debugging and developing git activity | [
"traceGitCommand",
"returns",
"a",
"log",
"line",
"that",
"can",
"be",
"useful",
"when",
"debugging",
"and",
"developing",
"git",
"activity"
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/git/operations.go#L293-L319 |
131,544 | weaveworks/flux | git/operations.go | execGitCmd | func execGitCmd(ctx context.Context, args []string, config gitCmdConfig) error {
c := exec.CommandContext(ctx, "git", args...)
if config.dir != "" {
c.Dir = config.dir
}
c.Env = append(env(), config.env...)
c.Stdout = ioutil.Discard
if config.out != nil {
c.Stdout = config.out
}
errOut := &bytes.Buffer{}
... | go | func execGitCmd(ctx context.Context, args []string, config gitCmdConfig) error {
c := exec.CommandContext(ctx, "git", args...)
if config.dir != "" {
c.Dir = config.dir
}
c.Env = append(env(), config.env...)
c.Stdout = ioutil.Discard
if config.out != nil {
c.Stdout = config.out
}
errOut := &bytes.Buffer{}
... | [
"func",
"execGitCmd",
"(",
"ctx",
"context",
".",
"Context",
",",
"args",
"[",
"]",
"string",
",",
"config",
"gitCmdConfig",
")",
"error",
"{",
"c",
":=",
"exec",
".",
"CommandContext",
"(",
"ctx",
",",
"\"",
"\"",
",",
"args",
"...",
")",
"\n\n",
"i... | // execGitCmd runs a `git` command with the supplied arguments. | [
"execGitCmd",
"runs",
"a",
"git",
"command",
"with",
"the",
"supplied",
"arguments",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/git/operations.go#L322-L363 |
131,545 | weaveworks/flux | git/operations.go | check | func check(ctx context.Context, workingDir string, subdirs []string) bool {
// `--quiet` means "exit with 1 if there are changes"
args := []string{"diff", "--quiet"}
args = append(args, "--")
if len(subdirs) > 0 {
args = append(args, subdirs...)
}
return execGitCmd(ctx, args, gitCmdConfig{dir: workingDir}) != n... | go | func check(ctx context.Context, workingDir string, subdirs []string) bool {
// `--quiet` means "exit with 1 if there are changes"
args := []string{"diff", "--quiet"}
args = append(args, "--")
if len(subdirs) > 0 {
args = append(args, subdirs...)
}
return execGitCmd(ctx, args, gitCmdConfig{dir: workingDir}) != n... | [
"func",
"check",
"(",
"ctx",
"context",
".",
"Context",
",",
"workingDir",
"string",
",",
"subdirs",
"[",
"]",
"string",
")",
"bool",
"{",
"// `--quiet` means \"exit with 1 if there are changes\"",
"args",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
... | // check returns true if there are changes locally. | [
"check",
"returns",
"true",
"if",
"there",
"are",
"changes",
"locally",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/git/operations.go#L379-L387 |
131,546 | weaveworks/flux | update/release_image.go | selectWorkloads | func (s ReleaseImageSpec) selectWorkloads(rc ReleaseContext, results Result) ([]*WorkloadUpdate, error) {
// Build list of filters
prefilters, postfilters, err := s.filters(rc)
if err != nil {
return nil, err
}
// Find and filter workloads
return rc.SelectWorkloads(results, prefilters, postfilters)
} | go | func (s ReleaseImageSpec) selectWorkloads(rc ReleaseContext, results Result) ([]*WorkloadUpdate, error) {
// Build list of filters
prefilters, postfilters, err := s.filters(rc)
if err != nil {
return nil, err
}
// Find and filter workloads
return rc.SelectWorkloads(results, prefilters, postfilters)
} | [
"func",
"(",
"s",
"ReleaseImageSpec",
")",
"selectWorkloads",
"(",
"rc",
"ReleaseContext",
",",
"results",
"Result",
")",
"(",
"[",
"]",
"*",
"WorkloadUpdate",
",",
"error",
")",
"{",
"// Build list of filters",
"prefilters",
",",
"postfilters",
",",
"err",
":... | // Take the spec given in the job, and figure out which workloads are
// in question based on the running workloads and those defined in the
// repo. Fill in the release results along the way. | [
"Take",
"the",
"spec",
"given",
"in",
"the",
"job",
"and",
"figure",
"out",
"which",
"workloads",
"are",
"in",
"question",
"based",
"on",
"the",
"running",
"workloads",
"and",
"those",
"defined",
"in",
"the",
"repo",
".",
"Fill",
"in",
"the",
"release",
... | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/update/release_image.go#L108-L116 |
131,547 | weaveworks/flux | http/validate.go | makeWalkFunc | func makeWalkFunc(router *mux.Router) mux.WalkFunc {
return mux.WalkFunc(func(r *mux.Route, _ *mux.Router, _ []*mux.Route) error {
// Does a route with this name exist in router?
route := router.Get(r.GetName())
if route == nil {
return fmt.Errorf("no route by name %q in router", r.GetName())
}
// Does th... | go | func makeWalkFunc(router *mux.Router) mux.WalkFunc {
return mux.WalkFunc(func(r *mux.Route, _ *mux.Router, _ []*mux.Route) error {
// Does a route with this name exist in router?
route := router.Get(r.GetName())
if route == nil {
return fmt.Errorf("no route by name %q in router", r.GetName())
}
// Does th... | [
"func",
"makeWalkFunc",
"(",
"router",
"*",
"mux",
".",
"Router",
")",
"mux",
".",
"WalkFunc",
"{",
"return",
"mux",
".",
"WalkFunc",
"(",
"func",
"(",
"r",
"*",
"mux",
".",
"Route",
",",
"_",
"*",
"mux",
".",
"Router",
",",
"_",
"[",
"]",
"*",
... | // makeWalkFunc creates a function which verifies that the route passed
// to it both exists in the router under test and has a handler attached. | [
"makeWalkFunc",
"creates",
"a",
"function",
"which",
"verifies",
"that",
"the",
"route",
"passed",
"to",
"it",
"both",
"exists",
"in",
"the",
"router",
"under",
"test",
"and",
"has",
"a",
"handler",
"attached",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/http/validate.go#L26-L40 |
131,548 | weaveworks/flux | flux.go | ParseResourceID | func ParseResourceID(s string) (ResourceID, error) {
if m := ResourceIDRegexp.FindStringSubmatch(s); m != nil {
return ResourceID{resourceID{m[1], strings.ToLower(m[2]), m[3]}}, nil
}
if m := LegacyServiceIDRegexp.FindStringSubmatch(s); m != nil {
return ResourceID{legacyServiceID{m[1], m[2]}}, nil
}
return Re... | go | func ParseResourceID(s string) (ResourceID, error) {
if m := ResourceIDRegexp.FindStringSubmatch(s); m != nil {
return ResourceID{resourceID{m[1], strings.ToLower(m[2]), m[3]}}, nil
}
if m := LegacyServiceIDRegexp.FindStringSubmatch(s); m != nil {
return ResourceID{legacyServiceID{m[1], m[2]}}, nil
}
return Re... | [
"func",
"ParseResourceID",
"(",
"s",
"string",
")",
"(",
"ResourceID",
",",
"error",
")",
"{",
"if",
"m",
":=",
"ResourceIDRegexp",
".",
"FindStringSubmatch",
"(",
"s",
")",
";",
"m",
"!=",
"nil",
"{",
"return",
"ResourceID",
"{",
"resourceID",
"{",
"m",... | // ParseResourceID constructs a ResourceID from a string representation
// if possible, returning an error value otherwise. | [
"ParseResourceID",
"constructs",
"a",
"ResourceID",
"from",
"a",
"string",
"representation",
"if",
"possible",
"returning",
"an",
"error",
"value",
"otherwise",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/flux.go#L56-L64 |
131,549 | weaveworks/flux | flux.go | MustParseResourceID | func MustParseResourceID(s string) ResourceID {
id, err := ParseResourceID(s)
if err != nil {
panic(err)
}
return id
} | go | func MustParseResourceID(s string) ResourceID {
id, err := ParseResourceID(s)
if err != nil {
panic(err)
}
return id
} | [
"func",
"MustParseResourceID",
"(",
"s",
"string",
")",
"ResourceID",
"{",
"id",
",",
"err",
":=",
"ParseResourceID",
"(",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"id",
"\n",
"}"
] | // MustParseResourceID constructs a ResourceID from a string representation,
// panicing if the format is invalid. | [
"MustParseResourceID",
"constructs",
"a",
"ResourceID",
"from",
"a",
"string",
"representation",
"panicing",
"if",
"the",
"format",
"is",
"invalid",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/flux.go#L68-L74 |
131,550 | weaveworks/flux | flux.go | MakeResourceID | func MakeResourceID(namespace, kind, name string) ResourceID {
return ResourceID{resourceID{namespace, strings.ToLower(kind), name}}
} | go | func MakeResourceID(namespace, kind, name string) ResourceID {
return ResourceID{resourceID{namespace, strings.ToLower(kind), name}}
} | [
"func",
"MakeResourceID",
"(",
"namespace",
",",
"kind",
",",
"name",
"string",
")",
"ResourceID",
"{",
"return",
"ResourceID",
"{",
"resourceID",
"{",
"namespace",
",",
"strings",
".",
"ToLower",
"(",
"kind",
")",
",",
"name",
"}",
"}",
"\n",
"}"
] | // MakeResourceID constructs a ResourceID from constituent components. | [
"MakeResourceID",
"constructs",
"a",
"ResourceID",
"from",
"constituent",
"components",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/flux.go#L90-L92 |
131,551 | weaveworks/flux | flux.go | Components | func (id ResourceID) Components() (namespace, kind, name string) {
switch impl := id.resourceIDImpl.(type) {
case resourceID:
return impl.namespace, impl.kind, impl.name
case legacyServiceID:
return impl.namespace, "service", impl.service
default:
panic("wrong underlying type")
}
} | go | func (id ResourceID) Components() (namespace, kind, name string) {
switch impl := id.resourceIDImpl.(type) {
case resourceID:
return impl.namespace, impl.kind, impl.name
case legacyServiceID:
return impl.namespace, "service", impl.service
default:
panic("wrong underlying type")
}
} | [
"func",
"(",
"id",
"ResourceID",
")",
"Components",
"(",
")",
"(",
"namespace",
",",
"kind",
",",
"name",
"string",
")",
"{",
"switch",
"impl",
":=",
"id",
".",
"resourceIDImpl",
".",
"(",
"type",
")",
"{",
"case",
"resourceID",
":",
"return",
"impl",
... | // Components returns the constituent components of a ResourceID | [
"Components",
"returns",
"the",
"constituent",
"components",
"of",
"a",
"ResourceID"
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/flux.go#L95-L104 |
131,552 | weaveworks/flux | flux.go | MarshalJSON | func (id ResourceID) MarshalJSON() ([]byte, error) {
if id.resourceIDImpl == nil {
// Sadly needed as it's possible to construct an empty ResourceID literal
return json.Marshal("")
}
return json.Marshal(id.String())
} | go | func (id ResourceID) MarshalJSON() ([]byte, error) {
if id.resourceIDImpl == nil {
// Sadly needed as it's possible to construct an empty ResourceID literal
return json.Marshal("")
}
return json.Marshal(id.String())
} | [
"func",
"(",
"id",
"ResourceID",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"id",
".",
"resourceIDImpl",
"==",
"nil",
"{",
"// Sadly needed as it's possible to construct an empty ResourceID literal",
"return",
"json",
".",
... | // MarshalJSON encodes a ResourceID as a JSON string. This is
// done to maintain backwards compatibility with previous flux
// versions where the ResourceID is a plain string. | [
"MarshalJSON",
"encodes",
"a",
"ResourceID",
"as",
"a",
"JSON",
"string",
".",
"This",
"is",
"done",
"to",
"maintain",
"backwards",
"compatibility",
"with",
"previous",
"flux",
"versions",
"where",
"the",
"ResourceID",
"is",
"a",
"plain",
"string",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/flux.go#L109-L115 |
131,553 | weaveworks/flux | flux.go | UnmarshalJSON | func (id *ResourceID) UnmarshalJSON(data []byte) (err error) {
var str string
if err := json.Unmarshal(data, &str); err != nil {
return err
}
if string(str) == "" {
// Sadly needed as it's possible to construct an empty ResourceID literal
*id = ResourceID{}
return nil
}
*id, err = ParseResourceID(string(s... | go | func (id *ResourceID) UnmarshalJSON(data []byte) (err error) {
var str string
if err := json.Unmarshal(data, &str); err != nil {
return err
}
if string(str) == "" {
// Sadly needed as it's possible to construct an empty ResourceID literal
*id = ResourceID{}
return nil
}
*id, err = ParseResourceID(string(s... | [
"func",
"(",
"id",
"*",
"ResourceID",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"err",
"error",
")",
"{",
"var",
"str",
"string",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"str",
")",
";",
"err... | // UnmarshalJSON decodes a ResourceID from a JSON string. This is
// done to maintain backwards compatibility with previous flux
// versions where the ResourceID is a plain string. | [
"UnmarshalJSON",
"decodes",
"a",
"ResourceID",
"from",
"a",
"JSON",
"string",
".",
"This",
"is",
"done",
"to",
"maintain",
"backwards",
"compatibility",
"with",
"previous",
"flux",
"versions",
"where",
"the",
"ResourceID",
"is",
"a",
"plain",
"string",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/flux.go#L120-L132 |
131,554 | weaveworks/flux | flux.go | MarshalText | func (id ResourceID) MarshalText() (text []byte, err error) {
return []byte(id.String()), nil
} | go | func (id ResourceID) MarshalText() (text []byte, err error) {
return []byte(id.String()), nil
} | [
"func",
"(",
"id",
"ResourceID",
")",
"MarshalText",
"(",
")",
"(",
"text",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"return",
"[",
"]",
"byte",
"(",
"id",
".",
"String",
"(",
")",
")",
",",
"nil",
"\n",
"}"
] | // MarshalText encodes a ResourceID as a flat string; this is
// required because ResourceIDs are sometimes used as map keys. | [
"MarshalText",
"encodes",
"a",
"ResourceID",
"as",
"a",
"flat",
"string",
";",
"this",
"is",
"required",
"because",
"ResourceIDs",
"are",
"sometimes",
"used",
"as",
"map",
"keys",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/flux.go#L136-L138 |
131,555 | weaveworks/flux | flux.go | UnmarshalText | func (id *ResourceID) UnmarshalText(text []byte) error {
result, err := ParseResourceID(string(text))
if err != nil {
return err
}
*id = result
return nil
} | go | func (id *ResourceID) UnmarshalText(text []byte) error {
result, err := ParseResourceID(string(text))
if err != nil {
return err
}
*id = result
return nil
} | [
"func",
"(",
"id",
"*",
"ResourceID",
")",
"UnmarshalText",
"(",
"text",
"[",
"]",
"byte",
")",
"error",
"{",
"result",
",",
"err",
":=",
"ParseResourceID",
"(",
"string",
"(",
"text",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
... | // MarshalText decodes a ResourceID from a flat string; this is
// required because ResourceIDs are sometimes used as map keys. | [
"MarshalText",
"decodes",
"a",
"ResourceID",
"from",
"a",
"flat",
"string",
";",
"this",
"is",
"required",
"because",
"ResourceIDs",
"are",
"sometimes",
"used",
"as",
"map",
"keys",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/flux.go#L142-L149 |
131,556 | weaveworks/flux | integrations/helm/operator/operator.go | New | func New(
logger log.Logger,
logReleaseDiffs bool,
kubeclientset kubernetes.Interface,
fhrInformer fhrv1.HelmReleaseInformer,
releaseWorkqueue workqueue.RateLimitingInterface,
sync *chartsync.ChartChangeSync) *Controller {
// Add helm-operator types to the default Kubernetes Scheme so Events can be
// logged f... | go | func New(
logger log.Logger,
logReleaseDiffs bool,
kubeclientset kubernetes.Interface,
fhrInformer fhrv1.HelmReleaseInformer,
releaseWorkqueue workqueue.RateLimitingInterface,
sync *chartsync.ChartChangeSync) *Controller {
// Add helm-operator types to the default Kubernetes Scheme so Events can be
// logged f... | [
"func",
"New",
"(",
"logger",
"log",
".",
"Logger",
",",
"logReleaseDiffs",
"bool",
",",
"kubeclientset",
"kubernetes",
".",
"Interface",
",",
"fhrInformer",
"fhrv1",
".",
"HelmReleaseInformer",
",",
"releaseWorkqueue",
"workqueue",
".",
"RateLimitingInterface",
","... | // New returns a new helm-operator | [
"New",
"returns",
"a",
"new",
"helm",
"-",
"operator"
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/helm/operator/operator.go#L70-L118 |
131,557 | weaveworks/flux | integrations/helm/operator/operator.go | Run | func (c *Controller) Run(threadiness int, stopCh <-chan struct{}, wg *sync.WaitGroup) error {
defer runtime.HandleCrash()
defer c.releaseWorkqueue.ShutDown()
c.logger.Log("info", "starting operator")
// Wait for the caches to be synced before starting workers
c.logger.Log("info", "waiting for informer caches to s... | go | func (c *Controller) Run(threadiness int, stopCh <-chan struct{}, wg *sync.WaitGroup) error {
defer runtime.HandleCrash()
defer c.releaseWorkqueue.ShutDown()
c.logger.Log("info", "starting operator")
// Wait for the caches to be synced before starting workers
c.logger.Log("info", "waiting for informer caches to s... | [
"func",
"(",
"c",
"*",
"Controller",
")",
"Run",
"(",
"threadiness",
"int",
",",
"stopCh",
"<-",
"chan",
"struct",
"{",
"}",
",",
"wg",
"*",
"sync",
".",
"WaitGroup",
")",
"error",
"{",
"defer",
"runtime",
".",
"HandleCrash",
"(",
")",
"\n",
"defer",... | // Run sets up the event handlers for our Custom Resource, as well
// as syncing informer caches and starting workers. It will block until stopCh
// is closed, at which point it will shutdown the workqueue and wait for
// workers to finish processing their current work items. | [
"Run",
"sets",
"up",
"the",
"event",
"handlers",
"for",
"our",
"Custom",
"Resource",
"as",
"well",
"as",
"syncing",
"informer",
"caches",
"and",
"starting",
"workers",
".",
"It",
"will",
"block",
"until",
"stopCh",
"is",
"closed",
"at",
"which",
"point",
"... | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/helm/operator/operator.go#L124-L150 |
131,558 | weaveworks/flux | integrations/helm/operator/operator.go | enqueueUpdateJob | func (c *Controller) enqueueUpdateJob(old, new interface{}) {
oldFhr, ok := checkCustomResourceType(c.logger, old)
if !ok {
return
}
newFhr, ok := checkCustomResourceType(c.logger, new)
if !ok {
return
}
diff := cmp.Diff(oldFhr.Spec, newFhr.Spec)
// Filter out any update notifications that are due to stat... | go | func (c *Controller) enqueueUpdateJob(old, new interface{}) {
oldFhr, ok := checkCustomResourceType(c.logger, old)
if !ok {
return
}
newFhr, ok := checkCustomResourceType(c.logger, new)
if !ok {
return
}
diff := cmp.Diff(oldFhr.Spec, newFhr.Spec)
// Filter out any update notifications that are due to stat... | [
"func",
"(",
"c",
"*",
"Controller",
")",
"enqueueUpdateJob",
"(",
"old",
",",
"new",
"interface",
"{",
"}",
")",
"{",
"oldFhr",
",",
"ok",
":=",
"checkCustomResourceType",
"(",
"c",
".",
"logger",
",",
"old",
")",
"\n",
"if",
"!",
"ok",
"{",
"return... | // enqueueUpdateJob decides if there is a genuine resource update | [
"enqueueUpdateJob",
"decides",
"if",
"there",
"is",
"a",
"genuine",
"resource",
"update"
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/helm/operator/operator.go#L275-L310 |
131,559 | weaveworks/flux | ssh/keygen.go | KeyGen | func KeyGen(keyBits, keyType OptionalValue, tmpfsPath string) (privateKeyPath string, privateKey []byte, publicKey PublicKey, err error) {
tempDir, err := ioutil.TempDir(tmpfsPath, "..weave-keygen")
if err != nil {
return "", nil, PublicKey{}, err
}
privateKeyPath = path.Join(tempDir, "identity")
args := []stri... | go | func KeyGen(keyBits, keyType OptionalValue, tmpfsPath string) (privateKeyPath string, privateKey []byte, publicKey PublicKey, err error) {
tempDir, err := ioutil.TempDir(tmpfsPath, "..weave-keygen")
if err != nil {
return "", nil, PublicKey{}, err
}
privateKeyPath = path.Join(tempDir, "identity")
args := []stri... | [
"func",
"KeyGen",
"(",
"keyBits",
",",
"keyType",
"OptionalValue",
",",
"tmpfsPath",
"string",
")",
"(",
"privateKeyPath",
"string",
",",
"privateKey",
"[",
"]",
"byte",
",",
"publicKey",
"PublicKey",
",",
"err",
"error",
")",
"{",
"tempDir",
",",
"err",
"... | // KeyGen generates a new keypair with ssh-keygen, optionally overriding the
// default type and size. Each generated keypair is written to a new unique
// subdirectory of tmpfsPath, which should point to a tmpfs mount as the
// private key is not encrypted. | [
"KeyGen",
"generates",
"a",
"new",
"keypair",
"with",
"ssh",
"-",
"keygen",
"optionally",
"overriding",
"the",
"default",
"type",
"and",
"size",
".",
"Each",
"generated",
"keypair",
"is",
"written",
"to",
"a",
"new",
"unique",
"subdirectory",
"of",
"tmpfsPath"... | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/ssh/keygen.go#L85-L116 |
131,560 | weaveworks/flux | ssh/keygen.go | ExtractFingerprint | func ExtractFingerprint(privateKeyPath, hashAlgo string) (Fingerprint, error) {
output, err := exec.Command("ssh-keygen", "-l", "-v", "-E", hashAlgo, "-f", privateKeyPath).Output()
if err != nil {
return Fingerprint{}, err
}
i := bytes.IndexByte(output, '\n')
if i == -1 {
return Fingerprint{}, fmt.Errorf("cou... | go | func ExtractFingerprint(privateKeyPath, hashAlgo string) (Fingerprint, error) {
output, err := exec.Command("ssh-keygen", "-l", "-v", "-E", hashAlgo, "-f", privateKeyPath).Output()
if err != nil {
return Fingerprint{}, err
}
i := bytes.IndexByte(output, '\n')
if i == -1 {
return Fingerprint{}, fmt.Errorf("cou... | [
"func",
"ExtractFingerprint",
"(",
"privateKeyPath",
",",
"hashAlgo",
"string",
")",
"(",
"Fingerprint",
",",
"error",
")",
"{",
"output",
",",
"err",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"... | // Fingerprint extracts and returns the hash and randomart of the public key
// associated with the specified private key. | [
"Fingerprint",
"extracts",
"and",
"returns",
"the",
"hash",
"and",
"randomart",
"of",
"the",
"public",
"key",
"associated",
"with",
"the",
"specified",
"private",
"key",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/ssh/keygen.go#L130-L150 |
131,561 | weaveworks/flux | ssh/keygen.go | ExtractPublicKey | func ExtractPublicKey(privateKeyPath string) (PublicKey, error) {
keyBytes, err := exec.Command("ssh-keygen", "-y", "-f", privateKeyPath).CombinedOutput()
if err != nil {
return PublicKey{}, errors.New(string(keyBytes))
}
md5Print, err := ExtractFingerprint(privateKeyPath, "md5")
if err != nil {
return Public... | go | func ExtractPublicKey(privateKeyPath string) (PublicKey, error) {
keyBytes, err := exec.Command("ssh-keygen", "-y", "-f", privateKeyPath).CombinedOutput()
if err != nil {
return PublicKey{}, errors.New(string(keyBytes))
}
md5Print, err := ExtractFingerprint(privateKeyPath, "md5")
if err != nil {
return Public... | [
"func",
"ExtractPublicKey",
"(",
"privateKeyPath",
"string",
")",
"(",
"PublicKey",
",",
"error",
")",
"{",
"keyBytes",
",",
"err",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"privateKeyPath",
")",
".",
"Combi... | // ExtractPublicKey extracts and returns the public key from the specified
// private key, along with its fingerprint hashes. | [
"ExtractPublicKey",
"extracts",
"and",
"returns",
"the",
"public",
"key",
"from",
"the",
"specified",
"private",
"key",
"along",
"with",
"its",
"fingerprint",
"hashes",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/ssh/keygen.go#L159-L182 |
131,562 | weaveworks/flux | git/mirrors.go | Get | func (m *Mirrors) Get(name string) (*Repo, bool) {
m.reposMu.Lock()
defer m.reposMu.Unlock()
r, ok := m.repos[name]
if ok {
return r.repo, true
}
return nil, false
} | go | func (m *Mirrors) Get(name string) (*Repo, bool) {
m.reposMu.Lock()
defer m.reposMu.Unlock()
r, ok := m.repos[name]
if ok {
return r.repo, true
}
return nil, false
} | [
"func",
"(",
"m",
"*",
"Mirrors",
")",
"Get",
"(",
"name",
"string",
")",
"(",
"*",
"Repo",
",",
"bool",
")",
"{",
"m",
".",
"reposMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"reposMu",
".",
"Unlock",
"(",
")",
"\n",
"r",
",",
"ok",
... | // Get returns the named repo or nil, and a bool indicating whether
// the repo is being mirrored. | [
"Get",
"returns",
"the",
"named",
"repo",
"or",
"nil",
"and",
"a",
"bool",
"indicating",
"whether",
"the",
"repo",
"is",
"being",
"mirrored",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/git/mirrors.go#L90-L98 |
131,563 | weaveworks/flux | git/mirrors.go | StopAllAndWait | func (m *Mirrors) StopAllAndWait() {
m.reposMu.Lock()
for k, state := range m.repos {
close(state.stop)
state.repo.Clean()
delete(m.repos, k)
}
m.reposMu.Unlock()
m.wg.Wait()
} | go | func (m *Mirrors) StopAllAndWait() {
m.reposMu.Lock()
for k, state := range m.repos {
close(state.stop)
state.repo.Clean()
delete(m.repos, k)
}
m.reposMu.Unlock()
m.wg.Wait()
} | [
"func",
"(",
"m",
"*",
"Mirrors",
")",
"StopAllAndWait",
"(",
")",
"{",
"m",
".",
"reposMu",
".",
"Lock",
"(",
")",
"\n",
"for",
"k",
",",
"state",
":=",
"range",
"m",
".",
"repos",
"{",
"close",
"(",
"state",
".",
"stop",
")",
"\n",
"state",
"... | // StopAllAndWait stops all the repos refreshing, and waits for them
// to indicate they've done so. | [
"StopAllAndWait",
"stops",
"all",
"the",
"repos",
"refreshing",
"and",
"waits",
"for",
"them",
"to",
"indicate",
"they",
"ve",
"done",
"so",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/git/mirrors.go#L102-L111 |
131,564 | weaveworks/flux | git/mirrors.go | RefreshAll | func (m *Mirrors) RefreshAll(timeout time.Duration) []error {
m.reposMu.Lock()
defer m.reposMu.Unlock()
var errs []error
for _, state := range m.repos {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
if err := state.repo.Refresh(ctx); err != nil {
errs = append(errs, err)
}
cancel()
... | go | func (m *Mirrors) RefreshAll(timeout time.Duration) []error {
m.reposMu.Lock()
defer m.reposMu.Unlock()
var errs []error
for _, state := range m.repos {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
if err := state.repo.Refresh(ctx); err != nil {
errs = append(errs, err)
}
cancel()
... | [
"func",
"(",
"m",
"*",
"Mirrors",
")",
"RefreshAll",
"(",
"timeout",
"time",
".",
"Duration",
")",
"[",
"]",
"error",
"{",
"m",
".",
"reposMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"reposMu",
".",
"Unlock",
"(",
")",
"\n\n",
"var",
"er... | // RefreshAll instructs all the repos to refresh, this means
// fetching updated refs, and associated objects. The given
// timeout is the timeout per mirror and _not_ the timeout
// for the whole operation. It returns a collection of
// eventual errors it encountered. | [
"RefreshAll",
"instructs",
"all",
"the",
"repos",
"to",
"refresh",
"this",
"means",
"fetching",
"updated",
"refs",
"and",
"associated",
"objects",
".",
"The",
"given",
"timeout",
"is",
"the",
"timeout",
"per",
"mirror",
"and",
"_not_",
"the",
"timeout",
"for",... | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/git/mirrors.go#L130-L143 |
131,565 | weaveworks/flux | update/menu.go | writeln | func (c *writer) writeln(line string) error {
line += "\n"
c.lines += (len(line)-1)/int(c.width) + 1
_, err := c.tw.Write([]byte(line))
return err
} | go | func (c *writer) writeln(line string) error {
line += "\n"
c.lines += (len(line)-1)/int(c.width) + 1
_, err := c.tw.Write([]byte(line))
return err
} | [
"func",
"(",
"c",
"*",
"writer",
")",
"writeln",
"(",
"line",
"string",
")",
"error",
"{",
"line",
"+=",
"\"",
"\\n",
"\"",
"\n",
"c",
".",
"lines",
"+=",
"(",
"len",
"(",
"line",
")",
"-",
"1",
")",
"/",
"int",
"(",
"c",
".",
"width",
")",
... | // writeln counts the lines we output. | [
"writeln",
"counts",
"the",
"lines",
"we",
"output",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/update/menu.go#L51-L56 |
131,566 | weaveworks/flux | update/menu.go | clear | func (c *writer) clear() {
if c.lines != 0 {
fmt.Fprintf(c.out, moveCursorUp, c.lines)
}
c.lines = 0
} | go | func (c *writer) clear() {
if c.lines != 0 {
fmt.Fprintf(c.out, moveCursorUp, c.lines)
}
c.lines = 0
} | [
"func",
"(",
"c",
"*",
"writer",
")",
"clear",
"(",
")",
"{",
"if",
"c",
".",
"lines",
"!=",
"0",
"{",
"fmt",
".",
"Fprintf",
"(",
"c",
".",
"out",
",",
"moveCursorUp",
",",
"c",
".",
"lines",
")",
"\n",
"}",
"\n",
"c",
".",
"lines",
"=",
"... | // clear moves the terminal cursor up to the beginning of the
// line where we started writing. | [
"clear",
"moves",
"the",
"terminal",
"cursor",
"up",
"to",
"the",
"beginning",
"of",
"the",
"line",
"where",
"we",
"started",
"writing",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/update/menu.go#L60-L65 |
131,567 | weaveworks/flux | update/menu.go | Run | func (m *Menu) Run() (map[flux.ResourceID][]ContainerUpdate, error) {
specs := make(map[flux.ResourceID][]ContainerUpdate)
if m.selectable == 0 {
return specs, errors.New("No changes found.")
}
m.printInteractive()
m.wr.hideCursor()
defer m.wr.showCursor()
for {
ascii, keyCode, err := getChar()
if err !=... | go | func (m *Menu) Run() (map[flux.ResourceID][]ContainerUpdate, error) {
specs := make(map[flux.ResourceID][]ContainerUpdate)
if m.selectable == 0 {
return specs, errors.New("No changes found.")
}
m.printInteractive()
m.wr.hideCursor()
defer m.wr.showCursor()
for {
ascii, keyCode, err := getChar()
if err !=... | [
"func",
"(",
"m",
"*",
"Menu",
")",
"Run",
"(",
")",
"(",
"map",
"[",
"flux",
".",
"ResourceID",
"]",
"[",
"]",
"ContainerUpdate",
",",
"error",
")",
"{",
"specs",
":=",
"make",
"(",
"map",
"[",
"flux",
".",
"ResourceID",
"]",
"[",
"]",
"Containe... | // Run starts the interactive menu mode. | [
"Run",
"starts",
"the",
"interactive",
"menu",
"mode",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/update/menu.go#L150-L193 |
131,568 | weaveworks/flux | image/image.go | Repository | func (i Name) Repository() string {
switch i.Domain {
case "", oldDockerHubHost, dockerHubHost:
path := strings.Split(i.Image, "/")
if len(path) == 1 {
return "library/" + i.Image
}
return i.Image
default:
return i.Image
}
} | go | func (i Name) Repository() string {
switch i.Domain {
case "", oldDockerHubHost, dockerHubHost:
path := strings.Split(i.Image, "/")
if len(path) == 1 {
return "library/" + i.Image
}
return i.Image
default:
return i.Image
}
} | [
"func",
"(",
"i",
"Name",
")",
"Repository",
"(",
")",
"string",
"{",
"switch",
"i",
".",
"Domain",
"{",
"case",
"\"",
"\"",
",",
"oldDockerHubHost",
",",
"dockerHubHost",
":",
"path",
":=",
"strings",
".",
"Split",
"(",
"i",
".",
"Image",
",",
"\"",... | // Repository returns the canonicalised path part of an Name. | [
"Repository",
"returns",
"the",
"canonicalised",
"path",
"part",
"of",
"an",
"Name",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/image/image.go#L61-L72 |
131,569 | weaveworks/flux | image/image.go | Registry | func (i Name) Registry() string {
switch i.Domain {
case "", oldDockerHubHost:
return dockerHubHost
default:
return i.Domain
}
} | go | func (i Name) Registry() string {
switch i.Domain {
case "", oldDockerHubHost:
return dockerHubHost
default:
return i.Domain
}
} | [
"func",
"(",
"i",
"Name",
")",
"Registry",
"(",
")",
"string",
"{",
"switch",
"i",
".",
"Domain",
"{",
"case",
"\"",
"\"",
",",
"oldDockerHubHost",
":",
"return",
"dockerHubHost",
"\n",
"default",
":",
"return",
"i",
".",
"Domain",
"\n",
"}",
"\n",
"... | // Registry returns the domain name of the Docker image registry, to
// use to fetch the image or image metadata. | [
"Registry",
"returns",
"the",
"domain",
"name",
"of",
"the",
"Docker",
"image",
"registry",
"to",
"use",
"to",
"fetch",
"the",
"image",
"or",
"image",
"metadata",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/image/image.go#L76-L83 |
131,570 | weaveworks/flux | image/image.go | CanonicalName | func (i Name) CanonicalName() CanonicalName {
return CanonicalName{
Name: Name{
Domain: i.Registry(),
Image: i.Repository(),
},
}
} | go | func (i Name) CanonicalName() CanonicalName {
return CanonicalName{
Name: Name{
Domain: i.Registry(),
Image: i.Repository(),
},
}
} | [
"func",
"(",
"i",
"Name",
")",
"CanonicalName",
"(",
")",
"CanonicalName",
"{",
"return",
"CanonicalName",
"{",
"Name",
":",
"Name",
"{",
"Domain",
":",
"i",
".",
"Registry",
"(",
")",
",",
"Image",
":",
"i",
".",
"Repository",
"(",
")",
",",
"}",
... | // CanonicalName returns the canonicalised registry host and image parts
// of the ID. | [
"CanonicalName",
"returns",
"the",
"canonicalised",
"registry",
"host",
"and",
"image",
"parts",
"of",
"the",
"ID",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/image/image.go#L87-L94 |
131,571 | weaveworks/flux | image/image.go | CanonicalRef | func (i Ref) CanonicalRef() CanonicalRef {
name := i.CanonicalName()
return CanonicalRef{
Ref: Ref{
Name: name.Name,
Tag: i.Tag,
},
}
} | go | func (i Ref) CanonicalRef() CanonicalRef {
name := i.CanonicalName()
return CanonicalRef{
Ref: Ref{
Name: name.Name,
Tag: i.Tag,
},
}
} | [
"func",
"(",
"i",
"Ref",
")",
"CanonicalRef",
"(",
")",
"CanonicalRef",
"{",
"name",
":=",
"i",
".",
"CanonicalName",
"(",
")",
"\n",
"return",
"CanonicalRef",
"{",
"Ref",
":",
"Ref",
"{",
"Name",
":",
"name",
".",
"Name",
",",
"Tag",
":",
"i",
"."... | // CanonicalRef returns the canonicalised reference including the tag
// if present. | [
"CanonicalRef",
"returns",
"the",
"canonicalised",
"reference",
"including",
"the",
"tag",
"if",
"present",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/image/image.go#L204-L212 |
131,572 | weaveworks/flux | image/image.go | WithNewTag | func (i Ref) WithNewTag(t string) Ref {
var img Ref
img = i
img.Tag = t
return img
} | go | func (i Ref) WithNewTag(t string) Ref {
var img Ref
img = i
img.Tag = t
return img
} | [
"func",
"(",
"i",
"Ref",
")",
"WithNewTag",
"(",
"t",
"string",
")",
"Ref",
"{",
"var",
"img",
"Ref",
"\n",
"img",
"=",
"i",
"\n",
"img",
".",
"Tag",
"=",
"t",
"\n",
"return",
"img",
"\n",
"}"
] | // WithNewTag makes a new copy of an ImageID with a new tag | [
"WithNewTag",
"makes",
"a",
"new",
"copy",
"of",
"an",
"ImageID",
"with",
"a",
"new",
"tag"
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/image/image.go#L219-L224 |
131,573 | weaveworks/flux | image/image.go | FindImageWithRef | func (rm RepositoryMetadata) FindImageWithRef(ref Ref) Info {
for _, img := range rm.Images {
if img.ID == ref {
return img
}
}
return Info{ID: ref}
} | go | func (rm RepositoryMetadata) FindImageWithRef(ref Ref) Info {
for _, img := range rm.Images {
if img.ID == ref {
return img
}
}
return Info{ID: ref}
} | [
"func",
"(",
"rm",
"RepositoryMetadata",
")",
"FindImageWithRef",
"(",
"ref",
"Ref",
")",
"Info",
"{",
"for",
"_",
",",
"img",
":=",
"range",
"rm",
".",
"Images",
"{",
"if",
"img",
".",
"ID",
"==",
"ref",
"{",
"return",
"img",
"\n",
"}",
"\n",
"}",... | // FindImageWithRef returns image.Info given an image ref. If the image cannot be
// found, it returns the image.Info with the ID provided. | [
"FindImageWithRef",
"returns",
"image",
".",
"Info",
"given",
"an",
"image",
"ref",
".",
"If",
"the",
"image",
"cannot",
"be",
"found",
"it",
"returns",
"the",
"image",
".",
"Info",
"with",
"the",
"ID",
"provided",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/image/image.go#L298-L305 |
131,574 | weaveworks/flux | image/image.go | GetImageTagInfo | func (rm RepositoryMetadata) GetImageTagInfo() ([]Info, error) {
result := make([]Info, len(rm.Tags), len(rm.Tags))
for i, tag := range rm.Tags {
info, ok := rm.Images[tag]
if !ok {
return nil, fmt.Errorf("missing metadata for image tag %q", tag)
}
result[i] = info
}
return result, nil
} | go | func (rm RepositoryMetadata) GetImageTagInfo() ([]Info, error) {
result := make([]Info, len(rm.Tags), len(rm.Tags))
for i, tag := range rm.Tags {
info, ok := rm.Images[tag]
if !ok {
return nil, fmt.Errorf("missing metadata for image tag %q", tag)
}
result[i] = info
}
return result, nil
} | [
"func",
"(",
"rm",
"RepositoryMetadata",
")",
"GetImageTagInfo",
"(",
")",
"(",
"[",
"]",
"Info",
",",
"error",
")",
"{",
"result",
":=",
"make",
"(",
"[",
"]",
"Info",
",",
"len",
"(",
"rm",
".",
"Tags",
")",
",",
"len",
"(",
"rm",
".",
"Tags",
... | // GetImageTagInfo gets the information of all image tags.
// If there are tags missing information, an error is returned | [
"GetImageTagInfo",
"gets",
"the",
"information",
"of",
"all",
"image",
"tags",
".",
"If",
"there",
"are",
"tags",
"missing",
"information",
"an",
"error",
"is",
"returned"
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/image/image.go#L309-L319 |
131,575 | weaveworks/flux | image/image.go | NewerByCreated | func NewerByCreated(lhs, rhs *Info) bool {
if lhs.CreatedAt.Equal(rhs.CreatedAt) {
return lhs.ID.String() < rhs.ID.String()
}
return lhs.CreatedAt.After(rhs.CreatedAt)
} | go | func NewerByCreated(lhs, rhs *Info) bool {
if lhs.CreatedAt.Equal(rhs.CreatedAt) {
return lhs.ID.String() < rhs.ID.String()
}
return lhs.CreatedAt.After(rhs.CreatedAt)
} | [
"func",
"NewerByCreated",
"(",
"lhs",
",",
"rhs",
"*",
"Info",
")",
"bool",
"{",
"if",
"lhs",
".",
"CreatedAt",
".",
"Equal",
"(",
"rhs",
".",
"CreatedAt",
")",
"{",
"return",
"lhs",
".",
"ID",
".",
"String",
"(",
")",
"<",
"rhs",
".",
"ID",
".",... | // NewerByCreated returns true if lhs image should be sorted
// before rhs with regard to their creation date descending. | [
"NewerByCreated",
"returns",
"true",
"if",
"lhs",
"image",
"should",
"be",
"sorted",
"before",
"rhs",
"with",
"regard",
"to",
"their",
"creation",
"date",
"descending",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/image/image.go#L336-L341 |
131,576 | weaveworks/flux | image/image.go | NewerBySemver | func NewerBySemver(lhs, rhs *Info) bool {
lv, lerr := semver.NewVersion(lhs.ID.Tag)
rv, rerr := semver.NewVersion(rhs.ID.Tag)
if (lerr != nil && rerr != nil) || (lv == rv) {
return lhs.ID.String() < rhs.ID.String()
}
if lerr != nil {
return false
}
if rerr != nil {
return true
}
cmp := lv.Compare(rv)
//... | go | func NewerBySemver(lhs, rhs *Info) bool {
lv, lerr := semver.NewVersion(lhs.ID.Tag)
rv, rerr := semver.NewVersion(rhs.ID.Tag)
if (lerr != nil && rerr != nil) || (lv == rv) {
return lhs.ID.String() < rhs.ID.String()
}
if lerr != nil {
return false
}
if rerr != nil {
return true
}
cmp := lv.Compare(rv)
//... | [
"func",
"NewerBySemver",
"(",
"lhs",
",",
"rhs",
"*",
"Info",
")",
"bool",
"{",
"lv",
",",
"lerr",
":=",
"semver",
".",
"NewVersion",
"(",
"lhs",
".",
"ID",
".",
"Tag",
")",
"\n",
"rv",
",",
"rerr",
":=",
"semver",
".",
"NewVersion",
"(",
"rhs",
... | // NewerBySemver returns true if lhs image should be sorted
// before rhs with regard to their semver order descending. | [
"NewerBySemver",
"returns",
"true",
"if",
"lhs",
"image",
"should",
"be",
"sorted",
"before",
"rhs",
"with",
"regard",
"to",
"their",
"semver",
"order",
"descending",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/image/image.go#L345-L364 |
131,577 | weaveworks/flux | image/image.go | Sort | func Sort(infos []Info, newer func(a, b *Info) bool) {
if newer == nil {
newer = NewerByCreated
}
sort.Sort(&infoSort{infos: infos, newer: newer})
} | go | func Sort(infos []Info, newer func(a, b *Info) bool) {
if newer == nil {
newer = NewerByCreated
}
sort.Sort(&infoSort{infos: infos, newer: newer})
} | [
"func",
"Sort",
"(",
"infos",
"[",
"]",
"Info",
",",
"newer",
"func",
"(",
"a",
",",
"b",
"*",
"Info",
")",
"bool",
")",
"{",
"if",
"newer",
"==",
"nil",
"{",
"newer",
"=",
"NewerByCreated",
"\n",
"}",
"\n",
"sort",
".",
"Sort",
"(",
"&",
"info... | // Sort orders the given image infos according to `newer` func. | [
"Sort",
"orders",
"the",
"given",
"image",
"infos",
"according",
"to",
"newer",
"func",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/image/image.go#L367-L372 |
131,578 | weaveworks/flux | daemon/daemon.go | ListImages | func (d *Daemon) ListImages(ctx context.Context, spec update.ResourceSpec) ([]v6.ImageStatus, error) {
return d.ListImagesWithOptions(ctx, v10.ListImagesOptions{Spec: spec})
} | go | func (d *Daemon) ListImages(ctx context.Context, spec update.ResourceSpec) ([]v6.ImageStatus, error) {
return d.ListImagesWithOptions(ctx, v10.ListImagesOptions{Spec: spec})
} | [
"func",
"(",
"d",
"*",
"Daemon",
")",
"ListImages",
"(",
"ctx",
"context",
".",
"Context",
",",
"spec",
"update",
".",
"ResourceSpec",
")",
"(",
"[",
"]",
"v6",
".",
"ImageStatus",
",",
"error",
")",
"{",
"return",
"d",
".",
"ListImagesWithOptions",
"(... | // ListImages - deprecated from v10, lists the images available for set of workloads | [
"ListImages",
"-",
"deprecated",
"from",
"v10",
"lists",
"the",
"images",
"available",
"for",
"set",
"of",
"workloads"
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/daemon/daemon.go#L173-L175 |
131,579 | weaveworks/flux | daemon/daemon.go | ListImagesWithOptions | func (d *Daemon) ListImagesWithOptions(ctx context.Context, opts v10.ListImagesOptions) ([]v6.ImageStatus, error) {
if opts.Namespace != "" && opts.Spec != update.ResourceSpecAll {
return nil, errors.New("cannot filter by 'namespace' and 'workload' at the same time")
}
var workloads []cluster.Workload
var err er... | go | func (d *Daemon) ListImagesWithOptions(ctx context.Context, opts v10.ListImagesOptions) ([]v6.ImageStatus, error) {
if opts.Namespace != "" && opts.Spec != update.ResourceSpecAll {
return nil, errors.New("cannot filter by 'namespace' and 'workload' at the same time")
}
var workloads []cluster.Workload
var err er... | [
"func",
"(",
"d",
"*",
"Daemon",
")",
"ListImagesWithOptions",
"(",
"ctx",
"context",
".",
"Context",
",",
"opts",
"v10",
".",
"ListImagesOptions",
")",
"(",
"[",
"]",
"v6",
".",
"ImageStatus",
",",
"error",
")",
"{",
"if",
"opts",
".",
"Namespace",
"!... | // ListImagesWithOptions lists the images available for set of workloads | [
"ListImagesWithOptions",
"lists",
"the",
"images",
"available",
"for",
"set",
"of",
"workloads"
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/daemon/daemon.go#L178-L224 |
131,580 | weaveworks/flux | daemon/daemon.go | makeJobFromUpdate | func (d *Daemon) makeJobFromUpdate(update updateFunc) jobFunc {
return func(ctx context.Context, jobID job.ID, logger log.Logger) (job.Result, error) {
var result job.Result
err := d.WithClone(ctx, func(working *git.Checkout) error {
var err error
result, err = update(ctx, jobID, working, logger)
if err !... | go | func (d *Daemon) makeJobFromUpdate(update updateFunc) jobFunc {
return func(ctx context.Context, jobID job.ID, logger log.Logger) (job.Result, error) {
var result job.Result
err := d.WithClone(ctx, func(working *git.Checkout) error {
var err error
result, err = update(ctx, jobID, working, logger)
if err !... | [
"func",
"(",
"d",
"*",
"Daemon",
")",
"makeJobFromUpdate",
"(",
"update",
"updateFunc",
")",
"jobFunc",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"jobID",
"job",
".",
"ID",
",",
"logger",
"log",
".",
"Logger",
")",
"(",
"job",
... | // makeJobFromUpdate turns an updateFunc into a jobFunc that will run
// the update with a fresh clone, and log the result as an event. | [
"makeJobFromUpdate",
"turns",
"an",
"updateFunc",
"into",
"a",
"jobFunc",
"that",
"will",
"run",
"the",
"update",
"with",
"a",
"fresh",
"clone",
"and",
"log",
"the",
"result",
"as",
"an",
"event",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/daemon/daemon.go#L234-L250 |
131,581 | weaveworks/flux | daemon/daemon.go | executeJob | func (d *Daemon) executeJob(id job.ID, do jobFunc, logger log.Logger) (job.Result, error) {
ctx, cancel := context.WithTimeout(context.Background(), defaultJobTimeout)
defer cancel()
d.JobStatusCache.SetStatus(id, job.Status{StatusString: job.StatusRunning})
result, err := do(ctx, id, logger)
if err != nil {
d.J... | go | func (d *Daemon) executeJob(id job.ID, do jobFunc, logger log.Logger) (job.Result, error) {
ctx, cancel := context.WithTimeout(context.Background(), defaultJobTimeout)
defer cancel()
d.JobStatusCache.SetStatus(id, job.Status{StatusString: job.StatusRunning})
result, err := do(ctx, id, logger)
if err != nil {
d.J... | [
"func",
"(",
"d",
"*",
"Daemon",
")",
"executeJob",
"(",
"id",
"job",
".",
"ID",
",",
"do",
"jobFunc",
",",
"logger",
"log",
".",
"Logger",
")",
"(",
"job",
".",
"Result",
",",
"error",
")",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithT... | // executeJob runs a job func and keeps track of its status, so the
// daemon can report it when asked. | [
"executeJob",
"runs",
"a",
"job",
"func",
"and",
"keeps",
"track",
"of",
"its",
"status",
"so",
"the",
"daemon",
"can",
"report",
"it",
"when",
"asked",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/daemon/daemon.go#L254-L265 |
131,582 | weaveworks/flux | daemon/daemon.go | makeLoggingJobFunc | func (d *Daemon) makeLoggingJobFunc(f jobFunc) jobFunc {
return func(ctx context.Context, id job.ID, logger log.Logger) (job.Result, error) {
started := time.Now().UTC()
result, err := f(ctx, id, logger)
if err != nil {
return result, err
}
logger.Log("revision", result.Revision)
if result.Revision != "... | go | func (d *Daemon) makeLoggingJobFunc(f jobFunc) jobFunc {
return func(ctx context.Context, id job.ID, logger log.Logger) (job.Result, error) {
started := time.Now().UTC()
result, err := f(ctx, id, logger)
if err != nil {
return result, err
}
logger.Log("revision", result.Revision)
if result.Revision != "... | [
"func",
"(",
"d",
"*",
"Daemon",
")",
"makeLoggingJobFunc",
"(",
"f",
"jobFunc",
")",
"jobFunc",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"job",
".",
"ID",
",",
"logger",
"log",
".",
"Logger",
")",
"(",
"job",
".",
"... | // makeLoggingFunc takes a jobFunc and returns a jobFunc that will log
// a commit event with the result. | [
"makeLoggingFunc",
"takes",
"a",
"jobFunc",
"and",
"returns",
"a",
"jobFunc",
"that",
"will",
"log",
"a",
"commit",
"event",
"with",
"the",
"result",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/daemon/daemon.go#L269-L302 |
131,583 | weaveworks/flux | daemon/daemon.go | queueJob | func (d *Daemon) queueJob(do jobFunc) job.ID {
id := job.ID(guid.New())
enqueuedAt := time.Now()
d.Jobs.Enqueue(&job.Job{
ID: id,
Do: func(logger log.Logger) error {
queueDuration.Observe(time.Since(enqueuedAt).Seconds())
_, err := d.executeJob(id, do, logger)
if err != nil {
return err
}
retu... | go | func (d *Daemon) queueJob(do jobFunc) job.ID {
id := job.ID(guid.New())
enqueuedAt := time.Now()
d.Jobs.Enqueue(&job.Job{
ID: id,
Do: func(logger log.Logger) error {
queueDuration.Observe(time.Since(enqueuedAt).Seconds())
_, err := d.executeJob(id, do, logger)
if err != nil {
return err
}
retu... | [
"func",
"(",
"d",
"*",
"Daemon",
")",
"queueJob",
"(",
"do",
"jobFunc",
")",
"job",
".",
"ID",
"{",
"id",
":=",
"job",
".",
"ID",
"(",
"guid",
".",
"New",
"(",
")",
")",
"\n",
"enqueuedAt",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"d",
".",
... | // queueJob queues a job func to be executed. | [
"queueJob",
"queues",
"a",
"job",
"func",
"to",
"be",
"executed",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/daemon/daemon.go#L305-L322 |
131,584 | weaveworks/flux | daemon/daemon.go | UpdateManifests | func (d *Daemon) UpdateManifests(ctx context.Context, spec update.Spec) (job.ID, error) {
var id job.ID
if spec.Type == "" {
return id, errors.New("no type in update spec")
}
switch s := spec.Spec.(type) {
case release.Changes:
if s.ReleaseKind() == update.ReleaseKindPlan {
id := job.ID(guid.New())
_, er... | go | func (d *Daemon) UpdateManifests(ctx context.Context, spec update.Spec) (job.ID, error) {
var id job.ID
if spec.Type == "" {
return id, errors.New("no type in update spec")
}
switch s := spec.Spec.(type) {
case release.Changes:
if s.ReleaseKind() == update.ReleaseKindPlan {
id := job.ID(guid.New())
_, er... | [
"func",
"(",
"d",
"*",
"Daemon",
")",
"UpdateManifests",
"(",
"ctx",
"context",
".",
"Context",
",",
"spec",
"update",
".",
"Spec",
")",
"(",
"job",
".",
"ID",
",",
"error",
")",
"{",
"var",
"id",
"job",
".",
"ID",
"\n",
"if",
"spec",
".",
"Type"... | // Apply the desired changes to the config files | [
"Apply",
"the",
"desired",
"changes",
"to",
"the",
"config",
"files"
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/daemon/daemon.go#L325-L345 |
131,585 | weaveworks/flux | daemon/daemon.go | NotifyChange | func (d *Daemon) NotifyChange(ctx context.Context, change v9.Change) error {
switch change.Kind {
case v9.GitChange:
gitUpdate := change.Source.(v9.GitUpdate)
if gitUpdate.URL != d.Repo.Origin().URL && gitUpdate.Branch != d.GitConfig.Branch {
// It isn't strictly an _error_ to be notified about a repo/branch p... | go | func (d *Daemon) NotifyChange(ctx context.Context, change v9.Change) error {
switch change.Kind {
case v9.GitChange:
gitUpdate := change.Source.(v9.GitUpdate)
if gitUpdate.URL != d.Repo.Origin().URL && gitUpdate.Branch != d.GitConfig.Branch {
// It isn't strictly an _error_ to be notified about a repo/branch p... | [
"func",
"(",
"d",
"*",
"Daemon",
")",
"NotifyChange",
"(",
"ctx",
"context",
".",
"Context",
",",
"change",
"v9",
".",
"Change",
")",
"error",
"{",
"switch",
"change",
".",
"Kind",
"{",
"case",
"v9",
".",
"GitChange",
":",
"gitUpdate",
":=",
"change",
... | // Tell the daemon to synchronise the cluster with the manifests in
// the git repo. This has an error return value because upstream there
// may be comms difficulties or other sources of problems; here, we
// always succeed because it's just bookkeeping. | [
"Tell",
"the",
"daemon",
"to",
"synchronise",
"the",
"cluster",
"with",
"the",
"manifests",
"in",
"the",
"git",
"repo",
".",
"This",
"has",
"an",
"error",
"return",
"value",
"because",
"upstream",
"there",
"may",
"be",
"comms",
"difficulties",
"or",
"other",... | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/daemon/daemon.go#L504-L522 |
131,586 | weaveworks/flux | daemon/daemon.go | JobStatus | func (d *Daemon) JobStatus(ctx context.Context, jobID job.ID) (job.Status, error) {
// Is the job queued, running, or recently finished?
status, ok := d.JobStatusCache.Status(jobID)
if ok {
return status, nil
}
// Look through the commits for a note referencing this job. This
// means that even if fluxd resta... | go | func (d *Daemon) JobStatus(ctx context.Context, jobID job.ID) (job.Status, error) {
// Is the job queued, running, or recently finished?
status, ok := d.JobStatusCache.Status(jobID)
if ok {
return status, nil
}
// Look through the commits for a note referencing this job. This
// means that even if fluxd resta... | [
"func",
"(",
"d",
"*",
"Daemon",
")",
"JobStatus",
"(",
"ctx",
"context",
".",
"Context",
",",
"jobID",
"job",
".",
"ID",
")",
"(",
"job",
".",
"Status",
",",
"error",
")",
"{",
"// Is the job queued, running, or recently finished?",
"status",
",",
"ok",
"... | // JobStatus - Ask the daemon how far it's got committing things; in particular, is the job
// queued? running? committed? If it is done, the commit ref is returned. | [
"JobStatus",
"-",
"Ask",
"the",
"daemon",
"how",
"far",
"it",
"s",
"got",
"committing",
"things",
";",
"in",
"particular",
"is",
"the",
"job",
"queued?",
"running?",
"committed?",
"If",
"it",
"is",
"done",
"the",
"commit",
"ref",
"is",
"returned",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/daemon/daemon.go#L526-L567 |
131,587 | weaveworks/flux | daemon/daemon.go | WithClone | func (d *Daemon) WithClone(ctx context.Context, fn func(*git.Checkout) error) error {
co, err := d.Repo.Clone(ctx, d.GitConfig)
if err != nil {
return err
}
defer co.Clean()
return fn(co)
} | go | func (d *Daemon) WithClone(ctx context.Context, fn func(*git.Checkout) error) error {
co, err := d.Repo.Clone(ctx, d.GitConfig)
if err != nil {
return err
}
defer co.Clean()
return fn(co)
} | [
"func",
"(",
"d",
"*",
"Daemon",
")",
"WithClone",
"(",
"ctx",
"context",
".",
"Context",
",",
"fn",
"func",
"(",
"*",
"git",
".",
"Checkout",
")",
"error",
")",
"error",
"{",
"co",
",",
"err",
":=",
"d",
".",
"Repo",
".",
"Clone",
"(",
"ctx",
... | // Non-api.Server methods | [
"Non",
"-",
"api",
".",
"Server",
"methods"
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/daemon/daemon.go#L613-L620 |
131,588 | weaveworks/flux | daemon/daemon.go | containers2containers | func containers2containers(cs []resource.Container) []v6.Container {
res := make([]v6.Container, len(cs))
for i, c := range cs {
res[i] = v6.Container{
Name: c.Name,
Current: image.Info{
ID: c.Image,
},
}
}
return res
} | go | func containers2containers(cs []resource.Container) []v6.Container {
res := make([]v6.Container, len(cs))
for i, c := range cs {
res[i] = v6.Container{
Name: c.Name,
Current: image.Info{
ID: c.Image,
},
}
}
return res
} | [
"func",
"containers2containers",
"(",
"cs",
"[",
"]",
"resource",
".",
"Container",
")",
"[",
"]",
"v6",
".",
"Container",
"{",
"res",
":=",
"make",
"(",
"[",
"]",
"v6",
".",
"Container",
",",
"len",
"(",
"cs",
")",
")",
"\n",
"for",
"i",
",",
"c... | // vvv helpers vvv | [
"vvv",
"helpers",
"vvv"
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/daemon/daemon.go#L633-L644 |
131,589 | weaveworks/flux | daemon/daemon.go | policyEventTypes | func policyEventTypes(u policy.Update) []string {
types := map[string]struct{}{}
for p := range u.Add {
switch {
case p == policy.Automated:
types[event.EventAutomate] = struct{}{}
case p == policy.Locked:
types[event.EventLock] = struct{}{}
default:
types[event.EventUpdatePolicy] = struct{}{}
}
}... | go | func policyEventTypes(u policy.Update) []string {
types := map[string]struct{}{}
for p := range u.Add {
switch {
case p == policy.Automated:
types[event.EventAutomate] = struct{}{}
case p == policy.Locked:
types[event.EventLock] = struct{}{}
default:
types[event.EventUpdatePolicy] = struct{}{}
}
}... | [
"func",
"policyEventTypes",
"(",
"u",
"policy",
".",
"Update",
")",
"[",
"]",
"string",
"{",
"types",
":=",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
"{",
"}",
"\n",
"for",
"p",
":=",
"range",
"u",
".",
"Add",
"{",
"switch",
"{",
"case",
"p"... | // policyEventTypes is a deduped list of all event types this update contains | [
"policyEventTypes",
"is",
"a",
"deduped",
"list",
"of",
"all",
"event",
"types",
"this",
"update",
"contains"
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/daemon/daemon.go#L724-L753 |
131,590 | weaveworks/flux | integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/fake_fluxhelmrelease.go | Get | func (c *FakeFluxHelmReleases) Get(name string, options v1.GetOptions) (result *v1alpha2.FluxHelmRelease, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(fluxhelmreleasesResource, c.ns, name), &v1alpha2.FluxHelmRelease{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.FluxHelmRelease), e... | go | func (c *FakeFluxHelmReleases) Get(name string, options v1.GetOptions) (result *v1alpha2.FluxHelmRelease, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(fluxhelmreleasesResource, c.ns, name), &v1alpha2.FluxHelmRelease{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.FluxHelmRelease), e... | [
"func",
"(",
"c",
"*",
"FakeFluxHelmReleases",
")",
"Get",
"(",
"name",
"string",
",",
"options",
"v1",
".",
"GetOptions",
")",
"(",
"result",
"*",
"v1alpha2",
".",
"FluxHelmRelease",
",",
"err",
"error",
")",
"{",
"obj",
",",
"err",
":=",
"c",
".",
... | // Get takes name of the fluxHelmRelease, and returns the corresponding fluxHelmRelease object, and an error if there is any. | [
"Get",
"takes",
"name",
"of",
"the",
"fluxHelmRelease",
"and",
"returns",
"the",
"corresponding",
"fluxHelmRelease",
"object",
"and",
"an",
"error",
"if",
"there",
"is",
"any",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/fake_fluxhelmrelease.go#L42-L50 |
131,591 | weaveworks/flux | integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/fake_fluxhelmrelease.go | List | func (c *FakeFluxHelmReleases) List(opts v1.ListOptions) (result *v1alpha2.FluxHelmReleaseList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(fluxhelmreleasesResource, fluxhelmreleasesKind, c.ns, opts), &v1alpha2.FluxHelmReleaseList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.... | go | func (c *FakeFluxHelmReleases) List(opts v1.ListOptions) (result *v1alpha2.FluxHelmReleaseList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(fluxhelmreleasesResource, fluxhelmreleasesKind, c.ns, opts), &v1alpha2.FluxHelmReleaseList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.... | [
"func",
"(",
"c",
"*",
"FakeFluxHelmReleases",
")",
"List",
"(",
"opts",
"v1",
".",
"ListOptions",
")",
"(",
"result",
"*",
"v1alpha2",
".",
"FluxHelmReleaseList",
",",
"err",
"error",
")",
"{",
"obj",
",",
"err",
":=",
"c",
".",
"Fake",
".",
"Invokes"... | // List takes label and field selectors, and returns the list of FluxHelmReleases that match those selectors. | [
"List",
"takes",
"label",
"and",
"field",
"selectors",
"and",
"returns",
"the",
"list",
"of",
"FluxHelmReleases",
"that",
"match",
"those",
"selectors",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/fake_fluxhelmrelease.go#L53-L72 |
131,592 | weaveworks/flux | integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/fake_fluxhelmrelease.go | Watch | func (c *FakeFluxHelmReleases) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(fluxhelmreleasesResource, c.ns, opts))
} | go | func (c *FakeFluxHelmReleases) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(fluxhelmreleasesResource, c.ns, opts))
} | [
"func",
"(",
"c",
"*",
"FakeFluxHelmReleases",
")",
"Watch",
"(",
"opts",
"v1",
".",
"ListOptions",
")",
"(",
"watch",
".",
"Interface",
",",
"error",
")",
"{",
"return",
"c",
".",
"Fake",
".",
"InvokesWatch",
"(",
"testing",
".",
"NewWatchAction",
"(",
... | // Watch returns a watch.Interface that watches the requested fluxHelmReleases. | [
"Watch",
"returns",
"a",
"watch",
".",
"Interface",
"that",
"watches",
"the",
"requested",
"fluxHelmReleases",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/fake_fluxhelmrelease.go#L75-L79 |
131,593 | weaveworks/flux | integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/fake_fluxhelmrelease.go | Delete | func (c *FakeFluxHelmReleases) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(fluxhelmreleasesResource, c.ns, name), &v1alpha2.FluxHelmRelease{})
return err
} | go | func (c *FakeFluxHelmReleases) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(fluxhelmreleasesResource, c.ns, name), &v1alpha2.FluxHelmRelease{})
return err
} | [
"func",
"(",
"c",
"*",
"FakeFluxHelmReleases",
")",
"Delete",
"(",
"name",
"string",
",",
"options",
"*",
"v1",
".",
"DeleteOptions",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"Fake",
".",
"Invokes",
"(",
"testing",
".",
"NewDeleteAction",
"(... | // Delete takes name of the fluxHelmRelease and deletes it. Returns an error if one occurs. | [
"Delete",
"takes",
"name",
"of",
"the",
"fluxHelmRelease",
"and",
"deletes",
"it",
".",
"Returns",
"an",
"error",
"if",
"one",
"occurs",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/fake_fluxhelmrelease.go#L104-L109 |
131,594 | weaveworks/flux | integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/fake_fluxhelmrelease.go | Patch | func (c *FakeFluxHelmReleases) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.FluxHelmRelease, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(fluxhelmreleasesResource, c.ns, name, pt, data, subresources...), &v1alpha2.FluxHelmRelease{})
if ... | go | func (c *FakeFluxHelmReleases) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.FluxHelmRelease, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(fluxhelmreleasesResource, c.ns, name, pt, data, subresources...), &v1alpha2.FluxHelmRelease{})
if ... | [
"func",
"(",
"c",
"*",
"FakeFluxHelmReleases",
")",
"Patch",
"(",
"name",
"string",
",",
"pt",
"types",
".",
"PatchType",
",",
"data",
"[",
"]",
"byte",
",",
"subresources",
"...",
"string",
")",
"(",
"result",
"*",
"v1alpha2",
".",
"FluxHelmRelease",
",... | // Patch applies the patch and returns the patched fluxHelmRelease. | [
"Patch",
"applies",
"the",
"patch",
"and",
"returns",
"the",
"patched",
"fluxHelmRelease",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/fake_fluxhelmrelease.go#L120-L128 |
131,595 | weaveworks/flux | event/event.go | UnmarshalJSON | func (ev *SyncEventMetadata) UnmarshalJSON(b []byte) error {
type data SyncEventMetadata
err := json.Unmarshal(b, (*data)(ev))
if err != nil {
return err
}
if ev.Commits == nil {
ev.Commits = make([]Commit, len(ev.Revs))
for i, rev := range ev.Revs {
ev.Commits[i].Revision = rev
}
}
return nil
} | go | func (ev *SyncEventMetadata) UnmarshalJSON(b []byte) error {
type data SyncEventMetadata
err := json.Unmarshal(b, (*data)(ev))
if err != nil {
return err
}
if ev.Commits == nil {
ev.Commits = make([]Commit, len(ev.Revs))
for i, rev := range ev.Revs {
ev.Commits[i].Revision = rev
}
}
return nil
} | [
"func",
"(",
"ev",
"*",
"SyncEventMetadata",
")",
"UnmarshalJSON",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"type",
"data",
"SyncEventMetadata",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"b",
",",
"(",
"*",
"data",
")",
"(",
"ev",
")",
... | // Account for old events, which used the revisions field rather than commits | [
"Account",
"for",
"old",
"events",
"which",
"used",
"the",
"revisions",
"field",
"rather",
"than",
"commits"
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/event/event.go#L223-L236 |
131,596 | weaveworks/flux | event/event.go | IsKindExecute | func (s ReleaseSpec) IsKindExecute() (bool, error) {
switch s.Type {
case ReleaseImageSpecType:
if s.ReleaseImageSpec != nil && s.ReleaseImageSpec.Kind == update.ReleaseKindExecute {
return true, nil
}
case ReleaseContainersSpecType:
if s.ReleaseContainersSpec != nil && s.ReleaseContainersSpec.Kind == updat... | go | func (s ReleaseSpec) IsKindExecute() (bool, error) {
switch s.Type {
case ReleaseImageSpecType:
if s.ReleaseImageSpec != nil && s.ReleaseImageSpec.Kind == update.ReleaseKindExecute {
return true, nil
}
case ReleaseContainersSpecType:
if s.ReleaseContainersSpec != nil && s.ReleaseContainersSpec.Kind == updat... | [
"func",
"(",
"s",
"ReleaseSpec",
")",
"IsKindExecute",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"switch",
"s",
".",
"Type",
"{",
"case",
"ReleaseImageSpecType",
":",
"if",
"s",
".",
"ReleaseImageSpec",
"!=",
"nil",
"&&",
"s",
".",
"ReleaseImageSpec... | // IsKindExecute reports whether the release spec s has ReleaseImageSpec or ReleaseImageSpec with Kind execute
// or error if s has invalid Type | [
"IsKindExecute",
"reports",
"whether",
"the",
"release",
"spec",
"s",
"has",
"ReleaseImageSpec",
"or",
"ReleaseImageSpec",
"with",
"Kind",
"execute",
"or",
"error",
"if",
"s",
"has",
"invalid",
"Type"
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/event/event.go#L263-L278 |
131,597 | weaveworks/flux | registry/middleware/rate_limiter.go | BackOff | func (limiters *RateLimiters) BackOff(host string) {
limiters.mu.Lock()
defer limiters.mu.Unlock()
var limiter *rate.Limiter
if limiters.perHost == nil {
limiters.perHost = map[string]*rate.Limiter{}
}
if rl, ok := limiters.perHost[host]; ok {
limiter = rl
} else {
limiter = rate.NewLimiter(rate.Limit(lim... | go | func (limiters *RateLimiters) BackOff(host string) {
limiters.mu.Lock()
defer limiters.mu.Unlock()
var limiter *rate.Limiter
if limiters.perHost == nil {
limiters.perHost = map[string]*rate.Limiter{}
}
if rl, ok := limiters.perHost[host]; ok {
limiter = rl
} else {
limiter = rate.NewLimiter(rate.Limit(lim... | [
"func",
"(",
"limiters",
"*",
"RateLimiters",
")",
"BackOff",
"(",
"host",
"string",
")",
"{",
"limiters",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"limiters",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"var",
"limiter",
"*",
"rate",
".",
... | // BackOff can be called to explicitly reduce the limit for a
// particular host. Usually this isn't necessary since a RoundTripper
// obtained for a host will respond to `HTTP 429` by doing this for
// you. | [
"BackOff",
"can",
"be",
"called",
"to",
"explicitly",
"reduce",
"the",
"limit",
"for",
"a",
"particular",
"host",
".",
"Usually",
"this",
"isn",
"t",
"necessary",
"since",
"a",
"RoundTripper",
"obtained",
"for",
"a",
"host",
"will",
"respond",
"to",
"HTTP",
... | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/registry/middleware/rate_limiter.go#L53-L74 |
131,598 | weaveworks/flux | registry/middleware/rate_limiter.go | Recover | func (limiters *RateLimiters) Recover(host string) {
limiters.mu.Lock()
defer limiters.mu.Unlock()
if limiters.perHost == nil {
return
}
if limiter, ok := limiters.perHost[host]; ok {
oldLimit := float64(limiter.Limit())
newLimit := limiters.clip(oldLimit * recoverBy)
if newLimit != oldLimit && limiters.Lo... | go | func (limiters *RateLimiters) Recover(host string) {
limiters.mu.Lock()
defer limiters.mu.Unlock()
if limiters.perHost == nil {
return
}
if limiter, ok := limiters.perHost[host]; ok {
oldLimit := float64(limiter.Limit())
newLimit := limiters.clip(oldLimit * recoverBy)
if newLimit != oldLimit && limiters.Lo... | [
"func",
"(",
"limiters",
"*",
"RateLimiters",
")",
"Recover",
"(",
"host",
"string",
")",
"{",
"limiters",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"limiters",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"limiters",
".",
"perHost",
"==",
... | // Recover should be called when a use of a RoundTripper has
// succeeded, to bump the limit back up again. | [
"Recover",
"should",
"be",
"called",
"when",
"a",
"use",
"of",
"a",
"RoundTripper",
"has",
"succeeded",
"to",
"bump",
"the",
"limit",
"back",
"up",
"again",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/registry/middleware/rate_limiter.go#L78-L92 |
131,599 | weaveworks/flux | registry/middleware/rate_limiter.go | RoundTripper | func (limiters *RateLimiters) RoundTripper(rt http.RoundTripper, host string) http.RoundTripper {
limiters.mu.Lock()
defer limiters.mu.Unlock()
if limiters.perHost == nil {
limiters.perHost = map[string]*rate.Limiter{}
}
if _, ok := limiters.perHost[host]; !ok {
rl := rate.NewLimiter(rate.Limit(limiters.RPS),... | go | func (limiters *RateLimiters) RoundTripper(rt http.RoundTripper, host string) http.RoundTripper {
limiters.mu.Lock()
defer limiters.mu.Unlock()
if limiters.perHost == nil {
limiters.perHost = map[string]*rate.Limiter{}
}
if _, ok := limiters.perHost[host]; !ok {
rl := rate.NewLimiter(rate.Limit(limiters.RPS),... | [
"func",
"(",
"limiters",
"*",
"RateLimiters",
")",
"RoundTripper",
"(",
"rt",
"http",
".",
"RoundTripper",
",",
"host",
"string",
")",
"http",
".",
"RoundTripper",
"{",
"limiters",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"limiters",
".",
"mu",
... | // Limit returns a RoundTripper for a particular host. We expect to do
// a number of requests to a particular host at a time. | [
"Limit",
"returns",
"a",
"RoundTripper",
"for",
"a",
"particular",
"host",
".",
"We",
"expect",
"to",
"do",
"a",
"number",
"of",
"requests",
"to",
"a",
"particular",
"host",
"at",
"a",
"time",
"."
] | 6e1702275f5fae61a4d2c796215612450e73da62 | https://github.com/weaveworks/flux/blob/6e1702275f5fae61a4d2c796215612450e73da62/registry/middleware/rate_limiter.go#L96-L115 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.