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
20,700
ugorji/go
codec/helper.go
basicHandle
func basicHandle(hh Handle) (x *BasicHandle) { x = hh.getBasicHandle() // ** We need to simulate once.Do, to ensure no data race within the block. // ** Consequently, below would not work. // if atomic.CompareAndSwapUint32(&x.inited, 0, 1) { // x.be = hh.isBinary() // _, x.js = hh.(*JsonHandle) // x.n = hh.Na...
go
func basicHandle(hh Handle) (x *BasicHandle) { x = hh.getBasicHandle() // ** We need to simulate once.Do, to ensure no data race within the block. // ** Consequently, below would not work. // if atomic.CompareAndSwapUint32(&x.inited, 0, 1) { // x.be = hh.isBinary() // _, x.js = hh.(*JsonHandle) // x.n = hh.Na...
[ "func", "basicHandle", "(", "hh", "Handle", ")", "(", "x", "*", "BasicHandle", ")", "{", "x", "=", "hh", ".", "getBasicHandle", "(", ")", "\n", "// ** We need to simulate once.Do, to ensure no data race within the block.", "// ** Consequently, below would not work.", "// ...
// basicHandle returns an initialized BasicHandle from the Handle.
[ "basicHandle", "returns", "an", "initialized", "BasicHandle", "from", "the", "Handle", "." ]
1d7ab5c50b36701116070c4c612259f93c262367
https://github.com/ugorji/go/blob/1d7ab5c50b36701116070c4c612259f93c262367/codec/helper.go#L583-L600
20,701
ugorji/go
codec/helper.go
field
func (si *structFieldInfo) field(v reflect.Value, update bool) (rv2 reflect.Value, valid bool) { // replicate FieldByIndex for i, x := range si.is { if uint8(i) == si.nis { break } if v, valid = baseStructRv(v, update); !valid { return } v = v.Field(int(x)) } return v, true }
go
func (si *structFieldInfo) field(v reflect.Value, update bool) (rv2 reflect.Value, valid bool) { // replicate FieldByIndex for i, x := range si.is { if uint8(i) == si.nis { break } if v, valid = baseStructRv(v, update); !valid { return } v = v.Field(int(x)) } return v, true }
[ "func", "(", "si", "*", "structFieldInfo", ")", "field", "(", "v", "reflect", ".", "Value", ",", "update", "bool", ")", "(", "rv2", "reflect", ".", "Value", ",", "valid", "bool", ")", "{", "// replicate FieldByIndex", "for", "i", ",", "x", ":=", "range...
// rv returns the field of the struct. // If anonymous, it returns an Invalid
[ "rv", "returns", "the", "field", "of", "the", "struct", ".", "If", "anonymous", "it", "returns", "an", "Invalid" ]
1d7ab5c50b36701116070c4c612259f93c262367
https://github.com/ugorji/go/blob/1d7ab5c50b36701116070c4c612259f93c262367/codec/helper.go#L1236-L1249
20,702
ugorji/go
codec/encode.go
NewEncoderBytes
func NewEncoderBytes(out *[]byte, h Handle) *Encoder { e := newEncoder(h) e.ResetBytes(out) return e }
go
func NewEncoderBytes(out *[]byte, h Handle) *Encoder { e := newEncoder(h) e.ResetBytes(out) return e }
[ "func", "NewEncoderBytes", "(", "out", "*", "[", "]", "byte", ",", "h", "Handle", ")", "*", "Encoder", "{", "e", ":=", "newEncoder", "(", "h", ")", "\n", "e", ".", "ResetBytes", "(", "out", ")", "\n", "return", "e", "\n", "}" ]
// NewEncoderBytes returns an encoder for encoding directly and efficiently // into a byte slice, using zero-copying to temporary slices. // // It will potentially replace the output byte slice pointed to. // After encoding, the out parameter contains the encoded contents.
[ "NewEncoderBytes", "returns", "an", "encoder", "for", "encoding", "directly", "and", "efficiently", "into", "a", "byte", "slice", "using", "zero", "-", "copying", "to", "temporary", "slices", ".", "It", "will", "potentially", "replace", "the", "output", "byte", ...
1d7ab5c50b36701116070c4c612259f93c262367
https://github.com/ugorji/go/blob/1d7ab5c50b36701116070c4c612259f93c262367/codec/encode.go#L1272-L1276
20,703
ugorji/go
codec/encode.go
Reset
func (e *Encoder) Reset(w io.Writer) { if w == nil { return } // var ok bool e.bytes = false if e.wf == nil { e.wf = new(bufioEncWriter) } // e.typ = entryTypeUnset // if e.h.WriterBufferSize > 0 { // // bw := bufio.NewWriterSize(w, e.h.WriterBufferSize) // // e.wi.bw = bw // // e.wi.sw = bw // // e...
go
func (e *Encoder) Reset(w io.Writer) { if w == nil { return } // var ok bool e.bytes = false if e.wf == nil { e.wf = new(bufioEncWriter) } // e.typ = entryTypeUnset // if e.h.WriterBufferSize > 0 { // // bw := bufio.NewWriterSize(w, e.h.WriterBufferSize) // // e.wi.bw = bw // // e.wi.sw = bw // // e...
[ "func", "(", "e", "*", "Encoder", ")", "Reset", "(", "w", "io", ".", "Writer", ")", "{", "if", "w", "==", "nil", "{", "return", "\n", "}", "\n", "// var ok bool", "e", ".", "bytes", "=", "false", "\n", "if", "e", ".", "wf", "==", "nil", "{", ...
// Reset resets the Encoder with a new output stream. // // This accommodates using the state of the Encoder, // where it has "cached" information about sub-engines.
[ "Reset", "resets", "the", "Encoder", "with", "a", "new", "output", "stream", ".", "This", "accommodates", "using", "the", "state", "of", "the", "Encoder", "where", "it", "has", "cached", "information", "about", "sub", "-", "engines", "." ]
1d7ab5c50b36701116070c4c612259f93c262367
https://github.com/ugorji/go/blob/1d7ab5c50b36701116070c4c612259f93c262367/codec/encode.go#L1309-L1342
20,704
ugorji/go
codec/encode.go
MustEncode
func (e *Encoder) MustEncode(v interface{}) { if e.err != nil { panic(e.err) } e.mustEncode(v) }
go
func (e *Encoder) MustEncode(v interface{}) { if e.err != nil { panic(e.err) } e.mustEncode(v) }
[ "func", "(", "e", "*", "Encoder", ")", "MustEncode", "(", "v", "interface", "{", "}", ")", "{", "if", "e", ".", "err", "!=", "nil", "{", "panic", "(", "e", ".", "err", ")", "\n", "}", "\n", "e", ".", "mustEncode", "(", "v", ")", "\n", "}" ]
// MustEncode is like Encode, but panics if unable to Encode. // This provides insight to the code location that triggered the error.
[ "MustEncode", "is", "like", "Encode", "but", "panics", "if", "unable", "to", "Encode", ".", "This", "provides", "insight", "to", "the", "code", "location", "that", "triggered", "the", "error", "." ]
1d7ab5c50b36701116070c4c612259f93c262367
https://github.com/ugorji/go/blob/1d7ab5c50b36701116070c4c612259f93c262367/codec/encode.go#L1474-L1479
20,705
ugorji/go
codec/cbor.go
SetInterfaceExt
func (h *CborHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) { return h.SetExt(rt, tag, &extWrapper{bytesExtFailer{}, ext}) }
go
func (h *CborHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) { return h.SetExt(rt, tag, &extWrapper{bytesExtFailer{}, ext}) }
[ "func", "(", "h", "*", "CborHandle", ")", "SetInterfaceExt", "(", "rt", "reflect", ".", "Type", ",", "tag", "uint64", ",", "ext", "InterfaceExt", ")", "(", "err", "error", ")", "{", "return", "h", ".", "SetExt", "(", "rt", ",", "tag", ",", "&", "ex...
// SetInterfaceExt sets an extension
[ "SetInterfaceExt", "sets", "an", "extension" ]
1d7ab5c50b36701116070c4c612259f93c262367
https://github.com/ugorji/go/blob/1d7ab5c50b36701116070c4c612259f93c262367/codec/cbor.go#L745-L747
20,706
ugorji/go
codec/msgpack.go
DecodeBool
func (d *msgpackDecDriver) DecodeBool() (b bool) { if !d.bdRead { d.readNextBd() } if d.bd == mpFalse || d.bd == 0 { // b = false } else if d.bd == mpTrue || d.bd == 1 { b = true } else { d.d.errorf("cannot decode bool: %s: %x/%s", msgBadDesc, d.bd, mpdesc(d.bd)) return } d.bdRead = false return }
go
func (d *msgpackDecDriver) DecodeBool() (b bool) { if !d.bdRead { d.readNextBd() } if d.bd == mpFalse || d.bd == 0 { // b = false } else if d.bd == mpTrue || d.bd == 1 { b = true } else { d.d.errorf("cannot decode bool: %s: %x/%s", msgBadDesc, d.bd, mpdesc(d.bd)) return } d.bdRead = false return }
[ "func", "(", "d", "*", "msgpackDecDriver", ")", "DecodeBool", "(", ")", "(", "b", "bool", ")", "{", "if", "!", "d", ".", "bdRead", "{", "d", ".", "readNextBd", "(", ")", "\n", "}", "\n", "if", "d", ".", "bd", "==", "mpFalse", "||", "d", ".", ...
// bool can be decoded from bool, fixnum 0 or 1.
[ "bool", "can", "be", "decoded", "from", "bool", "fixnum", "0", "or", "1", "." ]
1d7ab5c50b36701116070c4c612259f93c262367
https://github.com/ugorji/go/blob/1d7ab5c50b36701116070c4c612259f93c262367/codec/msgpack.go#L680-L694
20,707
ugorji/go
codec/gen.go
xtraSM
func (x *genRunner) xtraSM(varname string, t reflect.Type, encode, isptr bool) { var ptrPfx, addrPfx string if isptr { ptrPfx = "*" } else { addrPfx = "&" } if encode { x.linef("h.enc%s((%s%s)(%s), e)", x.genMethodNameT(t), ptrPfx, x.genTypeName(t), varname) } else { x.linef("h.dec%s((*%s)(%s%s), d)", x.g...
go
func (x *genRunner) xtraSM(varname string, t reflect.Type, encode, isptr bool) { var ptrPfx, addrPfx string if isptr { ptrPfx = "*" } else { addrPfx = "&" } if encode { x.linef("h.enc%s((%s%s)(%s), e)", x.genMethodNameT(t), ptrPfx, x.genTypeName(t), varname) } else { x.linef("h.dec%s((*%s)(%s%s), d)", x.g...
[ "func", "(", "x", "*", "genRunner", ")", "xtraSM", "(", "varname", "string", ",", "t", "reflect", ".", "Type", ",", "encode", ",", "isptr", "bool", ")", "{", "var", "ptrPfx", ",", "addrPfx", "string", "\n", "if", "isptr", "{", "ptrPfx", "=", "\"", ...
// used for chan, array, slice, map
[ "used", "for", "chan", "array", "slice", "map" ]
1d7ab5c50b36701116070c4c612259f93c262367
https://github.com/ugorji/go/blob/1d7ab5c50b36701116070c4c612259f93c262367/codec/gen.go#L601-L614
20,708
ugorji/go
codec/gen.go
encVar
func (x *genRunner) encVar(varname string, t reflect.Type) { // fmt.Printf(">>>>>> varname: %s, t: %v\n", varname, t) var checkNil bool switch t.Kind() { case reflect.Ptr, reflect.Interface, reflect.Slice, reflect.Map, reflect.Chan: checkNil = true } if checkNil { x.linef("if %s == nil { r.EncodeNil() } else ...
go
func (x *genRunner) encVar(varname string, t reflect.Type) { // fmt.Printf(">>>>>> varname: %s, t: %v\n", varname, t) var checkNil bool switch t.Kind() { case reflect.Ptr, reflect.Interface, reflect.Slice, reflect.Map, reflect.Chan: checkNil = true } if checkNil { x.linef("if %s == nil { r.EncodeNil() } else ...
[ "func", "(", "x", "*", "genRunner", ")", "encVar", "(", "varname", "string", ",", "t", "reflect", ".", "Type", ")", "{", "// fmt.Printf(\">>>>>> varname: %s, t: %v\\n\", varname, t)", "var", "checkNil", "bool", "\n", "switch", "t", ".", "Kind", "(", ")", "{", ...
// encVar will encode a variable. // The parameter, t, is the reflect.Type of the variable itself
[ "encVar", "will", "encode", "a", "variable", ".", "The", "parameter", "t", "is", "the", "reflect", ".", "Type", "of", "the", "variable", "itself" ]
1d7ab5c50b36701116070c4c612259f93c262367
https://github.com/ugorji/go/blob/1d7ab5c50b36701116070c4c612259f93c262367/codec/gen.go#L640-L678
20,709
ugorji/go
codec/gen.go
genImportPath
func genImportPath(t reflect.Type) (s string) { s = t.PkgPath() if genCheckVendor { // HACK: always handle vendoring. It should be typically on in go 1.6, 1.7 s = genStripVendor(s) } return }
go
func genImportPath(t reflect.Type) (s string) { s = t.PkgPath() if genCheckVendor { // HACK: always handle vendoring. It should be typically on in go 1.6, 1.7 s = genStripVendor(s) } return }
[ "func", "genImportPath", "(", "t", "reflect", ".", "Type", ")", "(", "s", "string", ")", "{", "s", "=", "t", ".", "PkgPath", "(", ")", "\n", "if", "genCheckVendor", "{", "// HACK: always handle vendoring. It should be typically on in go 1.6, 1.7", "s", "=", "gen...
// genImportPath returns import path of a non-predeclared named typed, or an empty string otherwise. // // This handles the misbehaviour that occurs when 1.5-style vendoring is enabled, // where PkgPath returns the full path, including the vendoring pre-fix that should have been stripped. // We strip it here.
[ "genImportPath", "returns", "import", "path", "of", "a", "non", "-", "predeclared", "named", "typed", "or", "an", "empty", "string", "otherwise", ".", "This", "handles", "the", "misbehaviour", "that", "occurs", "when", "1", ".", "5", "-", "style", "vendoring...
1d7ab5c50b36701116070c4c612259f93c262367
https://github.com/ugorji/go/blob/1d7ab5c50b36701116070c4c612259f93c262367/codec/gen.go#L1754-L1761
20,710
ugorji/go
codec/simple.go
SetBytesExt
func (h *SimpleHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) { return h.SetExt(rt, tag, &extWrapper{ext, interfaceExtFailer{}}) }
go
func (h *SimpleHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) { return h.SetExt(rt, tag, &extWrapper{ext, interfaceExtFailer{}}) }
[ "func", "(", "h", "*", "SimpleHandle", ")", "SetBytesExt", "(", "rt", "reflect", ".", "Type", ",", "tag", "uint64", ",", "ext", "BytesExt", ")", "(", "err", "error", ")", "{", "return", "h", ".", "SetExt", "(", "rt", ",", "tag", ",", "&", "extWrapp...
// SetBytesExt sets an extension
[ "SetBytesExt", "sets", "an", "extension" ]
1d7ab5c50b36701116070c4c612259f93c262367
https://github.com/ugorji/go/blob/1d7ab5c50b36701116070c4c612259f93c262367/codec/simple.go#L640-L642
20,711
go-validator/validator
builtins.go
nonzero
func nonzero(v interface{}, param string) error { st := reflect.ValueOf(v) valid := true switch st.Kind() { case reflect.String: valid = len(st.String()) != 0 case reflect.Ptr, reflect.Interface: valid = !st.IsNil() case reflect.Slice, reflect.Map, reflect.Array: valid = st.Len() != 0 case reflect.Int, ref...
go
func nonzero(v interface{}, param string) error { st := reflect.ValueOf(v) valid := true switch st.Kind() { case reflect.String: valid = len(st.String()) != 0 case reflect.Ptr, reflect.Interface: valid = !st.IsNil() case reflect.Slice, reflect.Map, reflect.Array: valid = st.Len() != 0 case reflect.Int, ref...
[ "func", "nonzero", "(", "v", "interface", "{", "}", ",", "param", "string", ")", "error", "{", "st", ":=", "reflect", ".", "ValueOf", "(", "v", ")", "\n", "valid", ":=", "true", "\n", "switch", "st", ".", "Kind", "(", ")", "{", "case", "reflect", ...
// nonzero tests whether a variable value non-zero // as defined by the golang spec.
[ "nonzero", "tests", "whether", "a", "variable", "value", "non", "-", "zero", "as", "defined", "by", "the", "golang", "spec", "." ]
135c24b11c19e52befcae2ec3fca5d9b78c4e98e
https://github.com/go-validator/validator/blob/135c24b11c19e52befcae2ec3fca5d9b78c4e98e/builtins.go#L27-L57
20,712
go-validator/validator
builtins.go
length
func length(v interface{}, param string) error { st := reflect.ValueOf(v) valid := true if st.Kind() == reflect.Ptr { if st.IsNil() { return nil } st = st.Elem() } switch st.Kind() { case reflect.String: p, err := asInt(param) if err != nil { return ErrBadParameter } valid = int64(len(st.Strin...
go
func length(v interface{}, param string) error { st := reflect.ValueOf(v) valid := true if st.Kind() == reflect.Ptr { if st.IsNil() { return nil } st = st.Elem() } switch st.Kind() { case reflect.String: p, err := asInt(param) if err != nil { return ErrBadParameter } valid = int64(len(st.Strin...
[ "func", "length", "(", "v", "interface", "{", "}", ",", "param", "string", ")", "error", "{", "st", ":=", "reflect", ".", "ValueOf", "(", "v", ")", "\n", "valid", ":=", "true", "\n", "if", "st", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr",...
// length tests whether a variable's length is equal to a given // value. For strings it tests the number of characters whereas // for maps and slices it tests the number of items.
[ "length", "tests", "whether", "a", "variable", "s", "length", "is", "equal", "to", "a", "given", "value", ".", "For", "strings", "it", "tests", "the", "number", "of", "characters", "whereas", "for", "maps", "and", "slices", "it", "tests", "the", "number", ...
135c24b11c19e52befcae2ec3fca5d9b78c4e98e
https://github.com/go-validator/validator/blob/135c24b11c19e52befcae2ec3fca5d9b78c4e98e/builtins.go#L62-L109
20,713
go-validator/validator
builtins.go
regex
func regex(v interface{}, param string) error { s, ok := v.(string) if !ok { sptr, ok := v.(*string) if !ok { return ErrUnsupported } if sptr == nil { return nil } s = *sptr } re, err := regexp.Compile(param) if err != nil { return ErrBadParameter } if !re.MatchString(s) { return ErrRegex...
go
func regex(v interface{}, param string) error { s, ok := v.(string) if !ok { sptr, ok := v.(*string) if !ok { return ErrUnsupported } if sptr == nil { return nil } s = *sptr } re, err := regexp.Compile(param) if err != nil { return ErrBadParameter } if !re.MatchString(s) { return ErrRegex...
[ "func", "regex", "(", "v", "interface", "{", "}", ",", "param", "string", ")", "error", "{", "s", ",", "ok", ":=", "v", ".", "(", "string", ")", "\n", "if", "!", "ok", "{", "sptr", ",", "ok", ":=", "v", ".", "(", "*", "string", ")", "\n", "...
// regex is the builtin validation function that checks // whether the string variable matches a regular expression
[ "regex", "is", "the", "builtin", "validation", "function", "that", "checks", "whether", "the", "string", "variable", "matches", "a", "regular", "expression" ]
135c24b11c19e52befcae2ec3fca5d9b78c4e98e
https://github.com/go-validator/validator/blob/135c24b11c19e52befcae2ec3fca5d9b78c4e98e/builtins.go#L219-L241
20,714
go-validator/validator
builtins.go
asInt
func asInt(param string) (int64, error) { i, err := strconv.ParseInt(param, 0, 64) if err != nil { return 0, ErrBadParameter } return i, nil }
go
func asInt(param string) (int64, error) { i, err := strconv.ParseInt(param, 0, 64) if err != nil { return 0, ErrBadParameter } return i, nil }
[ "func", "asInt", "(", "param", "string", ")", "(", "int64", ",", "error", ")", "{", "i", ",", "err", ":=", "strconv", ".", "ParseInt", "(", "param", ",", "0", ",", "64", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "ErrBadParamet...
// asInt retuns the parameter as a int64 // or panics if it can't convert
[ "asInt", "retuns", "the", "parameter", "as", "a", "int64", "or", "panics", "if", "it", "can", "t", "convert" ]
135c24b11c19e52befcae2ec3fca5d9b78c4e98e
https://github.com/go-validator/validator/blob/135c24b11c19e52befcae2ec3fca5d9b78c4e98e/builtins.go#L245-L251
20,715
go-validator/validator
builtins.go
asUint
func asUint(param string) (uint64, error) { i, err := strconv.ParseUint(param, 0, 64) if err != nil { return 0, ErrBadParameter } return i, nil }
go
func asUint(param string) (uint64, error) { i, err := strconv.ParseUint(param, 0, 64) if err != nil { return 0, ErrBadParameter } return i, nil }
[ "func", "asUint", "(", "param", "string", ")", "(", "uint64", ",", "error", ")", "{", "i", ",", "err", ":=", "strconv", ".", "ParseUint", "(", "param", ",", "0", ",", "64", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "ErrBadPara...
// asUint retuns the parameter as a uint64 // or panics if it can't convert
[ "asUint", "retuns", "the", "parameter", "as", "a", "uint64", "or", "panics", "if", "it", "can", "t", "convert" ]
135c24b11c19e52befcae2ec3fca5d9b78c4e98e
https://github.com/go-validator/validator/blob/135c24b11c19e52befcae2ec3fca5d9b78c4e98e/builtins.go#L255-L261
20,716
go-validator/validator
builtins.go
asFloat
func asFloat(param string) (float64, error) { i, err := strconv.ParseFloat(param, 64) if err != nil { return 0.0, ErrBadParameter } return i, nil }
go
func asFloat(param string) (float64, error) { i, err := strconv.ParseFloat(param, 64) if err != nil { return 0.0, ErrBadParameter } return i, nil }
[ "func", "asFloat", "(", "param", "string", ")", "(", "float64", ",", "error", ")", "{", "i", ",", "err", ":=", "strconv", ".", "ParseFloat", "(", "param", ",", "64", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0.0", ",", "ErrBadParameter", ...
// asFloat retuns the parameter as a float64 // or panics if it can't convert
[ "asFloat", "retuns", "the", "parameter", "as", "a", "float64", "or", "panics", "if", "it", "can", "t", "convert" ]
135c24b11c19e52befcae2ec3fca5d9b78c4e98e
https://github.com/go-validator/validator/blob/135c24b11c19e52befcae2ec3fca5d9b78c4e98e/builtins.go#L265-L271
20,717
go-validator/validator
validator.go
MarshalText
func (t TextErr) MarshalText() ([]byte, error) { return []byte(t.Err.Error()), nil }
go
func (t TextErr) MarshalText() ([]byte, error) { return []byte(t.Err.Error()), nil }
[ "func", "(", "t", "TextErr", ")", "MarshalText", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "return", "[", "]", "byte", "(", "t", ".", "Err", ".", "Error", "(", ")", ")", ",", "nil", "\n", "}" ]
// MarshalText implements the TextMarshaller
[ "MarshalText", "implements", "the", "TextMarshaller" ]
135c24b11c19e52befcae2ec3fca5d9b78c4e98e
https://github.com/go-validator/validator/blob/135c24b11c19e52befcae2ec3fca5d9b78c4e98e/validator.go#L42-L44
20,718
go-validator/validator
validator.go
Error
func (err ErrorMap) Error() string { for k, errs := range err { if len(errs) > 0 { return fmt.Sprintf("%s: %s", k, errs.Error()) } } return "" }
go
func (err ErrorMap) Error() string { for k, errs := range err { if len(errs) > 0 { return fmt.Sprintf("%s: %s", k, errs.Error()) } } return "" }
[ "func", "(", "err", "ErrorMap", ")", "Error", "(", ")", "string", "{", "for", "k", ",", "errs", ":=", "range", "err", "{", "if", "len", "(", "errs", ")", ">", "0", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "k", ",", "errs", ...
// ErrorMap implements the Error interface so we can check error against nil. // The returned error is if existent the first error which was added to the map.
[ "ErrorMap", "implements", "the", "Error", "interface", "so", "we", "can", "check", "error", "against", "nil", ".", "The", "returned", "error", "is", "if", "existent", "the", "first", "error", "which", "was", "added", "to", "the", "map", "." ]
135c24b11c19e52befcae2ec3fca5d9b78c4e98e
https://github.com/go-validator/validator/blob/135c24b11c19e52befcae2ec3fca5d9b78c4e98e/validator.go#L81-L89
20,719
go-validator/validator
validator.go
NewValidator
func NewValidator() *Validator { return &Validator{ tagName: "validate", validationFuncs: map[string]ValidationFunc{ "nonzero": nonzero, "len": length, "min": min, "max": max, "regexp": regex, }, } }
go
func NewValidator() *Validator { return &Validator{ tagName: "validate", validationFuncs: map[string]ValidationFunc{ "nonzero": nonzero, "len": length, "min": min, "max": max, "regexp": regex, }, } }
[ "func", "NewValidator", "(", ")", "*", "Validator", "{", "return", "&", "Validator", "{", "tagName", ":", "\"", "\"", ",", "validationFuncs", ":", "map", "[", "string", "]", "ValidationFunc", "{", "\"", "\"", ":", "nonzero", ",", "\"", "\"", ":", "leng...
// NewValidator creates a new Validator
[ "NewValidator", "creates", "a", "new", "Validator" ]
135c24b11c19e52befcae2ec3fca5d9b78c4e98e
https://github.com/go-validator/validator/blob/135c24b11c19e52befcae2ec3fca5d9b78c4e98e/validator.go#L121-L132
20,720
go-validator/validator
validator.go
Validate
func (mv *Validator) Validate(v interface{}) error { sv := reflect.ValueOf(v) st := reflect.TypeOf(v) if sv.Kind() == reflect.Ptr && !sv.IsNil() { return mv.Validate(sv.Elem().Interface()) } if sv.Kind() != reflect.Struct && sv.Kind() != reflect.Interface { return ErrUnsupported } nfields := sv.NumField() ...
go
func (mv *Validator) Validate(v interface{}) error { sv := reflect.ValueOf(v) st := reflect.TypeOf(v) if sv.Kind() == reflect.Ptr && !sv.IsNil() { return mv.Validate(sv.Elem().Interface()) } if sv.Kind() != reflect.Struct && sv.Kind() != reflect.Interface { return ErrUnsupported } nfields := sv.NumField() ...
[ "func", "(", "mv", "*", "Validator", ")", "Validate", "(", "v", "interface", "{", "}", ")", "error", "{", "sv", ":=", "reflect", ".", "ValueOf", "(", "v", ")", "\n", "st", ":=", "reflect", ".", "TypeOf", "(", "v", ")", "\n", "if", "sv", ".", "K...
// Validate validates the fields of a struct based // on 'validator' tags and returns errors found indexed // by the field name.
[ "Validate", "validates", "the", "fields", "of", "a", "struct", "based", "on", "validator", "tags", "and", "returns", "errors", "found", "indexed", "by", "the", "field", "name", "." ]
135c24b11c19e52befcae2ec3fca5d9b78c4e98e
https://github.com/go-validator/validator/blob/135c24b11c19e52befcae2ec3fca5d9b78c4e98e/validator.go#L204-L255
20,721
go-validator/validator
validator.go
validateVar
func (mv *Validator) validateVar(v interface{}, tag string) error { tags, err := mv.parseTags(tag) if err != nil { // unknown tag found, give up. return err } errs := make(ErrorArray, 0, len(tags)) for _, t := range tags { if err := t.Fn(v, t.Param); err != nil { errs = append(errs, err) } } if len(er...
go
func (mv *Validator) validateVar(v interface{}, tag string) error { tags, err := mv.parseTags(tag) if err != nil { // unknown tag found, give up. return err } errs := make(ErrorArray, 0, len(tags)) for _, t := range tags { if err := t.Fn(v, t.Param); err != nil { errs = append(errs, err) } } if len(er...
[ "func", "(", "mv", "*", "Validator", ")", "validateVar", "(", "v", "interface", "{", "}", ",", "tag", "string", ")", "error", "{", "tags", ",", "err", ":=", "mv", ".", "parseTags", "(", "tag", ")", "\n", "if", "err", "!=", "nil", "{", "// unknown t...
// validateVar validates one single variable
[ "validateVar", "validates", "one", "single", "variable" ]
135c24b11c19e52befcae2ec3fca5d9b78c4e98e
https://github.com/go-validator/validator/blob/135c24b11c19e52befcae2ec3fca5d9b78c4e98e/validator.go#L306-L322
20,722
mikespook/gorbac
helper.go
Walk
func Walk(rbac *RBAC, h WalkHandler) (err error) { if h == nil { return } rbac.mutex.Lock() defer rbac.mutex.Unlock() for id := range rbac.roles { var parents []string r := rbac.roles[id] for parent := range rbac.parents[id] { parents = append(parents, parent) } if err := h(r, parents); err != nil {...
go
func Walk(rbac *RBAC, h WalkHandler) (err error) { if h == nil { return } rbac.mutex.Lock() defer rbac.mutex.Unlock() for id := range rbac.roles { var parents []string r := rbac.roles[id] for parent := range rbac.parents[id] { parents = append(parents, parent) } if err := h(r, parents); err != nil {...
[ "func", "Walk", "(", "rbac", "*", "RBAC", ",", "h", "WalkHandler", ")", "(", "err", "error", ")", "{", "if", "h", "==", "nil", "{", "return", "\n", "}", "\n", "rbac", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "rbac", ".", "mutex", "."...
// Walk passes each Role to WalkHandler
[ "Walk", "passes", "each", "Role", "to", "WalkHandler" ]
a989d0e80a235460ebe9e8f2e7971e9ed948db88
https://github.com/mikespook/gorbac/blob/a989d0e80a235460ebe9e8f2e7971e9ed948db88/helper.go#L9-L26
20,723
mikespook/gorbac
helper.go
InherCircle
func InherCircle(rbac *RBAC) (err error) { rbac.mutex.Lock() skipped := make(map[string]struct{}, len(rbac.roles)) var stack []string for id := range rbac.roles { if err = dfs(rbac, id, skipped, stack); err != nil { break } } rbac.mutex.Unlock() return err }
go
func InherCircle(rbac *RBAC) (err error) { rbac.mutex.Lock() skipped := make(map[string]struct{}, len(rbac.roles)) var stack []string for id := range rbac.roles { if err = dfs(rbac, id, skipped, stack); err != nil { break } } rbac.mutex.Unlock() return err }
[ "func", "InherCircle", "(", "rbac", "*", "RBAC", ")", "(", "err", "error", ")", "{", "rbac", ".", "mutex", ".", "Lock", "(", ")", "\n\n", "skipped", ":=", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ",", "len", "(", "rbac", ".", ...
// InherCircle returns an error when detecting any circle inheritance.
[ "InherCircle", "returns", "an", "error", "when", "detecting", "any", "circle", "inheritance", "." ]
a989d0e80a235460ebe9e8f2e7971e9ed948db88
https://github.com/mikespook/gorbac/blob/a989d0e80a235460ebe9e8f2e7971e9ed948db88/helper.go#L29-L42
20,724
mikespook/gorbac
helper.go
AnyGranted
func AnyGranted(rbac *RBAC, roles []string, permission Permission, assert AssertionFunc) (rslt bool) { rbac.mutex.Lock() for _, role := range roles { if rbac.isGranted(role, permission, assert) { rslt = true break } } rbac.mutex.Unlock() return rslt }
go
func AnyGranted(rbac *RBAC, roles []string, permission Permission, assert AssertionFunc) (rslt bool) { rbac.mutex.Lock() for _, role := range roles { if rbac.isGranted(role, permission, assert) { rslt = true break } } rbac.mutex.Unlock() return rslt }
[ "func", "AnyGranted", "(", "rbac", "*", "RBAC", ",", "roles", "[", "]", "string", ",", "permission", "Permission", ",", "assert", "AssertionFunc", ")", "(", "rslt", "bool", ")", "{", "rbac", ".", "mutex", ".", "Lock", "(", ")", "\n", "for", "_", ",",...
// AnyGranted checks if any role has the permission.
[ "AnyGranted", "checks", "if", "any", "role", "has", "the", "permission", "." ]
a989d0e80a235460ebe9e8f2e7971e9ed948db88
https://github.com/mikespook/gorbac/blob/a989d0e80a235460ebe9e8f2e7971e9ed948db88/helper.go#L74-L85
20,725
mikespook/gorbac
role.go
NewStdRole
func NewStdRole(id string) *StdRole { role := &StdRole{ IDStr: id, permissions: make(Permissions), } return role }
go
func NewStdRole(id string) *StdRole { role := &StdRole{ IDStr: id, permissions: make(Permissions), } return role }
[ "func", "NewStdRole", "(", "id", "string", ")", "*", "StdRole", "{", "role", ":=", "&", "StdRole", "{", "IDStr", ":", "id", ",", "permissions", ":", "make", "(", "Permissions", ")", ",", "}", "\n", "return", "role", "\n", "}" ]
// NewStdRole is the default role factory function. // It matches the declaration to RoleFactoryFunc.
[ "NewStdRole", "is", "the", "default", "role", "factory", "function", ".", "It", "matches", "the", "declaration", "to", "RoleFactoryFunc", "." ]
a989d0e80a235460ebe9e8f2e7971e9ed948db88
https://github.com/mikespook/gorbac/blob/a989d0e80a235460ebe9e8f2e7971e9ed948db88/role.go#L19-L25
20,726
mikespook/gorbac
role.go
Assign
func (role *StdRole) Assign(p Permission) error { role.Lock() role.permissions[p.ID()] = p role.Unlock() return nil }
go
func (role *StdRole) Assign(p Permission) error { role.Lock() role.permissions[p.ID()] = p role.Unlock() return nil }
[ "func", "(", "role", "*", "StdRole", ")", "Assign", "(", "p", "Permission", ")", "error", "{", "role", ".", "Lock", "(", ")", "\n", "role", ".", "permissions", "[", "p", ".", "ID", "(", ")", "]", "=", "p", "\n", "role", ".", "Unlock", "(", ")",...
// Assign a permission to the role.
[ "Assign", "a", "permission", "to", "the", "role", "." ]
a989d0e80a235460ebe9e8f2e7971e9ed948db88
https://github.com/mikespook/gorbac/blob/a989d0e80a235460ebe9e8f2e7971e9ed948db88/role.go#L42-L47
20,727
mikespook/gorbac
role.go
Permit
func (role *StdRole) Permit(p Permission) (rslt bool) { if p == nil { return false } role.RLock() for _, rp := range role.permissions { if rp.Match(p) { rslt = true break } } role.RUnlock() return }
go
func (role *StdRole) Permit(p Permission) (rslt bool) { if p == nil { return false } role.RLock() for _, rp := range role.permissions { if rp.Match(p) { rslt = true break } } role.RUnlock() return }
[ "func", "(", "role", "*", "StdRole", ")", "Permit", "(", "p", "Permission", ")", "(", "rslt", "bool", ")", "{", "if", "p", "==", "nil", "{", "return", "false", "\n", "}", "\n\n", "role", ".", "RLock", "(", ")", "\n", "for", "_", ",", "rp", ":="...
// Permit returns true if the role has specific permission.
[ "Permit", "returns", "true", "if", "the", "role", "has", "specific", "permission", "." ]
a989d0e80a235460ebe9e8f2e7971e9ed948db88
https://github.com/mikespook/gorbac/blob/a989d0e80a235460ebe9e8f2e7971e9ed948db88/role.go#L50-L64
20,728
mikespook/gorbac
role.go
Revoke
func (role *StdRole) Revoke(p Permission) error { role.Lock() delete(role.permissions, p.ID()) role.Unlock() return nil }
go
func (role *StdRole) Revoke(p Permission) error { role.Lock() delete(role.permissions, p.ID()) role.Unlock() return nil }
[ "func", "(", "role", "*", "StdRole", ")", "Revoke", "(", "p", "Permission", ")", "error", "{", "role", ".", "Lock", "(", ")", "\n", "delete", "(", "role", ".", "permissions", ",", "p", ".", "ID", "(", ")", ")", "\n", "role", ".", "Unlock", "(", ...
// Revoke the specific permission.
[ "Revoke", "the", "specific", "permission", "." ]
a989d0e80a235460ebe9e8f2e7971e9ed948db88
https://github.com/mikespook/gorbac/blob/a989d0e80a235460ebe9e8f2e7971e9ed948db88/role.go#L67-L72
20,729
mikespook/gorbac
role.go
Permissions
func (role *StdRole) Permissions() []Permission { role.RLock() result := make([]Permission, 0, len(role.permissions)) for _, p := range role.permissions { result = append(result, p) } role.RUnlock() return result }
go
func (role *StdRole) Permissions() []Permission { role.RLock() result := make([]Permission, 0, len(role.permissions)) for _, p := range role.permissions { result = append(result, p) } role.RUnlock() return result }
[ "func", "(", "role", "*", "StdRole", ")", "Permissions", "(", ")", "[", "]", "Permission", "{", "role", ".", "RLock", "(", ")", "\n", "result", ":=", "make", "(", "[", "]", "Permission", ",", "0", ",", "len", "(", "role", ".", "permissions", ")", ...
// Permissions returns all permissions into a slice.
[ "Permissions", "returns", "all", "permissions", "into", "a", "slice", "." ]
a989d0e80a235460ebe9e8f2e7971e9ed948db88
https://github.com/mikespook/gorbac/blob/a989d0e80a235460ebe9e8f2e7971e9ed948db88/role.go#L75-L83
20,730
mikespook/gorbac
rbac.go
New
func New() *RBAC { return &RBAC{ roles: make(Roles), parents: make(map[string]map[string]struct{}), } }
go
func New() *RBAC { return &RBAC{ roles: make(Roles), parents: make(map[string]map[string]struct{}), } }
[ "func", "New", "(", ")", "*", "RBAC", "{", "return", "&", "RBAC", "{", "roles", ":", "make", "(", "Roles", ")", ",", "parents", ":", "make", "(", "map", "[", "string", "]", "map", "[", "string", "]", "struct", "{", "}", ")", ",", "}", "\n", "...
// New returns a RBAC structure. // The default role structure will be used.
[ "New", "returns", "a", "RBAC", "structure", ".", "The", "default", "role", "structure", "will", "be", "used", "." ]
a989d0e80a235460ebe9e8f2e7971e9ed948db88
https://github.com/mikespook/gorbac/blob/a989d0e80a235460ebe9e8f2e7971e9ed948db88/rbac.go#L44-L49
20,731
mikespook/gorbac
rbac.go
GetParents
func (rbac *RBAC) GetParents(id string) ([]string, error) { rbac.mutex.Lock() defer rbac.mutex.Unlock() if _, ok := rbac.roles[id]; !ok { return nil, ErrRoleNotExist } ids, ok := rbac.parents[id] if !ok { return nil, nil } var parents []string for parent := range ids { parents = append(parents, parent) ...
go
func (rbac *RBAC) GetParents(id string) ([]string, error) { rbac.mutex.Lock() defer rbac.mutex.Unlock() if _, ok := rbac.roles[id]; !ok { return nil, ErrRoleNotExist } ids, ok := rbac.parents[id] if !ok { return nil, nil } var parents []string for parent := range ids { parents = append(parents, parent) ...
[ "func", "(", "rbac", "*", "RBAC", ")", "GetParents", "(", "id", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "rbac", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "rbac", ".", "mutex", ".", "Unlock", "(", ")", "\n", "if...
// GetParents return `parents` of the role `id`. // If the role is not existing, an error will be returned. // Or the role doesn't have any parents, // a nil slice will be returned.
[ "GetParents", "return", "parents", "of", "the", "role", "id", ".", "If", "the", "role", "is", "not", "existing", "an", "error", "will", "be", "returned", ".", "Or", "the", "role", "doesn", "t", "have", "any", "parents", "a", "nil", "slice", "will", "be...
a989d0e80a235460ebe9e8f2e7971e9ed948db88
https://github.com/mikespook/gorbac/blob/a989d0e80a235460ebe9e8f2e7971e9ed948db88/rbac.go#L78-L93
20,732
mikespook/gorbac
rbac.go
SetParent
func (rbac *RBAC) SetParent(id string, parent string) error { rbac.mutex.Lock() defer rbac.mutex.Unlock() if _, ok := rbac.roles[id]; !ok { return ErrRoleNotExist } if _, ok := rbac.roles[parent]; !ok { return ErrRoleNotExist } if _, ok := rbac.parents[id]; !ok { rbac.parents[id] = make(map[string]struct{}...
go
func (rbac *RBAC) SetParent(id string, parent string) error { rbac.mutex.Lock() defer rbac.mutex.Unlock() if _, ok := rbac.roles[id]; !ok { return ErrRoleNotExist } if _, ok := rbac.roles[parent]; !ok { return ErrRoleNotExist } if _, ok := rbac.parents[id]; !ok { rbac.parents[id] = make(map[string]struct{}...
[ "func", "(", "rbac", "*", "RBAC", ")", "SetParent", "(", "id", "string", ",", "parent", "string", ")", "error", "{", "rbac", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "rbac", ".", "mutex", ".", "Unlock", "(", ")", "\n", "if", "_", ",", ...
// SetParent bind the `parent` to the role `id`. // If the role or the parent is not existing, // an error will be returned.
[ "SetParent", "bind", "the", "parent", "to", "the", "role", "id", ".", "If", "the", "role", "or", "the", "parent", "is", "not", "existing", "an", "error", "will", "be", "returned", "." ]
a989d0e80a235460ebe9e8f2e7971e9ed948db88
https://github.com/mikespook/gorbac/blob/a989d0e80a235460ebe9e8f2e7971e9ed948db88/rbac.go#L98-L113
20,733
mikespook/gorbac
rbac.go
RemoveParent
func (rbac *RBAC) RemoveParent(id string, parent string) error { rbac.mutex.Lock() defer rbac.mutex.Unlock() if _, ok := rbac.roles[id]; !ok { return ErrRoleNotExist } if _, ok := rbac.roles[parent]; !ok { return ErrRoleNotExist } delete(rbac.parents[id], parent) return nil }
go
func (rbac *RBAC) RemoveParent(id string, parent string) error { rbac.mutex.Lock() defer rbac.mutex.Unlock() if _, ok := rbac.roles[id]; !ok { return ErrRoleNotExist } if _, ok := rbac.roles[parent]; !ok { return ErrRoleNotExist } delete(rbac.parents[id], parent) return nil }
[ "func", "(", "rbac", "*", "RBAC", ")", "RemoveParent", "(", "id", "string", ",", "parent", "string", ")", "error", "{", "rbac", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "rbac", ".", "mutex", ".", "Unlock", "(", ")", "\n", "if", "_", ",...
// RemoveParent unbind the `parent` with the role `id`. // If the role or the parent is not existing, // an error will be returned.
[ "RemoveParent", "unbind", "the", "parent", "with", "the", "role", "id", ".", "If", "the", "role", "or", "the", "parent", "is", "not", "existing", "an", "error", "will", "be", "returned", "." ]
a989d0e80a235460ebe9e8f2e7971e9ed948db88
https://github.com/mikespook/gorbac/blob/a989d0e80a235460ebe9e8f2e7971e9ed948db88/rbac.go#L118-L129
20,734
mikespook/gorbac
rbac.go
Add
func (rbac *RBAC) Add(r Role) (err error) { rbac.mutex.Lock() if _, ok := rbac.roles[r.ID()]; !ok { rbac.roles[r.ID()] = r } else { err = ErrRoleExist } rbac.mutex.Unlock() return }
go
func (rbac *RBAC) Add(r Role) (err error) { rbac.mutex.Lock() if _, ok := rbac.roles[r.ID()]; !ok { rbac.roles[r.ID()] = r } else { err = ErrRoleExist } rbac.mutex.Unlock() return }
[ "func", "(", "rbac", "*", "RBAC", ")", "Add", "(", "r", "Role", ")", "(", "err", "error", ")", "{", "rbac", ".", "mutex", ".", "Lock", "(", ")", "\n", "if", "_", ",", "ok", ":=", "rbac", ".", "roles", "[", "r", ".", "ID", "(", ")", "]", "...
// Add a role `r`.
[ "Add", "a", "role", "r", "." ]
a989d0e80a235460ebe9e8f2e7971e9ed948db88
https://github.com/mikespook/gorbac/blob/a989d0e80a235460ebe9e8f2e7971e9ed948db88/rbac.go#L132-L141
20,735
mikespook/gorbac
rbac.go
Remove
func (rbac *RBAC) Remove(id string) (err error) { rbac.mutex.Lock() if _, ok := rbac.roles[id]; ok { delete(rbac.roles, id) for rid, parents := range rbac.parents { if rid == id { delete(rbac.parents, rid) continue } for parent := range parents { if parent == id { delete(rbac.parents[rid...
go
func (rbac *RBAC) Remove(id string) (err error) { rbac.mutex.Lock() if _, ok := rbac.roles[id]; ok { delete(rbac.roles, id) for rid, parents := range rbac.parents { if rid == id { delete(rbac.parents, rid) continue } for parent := range parents { if parent == id { delete(rbac.parents[rid...
[ "func", "(", "rbac", "*", "RBAC", ")", "Remove", "(", "id", "string", ")", "(", "err", "error", ")", "{", "rbac", ".", "mutex", ".", "Lock", "(", ")", "\n", "if", "_", ",", "ok", ":=", "rbac", ".", "roles", "[", "id", "]", ";", "ok", "{", "...
// Remove the role by `id`.
[ "Remove", "the", "role", "by", "id", "." ]
a989d0e80a235460ebe9e8f2e7971e9ed948db88
https://github.com/mikespook/gorbac/blob/a989d0e80a235460ebe9e8f2e7971e9ed948db88/rbac.go#L144-L165
20,736
mikespook/gorbac
rbac.go
Get
func (rbac *RBAC) Get(id string) (r Role, parents []string, err error) { rbac.mutex.RLock() var ok bool if r, ok = rbac.roles[id]; ok { for parent := range rbac.parents[id] { parents = append(parents, parent) } } else { err = ErrRoleNotExist } rbac.mutex.RUnlock() return }
go
func (rbac *RBAC) Get(id string) (r Role, parents []string, err error) { rbac.mutex.RLock() var ok bool if r, ok = rbac.roles[id]; ok { for parent := range rbac.parents[id] { parents = append(parents, parent) } } else { err = ErrRoleNotExist } rbac.mutex.RUnlock() return }
[ "func", "(", "rbac", "*", "RBAC", ")", "Get", "(", "id", "string", ")", "(", "r", "Role", ",", "parents", "[", "]", "string", ",", "err", "error", ")", "{", "rbac", ".", "mutex", ".", "RLock", "(", ")", "\n", "var", "ok", "bool", "\n", "if", ...
// Get the role by `id` and a slice of its parents id.
[ "Get", "the", "role", "by", "id", "and", "a", "slice", "of", "its", "parents", "id", "." ]
a989d0e80a235460ebe9e8f2e7971e9ed948db88
https://github.com/mikespook/gorbac/blob/a989d0e80a235460ebe9e8f2e7971e9ed948db88/rbac.go#L168-L180
20,737
mikespook/gorbac
rbac.go
IsGranted
func (rbac *RBAC) IsGranted(id string, p Permission, assert AssertionFunc) (rslt bool) { rbac.mutex.RLock() rslt = rbac.isGranted(id, p, assert) rbac.mutex.RUnlock() return }
go
func (rbac *RBAC) IsGranted(id string, p Permission, assert AssertionFunc) (rslt bool) { rbac.mutex.RLock() rslt = rbac.isGranted(id, p, assert) rbac.mutex.RUnlock() return }
[ "func", "(", "rbac", "*", "RBAC", ")", "IsGranted", "(", "id", "string", ",", "p", "Permission", ",", "assert", "AssertionFunc", ")", "(", "rslt", "bool", ")", "{", "rbac", ".", "mutex", ".", "RLock", "(", ")", "\n", "rslt", "=", "rbac", ".", "isGr...
// IsGranted tests if the role `id` has Permission `p` with the condition `assert`.
[ "IsGranted", "tests", "if", "the", "role", "id", "has", "Permission", "p", "with", "the", "condition", "assert", "." ]
a989d0e80a235460ebe9e8f2e7971e9ed948db88
https://github.com/mikespook/gorbac/blob/a989d0e80a235460ebe9e8f2e7971e9ed948db88/rbac.go#L183-L188
20,738
tylerb/graceful
graceful.go
Run
func Run(addr string, timeout time.Duration, n http.Handler) { srv := &Server{ Timeout: timeout, TCPKeepAlive: 3 * time.Minute, Server: &http.Server{Addr: addr, Handler: n}, // Logger: DefaultLogger(), } if err := srv.ListenAndServe(); err != nil { if opErr, ok := err.(*net.OpError); !ok ...
go
func Run(addr string, timeout time.Duration, n http.Handler) { srv := &Server{ Timeout: timeout, TCPKeepAlive: 3 * time.Minute, Server: &http.Server{Addr: addr, Handler: n}, // Logger: DefaultLogger(), } if err := srv.ListenAndServe(); err != nil { if opErr, ok := err.(*net.OpError); !ok ...
[ "func", "Run", "(", "addr", "string", ",", "timeout", "time", ".", "Duration", ",", "n", "http", ".", "Handler", ")", "{", "srv", ":=", "&", "Server", "{", "Timeout", ":", "timeout", ",", "TCPKeepAlive", ":", "3", "*", "time", ".", "Minute", ",", "...
// Run serves the http.Handler with graceful shutdown enabled. // // timeout is the duration to wait until killing active requests and stopping the server. // If timeout is 0, the server never times out. It waits for all active requests to finish.
[ "Run", "serves", "the", "http", ".", "Handler", "with", "graceful", "shutdown", "enabled", ".", "timeout", "is", "the", "duration", "to", "wait", "until", "killing", "active", "requests", "and", "stopping", "the", "server", ".", "If", "timeout", "is", "0", ...
d72b0151351a13d0421b763b88f791469c4f5dc7
https://github.com/tylerb/graceful/blob/d72b0151351a13d0421b763b88f791469c4f5dc7/graceful.go#L94-L109
20,739
tylerb/graceful
graceful.go
RunWithErr
func RunWithErr(addr string, timeout time.Duration, n http.Handler) error { srv := &Server{ Timeout: timeout, TCPKeepAlive: 3 * time.Minute, Server: &http.Server{Addr: addr, Handler: n}, Logger: DefaultLogger(), } return srv.ListenAndServe() }
go
func RunWithErr(addr string, timeout time.Duration, n http.Handler) error { srv := &Server{ Timeout: timeout, TCPKeepAlive: 3 * time.Minute, Server: &http.Server{Addr: addr, Handler: n}, Logger: DefaultLogger(), } return srv.ListenAndServe() }
[ "func", "RunWithErr", "(", "addr", "string", ",", "timeout", "time", ".", "Duration", ",", "n", "http", ".", "Handler", ")", "error", "{", "srv", ":=", "&", "Server", "{", "Timeout", ":", "timeout", ",", "TCPKeepAlive", ":", "3", "*", "time", ".", "M...
// RunWithErr is an alternative version of Run function which can return error. // // Unlike Run this version will not exit the program if an error is encountered but will // return it instead.
[ "RunWithErr", "is", "an", "alternative", "version", "of", "Run", "function", "which", "can", "return", "error", ".", "Unlike", "Run", "this", "version", "will", "not", "exit", "the", "program", "if", "an", "error", "is", "encountered", "but", "will", "return...
d72b0151351a13d0421b763b88f791469c4f5dc7
https://github.com/tylerb/graceful/blob/d72b0151351a13d0421b763b88f791469c4f5dc7/graceful.go#L115-L124
20,740
tylerb/graceful
graceful.go
ListenAndServe
func ListenAndServe(server *http.Server, timeout time.Duration) error { srv := &Server{Timeout: timeout, Server: server, Logger: DefaultLogger()} return srv.ListenAndServe() }
go
func ListenAndServe(server *http.Server, timeout time.Duration) error { srv := &Server{Timeout: timeout, Server: server, Logger: DefaultLogger()} return srv.ListenAndServe() }
[ "func", "ListenAndServe", "(", "server", "*", "http", ".", "Server", ",", "timeout", "time", ".", "Duration", ")", "error", "{", "srv", ":=", "&", "Server", "{", "Timeout", ":", "timeout", ",", "Server", ":", "server", ",", "Logger", ":", "DefaultLogger"...
// ListenAndServe is equivalent to http.Server.ListenAndServe with graceful shutdown enabled. // // timeout is the duration to wait until killing active requests and stopping the server. // If timeout is 0, the server never times out. It waits for all active requests to finish.
[ "ListenAndServe", "is", "equivalent", "to", "http", ".", "Server", ".", "ListenAndServe", "with", "graceful", "shutdown", "enabled", ".", "timeout", "is", "the", "duration", "to", "wait", "until", "killing", "active", "requests", "and", "stopping", "the", "serve...
d72b0151351a13d0421b763b88f791469c4f5dc7
https://github.com/tylerb/graceful/blob/d72b0151351a13d0421b763b88f791469c4f5dc7/graceful.go#L130-L133
20,741
tylerb/graceful
graceful.go
ListenAndServe
func (srv *Server) ListenAndServe() error { // Create the listener so we can control their lifetime addr := srv.Addr if addr == "" { addr = ":http" } conn, err := srv.newTCPListener(addr) if err != nil { return err } return srv.Serve(conn) }
go
func (srv *Server) ListenAndServe() error { // Create the listener so we can control their lifetime addr := srv.Addr if addr == "" { addr = ":http" } conn, err := srv.newTCPListener(addr) if err != nil { return err } return srv.Serve(conn) }
[ "func", "(", "srv", "*", "Server", ")", "ListenAndServe", "(", ")", "error", "{", "// Create the listener so we can control their lifetime", "addr", ":=", "srv", ".", "Addr", "\n", "if", "addr", "==", "\"", "\"", "{", "addr", "=", "\"", "\"", "\n", "}", "\...
// ListenAndServe is equivalent to http.Server.ListenAndServe with graceful shutdown enabled.
[ "ListenAndServe", "is", "equivalent", "to", "http", ".", "Server", ".", "ListenAndServe", "with", "graceful", "shutdown", "enabled", "." ]
d72b0151351a13d0421b763b88f791469c4f5dc7
https://github.com/tylerb/graceful/blob/d72b0151351a13d0421b763b88f791469c4f5dc7/graceful.go#L136-L148
20,742
tylerb/graceful
graceful.go
ListenAndServeTLS
func ListenAndServeTLS(server *http.Server, certFile, keyFile string, timeout time.Duration) error { srv := &Server{Timeout: timeout, Server: server, Logger: DefaultLogger()} return srv.ListenAndServeTLS(certFile, keyFile) }
go
func ListenAndServeTLS(server *http.Server, certFile, keyFile string, timeout time.Duration) error { srv := &Server{Timeout: timeout, Server: server, Logger: DefaultLogger()} return srv.ListenAndServeTLS(certFile, keyFile) }
[ "func", "ListenAndServeTLS", "(", "server", "*", "http", ".", "Server", ",", "certFile", ",", "keyFile", "string", ",", "timeout", "time", ".", "Duration", ")", "error", "{", "srv", ":=", "&", "Server", "{", "Timeout", ":", "timeout", ",", "Server", ":",...
// ListenAndServeTLS is equivalent to http.Server.ListenAndServeTLS with graceful shutdown enabled. // // timeout is the duration to wait until killing active requests and stopping the server. // If timeout is 0, the server never times out. It waits for all active requests to finish.
[ "ListenAndServeTLS", "is", "equivalent", "to", "http", ".", "Server", ".", "ListenAndServeTLS", "with", "graceful", "shutdown", "enabled", ".", "timeout", "is", "the", "duration", "to", "wait", "until", "killing", "active", "requests", "and", "stopping", "the", ...
d72b0151351a13d0421b763b88f791469c4f5dc7
https://github.com/tylerb/graceful/blob/d72b0151351a13d0421b763b88f791469c4f5dc7/graceful.go#L154-L157
20,743
tylerb/graceful
graceful.go
ListenTLS
func (srv *Server) ListenTLS(certFile, keyFile string) (net.Listener, error) { // Create the listener ourselves so we can control its lifetime addr := srv.Addr if addr == "" { addr = ":https" } config := &tls.Config{} if srv.TLSConfig != nil { *config = *srv.TLSConfig } var err error if certFile != "" &&...
go
func (srv *Server) ListenTLS(certFile, keyFile string) (net.Listener, error) { // Create the listener ourselves so we can control its lifetime addr := srv.Addr if addr == "" { addr = ":https" } config := &tls.Config{} if srv.TLSConfig != nil { *config = *srv.TLSConfig } var err error if certFile != "" &&...
[ "func", "(", "srv", "*", "Server", ")", "ListenTLS", "(", "certFile", ",", "keyFile", "string", ")", "(", "net", ".", "Listener", ",", "error", ")", "{", "// Create the listener ourselves so we can control its lifetime", "addr", ":=", "srv", ".", "Addr", "\n", ...
// ListenTLS is a convenience method that creates an https listener using the // provided cert and key files. Use this method if you need access to the // listener object directly. When ready, pass it to the Serve method.
[ "ListenTLS", "is", "a", "convenience", "method", "that", "creates", "an", "https", "listener", "using", "the", "provided", "cert", "and", "key", "files", ".", "Use", "this", "method", "if", "you", "need", "access", "to", "the", "listener", "object", "directl...
d72b0151351a13d0421b763b88f791469c4f5dc7
https://github.com/tylerb/graceful/blob/d72b0151351a13d0421b763b88f791469c4f5dc7/graceful.go#L162-L195
20,744
tylerb/graceful
graceful.go
TLSConfigHasHTTP2Enabled
func TLSConfigHasHTTP2Enabled(t *tls.Config) bool { for _, value := range t.NextProtos { if value == "h2" { return true } } return false }
go
func TLSConfigHasHTTP2Enabled(t *tls.Config) bool { for _, value := range t.NextProtos { if value == "h2" { return true } } return false }
[ "func", "TLSConfigHasHTTP2Enabled", "(", "t", "*", "tls", ".", "Config", ")", "bool", "{", "for", "_", ",", "value", ":=", "range", "t", ".", "NextProtos", "{", "if", "value", "==", "\"", "\"", "{", "return", "true", "\n", "}", "\n", "}", "\n", "re...
// TLSConfigHasHTTP2Enabled checks to see if a given TLS Config has http2 enabled.
[ "TLSConfigHasHTTP2Enabled", "checks", "to", "see", "if", "a", "given", "TLS", "Config", "has", "http2", "enabled", "." ]
d72b0151351a13d0421b763b88f791469c4f5dc7
https://github.com/tylerb/graceful/blob/d72b0151351a13d0421b763b88f791469c4f5dc7/graceful.go#L210-L217
20,745
tylerb/graceful
graceful.go
ListenAndServeTLS
func (srv *Server) ListenAndServeTLS(certFile, keyFile string) error { l, err := srv.ListenTLS(certFile, keyFile) if err != nil { return err } return srv.Serve(l) }
go
func (srv *Server) ListenAndServeTLS(certFile, keyFile string) error { l, err := srv.ListenTLS(certFile, keyFile) if err != nil { return err } return srv.Serve(l) }
[ "func", "(", "srv", "*", "Server", ")", "ListenAndServeTLS", "(", "certFile", ",", "keyFile", "string", ")", "error", "{", "l", ",", "err", ":=", "srv", ".", "ListenTLS", "(", "certFile", ",", "keyFile", ")", "\n", "if", "err", "!=", "nil", "{", "ret...
// ListenAndServeTLS is equivalent to http.Server.ListenAndServeTLS with graceful shutdown enabled.
[ "ListenAndServeTLS", "is", "equivalent", "to", "http", ".", "Server", ".", "ListenAndServeTLS", "with", "graceful", "shutdown", "enabled", "." ]
d72b0151351a13d0421b763b88f791469c4f5dc7
https://github.com/tylerb/graceful/blob/d72b0151351a13d0421b763b88f791469c4f5dc7/graceful.go#L220-L227
20,746
tylerb/graceful
graceful.go
ListenAndServeTLSConfig
func (srv *Server) ListenAndServeTLSConfig(config *tls.Config) error { addr := srv.Addr if addr == "" { addr = ":https" } conn, err := srv.newTCPListener(addr) if err != nil { return err } srv.TLSConfig = config tlsListener := tls.NewListener(conn, config) return srv.Serve(tlsListener) }
go
func (srv *Server) ListenAndServeTLSConfig(config *tls.Config) error { addr := srv.Addr if addr == "" { addr = ":https" } conn, err := srv.newTCPListener(addr) if err != nil { return err } srv.TLSConfig = config tlsListener := tls.NewListener(conn, config) return srv.Serve(tlsListener) }
[ "func", "(", "srv", "*", "Server", ")", "ListenAndServeTLSConfig", "(", "config", "*", "tls", ".", "Config", ")", "error", "{", "addr", ":=", "srv", ".", "Addr", "\n", "if", "addr", "==", "\"", "\"", "{", "addr", "=", "\"", "\"", "\n", "}", "\n\n",...
// ListenAndServeTLSConfig can be used with an existing TLS config and is equivalent to // http.Server.ListenAndServeTLS with graceful shutdown enabled,
[ "ListenAndServeTLSConfig", "can", "be", "used", "with", "an", "existing", "TLS", "config", "and", "is", "equivalent", "to", "http", ".", "Server", ".", "ListenAndServeTLS", "with", "graceful", "shutdown", "enabled" ]
d72b0151351a13d0421b763b88f791469c4f5dc7
https://github.com/tylerb/graceful/blob/d72b0151351a13d0421b763b88f791469c4f5dc7/graceful.go#L231-L246
20,747
tylerb/graceful
graceful.go
Serve
func Serve(server *http.Server, l net.Listener, timeout time.Duration) error { srv := &Server{Timeout: timeout, Server: server, Logger: DefaultLogger()} return srv.Serve(l) }
go
func Serve(server *http.Server, l net.Listener, timeout time.Duration) error { srv := &Server{Timeout: timeout, Server: server, Logger: DefaultLogger()} return srv.Serve(l) }
[ "func", "Serve", "(", "server", "*", "http", ".", "Server", ",", "l", "net", ".", "Listener", ",", "timeout", "time", ".", "Duration", ")", "error", "{", "srv", ":=", "&", "Server", "{", "Timeout", ":", "timeout", ",", "Server", ":", "server", ",", ...
// Serve is equivalent to http.Server.Serve with graceful shutdown enabled. // // timeout is the duration to wait until killing active requests and stopping the server. // If timeout is 0, the server never times out. It waits for all active requests to finish.
[ "Serve", "is", "equivalent", "to", "http", ".", "Server", ".", "Serve", "with", "graceful", "shutdown", "enabled", ".", "timeout", "is", "the", "duration", "to", "wait", "until", "killing", "active", "requests", "and", "stopping", "the", "server", ".", "If",...
d72b0151351a13d0421b763b88f791469c4f5dc7
https://github.com/tylerb/graceful/blob/d72b0151351a13d0421b763b88f791469c4f5dc7/graceful.go#L252-L256
20,748
tylerb/graceful
graceful.go
Serve
func (srv *Server) Serve(listener net.Listener) error { if srv.ListenLimit != 0 { listener = LimitListener(listener, srv.ListenLimit) } // Make our stopchan srv.StopChan() // Track connection state add := make(chan net.Conn) idle := make(chan net.Conn) active := make(chan net.Conn) remove := make(chan net...
go
func (srv *Server) Serve(listener net.Listener) error { if srv.ListenLimit != 0 { listener = LimitListener(listener, srv.ListenLimit) } // Make our stopchan srv.StopChan() // Track connection state add := make(chan net.Conn) idle := make(chan net.Conn) active := make(chan net.Conn) remove := make(chan net...
[ "func", "(", "srv", "*", "Server", ")", "Serve", "(", "listener", "net", ".", "Listener", ")", "error", "{", "if", "srv", ".", "ListenLimit", "!=", "0", "{", "listener", "=", "LimitListener", "(", "listener", ",", "srv", ".", "ListenLimit", ")", "\n", ...
// Serve is equivalent to http.Server.Serve with graceful shutdown enabled.
[ "Serve", "is", "equivalent", "to", "http", ".", "Server", ".", "Serve", "with", "graceful", "shutdown", "enabled", "." ]
d72b0151351a13d0421b763b88f791469c4f5dc7
https://github.com/tylerb/graceful/blob/d72b0151351a13d0421b763b88f791469c4f5dc7/graceful.go#L259-L325
20,749
tylerb/graceful
graceful.go
Stop
func (srv *Server) Stop(timeout time.Duration) { srv.stopLock.Lock() defer srv.stopLock.Unlock() srv.Timeout = timeout sendSignalInt(srv.interruptChan()) }
go
func (srv *Server) Stop(timeout time.Duration) { srv.stopLock.Lock() defer srv.stopLock.Unlock() srv.Timeout = timeout sendSignalInt(srv.interruptChan()) }
[ "func", "(", "srv", "*", "Server", ")", "Stop", "(", "timeout", "time", ".", "Duration", ")", "{", "srv", ".", "stopLock", ".", "Lock", "(", ")", "\n", "defer", "srv", ".", "stopLock", ".", "Unlock", "(", ")", "\n\n", "srv", ".", "Timeout", "=", ...
// Stop instructs the type to halt operations and close // the stop channel when it is finished. // // timeout is grace period for which to wait before shutting // down the server. The timeout value passed here will override the // timeout given when constructing the server, as this is an explicit // command to stop th...
[ "Stop", "instructs", "the", "type", "to", "halt", "operations", "and", "close", "the", "stop", "channel", "when", "it", "is", "finished", ".", "timeout", "is", "grace", "period", "for", "which", "to", "wait", "before", "shutting", "down", "the", "server", ...
d72b0151351a13d0421b763b88f791469c4f5dc7
https://github.com/tylerb/graceful/blob/d72b0151351a13d0421b763b88f791469c4f5dc7/graceful.go#L334-L340
20,750
tylerb/graceful
graceful.go
StopChan
func (srv *Server) StopChan() <-chan struct{} { srv.chanLock.Lock() defer srv.chanLock.Unlock() if srv.stopChan == nil { srv.stopChan = make(chan struct{}) } return srv.stopChan }
go
func (srv *Server) StopChan() <-chan struct{} { srv.chanLock.Lock() defer srv.chanLock.Unlock() if srv.stopChan == nil { srv.stopChan = make(chan struct{}) } return srv.stopChan }
[ "func", "(", "srv", "*", "Server", ")", "StopChan", "(", ")", "<-", "chan", "struct", "{", "}", "{", "srv", ".", "chanLock", ".", "Lock", "(", ")", "\n", "defer", "srv", ".", "chanLock", ".", "Unlock", "(", ")", "\n\n", "if", "srv", ".", "stopCha...
// StopChan gets the stop channel which will block until // stopping has completed, at which point it is closed. // Callers should never close the stop channel.
[ "StopChan", "gets", "the", "stop", "channel", "which", "will", "block", "until", "stopping", "has", "completed", "at", "which", "point", "it", "is", "closed", ".", "Callers", "should", "never", "close", "the", "stop", "channel", "." ]
d72b0151351a13d0421b763b88f791469c4f5dc7
https://github.com/tylerb/graceful/blob/d72b0151351a13d0421b763b88f791469c4f5dc7/graceful.go#L345-L353
20,751
hashicorp/go-multierror
multierror.go
ErrorOrNil
func (e *Error) ErrorOrNil() error { if e == nil { return nil } if len(e.Errors) == 0 { return nil } return e }
go
func (e *Error) ErrorOrNil() error { if e == nil { return nil } if len(e.Errors) == 0 { return nil } return e }
[ "func", "(", "e", "*", "Error", ")", "ErrorOrNil", "(", ")", "error", "{", "if", "e", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "if", "len", "(", "e", ".", "Errors", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "return", ...
// ErrorOrNil returns an error interface if this Error represents // a list of errors, or returns nil if the list of errors is empty. This // function is useful at the end of accumulation to make sure that the value // returned represents the existence of errors.
[ "ErrorOrNil", "returns", "an", "error", "interface", "if", "this", "Error", "represents", "a", "list", "of", "errors", "or", "returns", "nil", "if", "the", "list", "of", "errors", "is", "empty", ".", "This", "function", "is", "useful", "at", "the", "end", ...
886a7fbe3eb1c874d46f623bfa70af45f425b3d1
https://github.com/hashicorp/go-multierror/blob/886a7fbe3eb1c874d46f623bfa70af45f425b3d1/multierror.go#L27-L36
20,752
hashicorp/go-multierror
prefix.go
Prefix
func Prefix(err error, prefix string) error { if err == nil { return nil } format := fmt.Sprintf("%s {{err}}", prefix) switch err := err.(type) { case *Error: // Typed nils can reach here, so initialize if we are nil if err == nil { err = new(Error) } // Wrap each of the errors for i, e := range e...
go
func Prefix(err error, prefix string) error { if err == nil { return nil } format := fmt.Sprintf("%s {{err}}", prefix) switch err := err.(type) { case *Error: // Typed nils can reach here, so initialize if we are nil if err == nil { err = new(Error) } // Wrap each of the errors for i, e := range e...
[ "func", "Prefix", "(", "err", "error", ",", "prefix", "string", ")", "error", "{", "if", "err", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "format", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "prefix", ")", "\n", "switch", "err",...
// Prefix is a helper function that will prefix some text // to the given error. If the error is a multierror.Error, then // it will be prefixed to each wrapped error. // // This is useful to use when appending multiple multierrors // together in order to give better scoping.
[ "Prefix", "is", "a", "helper", "function", "that", "will", "prefix", "some", "text", "to", "the", "given", "error", ".", "If", "the", "error", "is", "a", "multierror", ".", "Error", "then", "it", "will", "be", "prefixed", "to", "each", "wrapped", "error"...
886a7fbe3eb1c874d46f623bfa70af45f425b3d1
https://github.com/hashicorp/go-multierror/blob/886a7fbe3eb1c874d46f623bfa70af45f425b3d1/prefix.go#L15-L37
20,753
hashicorp/go-multierror
append.go
Append
func Append(err error, errs ...error) *Error { switch err := err.(type) { case *Error: // Typed nils can reach here, so initialize if we are nil if err == nil { err = new(Error) } // Go through each error and flatten for _, e := range errs { switch e := e.(type) { case *Error: if e != nil { ...
go
func Append(err error, errs ...error) *Error { switch err := err.(type) { case *Error: // Typed nils can reach here, so initialize if we are nil if err == nil { err = new(Error) } // Go through each error and flatten for _, e := range errs { switch e := e.(type) { case *Error: if e != nil { ...
[ "func", "Append", "(", "err", "error", ",", "errs", "...", "error", ")", "*", "Error", "{", "switch", "err", ":=", "err", ".", "(", "type", ")", "{", "case", "*", "Error", ":", "// Typed nils can reach here, so initialize if we are nil", "if", "err", "==", ...
// Append is a helper function that will append more errors // onto an Error in order to create a larger multi-error. // // If err is not a multierror.Error, then it will be turned into // one. If any of the errs are multierr.Error, they will be flattened // one level into err.
[ "Append", "is", "a", "helper", "function", "that", "will", "append", "more", "errors", "onto", "an", "Error", "in", "order", "to", "create", "a", "larger", "multi", "-", "error", ".", "If", "err", "is", "not", "a", "multierror", ".", "Error", "then", "...
886a7fbe3eb1c874d46f623bfa70af45f425b3d1
https://github.com/hashicorp/go-multierror/blob/886a7fbe3eb1c874d46f623bfa70af45f425b3d1/append.go#L9-L41
20,754
hashicorp/go-multierror
sort.go
Swap
func (err Error) Swap(i, j int) { err.Errors[i], err.Errors[j] = err.Errors[j], err.Errors[i] }
go
func (err Error) Swap(i, j int) { err.Errors[i], err.Errors[j] = err.Errors[j], err.Errors[i] }
[ "func", "(", "err", "Error", ")", "Swap", "(", "i", ",", "j", "int", ")", "{", "err", ".", "Errors", "[", "i", "]", ",", "err", ".", "Errors", "[", "j", "]", "=", "err", ".", "Errors", "[", "j", "]", ",", "err", ".", "Errors", "[", "i", "...
// Swap implements sort.Interface function for swapping elements
[ "Swap", "implements", "sort", ".", "Interface", "function", "for", "swapping", "elements" ]
886a7fbe3eb1c874d46f623bfa70af45f425b3d1
https://github.com/hashicorp/go-multierror/blob/886a7fbe3eb1c874d46f623bfa70af45f425b3d1/sort.go#L9-L11
20,755
hashicorp/go-multierror
sort.go
Less
func (err Error) Less(i, j int) bool { return err.Errors[i].Error() < err.Errors[j].Error() }
go
func (err Error) Less(i, j int) bool { return err.Errors[i].Error() < err.Errors[j].Error() }
[ "func", "(", "err", "Error", ")", "Less", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "err", ".", "Errors", "[", "i", "]", ".", "Error", "(", ")", "<", "err", ".", "Errors", "[", "j", "]", ".", "Error", "(", ")", "\n", "}" ]
// Less implements sort.Interface function for determining order
[ "Less", "implements", "sort", ".", "Interface", "function", "for", "determining", "order" ]
886a7fbe3eb1c874d46f623bfa70af45f425b3d1
https://github.com/hashicorp/go-multierror/blob/886a7fbe3eb1c874d46f623bfa70af45f425b3d1/sort.go#L14-L16
20,756
deis/deis
deisctl/backend/fleet/journal.go
runJournal
func (c *FleetClient) runJournal(name string) (exit int) { u, err := c.Fleet.Unit(name) if suToGlobal(*u) { fmt.Fprintf(c.errWriter, "Unable to get journal for global unit %s. Check on a host directly using journalctl.\n", name) return 1 } machineID, err := c.findUnit(name) if err != nil { return 1 } co...
go
func (c *FleetClient) runJournal(name string) (exit int) { u, err := c.Fleet.Unit(name) if suToGlobal(*u) { fmt.Fprintf(c.errWriter, "Unable to get journal for global unit %s. Check on a host directly using journalctl.\n", name) return 1 } machineID, err := c.findUnit(name) if err != nil { return 1 } co...
[ "func", "(", "c", "*", "FleetClient", ")", "runJournal", "(", "name", "string", ")", "(", "exit", "int", ")", "{", "u", ",", "err", ":=", "c", ".", "Fleet", ".", "Unit", "(", "name", ")", "\n", "if", "suToGlobal", "(", "*", "u", ")", "{", "fmt"...
// runJournal tails the systemd journal for a given unit
[ "runJournal", "tails", "the", "systemd", "journal", "for", "a", "given", "unit" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/journal.go#L20-L35
20,757
deis/deis
client/parser/ps.go
Ps
func Ps(argv []string) error { usage := ` Valid commands for processes: ps:list list application processes ps:restart restart an application or its process types ps:scale scale processes (e.g. web=4 worker=2) Use 'deis help [command]' to learn more. ` switch argv[0] { case "ps:list": return psL...
go
func Ps(argv []string) error { usage := ` Valid commands for processes: ps:list list application processes ps:restart restart an application or its process types ps:scale scale processes (e.g. web=4 worker=2) Use 'deis help [command]' to learn more. ` switch argv[0] { case "ps:list": return psL...
[ "func", "Ps", "(", "argv", "[", "]", "string", ")", "error", "{", "usage", ":=", "`\nValid commands for processes:\n\nps:list list application processes\nps:restart restart an application or its process types\nps:scale scale processes (e.g. web=4 worker=2)\n\nUse 'deis help ...
// Ps routes ps commands to their specific function.
[ "Ps", "routes", "ps", "commands", "to", "their", "specific", "function", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/parser/ps.go#L9-L40
20,758
deis/deis
logger/publisher/publisher.go
NewPublisher
func NewPublisher(etcdHost string, etcdPort int, etcdPath string, publishInterval int, publishTTL int, logHost string, logPort int) (*Publisher, error) { etcdClient := etcd.NewClient([]string{fmt.Sprintf("http://%s:%d", etcdHost, etcdPort)}) ticker := time.NewTicker(time.Duration(publishInterval) * time.Second) ret...
go
func NewPublisher(etcdHost string, etcdPort int, etcdPath string, publishInterval int, publishTTL int, logHost string, logPort int) (*Publisher, error) { etcdClient := etcd.NewClient([]string{fmt.Sprintf("http://%s:%d", etcdHost, etcdPort)}) ticker := time.NewTicker(time.Duration(publishInterval) * time.Second) ret...
[ "func", "NewPublisher", "(", "etcdHost", "string", ",", "etcdPort", "int", ",", "etcdPath", "string", ",", "publishInterval", "int", ",", "publishTTL", "int", ",", "logHost", "string", ",", "logPort", "int", ")", "(", "*", "Publisher", ",", "error", ")", "...
// NewPublisher returns a pointer to a new Publisher instance.
[ "NewPublisher", "returns", "a", "pointer", "to", "a", "new", "Publisher", "instance", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/publisher/publisher.go#L25-L37
20,759
deis/deis
logger/publisher/publisher.go
Start
func (p *Publisher) Start() { // Should only ever be called once if !p.running { p.running = true go p.publish() log.Println("publisher running") } }
go
func (p *Publisher) Start() { // Should only ever be called once if !p.running { p.running = true go p.publish() log.Println("publisher running") } }
[ "func", "(", "p", "*", "Publisher", ")", "Start", "(", ")", "{", "// Should only ever be called once", "if", "!", "p", ".", "running", "{", "p", ".", "running", "=", "true", "\n", "go", "p", ".", "publish", "(", ")", "\n", "log", ".", "Println", "(",...
// Start begins the publisher's main loop.
[ "Start", "begins", "the", "publisher", "s", "main", "loop", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/publisher/publisher.go#L40-L47
20,760
deis/deis
logspout/logspout.go
getLogParts
func getLogParts(logline *Log) (string, string, string) { // example regex that should match: go_v2.web.1 match := getMatch(`(^[a-z0-9-]+)_(v[0-9]+)\.([a-z-_]+\.[0-9]+)$`, logline.Name) if match != nil { return match[1], match[3], logline.Data } if logline.Name == "deis-controller" { data_match := getMatch(`^[...
go
func getLogParts(logline *Log) (string, string, string) { // example regex that should match: go_v2.web.1 match := getMatch(`(^[a-z0-9-]+)_(v[0-9]+)\.([a-z-_]+\.[0-9]+)$`, logline.Name) if match != nil { return match[1], match[3], logline.Data } if logline.Name == "deis-controller" { data_match := getMatch(`^[...
[ "func", "getLogParts", "(", "logline", "*", "Log", ")", "(", "string", ",", "string", ",", "string", ")", "{", "// example regex that should match: go_v2.web.1", "match", ":=", "getMatch", "(", "`(^[a-z0-9-]+)_(v[0-9]+)\\.([a-z-_]+\\.[0-9]+)$`", ",", "logline", ".", "...
// getLogParts returns a custom tag and PID for containers that // match Deis' specific application name format. Otherwise, // it returns the original name and 1 as the PID. Additionally, // it returns log data. The function is also smart enough to // detect when a leading tag in the log data represents an attempt //...
[ "getLogParts", "returns", "a", "custom", "tag", "and", "PID", "for", "containers", "that", "match", "Deis", "specific", "application", "name", "format", ".", "Otherwise", "it", "returns", "the", "original", "name", "and", "1", "as", "the", "PID", ".", "Addit...
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logspout/logspout.go#L118-L131
20,761
deis/deis
deisctl/client/client.go
NewClient
func NewClient(requestedBackend string) (*Client, error) { var backend backend.Backend cb, err := etcd.NewConfigBackend() if err != nil { return nil, err } if requestedBackend == "" { requestedBackend = "fleet" } switch requestedBackend { case "fleet": b, err := fleet.NewClient(cb) if err != nil { ...
go
func NewClient(requestedBackend string) (*Client, error) { var backend backend.Backend cb, err := etcd.NewConfigBackend() if err != nil { return nil, err } if requestedBackend == "" { requestedBackend = "fleet" } switch requestedBackend { case "fleet": b, err := fleet.NewClient(cb) if err != nil { ...
[ "func", "NewClient", "(", "requestedBackend", "string", ")", "(", "*", "Client", ",", "error", ")", "{", "var", "backend", "backend", ".", "Backend", "\n\n", "cb", ",", "err", ":=", "etcd", ".", "NewConfigBackend", "(", ")", "\n", "if", "err", "!=", "n...
// NewClient returns a Client using the requested backend. // The only backend currently supported is "fleet".
[ "NewClient", "returns", "a", "Client", "using", "the", "requested", "backend", ".", "The", "only", "backend", "currently", "supported", "is", "fleet", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/client/client.go#L47-L71
20,762
deis/deis
deisctl/client/client.go
UpgradePrep
func (c *Client) UpgradePrep(argv []string) error { usage := `Prepare platform for graceful upgrade. Usage: deisctl upgrade-prep [--stateless] Options: --stateless Use when the target platform is stateless ` args, err := docopt.Parse(usage, argv, true, "", false) if err != nil { return err } stateless, _...
go
func (c *Client) UpgradePrep(argv []string) error { usage := `Prepare platform for graceful upgrade. Usage: deisctl upgrade-prep [--stateless] Options: --stateless Use when the target platform is stateless ` args, err := docopt.Parse(usage, argv, true, "", false) if err != nil { return err } stateless, _...
[ "func", "(", "c", "*", "Client", ")", "UpgradePrep", "(", "argv", "[", "]", "string", ")", "error", "{", "usage", ":=", "`Prepare platform for graceful upgrade.\n\nUsage:\n deisctl upgrade-prep [--stateless]\n\nOptions:\n --stateless Use when the target platform is stateless\n`"...
// UpgradePrep prepares a running cluster to be upgraded
[ "UpgradePrep", "prepares", "a", "running", "cluster", "to", "be", "upgraded" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/client/client.go#L74-L91
20,763
deis/deis
deisctl/client/client.go
RollingRestart
func (c *Client) RollingRestart(argv []string) error { usage := `Perform a rolling restart of an instance unit. Usage: deisctl rolling-restart <target> ` args, err := docopt.Parse(usage, argv, true, "", false) if err != nil { return err } return cmd.RollingRestart(args["<target>"].(string), c.Backend) }
go
func (c *Client) RollingRestart(argv []string) error { usage := `Perform a rolling restart of an instance unit. Usage: deisctl rolling-restart <target> ` args, err := docopt.Parse(usage, argv, true, "", false) if err != nil { return err } return cmd.RollingRestart(args["<target>"].(string), c.Backend) }
[ "func", "(", "c", "*", "Client", ")", "RollingRestart", "(", "argv", "[", "]", "string", ")", "error", "{", "usage", ":=", "`Perform a rolling restart of an instance unit.\n\nUsage:\n deisctl rolling-restart <target>\n`", "\n", "args", ",", "err", ":=", "docopt", "."...
// RollingRestart attempts a rolling restart of an instance unit
[ "RollingRestart", "attempts", "a", "rolling", "restart", "of", "an", "instance", "unit" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/client/client.go#L114-L126
20,764
deis/deis
deisctl/client/client.go
List
func (c *Client) List(argv []string) error { usage := `Prints a list of installed units. Usage: deisctl list ` // parse command-line arguments if _, err := docopt.Parse(usage, argv, true, "", false); err != nil { return err } return cmd.ListUnits(c.Backend) }
go
func (c *Client) List(argv []string) error { usage := `Prints a list of installed units. Usage: deisctl list ` // parse command-line arguments if _, err := docopt.Parse(usage, argv, true, "", false); err != nil { return err } return cmd.ListUnits(c.Backend) }
[ "func", "(", "c", "*", "Client", ")", "List", "(", "argv", "[", "]", "string", ")", "error", "{", "usage", ":=", "`Prints a list of installed units.\n\nUsage:\n deisctl list\n`", "\n", "// parse command-line arguments", "if", "_", ",", "err", ":=", "docopt", ".",...
// List prints a summary of installed components.
[ "List", "prints", "a", "summary", "of", "installed", "components", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/client/client.go#L231-L242
20,765
deis/deis
deisctl/client/client.go
RefreshUnits
func (c *Client) RefreshUnits(argv []string) error { usage := `Overwrites local unit files with those requested. Downloading from the Deis project GitHub URL by tag or SHA is the only mechanism currently supported. "deisctl install" looks for unit files in these directories, in this order: - the $DEISCTL_UNITS envir...
go
func (c *Client) RefreshUnits(argv []string) error { usage := `Overwrites local unit files with those requested. Downloading from the Deis project GitHub URL by tag or SHA is the only mechanism currently supported. "deisctl install" looks for unit files in these directories, in this order: - the $DEISCTL_UNITS envir...
[ "func", "(", "c", "*", "Client", ")", "RefreshUnits", "(", "argv", "[", "]", "string", ")", "error", "{", "usage", ":=", "`Overwrites local unit files with those requested.\n\nDownloading from the Deis project GitHub URL by tag or SHA is the only mechanism\ncurrently supported.\n\n...
// RefreshUnits overwrites local unit files with those requested.
[ "RefreshUnits", "overwrites", "local", "unit", "files", "with", "those", "requested", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/client/client.go#L259-L286
20,766
deis/deis
deisctl/client/client.go
SSH
func (c *Client) SSH(argv []string) error { usage := `Open an interactive shell on a machine in the cluster given a unit or machine id. If an optional <command> is provided, that command is run remotely, and the results returned. Usage: deisctl ssh <target> [<command>...] ` // parse command-line arguments args, ...
go
func (c *Client) SSH(argv []string) error { usage := `Open an interactive shell on a machine in the cluster given a unit or machine id. If an optional <command> is provided, that command is run remotely, and the results returned. Usage: deisctl ssh <target> [<command>...] ` // parse command-line arguments args, ...
[ "func", "(", "c", "*", "Client", ")", "SSH", "(", "argv", "[", "]", "string", ")", "error", "{", "usage", ":=", "`Open an interactive shell on a machine in the cluster given a unit or machine id.\n\nIf an optional <command> is provided, that command is run remotely, and the results...
// SSH opens an interactive shell with a machine in the cluster.
[ "SSH", "opens", "an", "interactive", "shell", "with", "a", "machine", "in", "the", "cluster", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/client/client.go#L323-L350
20,767
deis/deis
builder/git/git.go
cleanRepoName
func cleanRepoName(name string) (string, error) { if len(name) == 0 { return name, errors.New("Empty repo name.") } if strings.Contains(name, "..") { return "", errors.New("Cannot change directory in file name.") } name = strings.Replace(name, "'", "", -1) return strings.TrimPrefix(strings.TrimSuffix(name, "....
go
func cleanRepoName(name string) (string, error) { if len(name) == 0 { return name, errors.New("Empty repo name.") } if strings.Contains(name, "..") { return "", errors.New("Cannot change directory in file name.") } name = strings.Replace(name, "'", "", -1) return strings.TrimPrefix(strings.TrimSuffix(name, "....
[ "func", "cleanRepoName", "(", "name", "string", ")", "(", "string", ",", "error", ")", "{", "if", "len", "(", "name", ")", "==", "0", "{", "return", "name", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "strings", ".", ...
// cleanRepoName cleans a repository name for a git-sh operation.
[ "cleanRepoName", "cleans", "a", "repository", "name", "for", "a", "git", "-", "sh", "operation", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/git/git.go#L142-L151
20,768
deis/deis
builder/git/git.go
initRepo
func initRepo(repoPath, gitHome string, c cookoo.Context) (bool, error) { log.Infof(c, "Creating new directory at %s", repoPath) // Create directory if err := os.MkdirAll(repoPath, 0755); err != nil { log.Warnf(c, "Failed to create repository: %s", err) return false, err } cmd := exec.Command("git", "init", "-...
go
func initRepo(repoPath, gitHome string, c cookoo.Context) (bool, error) { log.Infof(c, "Creating new directory at %s", repoPath) // Create directory if err := os.MkdirAll(repoPath, 0755); err != nil { log.Warnf(c, "Failed to create repository: %s", err) return false, err } cmd := exec.Command("git", "init", "-...
[ "func", "initRepo", "(", "repoPath", ",", "gitHome", "string", ",", "c", "cookoo", ".", "Context", ")", "(", "bool", ",", "error", ")", "{", "log", ".", "Infof", "(", "c", ",", "\"", "\"", ",", "repoPath", ")", "\n", "// Create directory", "if", "err...
// initRepo create a directory and init a new Git repo
[ "initRepo", "create", "a", "directory", "and", "init", "a", "new", "Git", "repo" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/git/git.go#L173-L194
20,769
deis/deis
builder/git/git.go
prereceiveHook
func prereceiveHook(vars map[string]string) ([]byte, error) { var out bytes.Buffer // We parse the template anew each receive in case it has changed. t, err := template.New("hooks").Parse(PrereceiveHookTpl) if err != nil { return []byte{}, err } err = t.Execute(&out, vars) return out.Bytes(), err }
go
func prereceiveHook(vars map[string]string) ([]byte, error) { var out bytes.Buffer // We parse the template anew each receive in case it has changed. t, err := template.New("hooks").Parse(PrereceiveHookTpl) if err != nil { return []byte{}, err } err = t.Execute(&out, vars) return out.Bytes(), err }
[ "func", "prereceiveHook", "(", "vars", "map", "[", "string", "]", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "out", "bytes", ".", "Buffer", "\n", "// We parse the template anew each receive in case it has changed.", "t", ",", "err", "...
//prereceiveHook templates a pre-receive hook for Git.
[ "prereceiveHook", "templates", "a", "pre", "-", "receive", "hook", "for", "Git", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/git/git.go#L233-L243
20,770
deis/deis
builder/sshd/server.go
sshConnection
func sshConnection(conn net.Conn) string { remote := conn.RemoteAddr().String() local := conn.LocalAddr().String() rhost, rport, _ := net.SplitHostPort(remote) lhost, lport, _ := net.SplitHostPort(local) return fmt.Sprintf("%s %d %s %d", rhost, rport, lhost, lport) }
go
func sshConnection(conn net.Conn) string { remote := conn.RemoteAddr().String() local := conn.LocalAddr().String() rhost, rport, _ := net.SplitHostPort(remote) lhost, lport, _ := net.SplitHostPort(local) return fmt.Sprintf("%s %d %s %d", rhost, rport, lhost, lport) }
[ "func", "sshConnection", "(", "conn", "net", ".", "Conn", ")", "string", "{", "remote", ":=", "conn", ".", "RemoteAddr", "(", ")", ".", "String", "(", ")", "\n", "local", ":=", "conn", ".", "LocalAddr", "(", ")", ".", "String", "(", ")", "\n", "rho...
// sshConnection generates the SSH_CONNECTION environment variable. // // This is untested on UNIX sockets.
[ "sshConnection", "generates", "the", "SSH_CONNECTION", "environment", "variable", ".", "This", "is", "untested", "on", "UNIX", "sockets", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/sshd/server.go#L153-L160
20,771
deis/deis
builder/sshd/server.go
answer
func (s *server) answer(channel ssh.Channel, requests <-chan *ssh.Request, sshConn string) error { defer channel.Close() // Answer all the requests on this connection. for req := range requests { ok := false // I think that ideally what we want to do here is pass this on to // the Cookoo router and let it ha...
go
func (s *server) answer(channel ssh.Channel, requests <-chan *ssh.Request, sshConn string) error { defer channel.Close() // Answer all the requests on this connection. for req := range requests { ok := false // I think that ideally what we want to do here is pass this on to // the Cookoo router and let it ha...
[ "func", "(", "s", "*", "server", ")", "answer", "(", "channel", "ssh", ".", "Channel", ",", "requests", "<-", "chan", "*", "ssh", ".", "Request", ",", "sshConn", "string", ")", "error", "{", "defer", "channel", ".", "Close", "(", ")", "\n\n", "// Ans...
// answer handles answering requests and channel requests // // Currently, an exec must be either "ping", "git-receive-pack" or // "git-upload-pack". Anything else will result in a failure response. Right // now, we leave the channel open on failure because it is unclear what the // correct behavior for a failed exec i...
[ "answer", "handles", "answering", "requests", "and", "channel", "requests", "Currently", "an", "exec", "must", "be", "either", "ping", "git", "-", "receive", "-", "pack", "or", "git", "-", "upload", "-", "pack", ".", "Anything", "else", "will", "result", "...
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/sshd/server.go#L176-L253
20,772
deis/deis
builder/sshd/server.go
cleanExec
func cleanExec(pay []byte) string { e := &ExecCmd{} ssh.Unmarshal(pay, e) // TODO: Minimal escaping of values in command. There is probably a better // way of doing this. r := strings.NewReplacer("$", "", "`", "'") return r.Replace(e.Value) }
go
func cleanExec(pay []byte) string { e := &ExecCmd{} ssh.Unmarshal(pay, e) // TODO: Minimal escaping of values in command. There is probably a better // way of doing this. r := strings.NewReplacer("$", "", "`", "'") return r.Replace(e.Value) }
[ "func", "cleanExec", "(", "pay", "[", "]", "byte", ")", "string", "{", "e", ":=", "&", "ExecCmd", "{", "}", "\n", "ssh", ".", "Unmarshal", "(", "pay", ",", "e", ")", "\n", "// TODO: Minimal escaping of values in command. There is probably a better", "// way of d...
// cleanExec cleans the exec string.
[ "cleanExec", "cleans", "the", "exec", "string", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/sshd/server.go#L272-L279
20,773
deis/deis
client/controller/models/config/config.go
List
func List(c *client.Client, app string) (api.Config, error) { u := fmt.Sprintf("/v1/apps/%s/config/", app) body, err := c.BasicRequest("GET", u, nil) if err != nil { return api.Config{}, err } config := api.Config{} if err = json.Unmarshal([]byte(body), &config); err != nil { return api.Config{}, err } ...
go
func List(c *client.Client, app string) (api.Config, error) { u := fmt.Sprintf("/v1/apps/%s/config/", app) body, err := c.BasicRequest("GET", u, nil) if err != nil { return api.Config{}, err } config := api.Config{} if err = json.Unmarshal([]byte(body), &config); err != nil { return api.Config{}, err } ...
[ "func", "List", "(", "c", "*", "client", ".", "Client", ",", "app", "string", ")", "(", "api", ".", "Config", ",", "error", ")", "{", "u", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "app", ")", "\n\n", "body", ",", "err", ":=", "c", "...
// List lists an app's config.
[ "List", "lists", "an", "app", "s", "config", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/config/config.go#L12-L27
20,774
deis/deis
client/controller/models/config/config.go
Set
func Set(c *client.Client, app string, config api.Config) (api.Config, error) { body, err := json.Marshal(config) if err != nil { return api.Config{}, err } u := fmt.Sprintf("/v1/apps/%s/config/", app) resBody, err := c.BasicRequest("POST", u, body) if err != nil { return api.Config{}, err } newConfig ...
go
func Set(c *client.Client, app string, config api.Config) (api.Config, error) { body, err := json.Marshal(config) if err != nil { return api.Config{}, err } u := fmt.Sprintf("/v1/apps/%s/config/", app) resBody, err := c.BasicRequest("POST", u, body) if err != nil { return api.Config{}, err } newConfig ...
[ "func", "Set", "(", "c", "*", "client", ".", "Client", ",", "app", "string", ",", "config", "api", ".", "Config", ")", "(", "api", ".", "Config", ",", "error", ")", "{", "body", ",", "err", ":=", "json", ".", "Marshal", "(", "config", ")", "\n\n"...
// Set sets an app's config variables.
[ "Set", "sets", "an", "app", "s", "config", "variables", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/config/config.go#L30-L51
20,775
deis/deis
deisctl/backend/fleet/scale.go
Scale
func (c *FleetClient) Scale( component string, requested int, wg *sync.WaitGroup, out, ew io.Writer) { if requested < 0 { fmt.Fprintln(ew, "cannot scale below 0") return } // check how many currently exist components, err := c.Units(component) if err != nil { // skip checking the first time; we just want a...
go
func (c *FleetClient) Scale( component string, requested int, wg *sync.WaitGroup, out, ew io.Writer) { if requested < 0 { fmt.Fprintln(ew, "cannot scale below 0") return } // check how many currently exist components, err := c.Units(component) if err != nil { // skip checking the first time; we just want a...
[ "func", "(", "c", "*", "FleetClient", ")", "Scale", "(", "component", "string", ",", "requested", "int", ",", "wg", "*", "sync", ".", "WaitGroup", ",", "out", ",", "ew", "io", ".", "Writer", ")", "{", "if", "requested", "<", "0", "{", "fmt", ".", ...
// Scale creates or destroys units to match the desired number
[ "Scale", "creates", "or", "destroys", "units", "to", "match", "the", "desired", "number" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/scale.go#L13-L39
20,776
deis/deis
deisctl/backend/fleet/list_unit_files.go
ListUnitFiles
func (c *FleetClient) ListUnitFiles() (err error) { var sortable sort.StringSlice units := make(map[string]*schema.Unit, 0) us, err := c.Fleet.Units() if err != nil { return err } for _, u := range us { if strings.HasPrefix(u.Name, "deis-") { units[u.Name] = u sortable = append(sortable, u.Name) } ...
go
func (c *FleetClient) ListUnitFiles() (err error) { var sortable sort.StringSlice units := make(map[string]*schema.Unit, 0) us, err := c.Fleet.Units() if err != nil { return err } for _, u := range us { if strings.HasPrefix(u.Name, "deis-") { units[u.Name] = u sortable = append(sortable, u.Name) } ...
[ "func", "(", "c", "*", "FleetClient", ")", "ListUnitFiles", "(", ")", "(", "err", "error", ")", "{", "var", "sortable", "sort", ".", "StringSlice", "\n", "units", ":=", "make", "(", "map", "[", "string", "]", "*", "schema", ".", "Unit", ",", "0", "...
// ListUnitFiles prints all Deis-related unit files to Stdout
[ "ListUnitFiles", "prints", "all", "Deis", "-", "related", "unit", "files", "to", "Stdout" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/list_unit_files.go#L70-L88
20,777
deis/deis
deisctl/backend/fleet/list_unit_files.go
printUnitFiles
func (c *FleetClient) printUnitFiles(units map[string]*schema.Unit, sortable sort.StringSlice) { cols := strings.Split(defaultListUnitFilesFields, ",") fmt.Fprintln(c.out, strings.ToUpper(strings.Join(cols, "\t"))) for _, name := range sortable { var f []string u := units[name] for _, col := range cols { f ...
go
func (c *FleetClient) printUnitFiles(units map[string]*schema.Unit, sortable sort.StringSlice) { cols := strings.Split(defaultListUnitFilesFields, ",") fmt.Fprintln(c.out, strings.ToUpper(strings.Join(cols, "\t"))) for _, name := range sortable { var f []string u := units[name] for _, col := range cols { f ...
[ "func", "(", "c", "*", "FleetClient", ")", "printUnitFiles", "(", "units", "map", "[", "string", "]", "*", "schema", ".", "Unit", ",", "sortable", "sort", ".", "StringSlice", ")", "{", "cols", ":=", "strings", ".", "Split", "(", "defaultListUnitFilesFields...
// printUnitFiles writes unit files to stdout using a tabwriter
[ "printUnitFiles", "writes", "unit", "files", "to", "stdout", "using", "a", "tabwriter" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/list_unit_files.go#L91-L103
20,778
deis/deis
deisctl/backend/fleet/list_unit_files.go
suToGlobal
func suToGlobal(su schema.Unit) bool { u := job.Unit{ Unit: *schema.MapSchemaUnitOptionsToUnitFile(su.Options), } return u.IsGlobal() }
go
func suToGlobal(su schema.Unit) bool { u := job.Unit{ Unit: *schema.MapSchemaUnitOptionsToUnitFile(su.Options), } return u.IsGlobal() }
[ "func", "suToGlobal", "(", "su", "schema", ".", "Unit", ")", "bool", "{", "u", ":=", "job", ".", "Unit", "{", "Unit", ":", "*", "schema", ".", "MapSchemaUnitOptionsToUnitFile", "(", "su", ".", "Options", ")", ",", "}", "\n", "return", "u", ".", "IsGl...
// suToGlobal returns whether or not a schema.Unit refers to a global unit
[ "suToGlobal", "returns", "whether", "or", "not", "a", "schema", ".", "Unit", "refers", "to", "a", "global", "unit" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/list_unit_files.go#L106-L111
20,779
deis/deis
client/controller/models/releases/releases.go
Get
func Get(c *client.Client, appID string, version int) (api.Release, error) { u := fmt.Sprintf("/v1/apps/%s/releases/v%d/", appID, version) body, err := c.BasicRequest("GET", u, nil) if err != nil { return api.Release{}, err } release := api.Release{} if err = json.Unmarshal([]byte(body), &release); err != ni...
go
func Get(c *client.Client, appID string, version int) (api.Release, error) { u := fmt.Sprintf("/v1/apps/%s/releases/v%d/", appID, version) body, err := c.BasicRequest("GET", u, nil) if err != nil { return api.Release{}, err } release := api.Release{} if err = json.Unmarshal([]byte(body), &release); err != ni...
[ "func", "Get", "(", "c", "*", "client", ".", "Client", ",", "appID", "string", ",", "version", "int", ")", "(", "api", ".", "Release", ",", "error", ")", "{", "u", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "appID", ",", "version", ")", ...
// Get a release of an app.
[ "Get", "a", "release", "of", "an", "app", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/releases/releases.go#L30-L45
20,780
deis/deis
client/controller/models/releases/releases.go
Rollback
func Rollback(c *client.Client, appID string, version int) (int, error) { u := fmt.Sprintf("/v1/apps/%s/releases/rollback/", appID) req := api.ReleaseRollback{Version: version} var err error var reqBody []byte if version != -1 { reqBody, err = json.Marshal(req) if err != nil { return -1, err } } bod...
go
func Rollback(c *client.Client, appID string, version int) (int, error) { u := fmt.Sprintf("/v1/apps/%s/releases/rollback/", appID) req := api.ReleaseRollback{Version: version} var err error var reqBody []byte if version != -1 { reqBody, err = json.Marshal(req) if err != nil { return -1, err } } bod...
[ "func", "Rollback", "(", "c", "*", "client", ".", "Client", ",", "appID", "string", ",", "version", "int", ")", "(", "int", ",", "error", ")", "{", "u", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "appID", ")", "\n\n", "req", ":=", "api", ...
// Rollback rolls back an app to a previous release.
[ "Rollback", "rolls", "back", "an", "app", "to", "a", "previous", "release", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/releases/releases.go#L48-L76
20,781
deis/deis
deisctl/config/etcd/etcd.go
Get
func (cb *ConfigBackend) Get(key string) (string, error) { sort, recursive := true, false resp, err := cb.etcdlib.Get(key, sort, recursive) if err != nil { return "", err } return resp.Node.Value, nil }
go
func (cb *ConfigBackend) Get(key string) (string, error) { sort, recursive := true, false resp, err := cb.etcdlib.Get(key, sort, recursive) if err != nil { return "", err } return resp.Node.Value, nil }
[ "func", "(", "cb", "*", "ConfigBackend", ")", "Get", "(", "key", "string", ")", "(", "string", ",", "error", ")", "{", "sort", ",", "recursive", ":=", "true", ",", "false", "\n", "resp", ",", "err", ":=", "cb", ".", "etcdlib", ".", "Get", "(", "k...
// Get a value by key from etcd
[ "Get", "a", "value", "by", "key", "from", "etcd" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/config/etcd/etcd.go#L39-L46
20,782
deis/deis
deisctl/config/etcd/etcd.go
GetWithDefault
func (cb *ConfigBackend) GetWithDefault(key string, defaultValue string) (string, error) { sort, recursive := true, false resp, err := cb.etcdlib.Get(key, sort, recursive) if err != nil { etcdErr, ok := err.(*etcdlib.EtcdError) if ok && etcdErr.ErrorCode == 100 { return defaultValue, nil } return "", err ...
go
func (cb *ConfigBackend) GetWithDefault(key string, defaultValue string) (string, error) { sort, recursive := true, false resp, err := cb.etcdlib.Get(key, sort, recursive) if err != nil { etcdErr, ok := err.(*etcdlib.EtcdError) if ok && etcdErr.ErrorCode == 100 { return defaultValue, nil } return "", err ...
[ "func", "(", "cb", "*", "ConfigBackend", ")", "GetWithDefault", "(", "key", "string", ",", "defaultValue", "string", ")", "(", "string", ",", "error", ")", "{", "sort", ",", "recursive", ":=", "true", ",", "false", "\n", "resp", ",", "err", ":=", "cb",...
// GetWithDefault gets a value by key from etcd and return a default value if // not found
[ "GetWithDefault", "gets", "a", "value", "by", "key", "from", "etcd", "and", "return", "a", "default", "value", "if", "not", "found" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/config/etcd/etcd.go#L50-L61
20,783
deis/deis
deisctl/config/etcd/etcd.go
Set
func (cb *ConfigBackend) Set(key string, value string) (string, error) { resp, err := cb.etcdlib.Set(key, value, 0) // don't use TTLs if err != nil { return "", err } return resp.Node.Value, nil }
go
func (cb *ConfigBackend) Set(key string, value string) (string, error) { resp, err := cb.etcdlib.Set(key, value, 0) // don't use TTLs if err != nil { return "", err } return resp.Node.Value, nil }
[ "func", "(", "cb", "*", "ConfigBackend", ")", "Set", "(", "key", "string", ",", "value", "string", ")", "(", "string", ",", "error", ")", "{", "resp", ",", "err", ":=", "cb", ".", "etcdlib", ".", "Set", "(", "key", ",", "value", ",", "0", ")", ...
// Set a value for the specified key in etcd
[ "Set", "a", "value", "for", "the", "specified", "key", "in", "etcd" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/config/etcd/etcd.go#L112-L118
20,784
deis/deis
deisctl/config/etcd/etcd.go
NewConfigBackend
func NewConfigBackend() (*ConfigBackend, error) { var dial func(string, string) (net.Conn, error) sshTimeout := time.Duration(fleet.Flags.SSHTimeout*1000) * time.Millisecond tun := getTunnelFlag() if tun != "" { sshClient, err := ssh.NewSSHClient("core", tun, getChecker(), false, sshTimeout) if err != nil { ...
go
func NewConfigBackend() (*ConfigBackend, error) { var dial func(string, string) (net.Conn, error) sshTimeout := time.Duration(fleet.Flags.SSHTimeout*1000) * time.Millisecond tun := getTunnelFlag() if tun != "" { sshClient, err := ssh.NewSSHClient("core", tun, getChecker(), false, sshTimeout) if err != nil { ...
[ "func", "NewConfigBackend", "(", ")", "(", "*", "ConfigBackend", ",", "error", ")", "{", "var", "dial", "func", "(", "string", ",", "string", ")", "(", "net", ".", "Conn", ",", "error", ")", "\n", "sshTimeout", ":=", "time", ".", "Duration", "(", "fl...
// NewConfigBackend returns this etcd-based implementation of the config.Backend // interface
[ "NewConfigBackend", "returns", "this", "etcd", "-", "based", "implementation", "of", "the", "config", ".", "Backend", "interface" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/config/etcd/etcd.go#L131-L171
20,785
deis/deis
logger/drain/simple/drain.go
NewDrain
func NewDrain(drainURL string) (*logDrain, error) { u, err := url.Parse(drainURL) if err != nil { return nil, err } var proto string if u.Scheme == "udp" || u.Scheme == "syslog" { proto = "udp" } else if u.Scheme == "tcp" { proto = "tcp" } else { return nil, fmt.Errorf("Invalid drain url scheme: %s", u.S...
go
func NewDrain(drainURL string) (*logDrain, error) { u, err := url.Parse(drainURL) if err != nil { return nil, err } var proto string if u.Scheme == "udp" || u.Scheme == "syslog" { proto = "udp" } else if u.Scheme == "tcp" { proto = "tcp" } else { return nil, fmt.Errorf("Invalid drain url scheme: %s", u.S...
[ "func", "NewDrain", "(", "drainURL", "string", ")", "(", "*", "logDrain", ",", "error", ")", "{", "u", ",", "err", ":=", "url", ".", "Parse", "(", "drainURL", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n",...
// NewDrain returns a pointer to a new instance of a drain.LogDrain
[ "NewDrain", "returns", "a", "pointer", "to", "a", "new", "instance", "of", "a", "drain", ".", "LogDrain" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/drain/simple/drain.go#L45-L59
20,786
deis/deis
logger/drain/simple/drain.go
Send
func (d *logDrain) Send(message string) error { if d.muted { return nil } d.mutex.Lock() defer d.mutex.Unlock() conn, err := d.getConnection(false) if err != nil { return err } _, err = fmt.Fprintln(conn, message) if err != nil { // Try again with a new connection in case the issue was a broken pipe co...
go
func (d *logDrain) Send(message string) error { if d.muted { return nil } d.mutex.Lock() defer d.mutex.Unlock() conn, err := d.getConnection(false) if err != nil { return err } _, err = fmt.Fprintln(conn, message) if err != nil { // Try again with a new connection in case the issue was a broken pipe co...
[ "func", "(", "d", "*", "logDrain", ")", "Send", "(", "message", "string", ")", "error", "{", "if", "d", ".", "muted", "{", "return", "nil", "\n", "}", "\n", "d", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "d", ".", "mutex", ".", "Unloc...
// Send forwards the provided log message to an external destination
[ "Send", "forwards", "the", "provided", "log", "message", "to", "an", "external", "destination" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/drain/simple/drain.go#L62-L85
20,787
deis/deis
logger/drain/simple/drain.go
getConnection
func (d *logDrain) getConnection(forceNew bool) (net.Conn, error) { // If we have a connection, it's not old, and we're not focing a new one... if d.conn != nil && !forceNew { // then return the existing connection return d.conn, nil } // If ANY of those conditions weren't met, it's time for a new connection. ...
go
func (d *logDrain) getConnection(forceNew bool) (net.Conn, error) { // If we have a connection, it's not old, and we're not focing a new one... if d.conn != nil && !forceNew { // then return the existing connection return d.conn, nil } // If ANY of those conditions weren't met, it's time for a new connection. ...
[ "func", "(", "d", "*", "logDrain", ")", "getConnection", "(", "forceNew", "bool", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "// If we have a connection, it's not old, and we're not focing a new one...", "if", "d", ".", "conn", "!=", "nil", "&&", "!",...
// getConnection returns a usable connection, often without needing to redial, but still // redialing when advised.
[ "getConnection", "returns", "a", "usable", "connection", "often", "without", "needing", "to", "redial", "but", "still", "redialing", "when", "advised", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/drain/simple/drain.go#L89-L132
20,788
deis/deis
client/cmd/releases.go
ReleasesList
func ReleasesList(appID string, results int) error { c, appID, err := load(appID) if err != nil { return err } if results == defaultLimit { results = c.ResponseLimit } releases, count, err := releases.List(c, appID, results) fmt.Printf("=== %s Releases%s", appID, limitCount(len(releases), count)) w := ...
go
func ReleasesList(appID string, results int) error { c, appID, err := load(appID) if err != nil { return err } if results == defaultLimit { results = c.ResponseLimit } releases, count, err := releases.List(c, appID, results) fmt.Printf("=== %s Releases%s", appID, limitCount(len(releases), count)) w := ...
[ "func", "ReleasesList", "(", "appID", "string", ",", "results", "int", ")", "error", "{", "c", ",", "appID", ",", "err", ":=", "load", "(", "appID", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "results", "=...
// ReleasesList lists an app's releases.
[ "ReleasesList", "lists", "an", "app", "s", "releases", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/releases.go#L12-L35
20,789
deis/deis
client/cmd/releases.go
ReleasesInfo
func ReleasesInfo(appID string, version int) error { c, appID, err := load(appID) if err != nil { return err } r, err := releases.Get(c, appID, version) if err != nil { return err } fmt.Printf("=== %s Release v%d\n", appID, version) if r.Build != "" { fmt.Println("build: ", r.Build) } fmt.Println(...
go
func ReleasesInfo(appID string, version int) error { c, appID, err := load(appID) if err != nil { return err } r, err := releases.Get(c, appID, version) if err != nil { return err } fmt.Printf("=== %s Release v%d\n", appID, version) if r.Build != "" { fmt.Println("build: ", r.Build) } fmt.Println(...
[ "func", "ReleasesInfo", "(", "appID", "string", ",", "version", "int", ")", "error", "{", "c", ",", "appID", ",", "err", ":=", "load", "(", "appID", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "r", ",", "err", ...
// ReleasesInfo prints info about a specific release.
[ "ReleasesInfo", "prints", "info", "about", "a", "specific", "release", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/releases.go#L38-L63
20,790
deis/deis
client/cmd/releases.go
ReleasesRollback
func ReleasesRollback(appID string, version int) error { c, appID, err := load(appID) if err != nil { return err } if version == -1 { fmt.Print("Rolling back one release... ") } else { fmt.Printf("Rolling back to v%d... ", version) } quit := progress() newVersion, err := releases.Rollback(c, appID, ver...
go
func ReleasesRollback(appID string, version int) error { c, appID, err := load(appID) if err != nil { return err } if version == -1 { fmt.Print("Rolling back one release... ") } else { fmt.Printf("Rolling back to v%d... ", version) } quit := progress() newVersion, err := releases.Rollback(c, appID, ver...
[ "func", "ReleasesRollback", "(", "appID", "string", ",", "version", "int", ")", "error", "{", "c", ",", "appID", ",", "err", ":=", "load", "(", "appID", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "version", ...
// ReleasesRollback rolls an app back to a previous release.
[ "ReleasesRollback", "rolls", "an", "app", "back", "to", "a", "previous", "release", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/releases.go#L66-L91
20,791
deis/deis
Godeps/_workspace/src/google.golang.org/api/googleapi/googleapi.go
IsNotModified
func IsNotModified(err error) bool { if err == nil { return false } ae, ok := err.(*Error) return ok && ae.Code == http.StatusNotModified }
go
func IsNotModified(err error) bool { if err == nil { return false } ae, ok := err.(*Error) return ok && ae.Code == http.StatusNotModified }
[ "func", "IsNotModified", "(", "err", "error", ")", "bool", "{", "if", "err", "==", "nil", "{", "return", "false", "\n", "}", "\n", "ae", ",", "ok", ":=", "err", ".", "(", "*", "Error", ")", "\n", "return", "ok", "&&", "ae", ".", "Code", "==", "...
// IsNotModified reports whether err is the result of the // server replying with http.StatusNotModified. // Such error values are sometimes returned by "Do" methods // on calls when If-None-Match is used.
[ "IsNotModified", "reports", "whether", "err", "is", "the", "result", "of", "the", "server", "replying", "with", "http", ".", "StatusNotModified", ".", "Such", "error", "values", "are", "sometimes", "returned", "by", "Do", "methods", "on", "calls", "when", "If"...
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/Godeps/_workspace/src/google.golang.org/api/googleapi/googleapi.go#L141-L147
20,792
deis/deis
Godeps/_workspace/src/google.golang.org/api/googleapi/googleapi.go
ProcessMediaOptions
func ProcessMediaOptions(opts []MediaOption) *MediaOptions { mo := &MediaOptions{ChunkSize: DefaultUploadChunkSize} for _, o := range opts { o.setOptions(mo) } return mo }
go
func ProcessMediaOptions(opts []MediaOption) *MediaOptions { mo := &MediaOptions{ChunkSize: DefaultUploadChunkSize} for _, o := range opts { o.setOptions(mo) } return mo }
[ "func", "ProcessMediaOptions", "(", "opts", "[", "]", "MediaOption", ")", "*", "MediaOptions", "{", "mo", ":=", "&", "MediaOptions", "{", "ChunkSize", ":", "DefaultUploadChunkSize", "}", "\n", "for", "_", ",", "o", ":=", "range", "opts", "{", "o", ".", "...
// ProcessMediaOptions stores options from opts in a MediaOptions. // It is not used by developers directly.
[ "ProcessMediaOptions", "stores", "options", "from", "opts", "in", "a", "MediaOptions", ".", "It", "is", "not", "used", "by", "developers", "directly", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/Godeps/_workspace/src/google.golang.org/api/googleapi/googleapi.go#L257-L263
20,793
deis/deis
Godeps/_workspace/src/google.golang.org/api/googleapi/googleapi.go
SetOpaque
func SetOpaque(u *url.URL) { u.Opaque = "//" + u.Host + u.Path if !has4860Fix { u.Opaque = u.Scheme + ":" + u.Opaque } }
go
func SetOpaque(u *url.URL) { u.Opaque = "//" + u.Host + u.Path if !has4860Fix { u.Opaque = u.Scheme + ":" + u.Opaque } }
[ "func", "SetOpaque", "(", "u", "*", "url", ".", "URL", ")", "{", "u", ".", "Opaque", "=", "\"", "\"", "+", "u", ".", "Host", "+", "u", ".", "Path", "\n", "if", "!", "has4860Fix", "{", "u", ".", "Opaque", "=", "u", ".", "Scheme", "+", "\"", ...
// SetOpaque sets u.Opaque from u.Path such that HTTP requests to it // don't alter any hex-escaped characters in u.Path.
[ "SetOpaque", "sets", "u", ".", "Opaque", "from", "u", ".", "Path", "such", "that", "HTTP", "requests", "to", "it", "don", "t", "alter", "any", "hex", "-", "escaped", "characters", "in", "u", ".", "Path", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/Godeps/_workspace/src/google.golang.org/api/googleapi/googleapi.go#L294-L299
20,794
deis/deis
Godeps/_workspace/src/google.golang.org/api/googleapi/googleapi.go
CloseBody
func CloseBody(res *http.Response) { if res == nil || res.Body == nil { return } // Justification for 3 byte reads: two for up to "\r\n" after // a JSON/XML document, and then 1 to see EOF if we haven't yet. // TODO(bradfitz): detect Go 1.3+ and skip these reads. // See https://codereview.appspot.com/58240043 ...
go
func CloseBody(res *http.Response) { if res == nil || res.Body == nil { return } // Justification for 3 byte reads: two for up to "\r\n" after // a JSON/XML document, and then 1 to see EOF if we haven't yet. // TODO(bradfitz): detect Go 1.3+ and skip these reads. // See https://codereview.appspot.com/58240043 ...
[ "func", "CloseBody", "(", "res", "*", "http", ".", "Response", ")", "{", "if", "res", "==", "nil", "||", "res", ".", "Body", "==", "nil", "{", "return", "\n", "}", "\n", "// Justification for 3 byte reads: two for up to \"\\r\\n\" after", "// a JSON/XML document, ...
// CloseBody is used to close res.Body. // Prior to calling Close, it also tries to Read a small amount to see an EOF. // Not seeing an EOF can prevent HTTP Transports from reusing connections.
[ "CloseBody", "is", "used", "to", "close", "res", ".", "Body", ".", "Prior", "to", "calling", "Close", "it", "also", "tries", "to", "Read", "a", "small", "amount", "to", "see", "an", "EOF", ".", "Not", "seeing", "an", "EOF", "can", "prevent", "HTTP", ...
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/Godeps/_workspace/src/google.golang.org/api/googleapi/googleapi.go#L316-L334
20,795
deis/deis
Godeps/_workspace/src/google.golang.org/api/googleapi/googleapi.go
CombineFields
func CombineFields(s []Field) string { r := make([]string, len(s)) for i, v := range s { r[i] = string(v) } return strings.Join(r, ",") }
go
func CombineFields(s []Field) string { r := make([]string, len(s)) for i, v := range s { r[i] = string(v) } return strings.Join(r, ",") }
[ "func", "CombineFields", "(", "s", "[", "]", "Field", ")", "string", "{", "r", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "s", ")", ")", "\n", "for", "i", ",", "v", ":=", "range", "s", "{", "r", "[", "i", "]", "=", "string", "(...
// CombineFields combines fields into a single string.
[ "CombineFields", "combines", "fields", "into", "a", "single", "string", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/Godeps/_workspace/src/google.golang.org/api/googleapi/googleapi.go#L382-L388
20,796
deis/deis
client/cmd/auth.go
Register
func Register(controller string, username string, password string, email string, sslVerify bool) error { u, err := url.Parse(controller) httpClient := client.CreateHTTPClient(sslVerify) if err != nil { return err } controllerURL, err := chooseScheme(*u) if err != nil { return err } if err = client.Che...
go
func Register(controller string, username string, password string, email string, sslVerify bool) error { u, err := url.Parse(controller) httpClient := client.CreateHTTPClient(sslVerify) if err != nil { return err } controllerURL, err := chooseScheme(*u) if err != nil { return err } if err = client.Che...
[ "func", "Register", "(", "controller", "string", ",", "username", "string", ",", "password", "string", ",", "email", "string", ",", "sslVerify", "bool", ")", "error", "{", "u", ",", "err", ":=", "url", ".", "Parse", "(", "controller", ")", "\n", "httpCli...
// Register creates a account on a Deis controller.
[ "Register", "creates", "a", "account", "on", "a", "Deis", "controller", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/auth.go#L18-L83
20,797
deis/deis
client/cmd/auth.go
Login
func Login(controller string, username string, password string, sslVerify bool) error { u, err := url.Parse(controller) if err != nil { return err } controllerURL, err := chooseScheme(*u) httpClient := client.CreateHTTPClient(sslVerify) if err != nil { return err } if err = client.CheckConnection(httpCl...
go
func Login(controller string, username string, password string, sslVerify bool) error { u, err := url.Parse(controller) if err != nil { return err } controllerURL, err := chooseScheme(*u) httpClient := client.CreateHTTPClient(sslVerify) if err != nil { return err } if err = client.CheckConnection(httpCl...
[ "func", "Login", "(", "controller", "string", ",", "username", "string", ",", "password", "string", ",", "sslVerify", "bool", ")", "error", "{", "u", ",", "err", ":=", "url", ".", "Parse", "(", "controller", ")", "\n\n", "if", "err", "!=", "nil", "{", ...
// Login to a Deis controller.
[ "Login", "to", "a", "Deis", "controller", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/auth.go#L106-L142
20,798
deis/deis
client/cmd/auth.go
Logout
func Logout() error { if err := client.Delete(); err != nil { return err } fmt.Println("Logged out") return nil }
go
func Logout() error { if err := client.Delete(); err != nil { return err } fmt.Println("Logged out") return nil }
[ "func", "Logout", "(", ")", "error", "{", "if", "err", ":=", "client", ".", "Delete", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n", "return", "nil", "\n", "}" ]
// Logout from a Deis controller.
[ "Logout", "from", "a", "Deis", "controller", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/auth.go#L145-L152
20,799
deis/deis
client/cmd/auth.go
Cancel
func Cancel(username string, password string, yes bool) error { c, err := client.New() if err != nil { return err } if username == "" || password != "" { fmt.Println("Please log in again in order to cancel this account") if err = Login(c.ControllerURL.String(), username, password, c.SSLVerify); err != nil ...
go
func Cancel(username string, password string, yes bool) error { c, err := client.New() if err != nil { return err } if username == "" || password != "" { fmt.Println("Please log in again in order to cancel this account") if err = Login(c.ControllerURL.String(), username, password, c.SSLVerify); err != nil ...
[ "func", "Cancel", "(", "username", "string", ",", "password", "string", ",", "yes", "bool", ")", "error", "{", "c", ",", "err", ":=", "client", ".", "New", "(", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", ...
// Cancel deletes a user's account.
[ "Cancel", "deletes", "a", "user", "s", "account", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/auth.go#L201-L263