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
sequence
docstring
stringlengths
6
2.61k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go
yaml_emitter_emit_flow_mapping_key
func yaml_emitter_emit_flow_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { if first { if !yaml_emitter_write_indicator(emitter, []byte{'{'}, true, true, false) { return false } if !yaml_emitter_increase_indent(emitter, true, false) { return false } emitter.flow_level++ } if event.typ == yaml_MAPPING_END_EVENT { emitter.flow_level-- emitter.indent = emitter.indents[len(emitter.indents)-1] emitter.indents = emitter.indents[:len(emitter.indents)-1] if emitter.canonical && !first { if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { return false } if !yaml_emitter_write_indent(emitter) { return false } } if !yaml_emitter_write_indicator(emitter, []byte{'}'}, false, false, false) { return false } emitter.state = emitter.states[len(emitter.states)-1] emitter.states = emitter.states[:len(emitter.states)-1] return true } if !first { if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { return false } } if emitter.canonical || emitter.column > emitter.best_width { if !yaml_emitter_write_indent(emitter) { return false } } if !emitter.canonical && yaml_emitter_check_simple_key(emitter) { emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE) return yaml_emitter_emit_node(emitter, event, false, false, true, true) } if !yaml_emitter_write_indicator(emitter, []byte{'?'}, true, false, false) { return false } emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_VALUE_STATE) return yaml_emitter_emit_node(emitter, event, false, false, true, false) }
go
func yaml_emitter_emit_flow_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { if first { if !yaml_emitter_write_indicator(emitter, []byte{'{'}, true, true, false) { return false } if !yaml_emitter_increase_indent(emitter, true, false) { return false } emitter.flow_level++ } if event.typ == yaml_MAPPING_END_EVENT { emitter.flow_level-- emitter.indent = emitter.indents[len(emitter.indents)-1] emitter.indents = emitter.indents[:len(emitter.indents)-1] if emitter.canonical && !first { if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { return false } if !yaml_emitter_write_indent(emitter) { return false } } if !yaml_emitter_write_indicator(emitter, []byte{'}'}, false, false, false) { return false } emitter.state = emitter.states[len(emitter.states)-1] emitter.states = emitter.states[:len(emitter.states)-1] return true } if !first { if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { return false } } if emitter.canonical || emitter.column > emitter.best_width { if !yaml_emitter_write_indent(emitter) { return false } } if !emitter.canonical && yaml_emitter_check_simple_key(emitter) { emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE) return yaml_emitter_emit_node(emitter, event, false, false, true, true) } if !yaml_emitter_write_indicator(emitter, []byte{'?'}, true, false, false) { return false } emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_VALUE_STATE) return yaml_emitter_emit_node(emitter, event, false, false, true, false) }
[ "func", "yaml_emitter_emit_flow_mapping_key", "(", "emitter", "*", "yaml_emitter_t", ",", "event", "*", "yaml_event_t", ",", "first", "bool", ")", "bool", "{", "if", "first", "{", "if", "!", "yaml_emitter_write_indicator", "(", "emitter", ",", "[", "]", "byte", "{", "'{'", "}", ",", "true", ",", "true", ",", "false", ")", "{", "return", "false", "\n", "}", "\n", "if", "!", "yaml_emitter_increase_indent", "(", "emitter", ",", "true", ",", "false", ")", "{", "return", "false", "\n", "}", "\n", "emitter", ".", "flow_level", "++", "\n", "}", "\n\n", "if", "event", ".", "typ", "==", "yaml_MAPPING_END_EVENT", "{", "emitter", ".", "flow_level", "--", "\n", "emitter", ".", "indent", "=", "emitter", ".", "indents", "[", "len", "(", "emitter", ".", "indents", ")", "-", "1", "]", "\n", "emitter", ".", "indents", "=", "emitter", ".", "indents", "[", ":", "len", "(", "emitter", ".", "indents", ")", "-", "1", "]", "\n", "if", "emitter", ".", "canonical", "&&", "!", "first", "{", "if", "!", "yaml_emitter_write_indicator", "(", "emitter", ",", "[", "]", "byte", "{", "','", "}", ",", "false", ",", "false", ",", "false", ")", "{", "return", "false", "\n", "}", "\n", "if", "!", "yaml_emitter_write_indent", "(", "emitter", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "if", "!", "yaml_emitter_write_indicator", "(", "emitter", ",", "[", "]", "byte", "{", "'}'", "}", ",", "false", ",", "false", ",", "false", ")", "{", "return", "false", "\n", "}", "\n", "emitter", ".", "state", "=", "emitter", ".", "states", "[", "len", "(", "emitter", ".", "states", ")", "-", "1", "]", "\n", "emitter", ".", "states", "=", "emitter", ".", "states", "[", ":", "len", "(", "emitter", ".", "states", ")", "-", "1", "]", "\n", "return", "true", "\n", "}", "\n\n", "if", "!", "first", "{", "if", "!", "yaml_emitter_write_indicator", "(", "emitter", ",", "[", "]", "byte", "{", "','", "}", ",", "false", ",", "false", ",", "false", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "if", "emitter", ".", "canonical", "||", "emitter", ".", "column", ">", "emitter", ".", "best_width", "{", "if", "!", "yaml_emitter_write_indent", "(", "emitter", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n\n", "if", "!", "emitter", ".", "canonical", "&&", "yaml_emitter_check_simple_key", "(", "emitter", ")", "{", "emitter", ".", "states", "=", "append", "(", "emitter", ".", "states", ",", "yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE", ")", "\n", "return", "yaml_emitter_emit_node", "(", "emitter", ",", "event", ",", "false", ",", "false", ",", "true", ",", "true", ")", "\n", "}", "\n", "if", "!", "yaml_emitter_write_indicator", "(", "emitter", ",", "[", "]", "byte", "{", "'?'", "}", ",", "true", ",", "false", ",", "false", ")", "{", "return", "false", "\n", "}", "\n", "emitter", ".", "states", "=", "append", "(", "emitter", ".", "states", ",", "yaml_EMIT_FLOW_MAPPING_VALUE_STATE", ")", "\n", "return", "yaml_emitter_emit_node", "(", "emitter", ",", "event", ",", "false", ",", "false", ",", "true", ",", "false", ")", "\n", "}" ]
// Expect a flow key node.
[ "Expect", "a", "flow", "key", "node", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L504-L555
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go
yaml_emitter_emit_flow_mapping_value
func yaml_emitter_emit_flow_mapping_value(emitter *yaml_emitter_t, event *yaml_event_t, simple bool) bool { if simple { if !yaml_emitter_write_indicator(emitter, []byte{':'}, false, false, false) { return false } } else { if emitter.canonical || emitter.column > emitter.best_width { if !yaml_emitter_write_indent(emitter) { return false } } if !yaml_emitter_write_indicator(emitter, []byte{':'}, true, false, false) { return false } } emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_KEY_STATE) return yaml_emitter_emit_node(emitter, event, false, false, true, false) }
go
func yaml_emitter_emit_flow_mapping_value(emitter *yaml_emitter_t, event *yaml_event_t, simple bool) bool { if simple { if !yaml_emitter_write_indicator(emitter, []byte{':'}, false, false, false) { return false } } else { if emitter.canonical || emitter.column > emitter.best_width { if !yaml_emitter_write_indent(emitter) { return false } } if !yaml_emitter_write_indicator(emitter, []byte{':'}, true, false, false) { return false } } emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_KEY_STATE) return yaml_emitter_emit_node(emitter, event, false, false, true, false) }
[ "func", "yaml_emitter_emit_flow_mapping_value", "(", "emitter", "*", "yaml_emitter_t", ",", "event", "*", "yaml_event_t", ",", "simple", "bool", ")", "bool", "{", "if", "simple", "{", "if", "!", "yaml_emitter_write_indicator", "(", "emitter", ",", "[", "]", "byte", "{", "':'", "}", ",", "false", ",", "false", ",", "false", ")", "{", "return", "false", "\n", "}", "\n", "}", "else", "{", "if", "emitter", ".", "canonical", "||", "emitter", ".", "column", ">", "emitter", ".", "best_width", "{", "if", "!", "yaml_emitter_write_indent", "(", "emitter", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "if", "!", "yaml_emitter_write_indicator", "(", "emitter", ",", "[", "]", "byte", "{", "':'", "}", ",", "true", ",", "false", ",", "false", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "emitter", ".", "states", "=", "append", "(", "emitter", ".", "states", ",", "yaml_EMIT_FLOW_MAPPING_KEY_STATE", ")", "\n", "return", "yaml_emitter_emit_node", "(", "emitter", ",", "event", ",", "false", ",", "false", ",", "true", ",", "false", ")", "\n", "}" ]
// Expect a flow value node.
[ "Expect", "a", "flow", "value", "node", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L558-L575
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go
yaml_emitter_emit_block_sequence_item
func yaml_emitter_emit_block_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { if first { if !yaml_emitter_increase_indent(emitter, false, emitter.mapping_context && !emitter.indention) { return false } } if event.typ == yaml_SEQUENCE_END_EVENT { emitter.indent = emitter.indents[len(emitter.indents)-1] emitter.indents = emitter.indents[:len(emitter.indents)-1] emitter.state = emitter.states[len(emitter.states)-1] emitter.states = emitter.states[:len(emitter.states)-1] return true } if !yaml_emitter_write_indent(emitter) { return false } if !yaml_emitter_write_indicator(emitter, []byte{'-'}, true, false, true) { return false } emitter.states = append(emitter.states, yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE) return yaml_emitter_emit_node(emitter, event, false, true, false, false) }
go
func yaml_emitter_emit_block_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { if first { if !yaml_emitter_increase_indent(emitter, false, emitter.mapping_context && !emitter.indention) { return false } } if event.typ == yaml_SEQUENCE_END_EVENT { emitter.indent = emitter.indents[len(emitter.indents)-1] emitter.indents = emitter.indents[:len(emitter.indents)-1] emitter.state = emitter.states[len(emitter.states)-1] emitter.states = emitter.states[:len(emitter.states)-1] return true } if !yaml_emitter_write_indent(emitter) { return false } if !yaml_emitter_write_indicator(emitter, []byte{'-'}, true, false, true) { return false } emitter.states = append(emitter.states, yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE) return yaml_emitter_emit_node(emitter, event, false, true, false, false) }
[ "func", "yaml_emitter_emit_block_sequence_item", "(", "emitter", "*", "yaml_emitter_t", ",", "event", "*", "yaml_event_t", ",", "first", "bool", ")", "bool", "{", "if", "first", "{", "if", "!", "yaml_emitter_increase_indent", "(", "emitter", ",", "false", ",", "emitter", ".", "mapping_context", "&&", "!", "emitter", ".", "indention", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "if", "event", ".", "typ", "==", "yaml_SEQUENCE_END_EVENT", "{", "emitter", ".", "indent", "=", "emitter", ".", "indents", "[", "len", "(", "emitter", ".", "indents", ")", "-", "1", "]", "\n", "emitter", ".", "indents", "=", "emitter", ".", "indents", "[", ":", "len", "(", "emitter", ".", "indents", ")", "-", "1", "]", "\n", "emitter", ".", "state", "=", "emitter", ".", "states", "[", "len", "(", "emitter", ".", "states", ")", "-", "1", "]", "\n", "emitter", ".", "states", "=", "emitter", ".", "states", "[", ":", "len", "(", "emitter", ".", "states", ")", "-", "1", "]", "\n", "return", "true", "\n", "}", "\n", "if", "!", "yaml_emitter_write_indent", "(", "emitter", ")", "{", "return", "false", "\n", "}", "\n", "if", "!", "yaml_emitter_write_indicator", "(", "emitter", ",", "[", "]", "byte", "{", "'-'", "}", ",", "true", ",", "false", ",", "true", ")", "{", "return", "false", "\n", "}", "\n", "emitter", ".", "states", "=", "append", "(", "emitter", ".", "states", ",", "yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE", ")", "\n", "return", "yaml_emitter_emit_node", "(", "emitter", ",", "event", ",", "false", ",", "true", ",", "false", ",", "false", ")", "\n", "}" ]
// Expect a block item node.
[ "Expect", "a", "block", "item", "node", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L578-L599
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go
yaml_emitter_emit_block_mapping_key
func yaml_emitter_emit_block_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { if first { if !yaml_emitter_increase_indent(emitter, false, false) { return false } } if event.typ == yaml_MAPPING_END_EVENT { emitter.indent = emitter.indents[len(emitter.indents)-1] emitter.indents = emitter.indents[:len(emitter.indents)-1] emitter.state = emitter.states[len(emitter.states)-1] emitter.states = emitter.states[:len(emitter.states)-1] return true } if !yaml_emitter_write_indent(emitter) { return false } if yaml_emitter_check_simple_key(emitter) { emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE) return yaml_emitter_emit_node(emitter, event, false, false, true, true) } if !yaml_emitter_write_indicator(emitter, []byte{'?'}, true, false, true) { return false } emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_VALUE_STATE) return yaml_emitter_emit_node(emitter, event, false, false, true, false) }
go
func yaml_emitter_emit_block_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { if first { if !yaml_emitter_increase_indent(emitter, false, false) { return false } } if event.typ == yaml_MAPPING_END_EVENT { emitter.indent = emitter.indents[len(emitter.indents)-1] emitter.indents = emitter.indents[:len(emitter.indents)-1] emitter.state = emitter.states[len(emitter.states)-1] emitter.states = emitter.states[:len(emitter.states)-1] return true } if !yaml_emitter_write_indent(emitter) { return false } if yaml_emitter_check_simple_key(emitter) { emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE) return yaml_emitter_emit_node(emitter, event, false, false, true, true) } if !yaml_emitter_write_indicator(emitter, []byte{'?'}, true, false, true) { return false } emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_VALUE_STATE) return yaml_emitter_emit_node(emitter, event, false, false, true, false) }
[ "func", "yaml_emitter_emit_block_mapping_key", "(", "emitter", "*", "yaml_emitter_t", ",", "event", "*", "yaml_event_t", ",", "first", "bool", ")", "bool", "{", "if", "first", "{", "if", "!", "yaml_emitter_increase_indent", "(", "emitter", ",", "false", ",", "false", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "if", "event", ".", "typ", "==", "yaml_MAPPING_END_EVENT", "{", "emitter", ".", "indent", "=", "emitter", ".", "indents", "[", "len", "(", "emitter", ".", "indents", ")", "-", "1", "]", "\n", "emitter", ".", "indents", "=", "emitter", ".", "indents", "[", ":", "len", "(", "emitter", ".", "indents", ")", "-", "1", "]", "\n", "emitter", ".", "state", "=", "emitter", ".", "states", "[", "len", "(", "emitter", ".", "states", ")", "-", "1", "]", "\n", "emitter", ".", "states", "=", "emitter", ".", "states", "[", ":", "len", "(", "emitter", ".", "states", ")", "-", "1", "]", "\n", "return", "true", "\n", "}", "\n", "if", "!", "yaml_emitter_write_indent", "(", "emitter", ")", "{", "return", "false", "\n", "}", "\n", "if", "yaml_emitter_check_simple_key", "(", "emitter", ")", "{", "emitter", ".", "states", "=", "append", "(", "emitter", ".", "states", ",", "yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE", ")", "\n", "return", "yaml_emitter_emit_node", "(", "emitter", ",", "event", ",", "false", ",", "false", ",", "true", ",", "true", ")", "\n", "}", "\n", "if", "!", "yaml_emitter_write_indicator", "(", "emitter", ",", "[", "]", "byte", "{", "'?'", "}", ",", "true", ",", "false", ",", "true", ")", "{", "return", "false", "\n", "}", "\n", "emitter", ".", "states", "=", "append", "(", "emitter", ".", "states", ",", "yaml_EMIT_BLOCK_MAPPING_VALUE_STATE", ")", "\n", "return", "yaml_emitter_emit_node", "(", "emitter", ",", "event", ",", "false", ",", "false", ",", "true", ",", "false", ")", "\n", "}" ]
// Expect a block key node.
[ "Expect", "a", "block", "key", "node", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L602-L627
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go
yaml_emitter_emit_block_mapping_value
func yaml_emitter_emit_block_mapping_value(emitter *yaml_emitter_t, event *yaml_event_t, simple bool) bool { if simple { if !yaml_emitter_write_indicator(emitter, []byte{':'}, false, false, false) { return false } } else { if !yaml_emitter_write_indent(emitter) { return false } if !yaml_emitter_write_indicator(emitter, []byte{':'}, true, false, true) { return false } } emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_KEY_STATE) return yaml_emitter_emit_node(emitter, event, false, false, true, false) }
go
func yaml_emitter_emit_block_mapping_value(emitter *yaml_emitter_t, event *yaml_event_t, simple bool) bool { if simple { if !yaml_emitter_write_indicator(emitter, []byte{':'}, false, false, false) { return false } } else { if !yaml_emitter_write_indent(emitter) { return false } if !yaml_emitter_write_indicator(emitter, []byte{':'}, true, false, true) { return false } } emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_KEY_STATE) return yaml_emitter_emit_node(emitter, event, false, false, true, false) }
[ "func", "yaml_emitter_emit_block_mapping_value", "(", "emitter", "*", "yaml_emitter_t", ",", "event", "*", "yaml_event_t", ",", "simple", "bool", ")", "bool", "{", "if", "simple", "{", "if", "!", "yaml_emitter_write_indicator", "(", "emitter", ",", "[", "]", "byte", "{", "':'", "}", ",", "false", ",", "false", ",", "false", ")", "{", "return", "false", "\n", "}", "\n", "}", "else", "{", "if", "!", "yaml_emitter_write_indent", "(", "emitter", ")", "{", "return", "false", "\n", "}", "\n", "if", "!", "yaml_emitter_write_indicator", "(", "emitter", ",", "[", "]", "byte", "{", "':'", "}", ",", "true", ",", "false", ",", "true", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "emitter", ".", "states", "=", "append", "(", "emitter", ".", "states", ",", "yaml_EMIT_BLOCK_MAPPING_KEY_STATE", ")", "\n", "return", "yaml_emitter_emit_node", "(", "emitter", ",", "event", ",", "false", ",", "false", ",", "true", ",", "false", ")", "\n", "}" ]
// Expect a block value node.
[ "Expect", "a", "block", "value", "node", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L630-L645
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go
yaml_emitter_emit_alias
func yaml_emitter_emit_alias(emitter *yaml_emitter_t, event *yaml_event_t) bool { if !yaml_emitter_process_anchor(emitter) { return false } emitter.state = emitter.states[len(emitter.states)-1] emitter.states = emitter.states[:len(emitter.states)-1] return true }
go
func yaml_emitter_emit_alias(emitter *yaml_emitter_t, event *yaml_event_t) bool { if !yaml_emitter_process_anchor(emitter) { return false } emitter.state = emitter.states[len(emitter.states)-1] emitter.states = emitter.states[:len(emitter.states)-1] return true }
[ "func", "yaml_emitter_emit_alias", "(", "emitter", "*", "yaml_emitter_t", ",", "event", "*", "yaml_event_t", ")", "bool", "{", "if", "!", "yaml_emitter_process_anchor", "(", "emitter", ")", "{", "return", "false", "\n", "}", "\n", "emitter", ".", "state", "=", "emitter", ".", "states", "[", "len", "(", "emitter", ".", "states", ")", "-", "1", "]", "\n", "emitter", ".", "states", "=", "emitter", ".", "states", "[", ":", "len", "(", "emitter", ".", "states", ")", "-", "1", "]", "\n", "return", "true", "\n", "}" ]
// Expect ALIAS.
[ "Expect", "ALIAS", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L673-L680
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go
yaml_emitter_emit_scalar
func yaml_emitter_emit_scalar(emitter *yaml_emitter_t, event *yaml_event_t) bool { if !yaml_emitter_select_scalar_style(emitter, event) { return false } if !yaml_emitter_process_anchor(emitter) { return false } if !yaml_emitter_process_tag(emitter) { return false } if !yaml_emitter_increase_indent(emitter, true, false) { return false } if !yaml_emitter_process_scalar(emitter) { return false } emitter.indent = emitter.indents[len(emitter.indents)-1] emitter.indents = emitter.indents[:len(emitter.indents)-1] emitter.state = emitter.states[len(emitter.states)-1] emitter.states = emitter.states[:len(emitter.states)-1] return true }
go
func yaml_emitter_emit_scalar(emitter *yaml_emitter_t, event *yaml_event_t) bool { if !yaml_emitter_select_scalar_style(emitter, event) { return false } if !yaml_emitter_process_anchor(emitter) { return false } if !yaml_emitter_process_tag(emitter) { return false } if !yaml_emitter_increase_indent(emitter, true, false) { return false } if !yaml_emitter_process_scalar(emitter) { return false } emitter.indent = emitter.indents[len(emitter.indents)-1] emitter.indents = emitter.indents[:len(emitter.indents)-1] emitter.state = emitter.states[len(emitter.states)-1] emitter.states = emitter.states[:len(emitter.states)-1] return true }
[ "func", "yaml_emitter_emit_scalar", "(", "emitter", "*", "yaml_emitter_t", ",", "event", "*", "yaml_event_t", ")", "bool", "{", "if", "!", "yaml_emitter_select_scalar_style", "(", "emitter", ",", "event", ")", "{", "return", "false", "\n", "}", "\n", "if", "!", "yaml_emitter_process_anchor", "(", "emitter", ")", "{", "return", "false", "\n", "}", "\n", "if", "!", "yaml_emitter_process_tag", "(", "emitter", ")", "{", "return", "false", "\n", "}", "\n", "if", "!", "yaml_emitter_increase_indent", "(", "emitter", ",", "true", ",", "false", ")", "{", "return", "false", "\n", "}", "\n", "if", "!", "yaml_emitter_process_scalar", "(", "emitter", ")", "{", "return", "false", "\n", "}", "\n", "emitter", ".", "indent", "=", "emitter", ".", "indents", "[", "len", "(", "emitter", ".", "indents", ")", "-", "1", "]", "\n", "emitter", ".", "indents", "=", "emitter", ".", "indents", "[", ":", "len", "(", "emitter", ".", "indents", ")", "-", "1", "]", "\n", "emitter", ".", "state", "=", "emitter", ".", "states", "[", "len", "(", "emitter", ".", "states", ")", "-", "1", "]", "\n", "emitter", ".", "states", "=", "emitter", ".", "states", "[", ":", "len", "(", "emitter", ".", "states", ")", "-", "1", "]", "\n", "return", "true", "\n", "}" ]
// Expect SCALAR.
[ "Expect", "SCALAR", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L683-L704
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go
yaml_emitter_emit_sequence_start
func yaml_emitter_emit_sequence_start(emitter *yaml_emitter_t, event *yaml_event_t) bool { if !yaml_emitter_process_anchor(emitter) { return false } if !yaml_emitter_process_tag(emitter) { return false } if emitter.flow_level > 0 || emitter.canonical || event.sequence_style() == yaml_FLOW_SEQUENCE_STYLE || yaml_emitter_check_empty_sequence(emitter) { emitter.state = yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE } else { emitter.state = yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE } return true }
go
func yaml_emitter_emit_sequence_start(emitter *yaml_emitter_t, event *yaml_event_t) bool { if !yaml_emitter_process_anchor(emitter) { return false } if !yaml_emitter_process_tag(emitter) { return false } if emitter.flow_level > 0 || emitter.canonical || event.sequence_style() == yaml_FLOW_SEQUENCE_STYLE || yaml_emitter_check_empty_sequence(emitter) { emitter.state = yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE } else { emitter.state = yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE } return true }
[ "func", "yaml_emitter_emit_sequence_start", "(", "emitter", "*", "yaml_emitter_t", ",", "event", "*", "yaml_event_t", ")", "bool", "{", "if", "!", "yaml_emitter_process_anchor", "(", "emitter", ")", "{", "return", "false", "\n", "}", "\n", "if", "!", "yaml_emitter_process_tag", "(", "emitter", ")", "{", "return", "false", "\n", "}", "\n", "if", "emitter", ".", "flow_level", ">", "0", "||", "emitter", ".", "canonical", "||", "event", ".", "sequence_style", "(", ")", "==", "yaml_FLOW_SEQUENCE_STYLE", "||", "yaml_emitter_check_empty_sequence", "(", "emitter", ")", "{", "emitter", ".", "state", "=", "yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE", "\n", "}", "else", "{", "emitter", ".", "state", "=", "yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Expect SEQUENCE-START.
[ "Expect", "SEQUENCE", "-", "START", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L707-L721
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go
yaml_emitter_emit_mapping_start
func yaml_emitter_emit_mapping_start(emitter *yaml_emitter_t, event *yaml_event_t) bool { if !yaml_emitter_process_anchor(emitter) { return false } if !yaml_emitter_process_tag(emitter) { return false } if emitter.flow_level > 0 || emitter.canonical || event.mapping_style() == yaml_FLOW_MAPPING_STYLE || yaml_emitter_check_empty_mapping(emitter) { emitter.state = yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE } else { emitter.state = yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE } return true }
go
func yaml_emitter_emit_mapping_start(emitter *yaml_emitter_t, event *yaml_event_t) bool { if !yaml_emitter_process_anchor(emitter) { return false } if !yaml_emitter_process_tag(emitter) { return false } if emitter.flow_level > 0 || emitter.canonical || event.mapping_style() == yaml_FLOW_MAPPING_STYLE || yaml_emitter_check_empty_mapping(emitter) { emitter.state = yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE } else { emitter.state = yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE } return true }
[ "func", "yaml_emitter_emit_mapping_start", "(", "emitter", "*", "yaml_emitter_t", ",", "event", "*", "yaml_event_t", ")", "bool", "{", "if", "!", "yaml_emitter_process_anchor", "(", "emitter", ")", "{", "return", "false", "\n", "}", "\n", "if", "!", "yaml_emitter_process_tag", "(", "emitter", ")", "{", "return", "false", "\n", "}", "\n", "if", "emitter", ".", "flow_level", ">", "0", "||", "emitter", ".", "canonical", "||", "event", ".", "mapping_style", "(", ")", "==", "yaml_FLOW_MAPPING_STYLE", "||", "yaml_emitter_check_empty_mapping", "(", "emitter", ")", "{", "emitter", ".", "state", "=", "yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE", "\n", "}", "else", "{", "emitter", ".", "state", "=", "yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Expect MAPPING-START.
[ "Expect", "MAPPING", "-", "START", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L724-L738
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go
yaml_emitter_check_empty_sequence
func yaml_emitter_check_empty_sequence(emitter *yaml_emitter_t) bool { if len(emitter.events)-emitter.events_head < 2 { return false } return emitter.events[emitter.events_head].typ == yaml_SEQUENCE_START_EVENT && emitter.events[emitter.events_head+1].typ == yaml_SEQUENCE_END_EVENT }
go
func yaml_emitter_check_empty_sequence(emitter *yaml_emitter_t) bool { if len(emitter.events)-emitter.events_head < 2 { return false } return emitter.events[emitter.events_head].typ == yaml_SEQUENCE_START_EVENT && emitter.events[emitter.events_head+1].typ == yaml_SEQUENCE_END_EVENT }
[ "func", "yaml_emitter_check_empty_sequence", "(", "emitter", "*", "yaml_emitter_t", ")", "bool", "{", "if", "len", "(", "emitter", ".", "events", ")", "-", "emitter", ".", "events_head", "<", "2", "{", "return", "false", "\n", "}", "\n", "return", "emitter", ".", "events", "[", "emitter", ".", "events_head", "]", ".", "typ", "==", "yaml_SEQUENCE_START_EVENT", "&&", "emitter", ".", "events", "[", "emitter", ".", "events_head", "+", "1", "]", ".", "typ", "==", "yaml_SEQUENCE_END_EVENT", "\n", "}" ]
// Check if the next events represent an empty sequence.
[ "Check", "if", "the", "next", "events", "represent", "an", "empty", "sequence", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L746-L752
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go
yaml_emitter_check_empty_mapping
func yaml_emitter_check_empty_mapping(emitter *yaml_emitter_t) bool { if len(emitter.events)-emitter.events_head < 2 { return false } return emitter.events[emitter.events_head].typ == yaml_MAPPING_START_EVENT && emitter.events[emitter.events_head+1].typ == yaml_MAPPING_END_EVENT }
go
func yaml_emitter_check_empty_mapping(emitter *yaml_emitter_t) bool { if len(emitter.events)-emitter.events_head < 2 { return false } return emitter.events[emitter.events_head].typ == yaml_MAPPING_START_EVENT && emitter.events[emitter.events_head+1].typ == yaml_MAPPING_END_EVENT }
[ "func", "yaml_emitter_check_empty_mapping", "(", "emitter", "*", "yaml_emitter_t", ")", "bool", "{", "if", "len", "(", "emitter", ".", "events", ")", "-", "emitter", ".", "events_head", "<", "2", "{", "return", "false", "\n", "}", "\n", "return", "emitter", ".", "events", "[", "emitter", ".", "events_head", "]", ".", "typ", "==", "yaml_MAPPING_START_EVENT", "&&", "emitter", ".", "events", "[", "emitter", ".", "events_head", "+", "1", "]", ".", "typ", "==", "yaml_MAPPING_END_EVENT", "\n", "}" ]
// Check if the next events represent an empty mapping.
[ "Check", "if", "the", "next", "events", "represent", "an", "empty", "mapping", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L755-L761
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go
yaml_emitter_check_simple_key
func yaml_emitter_check_simple_key(emitter *yaml_emitter_t) bool { length := 0 switch emitter.events[emitter.events_head].typ { case yaml_ALIAS_EVENT: length += len(emitter.anchor_data.anchor) case yaml_SCALAR_EVENT: if emitter.scalar_data.multiline { return false } length += len(emitter.anchor_data.anchor) + len(emitter.tag_data.handle) + len(emitter.tag_data.suffix) + len(emitter.scalar_data.value) case yaml_SEQUENCE_START_EVENT: if !yaml_emitter_check_empty_sequence(emitter) { return false } length += len(emitter.anchor_data.anchor) + len(emitter.tag_data.handle) + len(emitter.tag_data.suffix) case yaml_MAPPING_START_EVENT: if !yaml_emitter_check_empty_mapping(emitter) { return false } length += len(emitter.anchor_data.anchor) + len(emitter.tag_data.handle) + len(emitter.tag_data.suffix) default: return false } return length <= 128 }
go
func yaml_emitter_check_simple_key(emitter *yaml_emitter_t) bool { length := 0 switch emitter.events[emitter.events_head].typ { case yaml_ALIAS_EVENT: length += len(emitter.anchor_data.anchor) case yaml_SCALAR_EVENT: if emitter.scalar_data.multiline { return false } length += len(emitter.anchor_data.anchor) + len(emitter.tag_data.handle) + len(emitter.tag_data.suffix) + len(emitter.scalar_data.value) case yaml_SEQUENCE_START_EVENT: if !yaml_emitter_check_empty_sequence(emitter) { return false } length += len(emitter.anchor_data.anchor) + len(emitter.tag_data.handle) + len(emitter.tag_data.suffix) case yaml_MAPPING_START_EVENT: if !yaml_emitter_check_empty_mapping(emitter) { return false } length += len(emitter.anchor_data.anchor) + len(emitter.tag_data.handle) + len(emitter.tag_data.suffix) default: return false } return length <= 128 }
[ "func", "yaml_emitter_check_simple_key", "(", "emitter", "*", "yaml_emitter_t", ")", "bool", "{", "length", ":=", "0", "\n", "switch", "emitter", ".", "events", "[", "emitter", ".", "events_head", "]", ".", "typ", "{", "case", "yaml_ALIAS_EVENT", ":", "length", "+=", "len", "(", "emitter", ".", "anchor_data", ".", "anchor", ")", "\n", "case", "yaml_SCALAR_EVENT", ":", "if", "emitter", ".", "scalar_data", ".", "multiline", "{", "return", "false", "\n", "}", "\n", "length", "+=", "len", "(", "emitter", ".", "anchor_data", ".", "anchor", ")", "+", "len", "(", "emitter", ".", "tag_data", ".", "handle", ")", "+", "len", "(", "emitter", ".", "tag_data", ".", "suffix", ")", "+", "len", "(", "emitter", ".", "scalar_data", ".", "value", ")", "\n", "case", "yaml_SEQUENCE_START_EVENT", ":", "if", "!", "yaml_emitter_check_empty_sequence", "(", "emitter", ")", "{", "return", "false", "\n", "}", "\n", "length", "+=", "len", "(", "emitter", ".", "anchor_data", ".", "anchor", ")", "+", "len", "(", "emitter", ".", "tag_data", ".", "handle", ")", "+", "len", "(", "emitter", ".", "tag_data", ".", "suffix", ")", "\n", "case", "yaml_MAPPING_START_EVENT", ":", "if", "!", "yaml_emitter_check_empty_mapping", "(", "emitter", ")", "{", "return", "false", "\n", "}", "\n", "length", "+=", "len", "(", "emitter", ".", "anchor_data", ".", "anchor", ")", "+", "len", "(", "emitter", ".", "tag_data", ".", "handle", ")", "+", "len", "(", "emitter", ".", "tag_data", ".", "suffix", ")", "\n", "default", ":", "return", "false", "\n", "}", "\n", "return", "length", "<=", "128", "\n", "}" ]
// Check if the next node can be expressed as a simple key.
[ "Check", "if", "the", "next", "node", "can", "be", "expressed", "as", "a", "simple", "key", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L764-L795
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go
yaml_emitter_select_scalar_style
func yaml_emitter_select_scalar_style(emitter *yaml_emitter_t, event *yaml_event_t) bool { no_tag := len(emitter.tag_data.handle) == 0 && len(emitter.tag_data.suffix) == 0 if no_tag && !event.implicit && !event.quoted_implicit { return yaml_emitter_set_emitter_error(emitter, "neither tag nor implicit flags are specified") } style := event.scalar_style() if style == yaml_ANY_SCALAR_STYLE { style = yaml_PLAIN_SCALAR_STYLE } if emitter.canonical { style = yaml_DOUBLE_QUOTED_SCALAR_STYLE } if emitter.simple_key_context && emitter.scalar_data.multiline { style = yaml_DOUBLE_QUOTED_SCALAR_STYLE } if style == yaml_PLAIN_SCALAR_STYLE { if emitter.flow_level > 0 && !emitter.scalar_data.flow_plain_allowed || emitter.flow_level == 0 && !emitter.scalar_data.block_plain_allowed { style = yaml_SINGLE_QUOTED_SCALAR_STYLE } if len(emitter.scalar_data.value) == 0 && (emitter.flow_level > 0 || emitter.simple_key_context) { style = yaml_SINGLE_QUOTED_SCALAR_STYLE } if no_tag && !event.implicit { style = yaml_SINGLE_QUOTED_SCALAR_STYLE } } if style == yaml_SINGLE_QUOTED_SCALAR_STYLE { if !emitter.scalar_data.single_quoted_allowed { style = yaml_DOUBLE_QUOTED_SCALAR_STYLE } } if style == yaml_LITERAL_SCALAR_STYLE || style == yaml_FOLDED_SCALAR_STYLE { if !emitter.scalar_data.block_allowed || emitter.flow_level > 0 || emitter.simple_key_context { style = yaml_DOUBLE_QUOTED_SCALAR_STYLE } } if no_tag && !event.quoted_implicit && style != yaml_PLAIN_SCALAR_STYLE { emitter.tag_data.handle = []byte{'!'} } emitter.scalar_data.style = style return true }
go
func yaml_emitter_select_scalar_style(emitter *yaml_emitter_t, event *yaml_event_t) bool { no_tag := len(emitter.tag_data.handle) == 0 && len(emitter.tag_data.suffix) == 0 if no_tag && !event.implicit && !event.quoted_implicit { return yaml_emitter_set_emitter_error(emitter, "neither tag nor implicit flags are specified") } style := event.scalar_style() if style == yaml_ANY_SCALAR_STYLE { style = yaml_PLAIN_SCALAR_STYLE } if emitter.canonical { style = yaml_DOUBLE_QUOTED_SCALAR_STYLE } if emitter.simple_key_context && emitter.scalar_data.multiline { style = yaml_DOUBLE_QUOTED_SCALAR_STYLE } if style == yaml_PLAIN_SCALAR_STYLE { if emitter.flow_level > 0 && !emitter.scalar_data.flow_plain_allowed || emitter.flow_level == 0 && !emitter.scalar_data.block_plain_allowed { style = yaml_SINGLE_QUOTED_SCALAR_STYLE } if len(emitter.scalar_data.value) == 0 && (emitter.flow_level > 0 || emitter.simple_key_context) { style = yaml_SINGLE_QUOTED_SCALAR_STYLE } if no_tag && !event.implicit { style = yaml_SINGLE_QUOTED_SCALAR_STYLE } } if style == yaml_SINGLE_QUOTED_SCALAR_STYLE { if !emitter.scalar_data.single_quoted_allowed { style = yaml_DOUBLE_QUOTED_SCALAR_STYLE } } if style == yaml_LITERAL_SCALAR_STYLE || style == yaml_FOLDED_SCALAR_STYLE { if !emitter.scalar_data.block_allowed || emitter.flow_level > 0 || emitter.simple_key_context { style = yaml_DOUBLE_QUOTED_SCALAR_STYLE } } if no_tag && !event.quoted_implicit && style != yaml_PLAIN_SCALAR_STYLE { emitter.tag_data.handle = []byte{'!'} } emitter.scalar_data.style = style return true }
[ "func", "yaml_emitter_select_scalar_style", "(", "emitter", "*", "yaml_emitter_t", ",", "event", "*", "yaml_event_t", ")", "bool", "{", "no_tag", ":=", "len", "(", "emitter", ".", "tag_data", ".", "handle", ")", "==", "0", "&&", "len", "(", "emitter", ".", "tag_data", ".", "suffix", ")", "==", "0", "\n", "if", "no_tag", "&&", "!", "event", ".", "implicit", "&&", "!", "event", ".", "quoted_implicit", "{", "return", "yaml_emitter_set_emitter_error", "(", "emitter", ",", "\"", "\"", ")", "\n", "}", "\n\n", "style", ":=", "event", ".", "scalar_style", "(", ")", "\n", "if", "style", "==", "yaml_ANY_SCALAR_STYLE", "{", "style", "=", "yaml_PLAIN_SCALAR_STYLE", "\n", "}", "\n", "if", "emitter", ".", "canonical", "{", "style", "=", "yaml_DOUBLE_QUOTED_SCALAR_STYLE", "\n", "}", "\n", "if", "emitter", ".", "simple_key_context", "&&", "emitter", ".", "scalar_data", ".", "multiline", "{", "style", "=", "yaml_DOUBLE_QUOTED_SCALAR_STYLE", "\n", "}", "\n\n", "if", "style", "==", "yaml_PLAIN_SCALAR_STYLE", "{", "if", "emitter", ".", "flow_level", ">", "0", "&&", "!", "emitter", ".", "scalar_data", ".", "flow_plain_allowed", "||", "emitter", ".", "flow_level", "==", "0", "&&", "!", "emitter", ".", "scalar_data", ".", "block_plain_allowed", "{", "style", "=", "yaml_SINGLE_QUOTED_SCALAR_STYLE", "\n", "}", "\n", "if", "len", "(", "emitter", ".", "scalar_data", ".", "value", ")", "==", "0", "&&", "(", "emitter", ".", "flow_level", ">", "0", "||", "emitter", ".", "simple_key_context", ")", "{", "style", "=", "yaml_SINGLE_QUOTED_SCALAR_STYLE", "\n", "}", "\n", "if", "no_tag", "&&", "!", "event", ".", "implicit", "{", "style", "=", "yaml_SINGLE_QUOTED_SCALAR_STYLE", "\n", "}", "\n", "}", "\n", "if", "style", "==", "yaml_SINGLE_QUOTED_SCALAR_STYLE", "{", "if", "!", "emitter", ".", "scalar_data", ".", "single_quoted_allowed", "{", "style", "=", "yaml_DOUBLE_QUOTED_SCALAR_STYLE", "\n", "}", "\n", "}", "\n", "if", "style", "==", "yaml_LITERAL_SCALAR_STYLE", "||", "style", "==", "yaml_FOLDED_SCALAR_STYLE", "{", "if", "!", "emitter", ".", "scalar_data", ".", "block_allowed", "||", "emitter", ".", "flow_level", ">", "0", "||", "emitter", ".", "simple_key_context", "{", "style", "=", "yaml_DOUBLE_QUOTED_SCALAR_STYLE", "\n", "}", "\n", "}", "\n\n", "if", "no_tag", "&&", "!", "event", ".", "quoted_implicit", "&&", "style", "!=", "yaml_PLAIN_SCALAR_STYLE", "{", "emitter", ".", "tag_data", ".", "handle", "=", "[", "]", "byte", "{", "'!'", "}", "\n", "}", "\n", "emitter", ".", "scalar_data", ".", "style", "=", "style", "\n", "return", "true", "\n", "}" ]
// Determine an acceptable scalar style.
[ "Determine", "an", "acceptable", "scalar", "style", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L798-L844
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go
yaml_emitter_process_anchor
func yaml_emitter_process_anchor(emitter *yaml_emitter_t) bool { if emitter.anchor_data.anchor == nil { return true } c := []byte{'&'} if emitter.anchor_data.alias { c[0] = '*' } if !yaml_emitter_write_indicator(emitter, c, true, false, false) { return false } return yaml_emitter_write_anchor(emitter, emitter.anchor_data.anchor) }
go
func yaml_emitter_process_anchor(emitter *yaml_emitter_t) bool { if emitter.anchor_data.anchor == nil { return true } c := []byte{'&'} if emitter.anchor_data.alias { c[0] = '*' } if !yaml_emitter_write_indicator(emitter, c, true, false, false) { return false } return yaml_emitter_write_anchor(emitter, emitter.anchor_data.anchor) }
[ "func", "yaml_emitter_process_anchor", "(", "emitter", "*", "yaml_emitter_t", ")", "bool", "{", "if", "emitter", ".", "anchor_data", ".", "anchor", "==", "nil", "{", "return", "true", "\n", "}", "\n", "c", ":=", "[", "]", "byte", "{", "'&'", "}", "\n", "if", "emitter", ".", "anchor_data", ".", "alias", "{", "c", "[", "0", "]", "=", "'*'", "\n", "}", "\n", "if", "!", "yaml_emitter_write_indicator", "(", "emitter", ",", "c", ",", "true", ",", "false", ",", "false", ")", "{", "return", "false", "\n", "}", "\n", "return", "yaml_emitter_write_anchor", "(", "emitter", ",", "emitter", ".", "anchor_data", ".", "anchor", ")", "\n", "}" ]
// Write an achor.
[ "Write", "an", "achor", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L847-L859
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go
yaml_emitter_process_tag
func yaml_emitter_process_tag(emitter *yaml_emitter_t) bool { if len(emitter.tag_data.handle) == 0 && len(emitter.tag_data.suffix) == 0 { return true } if len(emitter.tag_data.handle) > 0 { if !yaml_emitter_write_tag_handle(emitter, emitter.tag_data.handle) { return false } if len(emitter.tag_data.suffix) > 0 { if !yaml_emitter_write_tag_content(emitter, emitter.tag_data.suffix, false) { return false } } } else { // [Go] Allocate these slices elsewhere. if !yaml_emitter_write_indicator(emitter, []byte("!<"), true, false, false) { return false } if !yaml_emitter_write_tag_content(emitter, emitter.tag_data.suffix, false) { return false } if !yaml_emitter_write_indicator(emitter, []byte{'>'}, false, false, false) { return false } } return true }
go
func yaml_emitter_process_tag(emitter *yaml_emitter_t) bool { if len(emitter.tag_data.handle) == 0 && len(emitter.tag_data.suffix) == 0 { return true } if len(emitter.tag_data.handle) > 0 { if !yaml_emitter_write_tag_handle(emitter, emitter.tag_data.handle) { return false } if len(emitter.tag_data.suffix) > 0 { if !yaml_emitter_write_tag_content(emitter, emitter.tag_data.suffix, false) { return false } } } else { // [Go] Allocate these slices elsewhere. if !yaml_emitter_write_indicator(emitter, []byte("!<"), true, false, false) { return false } if !yaml_emitter_write_tag_content(emitter, emitter.tag_data.suffix, false) { return false } if !yaml_emitter_write_indicator(emitter, []byte{'>'}, false, false, false) { return false } } return true }
[ "func", "yaml_emitter_process_tag", "(", "emitter", "*", "yaml_emitter_t", ")", "bool", "{", "if", "len", "(", "emitter", ".", "tag_data", ".", "handle", ")", "==", "0", "&&", "len", "(", "emitter", ".", "tag_data", ".", "suffix", ")", "==", "0", "{", "return", "true", "\n", "}", "\n", "if", "len", "(", "emitter", ".", "tag_data", ".", "handle", ")", ">", "0", "{", "if", "!", "yaml_emitter_write_tag_handle", "(", "emitter", ",", "emitter", ".", "tag_data", ".", "handle", ")", "{", "return", "false", "\n", "}", "\n", "if", "len", "(", "emitter", ".", "tag_data", ".", "suffix", ")", ">", "0", "{", "if", "!", "yaml_emitter_write_tag_content", "(", "emitter", ",", "emitter", ".", "tag_data", ".", "suffix", ",", "false", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "}", "else", "{", "// [Go] Allocate these slices elsewhere.", "if", "!", "yaml_emitter_write_indicator", "(", "emitter", ",", "[", "]", "byte", "(", "\"", "\"", ")", ",", "true", ",", "false", ",", "false", ")", "{", "return", "false", "\n", "}", "\n", "if", "!", "yaml_emitter_write_tag_content", "(", "emitter", ",", "emitter", ".", "tag_data", ".", "suffix", ",", "false", ")", "{", "return", "false", "\n", "}", "\n", "if", "!", "yaml_emitter_write_indicator", "(", "emitter", ",", "[", "]", "byte", "{", "'>'", "}", ",", "false", ",", "false", ",", "false", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Write a tag.
[ "Write", "a", "tag", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L862-L888
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go
yaml_emitter_process_scalar
func yaml_emitter_process_scalar(emitter *yaml_emitter_t) bool { switch emitter.scalar_data.style { case yaml_PLAIN_SCALAR_STYLE: return yaml_emitter_write_plain_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context) case yaml_SINGLE_QUOTED_SCALAR_STYLE: return yaml_emitter_write_single_quoted_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context) case yaml_DOUBLE_QUOTED_SCALAR_STYLE: return yaml_emitter_write_double_quoted_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context) case yaml_LITERAL_SCALAR_STYLE: return yaml_emitter_write_literal_scalar(emitter, emitter.scalar_data.value) case yaml_FOLDED_SCALAR_STYLE: return yaml_emitter_write_folded_scalar(emitter, emitter.scalar_data.value) } panic("unknown scalar style") }
go
func yaml_emitter_process_scalar(emitter *yaml_emitter_t) bool { switch emitter.scalar_data.style { case yaml_PLAIN_SCALAR_STYLE: return yaml_emitter_write_plain_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context) case yaml_SINGLE_QUOTED_SCALAR_STYLE: return yaml_emitter_write_single_quoted_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context) case yaml_DOUBLE_QUOTED_SCALAR_STYLE: return yaml_emitter_write_double_quoted_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context) case yaml_LITERAL_SCALAR_STYLE: return yaml_emitter_write_literal_scalar(emitter, emitter.scalar_data.value) case yaml_FOLDED_SCALAR_STYLE: return yaml_emitter_write_folded_scalar(emitter, emitter.scalar_data.value) } panic("unknown scalar style") }
[ "func", "yaml_emitter_process_scalar", "(", "emitter", "*", "yaml_emitter_t", ")", "bool", "{", "switch", "emitter", ".", "scalar_data", ".", "style", "{", "case", "yaml_PLAIN_SCALAR_STYLE", ":", "return", "yaml_emitter_write_plain_scalar", "(", "emitter", ",", "emitter", ".", "scalar_data", ".", "value", ",", "!", "emitter", ".", "simple_key_context", ")", "\n\n", "case", "yaml_SINGLE_QUOTED_SCALAR_STYLE", ":", "return", "yaml_emitter_write_single_quoted_scalar", "(", "emitter", ",", "emitter", ".", "scalar_data", ".", "value", ",", "!", "emitter", ".", "simple_key_context", ")", "\n\n", "case", "yaml_DOUBLE_QUOTED_SCALAR_STYLE", ":", "return", "yaml_emitter_write_double_quoted_scalar", "(", "emitter", ",", "emitter", ".", "scalar_data", ".", "value", ",", "!", "emitter", ".", "simple_key_context", ")", "\n\n", "case", "yaml_LITERAL_SCALAR_STYLE", ":", "return", "yaml_emitter_write_literal_scalar", "(", "emitter", ",", "emitter", ".", "scalar_data", ".", "value", ")", "\n\n", "case", "yaml_FOLDED_SCALAR_STYLE", ":", "return", "yaml_emitter_write_folded_scalar", "(", "emitter", ",", "emitter", ".", "scalar_data", ".", "value", ")", "\n", "}", "\n", "panic", "(", "\"", "\"", ")", "\n", "}" ]
// Write a scalar.
[ "Write", "a", "scalar", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L891-L909
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go
yaml_emitter_analyze_version_directive
func yaml_emitter_analyze_version_directive(emitter *yaml_emitter_t, version_directive *yaml_version_directive_t) bool { if version_directive.major != 1 || version_directive.minor != 1 { return yaml_emitter_set_emitter_error(emitter, "incompatible %YAML directive") } return true }
go
func yaml_emitter_analyze_version_directive(emitter *yaml_emitter_t, version_directive *yaml_version_directive_t) bool { if version_directive.major != 1 || version_directive.minor != 1 { return yaml_emitter_set_emitter_error(emitter, "incompatible %YAML directive") } return true }
[ "func", "yaml_emitter_analyze_version_directive", "(", "emitter", "*", "yaml_emitter_t", ",", "version_directive", "*", "yaml_version_directive_t", ")", "bool", "{", "if", "version_directive", ".", "major", "!=", "1", "||", "version_directive", ".", "minor", "!=", "1", "{", "return", "yaml_emitter_set_emitter_error", "(", "emitter", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Check if a %YAML directive is valid.
[ "Check", "if", "a", "%YAML", "directive", "is", "valid", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L912-L917
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go
yaml_emitter_analyze_tag_directive
func yaml_emitter_analyze_tag_directive(emitter *yaml_emitter_t, tag_directive *yaml_tag_directive_t) bool { handle := tag_directive.handle prefix := tag_directive.prefix if len(handle) == 0 { return yaml_emitter_set_emitter_error(emitter, "tag handle must not be empty") } if handle[0] != '!' { return yaml_emitter_set_emitter_error(emitter, "tag handle must start with '!'") } if handle[len(handle)-1] != '!' { return yaml_emitter_set_emitter_error(emitter, "tag handle must end with '!'") } for i := 1; i < len(handle)-1; i += width(handle[i]) { if !is_alpha(handle, i) { return yaml_emitter_set_emitter_error(emitter, "tag handle must contain alphanumerical characters only") } } if len(prefix) == 0 { return yaml_emitter_set_emitter_error(emitter, "tag prefix must not be empty") } return true }
go
func yaml_emitter_analyze_tag_directive(emitter *yaml_emitter_t, tag_directive *yaml_tag_directive_t) bool { handle := tag_directive.handle prefix := tag_directive.prefix if len(handle) == 0 { return yaml_emitter_set_emitter_error(emitter, "tag handle must not be empty") } if handle[0] != '!' { return yaml_emitter_set_emitter_error(emitter, "tag handle must start with '!'") } if handle[len(handle)-1] != '!' { return yaml_emitter_set_emitter_error(emitter, "tag handle must end with '!'") } for i := 1; i < len(handle)-1; i += width(handle[i]) { if !is_alpha(handle, i) { return yaml_emitter_set_emitter_error(emitter, "tag handle must contain alphanumerical characters only") } } if len(prefix) == 0 { return yaml_emitter_set_emitter_error(emitter, "tag prefix must not be empty") } return true }
[ "func", "yaml_emitter_analyze_tag_directive", "(", "emitter", "*", "yaml_emitter_t", ",", "tag_directive", "*", "yaml_tag_directive_t", ")", "bool", "{", "handle", ":=", "tag_directive", ".", "handle", "\n", "prefix", ":=", "tag_directive", ".", "prefix", "\n", "if", "len", "(", "handle", ")", "==", "0", "{", "return", "yaml_emitter_set_emitter_error", "(", "emitter", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "handle", "[", "0", "]", "!=", "'!'", "{", "return", "yaml_emitter_set_emitter_error", "(", "emitter", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "handle", "[", "len", "(", "handle", ")", "-", "1", "]", "!=", "'!'", "{", "return", "yaml_emitter_set_emitter_error", "(", "emitter", ",", "\"", "\"", ")", "\n", "}", "\n", "for", "i", ":=", "1", ";", "i", "<", "len", "(", "handle", ")", "-", "1", ";", "i", "+=", "width", "(", "handle", "[", "i", "]", ")", "{", "if", "!", "is_alpha", "(", "handle", ",", "i", ")", "{", "return", "yaml_emitter_set_emitter_error", "(", "emitter", ",", "\"", "\"", ")", "\n", "}", "\n", "}", "\n", "if", "len", "(", "prefix", ")", "==", "0", "{", "return", "yaml_emitter_set_emitter_error", "(", "emitter", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Check if a %TAG directive is valid.
[ "Check", "if", "a", "%TAG", "directive", "is", "valid", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L920-L941
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go
yaml_emitter_analyze_anchor
func yaml_emitter_analyze_anchor(emitter *yaml_emitter_t, anchor []byte, alias bool) bool { if len(anchor) == 0 { problem := "anchor value must not be empty" if alias { problem = "alias value must not be empty" } return yaml_emitter_set_emitter_error(emitter, problem) } for i := 0; i < len(anchor); i += width(anchor[i]) { if !is_alpha(anchor, i) { problem := "anchor value must contain alphanumerical characters only" if alias { problem = "alias value must contain alphanumerical characters only" } return yaml_emitter_set_emitter_error(emitter, problem) } } emitter.anchor_data.anchor = anchor emitter.anchor_data.alias = alias return true }
go
func yaml_emitter_analyze_anchor(emitter *yaml_emitter_t, anchor []byte, alias bool) bool { if len(anchor) == 0 { problem := "anchor value must not be empty" if alias { problem = "alias value must not be empty" } return yaml_emitter_set_emitter_error(emitter, problem) } for i := 0; i < len(anchor); i += width(anchor[i]) { if !is_alpha(anchor, i) { problem := "anchor value must contain alphanumerical characters only" if alias { problem = "alias value must contain alphanumerical characters only" } return yaml_emitter_set_emitter_error(emitter, problem) } } emitter.anchor_data.anchor = anchor emitter.anchor_data.alias = alias return true }
[ "func", "yaml_emitter_analyze_anchor", "(", "emitter", "*", "yaml_emitter_t", ",", "anchor", "[", "]", "byte", ",", "alias", "bool", ")", "bool", "{", "if", "len", "(", "anchor", ")", "==", "0", "{", "problem", ":=", "\"", "\"", "\n", "if", "alias", "{", "problem", "=", "\"", "\"", "\n", "}", "\n", "return", "yaml_emitter_set_emitter_error", "(", "emitter", ",", "problem", ")", "\n", "}", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "anchor", ")", ";", "i", "+=", "width", "(", "anchor", "[", "i", "]", ")", "{", "if", "!", "is_alpha", "(", "anchor", ",", "i", ")", "{", "problem", ":=", "\"", "\"", "\n", "if", "alias", "{", "problem", "=", "\"", "\"", "\n", "}", "\n", "return", "yaml_emitter_set_emitter_error", "(", "emitter", ",", "problem", ")", "\n", "}", "\n", "}", "\n", "emitter", ".", "anchor_data", ".", "anchor", "=", "anchor", "\n", "emitter", ".", "anchor_data", ".", "alias", "=", "alias", "\n", "return", "true", "\n", "}" ]
// Check if an anchor is valid.
[ "Check", "if", "an", "anchor", "is", "valid", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L944-L964
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go
yaml_emitter_analyze_event
func yaml_emitter_analyze_event(emitter *yaml_emitter_t, event *yaml_event_t) bool { emitter.anchor_data.anchor = nil emitter.tag_data.handle = nil emitter.tag_data.suffix = nil emitter.scalar_data.value = nil switch event.typ { case yaml_ALIAS_EVENT: if !yaml_emitter_analyze_anchor(emitter, event.anchor, true) { return false } case yaml_SCALAR_EVENT: if len(event.anchor) > 0 { if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) { return false } } if len(event.tag) > 0 && (emitter.canonical || (!event.implicit && !event.quoted_implicit)) { if !yaml_emitter_analyze_tag(emitter, event.tag) { return false } } if !yaml_emitter_analyze_scalar(emitter, event.value) { return false } case yaml_SEQUENCE_START_EVENT: if len(event.anchor) > 0 { if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) { return false } } if len(event.tag) > 0 && (emitter.canonical || !event.implicit) { if !yaml_emitter_analyze_tag(emitter, event.tag) { return false } } case yaml_MAPPING_START_EVENT: if len(event.anchor) > 0 { if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) { return false } } if len(event.tag) > 0 && (emitter.canonical || !event.implicit) { if !yaml_emitter_analyze_tag(emitter, event.tag) { return false } } } return true }
go
func yaml_emitter_analyze_event(emitter *yaml_emitter_t, event *yaml_event_t) bool { emitter.anchor_data.anchor = nil emitter.tag_data.handle = nil emitter.tag_data.suffix = nil emitter.scalar_data.value = nil switch event.typ { case yaml_ALIAS_EVENT: if !yaml_emitter_analyze_anchor(emitter, event.anchor, true) { return false } case yaml_SCALAR_EVENT: if len(event.anchor) > 0 { if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) { return false } } if len(event.tag) > 0 && (emitter.canonical || (!event.implicit && !event.quoted_implicit)) { if !yaml_emitter_analyze_tag(emitter, event.tag) { return false } } if !yaml_emitter_analyze_scalar(emitter, event.value) { return false } case yaml_SEQUENCE_START_EVENT: if len(event.anchor) > 0 { if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) { return false } } if len(event.tag) > 0 && (emitter.canonical || !event.implicit) { if !yaml_emitter_analyze_tag(emitter, event.tag) { return false } } case yaml_MAPPING_START_EVENT: if len(event.anchor) > 0 { if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) { return false } } if len(event.tag) > 0 && (emitter.canonical || !event.implicit) { if !yaml_emitter_analyze_tag(emitter, event.tag) { return false } } } return true }
[ "func", "yaml_emitter_analyze_event", "(", "emitter", "*", "yaml_emitter_t", ",", "event", "*", "yaml_event_t", ")", "bool", "{", "emitter", ".", "anchor_data", ".", "anchor", "=", "nil", "\n", "emitter", ".", "tag_data", ".", "handle", "=", "nil", "\n", "emitter", ".", "tag_data", ".", "suffix", "=", "nil", "\n", "emitter", ".", "scalar_data", ".", "value", "=", "nil", "\n\n", "switch", "event", ".", "typ", "{", "case", "yaml_ALIAS_EVENT", ":", "if", "!", "yaml_emitter_analyze_anchor", "(", "emitter", ",", "event", ".", "anchor", ",", "true", ")", "{", "return", "false", "\n", "}", "\n\n", "case", "yaml_SCALAR_EVENT", ":", "if", "len", "(", "event", ".", "anchor", ")", ">", "0", "{", "if", "!", "yaml_emitter_analyze_anchor", "(", "emitter", ",", "event", ".", "anchor", ",", "false", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "if", "len", "(", "event", ".", "tag", ")", ">", "0", "&&", "(", "emitter", ".", "canonical", "||", "(", "!", "event", ".", "implicit", "&&", "!", "event", ".", "quoted_implicit", ")", ")", "{", "if", "!", "yaml_emitter_analyze_tag", "(", "emitter", ",", "event", ".", "tag", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "if", "!", "yaml_emitter_analyze_scalar", "(", "emitter", ",", "event", ".", "value", ")", "{", "return", "false", "\n", "}", "\n\n", "case", "yaml_SEQUENCE_START_EVENT", ":", "if", "len", "(", "event", ".", "anchor", ")", ">", "0", "{", "if", "!", "yaml_emitter_analyze_anchor", "(", "emitter", ",", "event", ".", "anchor", ",", "false", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "if", "len", "(", "event", ".", "tag", ")", ">", "0", "&&", "(", "emitter", ".", "canonical", "||", "!", "event", ".", "implicit", ")", "{", "if", "!", "yaml_emitter_analyze_tag", "(", "emitter", ",", "event", ".", "tag", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n\n", "case", "yaml_MAPPING_START_EVENT", ":", "if", "len", "(", "event", ".", "anchor", ")", ">", "0", "{", "if", "!", "yaml_emitter_analyze_anchor", "(", "emitter", ",", "event", ".", "anchor", ",", "false", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "if", "len", "(", "event", ".", "tag", ")", ">", "0", "&&", "(", "emitter", ".", "canonical", "||", "!", "event", ".", "implicit", ")", "{", "if", "!", "yaml_emitter_analyze_tag", "(", "emitter", ",", "event", ".", "tag", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Check if the event data is valid.
[ "Check", "if", "the", "event", "data", "is", "valid", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L1133-L1186
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go
yaml_emitter_write_bom
func yaml_emitter_write_bom(emitter *yaml_emitter_t) bool { if !flush(emitter) { return false } pos := emitter.buffer_pos emitter.buffer[pos+0] = '\xEF' emitter.buffer[pos+1] = '\xBB' emitter.buffer[pos+2] = '\xBF' emitter.buffer_pos += 3 return true }
go
func yaml_emitter_write_bom(emitter *yaml_emitter_t) bool { if !flush(emitter) { return false } pos := emitter.buffer_pos emitter.buffer[pos+0] = '\xEF' emitter.buffer[pos+1] = '\xBB' emitter.buffer[pos+2] = '\xBF' emitter.buffer_pos += 3 return true }
[ "func", "yaml_emitter_write_bom", "(", "emitter", "*", "yaml_emitter_t", ")", "bool", "{", "if", "!", "flush", "(", "emitter", ")", "{", "return", "false", "\n", "}", "\n", "pos", ":=", "emitter", ".", "buffer_pos", "\n", "emitter", ".", "buffer", "[", "pos", "+", "0", "]", "=", "'\\xEF'", "\n", "emitter", ".", "buffer", "[", "pos", "+", "1", "]", "=", "'\\xBB'", "\n", "emitter", ".", "buffer", "[", "pos", "+", "2", "]", "=", "'\\xBF'", "\n", "emitter", ".", "buffer_pos", "+=", "3", "\n", "return", "true", "\n", "}" ]
// Write the BOM character.
[ "Write", "the", "BOM", "character", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L1189-L1199
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/jsonpath/jsonpath.go
evalIdentifier
func (j *JSONPath) evalIdentifier(input []reflect.Value, node *IdentifierNode) ([]reflect.Value, error) { results := []reflect.Value{} switch node.Name { case "range": j.stack = append(j.stack, j.cur) j.beginRange += 1 results = input case "end": if j.endRange < j.inRange { //inside a loop, break the current block j.endRange += 1 break } // the loop is about to end, pop value and continue the following execution if len(j.stack) > 0 { j.cur, j.stack = j.stack[len(j.stack)-1], j.stack[:len(j.stack)-1] } else { return results, fmt.Errorf("not in range, nothing to end") } default: return input, fmt.Errorf("unrecongnized identifier %v", node.Name) } return results, nil }
go
func (j *JSONPath) evalIdentifier(input []reflect.Value, node *IdentifierNode) ([]reflect.Value, error) { results := []reflect.Value{} switch node.Name { case "range": j.stack = append(j.stack, j.cur) j.beginRange += 1 results = input case "end": if j.endRange < j.inRange { //inside a loop, break the current block j.endRange += 1 break } // the loop is about to end, pop value and continue the following execution if len(j.stack) > 0 { j.cur, j.stack = j.stack[len(j.stack)-1], j.stack[:len(j.stack)-1] } else { return results, fmt.Errorf("not in range, nothing to end") } default: return input, fmt.Errorf("unrecongnized identifier %v", node.Name) } return results, nil }
[ "func", "(", "j", "*", "JSONPath", ")", "evalIdentifier", "(", "input", "[", "]", "reflect", ".", "Value", ",", "node", "*", "IdentifierNode", ")", "(", "[", "]", "reflect", ".", "Value", ",", "error", ")", "{", "results", ":=", "[", "]", "reflect", ".", "Value", "{", "}", "\n", "switch", "node", ".", "Name", "{", "case", "\"", "\"", ":", "j", ".", "stack", "=", "append", "(", "j", ".", "stack", ",", "j", ".", "cur", ")", "\n", "j", ".", "beginRange", "+=", "1", "\n", "results", "=", "input", "\n", "case", "\"", "\"", ":", "if", "j", ".", "endRange", "<", "j", ".", "inRange", "{", "//inside a loop, break the current block", "j", ".", "endRange", "+=", "1", "\n", "break", "\n", "}", "\n", "// the loop is about to end, pop value and continue the following execution", "if", "len", "(", "j", ".", "stack", ")", ">", "0", "{", "j", ".", "cur", ",", "j", ".", "stack", "=", "j", ".", "stack", "[", "len", "(", "j", ".", "stack", ")", "-", "1", "]", ",", "j", ".", "stack", "[", ":", "len", "(", "j", ".", "stack", ")", "-", "1", "]", "\n", "}", "else", "{", "return", "results", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "default", ":", "return", "input", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "node", ".", "Name", ")", "\n", "}", "\n", "return", "results", ",", "nil", "\n", "}" ]
// evalIdentifier evaluates IdentifierNode
[ "evalIdentifier", "evaluates", "IdentifierNode" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/jsonpath/jsonpath.go#L189-L211
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/jsonpath/jsonpath.go
evalArray
func (j *JSONPath) evalArray(input []reflect.Value, node *ArrayNode) ([]reflect.Value, error) { result := []reflect.Value{} for _, value := range input { value, isNil := template.Indirect(value) if isNil || (value.Kind() != reflect.Array && value.Kind() != reflect.Slice) { return input, fmt.Errorf("%v is not array or slice", value.Type()) } params := node.Params if !params[0].Known { params[0].Value = 0 } if params[0].Value < 0 { params[0].Value += value.Len() } if !params[1].Known { params[1].Value = value.Len() } if params[1].Value < 0 { params[1].Value += value.Len() } sliceLength := value.Len() if params[1].Value != params[0].Value { // if you're requesting zero elements, allow it through. if params[0].Value >= sliceLength { return input, fmt.Errorf("array index out of bounds: index %d, length %d", params[0].Value, sliceLength) } if params[1].Value > sliceLength { return input, fmt.Errorf("array index out of bounds: index %d, length %d", params[1].Value-1, sliceLength) } } if !params[2].Known { value = value.Slice(params[0].Value, params[1].Value) } else { value = value.Slice3(params[0].Value, params[1].Value, params[2].Value) } for i := 0; i < value.Len(); i++ { result = append(result, value.Index(i)) } } return result, nil }
go
func (j *JSONPath) evalArray(input []reflect.Value, node *ArrayNode) ([]reflect.Value, error) { result := []reflect.Value{} for _, value := range input { value, isNil := template.Indirect(value) if isNil || (value.Kind() != reflect.Array && value.Kind() != reflect.Slice) { return input, fmt.Errorf("%v is not array or slice", value.Type()) } params := node.Params if !params[0].Known { params[0].Value = 0 } if params[0].Value < 0 { params[0].Value += value.Len() } if !params[1].Known { params[1].Value = value.Len() } if params[1].Value < 0 { params[1].Value += value.Len() } sliceLength := value.Len() if params[1].Value != params[0].Value { // if you're requesting zero elements, allow it through. if params[0].Value >= sliceLength { return input, fmt.Errorf("array index out of bounds: index %d, length %d", params[0].Value, sliceLength) } if params[1].Value > sliceLength { return input, fmt.Errorf("array index out of bounds: index %d, length %d", params[1].Value-1, sliceLength) } } if !params[2].Known { value = value.Slice(params[0].Value, params[1].Value) } else { value = value.Slice3(params[0].Value, params[1].Value, params[2].Value) } for i := 0; i < value.Len(); i++ { result = append(result, value.Index(i)) } } return result, nil }
[ "func", "(", "j", "*", "JSONPath", ")", "evalArray", "(", "input", "[", "]", "reflect", ".", "Value", ",", "node", "*", "ArrayNode", ")", "(", "[", "]", "reflect", ".", "Value", ",", "error", ")", "{", "result", ":=", "[", "]", "reflect", ".", "Value", "{", "}", "\n", "for", "_", ",", "value", ":=", "range", "input", "{", "value", ",", "isNil", ":=", "template", ".", "Indirect", "(", "value", ")", "\n", "if", "isNil", "||", "(", "value", ".", "Kind", "(", ")", "!=", "reflect", ".", "Array", "&&", "value", ".", "Kind", "(", ")", "!=", "reflect", ".", "Slice", ")", "{", "return", "input", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "value", ".", "Type", "(", ")", ")", "\n", "}", "\n", "params", ":=", "node", ".", "Params", "\n", "if", "!", "params", "[", "0", "]", ".", "Known", "{", "params", "[", "0", "]", ".", "Value", "=", "0", "\n", "}", "\n", "if", "params", "[", "0", "]", ".", "Value", "<", "0", "{", "params", "[", "0", "]", ".", "Value", "+=", "value", ".", "Len", "(", ")", "\n", "}", "\n", "if", "!", "params", "[", "1", "]", ".", "Known", "{", "params", "[", "1", "]", ".", "Value", "=", "value", ".", "Len", "(", ")", "\n", "}", "\n\n", "if", "params", "[", "1", "]", ".", "Value", "<", "0", "{", "params", "[", "1", "]", ".", "Value", "+=", "value", ".", "Len", "(", ")", "\n", "}", "\n\n", "sliceLength", ":=", "value", ".", "Len", "(", ")", "\n", "if", "params", "[", "1", "]", ".", "Value", "!=", "params", "[", "0", "]", ".", "Value", "{", "// if you're requesting zero elements, allow it through.", "if", "params", "[", "0", "]", ".", "Value", ">=", "sliceLength", "{", "return", "input", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "params", "[", "0", "]", ".", "Value", ",", "sliceLength", ")", "\n", "}", "\n", "if", "params", "[", "1", "]", ".", "Value", ">", "sliceLength", "{", "return", "input", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "params", "[", "1", "]", ".", "Value", "-", "1", ",", "sliceLength", ")", "\n", "}", "\n", "}", "\n\n", "if", "!", "params", "[", "2", "]", ".", "Known", "{", "value", "=", "value", ".", "Slice", "(", "params", "[", "0", "]", ".", "Value", ",", "params", "[", "1", "]", ".", "Value", ")", "\n", "}", "else", "{", "value", "=", "value", ".", "Slice3", "(", "params", "[", "0", "]", ".", "Value", ",", "params", "[", "1", "]", ".", "Value", ",", "params", "[", "2", "]", ".", "Value", ")", "\n", "}", "\n", "for", "i", ":=", "0", ";", "i", "<", "value", ".", "Len", "(", ")", ";", "i", "++", "{", "result", "=", "append", "(", "result", ",", "value", ".", "Index", "(", "i", ")", ")", "\n", "}", "\n", "}", "\n", "return", "result", ",", "nil", "\n", "}" ]
// evalArray evaluates ArrayNode
[ "evalArray", "evaluates", "ArrayNode" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/jsonpath/jsonpath.go#L214-L257
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/jsonpath/jsonpath.go
evalField
func (j *JSONPath) evalField(input []reflect.Value, node *FieldNode) ([]reflect.Value, error) { results := []reflect.Value{} // If there's no input, there's no output if len(input) == 0 { return results, nil } for _, value := range input { var result reflect.Value value, isNil := template.Indirect(value) if isNil { continue } if value.Kind() == reflect.Struct { var err error if result, err = j.findFieldInValue(&value, node); err != nil { return nil, err } } else if value.Kind() == reflect.Map { result = value.MapIndex(reflect.ValueOf(node.Value)) } if result.IsValid() { results = append(results, result) } } if len(results) == 0 { return results, fmt.Errorf("%s is not found", node.Value) } return results, nil }
go
func (j *JSONPath) evalField(input []reflect.Value, node *FieldNode) ([]reflect.Value, error) { results := []reflect.Value{} // If there's no input, there's no output if len(input) == 0 { return results, nil } for _, value := range input { var result reflect.Value value, isNil := template.Indirect(value) if isNil { continue } if value.Kind() == reflect.Struct { var err error if result, err = j.findFieldInValue(&value, node); err != nil { return nil, err } } else if value.Kind() == reflect.Map { result = value.MapIndex(reflect.ValueOf(node.Value)) } if result.IsValid() { results = append(results, result) } } if len(results) == 0 { return results, fmt.Errorf("%s is not found", node.Value) } return results, nil }
[ "func", "(", "j", "*", "JSONPath", ")", "evalField", "(", "input", "[", "]", "reflect", ".", "Value", ",", "node", "*", "FieldNode", ")", "(", "[", "]", "reflect", ".", "Value", ",", "error", ")", "{", "results", ":=", "[", "]", "reflect", ".", "Value", "{", "}", "\n", "// If there's no input, there's no output", "if", "len", "(", "input", ")", "==", "0", "{", "return", "results", ",", "nil", "\n", "}", "\n", "for", "_", ",", "value", ":=", "range", "input", "{", "var", "result", "reflect", ".", "Value", "\n", "value", ",", "isNil", ":=", "template", ".", "Indirect", "(", "value", ")", "\n", "if", "isNil", "{", "continue", "\n", "}", "\n\n", "if", "value", ".", "Kind", "(", ")", "==", "reflect", ".", "Struct", "{", "var", "err", "error", "\n", "if", "result", ",", "err", "=", "j", ".", "findFieldInValue", "(", "&", "value", ",", "node", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "else", "if", "value", ".", "Kind", "(", ")", "==", "reflect", ".", "Map", "{", "result", "=", "value", ".", "MapIndex", "(", "reflect", ".", "ValueOf", "(", "node", ".", "Value", ")", ")", "\n", "}", "\n", "if", "result", ".", "IsValid", "(", ")", "{", "results", "=", "append", "(", "results", ",", "result", ")", "\n", "}", "\n", "}", "\n", "if", "len", "(", "results", ")", "==", "0", "{", "return", "results", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "node", ".", "Value", ")", "\n", "}", "\n", "return", "results", ",", "nil", "\n", "}" ]
// evalField evaluates filed of struct or key of map.
[ "evalField", "evaluates", "filed", "of", "struct", "or", "key", "of", "map", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/jsonpath/jsonpath.go#L306-L335
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/remotecommand/remotecommand.go
NewStreamExecutor
func NewStreamExecutor(upgrader httpstream.UpgradeRoundTripper, fn func(http.RoundTripper) http.RoundTripper, method string, url *url.URL) (StreamExecutor, error) { var rt http.RoundTripper = upgrader if fn != nil { rt = fn(rt) } return &streamExecutor{ upgrader: upgrader, transport: rt, method: method, url: url, }, nil }
go
func NewStreamExecutor(upgrader httpstream.UpgradeRoundTripper, fn func(http.RoundTripper) http.RoundTripper, method string, url *url.URL) (StreamExecutor, error) { var rt http.RoundTripper = upgrader if fn != nil { rt = fn(rt) } return &streamExecutor{ upgrader: upgrader, transport: rt, method: method, url: url, }, nil }
[ "func", "NewStreamExecutor", "(", "upgrader", "httpstream", ".", "UpgradeRoundTripper", ",", "fn", "func", "(", "http", ".", "RoundTripper", ")", "http", ".", "RoundTripper", ",", "method", "string", ",", "url", "*", "url", ".", "URL", ")", "(", "StreamExecutor", ",", "error", ")", "{", "var", "rt", "http", ".", "RoundTripper", "=", "upgrader", "\n", "if", "fn", "!=", "nil", "{", "rt", "=", "fn", "(", "rt", ")", "\n", "}", "\n", "return", "&", "streamExecutor", "{", "upgrader", ":", "upgrader", ",", "transport", ":", "rt", ",", "method", ":", "method", ",", "url", ":", "url", ",", "}", ",", "nil", "\n", "}" ]
// NewStreamExecutor upgrades the request so that it supports multiplexed bidirectional // streams. This method takes a stream upgrader and an optional function that is invoked // to wrap the round tripper. This method may be used by clients that are lower level than // Kubernetes clients or need to provide their own upgrade round tripper.
[ "NewStreamExecutor", "upgrades", "the", "request", "so", "that", "it", "supports", "multiplexed", "bidirectional", "streams", ".", "This", "method", "takes", "a", "stream", "upgrader", "and", "an", "optional", "function", "that", "is", "invoked", "to", "wrap", "the", "round", "tripper", ".", "This", "method", "may", "be", "used", "by", "clients", "that", "are", "lower", "level", "than", "Kubernetes", "clients", "or", "need", "to", "provide", "their", "own", "upgrade", "round", "tripper", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/remotecommand/remotecommand.go#L86-L97
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/remotecommand/remotecommand.go
Dial
func (e *streamExecutor) Dial(protocols ...string) (httpstream.Connection, string, error) { rt := transport.DebugWrappers(e.transport) // TODO the client probably shouldn't be created here, as it doesn't allow // flexibility to allow callers to configure it. client := &http.Client{Transport: rt} req, err := http.NewRequest(e.method, e.url.String(), nil) if err != nil { return nil, "", fmt.Errorf("error creating request: %v", err) } for i := range protocols { req.Header.Add(httpstream.HeaderProtocolVersion, protocols[i]) } resp, err := client.Do(req) if err != nil { return nil, "", fmt.Errorf("error sending request: %v", err) } defer resp.Body.Close() conn, err := e.upgrader.NewConnection(resp) if err != nil { return nil, "", err } return conn, resp.Header.Get(httpstream.HeaderProtocolVersion), nil }
go
func (e *streamExecutor) Dial(protocols ...string) (httpstream.Connection, string, error) { rt := transport.DebugWrappers(e.transport) // TODO the client probably shouldn't be created here, as it doesn't allow // flexibility to allow callers to configure it. client := &http.Client{Transport: rt} req, err := http.NewRequest(e.method, e.url.String(), nil) if err != nil { return nil, "", fmt.Errorf("error creating request: %v", err) } for i := range protocols { req.Header.Add(httpstream.HeaderProtocolVersion, protocols[i]) } resp, err := client.Do(req) if err != nil { return nil, "", fmt.Errorf("error sending request: %v", err) } defer resp.Body.Close() conn, err := e.upgrader.NewConnection(resp) if err != nil { return nil, "", err } return conn, resp.Header.Get(httpstream.HeaderProtocolVersion), nil }
[ "func", "(", "e", "*", "streamExecutor", ")", "Dial", "(", "protocols", "...", "string", ")", "(", "httpstream", ".", "Connection", ",", "string", ",", "error", ")", "{", "rt", ":=", "transport", ".", "DebugWrappers", "(", "e", ".", "transport", ")", "\n\n", "// TODO the client probably shouldn't be created here, as it doesn't allow", "// flexibility to allow callers to configure it.", "client", ":=", "&", "http", ".", "Client", "{", "Transport", ":", "rt", "}", "\n\n", "req", ",", "err", ":=", "http", ".", "NewRequest", "(", "e", ".", "method", ",", "e", ".", "url", ".", "String", "(", ")", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "for", "i", ":=", "range", "protocols", "{", "req", ".", "Header", ".", "Add", "(", "httpstream", ".", "HeaderProtocolVersion", ",", "protocols", "[", "i", "]", ")", "\n", "}", "\n\n", "resp", ",", "err", ":=", "client", ".", "Do", "(", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "defer", "resp", ".", "Body", ".", "Close", "(", ")", "\n\n", "conn", ",", "err", ":=", "e", ".", "upgrader", ".", "NewConnection", "(", "resp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "err", "\n", "}", "\n\n", "return", "conn", ",", "resp", ".", "Header", ".", "Get", "(", "httpstream", ".", "HeaderProtocolVersion", ")", ",", "nil", "\n", "}" ]
// Dial opens a connection to a remote server and attempts to negotiate a SPDY // connection. Upon success, it returns the connection and the protocol // selected by the server.
[ "Dial", "opens", "a", "connection", "to", "a", "remote", "server", "and", "attempts", "to", "negotiate", "a", "SPDY", "connection", ".", "Upon", "success", "it", "returns", "the", "connection", "and", "the", "protocol", "selected", "by", "the", "server", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/remotecommand/remotecommand.go#L102-L129
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/transport.go
getSessionID
func (t *transport) getSessionID() []byte { if t.sessionID == nil { panic("session ID not set yet") } return t.sessionID }
go
func (t *transport) getSessionID() []byte { if t.sessionID == nil { panic("session ID not set yet") } return t.sessionID }
[ "func", "(", "t", "*", "transport", ")", "getSessionID", "(", ")", "[", "]", "byte", "{", "if", "t", ".", "sessionID", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "t", ".", "sessionID", "\n", "}" ]
// getSessionID returns the ID of the SSH connection. The return value // should not be modified.
[ "getSessionID", "returns", "the", "ID", "of", "the", "SSH", "connection", ".", "The", "return", "value", "should", "not", "be", "modified", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/transport.go#L50-L55
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/transport.go
prepareKeyChange
func (t *transport) prepareKeyChange(algs *algorithms, kexResult *kexResult) error { if t.sessionID == nil { t.sessionID = kexResult.H } kexResult.SessionID = t.sessionID if ciph, err := newPacketCipher(t.reader.dir, algs.r, kexResult); err != nil { return err } else { t.reader.pendingKeyChange <- ciph } if ciph, err := newPacketCipher(t.writer.dir, algs.w, kexResult); err != nil { return err } else { t.writer.pendingKeyChange <- ciph } return nil }
go
func (t *transport) prepareKeyChange(algs *algorithms, kexResult *kexResult) error { if t.sessionID == nil { t.sessionID = kexResult.H } kexResult.SessionID = t.sessionID if ciph, err := newPacketCipher(t.reader.dir, algs.r, kexResult); err != nil { return err } else { t.reader.pendingKeyChange <- ciph } if ciph, err := newPacketCipher(t.writer.dir, algs.w, kexResult); err != nil { return err } else { t.writer.pendingKeyChange <- ciph } return nil }
[ "func", "(", "t", "*", "transport", ")", "prepareKeyChange", "(", "algs", "*", "algorithms", ",", "kexResult", "*", "kexResult", ")", "error", "{", "if", "t", ".", "sessionID", "==", "nil", "{", "t", ".", "sessionID", "=", "kexResult", ".", "H", "\n", "}", "\n\n", "kexResult", ".", "SessionID", "=", "t", ".", "sessionID", "\n\n", "if", "ciph", ",", "err", ":=", "newPacketCipher", "(", "t", ".", "reader", ".", "dir", ",", "algs", ".", "r", ",", "kexResult", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "else", "{", "t", ".", "reader", ".", "pendingKeyChange", "<-", "ciph", "\n", "}", "\n\n", "if", "ciph", ",", "err", ":=", "newPacketCipher", "(", "t", ".", "writer", ".", "dir", ",", "algs", ".", "w", ",", "kexResult", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "else", "{", "t", ".", "writer", ".", "pendingKeyChange", "<-", "ciph", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// prepareKeyChange sets up key material for a keychange. The key changes in // both directions are triggered by reading and writing a msgNewKey packet // respectively.
[ "prepareKeyChange", "sets", "up", "key", "material", "for", "a", "keychange", ".", "The", "key", "changes", "in", "both", "directions", "are", "triggered", "by", "reading", "and", "writing", "a", "msgNewKey", "packet", "respectively", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/transport.go#L83-L103
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/transport.go
readPacket
func (t *transport) readPacket() ([]byte, error) { return t.reader.readPacket(t.bufReader) }
go
func (t *transport) readPacket() ([]byte, error) { return t.reader.readPacket(t.bufReader) }
[ "func", "(", "t", "*", "transport", ")", "readPacket", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "return", "t", ".", "reader", ".", "readPacket", "(", "t", ".", "bufReader", ")", "\n", "}" ]
// Read and decrypt next packet.
[ "Read", "and", "decrypt", "next", "packet", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/transport.go#L106-L108
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/transport.go
generateKeys
func generateKeys(d direction, algs directionAlgorithms, kex *kexResult) (iv, key, macKey []byte) { cipherMode := cipherModes[algs.Cipher] macMode := macModes[algs.MAC] iv = make([]byte, cipherMode.ivSize) key = make([]byte, cipherMode.keySize) macKey = make([]byte, macMode.keySize) generateKeyMaterial(iv, d.ivTag, kex) generateKeyMaterial(key, d.keyTag, kex) generateKeyMaterial(macKey, d.macKeyTag, kex) return }
go
func generateKeys(d direction, algs directionAlgorithms, kex *kexResult) (iv, key, macKey []byte) { cipherMode := cipherModes[algs.Cipher] macMode := macModes[algs.MAC] iv = make([]byte, cipherMode.ivSize) key = make([]byte, cipherMode.keySize) macKey = make([]byte, macMode.keySize) generateKeyMaterial(iv, d.ivTag, kex) generateKeyMaterial(key, d.keyTag, kex) generateKeyMaterial(macKey, d.macKeyTag, kex) return }
[ "func", "generateKeys", "(", "d", "direction", ",", "algs", "directionAlgorithms", ",", "kex", "*", "kexResult", ")", "(", "iv", ",", "key", ",", "macKey", "[", "]", "byte", ")", "{", "cipherMode", ":=", "cipherModes", "[", "algs", ".", "Cipher", "]", "\n", "macMode", ":=", "macModes", "[", "algs", ".", "MAC", "]", "\n\n", "iv", "=", "make", "(", "[", "]", "byte", ",", "cipherMode", ".", "ivSize", ")", "\n", "key", "=", "make", "(", "[", "]", "byte", ",", "cipherMode", ".", "keySize", ")", "\n", "macKey", "=", "make", "(", "[", "]", "byte", ",", "macMode", ".", "keySize", ")", "\n\n", "generateKeyMaterial", "(", "iv", ",", "d", ".", "ivTag", ",", "kex", ")", "\n", "generateKeyMaterial", "(", "key", ",", "d", ".", "keyTag", ",", "kex", ")", "\n", "generateKeyMaterial", "(", "macKey", ",", "d", ".", "macKeyTag", ",", "kex", ")", "\n", "return", "\n", "}" ]
// generateKeys generates key material for IV, MAC and encryption.
[ "generateKeys", "generates", "key", "material", "for", "IV", "MAC", "and", "encryption", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/transport.go#L198-L210
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/transport.go
generateKeyMaterial
func generateKeyMaterial(out, tag []byte, r *kexResult) { var digestsSoFar []byte h := r.Hash.New() for len(out) > 0 { h.Reset() h.Write(r.K) h.Write(r.H) if len(digestsSoFar) == 0 { h.Write(tag) h.Write(r.SessionID) } else { h.Write(digestsSoFar) } digest := h.Sum(nil) n := copy(out, digest) out = out[n:] if len(out) > 0 { digestsSoFar = append(digestsSoFar, digest...) } } }
go
func generateKeyMaterial(out, tag []byte, r *kexResult) { var digestsSoFar []byte h := r.Hash.New() for len(out) > 0 { h.Reset() h.Write(r.K) h.Write(r.H) if len(digestsSoFar) == 0 { h.Write(tag) h.Write(r.SessionID) } else { h.Write(digestsSoFar) } digest := h.Sum(nil) n := copy(out, digest) out = out[n:] if len(out) > 0 { digestsSoFar = append(digestsSoFar, digest...) } } }
[ "func", "generateKeyMaterial", "(", "out", ",", "tag", "[", "]", "byte", ",", "r", "*", "kexResult", ")", "{", "var", "digestsSoFar", "[", "]", "byte", "\n\n", "h", ":=", "r", ".", "Hash", ".", "New", "(", ")", "\n", "for", "len", "(", "out", ")", ">", "0", "{", "h", ".", "Reset", "(", ")", "\n", "h", ".", "Write", "(", "r", ".", "K", ")", "\n", "h", ".", "Write", "(", "r", ".", "H", ")", "\n\n", "if", "len", "(", "digestsSoFar", ")", "==", "0", "{", "h", ".", "Write", "(", "tag", ")", "\n", "h", ".", "Write", "(", "r", ".", "SessionID", ")", "\n", "}", "else", "{", "h", ".", "Write", "(", "digestsSoFar", ")", "\n", "}", "\n\n", "digest", ":=", "h", ".", "Sum", "(", "nil", ")", "\n", "n", ":=", "copy", "(", "out", ",", "digest", ")", "\n", "out", "=", "out", "[", "n", ":", "]", "\n", "if", "len", "(", "out", ")", ">", "0", "{", "digestsSoFar", "=", "append", "(", "digestsSoFar", ",", "digest", "...", ")", "\n", "}", "\n", "}", "\n", "}" ]
// generateKeyMaterial fills out with key material generated from tag, K, H // and sessionId, as specified in RFC 4253, section 7.2.
[ "generateKeyMaterial", "fills", "out", "with", "key", "material", "generated", "from", "tag", "K", "H", "and", "sessionId", "as", "specified", "in", "RFC", "4253", "section", "7", ".", "2", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/transport.go#L242-L265
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/transport.go
exchangeVersions
func exchangeVersions(rw io.ReadWriter, versionLine []byte) (them []byte, err error) { // Contrary to the RFC, we do not ignore lines that don't // start with "SSH-2.0-" to make the library usable with // nonconforming servers. for _, c := range versionLine { // The spec disallows non US-ASCII chars, and // specifically forbids null chars. if c < 32 { return nil, errors.New("ssh: junk character in version line") } } if _, err = rw.Write(append(versionLine, '\r', '\n')); err != nil { return } them, err = readVersion(rw) return them, err }
go
func exchangeVersions(rw io.ReadWriter, versionLine []byte) (them []byte, err error) { // Contrary to the RFC, we do not ignore lines that don't // start with "SSH-2.0-" to make the library usable with // nonconforming servers. for _, c := range versionLine { // The spec disallows non US-ASCII chars, and // specifically forbids null chars. if c < 32 { return nil, errors.New("ssh: junk character in version line") } } if _, err = rw.Write(append(versionLine, '\r', '\n')); err != nil { return } them, err = readVersion(rw) return them, err }
[ "func", "exchangeVersions", "(", "rw", "io", ".", "ReadWriter", ",", "versionLine", "[", "]", "byte", ")", "(", "them", "[", "]", "byte", ",", "err", "error", ")", "{", "// Contrary to the RFC, we do not ignore lines that don't", "// start with \"SSH-2.0-\" to make the library usable with", "// nonconforming servers.", "for", "_", ",", "c", ":=", "range", "versionLine", "{", "// The spec disallows non US-ASCII chars, and", "// specifically forbids null chars.", "if", "c", "<", "32", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "}", "\n", "if", "_", ",", "err", "=", "rw", ".", "Write", "(", "append", "(", "versionLine", ",", "'\\r'", ",", "'\\n'", ")", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "them", ",", "err", "=", "readVersion", "(", "rw", ")", "\n", "return", "them", ",", "err", "\n", "}" ]
// Sends and receives a version line. The versionLine string should // be US ASCII, start with "SSH-2.0-", and should not include a // newline. exchangeVersions returns the other side's version line.
[ "Sends", "and", "receives", "a", "version", "line", ".", "The", "versionLine", "string", "should", "be", "US", "ASCII", "start", "with", "SSH", "-", "2", ".", "0", "-", "and", "should", "not", "include", "a", "newline", ".", "exchangeVersions", "returns", "the", "other", "side", "s", "version", "line", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/transport.go#L272-L289
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/transport.go
readVersion
func readVersion(r io.Reader) ([]byte, error) { versionString := make([]byte, 0, 64) var ok bool var buf [1]byte for len(versionString) < maxVersionStringBytes { _, err := io.ReadFull(r, buf[:]) if err != nil { return nil, err } // The RFC says that the version should be terminated with \r\n // but several SSH servers actually only send a \n. if buf[0] == '\n' { ok = true break } // non ASCII chars are disallowed, but we are lenient, // since Go doesn't use null-terminated strings. // The RFC allows a comment after a space, however, // all of it (version and comments) goes into the // session hash. versionString = append(versionString, buf[0]) } if !ok { return nil, errors.New("ssh: overflow reading version string") } // There might be a '\r' on the end which we should remove. if len(versionString) > 0 && versionString[len(versionString)-1] == '\r' { versionString = versionString[:len(versionString)-1] } return versionString, nil }
go
func readVersion(r io.Reader) ([]byte, error) { versionString := make([]byte, 0, 64) var ok bool var buf [1]byte for len(versionString) < maxVersionStringBytes { _, err := io.ReadFull(r, buf[:]) if err != nil { return nil, err } // The RFC says that the version should be terminated with \r\n // but several SSH servers actually only send a \n. if buf[0] == '\n' { ok = true break } // non ASCII chars are disallowed, but we are lenient, // since Go doesn't use null-terminated strings. // The RFC allows a comment after a space, however, // all of it (version and comments) goes into the // session hash. versionString = append(versionString, buf[0]) } if !ok { return nil, errors.New("ssh: overflow reading version string") } // There might be a '\r' on the end which we should remove. if len(versionString) > 0 && versionString[len(versionString)-1] == '\r' { versionString = versionString[:len(versionString)-1] } return versionString, nil }
[ "func", "readVersion", "(", "r", "io", ".", "Reader", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "versionString", ":=", "make", "(", "[", "]", "byte", ",", "0", ",", "64", ")", "\n", "var", "ok", "bool", "\n", "var", "buf", "[", "1", "]", "byte", "\n\n", "for", "len", "(", "versionString", ")", "<", "maxVersionStringBytes", "{", "_", ",", "err", ":=", "io", ".", "ReadFull", "(", "r", ",", "buf", "[", ":", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "// The RFC says that the version should be terminated with \\r\\n", "// but several SSH servers actually only send a \\n.", "if", "buf", "[", "0", "]", "==", "'\\n'", "{", "ok", "=", "true", "\n", "break", "\n", "}", "\n\n", "// non ASCII chars are disallowed, but we are lenient,", "// since Go doesn't use null-terminated strings.", "// The RFC allows a comment after a space, however,", "// all of it (version and comments) goes into the", "// session hash.", "versionString", "=", "append", "(", "versionString", ",", "buf", "[", "0", "]", ")", "\n", "}", "\n\n", "if", "!", "ok", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// There might be a '\\r' on the end which we should remove.", "if", "len", "(", "versionString", ")", ">", "0", "&&", "versionString", "[", "len", "(", "versionString", ")", "-", "1", "]", "==", "'\\r'", "{", "versionString", "=", "versionString", "[", ":", "len", "(", "versionString", ")", "-", "1", "]", "\n", "}", "\n", "return", "versionString", ",", "nil", "\n", "}" ]
// Read version string as specified by RFC 4253, section 4.2.
[ "Read", "version", "string", "as", "specified", "by", "RFC", "4253", "section", "4", ".", "2", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/transport.go#L297-L332
train
kubernetes-retired/contrib
release-notes/Godeps/_workspace/src/golang.org/x/oauth2/google/appengine.go
AppEngineTokenSource
func AppEngineTokenSource(ctx context.Context, scope ...string) oauth2.TokenSource { if appengineTokenFunc == nil { panic("google: AppEngineTokenSource can only be used on App Engine.") } scopes := append([]string{}, scope...) sort.Strings(scopes) return &appEngineTokenSource{ ctx: ctx, scopes: scopes, key: strings.Join(scopes, " "), } }
go
func AppEngineTokenSource(ctx context.Context, scope ...string) oauth2.TokenSource { if appengineTokenFunc == nil { panic("google: AppEngineTokenSource can only be used on App Engine.") } scopes := append([]string{}, scope...) sort.Strings(scopes) return &appEngineTokenSource{ ctx: ctx, scopes: scopes, key: strings.Join(scopes, " "), } }
[ "func", "AppEngineTokenSource", "(", "ctx", "context", ".", "Context", ",", "scope", "...", "string", ")", "oauth2", ".", "TokenSource", "{", "if", "appengineTokenFunc", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "scopes", ":=", "append", "(", "[", "]", "string", "{", "}", ",", "scope", "...", ")", "\n", "sort", ".", "Strings", "(", "scopes", ")", "\n", "return", "&", "appEngineTokenSource", "{", "ctx", ":", "ctx", ",", "scopes", ":", "scopes", ",", "key", ":", "strings", ".", "Join", "(", "scopes", ",", "\"", "\"", ")", ",", "}", "\n", "}" ]
// AppEngineTokenSource returns a token source that fetches tokens // issued to the current App Engine application's service account. // If you are implementing a 3-legged OAuth 2.0 flow on App Engine // that involves user accounts, see oauth2.Config instead. // // The provided context must have come from appengine.NewContext.
[ "AppEngineTokenSource", "returns", "a", "token", "source", "that", "fetches", "tokens", "issued", "to", "the", "current", "App", "Engine", "application", "s", "service", "account", ".", "If", "you", "are", "implementing", "a", "3", "-", "legged", "OAuth", "2", ".", "0", "flow", "on", "App", "Engine", "that", "involves", "user", "accounts", "see", "oauth2", ".", "Config", "instead", ".", "The", "provided", "context", "must", "have", "come", "from", "appengine", ".", "NewContext", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/release-notes/Godeps/_workspace/src/golang.org/x/oauth2/google/appengine.go#L26-L37
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/sysctl/sysctl.go
GetSysctl
func GetSysctl(sysctl string) (int, error) { data, err := ioutil.ReadFile(path.Join(sysctlBase, sysctl)) if err != nil { return -1, err } val, err := strconv.Atoi(strings.Trim(string(data), " \n")) if err != nil { return -1, err } return val, nil }
go
func GetSysctl(sysctl string) (int, error) { data, err := ioutil.ReadFile(path.Join(sysctlBase, sysctl)) if err != nil { return -1, err } val, err := strconv.Atoi(strings.Trim(string(data), " \n")) if err != nil { return -1, err } return val, nil }
[ "func", "GetSysctl", "(", "sysctl", "string", ")", "(", "int", ",", "error", ")", "{", "data", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "path", ".", "Join", "(", "sysctlBase", ",", "sysctl", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "-", "1", ",", "err", "\n", "}", "\n", "val", ",", "err", ":=", "strconv", ".", "Atoi", "(", "strings", ".", "Trim", "(", "string", "(", "data", ")", ",", "\"", "\\n", "\"", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "-", "1", ",", "err", "\n", "}", "\n", "return", "val", ",", "nil", "\n", "}" ]
// GetSysctl returns the value for the specified sysctl setting
[ "GetSysctl", "returns", "the", "value", "for", "the", "specified", "sysctl", "setting" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/sysctl/sysctl.go#L41-L51
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/sysctl/sysctl.go
SetSysctl
func SetSysctl(sysctl string, newVal int) error { return ioutil.WriteFile(path.Join(sysctlBase, sysctl), []byte(strconv.Itoa(newVal)), 0640) }
go
func SetSysctl(sysctl string, newVal int) error { return ioutil.WriteFile(path.Join(sysctlBase, sysctl), []byte(strconv.Itoa(newVal)), 0640) }
[ "func", "SetSysctl", "(", "sysctl", "string", ",", "newVal", "int", ")", "error", "{", "return", "ioutil", ".", "WriteFile", "(", "path", ".", "Join", "(", "sysctlBase", ",", "sysctl", ")", ",", "[", "]", "byte", "(", "strconv", ".", "Itoa", "(", "newVal", ")", ")", ",", "0640", ")", "\n", "}" ]
// SetSysctl modifies the specified sysctl flag to the new value
[ "SetSysctl", "modifies", "the", "specified", "sysctl", "flag", "to", "the", "new", "value" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/sysctl/sysctl.go#L54-L56
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/quantity.go
MustParse
func MustParse(str string) Quantity { q, err := ParseQuantity(str) if err != nil { panic(fmt.Errorf("cannot parse '%v': %v", str, err)) } return *q }
go
func MustParse(str string) Quantity { q, err := ParseQuantity(str) if err != nil { panic(fmt.Errorf("cannot parse '%v': %v", str, err)) } return *q }
[ "func", "MustParse", "(", "str", "string", ")", "Quantity", "{", "q", ",", "err", ":=", "ParseQuantity", "(", "str", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "str", ",", "err", ")", ")", "\n", "}", "\n", "return", "*", "q", "\n", "}" ]
// MustParse turns the given string into a quantity or panics; for tests // or others cases where you know the string is valid.
[ "MustParse", "turns", "the", "given", "string", "into", "a", "quantity", "or", "panics", ";", "for", "tests", "or", "others", "cases", "where", "you", "know", "the", "string", "is", "valid", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/quantity.go#L112-L118
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/quantity.go
String
func (q *Quantity) String() string { number, suffix := q.Canonicalize() return number + string(suffix) }
go
func (q *Quantity) String() string { number, suffix := q.Canonicalize() return number + string(suffix) }
[ "func", "(", "q", "*", "Quantity", ")", "String", "(", ")", "string", "{", "number", ",", "suffix", ":=", "q", ".", "Canonicalize", "(", ")", "\n", "return", "number", "+", "string", "(", "suffix", ")", "\n", "}" ]
// String formats the Quantity as a string.
[ "String", "formats", "the", "Quantity", "as", "a", "string", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/quantity.go#L304-L307
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/quantity.go
Set
func (q *Quantity) Set(value int64) { if q.Amount == nil { q.Amount = &inf.Dec{} } q.Amount.SetUnscaled(value) q.Amount.SetScale(0) }
go
func (q *Quantity) Set(value int64) { if q.Amount == nil { q.Amount = &inf.Dec{} } q.Amount.SetUnscaled(value) q.Amount.SetScale(0) }
[ "func", "(", "q", "*", "Quantity", ")", "Set", "(", "value", "int64", ")", "{", "if", "q", ".", "Amount", "==", "nil", "{", "q", ".", "Amount", "=", "&", "inf", ".", "Dec", "{", "}", "\n", "}", "\n", "q", ".", "Amount", ".", "SetUnscaled", "(", "value", ")", "\n", "q", ".", "Amount", ".", "SetScale", "(", "0", ")", "\n", "}" ]
// Set sets q's value to be value.
[ "Set", "sets", "q", "s", "value", "to", "be", "value", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/quantity.go#L411-L417
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/keys.go
parsePubKey
func parsePubKey(in []byte, algo string) (pubKey PublicKey, rest []byte, err error) { switch algo { case KeyAlgoRSA: return parseRSA(in) case KeyAlgoDSA: return parseDSA(in) case KeyAlgoECDSA256, KeyAlgoECDSA384, KeyAlgoECDSA521: return parseECDSA(in) case CertAlgoRSAv01, CertAlgoDSAv01, CertAlgoECDSA256v01, CertAlgoECDSA384v01, CertAlgoECDSA521v01: cert, err := parseCert(in, certToPrivAlgo(algo)) if err != nil { return nil, nil, err } return cert, nil, nil } return nil, nil, fmt.Errorf("ssh: unknown key algorithm: %v", err) }
go
func parsePubKey(in []byte, algo string) (pubKey PublicKey, rest []byte, err error) { switch algo { case KeyAlgoRSA: return parseRSA(in) case KeyAlgoDSA: return parseDSA(in) case KeyAlgoECDSA256, KeyAlgoECDSA384, KeyAlgoECDSA521: return parseECDSA(in) case CertAlgoRSAv01, CertAlgoDSAv01, CertAlgoECDSA256v01, CertAlgoECDSA384v01, CertAlgoECDSA521v01: cert, err := parseCert(in, certToPrivAlgo(algo)) if err != nil { return nil, nil, err } return cert, nil, nil } return nil, nil, fmt.Errorf("ssh: unknown key algorithm: %v", err) }
[ "func", "parsePubKey", "(", "in", "[", "]", "byte", ",", "algo", "string", ")", "(", "pubKey", "PublicKey", ",", "rest", "[", "]", "byte", ",", "err", "error", ")", "{", "switch", "algo", "{", "case", "KeyAlgoRSA", ":", "return", "parseRSA", "(", "in", ")", "\n", "case", "KeyAlgoDSA", ":", "return", "parseDSA", "(", "in", ")", "\n", "case", "KeyAlgoECDSA256", ",", "KeyAlgoECDSA384", ",", "KeyAlgoECDSA521", ":", "return", "parseECDSA", "(", "in", ")", "\n", "case", "CertAlgoRSAv01", ",", "CertAlgoDSAv01", ",", "CertAlgoECDSA256v01", ",", "CertAlgoECDSA384v01", ",", "CertAlgoECDSA521v01", ":", "cert", ",", "err", ":=", "parseCert", "(", "in", ",", "certToPrivAlgo", "(", "algo", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "return", "cert", ",", "nil", ",", "nil", "\n", "}", "\n", "return", "nil", ",", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}" ]
// parsePubKey parses a public key of the given algorithm. // Use ParsePublicKey for keys with prepended algorithm.
[ "parsePubKey", "parses", "a", "public", "key", "of", "the", "given", "algorithm", ".", "Use", "ParsePublicKey", "for", "keys", "with", "prepended", "algorithm", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/keys.go#L36-L52
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/keys.go
MarshalAuthorizedKey
func MarshalAuthorizedKey(key PublicKey) []byte { b := &bytes.Buffer{} b.WriteString(key.Type()) b.WriteByte(' ') e := base64.NewEncoder(base64.StdEncoding, b) e.Write(key.Marshal()) e.Close() b.WriteByte('\n') return b.Bytes() }
go
func MarshalAuthorizedKey(key PublicKey) []byte { b := &bytes.Buffer{} b.WriteString(key.Type()) b.WriteByte(' ') e := base64.NewEncoder(base64.StdEncoding, b) e.Write(key.Marshal()) e.Close() b.WriteByte('\n') return b.Bytes() }
[ "func", "MarshalAuthorizedKey", "(", "key", "PublicKey", ")", "[", "]", "byte", "{", "b", ":=", "&", "bytes", ".", "Buffer", "{", "}", "\n", "b", ".", "WriteString", "(", "key", ".", "Type", "(", ")", ")", "\n", "b", ".", "WriteByte", "(", "' '", ")", "\n", "e", ":=", "base64", ".", "NewEncoder", "(", "base64", ".", "StdEncoding", ",", "b", ")", "\n", "e", ".", "Write", "(", "key", ".", "Marshal", "(", ")", ")", "\n", "e", ".", "Close", "(", ")", "\n", "b", ".", "WriteByte", "(", "'\\n'", ")", "\n", "return", "b", ".", "Bytes", "(", ")", "\n", "}" ]
// MarshalAuthorizedKey serializes key for inclusion in an OpenSSH // authorized_keys file. The return value ends with newline.
[ "MarshalAuthorizedKey", "serializes", "key", "for", "inclusion", "in", "an", "OpenSSH", "authorized_keys", "file", ".", "The", "return", "value", "ends", "with", "newline", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/keys.go#L180-L189
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/keys.go
parseRSA
func parseRSA(in []byte) (out PublicKey, rest []byte, err error) { var w struct { E *big.Int N *big.Int Rest []byte `ssh:"rest"` } if err := Unmarshal(in, &w); err != nil { return nil, nil, err } if w.E.BitLen() > 24 { return nil, nil, errors.New("ssh: exponent too large") } e := w.E.Int64() if e < 3 || e&1 == 0 { return nil, nil, errors.New("ssh: incorrect exponent") } var key rsa.PublicKey key.E = int(e) key.N = w.N return (*rsaPublicKey)(&key), w.Rest, nil }
go
func parseRSA(in []byte) (out PublicKey, rest []byte, err error) { var w struct { E *big.Int N *big.Int Rest []byte `ssh:"rest"` } if err := Unmarshal(in, &w); err != nil { return nil, nil, err } if w.E.BitLen() > 24 { return nil, nil, errors.New("ssh: exponent too large") } e := w.E.Int64() if e < 3 || e&1 == 0 { return nil, nil, errors.New("ssh: incorrect exponent") } var key rsa.PublicKey key.E = int(e) key.N = w.N return (*rsaPublicKey)(&key), w.Rest, nil }
[ "func", "parseRSA", "(", "in", "[", "]", "byte", ")", "(", "out", "PublicKey", ",", "rest", "[", "]", "byte", ",", "err", "error", ")", "{", "var", "w", "struct", "{", "E", "*", "big", ".", "Int", "\n", "N", "*", "big", ".", "Int", "\n", "Rest", "[", "]", "byte", "`ssh:\"rest\"`", "\n", "}", "\n", "if", "err", ":=", "Unmarshal", "(", "in", ",", "&", "w", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "if", "w", ".", "E", ".", "BitLen", "(", ")", ">", "24", "{", "return", "nil", ",", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "e", ":=", "w", ".", "E", ".", "Int64", "(", ")", "\n", "if", "e", "<", "3", "||", "e", "&", "1", "==", "0", "{", "return", "nil", ",", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "var", "key", "rsa", ".", "PublicKey", "\n", "key", ".", "E", "=", "int", "(", "e", ")", "\n", "key", ".", "N", "=", "w", ".", "N", "\n", "return", "(", "*", "rsaPublicKey", ")", "(", "&", "key", ")", ",", "w", ".", "Rest", ",", "nil", "\n", "}" ]
// parseRSA parses an RSA key according to RFC 4253, section 6.6.
[ "parseRSA", "parses", "an", "RSA", "key", "according", "to", "RFC", "4253", "section", "6", ".", "6", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/keys.go#L222-L244
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/keys.go
parseDSA
func parseDSA(in []byte) (out PublicKey, rest []byte, err error) { var w struct { P, Q, G, Y *big.Int Rest []byte `ssh:"rest"` } if err := Unmarshal(in, &w); err != nil { return nil, nil, err } key := &dsaPublicKey{ Parameters: dsa.Parameters{ P: w.P, Q: w.Q, G: w.G, }, Y: w.Y, } return key, w.Rest, nil }
go
func parseDSA(in []byte) (out PublicKey, rest []byte, err error) { var w struct { P, Q, G, Y *big.Int Rest []byte `ssh:"rest"` } if err := Unmarshal(in, &w); err != nil { return nil, nil, err } key := &dsaPublicKey{ Parameters: dsa.Parameters{ P: w.P, Q: w.Q, G: w.G, }, Y: w.Y, } return key, w.Rest, nil }
[ "func", "parseDSA", "(", "in", "[", "]", "byte", ")", "(", "out", "PublicKey", ",", "rest", "[", "]", "byte", ",", "err", "error", ")", "{", "var", "w", "struct", "{", "P", ",", "Q", ",", "G", ",", "Y", "*", "big", ".", "Int", "\n", "Rest", "[", "]", "byte", "`ssh:\"rest\"`", "\n", "}", "\n", "if", "err", ":=", "Unmarshal", "(", "in", ",", "&", "w", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "key", ":=", "&", "dsaPublicKey", "{", "Parameters", ":", "dsa", ".", "Parameters", "{", "P", ":", "w", ".", "P", ",", "Q", ":", "w", ".", "Q", ",", "G", ":", "w", ".", "G", ",", "}", ",", "Y", ":", "w", ".", "Y", ",", "}", "\n", "return", "key", ",", "w", ".", "Rest", ",", "nil", "\n", "}" ]
// parseDSA parses an DSA key according to RFC 4253, section 6.6.
[ "parseDSA", "parses", "an", "DSA", "key", "according", "to", "RFC", "4253", "section", "6", ".", "6", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/keys.go#L299-L317
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/keys.go
ecHash
func ecHash(curve elliptic.Curve) crypto.Hash { bitSize := curve.Params().BitSize switch { case bitSize <= 256: return crypto.SHA256 case bitSize <= 384: return crypto.SHA384 } return crypto.SHA512 }
go
func ecHash(curve elliptic.Curve) crypto.Hash { bitSize := curve.Params().BitSize switch { case bitSize <= 256: return crypto.SHA256 case bitSize <= 384: return crypto.SHA384 } return crypto.SHA512 }
[ "func", "ecHash", "(", "curve", "elliptic", ".", "Curve", ")", "crypto", ".", "Hash", "{", "bitSize", ":=", "curve", ".", "Params", "(", ")", ".", "BitSize", "\n", "switch", "{", "case", "bitSize", "<=", "256", ":", "return", "crypto", ".", "SHA256", "\n", "case", "bitSize", "<=", "384", ":", "return", "crypto", ".", "SHA384", "\n", "}", "\n", "return", "crypto", ".", "SHA512", "\n", "}" ]
// ecHash returns the hash to match the given elliptic curve, see RFC // 5656, section 6.2.1
[ "ecHash", "returns", "the", "hash", "to", "match", "the", "given", "elliptic", "curve", "see", "RFC", "5656", "section", "6", ".", "2", ".", "1" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/keys.go#L412-L421
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/keys.go
NewSignerFromKey
func NewSignerFromKey(k interface{}) (Signer, error) { var sshKey Signer switch t := k.(type) { case *rsa.PrivateKey: sshKey = &rsaPrivateKey{t} case *dsa.PrivateKey: sshKey = &dsaPrivateKey{t} case *ecdsa.PrivateKey: if !supportedEllipticCurve(t.Curve) { return nil, errors.New("ssh: only P256, P384 and P521 EC keys are supported.") } sshKey = &ecdsaPrivateKey{t} default: return nil, fmt.Errorf("ssh: unsupported key type %T", k) } return sshKey, nil }
go
func NewSignerFromKey(k interface{}) (Signer, error) { var sshKey Signer switch t := k.(type) { case *rsa.PrivateKey: sshKey = &rsaPrivateKey{t} case *dsa.PrivateKey: sshKey = &dsaPrivateKey{t} case *ecdsa.PrivateKey: if !supportedEllipticCurve(t.Curve) { return nil, errors.New("ssh: only P256, P384 and P521 EC keys are supported.") } sshKey = &ecdsaPrivateKey{t} default: return nil, fmt.Errorf("ssh: unsupported key type %T", k) } return sshKey, nil }
[ "func", "NewSignerFromKey", "(", "k", "interface", "{", "}", ")", "(", "Signer", ",", "error", ")", "{", "var", "sshKey", "Signer", "\n", "switch", "t", ":=", "k", ".", "(", "type", ")", "{", "case", "*", "rsa", ".", "PrivateKey", ":", "sshKey", "=", "&", "rsaPrivateKey", "{", "t", "}", "\n", "case", "*", "dsa", ".", "PrivateKey", ":", "sshKey", "=", "&", "dsaPrivateKey", "{", "t", "}", "\n", "case", "*", "ecdsa", ".", "PrivateKey", ":", "if", "!", "supportedEllipticCurve", "(", "t", ".", "Curve", ")", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "sshKey", "=", "&", "ecdsaPrivateKey", "{", "t", "}", "\n", "default", ":", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "k", ")", "\n", "}", "\n", "return", "sshKey", ",", "nil", "\n", "}" ]
// NewSignerFromKey takes a pointer to rsa, dsa or ecdsa PrivateKey // returns a corresponding Signer instance. EC keys should use P256, // P384 or P521.
[ "NewSignerFromKey", "takes", "a", "pointer", "to", "rsa", "dsa", "or", "ecdsa", "PrivateKey", "returns", "a", "corresponding", "Signer", "instance", ".", "EC", "keys", "should", "use", "P256", "P384", "or", "P521", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/keys.go#L528-L545
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/keys.go
NewPublicKey
func NewPublicKey(k interface{}) (PublicKey, error) { var sshKey PublicKey switch t := k.(type) { case *rsa.PublicKey: sshKey = (*rsaPublicKey)(t) case *ecdsa.PublicKey: if !supportedEllipticCurve(t.Curve) { return nil, errors.New("ssh: only P256, P384 and P521 EC keys are supported.") } sshKey = (*ecdsaPublicKey)(t) case *dsa.PublicKey: sshKey = (*dsaPublicKey)(t) default: return nil, fmt.Errorf("ssh: unsupported key type %T", k) } return sshKey, nil }
go
func NewPublicKey(k interface{}) (PublicKey, error) { var sshKey PublicKey switch t := k.(type) { case *rsa.PublicKey: sshKey = (*rsaPublicKey)(t) case *ecdsa.PublicKey: if !supportedEllipticCurve(t.Curve) { return nil, errors.New("ssh: only P256, P384 and P521 EC keys are supported.") } sshKey = (*ecdsaPublicKey)(t) case *dsa.PublicKey: sshKey = (*dsaPublicKey)(t) default: return nil, fmt.Errorf("ssh: unsupported key type %T", k) } return sshKey, nil }
[ "func", "NewPublicKey", "(", "k", "interface", "{", "}", ")", "(", "PublicKey", ",", "error", ")", "{", "var", "sshKey", "PublicKey", "\n", "switch", "t", ":=", "k", ".", "(", "type", ")", "{", "case", "*", "rsa", ".", "PublicKey", ":", "sshKey", "=", "(", "*", "rsaPublicKey", ")", "(", "t", ")", "\n", "case", "*", "ecdsa", ".", "PublicKey", ":", "if", "!", "supportedEllipticCurve", "(", "t", ".", "Curve", ")", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "sshKey", "=", "(", "*", "ecdsaPublicKey", ")", "(", "t", ")", "\n", "case", "*", "dsa", ".", "PublicKey", ":", "sshKey", "=", "(", "*", "dsaPublicKey", ")", "(", "t", ")", "\n", "default", ":", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "k", ")", "\n", "}", "\n", "return", "sshKey", ",", "nil", "\n", "}" ]
// NewPublicKey takes a pointer to rsa, dsa or ecdsa PublicKey // and returns a corresponding ssh PublicKey instance. EC keys should use P256, P384 or P521.
[ "NewPublicKey", "takes", "a", "pointer", "to", "rsa", "dsa", "or", "ecdsa", "PublicKey", "and", "returns", "a", "corresponding", "ssh", "PublicKey", "instance", ".", "EC", "keys", "should", "use", "P256", "P384", "or", "P521", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/keys.go#L549-L565
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/keys.go
ParsePrivateKey
func ParsePrivateKey(pemBytes []byte) (Signer, error) { key, err := ParseRawPrivateKey(pemBytes) if err != nil { return nil, err } return NewSignerFromKey(key) }
go
func ParsePrivateKey(pemBytes []byte) (Signer, error) { key, err := ParseRawPrivateKey(pemBytes) if err != nil { return nil, err } return NewSignerFromKey(key) }
[ "func", "ParsePrivateKey", "(", "pemBytes", "[", "]", "byte", ")", "(", "Signer", ",", "error", ")", "{", "key", ",", "err", ":=", "ParseRawPrivateKey", "(", "pemBytes", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "NewSignerFromKey", "(", "key", ")", "\n", "}" ]
// ParsePrivateKey returns a Signer from a PEM encoded private key. It supports // the same keys as ParseRawPrivateKey.
[ "ParsePrivateKey", "returns", "a", "Signer", "from", "a", "PEM", "encoded", "private", "key", ".", "It", "supports", "the", "same", "keys", "as", "ParseRawPrivateKey", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/keys.go#L569-L576
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/keys.go
ParseDSAPrivateKey
func ParseDSAPrivateKey(der []byte) (*dsa.PrivateKey, error) { var k struct { Version int P *big.Int Q *big.Int G *big.Int Priv *big.Int Pub *big.Int } rest, err := asn1.Unmarshal(der, &k) if err != nil { return nil, errors.New("ssh: failed to parse DSA key: " + err.Error()) } if len(rest) > 0 { return nil, errors.New("ssh: garbage after DSA key") } return &dsa.PrivateKey{ PublicKey: dsa.PublicKey{ Parameters: dsa.Parameters{ P: k.P, Q: k.Q, G: k.G, }, Y: k.Priv, }, X: k.Pub, }, nil }
go
func ParseDSAPrivateKey(der []byte) (*dsa.PrivateKey, error) { var k struct { Version int P *big.Int Q *big.Int G *big.Int Priv *big.Int Pub *big.Int } rest, err := asn1.Unmarshal(der, &k) if err != nil { return nil, errors.New("ssh: failed to parse DSA key: " + err.Error()) } if len(rest) > 0 { return nil, errors.New("ssh: garbage after DSA key") } return &dsa.PrivateKey{ PublicKey: dsa.PublicKey{ Parameters: dsa.Parameters{ P: k.P, Q: k.Q, G: k.G, }, Y: k.Priv, }, X: k.Pub, }, nil }
[ "func", "ParseDSAPrivateKey", "(", "der", "[", "]", "byte", ")", "(", "*", "dsa", ".", "PrivateKey", ",", "error", ")", "{", "var", "k", "struct", "{", "Version", "int", "\n", "P", "*", "big", ".", "Int", "\n", "Q", "*", "big", ".", "Int", "\n", "G", "*", "big", ".", "Int", "\n", "Priv", "*", "big", ".", "Int", "\n", "Pub", "*", "big", ".", "Int", "\n", "}", "\n", "rest", ",", "err", ":=", "asn1", ".", "Unmarshal", "(", "der", ",", "&", "k", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", "+", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "if", "len", "(", "rest", ")", ">", "0", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "&", "dsa", ".", "PrivateKey", "{", "PublicKey", ":", "dsa", ".", "PublicKey", "{", "Parameters", ":", "dsa", ".", "Parameters", "{", "P", ":", "k", ".", "P", ",", "Q", ":", "k", ".", "Q", ",", "G", ":", "k", ".", "G", ",", "}", ",", "Y", ":", "k", ".", "Priv", ",", "}", ",", "X", ":", "k", ".", "Pub", ",", "}", ",", "nil", "\n", "}" ]
// ParseDSAPrivateKey returns a DSA private key from its ASN.1 DER encoding, as // specified by the OpenSSL DSA man page.
[ "ParseDSAPrivateKey", "returns", "a", "DSA", "private", "key", "from", "its", "ASN", ".", "1", "DER", "encoding", "as", "specified", "by", "the", "OpenSSL", "DSA", "man", "page", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/keys.go#L600-L628
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/proxy_server.go
NewProxyServer
func NewProxyServer(filebase string, apiProxyPrefix string, staticPrefix string, filter *FilterServer, cfg *client.Config) (*ProxyServer, error) { host := cfg.Host if !strings.HasSuffix(host, "/") { host = host + "/" } target, err := url.Parse(host) if err != nil { return nil, err } proxy := newProxy(target) if proxy.Transport, err = client.TransportFor(cfg); err != nil { return nil, err } proxyServer := http.Handler(proxy) if filter != nil { proxyServer = filter.HandlerFor(proxyServer) } if !strings.HasPrefix(apiProxyPrefix, "/api") { proxyServer = stripLeaveSlash(apiProxyPrefix, proxyServer) } mux := http.NewServeMux() mux.Handle(apiProxyPrefix, proxyServer) if filebase != "" { // Require user to explicitly request this behavior rather than // serving their working directory by default. mux.Handle(staticPrefix, newFileHandler(staticPrefix, filebase)) } return &ProxyServer{handler: mux}, nil }
go
func NewProxyServer(filebase string, apiProxyPrefix string, staticPrefix string, filter *FilterServer, cfg *client.Config) (*ProxyServer, error) { host := cfg.Host if !strings.HasSuffix(host, "/") { host = host + "/" } target, err := url.Parse(host) if err != nil { return nil, err } proxy := newProxy(target) if proxy.Transport, err = client.TransportFor(cfg); err != nil { return nil, err } proxyServer := http.Handler(proxy) if filter != nil { proxyServer = filter.HandlerFor(proxyServer) } if !strings.HasPrefix(apiProxyPrefix, "/api") { proxyServer = stripLeaveSlash(apiProxyPrefix, proxyServer) } mux := http.NewServeMux() mux.Handle(apiProxyPrefix, proxyServer) if filebase != "" { // Require user to explicitly request this behavior rather than // serving their working directory by default. mux.Handle(staticPrefix, newFileHandler(staticPrefix, filebase)) } return &ProxyServer{handler: mux}, nil }
[ "func", "NewProxyServer", "(", "filebase", "string", ",", "apiProxyPrefix", "string", ",", "staticPrefix", "string", ",", "filter", "*", "FilterServer", ",", "cfg", "*", "client", ".", "Config", ")", "(", "*", "ProxyServer", ",", "error", ")", "{", "host", ":=", "cfg", ".", "Host", "\n", "if", "!", "strings", ".", "HasSuffix", "(", "host", ",", "\"", "\"", ")", "{", "host", "=", "host", "+", "\"", "\"", "\n", "}", "\n", "target", ",", "err", ":=", "url", ".", "Parse", "(", "host", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "proxy", ":=", "newProxy", "(", "target", ")", "\n", "if", "proxy", ".", "Transport", ",", "err", "=", "client", ".", "TransportFor", "(", "cfg", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "proxyServer", ":=", "http", ".", "Handler", "(", "proxy", ")", "\n", "if", "filter", "!=", "nil", "{", "proxyServer", "=", "filter", ".", "HandlerFor", "(", "proxyServer", ")", "\n", "}", "\n\n", "if", "!", "strings", ".", "HasPrefix", "(", "apiProxyPrefix", ",", "\"", "\"", ")", "{", "proxyServer", "=", "stripLeaveSlash", "(", "apiProxyPrefix", ",", "proxyServer", ")", "\n", "}", "\n\n", "mux", ":=", "http", ".", "NewServeMux", "(", ")", "\n", "mux", ".", "Handle", "(", "apiProxyPrefix", ",", "proxyServer", ")", "\n", "if", "filebase", "!=", "\"", "\"", "{", "// Require user to explicitly request this behavior rather than", "// serving their working directory by default.", "mux", ".", "Handle", "(", "staticPrefix", ",", "newFileHandler", "(", "staticPrefix", ",", "filebase", ")", ")", "\n", "}", "\n", "return", "&", "ProxyServer", "{", "handler", ":", "mux", "}", ",", "nil", "\n", "}" ]
// NewProxyServer creates and installs a new ProxyServer. // It automatically registers the created ProxyServer to http.DefaultServeMux. // 'filter', if non-nil, protects requests to the api only.
[ "NewProxyServer", "creates", "and", "installs", "a", "new", "ProxyServer", ".", "It", "automatically", "registers", "the", "created", "ProxyServer", "to", "http", ".", "DefaultServeMux", ".", "filter", "if", "non", "-", "nil", "protects", "requests", "to", "the", "api", "only", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/proxy_server.go#L149-L179
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/proxy_server.go
ListenUnix
func (s *ProxyServer) ListenUnix(path string) (net.Listener, error) { // Remove any socket, stale or not, but fall through for other files fi, err := os.Stat(path) if err == nil && (fi.Mode()&os.ModeSocket) != 0 { os.Remove(path) } // Default to only user accessible socket, caller can open up later if desired oldmask, _ := util.Umask(0077) l, err := net.Listen("unix", path) util.Umask(oldmask) return l, err }
go
func (s *ProxyServer) ListenUnix(path string) (net.Listener, error) { // Remove any socket, stale or not, but fall through for other files fi, err := os.Stat(path) if err == nil && (fi.Mode()&os.ModeSocket) != 0 { os.Remove(path) } // Default to only user accessible socket, caller can open up later if desired oldmask, _ := util.Umask(0077) l, err := net.Listen("unix", path) util.Umask(oldmask) return l, err }
[ "func", "(", "s", "*", "ProxyServer", ")", "ListenUnix", "(", "path", "string", ")", "(", "net", ".", "Listener", ",", "error", ")", "{", "// Remove any socket, stale or not, but fall through for other files", "fi", ",", "err", ":=", "os", ".", "Stat", "(", "path", ")", "\n", "if", "err", "==", "nil", "&&", "(", "fi", ".", "Mode", "(", ")", "&", "os", ".", "ModeSocket", ")", "!=", "0", "{", "os", ".", "Remove", "(", "path", ")", "\n", "}", "\n", "// Default to only user accessible socket, caller can open up later if desired", "oldmask", ",", "_", ":=", "util", ".", "Umask", "(", "0077", ")", "\n", "l", ",", "err", ":=", "net", ".", "Listen", "(", "\"", "\"", ",", "path", ")", "\n", "util", ".", "Umask", "(", "oldmask", ")", "\n", "return", "l", ",", "err", "\n", "}" ]
// ListenUnix does net.Listen for a unix socket
[ "ListenUnix", "does", "net", ".", "Listen", "for", "a", "unix", "socket" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/proxy_server.go#L187-L198
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/proxy_server.go
ServeOnListener
func (s *ProxyServer) ServeOnListener(l net.Listener) error { server := http.Server{ Handler: s.handler, } return server.Serve(l) }
go
func (s *ProxyServer) ServeOnListener(l net.Listener) error { server := http.Server{ Handler: s.handler, } return server.Serve(l) }
[ "func", "(", "s", "*", "ProxyServer", ")", "ServeOnListener", "(", "l", "net", ".", "Listener", ")", "error", "{", "server", ":=", "http", ".", "Server", "{", "Handler", ":", "s", ".", "handler", ",", "}", "\n", "return", "server", ".", "Serve", "(", "l", ")", "\n", "}" ]
// Serve starts the server using given listener, loops forever.
[ "Serve", "starts", "the", "server", "using", "given", "listener", "loops", "forever", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/proxy_server.go#L201-L206
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/template.go
ExecuteTemplate
func ExecuteTemplate(w io.Writer, templateText string, data interface{}) error { t := template.New("top") t.Funcs(template.FuncMap{ "trim": strings.TrimSpace, "wrap": wrap, }) template.Must(t.Parse(templateText)) return t.Execute(w, data) }
go
func ExecuteTemplate(w io.Writer, templateText string, data interface{}) error { t := template.New("top") t.Funcs(template.FuncMap{ "trim": strings.TrimSpace, "wrap": wrap, }) template.Must(t.Parse(templateText)) return t.Execute(w, data) }
[ "func", "ExecuteTemplate", "(", "w", "io", ".", "Writer", ",", "templateText", "string", ",", "data", "interface", "{", "}", ")", "error", "{", "t", ":=", "template", ".", "New", "(", "\"", "\"", ")", "\n", "t", ".", "Funcs", "(", "template", ".", "FuncMap", "{", "\"", "\"", ":", "strings", ".", "TrimSpace", ",", "\"", "\"", ":", "wrap", ",", "}", ")", "\n", "template", ".", "Must", "(", "t", ".", "Parse", "(", "templateText", ")", ")", "\n", "return", "t", ".", "Execute", "(", "w", ",", "data", ")", "\n", "}" ]
// ExecuteTemplate executes templateText with data and output written to w.
[ "ExecuteTemplate", "executes", "templateText", "with", "data", "and", "output", "written", "to", "w", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/template.go#L34-L42
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/scheme.go
NewScheme
func NewScheme() *Scheme { s := &Scheme{ gvkToType: map[unversioned.GroupVersionKind]reflect.Type{}, typeToGVK: map[reflect.Type][]unversioned.GroupVersionKind{}, converter: NewConverter(), cloner: NewCloner(), // TODO remove this hard coded list. As step one, hardcode it here so this pull doesn't become even bigger InternalVersions: map[string]unversioned.GroupVersion{ "": {}, "componentconfig": {Group: "componentconfig"}, "extensions": {Group: "extensions"}, "metrics": {Group: "metrics"}, }, MetaFactory: DefaultMetaFactory, } s.converter.nameFunc = s.nameFunc return s }
go
func NewScheme() *Scheme { s := &Scheme{ gvkToType: map[unversioned.GroupVersionKind]reflect.Type{}, typeToGVK: map[reflect.Type][]unversioned.GroupVersionKind{}, converter: NewConverter(), cloner: NewCloner(), // TODO remove this hard coded list. As step one, hardcode it here so this pull doesn't become even bigger InternalVersions: map[string]unversioned.GroupVersion{ "": {}, "componentconfig": {Group: "componentconfig"}, "extensions": {Group: "extensions"}, "metrics": {Group: "metrics"}, }, MetaFactory: DefaultMetaFactory, } s.converter.nameFunc = s.nameFunc return s }
[ "func", "NewScheme", "(", ")", "*", "Scheme", "{", "s", ":=", "&", "Scheme", "{", "gvkToType", ":", "map", "[", "unversioned", ".", "GroupVersionKind", "]", "reflect", ".", "Type", "{", "}", ",", "typeToGVK", ":", "map", "[", "reflect", ".", "Type", "]", "[", "]", "unversioned", ".", "GroupVersionKind", "{", "}", ",", "converter", ":", "NewConverter", "(", ")", ",", "cloner", ":", "NewCloner", "(", ")", ",", "// TODO remove this hard coded list. As step one, hardcode it here so this pull doesn't become even bigger", "InternalVersions", ":", "map", "[", "string", "]", "unversioned", ".", "GroupVersion", "{", "\"", "\"", ":", "{", "}", ",", "\"", "\"", ":", "{", "Group", ":", "\"", "\"", "}", ",", "\"", "\"", ":", "{", "Group", ":", "\"", "\"", "}", ",", "\"", "\"", ":", "{", "Group", ":", "\"", "\"", "}", ",", "}", ",", "MetaFactory", ":", "DefaultMetaFactory", ",", "}", "\n", "s", ".", "converter", ".", "nameFunc", "=", "s", ".", "nameFunc", "\n", "return", "s", "\n", "}" ]
// NewScheme manufactures a new scheme.
[ "NewScheme", "manufactures", "a", "new", "scheme", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/scheme.go#L61-L78
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/scheme.go
AddGeneratedConversionFuncs
func (s *Scheme) AddGeneratedConversionFuncs(conversionFuncs ...interface{}) error { for _, f := range conversionFuncs { if err := s.converter.RegisterGeneratedConversionFunc(f); err != nil { return err } } return nil }
go
func (s *Scheme) AddGeneratedConversionFuncs(conversionFuncs ...interface{}) error { for _, f := range conversionFuncs { if err := s.converter.RegisterGeneratedConversionFunc(f); err != nil { return err } } return nil }
[ "func", "(", "s", "*", "Scheme", ")", "AddGeneratedConversionFuncs", "(", "conversionFuncs", "...", "interface", "{", "}", ")", "error", "{", "for", "_", ",", "f", ":=", "range", "conversionFuncs", "{", "if", "err", ":=", "s", ".", "converter", ".", "RegisterGeneratedConversionFunc", "(", "f", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Similar to AddConversionFuncs, but registers conversion functions that were // automatically generated.
[ "Similar", "to", "AddConversionFuncs", "but", "registers", "conversion", "functions", "that", "were", "automatically", "generated", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/scheme.go#L215-L222
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/scheme.go
AddDeepCopyFuncs
func (s *Scheme) AddDeepCopyFuncs(deepCopyFuncs ...interface{}) error { for _, f := range deepCopyFuncs { if err := s.cloner.RegisterDeepCopyFunc(f); err != nil { return err } } return nil }
go
func (s *Scheme) AddDeepCopyFuncs(deepCopyFuncs ...interface{}) error { for _, f := range deepCopyFuncs { if err := s.cloner.RegisterDeepCopyFunc(f); err != nil { return err } } return nil }
[ "func", "(", "s", "*", "Scheme", ")", "AddDeepCopyFuncs", "(", "deepCopyFuncs", "...", "interface", "{", "}", ")", "error", "{", "for", "_", ",", "f", ":=", "range", "deepCopyFuncs", "{", "if", "err", ":=", "s", ".", "cloner", ".", "RegisterDeepCopyFunc", "(", "f", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// AddDeepCopyFuncs adds functions to the list of deep copy functions. // Note that to copy sub-objects, you can use the conversion.Cloner object that // will be passed to your deep-copy function.
[ "AddDeepCopyFuncs", "adds", "functions", "to", "the", "list", "of", "deep", "copy", "functions", ".", "Note", "that", "to", "copy", "sub", "-", "objects", "you", "can", "use", "the", "conversion", ".", "Cloner", "object", "that", "will", "be", "passed", "to", "your", "deep", "-", "copy", "function", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/scheme.go#L227-L234
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/scheme.go
AddGeneratedDeepCopyFuncs
func (s *Scheme) AddGeneratedDeepCopyFuncs(deepCopyFuncs ...interface{}) error { for _, f := range deepCopyFuncs { if err := s.cloner.RegisterGeneratedDeepCopyFunc(f); err != nil { return err } } return nil }
go
func (s *Scheme) AddGeneratedDeepCopyFuncs(deepCopyFuncs ...interface{}) error { for _, f := range deepCopyFuncs { if err := s.cloner.RegisterGeneratedDeepCopyFunc(f); err != nil { return err } } return nil }
[ "func", "(", "s", "*", "Scheme", ")", "AddGeneratedDeepCopyFuncs", "(", "deepCopyFuncs", "...", "interface", "{", "}", ")", "error", "{", "for", "_", ",", "f", ":=", "range", "deepCopyFuncs", "{", "if", "err", ":=", "s", ".", "cloner", ".", "RegisterGeneratedDeepCopyFunc", "(", "f", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Similar to AddDeepCopyFuncs, but registers deep copy functions that were // automatically generated.
[ "Similar", "to", "AddDeepCopyFuncs", "but", "registers", "deep", "copy", "functions", "that", "were", "automatically", "generated", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/scheme.go#L238-L245
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/scheme.go
AddStructFieldConversion
func (s *Scheme) AddStructFieldConversion(srcFieldType interface{}, srcFieldName string, destFieldType interface{}, destFieldName string) error { return s.converter.SetStructFieldCopy(srcFieldType, srcFieldName, destFieldType, destFieldName) }
go
func (s *Scheme) AddStructFieldConversion(srcFieldType interface{}, srcFieldName string, destFieldType interface{}, destFieldName string) error { return s.converter.SetStructFieldCopy(srcFieldType, srcFieldName, destFieldType, destFieldName) }
[ "func", "(", "s", "*", "Scheme", ")", "AddStructFieldConversion", "(", "srcFieldType", "interface", "{", "}", ",", "srcFieldName", "string", ",", "destFieldType", "interface", "{", "}", ",", "destFieldName", "string", ")", "error", "{", "return", "s", ".", "converter", ".", "SetStructFieldCopy", "(", "srcFieldType", ",", "srcFieldName", ",", "destFieldType", ",", "destFieldName", ")", "\n", "}" ]
// AddStructFieldConversion allows you to specify a mechanical copy for a moved // or renamed struct field without writing an entire conversion function. See // the comment in Converter.SetStructFieldCopy for parameter details. // Call as many times as needed, even on the same fields.
[ "AddStructFieldConversion", "allows", "you", "to", "specify", "a", "mechanical", "copy", "for", "a", "moved", "or", "renamed", "struct", "field", "without", "writing", "an", "entire", "conversion", "function", ".", "See", "the", "comment", "in", "Converter", ".", "SetStructFieldCopy", "for", "parameter", "details", ".", "Call", "as", "many", "times", "as", "needed", "even", "on", "the", "same", "fields", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/scheme.go#L251-L253
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/proxy/transport.go
rewriteResponse
func (t *Transport) rewriteResponse(req *http.Request, resp *http.Response) (*http.Response, error) { origBody := resp.Body defer origBody.Close() newContent := &bytes.Buffer{} var reader io.Reader = origBody var writer io.Writer = newContent encoding := resp.Header.Get("Content-Encoding") switch encoding { case "gzip": var err error reader, err = gzip.NewReader(reader) if err != nil { return nil, fmt.Errorf("errorf making gzip reader: %v", err) } gzw := gzip.NewWriter(writer) defer gzw.Close() writer = gzw // TODO: support flate, other encodings. case "": // This is fine default: // Some encoding we don't understand-- don't try to parse this glog.Errorf("Proxy encountered encoding %v for text/html; can't understand this so not fixing links.", encoding) return resp, nil } urlRewriter := func(targetUrl string) string { return t.rewriteURL(targetUrl, req.URL) } err := rewriteHTML(reader, writer, urlRewriter) if err != nil { glog.Errorf("Failed to rewrite URLs: %v", err) return resp, err } resp.Body = ioutil.NopCloser(newContent) // Update header node with new content-length // TODO: Remove any hash/signature headers here? resp.Header.Del("Content-Length") resp.ContentLength = int64(newContent.Len()) return resp, err }
go
func (t *Transport) rewriteResponse(req *http.Request, resp *http.Response) (*http.Response, error) { origBody := resp.Body defer origBody.Close() newContent := &bytes.Buffer{} var reader io.Reader = origBody var writer io.Writer = newContent encoding := resp.Header.Get("Content-Encoding") switch encoding { case "gzip": var err error reader, err = gzip.NewReader(reader) if err != nil { return nil, fmt.Errorf("errorf making gzip reader: %v", err) } gzw := gzip.NewWriter(writer) defer gzw.Close() writer = gzw // TODO: support flate, other encodings. case "": // This is fine default: // Some encoding we don't understand-- don't try to parse this glog.Errorf("Proxy encountered encoding %v for text/html; can't understand this so not fixing links.", encoding) return resp, nil } urlRewriter := func(targetUrl string) string { return t.rewriteURL(targetUrl, req.URL) } err := rewriteHTML(reader, writer, urlRewriter) if err != nil { glog.Errorf("Failed to rewrite URLs: %v", err) return resp, err } resp.Body = ioutil.NopCloser(newContent) // Update header node with new content-length // TODO: Remove any hash/signature headers here? resp.Header.Del("Content-Length") resp.ContentLength = int64(newContent.Len()) return resp, err }
[ "func", "(", "t", "*", "Transport", ")", "rewriteResponse", "(", "req", "*", "http", ".", "Request", ",", "resp", "*", "http", ".", "Response", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "origBody", ":=", "resp", ".", "Body", "\n", "defer", "origBody", ".", "Close", "(", ")", "\n\n", "newContent", ":=", "&", "bytes", ".", "Buffer", "{", "}", "\n", "var", "reader", "io", ".", "Reader", "=", "origBody", "\n", "var", "writer", "io", ".", "Writer", "=", "newContent", "\n", "encoding", ":=", "resp", ".", "Header", ".", "Get", "(", "\"", "\"", ")", "\n", "switch", "encoding", "{", "case", "\"", "\"", ":", "var", "err", "error", "\n", "reader", ",", "err", "=", "gzip", ".", "NewReader", "(", "reader", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "gzw", ":=", "gzip", ".", "NewWriter", "(", "writer", ")", "\n", "defer", "gzw", ".", "Close", "(", ")", "\n", "writer", "=", "gzw", "\n", "// TODO: support flate, other encodings.", "case", "\"", "\"", ":", "// This is fine", "default", ":", "// Some encoding we don't understand-- don't try to parse this", "glog", ".", "Errorf", "(", "\"", "\"", ",", "encoding", ")", "\n", "return", "resp", ",", "nil", "\n", "}", "\n\n", "urlRewriter", ":=", "func", "(", "targetUrl", "string", ")", "string", "{", "return", "t", ".", "rewriteURL", "(", "targetUrl", ",", "req", ".", "URL", ")", "\n", "}", "\n", "err", ":=", "rewriteHTML", "(", "reader", ",", "writer", ",", "urlRewriter", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "return", "resp", ",", "err", "\n", "}", "\n\n", "resp", ".", "Body", "=", "ioutil", ".", "NopCloser", "(", "newContent", ")", "\n", "// Update header node with new content-length", "// TODO: Remove any hash/signature headers here?", "resp", ".", "Header", ".", "Del", "(", "\"", "\"", ")", "\n", "resp", ".", "ContentLength", "=", "int64", "(", "newContent", ".", "Len", "(", ")", ")", "\n\n", "return", "resp", ",", "err", "\n", "}" ]
// rewriteResponse modifies an HTML response by updating absolute links referring // to the original host to instead refer to the proxy transport.
[ "rewriteResponse", "modifies", "an", "HTML", "response", "by", "updating", "absolute", "links", "referring", "to", "the", "original", "host", "to", "instead", "refer", "to", "the", "proxy", "transport", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/proxy/transport.go#L198-L241
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/client.go
String
func (k *Key) String() string { s := string(k.Format) + " " + base64.StdEncoding.EncodeToString(k.Blob) if k.Comment != "" { s += " " + k.Comment } return s }
go
func (k *Key) String() string { s := string(k.Format) + " " + base64.StdEncoding.EncodeToString(k.Blob) if k.Comment != "" { s += " " + k.Comment } return s }
[ "func", "(", "k", "*", "Key", ")", "String", "(", ")", "string", "{", "s", ":=", "string", "(", "k", ".", "Format", ")", "+", "\"", "\"", "+", "base64", ".", "StdEncoding", ".", "EncodeToString", "(", "k", ".", "Blob", ")", "\n\n", "if", "k", ".", "Comment", "!=", "\"", "\"", "{", "s", "+=", "\"", "\"", "+", "k", ".", "Comment", "\n", "}", "\n\n", "return", "s", "\n", "}" ]
// String returns the storage form of an agent key with the format, base64 // encoded serialized key, and the comment if it is not empty.
[ "String", "returns", "the", "storage", "form", "of", "an", "agent", "key", "with", "the", "format", "base64", "encoded", "serialized", "key", "and", "the", "comment", "if", "it", "is", "not", "empty", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/client.go#L148-L156
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/client.go
Verify
func (k *Key) Verify(data []byte, sig *ssh.Signature) error { return errors.New("agent: agent key does not know how to verify") }
go
func (k *Key) Verify(data []byte, sig *ssh.Signature) error { return errors.New("agent: agent key does not know how to verify") }
[ "func", "(", "k", "*", "Key", ")", "Verify", "(", "data", "[", "]", "byte", ",", "sig", "*", "ssh", ".", "Signature", ")", "error", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}" ]
// Verify satisfies the ssh.PublicKey interface, but is not // implemented for agent keys.
[ "Verify", "satisfies", "the", "ssh", ".", "PublicKey", "interface", "but", "is", "not", "implemented", "for", "agent", "keys", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/client.go#L170-L172
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/client.go
call
func (c *client) call(req []byte) (reply interface{}, err error) { c.mu.Lock() defer c.mu.Unlock() msg := make([]byte, 4+len(req)) binary.BigEndian.PutUint32(msg, uint32(len(req))) copy(msg[4:], req) if _, err = c.conn.Write(msg); err != nil { return nil, clientErr(err) } var respSizeBuf [4]byte if _, err = io.ReadFull(c.conn, respSizeBuf[:]); err != nil { return nil, clientErr(err) } respSize := binary.BigEndian.Uint32(respSizeBuf[:]) if respSize > maxAgentResponseBytes { return nil, clientErr(err) } buf := make([]byte, respSize) if _, err = io.ReadFull(c.conn, buf); err != nil { return nil, clientErr(err) } reply, err = unmarshal(buf) if err != nil { return nil, clientErr(err) } return reply, err }
go
func (c *client) call(req []byte) (reply interface{}, err error) { c.mu.Lock() defer c.mu.Unlock() msg := make([]byte, 4+len(req)) binary.BigEndian.PutUint32(msg, uint32(len(req))) copy(msg[4:], req) if _, err = c.conn.Write(msg); err != nil { return nil, clientErr(err) } var respSizeBuf [4]byte if _, err = io.ReadFull(c.conn, respSizeBuf[:]); err != nil { return nil, clientErr(err) } respSize := binary.BigEndian.Uint32(respSizeBuf[:]) if respSize > maxAgentResponseBytes { return nil, clientErr(err) } buf := make([]byte, respSize) if _, err = io.ReadFull(c.conn, buf); err != nil { return nil, clientErr(err) } reply, err = unmarshal(buf) if err != nil { return nil, clientErr(err) } return reply, err }
[ "func", "(", "c", "*", "client", ")", "call", "(", "req", "[", "]", "byte", ")", "(", "reply", "interface", "{", "}", ",", "err", "error", ")", "{", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "msg", ":=", "make", "(", "[", "]", "byte", ",", "4", "+", "len", "(", "req", ")", ")", "\n", "binary", ".", "BigEndian", ".", "PutUint32", "(", "msg", ",", "uint32", "(", "len", "(", "req", ")", ")", ")", "\n", "copy", "(", "msg", "[", "4", ":", "]", ",", "req", ")", "\n", "if", "_", ",", "err", "=", "c", ".", "conn", ".", "Write", "(", "msg", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "clientErr", "(", "err", ")", "\n", "}", "\n\n", "var", "respSizeBuf", "[", "4", "]", "byte", "\n", "if", "_", ",", "err", "=", "io", ".", "ReadFull", "(", "c", ".", "conn", ",", "respSizeBuf", "[", ":", "]", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "clientErr", "(", "err", ")", "\n", "}", "\n", "respSize", ":=", "binary", ".", "BigEndian", ".", "Uint32", "(", "respSizeBuf", "[", ":", "]", ")", "\n", "if", "respSize", ">", "maxAgentResponseBytes", "{", "return", "nil", ",", "clientErr", "(", "err", ")", "\n", "}", "\n\n", "buf", ":=", "make", "(", "[", "]", "byte", ",", "respSize", ")", "\n", "if", "_", ",", "err", "=", "io", ".", "ReadFull", "(", "c", ".", "conn", ",", "buf", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "clientErr", "(", "err", ")", "\n", "}", "\n", "reply", ",", "err", "=", "unmarshal", "(", "buf", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "clientErr", "(", "err", ")", "\n", "}", "\n", "return", "reply", ",", "err", "\n", "}" ]
// call sends an RPC to the agent. On success, the reply is // unmarshaled into reply and replyType is set to the first byte of // the reply, which contains the type of the message.
[ "call", "sends", "an", "RPC", "to", "the", "agent", ".", "On", "success", "the", "reply", "is", "unmarshaled", "into", "reply", "and", "replyType", "is", "set", "to", "the", "first", "byte", "of", "the", "reply", "which", "contains", "the", "type", "of", "the", "message", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/client.go#L219-L248
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/client.go
unmarshal
func unmarshal(packet []byte) (interface{}, error) { if len(packet) < 1 { return nil, errors.New("agent: empty packet") } var msg interface{} switch packet[0] { case agentFailure: return new(failureAgentMsg), nil case agentSuccess: return new(successAgentMsg), nil case agentIdentitiesAnswer: msg = new(identitiesAnswerAgentMsg) case agentSignResponse: msg = new(signResponseAgentMsg) default: return nil, fmt.Errorf("agent: unknown type tag %d", packet[0]) } if err := ssh.Unmarshal(packet, msg); err != nil { return nil, err } return msg, nil }
go
func unmarshal(packet []byte) (interface{}, error) { if len(packet) < 1 { return nil, errors.New("agent: empty packet") } var msg interface{} switch packet[0] { case agentFailure: return new(failureAgentMsg), nil case agentSuccess: return new(successAgentMsg), nil case agentIdentitiesAnswer: msg = new(identitiesAnswerAgentMsg) case agentSignResponse: msg = new(signResponseAgentMsg) default: return nil, fmt.Errorf("agent: unknown type tag %d", packet[0]) } if err := ssh.Unmarshal(packet, msg); err != nil { return nil, err } return msg, nil }
[ "func", "unmarshal", "(", "packet", "[", "]", "byte", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "if", "len", "(", "packet", ")", "<", "1", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "var", "msg", "interface", "{", "}", "\n", "switch", "packet", "[", "0", "]", "{", "case", "agentFailure", ":", "return", "new", "(", "failureAgentMsg", ")", ",", "nil", "\n", "case", "agentSuccess", ":", "return", "new", "(", "successAgentMsg", ")", ",", "nil", "\n", "case", "agentIdentitiesAnswer", ":", "msg", "=", "new", "(", "identitiesAnswerAgentMsg", ")", "\n", "case", "agentSignResponse", ":", "msg", "=", "new", "(", "signResponseAgentMsg", ")", "\n", "default", ":", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "packet", "[", "0", "]", ")", "\n", "}", "\n", "if", "err", ":=", "ssh", ".", "Unmarshal", "(", "packet", ",", "msg", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "msg", ",", "nil", "\n", "}" ]
// unmarshal parses an agent message in packet, returning the parsed // form and the message type of packet.
[ "unmarshal", "parses", "an", "agent", "message", "in", "packet", "returning", "the", "parsed", "form", "and", "the", "message", "type", "of", "packet", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/client.go#L347-L368
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/client.go
insertKey
func (c *client) insertKey(s interface{}, comment string) error { var req []byte switch k := s.(type) { case *rsa.PrivateKey: if len(k.Primes) != 2 { return fmt.Errorf("agent: unsupported RSA key with %d primes", len(k.Primes)) } k.Precompute() req = ssh.Marshal(rsaKeyMsg{ Type: ssh.KeyAlgoRSA, N: k.N, E: big.NewInt(int64(k.E)), D: k.D, Iqmp: k.Precomputed.Qinv, P: k.Primes[0], Q: k.Primes[1], Comments: comment, }) case *dsa.PrivateKey: req = ssh.Marshal(dsaKeyMsg{ Type: ssh.KeyAlgoDSA, P: k.P, Q: k.Q, G: k.G, Y: k.Y, X: k.X, Comments: comment, }) case *ecdsa.PrivateKey: nistID := fmt.Sprintf("nistp%d", k.Params().BitSize) req = ssh.Marshal(ecdsaKeyMsg{ Type: "ecdsa-sha2-" + nistID, Curve: nistID, KeyBytes: elliptic.Marshal(k.Curve, k.X, k.Y), D: k.D, Comments: comment, }) default: return fmt.Errorf("agent: unsupported key type %T", s) } resp, err := c.call(req) if err != nil { return err } if _, ok := resp.(*successAgentMsg); ok { return nil } return errors.New("agent: failure") }
go
func (c *client) insertKey(s interface{}, comment string) error { var req []byte switch k := s.(type) { case *rsa.PrivateKey: if len(k.Primes) != 2 { return fmt.Errorf("agent: unsupported RSA key with %d primes", len(k.Primes)) } k.Precompute() req = ssh.Marshal(rsaKeyMsg{ Type: ssh.KeyAlgoRSA, N: k.N, E: big.NewInt(int64(k.E)), D: k.D, Iqmp: k.Precomputed.Qinv, P: k.Primes[0], Q: k.Primes[1], Comments: comment, }) case *dsa.PrivateKey: req = ssh.Marshal(dsaKeyMsg{ Type: ssh.KeyAlgoDSA, P: k.P, Q: k.Q, G: k.G, Y: k.Y, X: k.X, Comments: comment, }) case *ecdsa.PrivateKey: nistID := fmt.Sprintf("nistp%d", k.Params().BitSize) req = ssh.Marshal(ecdsaKeyMsg{ Type: "ecdsa-sha2-" + nistID, Curve: nistID, KeyBytes: elliptic.Marshal(k.Curve, k.X, k.Y), D: k.D, Comments: comment, }) default: return fmt.Errorf("agent: unsupported key type %T", s) } resp, err := c.call(req) if err != nil { return err } if _, ok := resp.(*successAgentMsg); ok { return nil } return errors.New("agent: failure") }
[ "func", "(", "c", "*", "client", ")", "insertKey", "(", "s", "interface", "{", "}", ",", "comment", "string", ")", "error", "{", "var", "req", "[", "]", "byte", "\n", "switch", "k", ":=", "s", ".", "(", "type", ")", "{", "case", "*", "rsa", ".", "PrivateKey", ":", "if", "len", "(", "k", ".", "Primes", ")", "!=", "2", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "len", "(", "k", ".", "Primes", ")", ")", "\n", "}", "\n", "k", ".", "Precompute", "(", ")", "\n", "req", "=", "ssh", ".", "Marshal", "(", "rsaKeyMsg", "{", "Type", ":", "ssh", ".", "KeyAlgoRSA", ",", "N", ":", "k", ".", "N", ",", "E", ":", "big", ".", "NewInt", "(", "int64", "(", "k", ".", "E", ")", ")", ",", "D", ":", "k", ".", "D", ",", "Iqmp", ":", "k", ".", "Precomputed", ".", "Qinv", ",", "P", ":", "k", ".", "Primes", "[", "0", "]", ",", "Q", ":", "k", ".", "Primes", "[", "1", "]", ",", "Comments", ":", "comment", ",", "}", ")", "\n", "case", "*", "dsa", ".", "PrivateKey", ":", "req", "=", "ssh", ".", "Marshal", "(", "dsaKeyMsg", "{", "Type", ":", "ssh", ".", "KeyAlgoDSA", ",", "P", ":", "k", ".", "P", ",", "Q", ":", "k", ".", "Q", ",", "G", ":", "k", ".", "G", ",", "Y", ":", "k", ".", "Y", ",", "X", ":", "k", ".", "X", ",", "Comments", ":", "comment", ",", "}", ")", "\n", "case", "*", "ecdsa", ".", "PrivateKey", ":", "nistID", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "k", ".", "Params", "(", ")", ".", "BitSize", ")", "\n", "req", "=", "ssh", ".", "Marshal", "(", "ecdsaKeyMsg", "{", "Type", ":", "\"", "\"", "+", "nistID", ",", "Curve", ":", "nistID", ",", "KeyBytes", ":", "elliptic", ".", "Marshal", "(", "k", ".", "Curve", ",", "k", ".", "X", ",", "k", ".", "Y", ")", ",", "D", ":", "k", ".", "D", ",", "Comments", ":", "comment", ",", "}", ")", "\n", "default", ":", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "s", ")", "\n", "}", "\n", "resp", ",", "err", ":=", "c", ".", "call", "(", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "_", ",", "ok", ":=", "resp", ".", "(", "*", "successAgentMsg", ")", ";", "ok", "{", "return", "nil", "\n", "}", "\n", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}" ]
// Insert adds a private key to the agent.
[ "Insert", "adds", "a", "private", "key", "to", "the", "agent", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/client.go#L400-L448
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/client.go
Signers
func (c *client) Signers() ([]ssh.Signer, error) { keys, err := c.List() if err != nil { return nil, err } var result []ssh.Signer for _, k := range keys { result = append(result, &agentKeyringSigner{c, k}) } return result, nil }
go
func (c *client) Signers() ([]ssh.Signer, error) { keys, err := c.List() if err != nil { return nil, err } var result []ssh.Signer for _, k := range keys { result = append(result, &agentKeyringSigner{c, k}) } return result, nil }
[ "func", "(", "c", "*", "client", ")", "Signers", "(", ")", "(", "[", "]", "ssh", ".", "Signer", ",", "error", ")", "{", "keys", ",", "err", ":=", "c", ".", "List", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "result", "[", "]", "ssh", ".", "Signer", "\n", "for", "_", ",", "k", ":=", "range", "keys", "{", "result", "=", "append", "(", "result", ",", "&", "agentKeyringSigner", "{", "c", ",", "k", "}", ")", "\n", "}", "\n", "return", "result", ",", "nil", "\n", "}" ]
// Signers provides a callback for client authentication.
[ "Signers", "provides", "a", "callback", "for", "client", "authentication", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/client.go#L538-L549
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/readerc.go
yaml_parser_set_reader_error
func yaml_parser_set_reader_error(parser *yaml_parser_t, problem string, offset int, value int) bool { parser.error = yaml_READER_ERROR parser.problem = problem parser.problem_offset = offset parser.problem_value = value return false }
go
func yaml_parser_set_reader_error(parser *yaml_parser_t, problem string, offset int, value int) bool { parser.error = yaml_READER_ERROR parser.problem = problem parser.problem_offset = offset parser.problem_value = value return false }
[ "func", "yaml_parser_set_reader_error", "(", "parser", "*", "yaml_parser_t", ",", "problem", "string", ",", "offset", "int", ",", "value", "int", ")", "bool", "{", "parser", ".", "error", "=", "yaml_READER_ERROR", "\n", "parser", ".", "problem", "=", "problem", "\n", "parser", ".", "problem_offset", "=", "offset", "\n", "parser", ".", "problem_value", "=", "value", "\n", "return", "false", "\n", "}" ]
// Set the reader error and return 0.
[ "Set", "the", "reader", "error", "and", "return", "0", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/readerc.go#L8-L14
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/readerc.go
yaml_parser_determine_encoding
func yaml_parser_determine_encoding(parser *yaml_parser_t) bool { // Ensure that we had enough bytes in the raw buffer. for !parser.eof && len(parser.raw_buffer)-parser.raw_buffer_pos < 3 { if !yaml_parser_update_raw_buffer(parser) { return false } } // Determine the encoding. buf := parser.raw_buffer pos := parser.raw_buffer_pos avail := len(buf) - pos if avail >= 2 && buf[pos] == bom_UTF16LE[0] && buf[pos+1] == bom_UTF16LE[1] { parser.encoding = yaml_UTF16LE_ENCODING parser.raw_buffer_pos += 2 parser.offset += 2 } else if avail >= 2 && buf[pos] == bom_UTF16BE[0] && buf[pos+1] == bom_UTF16BE[1] { parser.encoding = yaml_UTF16BE_ENCODING parser.raw_buffer_pos += 2 parser.offset += 2 } else if avail >= 3 && buf[pos] == bom_UTF8[0] && buf[pos+1] == bom_UTF8[1] && buf[pos+2] == bom_UTF8[2] { parser.encoding = yaml_UTF8_ENCODING parser.raw_buffer_pos += 3 parser.offset += 3 } else { parser.encoding = yaml_UTF8_ENCODING } return true }
go
func yaml_parser_determine_encoding(parser *yaml_parser_t) bool { // Ensure that we had enough bytes in the raw buffer. for !parser.eof && len(parser.raw_buffer)-parser.raw_buffer_pos < 3 { if !yaml_parser_update_raw_buffer(parser) { return false } } // Determine the encoding. buf := parser.raw_buffer pos := parser.raw_buffer_pos avail := len(buf) - pos if avail >= 2 && buf[pos] == bom_UTF16LE[0] && buf[pos+1] == bom_UTF16LE[1] { parser.encoding = yaml_UTF16LE_ENCODING parser.raw_buffer_pos += 2 parser.offset += 2 } else if avail >= 2 && buf[pos] == bom_UTF16BE[0] && buf[pos+1] == bom_UTF16BE[1] { parser.encoding = yaml_UTF16BE_ENCODING parser.raw_buffer_pos += 2 parser.offset += 2 } else if avail >= 3 && buf[pos] == bom_UTF8[0] && buf[pos+1] == bom_UTF8[1] && buf[pos+2] == bom_UTF8[2] { parser.encoding = yaml_UTF8_ENCODING parser.raw_buffer_pos += 3 parser.offset += 3 } else { parser.encoding = yaml_UTF8_ENCODING } return true }
[ "func", "yaml_parser_determine_encoding", "(", "parser", "*", "yaml_parser_t", ")", "bool", "{", "// Ensure that we had enough bytes in the raw buffer.", "for", "!", "parser", ".", "eof", "&&", "len", "(", "parser", ".", "raw_buffer", ")", "-", "parser", ".", "raw_buffer_pos", "<", "3", "{", "if", "!", "yaml_parser_update_raw_buffer", "(", "parser", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n\n", "// Determine the encoding.", "buf", ":=", "parser", ".", "raw_buffer", "\n", "pos", ":=", "parser", ".", "raw_buffer_pos", "\n", "avail", ":=", "len", "(", "buf", ")", "-", "pos", "\n", "if", "avail", ">=", "2", "&&", "buf", "[", "pos", "]", "==", "bom_UTF16LE", "[", "0", "]", "&&", "buf", "[", "pos", "+", "1", "]", "==", "bom_UTF16LE", "[", "1", "]", "{", "parser", ".", "encoding", "=", "yaml_UTF16LE_ENCODING", "\n", "parser", ".", "raw_buffer_pos", "+=", "2", "\n", "parser", ".", "offset", "+=", "2", "\n", "}", "else", "if", "avail", ">=", "2", "&&", "buf", "[", "pos", "]", "==", "bom_UTF16BE", "[", "0", "]", "&&", "buf", "[", "pos", "+", "1", "]", "==", "bom_UTF16BE", "[", "1", "]", "{", "parser", ".", "encoding", "=", "yaml_UTF16BE_ENCODING", "\n", "parser", ".", "raw_buffer_pos", "+=", "2", "\n", "parser", ".", "offset", "+=", "2", "\n", "}", "else", "if", "avail", ">=", "3", "&&", "buf", "[", "pos", "]", "==", "bom_UTF8", "[", "0", "]", "&&", "buf", "[", "pos", "+", "1", "]", "==", "bom_UTF8", "[", "1", "]", "&&", "buf", "[", "pos", "+", "2", "]", "==", "bom_UTF8", "[", "2", "]", "{", "parser", ".", "encoding", "=", "yaml_UTF8_ENCODING", "\n", "parser", ".", "raw_buffer_pos", "+=", "3", "\n", "parser", ".", "offset", "+=", "3", "\n", "}", "else", "{", "parser", ".", "encoding", "=", "yaml_UTF8_ENCODING", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Determine the input stream encoding by checking the BOM symbol. If no BOM is // found, the UTF-8 encoding is assumed. Return 1 on success, 0 on failure.
[ "Determine", "the", "input", "stream", "encoding", "by", "checking", "the", "BOM", "symbol", ".", "If", "no", "BOM", "is", "found", "the", "UTF", "-", "8", "encoding", "is", "assumed", ".", "Return", "1", "on", "success", "0", "on", "failure", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/readerc.go#L25-L53
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/readerc.go
yaml_parser_update_raw_buffer
func yaml_parser_update_raw_buffer(parser *yaml_parser_t) bool { size_read := 0 // Return if the raw buffer is full. if parser.raw_buffer_pos == 0 && len(parser.raw_buffer) == cap(parser.raw_buffer) { return true } // Return on EOF. if parser.eof { return true } // Move the remaining bytes in the raw buffer to the beginning. if parser.raw_buffer_pos > 0 && parser.raw_buffer_pos < len(parser.raw_buffer) { copy(parser.raw_buffer, parser.raw_buffer[parser.raw_buffer_pos:]) } parser.raw_buffer = parser.raw_buffer[:len(parser.raw_buffer)-parser.raw_buffer_pos] parser.raw_buffer_pos = 0 // Call the read handler to fill the buffer. size_read, err := parser.read_handler(parser, parser.raw_buffer[len(parser.raw_buffer):cap(parser.raw_buffer)]) parser.raw_buffer = parser.raw_buffer[:len(parser.raw_buffer)+size_read] if err == io.EOF { parser.eof = true } else if err != nil { return yaml_parser_set_reader_error(parser, "input error: "+err.Error(), parser.offset, -1) } return true }
go
func yaml_parser_update_raw_buffer(parser *yaml_parser_t) bool { size_read := 0 // Return if the raw buffer is full. if parser.raw_buffer_pos == 0 && len(parser.raw_buffer) == cap(parser.raw_buffer) { return true } // Return on EOF. if parser.eof { return true } // Move the remaining bytes in the raw buffer to the beginning. if parser.raw_buffer_pos > 0 && parser.raw_buffer_pos < len(parser.raw_buffer) { copy(parser.raw_buffer, parser.raw_buffer[parser.raw_buffer_pos:]) } parser.raw_buffer = parser.raw_buffer[:len(parser.raw_buffer)-parser.raw_buffer_pos] parser.raw_buffer_pos = 0 // Call the read handler to fill the buffer. size_read, err := parser.read_handler(parser, parser.raw_buffer[len(parser.raw_buffer):cap(parser.raw_buffer)]) parser.raw_buffer = parser.raw_buffer[:len(parser.raw_buffer)+size_read] if err == io.EOF { parser.eof = true } else if err != nil { return yaml_parser_set_reader_error(parser, "input error: "+err.Error(), parser.offset, -1) } return true }
[ "func", "yaml_parser_update_raw_buffer", "(", "parser", "*", "yaml_parser_t", ")", "bool", "{", "size_read", ":=", "0", "\n\n", "// Return if the raw buffer is full.", "if", "parser", ".", "raw_buffer_pos", "==", "0", "&&", "len", "(", "parser", ".", "raw_buffer", ")", "==", "cap", "(", "parser", ".", "raw_buffer", ")", "{", "return", "true", "\n", "}", "\n\n", "// Return on EOF.", "if", "parser", ".", "eof", "{", "return", "true", "\n", "}", "\n\n", "// Move the remaining bytes in the raw buffer to the beginning.", "if", "parser", ".", "raw_buffer_pos", ">", "0", "&&", "parser", ".", "raw_buffer_pos", "<", "len", "(", "parser", ".", "raw_buffer", ")", "{", "copy", "(", "parser", ".", "raw_buffer", ",", "parser", ".", "raw_buffer", "[", "parser", ".", "raw_buffer_pos", ":", "]", ")", "\n", "}", "\n", "parser", ".", "raw_buffer", "=", "parser", ".", "raw_buffer", "[", ":", "len", "(", "parser", ".", "raw_buffer", ")", "-", "parser", ".", "raw_buffer_pos", "]", "\n", "parser", ".", "raw_buffer_pos", "=", "0", "\n\n", "// Call the read handler to fill the buffer.", "size_read", ",", "err", ":=", "parser", ".", "read_handler", "(", "parser", ",", "parser", ".", "raw_buffer", "[", "len", "(", "parser", ".", "raw_buffer", ")", ":", "cap", "(", "parser", ".", "raw_buffer", ")", "]", ")", "\n", "parser", ".", "raw_buffer", "=", "parser", ".", "raw_buffer", "[", ":", "len", "(", "parser", ".", "raw_buffer", ")", "+", "size_read", "]", "\n", "if", "err", "==", "io", ".", "EOF", "{", "parser", ".", "eof", "=", "true", "\n", "}", "else", "if", "err", "!=", "nil", "{", "return", "yaml_parser_set_reader_error", "(", "parser", ",", "\"", "\"", "+", "err", ".", "Error", "(", ")", ",", "parser", ".", "offset", ",", "-", "1", ")", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Update the raw buffer.
[ "Update", "the", "raw", "buffer", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/readerc.go#L56-L85
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go
yaml_parser_initialize
func yaml_parser_initialize(parser *yaml_parser_t) bool { *parser = yaml_parser_t{ raw_buffer: make([]byte, 0, input_raw_buffer_size), buffer: make([]byte, 0, input_buffer_size), } return true }
go
func yaml_parser_initialize(parser *yaml_parser_t) bool { *parser = yaml_parser_t{ raw_buffer: make([]byte, 0, input_raw_buffer_size), buffer: make([]byte, 0, input_buffer_size), } return true }
[ "func", "yaml_parser_initialize", "(", "parser", "*", "yaml_parser_t", ")", "bool", "{", "*", "parser", "=", "yaml_parser_t", "{", "raw_buffer", ":", "make", "(", "[", "]", "byte", ",", "0", ",", "input_raw_buffer_size", ")", ",", "buffer", ":", "make", "(", "[", "]", "byte", ",", "0", ",", "input_buffer_size", ")", ",", "}", "\n", "return", "true", "\n", "}" ]
// Create a new parser object.
[ "Create", "a", "new", "parser", "object", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go#L28-L34
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go
yaml_string_read_handler
func yaml_string_read_handler(parser *yaml_parser_t, buffer []byte) (n int, err error) { if parser.input_pos == len(parser.input) { return 0, io.EOF } n = copy(buffer, parser.input[parser.input_pos:]) parser.input_pos += n return n, nil }
go
func yaml_string_read_handler(parser *yaml_parser_t, buffer []byte) (n int, err error) { if parser.input_pos == len(parser.input) { return 0, io.EOF } n = copy(buffer, parser.input[parser.input_pos:]) parser.input_pos += n return n, nil }
[ "func", "yaml_string_read_handler", "(", "parser", "*", "yaml_parser_t", ",", "buffer", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "if", "parser", ".", "input_pos", "==", "len", "(", "parser", ".", "input", ")", "{", "return", "0", ",", "io", ".", "EOF", "\n", "}", "\n", "n", "=", "copy", "(", "buffer", ",", "parser", ".", "input", "[", "parser", ".", "input_pos", ":", "]", ")", "\n", "parser", ".", "input_pos", "+=", "n", "\n", "return", "n", ",", "nil", "\n", "}" ]
// String read handler.
[ "String", "read", "handler", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go#L42-L49
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go
yaml_file_read_handler
func yaml_file_read_handler(parser *yaml_parser_t, buffer []byte) (n int, err error) { return parser.input_file.Read(buffer) }
go
func yaml_file_read_handler(parser *yaml_parser_t, buffer []byte) (n int, err error) { return parser.input_file.Read(buffer) }
[ "func", "yaml_file_read_handler", "(", "parser", "*", "yaml_parser_t", ",", "buffer", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "return", "parser", ".", "input_file", ".", "Read", "(", "buffer", ")", "\n", "}" ]
// File read handler.
[ "File", "read", "handler", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go#L52-L54
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go
yaml_parser_set_input_string
func yaml_parser_set_input_string(parser *yaml_parser_t, input []byte) { if parser.read_handler != nil { panic("must set the input source only once") } parser.read_handler = yaml_string_read_handler parser.input = input parser.input_pos = 0 }
go
func yaml_parser_set_input_string(parser *yaml_parser_t, input []byte) { if parser.read_handler != nil { panic("must set the input source only once") } parser.read_handler = yaml_string_read_handler parser.input = input parser.input_pos = 0 }
[ "func", "yaml_parser_set_input_string", "(", "parser", "*", "yaml_parser_t", ",", "input", "[", "]", "byte", ")", "{", "if", "parser", ".", "read_handler", "!=", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "parser", ".", "read_handler", "=", "yaml_string_read_handler", "\n", "parser", ".", "input", "=", "input", "\n", "parser", ".", "input_pos", "=", "0", "\n", "}" ]
// Set a string input.
[ "Set", "a", "string", "input", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go#L57-L64
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go
yaml_parser_set_input_file
func yaml_parser_set_input_file(parser *yaml_parser_t, file *os.File) { if parser.read_handler != nil { panic("must set the input source only once") } parser.read_handler = yaml_file_read_handler parser.input_file = file }
go
func yaml_parser_set_input_file(parser *yaml_parser_t, file *os.File) { if parser.read_handler != nil { panic("must set the input source only once") } parser.read_handler = yaml_file_read_handler parser.input_file = file }
[ "func", "yaml_parser_set_input_file", "(", "parser", "*", "yaml_parser_t", ",", "file", "*", "os", ".", "File", ")", "{", "if", "parser", ".", "read_handler", "!=", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "parser", ".", "read_handler", "=", "yaml_file_read_handler", "\n", "parser", ".", "input_file", "=", "file", "\n", "}" ]
// Set a file input.
[ "Set", "a", "file", "input", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go#L67-L73
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go
yaml_parser_set_encoding
func yaml_parser_set_encoding(parser *yaml_parser_t, encoding yaml_encoding_t) { if parser.encoding != yaml_ANY_ENCODING { panic("must set the encoding only once") } parser.encoding = encoding }
go
func yaml_parser_set_encoding(parser *yaml_parser_t, encoding yaml_encoding_t) { if parser.encoding != yaml_ANY_ENCODING { panic("must set the encoding only once") } parser.encoding = encoding }
[ "func", "yaml_parser_set_encoding", "(", "parser", "*", "yaml_parser_t", ",", "encoding", "yaml_encoding_t", ")", "{", "if", "parser", ".", "encoding", "!=", "yaml_ANY_ENCODING", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "parser", ".", "encoding", "=", "encoding", "\n", "}" ]
// Set the source encoding.
[ "Set", "the", "source", "encoding", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go#L76-L81
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go
yaml_string_write_handler
func yaml_string_write_handler(emitter *yaml_emitter_t, buffer []byte) error { *emitter.output_buffer = append(*emitter.output_buffer, buffer...) return nil }
go
func yaml_string_write_handler(emitter *yaml_emitter_t, buffer []byte) error { *emitter.output_buffer = append(*emitter.output_buffer, buffer...) return nil }
[ "func", "yaml_string_write_handler", "(", "emitter", "*", "yaml_emitter_t", ",", "buffer", "[", "]", "byte", ")", "error", "{", "*", "emitter", ".", "output_buffer", "=", "append", "(", "*", "emitter", ".", "output_buffer", ",", "buffer", "...", ")", "\n", "return", "nil", "\n", "}" ]
// String write handler.
[ "String", "write", "handler", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go#L100-L103
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go
yaml_file_write_handler
func yaml_file_write_handler(emitter *yaml_emitter_t, buffer []byte) error { _, err := emitter.output_file.Write(buffer) return err }
go
func yaml_file_write_handler(emitter *yaml_emitter_t, buffer []byte) error { _, err := emitter.output_file.Write(buffer) return err }
[ "func", "yaml_file_write_handler", "(", "emitter", "*", "yaml_emitter_t", ",", "buffer", "[", "]", "byte", ")", "error", "{", "_", ",", "err", ":=", "emitter", ".", "output_file", ".", "Write", "(", "buffer", ")", "\n", "return", "err", "\n", "}" ]
// File write handler.
[ "File", "write", "handler", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go#L106-L109
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go
yaml_emitter_set_output_string
func yaml_emitter_set_output_string(emitter *yaml_emitter_t, output_buffer *[]byte) { if emitter.write_handler != nil { panic("must set the output target only once") } emitter.write_handler = yaml_string_write_handler emitter.output_buffer = output_buffer }
go
func yaml_emitter_set_output_string(emitter *yaml_emitter_t, output_buffer *[]byte) { if emitter.write_handler != nil { panic("must set the output target only once") } emitter.write_handler = yaml_string_write_handler emitter.output_buffer = output_buffer }
[ "func", "yaml_emitter_set_output_string", "(", "emitter", "*", "yaml_emitter_t", ",", "output_buffer", "*", "[", "]", "byte", ")", "{", "if", "emitter", ".", "write_handler", "!=", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "emitter", ".", "write_handler", "=", "yaml_string_write_handler", "\n", "emitter", ".", "output_buffer", "=", "output_buffer", "\n", "}" ]
// Set a string output.
[ "Set", "a", "string", "output", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go#L112-L118
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go
yaml_emitter_set_output_file
func yaml_emitter_set_output_file(emitter *yaml_emitter_t, file io.Writer) { if emitter.write_handler != nil { panic("must set the output target only once") } emitter.write_handler = yaml_file_write_handler emitter.output_file = file }
go
func yaml_emitter_set_output_file(emitter *yaml_emitter_t, file io.Writer) { if emitter.write_handler != nil { panic("must set the output target only once") } emitter.write_handler = yaml_file_write_handler emitter.output_file = file }
[ "func", "yaml_emitter_set_output_file", "(", "emitter", "*", "yaml_emitter_t", ",", "file", "io", ".", "Writer", ")", "{", "if", "emitter", ".", "write_handler", "!=", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "emitter", ".", "write_handler", "=", "yaml_file_write_handler", "\n", "emitter", ".", "output_file", "=", "file", "\n", "}" ]
// Set a file output.
[ "Set", "a", "file", "output", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go#L121-L127
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go
yaml_emitter_set_encoding
func yaml_emitter_set_encoding(emitter *yaml_emitter_t, encoding yaml_encoding_t) { if emitter.encoding != yaml_ANY_ENCODING { panic("must set the output encoding only once") } emitter.encoding = encoding }
go
func yaml_emitter_set_encoding(emitter *yaml_emitter_t, encoding yaml_encoding_t) { if emitter.encoding != yaml_ANY_ENCODING { panic("must set the output encoding only once") } emitter.encoding = encoding }
[ "func", "yaml_emitter_set_encoding", "(", "emitter", "*", "yaml_emitter_t", ",", "encoding", "yaml_encoding_t", ")", "{", "if", "emitter", ".", "encoding", "!=", "yaml_ANY_ENCODING", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "emitter", ".", "encoding", "=", "encoding", "\n", "}" ]
// Set the output encoding.
[ "Set", "the", "output", "encoding", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go#L130-L135
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go
yaml_emitter_set_width
func yaml_emitter_set_width(emitter *yaml_emitter_t, width int) { if width < 0 { width = -1 } emitter.best_width = width }
go
func yaml_emitter_set_width(emitter *yaml_emitter_t, width int) { if width < 0 { width = -1 } emitter.best_width = width }
[ "func", "yaml_emitter_set_width", "(", "emitter", "*", "yaml_emitter_t", ",", "width", "int", ")", "{", "if", "width", "<", "0", "{", "width", "=", "-", "1", "\n", "}", "\n", "emitter", ".", "best_width", "=", "width", "\n", "}" ]
// Set the preferred line width.
[ "Set", "the", "preferred", "line", "width", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go#L151-L156
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go
yaml_document_start_event_initialize
func yaml_document_start_event_initialize(event *yaml_event_t, version_directive *yaml_version_directive_t, tag_directives []yaml_tag_directive_t, implicit bool) bool { *event = yaml_event_t{ typ: yaml_DOCUMENT_START_EVENT, version_directive: version_directive, tag_directives: tag_directives, implicit: implicit, } return true }
go
func yaml_document_start_event_initialize(event *yaml_event_t, version_directive *yaml_version_directive_t, tag_directives []yaml_tag_directive_t, implicit bool) bool { *event = yaml_event_t{ typ: yaml_DOCUMENT_START_EVENT, version_directive: version_directive, tag_directives: tag_directives, implicit: implicit, } return true }
[ "func", "yaml_document_start_event_initialize", "(", "event", "*", "yaml_event_t", ",", "version_directive", "*", "yaml_version_directive_t", ",", "tag_directives", "[", "]", "yaml_tag_directive_t", ",", "implicit", "bool", ")", "bool", "{", "*", "event", "=", "yaml_event_t", "{", "typ", ":", "yaml_DOCUMENT_START_EVENT", ",", "version_directive", ":", "version_directive", ",", "tag_directives", ":", "tag_directives", ",", "implicit", ":", "implicit", ",", "}", "\n", "return", "true", "\n", "}" ]
// Create DOCUMENT-START.
[ "Create", "DOCUMENT", "-", "START", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go#L272-L281
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go
yaml_document_end_event_initialize
func yaml_document_end_event_initialize(event *yaml_event_t, implicit bool) bool { *event = yaml_event_t{ typ: yaml_DOCUMENT_END_EVENT, implicit: implicit, } return true }
go
func yaml_document_end_event_initialize(event *yaml_event_t, implicit bool) bool { *event = yaml_event_t{ typ: yaml_DOCUMENT_END_EVENT, implicit: implicit, } return true }
[ "func", "yaml_document_end_event_initialize", "(", "event", "*", "yaml_event_t", ",", "implicit", "bool", ")", "bool", "{", "*", "event", "=", "yaml_event_t", "{", "typ", ":", "yaml_DOCUMENT_END_EVENT", ",", "implicit", ":", "implicit", ",", "}", "\n", "return", "true", "\n", "}" ]
// Create DOCUMENT-END.
[ "Create", "DOCUMENT", "-", "END", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go#L284-L290
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go
yaml_sequence_start_event_initialize
func yaml_sequence_start_event_initialize(event *yaml_event_t, anchor, tag []byte, implicit bool, style yaml_sequence_style_t) bool { *event = yaml_event_t{ typ: yaml_SEQUENCE_START_EVENT, anchor: anchor, tag: tag, implicit: implicit, style: yaml_style_t(style), } return true }
go
func yaml_sequence_start_event_initialize(event *yaml_event_t, anchor, tag []byte, implicit bool, style yaml_sequence_style_t) bool { *event = yaml_event_t{ typ: yaml_SEQUENCE_START_EVENT, anchor: anchor, tag: tag, implicit: implicit, style: yaml_style_t(style), } return true }
[ "func", "yaml_sequence_start_event_initialize", "(", "event", "*", "yaml_event_t", ",", "anchor", ",", "tag", "[", "]", "byte", ",", "implicit", "bool", ",", "style", "yaml_sequence_style_t", ")", "bool", "{", "*", "event", "=", "yaml_event_t", "{", "typ", ":", "yaml_SEQUENCE_START_EVENT", ",", "anchor", ":", "anchor", ",", "tag", ":", "tag", ",", "implicit", ":", "implicit", ",", "style", ":", "yaml_style_t", "(", "style", ")", ",", "}", "\n", "return", "true", "\n", "}" ]
// Create SEQUENCE-START.
[ "Create", "SEQUENCE", "-", "START", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go#L331-L340
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/resource_container_linux.go
RunInResourceContainer
func RunInResourceContainer(containerName string) error { manager := fs.Manager{ Cgroups: &configs.Cgroup{ Name: containerName, AllowAllDevices: true, }, } return manager.Apply(os.Getpid()) }
go
func RunInResourceContainer(containerName string) error { manager := fs.Manager{ Cgroups: &configs.Cgroup{ Name: containerName, AllowAllDevices: true, }, } return manager.Apply(os.Getpid()) }
[ "func", "RunInResourceContainer", "(", "containerName", "string", ")", "error", "{", "manager", ":=", "fs", ".", "Manager", "{", "Cgroups", ":", "&", "configs", ".", "Cgroup", "{", "Name", ":", "containerName", ",", "AllowAllDevices", ":", "true", ",", "}", ",", "}", "\n\n", "return", "manager", ".", "Apply", "(", "os", ".", "Getpid", "(", ")", ")", "\n", "}" ]
// Creates resource-only containerName if it does not already exist and moves // the current process to it. // // containerName must be an absolute container name.
[ "Creates", "resource", "-", "only", "containerName", "if", "it", "does", "not", "already", "exist", "and", "moves", "the", "current", "process", "to", "it", ".", "containerName", "must", "be", "an", "absolute", "container", "name", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/resource_container_linux.go#L33-L42
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/history.go
History
func (h *DeploymentHistoryViewer) History(namespace, name string) (HistoryInfo, error) { historyInfo := HistoryInfo{ RevisionToTemplate: make(map[int64]*api.PodTemplateSpec), } deployment, err := h.c.Extensions().Deployments(namespace).Get(name) if err != nil { return historyInfo, fmt.Errorf("failed to retrieve deployment %s: %v", name, err) } _, allOldRSs, err := deploymentutil.GetOldReplicaSets(*deployment, h.c) if err != nil { return historyInfo, fmt.Errorf("failed to retrieve old replica sets from deployment %s: %v", name, err) } newRS, err := deploymentutil.GetNewReplicaSet(*deployment, h.c) if err != nil { return historyInfo, fmt.Errorf("failed to retrieve new replica set from deployment %s: %v", name, err) } allRSs := append(allOldRSs, newRS) for _, rs := range allRSs { v, err := deploymentutil.Revision(rs) if err != nil { continue } historyInfo.RevisionToTemplate[v] = rs.Spec.Template changeCause := getChangeCause(rs) if historyInfo.RevisionToTemplate[v].Annotations == nil { historyInfo.RevisionToTemplate[v].Annotations = make(map[string]string) } historyInfo.RevisionToTemplate[v].Annotations[ChangeCauseAnnotation] = changeCause } return historyInfo, nil }
go
func (h *DeploymentHistoryViewer) History(namespace, name string) (HistoryInfo, error) { historyInfo := HistoryInfo{ RevisionToTemplate: make(map[int64]*api.PodTemplateSpec), } deployment, err := h.c.Extensions().Deployments(namespace).Get(name) if err != nil { return historyInfo, fmt.Errorf("failed to retrieve deployment %s: %v", name, err) } _, allOldRSs, err := deploymentutil.GetOldReplicaSets(*deployment, h.c) if err != nil { return historyInfo, fmt.Errorf("failed to retrieve old replica sets from deployment %s: %v", name, err) } newRS, err := deploymentutil.GetNewReplicaSet(*deployment, h.c) if err != nil { return historyInfo, fmt.Errorf("failed to retrieve new replica set from deployment %s: %v", name, err) } allRSs := append(allOldRSs, newRS) for _, rs := range allRSs { v, err := deploymentutil.Revision(rs) if err != nil { continue } historyInfo.RevisionToTemplate[v] = rs.Spec.Template changeCause := getChangeCause(rs) if historyInfo.RevisionToTemplate[v].Annotations == nil { historyInfo.RevisionToTemplate[v].Annotations = make(map[string]string) } historyInfo.RevisionToTemplate[v].Annotations[ChangeCauseAnnotation] = changeCause } return historyInfo, nil }
[ "func", "(", "h", "*", "DeploymentHistoryViewer", ")", "History", "(", "namespace", ",", "name", "string", ")", "(", "HistoryInfo", ",", "error", ")", "{", "historyInfo", ":=", "HistoryInfo", "{", "RevisionToTemplate", ":", "make", "(", "map", "[", "int64", "]", "*", "api", ".", "PodTemplateSpec", ")", ",", "}", "\n", "deployment", ",", "err", ":=", "h", ".", "c", ".", "Extensions", "(", ")", ".", "Deployments", "(", "namespace", ")", ".", "Get", "(", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "historyInfo", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ",", "err", ")", "\n", "}", "\n", "_", ",", "allOldRSs", ",", "err", ":=", "deploymentutil", ".", "GetOldReplicaSets", "(", "*", "deployment", ",", "h", ".", "c", ")", "\n", "if", "err", "!=", "nil", "{", "return", "historyInfo", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ",", "err", ")", "\n", "}", "\n", "newRS", ",", "err", ":=", "deploymentutil", ".", "GetNewReplicaSet", "(", "*", "deployment", ",", "h", ".", "c", ")", "\n", "if", "err", "!=", "nil", "{", "return", "historyInfo", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ",", "err", ")", "\n", "}", "\n", "allRSs", ":=", "append", "(", "allOldRSs", ",", "newRS", ")", "\n", "for", "_", ",", "rs", ":=", "range", "allRSs", "{", "v", ",", "err", ":=", "deploymentutil", ".", "Revision", "(", "rs", ")", "\n", "if", "err", "!=", "nil", "{", "continue", "\n", "}", "\n", "historyInfo", ".", "RevisionToTemplate", "[", "v", "]", "=", "rs", ".", "Spec", ".", "Template", "\n", "changeCause", ":=", "getChangeCause", "(", "rs", ")", "\n", "if", "historyInfo", ".", "RevisionToTemplate", "[", "v", "]", ".", "Annotations", "==", "nil", "{", "historyInfo", ".", "RevisionToTemplate", "[", "v", "]", ".", "Annotations", "=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "}", "\n", "historyInfo", ".", "RevisionToTemplate", "[", "v", "]", ".", "Annotations", "[", "ChangeCauseAnnotation", "]", "=", "changeCause", "\n", "}", "\n", "return", "historyInfo", ",", "nil", "\n", "}" ]
// History returns a revision-to-replicaset map as the revision history of a deployment
[ "History", "returns", "a", "revision", "-", "to", "-", "replicaset", "map", "as", "the", "revision", "history", "of", "a", "deployment" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/history.go#L62-L92
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/history.go
PrintRolloutHistory
func PrintRolloutHistory(historyInfo HistoryInfo, resource, name string) (string, error) { if len(historyInfo.RevisionToTemplate) == 0 { return fmt.Sprintf("No rollout history found in %s %q", resource, name), nil } // Sort the revisionToChangeCause map by revision var revisions []string for k := range historyInfo.RevisionToTemplate { revisions = append(revisions, strconv.FormatInt(k, 10)) } sort.Strings(revisions) return tabbedString(func(out io.Writer) error { fmt.Fprintf(out, "%s %q:\n", resource, name) fmt.Fprintf(out, "REVISION\tCHANGE-CAUSE\n") errs := []error{} for _, r := range revisions { // Find the change-cause of revision r r64, err := strconv.ParseInt(r, 10, 64) if err != nil { errs = append(errs, err) continue } changeCause := historyInfo.RevisionToTemplate[r64].Annotations[ChangeCauseAnnotation] if len(changeCause) == 0 { changeCause = "<none>" } fmt.Fprintf(out, "%s\t%s\n", r, changeCause) } return errors.NewAggregate(errs) }) }
go
func PrintRolloutHistory(historyInfo HistoryInfo, resource, name string) (string, error) { if len(historyInfo.RevisionToTemplate) == 0 { return fmt.Sprintf("No rollout history found in %s %q", resource, name), nil } // Sort the revisionToChangeCause map by revision var revisions []string for k := range historyInfo.RevisionToTemplate { revisions = append(revisions, strconv.FormatInt(k, 10)) } sort.Strings(revisions) return tabbedString(func(out io.Writer) error { fmt.Fprintf(out, "%s %q:\n", resource, name) fmt.Fprintf(out, "REVISION\tCHANGE-CAUSE\n") errs := []error{} for _, r := range revisions { // Find the change-cause of revision r r64, err := strconv.ParseInt(r, 10, 64) if err != nil { errs = append(errs, err) continue } changeCause := historyInfo.RevisionToTemplate[r64].Annotations[ChangeCauseAnnotation] if len(changeCause) == 0 { changeCause = "<none>" } fmt.Fprintf(out, "%s\t%s\n", r, changeCause) } return errors.NewAggregate(errs) }) }
[ "func", "PrintRolloutHistory", "(", "historyInfo", "HistoryInfo", ",", "resource", ",", "name", "string", ")", "(", "string", ",", "error", ")", "{", "if", "len", "(", "historyInfo", ".", "RevisionToTemplate", ")", "==", "0", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "resource", ",", "name", ")", ",", "nil", "\n", "}", "\n", "// Sort the revisionToChangeCause map by revision", "var", "revisions", "[", "]", "string", "\n", "for", "k", ":=", "range", "historyInfo", ".", "RevisionToTemplate", "{", "revisions", "=", "append", "(", "revisions", ",", "strconv", ".", "FormatInt", "(", "k", ",", "10", ")", ")", "\n", "}", "\n", "sort", ".", "Strings", "(", "revisions", ")", "\n\n", "return", "tabbedString", "(", "func", "(", "out", "io", ".", "Writer", ")", "error", "{", "fmt", ".", "Fprintf", "(", "out", ",", "\"", "\\n", "\"", ",", "resource", ",", "name", ")", "\n", "fmt", ".", "Fprintf", "(", "out", ",", "\"", "\\t", "\\n", "\"", ")", "\n", "errs", ":=", "[", "]", "error", "{", "}", "\n", "for", "_", ",", "r", ":=", "range", "revisions", "{", "// Find the change-cause of revision r", "r64", ",", "err", ":=", "strconv", ".", "ParseInt", "(", "r", ",", "10", ",", "64", ")", "\n", "if", "err", "!=", "nil", "{", "errs", "=", "append", "(", "errs", ",", "err", ")", "\n", "continue", "\n", "}", "\n", "changeCause", ":=", "historyInfo", ".", "RevisionToTemplate", "[", "r64", "]", ".", "Annotations", "[", "ChangeCauseAnnotation", "]", "\n", "if", "len", "(", "changeCause", ")", "==", "0", "{", "changeCause", "=", "\"", "\"", "\n", "}", "\n", "fmt", ".", "Fprintf", "(", "out", ",", "\"", "\\t", "\\n", "\"", ",", "r", ",", "changeCause", ")", "\n", "}", "\n", "return", "errors", ".", "NewAggregate", "(", "errs", ")", "\n", "}", ")", "\n", "}" ]
// PrintRolloutHistory prints a formatted table of the input revision history of the deployment
[ "PrintRolloutHistory", "prints", "a", "formatted", "table", "of", "the", "input", "revision", "history", "of", "the", "deployment" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/history.go#L95-L125
train
kubernetes-retired/contrib
node-perf-dash/parser.go
Parse
func Parse(allTestData map[string]TestToBuildData, testInfo *TestInfo, job string, source Downloader) error { fmt.Printf("Getting Data from %s... (Job: %s)\n", *datasource, job) grabbedLastBuild := allGrabbedLastBuild[job] lastBuildNumber, err := source.GetLastestBuildNumber(job) if err != nil { return fmt.Errorf("failed to get the lastest build number for job %q", job) } fmt.Printf("Last build no: %v (Job: %s)\n", lastBuildNumber, job) startBuildNumber := int(math.Max(math.Max(float64(lastBuildNumber-*builds), 0), float64(grabbedLastBuild))) + 1 for buildNumber := lastBuildNumber; buildNumber >= startBuildNumber; buildNumber-- { fmt.Printf("Fetching build %v... (Job: %s)\n", buildNumber, job) if err := populateDataForOneBuild(allTestData[job], testInfo, job, buildNumber, source); err != nil { return err } } allGrabbedLastBuild[job] = lastBuildNumber return nil }
go
func Parse(allTestData map[string]TestToBuildData, testInfo *TestInfo, job string, source Downloader) error { fmt.Printf("Getting Data from %s... (Job: %s)\n", *datasource, job) grabbedLastBuild := allGrabbedLastBuild[job] lastBuildNumber, err := source.GetLastestBuildNumber(job) if err != nil { return fmt.Errorf("failed to get the lastest build number for job %q", job) } fmt.Printf("Last build no: %v (Job: %s)\n", lastBuildNumber, job) startBuildNumber := int(math.Max(math.Max(float64(lastBuildNumber-*builds), 0), float64(grabbedLastBuild))) + 1 for buildNumber := lastBuildNumber; buildNumber >= startBuildNumber; buildNumber-- { fmt.Printf("Fetching build %v... (Job: %s)\n", buildNumber, job) if err := populateDataForOneBuild(allTestData[job], testInfo, job, buildNumber, source); err != nil { return err } } allGrabbedLastBuild[job] = lastBuildNumber return nil }
[ "func", "Parse", "(", "allTestData", "map", "[", "string", "]", "TestToBuildData", ",", "testInfo", "*", "TestInfo", ",", "job", "string", ",", "source", "Downloader", ")", "error", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "*", "datasource", ",", "job", ")", "\n\n", "grabbedLastBuild", ":=", "allGrabbedLastBuild", "[", "job", "]", "\n\n", "lastBuildNumber", ",", "err", ":=", "source", ".", "GetLastestBuildNumber", "(", "job", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "job", ")", "\n", "}", "\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "lastBuildNumber", ",", "job", ")", "\n\n", "startBuildNumber", ":=", "int", "(", "math", ".", "Max", "(", "math", ".", "Max", "(", "float64", "(", "lastBuildNumber", "-", "*", "builds", ")", ",", "0", ")", ",", "float64", "(", "grabbedLastBuild", ")", ")", ")", "+", "1", "\n", "for", "buildNumber", ":=", "lastBuildNumber", ";", "buildNumber", ">=", "startBuildNumber", ";", "buildNumber", "--", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "buildNumber", ",", "job", ")", "\n", "if", "err", ":=", "populateDataForOneBuild", "(", "allTestData", "[", "job", "]", ",", "testInfo", ",", "job", ",", "buildNumber", ",", "source", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "allGrabbedLastBuild", "[", "job", "]", "=", "lastBuildNumber", "\n", "return", "nil", "\n", "}" ]
// Parse fetches data from the source and populates allTestData and testInfo // for the given test job.
[ "Parse", "fetches", "data", "from", "the", "source", "and", "populates", "allTestData", "and", "testInfo", "for", "the", "given", "test", "job", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/node-perf-dash/parser.go#L56-L77
train
kubernetes-retired/contrib
node-perf-dash/parser.go
populateMetadata
func populateMetadata(testInfo *TestInfo, testTime *TestTime, labels map[string]string) error { test := labels["test"] // Populate testInfo with the test description. testInfo.Info[test] = labels["desc"] // Populate testTime with the test end timestamp. t, err := strconv.ParseInt(labels["timestamp"], 10, 64) if err != nil { return fmt.Errorf("failed to convert timestamp %q to an int64: %v", labels["timestamp"], err) } timestamp := time.Unix(t, 0).UTC().Format(testLogTimeFormat) testTime.Add(test, labels["node"], timestamp) return nil }
go
func populateMetadata(testInfo *TestInfo, testTime *TestTime, labels map[string]string) error { test := labels["test"] // Populate testInfo with the test description. testInfo.Info[test] = labels["desc"] // Populate testTime with the test end timestamp. t, err := strconv.ParseInt(labels["timestamp"], 10, 64) if err != nil { return fmt.Errorf("failed to convert timestamp %q to an int64: %v", labels["timestamp"], err) } timestamp := time.Unix(t, 0).UTC().Format(testLogTimeFormat) testTime.Add(test, labels["node"], timestamp) return nil }
[ "func", "populateMetadata", "(", "testInfo", "*", "TestInfo", ",", "testTime", "*", "TestTime", ",", "labels", "map", "[", "string", "]", "string", ")", "error", "{", "test", ":=", "labels", "[", "\"", "\"", "]", "\n\n", "// Populate testInfo with the test description.", "testInfo", ".", "Info", "[", "test", "]", "=", "labels", "[", "\"", "\"", "]", "\n\n", "// Populate testTime with the test end timestamp.", "t", ",", "err", ":=", "strconv", ".", "ParseInt", "(", "labels", "[", "\"", "\"", "]", ",", "10", ",", "64", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "labels", "[", "\"", "\"", "]", ",", "err", ")", "\n", "}", "\n", "timestamp", ":=", "time", ".", "Unix", "(", "t", ",", "0", ")", ".", "UTC", "(", ")", ".", "Format", "(", "testLogTimeFormat", ")", "\n", "testTime", ".", "Add", "(", "test", ",", "labels", "[", "\"", "\"", "]", ",", "timestamp", ")", "\n\n", "return", "nil", "\n", "}" ]
// populateMetadata populates the test description in testInfo and the test end // timestamp in testTime using the information in the given labels.
[ "populateMetadata", "populates", "the", "test", "description", "in", "testInfo", "and", "the", "test", "end", "timestamp", "in", "testTime", "using", "the", "information", "in", "the", "given", "labels", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/node-perf-dash/parser.go#L115-L130
train
kubernetes-retired/contrib
node-perf-dash/parser.go
populateTimeSeriesData
func populateTimeSeriesData(testData TestToBuildData, testInfo *TestInfo, testTime *TestTime, job, build string, source Downloader) error { contents, err := getDataFromFiles(job, build, "time_series", source) if err != nil { return err } for _, data := range contents { // Decode the data into obj. var obj nodeperftype.NodeTimeSeries if err := json.Unmarshal(data, &obj); err != nil { return fmt.Errorf("failed to parse time_series data: %v\ndata=\n%v", err, string(data)) } // Ignore the metrics with unsupported versions. if obj.Version != supportedMetricVersion { continue } // Populate the metadata (testInfo and testTime) with the // version and labels in the perf data. if err := populateMetadata(testInfo, testTime, obj.Labels); err != nil { return err } // Populate the result (testData) with the perf data. node := formatNodeName(obj.Labels, job) test := obj.Labels["test"] data := testData.GetDataPerBuild(job, build, test, node) data.Series = append(data.Series, obj) removeStaledBuilds(testData, job, test, node, build) } return nil }
go
func populateTimeSeriesData(testData TestToBuildData, testInfo *TestInfo, testTime *TestTime, job, build string, source Downloader) error { contents, err := getDataFromFiles(job, build, "time_series", source) if err != nil { return err } for _, data := range contents { // Decode the data into obj. var obj nodeperftype.NodeTimeSeries if err := json.Unmarshal(data, &obj); err != nil { return fmt.Errorf("failed to parse time_series data: %v\ndata=\n%v", err, string(data)) } // Ignore the metrics with unsupported versions. if obj.Version != supportedMetricVersion { continue } // Populate the metadata (testInfo and testTime) with the // version and labels in the perf data. if err := populateMetadata(testInfo, testTime, obj.Labels); err != nil { return err } // Populate the result (testData) with the perf data. node := formatNodeName(obj.Labels, job) test := obj.Labels["test"] data := testData.GetDataPerBuild(job, build, test, node) data.Series = append(data.Series, obj) removeStaledBuilds(testData, job, test, node, build) } return nil }
[ "func", "populateTimeSeriesData", "(", "testData", "TestToBuildData", ",", "testInfo", "*", "TestInfo", ",", "testTime", "*", "TestTime", ",", "job", ",", "build", "string", ",", "source", "Downloader", ")", "error", "{", "contents", ",", "err", ":=", "getDataFromFiles", "(", "job", ",", "build", ",", "\"", "\"", ",", "source", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "for", "_", ",", "data", ":=", "range", "contents", "{", "// Decode the data into obj.", "var", "obj", "nodeperftype", ".", "NodeTimeSeries", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "data", ",", "&", "obj", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\\n", "\\n", "\"", ",", "err", ",", "string", "(", "data", ")", ")", "\n", "}", "\n\n", "// Ignore the metrics with unsupported versions.", "if", "obj", ".", "Version", "!=", "supportedMetricVersion", "{", "continue", "\n", "}", "\n\n", "// Populate the metadata (testInfo and testTime) with the", "// version and labels in the perf data.", "if", "err", ":=", "populateMetadata", "(", "testInfo", ",", "testTime", ",", "obj", ".", "Labels", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Populate the result (testData) with the perf data.", "node", ":=", "formatNodeName", "(", "obj", ".", "Labels", ",", "job", ")", "\n", "test", ":=", "obj", ".", "Labels", "[", "\"", "\"", "]", "\n", "data", ":=", "testData", ".", "GetDataPerBuild", "(", "job", ",", "build", ",", "test", ",", "node", ")", "\n", "data", ".", "Series", "=", "append", "(", "data", ".", "Series", ",", "obj", ")", "\n\n", "removeStaledBuilds", "(", "testData", ",", "job", ",", "test", ",", "node", ",", "build", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// populateTimeSeriesData populates the time series data in testData and the // metadata in testInfo and testTime for the given test job at the given build // using the data fetched from source.
[ "populateTimeSeriesData", "populates", "the", "time", "series", "data", "in", "testData", "and", "the", "metadata", "in", "testInfo", "and", "testTime", "for", "the", "given", "test", "job", "at", "the", "given", "build", "using", "the", "data", "fetched", "from", "source", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/node-perf-dash/parser.go#L191-L223
train
kubernetes-retired/contrib
node-perf-dash/parser.go
populateDataForOneBuild
func populateDataForOneBuild(testData TestToBuildData, testInfo *TestInfo, job string, buildNumber int, source Downloader) error { build := strconv.Itoa(buildNumber) testTime := TestTime{} if err := populatePerformanceData(testData, testInfo, &testTime, job, build, source); err != nil { return err } if err := populateTimeSeriesData(testData, testInfo, &testTime, job, build, source); err != nil { return err } if *tracing { // Grab and convert tracing data from Kubelet log into time series data format. tracingData := ParseKubeletLog(source, job, buildNumber, testTime) // Parse time series data. parseTracingData(bufio.NewScanner(strings.NewReader(tracingData)), job, buildNumber, testData) } return nil }
go
func populateDataForOneBuild(testData TestToBuildData, testInfo *TestInfo, job string, buildNumber int, source Downloader) error { build := strconv.Itoa(buildNumber) testTime := TestTime{} if err := populatePerformanceData(testData, testInfo, &testTime, job, build, source); err != nil { return err } if err := populateTimeSeriesData(testData, testInfo, &testTime, job, build, source); err != nil { return err } if *tracing { // Grab and convert tracing data from Kubelet log into time series data format. tracingData := ParseKubeletLog(source, job, buildNumber, testTime) // Parse time series data. parseTracingData(bufio.NewScanner(strings.NewReader(tracingData)), job, buildNumber, testData) } return nil }
[ "func", "populateDataForOneBuild", "(", "testData", "TestToBuildData", ",", "testInfo", "*", "TestInfo", ",", "job", "string", ",", "buildNumber", "int", ",", "source", "Downloader", ")", "error", "{", "build", ":=", "strconv", ".", "Itoa", "(", "buildNumber", ")", "\n", "testTime", ":=", "TestTime", "{", "}", "\n", "if", "err", ":=", "populatePerformanceData", "(", "testData", ",", "testInfo", ",", "&", "testTime", ",", "job", ",", "build", ",", "source", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "populateTimeSeriesData", "(", "testData", ",", "testInfo", ",", "&", "testTime", ",", "job", ",", "build", ",", "source", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "*", "tracing", "{", "// Grab and convert tracing data from Kubelet log into time series data format.", "tracingData", ":=", "ParseKubeletLog", "(", "source", ",", "job", ",", "buildNumber", ",", "testTime", ")", "\n", "// Parse time series data.", "parseTracingData", "(", "bufio", ".", "NewScanner", "(", "strings", ".", "NewReader", "(", "tracingData", ")", ")", ",", "job", ",", "buildNumber", ",", "testData", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// populateDataForOneBuild populates perf and time series data in testData and // test description in testinfo for the given test job at given buildNumber // with the data fetched from source.
[ "populateDataForOneBuild", "populates", "perf", "and", "time", "series", "data", "in", "testData", "and", "test", "description", "in", "testinfo", "for", "the", "given", "test", "job", "at", "given", "buildNumber", "with", "the", "data", "fetched", "from", "source", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/node-perf-dash/parser.go#L228-L244
train
kubernetes-retired/contrib
node-perf-dash/parser.go
parseTracingData
func parseTracingData(scanner *bufio.Scanner, job string, buildNumber int, result TestToBuildData) { buff := &bytes.Buffer{} state := scanning build := fmt.Sprintf("%d", buildNumber) for scanner.Scan() { line := scanner.Text() if state == processing { if strings.Contains(line, timeSeriesEnd) { state = scanning obj := nodeperftype.NodeTimeSeries{} if err := json.Unmarshal(buff.Bytes(), &obj); err != nil { fmt.Fprintf(os.Stderr, "error parsing JSON in build %d: %v\n%s\n", buildNumber, err, buff.String()) continue } // We do not check the obj's version against // the supportedMetricVersion because this data // is generated internally by // ParseKubeletLog(). testName, nodeName := obj.Labels["test"], formatNodeName(obj.Labels, job) if _, found := result[testName]; !found { fmt.Fprintf(os.Stderr, "Error: tracing data have no test result: %s\n", testName) continue } if _, found := result[testName].Data[nodeName]; !found { fmt.Fprintf(os.Stderr, "Error: tracing data have no test result: %s\n", nodeName) continue } if _, found := result[testName].Data[nodeName][build]; !found { fmt.Fprintf(os.Stderr, "Error: tracing data have not test result: %s\n", build) continue } data := result.GetDataPerBuild(job, build, testName, nodeName) data.Series = append(data.Series, obj) buff.Reset() } } if strings.Contains(line, timeSeriesTag) { state = processing line = line[strings.Index(line, "{"):] } if state == processing { buff.WriteString(line + " ") } } }
go
func parseTracingData(scanner *bufio.Scanner, job string, buildNumber int, result TestToBuildData) { buff := &bytes.Buffer{} state := scanning build := fmt.Sprintf("%d", buildNumber) for scanner.Scan() { line := scanner.Text() if state == processing { if strings.Contains(line, timeSeriesEnd) { state = scanning obj := nodeperftype.NodeTimeSeries{} if err := json.Unmarshal(buff.Bytes(), &obj); err != nil { fmt.Fprintf(os.Stderr, "error parsing JSON in build %d: %v\n%s\n", buildNumber, err, buff.String()) continue } // We do not check the obj's version against // the supportedMetricVersion because this data // is generated internally by // ParseKubeletLog(). testName, nodeName := obj.Labels["test"], formatNodeName(obj.Labels, job) if _, found := result[testName]; !found { fmt.Fprintf(os.Stderr, "Error: tracing data have no test result: %s\n", testName) continue } if _, found := result[testName].Data[nodeName]; !found { fmt.Fprintf(os.Stderr, "Error: tracing data have no test result: %s\n", nodeName) continue } if _, found := result[testName].Data[nodeName][build]; !found { fmt.Fprintf(os.Stderr, "Error: tracing data have not test result: %s\n", build) continue } data := result.GetDataPerBuild(job, build, testName, nodeName) data.Series = append(data.Series, obj) buff.Reset() } } if strings.Contains(line, timeSeriesTag) { state = processing line = line[strings.Index(line, "{"):] } if state == processing { buff.WriteString(line + " ") } } }
[ "func", "parseTracingData", "(", "scanner", "*", "bufio", ".", "Scanner", ",", "job", "string", ",", "buildNumber", "int", ",", "result", "TestToBuildData", ")", "{", "buff", ":=", "&", "bytes", ".", "Buffer", "{", "}", "\n", "state", ":=", "scanning", "\n", "build", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "buildNumber", ")", "\n\n", "for", "scanner", ".", "Scan", "(", ")", "{", "line", ":=", "scanner", ".", "Text", "(", ")", "\n", "if", "state", "==", "processing", "{", "if", "strings", ".", "Contains", "(", "line", ",", "timeSeriesEnd", ")", "{", "state", "=", "scanning", "\n\n", "obj", ":=", "nodeperftype", ".", "NodeTimeSeries", "{", "}", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "buff", ".", "Bytes", "(", ")", ",", "&", "obj", ")", ";", "err", "!=", "nil", "{", "fmt", ".", "Fprintf", "(", "os", ".", "Stderr", ",", "\"", "\\n", "\\n", "\"", ",", "buildNumber", ",", "err", ",", "buff", ".", "String", "(", ")", ")", "\n", "continue", "\n", "}", "\n\n", "// We do not check the obj's version against", "// the supportedMetricVersion because this data", "// is generated internally by", "// ParseKubeletLog().", "testName", ",", "nodeName", ":=", "obj", ".", "Labels", "[", "\"", "\"", "]", ",", "formatNodeName", "(", "obj", ".", "Labels", ",", "job", ")", "\n\n", "if", "_", ",", "found", ":=", "result", "[", "testName", "]", ";", "!", "found", "{", "fmt", ".", "Fprintf", "(", "os", ".", "Stderr", ",", "\"", "\\n", "\"", ",", "testName", ")", "\n", "continue", "\n", "}", "\n", "if", "_", ",", "found", ":=", "result", "[", "testName", "]", ".", "Data", "[", "nodeName", "]", ";", "!", "found", "{", "fmt", ".", "Fprintf", "(", "os", ".", "Stderr", ",", "\"", "\\n", "\"", ",", "nodeName", ")", "\n", "continue", "\n", "}", "\n", "if", "_", ",", "found", ":=", "result", "[", "testName", "]", ".", "Data", "[", "nodeName", "]", "[", "build", "]", ";", "!", "found", "{", "fmt", ".", "Fprintf", "(", "os", ".", "Stderr", ",", "\"", "\\n", "\"", ",", "build", ")", "\n", "continue", "\n", "}", "\n\n", "data", ":=", "result", ".", "GetDataPerBuild", "(", "job", ",", "build", ",", "testName", ",", "nodeName", ")", "\n", "data", ".", "Series", "=", "append", "(", "data", ".", "Series", ",", "obj", ")", "\n\n", "buff", ".", "Reset", "(", ")", "\n", "}", "\n", "}", "\n", "if", "strings", ".", "Contains", "(", "line", ",", "timeSeriesTag", ")", "{", "state", "=", "processing", "\n", "line", "=", "line", "[", "strings", ".", "Index", "(", "line", ",", "\"", "\"", ")", ":", "]", "\n", "}", "\n", "if", "state", "==", "processing", "{", "buff", ".", "WriteString", "(", "line", "+", "\"", "\"", ")", "\n", "}", "\n", "}", "\n", "}" ]
// parseTracingData extracts and converts tracing data into time series data.
[ "parseTracingData", "extracts", "and", "converts", "tracing", "data", "into", "time", "series", "data", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/node-perf-dash/parser.go#L254-L305
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/replica_sets.go
Get
func (c *replicaSets) Get(name string) (result *extensions.ReplicaSet, err error) { result = &extensions.ReplicaSet{} err = c.client.Get().Namespace(c.ns).Resource("replicasets").Name(name).Do().Into(result) return }
go
func (c *replicaSets) Get(name string) (result *extensions.ReplicaSet, err error) { result = &extensions.ReplicaSet{} err = c.client.Get().Namespace(c.ns).Resource("replicasets").Name(name).Do().Into(result) return }
[ "func", "(", "c", "*", "replicaSets", ")", "Get", "(", "name", "string", ")", "(", "result", "*", "extensions", ".", "ReplicaSet", ",", "err", "error", ")", "{", "result", "=", "&", "extensions", ".", "ReplicaSet", "{", "}", "\n", "err", "=", "c", ".", "client", ".", "Get", "(", ")", ".", "Namespace", "(", "c", ".", "ns", ")", ".", "Resource", "(", "\"", "\"", ")", ".", "Name", "(", "name", ")", ".", "Do", "(", ")", ".", "Into", "(", "result", ")", "\n", "return", "\n", "}" ]
// Get returns information about a particular ReplicaSet.
[ "Get", "returns", "information", "about", "a", "particular", "ReplicaSet", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/replica_sets.go#L60-L64
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/cloner.go
NewCloner
func NewCloner() *Cloner { c := &Cloner{ deepCopyFuncs: map[reflect.Type]reflect.Value{}, generatedDeepCopyFuncs: map[reflect.Type]reflect.Value{}, } if err := c.RegisterDeepCopyFunc(byteSliceDeepCopy); err != nil { // If one of the deep-copy functions is malformed, detect it immediately. panic(err) } return c }
go
func NewCloner() *Cloner { c := &Cloner{ deepCopyFuncs: map[reflect.Type]reflect.Value{}, generatedDeepCopyFuncs: map[reflect.Type]reflect.Value{}, } if err := c.RegisterDeepCopyFunc(byteSliceDeepCopy); err != nil { // If one of the deep-copy functions is malformed, detect it immediately. panic(err) } return c }
[ "func", "NewCloner", "(", ")", "*", "Cloner", "{", "c", ":=", "&", "Cloner", "{", "deepCopyFuncs", ":", "map", "[", "reflect", ".", "Type", "]", "reflect", ".", "Value", "{", "}", ",", "generatedDeepCopyFuncs", ":", "map", "[", "reflect", ".", "Type", "]", "reflect", ".", "Value", "{", "}", ",", "}", "\n", "if", "err", ":=", "c", ".", "RegisterDeepCopyFunc", "(", "byteSliceDeepCopy", ")", ";", "err", "!=", "nil", "{", "// If one of the deep-copy functions is malformed, detect it immediately.", "panic", "(", "err", ")", "\n", "}", "\n", "return", "c", "\n", "}" ]
// NewCloner creates a new Cloner object.
[ "NewCloner", "creates", "a", "new", "Cloner", "object", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/cloner.go#L32-L42
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/cloner.go
byteSliceDeepCopy
func byteSliceDeepCopy(in []byte, out *[]byte, c *Cloner) error { if in != nil { *out = make([]byte, len(in)) copy(*out, in) } else { *out = nil } return nil }
go
func byteSliceDeepCopy(in []byte, out *[]byte, c *Cloner) error { if in != nil { *out = make([]byte, len(in)) copy(*out, in) } else { *out = nil } return nil }
[ "func", "byteSliceDeepCopy", "(", "in", "[", "]", "byte", ",", "out", "*", "[", "]", "byte", ",", "c", "*", "Cloner", ")", "error", "{", "if", "in", "!=", "nil", "{", "*", "out", "=", "make", "(", "[", "]", "byte", ",", "len", "(", "in", ")", ")", "\n", "copy", "(", "*", "out", ",", "in", ")", "\n", "}", "else", "{", "*", "out", "=", "nil", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Prevent recursing into every byte...
[ "Prevent", "recursing", "into", "every", "byte", "..." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/cloner.go#L45-L53
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/cloner.go
verifyDeepCopyFunctionSignature
func verifyDeepCopyFunctionSignature(ft reflect.Type) error { if ft.Kind() != reflect.Func { return fmt.Errorf("expected func, got: %v", ft) } if ft.NumIn() != 3 { return fmt.Errorf("expected three 'in' params, got %v", ft) } if ft.NumOut() != 1 { return fmt.Errorf("expected one 'out' param, got %v", ft) } if ft.In(1).Kind() != reflect.Ptr { return fmt.Errorf("expected pointer arg for 'in' param 1, got: %v", ft) } if ft.In(1).Elem() != ft.In(0) { return fmt.Errorf("expected 'in' param 0 the same as param 1, got: %v", ft) } var forClonerType Cloner if expected := reflect.TypeOf(&forClonerType); ft.In(2) != expected { return fmt.Errorf("expected '%v' arg for 'in' param 2, got: '%v'", expected, ft.In(2)) } var forErrorType error // This convolution is necessary, otherwise TypeOf picks up on the fact // that forErrorType is nil errorType := reflect.TypeOf(&forErrorType).Elem() if ft.Out(0) != errorType { return fmt.Errorf("expected error return, got: %v", ft) } return nil }
go
func verifyDeepCopyFunctionSignature(ft reflect.Type) error { if ft.Kind() != reflect.Func { return fmt.Errorf("expected func, got: %v", ft) } if ft.NumIn() != 3 { return fmt.Errorf("expected three 'in' params, got %v", ft) } if ft.NumOut() != 1 { return fmt.Errorf("expected one 'out' param, got %v", ft) } if ft.In(1).Kind() != reflect.Ptr { return fmt.Errorf("expected pointer arg for 'in' param 1, got: %v", ft) } if ft.In(1).Elem() != ft.In(0) { return fmt.Errorf("expected 'in' param 0 the same as param 1, got: %v", ft) } var forClonerType Cloner if expected := reflect.TypeOf(&forClonerType); ft.In(2) != expected { return fmt.Errorf("expected '%v' arg for 'in' param 2, got: '%v'", expected, ft.In(2)) } var forErrorType error // This convolution is necessary, otherwise TypeOf picks up on the fact // that forErrorType is nil errorType := reflect.TypeOf(&forErrorType).Elem() if ft.Out(0) != errorType { return fmt.Errorf("expected error return, got: %v", ft) } return nil }
[ "func", "verifyDeepCopyFunctionSignature", "(", "ft", "reflect", ".", "Type", ")", "error", "{", "if", "ft", ".", "Kind", "(", ")", "!=", "reflect", ".", "Func", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "ft", ")", "\n", "}", "\n", "if", "ft", ".", "NumIn", "(", ")", "!=", "3", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "ft", ")", "\n", "}", "\n", "if", "ft", ".", "NumOut", "(", ")", "!=", "1", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "ft", ")", "\n", "}", "\n", "if", "ft", ".", "In", "(", "1", ")", ".", "Kind", "(", ")", "!=", "reflect", ".", "Ptr", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "ft", ")", "\n", "}", "\n", "if", "ft", ".", "In", "(", "1", ")", ".", "Elem", "(", ")", "!=", "ft", ".", "In", "(", "0", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "ft", ")", "\n", "}", "\n", "var", "forClonerType", "Cloner", "\n", "if", "expected", ":=", "reflect", ".", "TypeOf", "(", "&", "forClonerType", ")", ";", "ft", ".", "In", "(", "2", ")", "!=", "expected", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "expected", ",", "ft", ".", "In", "(", "2", ")", ")", "\n", "}", "\n", "var", "forErrorType", "error", "\n", "// This convolution is necessary, otherwise TypeOf picks up on the fact", "// that forErrorType is nil", "errorType", ":=", "reflect", ".", "TypeOf", "(", "&", "forErrorType", ")", ".", "Elem", "(", ")", "\n", "if", "ft", ".", "Out", "(", "0", ")", "!=", "errorType", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "ft", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Verifies whether a deep-copy function has a correct signature.
[ "Verifies", "whether", "a", "deep", "-", "copy", "function", "has", "a", "correct", "signature", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/cloner.go#L56-L84
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/cloner.go
RegisterGeneratedDeepCopyFunc
func (c *Cloner) RegisterGeneratedDeepCopyFunc(deepCopyFunc interface{}) error { fv := reflect.ValueOf(deepCopyFunc) ft := fv.Type() if err := verifyDeepCopyFunctionSignature(ft); err != nil { return err } c.generatedDeepCopyFuncs[ft.In(0)] = fv return nil }
go
func (c *Cloner) RegisterGeneratedDeepCopyFunc(deepCopyFunc interface{}) error { fv := reflect.ValueOf(deepCopyFunc) ft := fv.Type() if err := verifyDeepCopyFunctionSignature(ft); err != nil { return err } c.generatedDeepCopyFuncs[ft.In(0)] = fv return nil }
[ "func", "(", "c", "*", "Cloner", ")", "RegisterGeneratedDeepCopyFunc", "(", "deepCopyFunc", "interface", "{", "}", ")", "error", "{", "fv", ":=", "reflect", ".", "ValueOf", "(", "deepCopyFunc", ")", "\n", "ft", ":=", "fv", ".", "Type", "(", ")", "\n", "if", "err", ":=", "verifyDeepCopyFunctionSignature", "(", "ft", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "c", ".", "generatedDeepCopyFuncs", "[", "ft", ".", "In", "(", "0", ")", "]", "=", "fv", "\n", "return", "nil", "\n", "}" ]
// Similar to RegisterDeepCopyFunc, but registers deep copy function that were // automatically generated.
[ "Similar", "to", "RegisterDeepCopyFunc", "but", "registers", "deep", "copy", "function", "that", "were", "automatically", "generated", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/cloner.go#L108-L116
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/cloner.go
DeepCopy
func (c *Cloner) DeepCopy(in interface{}) (interface{}, error) { // Can be invalid if we run DeepCopy(X) where X is a nil interface type. // For example, we get an invalid value when someone tries to deep-copy // a nil labels.Selector. // This does not occur if X is nil and is a pointer to a concrete type. if in == nil { return nil, nil } inValue := reflect.ValueOf(in) outValue, err := c.deepCopy(inValue) if err != nil { return nil, err } return outValue.Interface(), nil }
go
func (c *Cloner) DeepCopy(in interface{}) (interface{}, error) { // Can be invalid if we run DeepCopy(X) where X is a nil interface type. // For example, we get an invalid value when someone tries to deep-copy // a nil labels.Selector. // This does not occur if X is nil and is a pointer to a concrete type. if in == nil { return nil, nil } inValue := reflect.ValueOf(in) outValue, err := c.deepCopy(inValue) if err != nil { return nil, err } return outValue.Interface(), nil }
[ "func", "(", "c", "*", "Cloner", ")", "DeepCopy", "(", "in", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "// Can be invalid if we run DeepCopy(X) where X is a nil interface type.", "// For example, we get an invalid value when someone tries to deep-copy", "// a nil labels.Selector.", "// This does not occur if X is nil and is a pointer to a concrete type.", "if", "in", "==", "nil", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "inValue", ":=", "reflect", ".", "ValueOf", "(", "in", ")", "\n", "outValue", ",", "err", ":=", "c", ".", "deepCopy", "(", "inValue", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "outValue", ".", "Interface", "(", ")", ",", "nil", "\n", "}" ]
// DeepCopy will perform a deep copy of a given object.
[ "DeepCopy", "will", "perform", "a", "deep", "copy", "of", "a", "given", "object", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/cloner.go#L119-L133
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/scheme.go
KnownTypes
func (s *Scheme) KnownTypes(gv unversioned.GroupVersion) map[string]reflect.Type { types := make(map[string]reflect.Type) for gvk, t := range s.gvkToType { if gv != gvk.GroupVersion() { continue } types[gvk.Kind] = t } return types }
go
func (s *Scheme) KnownTypes(gv unversioned.GroupVersion) map[string]reflect.Type { types := make(map[string]reflect.Type) for gvk, t := range s.gvkToType { if gv != gvk.GroupVersion() { continue } types[gvk.Kind] = t } return types }
[ "func", "(", "s", "*", "Scheme", ")", "KnownTypes", "(", "gv", "unversioned", ".", "GroupVersion", ")", "map", "[", "string", "]", "reflect", ".", "Type", "{", "types", ":=", "make", "(", "map", "[", "string", "]", "reflect", ".", "Type", ")", "\n", "for", "gvk", ",", "t", ":=", "range", "s", ".", "gvkToType", "{", "if", "gv", "!=", "gvk", ".", "GroupVersion", "(", ")", "{", "continue", "\n", "}", "\n\n", "types", "[", "gvk", ".", "Kind", "]", "=", "t", "\n", "}", "\n", "return", "types", "\n", "}" ]
// KnownTypes returns the types known for the given version.
[ "KnownTypes", "returns", "the", "types", "known", "for", "the", "given", "version", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/scheme.go#L205-L215
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/scheme.go
ObjectKind
func (s *Scheme) ObjectKind(obj Object) (unversioned.GroupVersionKind, error) { gvks, err := s.ObjectKinds(obj) if err != nil { return unversioned.GroupVersionKind{}, err } return gvks[0], nil }
go
func (s *Scheme) ObjectKind(obj Object) (unversioned.GroupVersionKind, error) { gvks, err := s.ObjectKinds(obj) if err != nil { return unversioned.GroupVersionKind{}, err } return gvks[0], nil }
[ "func", "(", "s", "*", "Scheme", ")", "ObjectKind", "(", "obj", "Object", ")", "(", "unversioned", ".", "GroupVersionKind", ",", "error", ")", "{", "gvks", ",", "err", ":=", "s", ".", "ObjectKinds", "(", "obj", ")", "\n", "if", "err", "!=", "nil", "{", "return", "unversioned", ".", "GroupVersionKind", "{", "}", ",", "err", "\n", "}", "\n", "return", "gvks", "[", "0", "]", ",", "nil", "\n", "}" ]
// ObjectKind returns the group,version,kind of the go object, // or an error if it's not a pointer or is unregistered.
[ "ObjectKind", "returns", "the", "group", "version", "kind", "of", "the", "go", "object", "or", "an", "error", "if", "it", "s", "not", "a", "pointer", "or", "is", "unregistered", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/scheme.go#L219-L225
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/scheme.go
ObjectKinds
func (s *Scheme) ObjectKinds(obj Object) ([]unversioned.GroupVersionKind, error) { v, err := conversion.EnforcePtr(obj) if err != nil { return nil, err } t := v.Type() gvks, ok := s.typeToGVK[t] if !ok { return nil, &notRegisteredErr{t: t} } return gvks, nil }
go
func (s *Scheme) ObjectKinds(obj Object) ([]unversioned.GroupVersionKind, error) { v, err := conversion.EnforcePtr(obj) if err != nil { return nil, err } t := v.Type() gvks, ok := s.typeToGVK[t] if !ok { return nil, &notRegisteredErr{t: t} } return gvks, nil }
[ "func", "(", "s", "*", "Scheme", ")", "ObjectKinds", "(", "obj", "Object", ")", "(", "[", "]", "unversioned", ".", "GroupVersionKind", ",", "error", ")", "{", "v", ",", "err", ":=", "conversion", ".", "EnforcePtr", "(", "obj", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "t", ":=", "v", ".", "Type", "(", ")", "\n\n", "gvks", ",", "ok", ":=", "s", ".", "typeToGVK", "[", "t", "]", "\n", "if", "!", "ok", "{", "return", "nil", ",", "&", "notRegisteredErr", "{", "t", ":", "t", "}", "\n", "}", "\n\n", "return", "gvks", ",", "nil", "\n", "}" ]
// ObjectKinds returns all possible group,version,kind of the go object, // or an error if it's not a pointer or is unregistered.
[ "ObjectKinds", "returns", "all", "possible", "group", "version", "kind", "of", "the", "go", "object", "or", "an", "error", "if", "it", "s", "not", "a", "pointer", "or", "is", "unregistered", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/scheme.go#L229-L242
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/scheme.go
Copy
func (s *Scheme) Copy(src Object) (Object, error) { dst, err := s.DeepCopy(src) if err != nil { return nil, err } return dst.(Object), nil }
go
func (s *Scheme) Copy(src Object) (Object, error) { dst, err := s.DeepCopy(src) if err != nil { return nil, err } return dst.(Object), nil }
[ "func", "(", "s", "*", "Scheme", ")", "Copy", "(", "src", "Object", ")", "(", "Object", ",", "error", ")", "{", "dst", ",", "err", ":=", "s", ".", "DeepCopy", "(", "src", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "dst", ".", "(", "Object", ")", ",", "nil", "\n", "}" ]
// Copy does a deep copy of an API object.
[ "Copy", "does", "a", "deep", "copy", "of", "an", "API", "object", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/scheme.go#L414-L420
train