repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
chromedp/chromedp | kb/gen.go | loadDomKeyData | func loadDomKeyData() (map[string][]string, error) {
buf, err := grab(domKeyDataInc)
if err != nil {
return nil, err
}
buf = fixRE.ReplaceAllLiteral(buf, []byte(", "))
keyMap := make(map[string][]string)
matches := domKeyRE.FindAllStringSubmatch(string(buf), -1)
for _, m := range matches {
keyMap[m[2]] = m[... | go | func loadDomKeyData() (map[string][]string, error) {
buf, err := grab(domKeyDataInc)
if err != nil {
return nil, err
}
buf = fixRE.ReplaceAllLiteral(buf, []byte(", "))
keyMap := make(map[string][]string)
matches := domKeyRE.FindAllStringSubmatch(string(buf), -1)
for _, m := range matches {
keyMap[m[2]] = m[... | [
"func",
"loadDomKeyData",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
",",
"error",
")",
"{",
"buf",
",",
"err",
":=",
"grab",
"(",
"domKeyDataInc",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}... | // loadDomKeyData loads the dom key data definitions. | [
"loadDomKeyData",
"loads",
"the",
"dom",
"key",
"data",
"definitions",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/kb/gen.go#L288-L302 | train |
chromedp/chromedp | kb/gen.go | loadNonPrintable | func loadNonPrintable(keys map[rune]kb.Key, keycodeConverterMap, domKeyMap map[string][]string, layoutBuf []byte, scanCodeMap map[string][]int64) error {
buf := extract(layoutBuf, "kNonPrintableCodeMap")
matches := nonPrintableKeyRE.FindAllStringSubmatch(string(buf), -1)
for _, m := range matches {
code, key := m[... | go | func loadNonPrintable(keys map[rune]kb.Key, keycodeConverterMap, domKeyMap map[string][]string, layoutBuf []byte, scanCodeMap map[string][]int64) error {
buf := extract(layoutBuf, "kNonPrintableCodeMap")
matches := nonPrintableKeyRE.FindAllStringSubmatch(string(buf), -1)
for _, m := range matches {
code, key := m[... | [
"func",
"loadNonPrintable",
"(",
"keys",
"map",
"[",
"rune",
"]",
"kb",
".",
"Key",
",",
"keycodeConverterMap",
",",
"domKeyMap",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
",",
"layoutBuf",
"[",
"]",
"byte",
",",
"scanCodeMap",
"map",
"[",
"string",... | // loadNonPrintable loads the not printable key definitions. | [
"loadNonPrintable",
"loads",
"the",
"not",
"printable",
"key",
"definitions",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/kb/gen.go#L307-L342 | train |
chromedp/chromedp | kb/gen.go | processKeys | func processKeys(keys map[rune]kb.Key) ([]byte, []byte, error) {
// order rune keys
idx := make([]rune, len(keys))
var i int
for c := range keys {
idx[i] = c
i++
}
sort.Slice(idx, func(a, b int) bool {
return idx[a] < idx[b]
})
// process
var constBuf, mapBuf bytes.Buffer
for _, c := range idx {
key ... | go | func processKeys(keys map[rune]kb.Key) ([]byte, []byte, error) {
// order rune keys
idx := make([]rune, len(keys))
var i int
for c := range keys {
idx[i] = c
i++
}
sort.Slice(idx, func(a, b int) bool {
return idx[a] < idx[b]
})
// process
var constBuf, mapBuf bytes.Buffer
for _, c := range idx {
key ... | [
"func",
"processKeys",
"(",
"keys",
"map",
"[",
"rune",
"]",
"kb",
".",
"Key",
")",
"(",
"[",
"]",
"byte",
",",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// order rune keys",
"idx",
":=",
"make",
"(",
"[",
"]",
"rune",
",",
"len",
"(",
"keys",
... | // processKeys processes the generated keys. | [
"processKeys",
"processes",
"the",
"generated",
"keys",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/kb/gen.go#L347-L394 | train |
chromedp/chromedp | kb/gen.go | loadScanCodes | func loadScanCodes(keycodeConverterMap, domKeyMap map[string][]string, layoutBuf []byte) (map[string][]int64, error) {
vkeyCodeMap, err := loadPosixWinKeyboardCodes()
if err != nil {
return nil, err
}
buf := extract(layoutBuf, "kDomCodeToKeyboardCodeMap")
buf = domCodeVkeyFixRE.ReplaceAllLiteral(buf, []byte(", ... | go | func loadScanCodes(keycodeConverterMap, domKeyMap map[string][]string, layoutBuf []byte) (map[string][]int64, error) {
vkeyCodeMap, err := loadPosixWinKeyboardCodes()
if err != nil {
return nil, err
}
buf := extract(layoutBuf, "kDomCodeToKeyboardCodeMap")
buf = domCodeVkeyFixRE.ReplaceAllLiteral(buf, []byte(", ... | [
"func",
"loadScanCodes",
"(",
"keycodeConverterMap",
",",
"domKeyMap",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
",",
"layoutBuf",
"[",
"]",
"byte",
")",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"int64",
",",
"error",
")",
"{",
"vkeyCodeMap",
","... | // loadScanCodes loads the scan codes for the dom key definitions. | [
"loadScanCodes",
"loads",
"the",
"scan",
"codes",
"for",
"the",
"dom",
"key",
"definitions",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/kb/gen.go#L400-L428 | train |
chromedp/chromedp | kb/gen.go | loadPosixWinKeyboardCodes | func loadPosixWinKeyboardCodes() (map[string][]int64, error) {
lookup := map[string]string{
// mac alias
"VKEY_LWIN": "0x5B",
// no idea where these are defined in chromium code base (assuming in
// windows headers)
//
// manually added here as pulled from various online docs
"VK_CANCEL": "0x03",
... | go | func loadPosixWinKeyboardCodes() (map[string][]int64, error) {
lookup := map[string]string{
// mac alias
"VKEY_LWIN": "0x5B",
// no idea where these are defined in chromium code base (assuming in
// windows headers)
//
// manually added here as pulled from various online docs
"VK_CANCEL": "0x03",
... | [
"func",
"loadPosixWinKeyboardCodes",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"int64",
",",
"error",
")",
"{",
"lookup",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"// mac alias",
"\"",
"\"",
":",
"\"",
"\"",
",",
"// no idea where these ... | // loadPosixWinKeyboardCodes loads the native and windows keyboard scan codes
// mapped to the DOM key. | [
"loadPosixWinKeyboardCodes",
"loads",
"the",
"native",
"and",
"windows",
"keyboard",
"scan",
"codes",
"mapped",
"to",
"the",
"DOM",
"key",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/kb/gen.go#L434-L476 | train |
chromedp/chromedp | kb/gen.go | loadKeyboardCodes | func loadKeyboardCodes(vkeyCodeMap map[string][]int64, lookup map[string]string, path string, pos int) error {
buf, err := grab(path)
if err != nil {
return err
}
buf = extract(buf, "KeyboardCode")
matches := keyboardCodeRE.FindAllStringSubmatch(string(buf), -1)
for _, m := range matches {
v := m[2]
switch... | go | func loadKeyboardCodes(vkeyCodeMap map[string][]int64, lookup map[string]string, path string, pos int) error {
buf, err := grab(path)
if err != nil {
return err
}
buf = extract(buf, "KeyboardCode")
matches := keyboardCodeRE.FindAllStringSubmatch(string(buf), -1)
for _, m := range matches {
v := m[2]
switch... | [
"func",
"loadKeyboardCodes",
"(",
"vkeyCodeMap",
"map",
"[",
"string",
"]",
"[",
"]",
"int64",
",",
"lookup",
"map",
"[",
"string",
"]",
"string",
",",
"path",
"string",
",",
"pos",
"int",
")",
"error",
"{",
"buf",
",",
"err",
":=",
"grab",
"(",
"pat... | // loadKeyboardCodes loads the enum definition from the specified path, saving
// the resolved symbol value to the specified position for the resulting dom
// key name in the vkeyCodeMap. | [
"loadKeyboardCodes",
"loads",
"the",
"enum",
"definition",
"from",
"the",
"specified",
"path",
"saving",
"the",
"resolved",
"symbol",
"value",
"to",
"the",
"specified",
"position",
"for",
"the",
"resulting",
"dom",
"key",
"name",
"in",
"the",
"vkeyCodeMap",
"."
... | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/kb/gen.go#L483-L520 | train |
chromedp/chromedp | kb/gen.go | extract | func extract(buf []byte, name string) []byte {
extractRE := regexp.MustCompile(`\s+` + name + `.+?{`)
buf = buf[extractRE.FindIndex(buf)[0]:]
return buf[:endRE.FindIndex(buf)[1]]
} | go | func extract(buf []byte, name string) []byte {
extractRE := regexp.MustCompile(`\s+` + name + `.+?{`)
buf = buf[extractRE.FindIndex(buf)[0]:]
return buf[:endRE.FindIndex(buf)[1]]
} | [
"func",
"extract",
"(",
"buf",
"[",
"]",
"byte",
",",
"name",
"string",
")",
"[",
"]",
"byte",
"{",
"extractRE",
":=",
"regexp",
".",
"MustCompile",
"(",
"`\\s+`",
"+",
"name",
"+",
"`.+?{`",
")",
"\n",
"buf",
"=",
"buf",
"[",
"extractRE",
".",
"Fi... | // extract extracts a block of next from a block of c++ code. | [
"extract",
"extracts",
"a",
"block",
"of",
"next",
"from",
"a",
"block",
"of",
"c",
"++",
"code",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/kb/gen.go#L525-L529 | train |
chromedp/chromedp | kb/gen.go | grab | func grab(path string) ([]byte, error) {
res, err := http.Get(path)
if err != nil {
return nil, err
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
return nil, err
}
buf, err := base64.StdEncoding.DecodeString(string(body))
if err != nil {
return nil, err
}
return buf,... | go | func grab(path string) ([]byte, error) {
res, err := http.Get(path)
if err != nil {
return nil, err
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
return nil, err
}
buf, err := base64.StdEncoding.DecodeString(string(body))
if err != nil {
return nil, err
}
return buf,... | [
"func",
"grab",
"(",
"path",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"res",
",",
"err",
":=",
"http",
".",
"Get",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"defe... | // grab retrieves a file from the chromium source code. | [
"grab",
"retrieves",
"a",
"file",
"from",
"the",
"chromium",
"source",
"code",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/kb/gen.go#L532-L550 | train |
chromedp/chromedp | query.go | Nodes | func Nodes(sel interface{}, nodes *[]*cdp.Node, opts ...QueryOption) Action {
if nodes == nil {
panic("nodes cannot be nil")
}
return QueryAfter(sel, func(ctx context.Context, n ...*cdp.Node) error {
*nodes = n
return nil
}, opts...)
} | go | func Nodes(sel interface{}, nodes *[]*cdp.Node, opts ...QueryOption) Action {
if nodes == nil {
panic("nodes cannot be nil")
}
return QueryAfter(sel, func(ctx context.Context, n ...*cdp.Node) error {
*nodes = n
return nil
}, opts...)
} | [
"func",
"Nodes",
"(",
"sel",
"interface",
"{",
"}",
",",
"nodes",
"*",
"[",
"]",
"*",
"cdp",
".",
"Node",
",",
"opts",
"...",
"QueryOption",
")",
"Action",
"{",
"if",
"nodes",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
... | // Nodes retrieves the document nodes matching the selector. | [
"Nodes",
"retrieves",
"the",
"document",
"nodes",
"matching",
"the",
"selector",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/query.go#L23-L32 | train |
chromedp/chromedp | query.go | NodeIDs | func NodeIDs(sel interface{}, ids *[]cdp.NodeID, opts ...QueryOption) Action {
if ids == nil {
panic("nodes cannot be nil")
}
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
nodeIDs := make([]cdp.NodeID, len(nodes))
for i, n := range nodes {
nodeIDs[i] = n.NodeID
}
*ids = ... | go | func NodeIDs(sel interface{}, ids *[]cdp.NodeID, opts ...QueryOption) Action {
if ids == nil {
panic("nodes cannot be nil")
}
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
nodeIDs := make([]cdp.NodeID, len(nodes))
for i, n := range nodes {
nodeIDs[i] = n.NodeID
}
*ids = ... | [
"func",
"NodeIDs",
"(",
"sel",
"interface",
"{",
"}",
",",
"ids",
"*",
"[",
"]",
"cdp",
".",
"NodeID",
",",
"opts",
"...",
"QueryOption",
")",
"Action",
"{",
"if",
"ids",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return... | // NodeIDs retrieves the node IDs matching the selector. | [
"NodeIDs",
"retrieves",
"the",
"node",
"IDs",
"matching",
"the",
"selector",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/query.go#L35-L50 | train |
chromedp/chromedp | query.go | Focus | func Focus(sel interface{}, opts ...QueryOption) Action {
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes", sel)
}
return dom.Focus().WithNodeID(nodes[0].NodeID).Do(ctx)
}, opts...)
} | go | func Focus(sel interface{}, opts ...QueryOption) Action {
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes", sel)
}
return dom.Focus().WithNodeID(nodes[0].NodeID).Do(ctx)
}, opts...)
} | [
"func",
"Focus",
"(",
"sel",
"interface",
"{",
"}",
",",
"opts",
"...",
"QueryOption",
")",
"Action",
"{",
"return",
"QueryAfter",
"(",
"sel",
",",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"nodes",
"...",
"*",
"cdp",
".",
"Node",
")",
"err... | // Focus focuses the first node matching the selector. | [
"Focus",
"focuses",
"the",
"first",
"node",
"matching",
"the",
"selector",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/query.go#L53-L61 | train |
chromedp/chromedp | query.go | Dimensions | func Dimensions(sel interface{}, model **dom.BoxModel, opts ...QueryOption) Action {
if model == nil {
panic("model cannot be nil")
}
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes", sel)
}
var err ... | go | func Dimensions(sel interface{}, model **dom.BoxModel, opts ...QueryOption) Action {
if model == nil {
panic("model cannot be nil")
}
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes", sel)
}
var err ... | [
"func",
"Dimensions",
"(",
"sel",
"interface",
"{",
"}",
",",
"model",
"*",
"*",
"dom",
".",
"BoxModel",
",",
"opts",
"...",
"QueryOption",
")",
"Action",
"{",
"if",
"model",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return... | // Dimensions retrieves the box model dimensions for the first node matching
// the selector. | [
"Dimensions",
"retrieves",
"the",
"box",
"model",
"dimensions",
"for",
"the",
"first",
"node",
"matching",
"the",
"selector",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/query.go#L86-L98 | train |
chromedp/chromedp | query.go | Text | func Text(sel interface{}, text *string, opts ...QueryOption) Action {
if text == nil {
panic("text cannot be nil")
}
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes", sel)
}
return EvaluateAsDevTo... | go | func Text(sel interface{}, text *string, opts ...QueryOption) Action {
if text == nil {
panic("text cannot be nil")
}
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes", sel)
}
return EvaluateAsDevTo... | [
"func",
"Text",
"(",
"sel",
"interface",
"{",
"}",
",",
"text",
"*",
"string",
",",
"opts",
"...",
"QueryOption",
")",
"Action",
"{",
"if",
"text",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"QueryAfter",
"(",
"se... | // Text retrieves the visible text of the first node matching the selector. | [
"Text",
"retrieves",
"the",
"visible",
"text",
"of",
"the",
"first",
"node",
"matching",
"the",
"selector",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/query.go#L101-L113 | train |
chromedp/chromedp | query.go | Value | func Value(sel interface{}, value *string, opts ...QueryOption) Action {
if value == nil {
panic("value cannot be nil")
}
return JavascriptAttribute(sel, "value", value, opts...)
} | go | func Value(sel interface{}, value *string, opts ...QueryOption) Action {
if value == nil {
panic("value cannot be nil")
}
return JavascriptAttribute(sel, "value", value, opts...)
} | [
"func",
"Value",
"(",
"sel",
"interface",
"{",
"}",
",",
"value",
"*",
"string",
",",
"opts",
"...",
"QueryOption",
")",
"Action",
"{",
"if",
"value",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"JavascriptAttribute",
... | // Value retrieves the value of the first node matching the selector. | [
"Value",
"retrieves",
"the",
"value",
"of",
"the",
"first",
"node",
"matching",
"the",
"selector",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/query.go#L173-L179 | train |
chromedp/chromedp | query.go | SetValue | func SetValue(sel interface{}, value string, opts ...QueryOption) Action {
return SetJavascriptAttribute(sel, "value", value, opts...)
} | go | func SetValue(sel interface{}, value string, opts ...QueryOption) Action {
return SetJavascriptAttribute(sel, "value", value, opts...)
} | [
"func",
"SetValue",
"(",
"sel",
"interface",
"{",
"}",
",",
"value",
"string",
",",
"opts",
"...",
"QueryOption",
")",
"Action",
"{",
"return",
"SetJavascriptAttribute",
"(",
"sel",
",",
"\"",
"\"",
",",
"value",
",",
"opts",
"...",
")",
"\n",
"}"
] | // SetValue sets the value of an element. | [
"SetValue",
"sets",
"the",
"value",
"of",
"an",
"element",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/query.go#L182-L184 | train |
chromedp/chromedp | query.go | Attributes | func Attributes(sel interface{}, attributes *map[string]string, opts ...QueryOption) Action {
if attributes == nil {
panic("attributes cannot be nil")
}
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes",... | go | func Attributes(sel interface{}, attributes *map[string]string, opts ...QueryOption) Action {
if attributes == nil {
panic("attributes cannot be nil")
}
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes",... | [
"func",
"Attributes",
"(",
"sel",
"interface",
"{",
"}",
",",
"attributes",
"*",
"map",
"[",
"string",
"]",
"string",
",",
"opts",
"...",
"QueryOption",
")",
"Action",
"{",
"if",
"attributes",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}... | // Attributes retrieves the element attributes for the first node matching the
// selector. | [
"Attributes",
"retrieves",
"the",
"element",
"attributes",
"for",
"the",
"first",
"node",
"matching",
"the",
"selector",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/query.go#L188-L211 | train |
chromedp/chromedp | query.go | SetAttributes | func SetAttributes(sel interface{}, attributes map[string]string, opts ...QueryOption) Action {
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return errors.New("expected at least one element")
}
i, attrs := 0, make([]string, len(attributes))
for k, v := ra... | go | func SetAttributes(sel interface{}, attributes map[string]string, opts ...QueryOption) Action {
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return errors.New("expected at least one element")
}
i, attrs := 0, make([]string, len(attributes))
for k, v := ra... | [
"func",
"SetAttributes",
"(",
"sel",
"interface",
"{",
"}",
",",
"attributes",
"map",
"[",
"string",
"]",
"string",
",",
"opts",
"...",
"QueryOption",
")",
"Action",
"{",
"return",
"QueryAfter",
"(",
"sel",
",",
"func",
"(",
"ctx",
"context",
".",
"Conte... | // SetAttributes sets the element attributes for the first node matching the
// selector. | [
"SetAttributes",
"sets",
"the",
"element",
"attributes",
"for",
"the",
"first",
"node",
"matching",
"the",
"selector",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/query.go#L245-L259 | train |
chromedp/chromedp | query.go | AttributeValue | func AttributeValue(sel interface{}, name string, value *string, ok *bool, opts ...QueryOption) Action {
if value == nil {
panic("value cannot be nil")
}
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return errors.New("expected at least one element")
}
... | go | func AttributeValue(sel interface{}, name string, value *string, ok *bool, opts ...QueryOption) Action {
if value == nil {
panic("value cannot be nil")
}
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return errors.New("expected at least one element")
}
... | [
"func",
"AttributeValue",
"(",
"sel",
"interface",
"{",
"}",
",",
"name",
"string",
",",
"value",
"*",
"string",
",",
"ok",
"*",
"bool",
",",
"opts",
"...",
"QueryOption",
")",
"Action",
"{",
"if",
"value",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",... | // AttributeValue retrieves the element attribute value for the first node
// matching the selector. | [
"AttributeValue",
"retrieves",
"the",
"element",
"attribute",
"value",
"for",
"the",
"first",
"node",
"matching",
"the",
"selector",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/query.go#L263-L293 | train |
chromedp/chromedp | query.go | SetAttributeValue | func SetAttributeValue(sel interface{}, name, value string, opts ...QueryOption) Action {
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes", sel)
}
return dom.SetAttributeValue(nodes[0].NodeID, name, val... | go | func SetAttributeValue(sel interface{}, name, value string, opts ...QueryOption) Action {
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes", sel)
}
return dom.SetAttributeValue(nodes[0].NodeID, name, val... | [
"func",
"SetAttributeValue",
"(",
"sel",
"interface",
"{",
"}",
",",
"name",
",",
"value",
"string",
",",
"opts",
"...",
"QueryOption",
")",
"Action",
"{",
"return",
"QueryAfter",
"(",
"sel",
",",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"node... | // SetAttributeValue sets the element attribute with name to value for the
// first node matching the selector. | [
"SetAttributeValue",
"sets",
"the",
"element",
"attribute",
"with",
"name",
"to",
"value",
"for",
"the",
"first",
"node",
"matching",
"the",
"selector",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/query.go#L297-L305 | train |
chromedp/chromedp | query.go | JavascriptAttribute | func JavascriptAttribute(sel interface{}, name string, res interface{}, opts ...QueryOption) Action {
if res == nil {
panic("res cannot be nil")
}
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes", sel)
... | go | func JavascriptAttribute(sel interface{}, name string, res interface{}, opts ...QueryOption) Action {
if res == nil {
panic("res cannot be nil")
}
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes", sel)
... | [
"func",
"JavascriptAttribute",
"(",
"sel",
"interface",
"{",
"}",
",",
"name",
"string",
",",
"res",
"interface",
"{",
"}",
",",
"opts",
"...",
"QueryOption",
")",
"Action",
"{",
"if",
"res",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}"... | // JavascriptAttribute retrieves the Javascript attribute for the first node
// matching the selector. | [
"JavascriptAttribute",
"retrieves",
"the",
"Javascript",
"attribute",
"for",
"the",
"first",
"node",
"matching",
"the",
"selector",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/query.go#L321-L332 | train |
chromedp/chromedp | query.go | SetJavascriptAttribute | func SetJavascriptAttribute(sel interface{}, name, value string, opts ...QueryOption) Action {
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes", sel)
}
var res string
err := EvaluateAsDevTools(fmt.Spr... | go | func SetJavascriptAttribute(sel interface{}, name, value string, opts ...QueryOption) Action {
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes", sel)
}
var res string
err := EvaluateAsDevTools(fmt.Spr... | [
"func",
"SetJavascriptAttribute",
"(",
"sel",
"interface",
"{",
"}",
",",
"name",
",",
"value",
"string",
",",
"opts",
"...",
"QueryOption",
")",
"Action",
"{",
"return",
"QueryAfter",
"(",
"sel",
",",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
... | // SetJavascriptAttribute sets the javascript attribute for the first node
// matching the selector. | [
"SetJavascriptAttribute",
"sets",
"the",
"javascript",
"attribute",
"for",
"the",
"first",
"node",
"matching",
"the",
"selector",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/query.go#L336-L353 | train |
chromedp/chromedp | query.go | OuterHTML | func OuterHTML(sel interface{}, html *string, opts ...QueryOption) Action {
if html == nil {
panic("html cannot be nil")
}
return JavascriptAttribute(sel, "outerHTML", html, opts...)
} | go | func OuterHTML(sel interface{}, html *string, opts ...QueryOption) Action {
if html == nil {
panic("html cannot be nil")
}
return JavascriptAttribute(sel, "outerHTML", html, opts...)
} | [
"func",
"OuterHTML",
"(",
"sel",
"interface",
"{",
"}",
",",
"html",
"*",
"string",
",",
"opts",
"...",
"QueryOption",
")",
"Action",
"{",
"if",
"html",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"JavascriptAttribute",
... | // OuterHTML retrieves the outer html of the first node matching the selector. | [
"OuterHTML",
"retrieves",
"the",
"outer",
"html",
"of",
"the",
"first",
"node",
"matching",
"the",
"selector",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/query.go#L356-L361 | train |
chromedp/chromedp | query.go | Click | func Click(sel interface{}, opts ...QueryOption) Action {
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes", sel)
}
return MouseClickNode(nodes[0]).Do(ctx)
}, append(opts, NodeVisible)...)
} | go | func Click(sel interface{}, opts ...QueryOption) Action {
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes", sel)
}
return MouseClickNode(nodes[0]).Do(ctx)
}, append(opts, NodeVisible)...)
} | [
"func",
"Click",
"(",
"sel",
"interface",
"{",
"}",
",",
"opts",
"...",
"QueryOption",
")",
"Action",
"{",
"return",
"QueryAfter",
"(",
"sel",
",",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"nodes",
"...",
"*",
"cdp",
".",
"Node",
")",
"err... | // Click sends a mouse click event to the first node matching the selector. | [
"Click",
"sends",
"a",
"mouse",
"click",
"event",
"to",
"the",
"first",
"node",
"matching",
"the",
"selector",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/query.go#L372-L380 | train |
chromedp/chromedp | query.go | Screenshot | func Screenshot(sel interface{}, picbuf *[]byte, opts ...QueryOption) Action {
if picbuf == nil {
panic("picbuf cannot be nil")
}
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes", sel)
}
// get box... | go | func Screenshot(sel interface{}, picbuf *[]byte, opts ...QueryOption) Action {
if picbuf == nil {
panic("picbuf cannot be nil")
}
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes", sel)
}
// get box... | [
"func",
"Screenshot",
"(",
"sel",
"interface",
"{",
"}",
",",
"picbuf",
"*",
"[",
"]",
"byte",
",",
"opts",
"...",
"QueryOption",
")",
"Action",
"{",
"if",
"picbuf",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"Que... | // Screenshot takes a screenshot of the first node matching the selector. | [
"Screenshot",
"takes",
"a",
"screenshot",
"of",
"the",
"first",
"node",
"matching",
"the",
"selector",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/query.go#L439-L495 | train |
chromedp/chromedp | query.go | Reset | func Reset(sel interface{}, opts ...QueryOption) Action {
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes", sel)
}
var res bool
err := EvaluateAsDevTools(fmt.Sprintf(resetJS, nodes[0].FullXPath()), &r... | go | func Reset(sel interface{}, opts ...QueryOption) Action {
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes", sel)
}
var res bool
err := EvaluateAsDevTools(fmt.Sprintf(resetJS, nodes[0].FullXPath()), &r... | [
"func",
"Reset",
"(",
"sel",
"interface",
"{",
"}",
",",
"opts",
"...",
"QueryOption",
")",
"Action",
"{",
"return",
"QueryAfter",
"(",
"sel",
",",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"nodes",
"...",
"*",
"cdp",
".",
"Node",
")",
"err... | // Reset is an action that resets the form of the first node matching the
// selector belongs to. | [
"Reset",
"is",
"an",
"action",
"that",
"resets",
"the",
"form",
"of",
"the",
"first",
"node",
"matching",
"the",
"selector",
"belongs",
"to",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/query.go#L521-L539 | train |
chromedp/chromedp | query.go | ComputedStyle | func ComputedStyle(sel interface{}, style *[]*css.ComputedProperty, opts ...QueryOption) Action {
if style == nil {
panic("style cannot be nil")
}
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes", sel)
... | go | func ComputedStyle(sel interface{}, style *[]*css.ComputedProperty, opts ...QueryOption) Action {
if style == nil {
panic("style cannot be nil")
}
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes", sel)
... | [
"func",
"ComputedStyle",
"(",
"sel",
"interface",
"{",
"}",
",",
"style",
"*",
"[",
"]",
"*",
"css",
".",
"ComputedProperty",
",",
"opts",
"...",
"QueryOption",
")",
"Action",
"{",
"if",
"style",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",... | // ComputedStyle retrieves the computed style of the first node matching the selector. | [
"ComputedStyle",
"retrieves",
"the",
"computed",
"style",
"of",
"the",
"first",
"node",
"matching",
"the",
"selector",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/query.go#L542-L561 | train |
chromedp/chromedp | query.go | MatchedStyle | func MatchedStyle(sel interface{}, style **css.GetMatchedStylesForNodeReturns, opts ...QueryOption) Action {
if style == nil {
panic("style cannot be nil")
}
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any no... | go | func MatchedStyle(sel interface{}, style **css.GetMatchedStylesForNodeReturns, opts ...QueryOption) Action {
if style == nil {
panic("style cannot be nil")
}
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any no... | [
"func",
"MatchedStyle",
"(",
"sel",
"interface",
"{",
"}",
",",
"style",
"*",
"*",
"css",
".",
"GetMatchedStylesForNodeReturns",
",",
"opts",
"...",
"QueryOption",
")",
"Action",
"{",
"if",
"style",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
... | // MatchedStyle retrieves the matched style information for the first node
// matching the selector. | [
"MatchedStyle",
"retrieves",
"the",
"matched",
"style",
"information",
"for",
"the",
"first",
"node",
"matching",
"the",
"selector",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/query.go#L565-L588 | train |
chromedp/chromedp | query.go | ScrollIntoView | func ScrollIntoView(sel interface{}, opts ...QueryOption) Action {
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes", sel)
}
var pos []int
err := EvaluateAsDevTools(fmt.Sprintf(scrollIntoViewJS, nodes[... | go | func ScrollIntoView(sel interface{}, opts ...QueryOption) Action {
return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
return fmt.Errorf("selector `%s` did not return any nodes", sel)
}
var pos []int
err := EvaluateAsDevTools(fmt.Sprintf(scrollIntoViewJS, nodes[... | [
"func",
"ScrollIntoView",
"(",
"sel",
"interface",
"{",
"}",
",",
"opts",
"...",
"QueryOption",
")",
"Action",
"{",
"return",
"QueryAfter",
"(",
"sel",
",",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"nodes",
"...",
"*",
"cdp",
".",
"Node",
")... | // ScrollIntoView scrolls the window to the first node matching the selector. | [
"ScrollIntoView",
"scrolls",
"the",
"window",
"to",
"the",
"first",
"node",
"matching",
"the",
"selector",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/query.go#L591-L609 | train |
chromedp/chromedp | target.go | documentUpdated | func (t *Target) documentUpdated(ctx context.Context) {
f := t.cur
f.Lock()
defer f.Unlock()
// invalidate nodes
if f.Root != nil {
close(f.Root.Invalidated)
}
f.Nodes = make(map[cdp.NodeID]*cdp.Node)
var err error
f.Root, err = dom.GetDocument().WithPierce(true).Do(cdp.WithExecutor(ctx, t))
if err == con... | go | func (t *Target) documentUpdated(ctx context.Context) {
f := t.cur
f.Lock()
defer f.Unlock()
// invalidate nodes
if f.Root != nil {
close(f.Root.Invalidated)
}
f.Nodes = make(map[cdp.NodeID]*cdp.Node)
var err error
f.Root, err = dom.GetDocument().WithPierce(true).Do(cdp.WithExecutor(ctx, t))
if err == con... | [
"func",
"(",
"t",
"*",
"Target",
")",
"documentUpdated",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"f",
":=",
"t",
".",
"cur",
"\n",
"f",
".",
"Lock",
"(",
")",
"\n",
"defer",
"f",
".",
"Unlock",
"(",
")",
"\n\n",
"// invalidate nodes",
"if"... | // documentUpdated handles the document updated event, retrieving the document
// root for the root frame. | [
"documentUpdated",
"handles",
"the",
"document",
"updated",
"event",
"retrieving",
"the",
"document",
"root",
"for",
"the",
"root",
"frame",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/target.go#L168-L190 | train |
chromedp/chromedp | target.go | pageEvent | func (t *Target) pageEvent(ev interface{}) {
var id cdp.FrameID
var op frameOp
switch e := ev.(type) {
case *page.EventFrameNavigated:
t.frames[e.Frame.ID] = e.Frame
if e.Frame.ParentID == "" {
// This frame is only the new top-level frame if it has
// no parent.
t.cur = e.Frame
}
return
case *p... | go | func (t *Target) pageEvent(ev interface{}) {
var id cdp.FrameID
var op frameOp
switch e := ev.(type) {
case *page.EventFrameNavigated:
t.frames[e.Frame.ID] = e.Frame
if e.Frame.ParentID == "" {
// This frame is only the new top-level frame if it has
// no parent.
t.cur = e.Frame
}
return
case *p... | [
"func",
"(",
"t",
"*",
"Target",
")",
"pageEvent",
"(",
"ev",
"interface",
"{",
"}",
")",
"{",
"var",
"id",
"cdp",
".",
"FrameID",
"\n",
"var",
"op",
"frameOp",
"\n\n",
"switch",
"e",
":=",
"ev",
".",
"(",
"type",
")",
"{",
"case",
"*",
"page",
... | // pageEvent handles incoming page events. | [
"pageEvent",
"handles",
"incoming",
"page",
"events",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/target.go#L196-L257 | train |
chromedp/chromedp | target.go | domEvent | func (t *Target) domEvent(ctx context.Context, ev interface{}) {
f := t.cur
var id cdp.NodeID
var op nodeOp
switch e := ev.(type) {
case *dom.EventDocumentUpdated:
t.documentUpdated(ctx)
return
case *dom.EventSetChildNodes:
id, op = e.ParentID, setChildNodes(f.Nodes, e.Nodes)
case *dom.EventAttributeMod... | go | func (t *Target) domEvent(ctx context.Context, ev interface{}) {
f := t.cur
var id cdp.NodeID
var op nodeOp
switch e := ev.(type) {
case *dom.EventDocumentUpdated:
t.documentUpdated(ctx)
return
case *dom.EventSetChildNodes:
id, op = e.ParentID, setChildNodes(f.Nodes, e.Nodes)
case *dom.EventAttributeMod... | [
"func",
"(",
"t",
"*",
"Target",
")",
"domEvent",
"(",
"ctx",
"context",
".",
"Context",
",",
"ev",
"interface",
"{",
"}",
")",
"{",
"f",
":=",
"t",
".",
"cur",
"\n",
"var",
"id",
"cdp",
".",
"NodeID",
"\n",
"var",
"op",
"nodeOp",
"\n\n",
"switch... | // domEvent handles incoming DOM events. | [
"domEvent",
"handles",
"incoming",
"DOM",
"events",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/target.go#L260-L327 | train |
chromedp/chromedp | input.go | MouseAction | func MouseAction(typ input.MouseType, x, y int64, opts ...MouseOption) Action {
me := input.DispatchMouseEvent(typ, float64(x), float64(y))
// apply opts
for _, o := range opts {
me = o(me)
}
return me
} | go | func MouseAction(typ input.MouseType, x, y int64, opts ...MouseOption) Action {
me := input.DispatchMouseEvent(typ, float64(x), float64(y))
// apply opts
for _, o := range opts {
me = o(me)
}
return me
} | [
"func",
"MouseAction",
"(",
"typ",
"input",
".",
"MouseType",
",",
"x",
",",
"y",
"int64",
",",
"opts",
"...",
"MouseOption",
")",
"Action",
"{",
"me",
":=",
"input",
".",
"DispatchMouseEvent",
"(",
"typ",
",",
"float64",
"(",
"x",
")",
",",
"float64",... | // MouseAction is a mouse action. | [
"MouseAction",
"is",
"a",
"mouse",
"action",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/input.go#L15-L24 | train |
chromedp/chromedp | input.go | MouseClickNode | func MouseClickNode(n *cdp.Node, opts ...MouseOption) Action {
return ActionFunc(func(ctx context.Context) error {
var pos []int
err := EvaluateAsDevTools(fmt.Sprintf(scrollIntoViewJS, n.FullXPath()), &pos).Do(ctx)
if err != nil {
return err
}
box, err := dom.GetBoxModel().WithNodeID(n.NodeID).Do(ctx)
... | go | func MouseClickNode(n *cdp.Node, opts ...MouseOption) Action {
return ActionFunc(func(ctx context.Context) error {
var pos []int
err := EvaluateAsDevTools(fmt.Sprintf(scrollIntoViewJS, n.FullXPath()), &pos).Do(ctx)
if err != nil {
return err
}
box, err := dom.GetBoxModel().WithNodeID(n.NodeID).Do(ctx)
... | [
"func",
"MouseClickNode",
"(",
"n",
"*",
"cdp",
".",
"Node",
",",
"opts",
"...",
"MouseOption",
")",
"Action",
"{",
"return",
"ActionFunc",
"(",
"func",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"var",
"pos",
"[",
"]",
"int",
"\n",
"e... | // MouseClickNode dispatches a mouse left button click event at the center of a
// specified node.
//
// Note that the window will be scrolled if the node is not within the window's
// viewport. | [
"MouseClickNode",
"dispatches",
"a",
"mouse",
"left",
"button",
"click",
"event",
"at",
"the",
"center",
"of",
"a",
"specified",
"node",
".",
"Note",
"that",
"the",
"window",
"will",
"be",
"scrolled",
"if",
"the",
"node",
"is",
"not",
"within",
"the",
"win... | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/input.go#L57-L85 | train |
chromedp/chromedp | input.go | ButtonType | func ButtonType(button input.ButtonType) MouseOption {
return func(p *input.DispatchMouseEventParams) *input.DispatchMouseEventParams {
return p.WithButton(button)
}
} | go | func ButtonType(button input.ButtonType) MouseOption {
return func(p *input.DispatchMouseEventParams) *input.DispatchMouseEventParams {
return p.WithButton(button)
}
} | [
"func",
"ButtonType",
"(",
"button",
"input",
".",
"ButtonType",
")",
"MouseOption",
"{",
"return",
"func",
"(",
"p",
"*",
"input",
".",
"DispatchMouseEventParams",
")",
"*",
"input",
".",
"DispatchMouseEventParams",
"{",
"return",
"p",
".",
"WithButton",
"(",... | // ButtonType is a mouse action option to set the button to click. | [
"ButtonType",
"is",
"a",
"mouse",
"action",
"option",
"to",
"set",
"the",
"button",
"to",
"click",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/input.go#L96-L100 | train |
chromedp/chromedp | input.go | ButtonLeft | func ButtonLeft(p *input.DispatchMouseEventParams) *input.DispatchMouseEventParams {
return p.WithButton(input.ButtonLeft)
} | go | func ButtonLeft(p *input.DispatchMouseEventParams) *input.DispatchMouseEventParams {
return p.WithButton(input.ButtonLeft)
} | [
"func",
"ButtonLeft",
"(",
"p",
"*",
"input",
".",
"DispatchMouseEventParams",
")",
"*",
"input",
".",
"DispatchMouseEventParams",
"{",
"return",
"p",
".",
"WithButton",
"(",
"input",
".",
"ButtonLeft",
")",
"\n",
"}"
] | // ButtonLeft is a mouse action option to set the button clicked as the left
// mouse button. | [
"ButtonLeft",
"is",
"a",
"mouse",
"action",
"option",
"to",
"set",
"the",
"button",
"clicked",
"as",
"the",
"left",
"mouse",
"button",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/input.go#L104-L106 | train |
chromedp/chromedp | input.go | ButtonMiddle | func ButtonMiddle(p *input.DispatchMouseEventParams) *input.DispatchMouseEventParams {
return p.WithButton(input.ButtonMiddle)
} | go | func ButtonMiddle(p *input.DispatchMouseEventParams) *input.DispatchMouseEventParams {
return p.WithButton(input.ButtonMiddle)
} | [
"func",
"ButtonMiddle",
"(",
"p",
"*",
"input",
".",
"DispatchMouseEventParams",
")",
"*",
"input",
".",
"DispatchMouseEventParams",
"{",
"return",
"p",
".",
"WithButton",
"(",
"input",
".",
"ButtonMiddle",
")",
"\n",
"}"
] | // ButtonMiddle is a mouse action option to set the button clicked as the middle
// mouse button. | [
"ButtonMiddle",
"is",
"a",
"mouse",
"action",
"option",
"to",
"set",
"the",
"button",
"clicked",
"as",
"the",
"middle",
"mouse",
"button",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/input.go#L110-L112 | train |
chromedp/chromedp | input.go | ButtonRight | func ButtonRight(p *input.DispatchMouseEventParams) *input.DispatchMouseEventParams {
return p.WithButton(input.ButtonRight)
} | go | func ButtonRight(p *input.DispatchMouseEventParams) *input.DispatchMouseEventParams {
return p.WithButton(input.ButtonRight)
} | [
"func",
"ButtonRight",
"(",
"p",
"*",
"input",
".",
"DispatchMouseEventParams",
")",
"*",
"input",
".",
"DispatchMouseEventParams",
"{",
"return",
"p",
".",
"WithButton",
"(",
"input",
".",
"ButtonRight",
")",
"\n",
"}"
] | // ButtonRight is a mouse action option to set the button clicked as the right
// mouse button. | [
"ButtonRight",
"is",
"a",
"mouse",
"action",
"option",
"to",
"set",
"the",
"button",
"clicked",
"as",
"the",
"right",
"mouse",
"button",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/input.go#L116-L118 | train |
chromedp/chromedp | input.go | ButtonModifiers | func ButtonModifiers(modifiers ...input.Modifier) MouseOption {
return func(p *input.DispatchMouseEventParams) *input.DispatchMouseEventParams {
for _, m := range modifiers {
p.Modifiers |= m
}
return p
}
} | go | func ButtonModifiers(modifiers ...input.Modifier) MouseOption {
return func(p *input.DispatchMouseEventParams) *input.DispatchMouseEventParams {
for _, m := range modifiers {
p.Modifiers |= m
}
return p
}
} | [
"func",
"ButtonModifiers",
"(",
"modifiers",
"...",
"input",
".",
"Modifier",
")",
"MouseOption",
"{",
"return",
"func",
"(",
"p",
"*",
"input",
".",
"DispatchMouseEventParams",
")",
"*",
"input",
".",
"DispatchMouseEventParams",
"{",
"for",
"_",
",",
"m",
"... | // ButtonModifiers is a mouse action option to add additional input modifiers
// for a button click. | [
"ButtonModifiers",
"is",
"a",
"mouse",
"action",
"option",
"to",
"add",
"additional",
"input",
"modifiers",
"for",
"a",
"button",
"click",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/input.go#L128-L135 | train |
chromedp/chromedp | input.go | ClickCount | func ClickCount(n int) MouseOption {
return func(p *input.DispatchMouseEventParams) *input.DispatchMouseEventParams {
return p.WithClickCount(int64(n))
}
} | go | func ClickCount(n int) MouseOption {
return func(p *input.DispatchMouseEventParams) *input.DispatchMouseEventParams {
return p.WithClickCount(int64(n))
}
} | [
"func",
"ClickCount",
"(",
"n",
"int",
")",
"MouseOption",
"{",
"return",
"func",
"(",
"p",
"*",
"input",
".",
"DispatchMouseEventParams",
")",
"*",
"input",
".",
"DispatchMouseEventParams",
"{",
"return",
"p",
".",
"WithClickCount",
"(",
"int64",
"(",
"n",
... | // ClickCount is a mouse action option to set the click count. | [
"ClickCount",
"is",
"a",
"mouse",
"action",
"option",
"to",
"set",
"the",
"click",
"count",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/input.go#L138-L142 | train |
chromedp/chromedp | input.go | KeyActionNode | func KeyActionNode(n *cdp.Node, keys string, opts ...KeyOption) Action {
return ActionFunc(func(ctx context.Context) error {
err := dom.Focus().WithNodeID(n.NodeID).Do(ctx)
if err != nil {
return err
}
return KeyAction(keys, opts...).Do(ctx)
})
} | go | func KeyActionNode(n *cdp.Node, keys string, opts ...KeyOption) Action {
return ActionFunc(func(ctx context.Context) error {
err := dom.Focus().WithNodeID(n.NodeID).Do(ctx)
if err != nil {
return err
}
return KeyAction(keys, opts...).Do(ctx)
})
} | [
"func",
"KeyActionNode",
"(",
"n",
"*",
"cdp",
".",
"Node",
",",
"keys",
"string",
",",
"opts",
"...",
"KeyOption",
")",
"Action",
"{",
"return",
"ActionFunc",
"(",
"func",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"err",
":=",
"dom",
... | // KeyActionNode dispatches a key event on a node. | [
"KeyActionNode",
"dispatches",
"a",
"key",
"event",
"on",
"a",
"node",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/input.go#L166-L175 | train |
chromedp/chromedp | input.go | KeyModifiers | func KeyModifiers(modifiers ...input.Modifier) KeyOption {
return func(p *input.DispatchKeyEventParams) *input.DispatchKeyEventParams {
for _, m := range modifiers {
p.Modifiers |= m
}
return p
}
} | go | func KeyModifiers(modifiers ...input.Modifier) KeyOption {
return func(p *input.DispatchKeyEventParams) *input.DispatchKeyEventParams {
for _, m := range modifiers {
p.Modifiers |= m
}
return p
}
} | [
"func",
"KeyModifiers",
"(",
"modifiers",
"...",
"input",
".",
"Modifier",
")",
"KeyOption",
"{",
"return",
"func",
"(",
"p",
"*",
"input",
".",
"DispatchKeyEventParams",
")",
"*",
"input",
".",
"DispatchKeyEventParams",
"{",
"for",
"_",
",",
"m",
":=",
"r... | // KeyModifiers is a key action option to add additional modifiers on the key
// press. | [
"KeyModifiers",
"is",
"a",
"key",
"action",
"option",
"to",
"add",
"additional",
"modifiers",
"on",
"the",
"key",
"press",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/input.go#L182-L189 | train |
chromedp/chromedp | browser.go | NewBrowser | func NewBrowser(ctx context.Context, urlstr string, opts ...BrowserOption) (*Browser, error) {
b := &Browser{
LostConnection: make(chan struct{}),
newTabQueue: make(chan *Target),
delTabQueue: make(chan target.SessionID, 1),
// Fit some jobs without blocking, to reduce blocking in
// Execute.
cmdQueue: m... | go | func NewBrowser(ctx context.Context, urlstr string, opts ...BrowserOption) (*Browser, error) {
b := &Browser{
LostConnection: make(chan struct{}),
newTabQueue: make(chan *Target),
delTabQueue: make(chan target.SessionID, 1),
// Fit some jobs without blocking, to reduce blocking in
// Execute.
cmdQueue: m... | [
"func",
"NewBrowser",
"(",
"ctx",
"context",
".",
"Context",
",",
"urlstr",
"string",
",",
"opts",
"...",
"BrowserOption",
")",
"(",
"*",
"Browser",
",",
"error",
")",
"{",
"b",
":=",
"&",
"Browser",
"{",
"LostConnection",
":",
"make",
"(",
"chan",
"st... | // NewBrowser creates a new browser. | [
"NewBrowser",
"creates",
"a",
"new",
"browser",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/browser.go#L90-L122 | train |
chromedp/chromedp | nav.go | Navigate | func Navigate(urlstr string) Action {
return ActionFunc(func(ctx context.Context) error {
_, _, _, err := page.Navigate(urlstr).Do(ctx)
return err
})
} | go | func Navigate(urlstr string) Action {
return ActionFunc(func(ctx context.Context) error {
_, _, _, err := page.Navigate(urlstr).Do(ctx)
return err
})
} | [
"func",
"Navigate",
"(",
"urlstr",
"string",
")",
"Action",
"{",
"return",
"ActionFunc",
"(",
"func",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"_",
",",
"_",
",",
"_",
",",
"err",
":=",
"page",
".",
"Navigate",
"(",
"urlstr",
")",
... | // Navigate navigates the current frame. | [
"Navigate",
"navigates",
"the",
"current",
"frame",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/nav.go#L11-L16 | train |
chromedp/chromedp | nav.go | NavigationEntries | func NavigationEntries(currentIndex *int64, entries *[]*page.NavigationEntry) Action {
if currentIndex == nil || entries == nil {
panic("currentIndex and entries cannot be nil")
}
return ActionFunc(func(ctx context.Context) error {
var err error
*currentIndex, *entries, err = page.GetNavigationHistory().Do(ct... | go | func NavigationEntries(currentIndex *int64, entries *[]*page.NavigationEntry) Action {
if currentIndex == nil || entries == nil {
panic("currentIndex and entries cannot be nil")
}
return ActionFunc(func(ctx context.Context) error {
var err error
*currentIndex, *entries, err = page.GetNavigationHistory().Do(ct... | [
"func",
"NavigationEntries",
"(",
"currentIndex",
"*",
"int64",
",",
"entries",
"*",
"[",
"]",
"*",
"page",
".",
"NavigationEntry",
")",
"Action",
"{",
"if",
"currentIndex",
"==",
"nil",
"||",
"entries",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
... | // NavigationEntries is an action to retrieve the page's navigation history
// entries. | [
"NavigationEntries",
"is",
"an",
"action",
"to",
"retrieve",
"the",
"page",
"s",
"navigation",
"history",
"entries",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/nav.go#L20-L30 | train |
chromedp/chromedp | nav.go | NavigateBack | func NavigateBack() Action {
return ActionFunc(func(ctx context.Context) error {
cur, entries, err := page.GetNavigationHistory().Do(ctx)
if err != nil {
return err
}
if cur <= 0 || cur > int64(len(entries)-1) {
return errors.New("invalid navigation entry")
}
return page.NavigateToHistoryEntry(entr... | go | func NavigateBack() Action {
return ActionFunc(func(ctx context.Context) error {
cur, entries, err := page.GetNavigationHistory().Do(ctx)
if err != nil {
return err
}
if cur <= 0 || cur > int64(len(entries)-1) {
return errors.New("invalid navigation entry")
}
return page.NavigateToHistoryEntry(entr... | [
"func",
"NavigateBack",
"(",
")",
"Action",
"{",
"return",
"ActionFunc",
"(",
"func",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"cur",
",",
"entries",
",",
"err",
":=",
"page",
".",
"GetNavigationHistory",
"(",
")",
".",
"Do",
"(",
"ctx... | // NavigateBack navigates the current frame backwards in its history. | [
"NavigateBack",
"navigates",
"the",
"current",
"frame",
"backwards",
"in",
"its",
"history",
"."
] | d15a83b928250a6181ad5c2cd843b530a581fd2b | https://github.com/chromedp/chromedp/blob/d15a83b928250a6181ad5c2cd843b530a581fd2b/nav.go#L39-L52 | train |
argoproj/argo | workflow/controller/controller.go | NewWorkflowController | func NewWorkflowController(
restConfig *rest.Config,
kubeclientset kubernetes.Interface,
wfclientset wfclientset.Interface,
namespace,
executorImage,
executorImagePullPolicy,
configMap string,
) *WorkflowController {
wfc := WorkflowController{
restConfig: restConfig,
kubeclientset: ... | go | func NewWorkflowController(
restConfig *rest.Config,
kubeclientset kubernetes.Interface,
wfclientset wfclientset.Interface,
namespace,
executorImage,
executorImagePullPolicy,
configMap string,
) *WorkflowController {
wfc := WorkflowController{
restConfig: restConfig,
kubeclientset: ... | [
"func",
"NewWorkflowController",
"(",
"restConfig",
"*",
"rest",
".",
"Config",
",",
"kubeclientset",
"kubernetes",
".",
"Interface",
",",
"wfclientset",
"wfclientset",
".",
"Interface",
",",
"namespace",
",",
"executorImage",
",",
"executorImagePullPolicy",
",",
"c... | // NewWorkflowController instantiates a new WorkflowController | [
"NewWorkflowController",
"instantiates",
"a",
"new",
"WorkflowController"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/controller/controller.go#L69-L92 | train |
argoproj/argo | workflow/controller/controller.go | MetricsServer | func (wfc *WorkflowController) MetricsServer(ctx context.Context) {
if wfc.Config.MetricsConfig.Enabled {
informer := util.NewWorkflowInformer(wfc.restConfig, wfc.Config.Namespace, workflowMetricsResyncPeriod, wfc.tweakWorkflowMetricslist)
go informer.Run(ctx.Done())
registry := metrics.NewWorkflowRegistry(infor... | go | func (wfc *WorkflowController) MetricsServer(ctx context.Context) {
if wfc.Config.MetricsConfig.Enabled {
informer := util.NewWorkflowInformer(wfc.restConfig, wfc.Config.Namespace, workflowMetricsResyncPeriod, wfc.tweakWorkflowMetricslist)
go informer.Run(ctx.Done())
registry := metrics.NewWorkflowRegistry(infor... | [
"func",
"(",
"wfc",
"*",
"WorkflowController",
")",
"MetricsServer",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"if",
"wfc",
".",
"Config",
".",
"MetricsConfig",
".",
"Enabled",
"{",
"informer",
":=",
"util",
".",
"NewWorkflowInformer",
"(",
"wfc",
"... | // MetricsServer starts a prometheus metrics server if enabled in the configmap | [
"MetricsServer",
"starts",
"a",
"prometheus",
"metrics",
"server",
"if",
"enabled",
"in",
"the",
"configmap"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/controller/controller.go#L95-L102 | train |
argoproj/argo | workflow/controller/controller.go | TelemetryServer | func (wfc *WorkflowController) TelemetryServer(ctx context.Context) {
if wfc.Config.TelemetryConfig.Enabled {
registry := metrics.NewTelemetryRegistry()
metrics.RunServer(ctx, wfc.Config.TelemetryConfig, registry)
}
} | go | func (wfc *WorkflowController) TelemetryServer(ctx context.Context) {
if wfc.Config.TelemetryConfig.Enabled {
registry := metrics.NewTelemetryRegistry()
metrics.RunServer(ctx, wfc.Config.TelemetryConfig, registry)
}
} | [
"func",
"(",
"wfc",
"*",
"WorkflowController",
")",
"TelemetryServer",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"if",
"wfc",
".",
"Config",
".",
"TelemetryConfig",
".",
"Enabled",
"{",
"registry",
":=",
"metrics",
".",
"NewTelemetryRegistry",
"(",
")... | // TelemetryServer starts a prometheus telemetry server if enabled in the configmap | [
"TelemetryServer",
"starts",
"a",
"prometheus",
"telemetry",
"server",
"if",
"enabled",
"in",
"the",
"configmap"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/controller/controller.go#L105-L110 | train |
argoproj/argo | workflow/controller/controller.go | RunTTLController | func (wfc *WorkflowController) RunTTLController(ctx context.Context) {
ttlCtrl := ttlcontroller.NewController(
wfc.restConfig,
wfc.wfclientset,
wfc.Config.Namespace,
wfc.Config.InstanceID,
)
err := ttlCtrl.Run(ctx.Done())
if err != nil {
panic(err)
}
} | go | func (wfc *WorkflowController) RunTTLController(ctx context.Context) {
ttlCtrl := ttlcontroller.NewController(
wfc.restConfig,
wfc.wfclientset,
wfc.Config.Namespace,
wfc.Config.InstanceID,
)
err := ttlCtrl.Run(ctx.Done())
if err != nil {
panic(err)
}
} | [
"func",
"(",
"wfc",
"*",
"WorkflowController",
")",
"RunTTLController",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"ttlCtrl",
":=",
"ttlcontroller",
".",
"NewController",
"(",
"wfc",
".",
"restConfig",
",",
"wfc",
".",
"wfclientset",
",",
"wfc",
".",
... | // RunTTLController runs the workflow TTL controller | [
"RunTTLController",
"runs",
"the",
"workflow",
"TTL",
"controller"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/controller/controller.go#L113-L124 | train |
argoproj/argo | workflow/controller/controller.go | Run | func (wfc *WorkflowController) Run(ctx context.Context, wfWorkers, podWorkers int) {
defer wfc.wfQueue.ShutDown()
defer wfc.podQueue.ShutDown()
log.Infof("Workflow Controller (version: %s) starting", argo.GetVersion())
log.Infof("Workers: workflow: %d, pod: %d", wfWorkers, podWorkers)
log.Info("Watch Workflow con... | go | func (wfc *WorkflowController) Run(ctx context.Context, wfWorkers, podWorkers int) {
defer wfc.wfQueue.ShutDown()
defer wfc.podQueue.ShutDown()
log.Infof("Workflow Controller (version: %s) starting", argo.GetVersion())
log.Infof("Workers: workflow: %d, pod: %d", wfWorkers, podWorkers)
log.Info("Watch Workflow con... | [
"func",
"(",
"wfc",
"*",
"WorkflowController",
")",
"Run",
"(",
"ctx",
"context",
".",
"Context",
",",
"wfWorkers",
",",
"podWorkers",
"int",
")",
"{",
"defer",
"wfc",
".",
"wfQueue",
".",
"ShutDown",
"(",
")",
"\n",
"defer",
"wfc",
".",
"podQueue",
".... | // Run starts an Workflow resource controller | [
"Run",
"starts",
"an",
"Workflow",
"resource",
"controller"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/controller/controller.go#L127-L164 | train |
argoproj/argo | workflow/controller/controller.go | podLabeler | func (wfc *WorkflowController) podLabeler(stopCh <-chan struct{}) {
for {
select {
case <-stopCh:
return
case pod := <-wfc.completedPods:
parts := strings.Split(pod, "/")
if len(parts) != 2 {
log.Warnf("Unexpected item on completed pod channel: %s", pod)
continue
}
namespace := parts[0]
... | go | func (wfc *WorkflowController) podLabeler(stopCh <-chan struct{}) {
for {
select {
case <-stopCh:
return
case pod := <-wfc.completedPods:
parts := strings.Split(pod, "/")
if len(parts) != 2 {
log.Warnf("Unexpected item on completed pod channel: %s", pod)
continue
}
namespace := parts[0]
... | [
"func",
"(",
"wfc",
"*",
"WorkflowController",
")",
"podLabeler",
"(",
"stopCh",
"<-",
"chan",
"struct",
"{",
"}",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"<-",
"stopCh",
":",
"return",
"\n",
"case",
"pod",
":=",
"<-",
"wfc",
".",
"completedPods",... | // podLabeler will label all pods on the controllers completedPod channel as completed | [
"podLabeler",
"will",
"label",
"all",
"pods",
"on",
"the",
"controllers",
"completedPod",
"channel",
"as",
"completed"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/controller/controller.go#L167-L190 | train |
argoproj/argo | workflow/controller/controller.go | processNextItem | func (wfc *WorkflowController) processNextItem() bool {
key, quit := wfc.wfQueue.Get()
if quit {
return false
}
defer wfc.wfQueue.Done(key)
obj, exists, err := wfc.wfInformer.GetIndexer().GetByKey(key.(string))
if err != nil {
log.Errorf("Failed to get workflow '%s' from informer index: %+v", key, err)
ret... | go | func (wfc *WorkflowController) processNextItem() bool {
key, quit := wfc.wfQueue.Get()
if quit {
return false
}
defer wfc.wfQueue.Done(key)
obj, exists, err := wfc.wfInformer.GetIndexer().GetByKey(key.(string))
if err != nil {
log.Errorf("Failed to get workflow '%s' from informer index: %+v", key, err)
ret... | [
"func",
"(",
"wfc",
"*",
"WorkflowController",
")",
"processNextItem",
"(",
")",
"bool",
"{",
"key",
",",
"quit",
":=",
"wfc",
".",
"wfQueue",
".",
"Get",
"(",
")",
"\n",
"if",
"quit",
"{",
"return",
"false",
"\n",
"}",
"\n",
"defer",
"wfc",
".",
"... | // processNextItem is the worker logic for handling workflow updates | [
"processNextItem",
"is",
"the",
"worker",
"logic",
"for",
"handling",
"workflow",
"updates"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/controller/controller.go#L198-L266 | train |
argoproj/argo | workflow/controller/controller.go | processNextPodItem | func (wfc *WorkflowController) processNextPodItem() bool {
key, quit := wfc.podQueue.Get()
if quit {
return false
}
defer wfc.podQueue.Done(key)
obj, exists, err := wfc.podInformer.GetIndexer().GetByKey(key.(string))
if err != nil {
log.Errorf("Failed to get pod '%s' from informer index: %+v", key, err)
re... | go | func (wfc *WorkflowController) processNextPodItem() bool {
key, quit := wfc.podQueue.Get()
if quit {
return false
}
defer wfc.podQueue.Done(key)
obj, exists, err := wfc.podInformer.GetIndexer().GetByKey(key.(string))
if err != nil {
log.Errorf("Failed to get pod '%s' from informer index: %+v", key, err)
re... | [
"func",
"(",
"wfc",
"*",
"WorkflowController",
")",
"processNextPodItem",
"(",
")",
"bool",
"{",
"key",
",",
"quit",
":=",
"wfc",
".",
"podQueue",
".",
"Get",
"(",
")",
"\n",
"if",
"quit",
"{",
"return",
"false",
"\n",
"}",
"\n",
"defer",
"wfc",
".",... | // processNextPodItem is the worker logic for handling pod updates.
// For pods updates, this simply means to "wake up" the workflow by
// adding the corresponding workflow key into the workflow workqueue. | [
"processNextPodItem",
"is",
"the",
"worker",
"logic",
"for",
"handling",
"pod",
"updates",
".",
"For",
"pods",
"updates",
"this",
"simply",
"means",
"to",
"wake",
"up",
"the",
"workflow",
"by",
"adding",
"the",
"corresponding",
"workflow",
"key",
"into",
"the"... | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/controller/controller.go#L276-L314 | train |
argoproj/argo | workflow/executor/executor.go | NewExecutor | func NewExecutor(clientset kubernetes.Interface, podName, namespace, podAnnotationsPath string, cre ContainerRuntimeExecutor, template wfv1.Template) WorkflowExecutor {
return WorkflowExecutor{
PodName: podName,
ClientSet: clientset,
Namespace: namespace,
PodAnnotationsPath: podAnn... | go | func NewExecutor(clientset kubernetes.Interface, podName, namespace, podAnnotationsPath string, cre ContainerRuntimeExecutor, template wfv1.Template) WorkflowExecutor {
return WorkflowExecutor{
PodName: podName,
ClientSet: clientset,
Namespace: namespace,
PodAnnotationsPath: podAnn... | [
"func",
"NewExecutor",
"(",
"clientset",
"kubernetes",
".",
"Interface",
",",
"podName",
",",
"namespace",
",",
"podAnnotationsPath",
"string",
",",
"cre",
"ContainerRuntimeExecutor",
",",
"template",
"wfv1",
".",
"Template",
")",
"WorkflowExecutor",
"{",
"return",
... | // NewExecutor instantiates a new workflow executor | [
"NewExecutor",
"instantiates",
"a",
"new",
"workflow",
"executor"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L97-L109 | train |
argoproj/argo | workflow/executor/executor.go | HandleError | func (we *WorkflowExecutor) HandleError() {
if r := recover(); r != nil {
_ = we.AddAnnotation(common.AnnotationKeyNodeMessage, fmt.Sprintf("%v", r))
log.Fatalf("executor panic: %+v\n%s", r, debug.Stack())
} else {
if len(we.errors) > 0 {
_ = we.AddAnnotation(common.AnnotationKeyNodeMessage, we.errors[0].Err... | go | func (we *WorkflowExecutor) HandleError() {
if r := recover(); r != nil {
_ = we.AddAnnotation(common.AnnotationKeyNodeMessage, fmt.Sprintf("%v", r))
log.Fatalf("executor panic: %+v\n%s", r, debug.Stack())
} else {
if len(we.errors) > 0 {
_ = we.AddAnnotation(common.AnnotationKeyNodeMessage, we.errors[0].Err... | [
"func",
"(",
"we",
"*",
"WorkflowExecutor",
")",
"HandleError",
"(",
")",
"{",
"if",
"r",
":=",
"recover",
"(",
")",
";",
"r",
"!=",
"nil",
"{",
"_",
"=",
"we",
".",
"AddAnnotation",
"(",
"common",
".",
"AnnotationKeyNodeMessage",
",",
"fmt",
".",
"S... | // HandleError is a helper to annotate the pod with the error message upon a unexpected executor panic or error | [
"HandleError",
"is",
"a",
"helper",
"to",
"annotate",
"the",
"pod",
"with",
"the",
"error",
"message",
"upon",
"a",
"unexpected",
"executor",
"panic",
"or",
"error"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L112-L121 | train |
argoproj/argo | workflow/executor/executor.go | LoadArtifacts | func (we *WorkflowExecutor) LoadArtifacts() error {
log.Infof("Start loading input artifacts...")
for _, art := range we.Template.Inputs.Artifacts {
log.Infof("Downloading artifact: %s", art.Name)
if !art.HasLocation() {
if art.Optional {
log.Warnf("Ignoring optional artifact '%s' which was not supplied... | go | func (we *WorkflowExecutor) LoadArtifacts() error {
log.Infof("Start loading input artifacts...")
for _, art := range we.Template.Inputs.Artifacts {
log.Infof("Downloading artifact: %s", art.Name)
if !art.HasLocation() {
if art.Optional {
log.Warnf("Ignoring optional artifact '%s' which was not supplied... | [
"func",
"(",
"we",
"*",
"WorkflowExecutor",
")",
"LoadArtifacts",
"(",
")",
"error",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n\n",
"for",
"_",
",",
"art",
":=",
"range",
"we",
".",
"Template",
".",
"Inputs",
".",
"Artifacts",
"{",
"log",
... | // LoadArtifacts loads artifacts from location to a container path | [
"LoadArtifacts",
"loads",
"artifacts",
"from",
"location",
"to",
"a",
"container",
"path"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L124-L188 | train |
argoproj/argo | workflow/executor/executor.go | SaveArtifacts | func (we *WorkflowExecutor) SaveArtifacts() error {
if len(we.Template.Outputs.Artifacts) == 0 {
log.Infof("No output artifacts")
return nil
}
log.Infof("Saving output artifacts")
mainCtrID, err := we.GetMainContainerID()
if err != nil {
return err
}
err = os.MkdirAll(tempOutArtDir, os.ModePerm)
if err !... | go | func (we *WorkflowExecutor) SaveArtifacts() error {
if len(we.Template.Outputs.Artifacts) == 0 {
log.Infof("No output artifacts")
return nil
}
log.Infof("Saving output artifacts")
mainCtrID, err := we.GetMainContainerID()
if err != nil {
return err
}
err = os.MkdirAll(tempOutArtDir, os.ModePerm)
if err !... | [
"func",
"(",
"we",
"*",
"WorkflowExecutor",
")",
"SaveArtifacts",
"(",
")",
"error",
"{",
"if",
"len",
"(",
"we",
".",
"Template",
".",
"Outputs",
".",
"Artifacts",
")",
"==",
"0",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n",
"return",
"ni... | // SaveArtifacts uploads artifacts to the archive location | [
"SaveArtifacts",
"uploads",
"artifacts",
"to",
"the",
"archive",
"location"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L214-L238 | train |
argoproj/argo | workflow/executor/executor.go | SaveParameters | func (we *WorkflowExecutor) SaveParameters() error {
if len(we.Template.Outputs.Parameters) == 0 {
log.Infof("No output parameters")
return nil
}
log.Infof("Saving output parameters")
mainCtrID, err := we.GetMainContainerID()
if err != nil {
return err
}
for i, param := range we.Template.Outputs.Parameter... | go | func (we *WorkflowExecutor) SaveParameters() error {
if len(we.Template.Outputs.Parameters) == 0 {
log.Infof("No output parameters")
return nil
}
log.Infof("Saving output parameters")
mainCtrID, err := we.GetMainContainerID()
if err != nil {
return err
}
for i, param := range we.Template.Outputs.Parameter... | [
"func",
"(",
"we",
"*",
"WorkflowExecutor",
")",
"SaveParameters",
"(",
")",
"error",
"{",
"if",
"len",
"(",
"we",
".",
"Template",
".",
"Outputs",
".",
"Parameters",
")",
"==",
"0",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n",
"return",
"... | // SaveParameters will save the content in the specified file path as output parameter value | [
"SaveParameters",
"will",
"save",
"the",
"content",
"in",
"the",
"specified",
"file",
"path",
"as",
"output",
"parameter",
"value"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L391-L435 | train |
argoproj/argo | workflow/executor/executor.go | SaveLogs | func (we *WorkflowExecutor) SaveLogs() (*wfv1.Artifact, error) {
if we.Template.ArchiveLocation == nil || we.Template.ArchiveLocation.ArchiveLogs == nil || !*we.Template.ArchiveLocation.ArchiveLogs {
return nil, nil
}
log.Infof("Saving logs")
mainCtrID, err := we.GetMainContainerID()
if err != nil {
return nil... | go | func (we *WorkflowExecutor) SaveLogs() (*wfv1.Artifact, error) {
if we.Template.ArchiveLocation == nil || we.Template.ArchiveLocation.ArchiveLogs == nil || !*we.Template.ArchiveLocation.ArchiveLogs {
return nil, nil
}
log.Infof("Saving logs")
mainCtrID, err := we.GetMainContainerID()
if err != nil {
return nil... | [
"func",
"(",
"we",
"*",
"WorkflowExecutor",
")",
"SaveLogs",
"(",
")",
"(",
"*",
"wfv1",
".",
"Artifact",
",",
"error",
")",
"{",
"if",
"we",
".",
"Template",
".",
"ArchiveLocation",
"==",
"nil",
"||",
"we",
".",
"Template",
".",
"ArchiveLocation",
"."... | // SaveLogs saves logs | [
"SaveLogs",
"saves",
"logs"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L438-L492 | train |
argoproj/argo | workflow/executor/executor.go | GetSecretFromVolMount | func (we *WorkflowExecutor) GetSecretFromVolMount(accessKeyName string, accessKey string) ([]byte, error) {
return ioutil.ReadFile(filepath.Join(common.SecretVolMountPath, accessKeyName, accessKey))
} | go | func (we *WorkflowExecutor) GetSecretFromVolMount(accessKeyName string, accessKey string) ([]byte, error) {
return ioutil.ReadFile(filepath.Join(common.SecretVolMountPath, accessKeyName, accessKey))
} | [
"func",
"(",
"we",
"*",
"WorkflowExecutor",
")",
"GetSecretFromVolMount",
"(",
"accessKeyName",
"string",
",",
"accessKey",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"ioutil",
".",
"ReadFile",
"(",
"filepath",
".",
"Join",
"("... | // GetSecretFromVolMount will retrive the Secrets from VolumeMount | [
"GetSecretFromVolMount",
"will",
"retrive",
"the",
"Secrets",
"from",
"VolumeMount"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L495-L497 | train |
argoproj/argo | workflow/executor/executor.go | saveLogToFile | func (we *WorkflowExecutor) saveLogToFile(mainCtrID, path string) error {
outFile, err := os.Create(path)
if err != nil {
return errors.InternalWrapError(err)
}
defer func() { _ = outFile.Close() }()
reader, err := we.RuntimeExecutor.GetOutputStream(mainCtrID, true)
if err != nil {
return err
}
defer func()... | go | func (we *WorkflowExecutor) saveLogToFile(mainCtrID, path string) error {
outFile, err := os.Create(path)
if err != nil {
return errors.InternalWrapError(err)
}
defer func() { _ = outFile.Close() }()
reader, err := we.RuntimeExecutor.GetOutputStream(mainCtrID, true)
if err != nil {
return err
}
defer func()... | [
"func",
"(",
"we",
"*",
"WorkflowExecutor",
")",
"saveLogToFile",
"(",
"mainCtrID",
",",
"path",
"string",
")",
"error",
"{",
"outFile",
",",
"err",
":=",
"os",
".",
"Create",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
... | // saveLogToFile saves the entire log output of a container to a local file | [
"saveLogToFile",
"saves",
"the",
"entire",
"log",
"output",
"of",
"a",
"container",
"to",
"a",
"local",
"file"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L500-L516 | train |
argoproj/argo | workflow/executor/executor.go | getPod | func (we *WorkflowExecutor) getPod() (*apiv1.Pod, error) {
podsIf := we.ClientSet.CoreV1().Pods(we.Namespace)
var pod *apiv1.Pod
var err error
_ = wait.ExponentialBackoff(retry.DefaultRetry, func() (bool, error) {
pod, err = podsIf.Get(we.PodName, metav1.GetOptions{})
if err != nil {
log.Warnf("Failed to get... | go | func (we *WorkflowExecutor) getPod() (*apiv1.Pod, error) {
podsIf := we.ClientSet.CoreV1().Pods(we.Namespace)
var pod *apiv1.Pod
var err error
_ = wait.ExponentialBackoff(retry.DefaultRetry, func() (bool, error) {
pod, err = podsIf.Get(we.PodName, metav1.GetOptions{})
if err != nil {
log.Warnf("Failed to get... | [
"func",
"(",
"we",
"*",
"WorkflowExecutor",
")",
"getPod",
"(",
")",
"(",
"*",
"apiv1",
".",
"Pod",
",",
"error",
")",
"{",
"podsIf",
":=",
"we",
".",
"ClientSet",
".",
"CoreV1",
"(",
")",
".",
"Pods",
"(",
"we",
".",
"Namespace",
")",
"\n",
"var... | // getPod is a wrapper around the pod interface to get the current pod from kube API server | [
"getPod",
"is",
"a",
"wrapper",
"around",
"the",
"pod",
"interface",
"to",
"get",
"the",
"current",
"pod",
"from",
"kube",
"API",
"server"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L604-L623 | train |
argoproj/argo | workflow/executor/executor.go | GetConfigMapKey | func (we *WorkflowExecutor) GetConfigMapKey(namespace, name, key string) (string, error) {
cachedKey := fmt.Sprintf("%s/%s/%s", namespace, name, key)
if val, ok := we.memoizedConfigMaps[cachedKey]; ok {
return val, nil
}
configmapsIf := we.ClientSet.CoreV1().ConfigMaps(namespace)
var configmap *apiv1.ConfigMap
... | go | func (we *WorkflowExecutor) GetConfigMapKey(namespace, name, key string) (string, error) {
cachedKey := fmt.Sprintf("%s/%s/%s", namespace, name, key)
if val, ok := we.memoizedConfigMaps[cachedKey]; ok {
return val, nil
}
configmapsIf := we.ClientSet.CoreV1().ConfigMaps(namespace)
var configmap *apiv1.ConfigMap
... | [
"func",
"(",
"we",
"*",
"WorkflowExecutor",
")",
"GetConfigMapKey",
"(",
"namespace",
",",
"name",
",",
"key",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"cachedKey",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"namespace",
",",
"name... | // GetConfigMapKey retrieves a configmap value and memoizes the result | [
"GetConfigMapKey",
"retrieves",
"a",
"configmap",
"value",
"and",
"memoizes",
"the",
"result"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L631-L663 | train |
argoproj/argo | workflow/executor/executor.go | GetSecrets | func (we *WorkflowExecutor) GetSecrets(namespace, name, key string) ([]byte, error) {
cachedKey := fmt.Sprintf("%s/%s/%s", namespace, name, key)
if val, ok := we.memoizedSecrets[cachedKey]; ok {
return val, nil
}
secretsIf := we.ClientSet.CoreV1().Secrets(namespace)
var secret *apiv1.Secret
var err error
_ = w... | go | func (we *WorkflowExecutor) GetSecrets(namespace, name, key string) ([]byte, error) {
cachedKey := fmt.Sprintf("%s/%s/%s", namespace, name, key)
if val, ok := we.memoizedSecrets[cachedKey]; ok {
return val, nil
}
secretsIf := we.ClientSet.CoreV1().Secrets(namespace)
var secret *apiv1.Secret
var err error
_ = w... | [
"func",
"(",
"we",
"*",
"WorkflowExecutor",
")",
"GetSecrets",
"(",
"namespace",
",",
"name",
",",
"key",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"cachedKey",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"namespace",
",",
... | // GetSecrets retrieves a secret value and memoizes the result | [
"GetSecrets",
"retrieves",
"a",
"secret",
"value",
"and",
"memoizes",
"the",
"result"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L666-L698 | train |
argoproj/argo | workflow/executor/executor.go | GetMainContainerStatus | func (we *WorkflowExecutor) GetMainContainerStatus() (*apiv1.ContainerStatus, error) {
pod, err := we.getPod()
if err != nil {
return nil, err
}
for _, ctrStatus := range pod.Status.ContainerStatuses {
if ctrStatus.Name == common.MainContainerName {
return &ctrStatus, nil
}
}
return nil, nil
} | go | func (we *WorkflowExecutor) GetMainContainerStatus() (*apiv1.ContainerStatus, error) {
pod, err := we.getPod()
if err != nil {
return nil, err
}
for _, ctrStatus := range pod.Status.ContainerStatuses {
if ctrStatus.Name == common.MainContainerName {
return &ctrStatus, nil
}
}
return nil, nil
} | [
"func",
"(",
"we",
"*",
"WorkflowExecutor",
")",
"GetMainContainerStatus",
"(",
")",
"(",
"*",
"apiv1",
".",
"ContainerStatus",
",",
"error",
")",
"{",
"pod",
",",
"err",
":=",
"we",
".",
"getPod",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"retu... | // GetMainContainerStatus returns the container status of the main container, nil if the main container does not exist | [
"GetMainContainerStatus",
"returns",
"the",
"container",
"status",
"of",
"the",
"main",
"container",
"nil",
"if",
"the",
"main",
"container",
"does",
"not",
"exist"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L701-L712 | train |
argoproj/argo | workflow/executor/executor.go | GetMainContainerID | func (we *WorkflowExecutor) GetMainContainerID() (string, error) {
if we.mainContainerID != "" {
return we.mainContainerID, nil
}
ctrStatus, err := we.GetMainContainerStatus()
if err != nil {
return "", err
}
if ctrStatus == nil {
return "", nil
}
we.mainContainerID = containerID(ctrStatus.ContainerID)
r... | go | func (we *WorkflowExecutor) GetMainContainerID() (string, error) {
if we.mainContainerID != "" {
return we.mainContainerID, nil
}
ctrStatus, err := we.GetMainContainerStatus()
if err != nil {
return "", err
}
if ctrStatus == nil {
return "", nil
}
we.mainContainerID = containerID(ctrStatus.ContainerID)
r... | [
"func",
"(",
"we",
"*",
"WorkflowExecutor",
")",
"GetMainContainerID",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"we",
".",
"mainContainerID",
"!=",
"\"",
"\"",
"{",
"return",
"we",
".",
"mainContainerID",
",",
"nil",
"\n",
"}",
"\n",
"ctr... | // GetMainContainerID returns the container id of the main container | [
"GetMainContainerID",
"returns",
"the",
"container",
"id",
"of",
"the",
"main",
"container"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L715-L728 | train |
argoproj/argo | workflow/executor/executor.go | CaptureScriptResult | func (we *WorkflowExecutor) CaptureScriptResult() error {
if we.Template.Script == nil {
return nil
}
log.Infof("Capturing script output")
mainContainerID, err := we.GetMainContainerID()
if err != nil {
return err
}
reader, err := we.RuntimeExecutor.GetOutputStream(mainContainerID, false)
if err != nil {
... | go | func (we *WorkflowExecutor) CaptureScriptResult() error {
if we.Template.Script == nil {
return nil
}
log.Infof("Capturing script output")
mainContainerID, err := we.GetMainContainerID()
if err != nil {
return err
}
reader, err := we.RuntimeExecutor.GetOutputStream(mainContainerID, false)
if err != nil {
... | [
"func",
"(",
"we",
"*",
"WorkflowExecutor",
")",
"CaptureScriptResult",
"(",
")",
"error",
"{",
"if",
"we",
".",
"Template",
".",
"Script",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"log",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n",
"mainCont... | // CaptureScriptResult will add the stdout of a script template as output result | [
"CaptureScriptResult",
"will",
"add",
"the",
"stdout",
"of",
"a",
"script",
"template",
"as",
"output",
"result"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L731-L757 | train |
argoproj/argo | workflow/executor/executor.go | AnnotateOutputs | func (we *WorkflowExecutor) AnnotateOutputs(logArt *wfv1.Artifact) error {
outputs := we.Template.Outputs.DeepCopy()
if logArt != nil {
outputs.Artifacts = append(outputs.Artifacts, *logArt)
}
if !outputs.HasOutputs() {
return nil
}
log.Infof("Annotating pod with output")
outputBytes, err := json.Marshal(ou... | go | func (we *WorkflowExecutor) AnnotateOutputs(logArt *wfv1.Artifact) error {
outputs := we.Template.Outputs.DeepCopy()
if logArt != nil {
outputs.Artifacts = append(outputs.Artifacts, *logArt)
}
if !outputs.HasOutputs() {
return nil
}
log.Infof("Annotating pod with output")
outputBytes, err := json.Marshal(ou... | [
"func",
"(",
"we",
"*",
"WorkflowExecutor",
")",
"AnnotateOutputs",
"(",
"logArt",
"*",
"wfv1",
".",
"Artifact",
")",
"error",
"{",
"outputs",
":=",
"we",
".",
"Template",
".",
"Outputs",
".",
"DeepCopy",
"(",
")",
"\n",
"if",
"logArt",
"!=",
"nil",
"{... | // AnnotateOutputs annotation to the pod indicating all the outputs. | [
"AnnotateOutputs",
"annotation",
"to",
"the",
"pod",
"indicating",
"all",
"the",
"outputs",
"."
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L760-L775 | train |
argoproj/argo | workflow/executor/executor.go | AddError | func (we *WorkflowExecutor) AddError(err error) {
log.Errorf("executor error: %+v", err)
we.errors = append(we.errors, err)
} | go | func (we *WorkflowExecutor) AddError(err error) {
log.Errorf("executor error: %+v", err)
we.errors = append(we.errors, err)
} | [
"func",
"(",
"we",
"*",
"WorkflowExecutor",
")",
"AddError",
"(",
"err",
"error",
")",
"{",
"log",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"we",
".",
"errors",
"=",
"append",
"(",
"we",
".",
"errors",
",",
"err",
")",
"\n",
"}"
] | // AddError adds an error to the list of encountered errors durign execution | [
"AddError",
"adds",
"an",
"error",
"to",
"the",
"list",
"of",
"encountered",
"errors",
"durign",
"execution"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L778-L781 | train |
argoproj/argo | workflow/executor/executor.go | AddAnnotation | func (we *WorkflowExecutor) AddAnnotation(key, value string) error {
return common.AddPodAnnotation(we.ClientSet, we.PodName, we.Namespace, key, value)
} | go | func (we *WorkflowExecutor) AddAnnotation(key, value string) error {
return common.AddPodAnnotation(we.ClientSet, we.PodName, we.Namespace, key, value)
} | [
"func",
"(",
"we",
"*",
"WorkflowExecutor",
")",
"AddAnnotation",
"(",
"key",
",",
"value",
"string",
")",
"error",
"{",
"return",
"common",
".",
"AddPodAnnotation",
"(",
"we",
".",
"ClientSet",
",",
"we",
".",
"PodName",
",",
"we",
".",
"Namespace",
","... | // AddAnnotation adds an annotation to the workflow pod | [
"AddAnnotation",
"adds",
"an",
"annotation",
"to",
"the",
"workflow",
"pod"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L784-L786 | train |
argoproj/argo | workflow/executor/executor.go | isTarball | func isTarball(filePath string) bool {
cmd := exec.Command("tar", "-tf", filePath)
log.Info(cmd.Args)
err := cmd.Run()
return err == nil
} | go | func isTarball(filePath string) bool {
cmd := exec.Command("tar", "-tf", filePath)
log.Info(cmd.Args)
err := cmd.Run()
return err == nil
} | [
"func",
"isTarball",
"(",
"filePath",
"string",
")",
"bool",
"{",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"filePath",
")",
"\n",
"log",
".",
"Info",
"(",
"cmd",
".",
"Args",
")",
"\n",
"err",
":=",
"cmd",
".",
... | // isTarball returns whether or not the file is a tarball | [
"isTarball",
"returns",
"whether",
"or",
"not",
"the",
"file",
"is",
"a",
"tarball"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L789-L794 | train |
argoproj/argo | workflow/executor/executor.go | untar | func untar(tarPath string, destPath string) error {
// first extract the tar into a temporary dir
tmpDir := destPath + ".tmpdir"
err := os.MkdirAll(tmpDir, os.ModePerm)
if err != nil {
return errors.InternalWrapError(err)
}
err = common.RunCommand("tar", "-xf", tarPath, "-C", tmpDir)
if err != nil {
return e... | go | func untar(tarPath string, destPath string) error {
// first extract the tar into a temporary dir
tmpDir := destPath + ".tmpdir"
err := os.MkdirAll(tmpDir, os.ModePerm)
if err != nil {
return errors.InternalWrapError(err)
}
err = common.RunCommand("tar", "-xf", tarPath, "-C", tmpDir)
if err != nil {
return e... | [
"func",
"untar",
"(",
"tarPath",
"string",
",",
"destPath",
"string",
")",
"error",
"{",
"// first extract the tar into a temporary dir",
"tmpDir",
":=",
"destPath",
"+",
"\"",
"\"",
"\n",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"tmpDir",
",",
"os",
".",
"M... | // untar extracts a tarball to a temporary directory,
// renaming it to the desired location | [
"untar",
"extracts",
"a",
"tarball",
"to",
"a",
"temporary",
"directory",
"renaming",
"it",
"to",
"the",
"desired",
"location"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L798-L836 | train |
argoproj/argo | workflow/executor/executor.go | waitMainContainerStart | func (we *WorkflowExecutor) waitMainContainerStart() (string, error) {
for {
podsIf := we.ClientSet.CoreV1().Pods(we.Namespace)
fieldSelector := fields.ParseSelectorOrDie(fmt.Sprintf("metadata.name=%s", we.PodName))
opts := metav1.ListOptions{
FieldSelector: fieldSelector.String(),
}
watchIf, err := podsI... | go | func (we *WorkflowExecutor) waitMainContainerStart() (string, error) {
for {
podsIf := we.ClientSet.CoreV1().Pods(we.Namespace)
fieldSelector := fields.ParseSelectorOrDie(fmt.Sprintf("metadata.name=%s", we.PodName))
opts := metav1.ListOptions{
FieldSelector: fieldSelector.String(),
}
watchIf, err := podsI... | [
"func",
"(",
"we",
"*",
"WorkflowExecutor",
")",
"waitMainContainerStart",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"for",
"{",
"podsIf",
":=",
"we",
".",
"ClientSet",
".",
"CoreV1",
"(",
")",
".",
"Pods",
"(",
"we",
".",
"Namespace",
")",
"\... | // waitMainContainerStart waits for the main container to start and returns its container ID. | [
"waitMainContainerStart",
"waits",
"for",
"the",
"main",
"container",
"to",
"start",
"and",
"returns",
"its",
"container",
"ID",
"."
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L876-L915 | train |
argoproj/argo | workflow/executor/executor.go | monitorAnnotations | func (we *WorkflowExecutor) monitorAnnotations(ctx context.Context) <-chan struct{} {
log.Infof("Starting annotations monitor")
// Create a channel to listen for a SIGUSR2. Upon receiving of the signal, we force reload our annotations
// directly from kubernetes API. The controller uses this to fast-track notificat... | go | func (we *WorkflowExecutor) monitorAnnotations(ctx context.Context) <-chan struct{} {
log.Infof("Starting annotations monitor")
// Create a channel to listen for a SIGUSR2. Upon receiving of the signal, we force reload our annotations
// directly from kubernetes API. The controller uses this to fast-track notificat... | [
"func",
"(",
"we",
"*",
"WorkflowExecutor",
")",
"monitorAnnotations",
"(",
"ctx",
"context",
".",
"Context",
")",
"<-",
"chan",
"struct",
"{",
"}",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n\n",
"// Create a channel to listen for a SIGUSR2. Upon receiv... | // monitorAnnotations starts a goroutine which monitors for any changes to the pod annotations.
// Emits an event on the returned channel upon any updates | [
"monitorAnnotations",
"starts",
"a",
"goroutine",
"which",
"monitors",
"for",
"any",
"changes",
"to",
"the",
"pod",
"annotations",
".",
"Emits",
"an",
"event",
"on",
"the",
"returned",
"channel",
"upon",
"any",
"updates"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L947-L990 | train |
argoproj/argo | workflow/executor/executor.go | setExecutionControl | func (we *WorkflowExecutor) setExecutionControl() {
pod, err := we.getPod()
if err != nil {
log.Warnf("Failed to set execution control from API server: %v", err)
return
}
execCtlString, ok := pod.ObjectMeta.Annotations[common.AnnotationKeyExecutionControl]
if !ok {
we.ExecutionControl = nil
} else {
var e... | go | func (we *WorkflowExecutor) setExecutionControl() {
pod, err := we.getPod()
if err != nil {
log.Warnf("Failed to set execution control from API server: %v", err)
return
}
execCtlString, ok := pod.ObjectMeta.Annotations[common.AnnotationKeyExecutionControl]
if !ok {
we.ExecutionControl = nil
} else {
var e... | [
"func",
"(",
"we",
"*",
"WorkflowExecutor",
")",
"setExecutionControl",
"(",
")",
"{",
"pod",
",",
"err",
":=",
"we",
".",
"getPod",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Warnf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"retu... | // setExecutionControl sets the execution control information from the pod annotation | [
"setExecutionControl",
"sets",
"the",
"execution",
"control",
"information",
"from",
"the",
"pod",
"annotation"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L993-L1012 | train |
argoproj/argo | workflow/executor/executor.go | monitorDeadline | func (we *WorkflowExecutor) monitorDeadline(ctx context.Context, annotationsUpdate <-chan struct{}) {
log.Infof("Starting deadline monitor")
for {
select {
case <-ctx.Done():
log.Info("Deadline monitor stopped")
return
case <-annotationsUpdate:
default:
// TODO(jessesuen): we do not effectively use t... | go | func (we *WorkflowExecutor) monitorDeadline(ctx context.Context, annotationsUpdate <-chan struct{}) {
log.Infof("Starting deadline monitor")
for {
select {
case <-ctx.Done():
log.Info("Deadline monitor stopped")
return
case <-annotationsUpdate:
default:
// TODO(jessesuen): we do not effectively use t... | [
"func",
"(",
"we",
"*",
"WorkflowExecutor",
")",
"monitorDeadline",
"(",
"ctx",
"context",
".",
"Context",
",",
"annotationsUpdate",
"<-",
"chan",
"struct",
"{",
"}",
")",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n",
"for",
"{",
"select",
"{",... | // monitorDeadline checks to see if we exceeded the deadline for the step and
// terminates the main container if we did | [
"monitorDeadline",
"checks",
"to",
"see",
"if",
"we",
"exceeded",
"the",
"deadline",
"for",
"the",
"step",
"and",
"terminates",
"the",
"main",
"container",
"if",
"we",
"did"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L1016-L1052 | train |
argoproj/argo | workflow/executor/executor.go | KillSidecars | func (we *WorkflowExecutor) KillSidecars() error {
if len(we.Template.Sidecars) == 0 {
log.Infof("No sidecars")
return nil
}
log.Infof("Killing sidecars")
pod, err := we.getPod()
if err != nil {
return err
}
sidecarIDs := make([]string, 0)
for _, ctrStatus := range pod.Status.ContainerStatuses {
if ctrS... | go | func (we *WorkflowExecutor) KillSidecars() error {
if len(we.Template.Sidecars) == 0 {
log.Infof("No sidecars")
return nil
}
log.Infof("Killing sidecars")
pod, err := we.getPod()
if err != nil {
return err
}
sidecarIDs := make([]string, 0)
for _, ctrStatus := range pod.Status.ContainerStatuses {
if ctrS... | [
"func",
"(",
"we",
"*",
"WorkflowExecutor",
")",
"KillSidecars",
"(",
")",
"error",
"{",
"if",
"len",
"(",
"we",
".",
"Template",
".",
"Sidecars",
")",
"==",
"0",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}",
"... | // KillSidecars kills any sidecars to the main container | [
"KillSidecars",
"kills",
"any",
"sidecars",
"to",
"the",
"main",
"container"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L1055-L1081 | train |
argoproj/argo | workflow/executor/executor.go | LoadExecutionControl | func (we *WorkflowExecutor) LoadExecutionControl() error {
err := unmarshalAnnotationField(we.PodAnnotationsPath, common.AnnotationKeyExecutionControl, &we.ExecutionControl)
if err != nil {
if errors.IsCode(errors.CodeNotFound, err) {
return nil
}
return err
}
return nil
} | go | func (we *WorkflowExecutor) LoadExecutionControl() error {
err := unmarshalAnnotationField(we.PodAnnotationsPath, common.AnnotationKeyExecutionControl, &we.ExecutionControl)
if err != nil {
if errors.IsCode(errors.CodeNotFound, err) {
return nil
}
return err
}
return nil
} | [
"func",
"(",
"we",
"*",
"WorkflowExecutor",
")",
"LoadExecutionControl",
"(",
")",
"error",
"{",
"err",
":=",
"unmarshalAnnotationField",
"(",
"we",
".",
"PodAnnotationsPath",
",",
"common",
".",
"AnnotationKeyExecutionControl",
",",
"&",
"we",
".",
"ExecutionCont... | // LoadExecutionControl reads the execution control definition from the the Kubernetes downward api annotations volume file | [
"LoadExecutionControl",
"reads",
"the",
"execution",
"control",
"definition",
"from",
"the",
"the",
"Kubernetes",
"downward",
"api",
"annotations",
"volume",
"file"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L1084-L1093 | train |
argoproj/argo | workflow/executor/executor.go | LoadTemplate | func LoadTemplate(path string) (*wfv1.Template, error) {
var tmpl wfv1.Template
err := unmarshalAnnotationField(path, common.AnnotationKeyTemplate, &tmpl)
if err != nil {
return nil, err
}
return &tmpl, nil
} | go | func LoadTemplate(path string) (*wfv1.Template, error) {
var tmpl wfv1.Template
err := unmarshalAnnotationField(path, common.AnnotationKeyTemplate, &tmpl)
if err != nil {
return nil, err
}
return &tmpl, nil
} | [
"func",
"LoadTemplate",
"(",
"path",
"string",
")",
"(",
"*",
"wfv1",
".",
"Template",
",",
"error",
")",
"{",
"var",
"tmpl",
"wfv1",
".",
"Template",
"\n",
"err",
":=",
"unmarshalAnnotationField",
"(",
"path",
",",
"common",
".",
"AnnotationKeyTemplate",
... | // LoadTemplate reads the template definition from the the Kubernetes downward api annotations volume file | [
"LoadTemplate",
"reads",
"the",
"template",
"definition",
"from",
"the",
"the",
"Kubernetes",
"downward",
"api",
"annotations",
"volume",
"file"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L1096-L1103 | train |
argoproj/argo | workflow/executor/executor.go | unmarshalAnnotationField | func unmarshalAnnotationField(filePath string, key string, into interface{}) error {
// Read the annotation file
file, err := os.Open(filePath)
if err != nil {
log.Errorf("ERROR opening annotation file from %s", filePath)
return errors.InternalWrapError(err)
}
defer func() {
_ = file.Close()
}()
reader :=... | go | func unmarshalAnnotationField(filePath string, key string, into interface{}) error {
// Read the annotation file
file, err := os.Open(filePath)
if err != nil {
log.Errorf("ERROR opening annotation file from %s", filePath)
return errors.InternalWrapError(err)
}
defer func() {
_ = file.Close()
}()
reader :=... | [
"func",
"unmarshalAnnotationField",
"(",
"filePath",
"string",
",",
"key",
"string",
",",
"into",
"interface",
"{",
"}",
")",
"error",
"{",
"// Read the annotation file",
"file",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"filePath",
")",
"\n",
"if",
"err",
... | // unmarshalAnnotationField unmarshals the value of an annotation key into the supplied interface
// from the downward api annotation volume file | [
"unmarshalAnnotationField",
"unmarshals",
"the",
"value",
"of",
"an",
"annotation",
"key",
"into",
"the",
"supplied",
"interface",
"from",
"the",
"downward",
"api",
"annotation",
"volume",
"file"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/executor/executor.go#L1107-L1182 | train |
argoproj/argo | cmd/argo/commands/get.go | attachToParent | func attachToParent(wf *wfv1.Workflow, n renderNode,
nonBoundaryParentChildrenMap map[string]*nonBoundaryParentNode, boundaryID string,
boundaryNodeMap map[string]*boundaryNode, parentBoundaryMap map[string][]renderNode) bool {
// Check first if I am a child of a nonBoundaryParent
// that implies I attach to that ... | go | func attachToParent(wf *wfv1.Workflow, n renderNode,
nonBoundaryParentChildrenMap map[string]*nonBoundaryParentNode, boundaryID string,
boundaryNodeMap map[string]*boundaryNode, parentBoundaryMap map[string][]renderNode) bool {
// Check first if I am a child of a nonBoundaryParent
// that implies I attach to that ... | [
"func",
"attachToParent",
"(",
"wf",
"*",
"wfv1",
".",
"Workflow",
",",
"n",
"renderNode",
",",
"nonBoundaryParentChildrenMap",
"map",
"[",
"string",
"]",
"*",
"nonBoundaryParentNode",
",",
"boundaryID",
"string",
",",
"boundaryNodeMap",
"map",
"[",
"string",
"]... | // Attach render node n to its parent based on what has been parsed previously
// In some cases add it to list of things that still needs to be attached to parent
// Return if I am a possible root | [
"Attach",
"render",
"node",
"n",
"to",
"its",
"parent",
"based",
"on",
"what",
"has",
"been",
"parsed",
"previously",
"In",
"some",
"cases",
"add",
"it",
"to",
"list",
"of",
"things",
"that",
"still",
"needs",
"to",
"be",
"attached",
"to",
"parent",
"Ret... | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/cmd/argo/commands/get.go#L238-L265 | train |
argoproj/argo | cmd/argo/commands/get.go | convertToRenderTrees | func convertToRenderTrees(wf *wfv1.Workflow) map[string]renderNode {
renderTreeRoots := make(map[string]renderNode)
// Used to store all boundary nodes so future render children can attach
// Maps node Name -> *boundaryNode
boundaryNodeMap := make(map[string]*boundaryNode)
// Used to store children of a boundary... | go | func convertToRenderTrees(wf *wfv1.Workflow) map[string]renderNode {
renderTreeRoots := make(map[string]renderNode)
// Used to store all boundary nodes so future render children can attach
// Maps node Name -> *boundaryNode
boundaryNodeMap := make(map[string]*boundaryNode)
// Used to store children of a boundary... | [
"func",
"convertToRenderTrees",
"(",
"wf",
"*",
"wfv1",
".",
"Workflow",
")",
"map",
"[",
"string",
"]",
"renderNode",
"{",
"renderTreeRoots",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"renderNode",
")",
"\n\n",
"// Used to store all boundary nodes so future r... | // This takes the map of NodeStatus and converts them into a forrest
// of trees of renderNodes and returns the set of roots for each tree | [
"This",
"takes",
"the",
"map",
"of",
"NodeStatus",
"and",
"converts",
"them",
"into",
"a",
"forrest",
"of",
"trees",
"of",
"renderNodes",
"and",
"returns",
"the",
"set",
"of",
"roots",
"for",
"each",
"tree"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/cmd/argo/commands/get.go#L269-L348 | train |
argoproj/argo | cmd/argo/commands/get.go | printNode | func printNode(w *tabwriter.Writer, wf *wfv1.Workflow, node wfv1.NodeStatus, depth int, nodePrefix string, childPrefix string, outFmt string) {
nodeName := fmt.Sprintf("%s %s", jobStatusIconMap[node.Phase], node.DisplayName)
var args []interface{}
duration := humanize.RelativeDurationShort(node.StartedAt.Time, node.... | go | func printNode(w *tabwriter.Writer, wf *wfv1.Workflow, node wfv1.NodeStatus, depth int, nodePrefix string, childPrefix string, outFmt string) {
nodeName := fmt.Sprintf("%s %s", jobStatusIconMap[node.Phase], node.DisplayName)
var args []interface{}
duration := humanize.RelativeDurationShort(node.StartedAt.Time, node.... | [
"func",
"printNode",
"(",
"w",
"*",
"tabwriter",
".",
"Writer",
",",
"wf",
"*",
"wfv1",
".",
"Workflow",
",",
"node",
"wfv1",
".",
"NodeStatus",
",",
"depth",
"int",
",",
"nodePrefix",
"string",
",",
"childPrefix",
"string",
",",
"outFmt",
"string",
")",... | // Main method to print information of node in get | [
"Main",
"method",
"to",
"print",
"information",
"of",
"node",
"in",
"get"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/cmd/argo/commands/get.go#L409-L426 | train |
argoproj/argo | workflow/controller/scope.go | replaceMap | func (s *wfScope) replaceMap() map[string]string {
replaceMap := make(map[string]string)
for key, val := range s.scope {
valStr, ok := val.(string)
if ok {
replaceMap[key] = valStr
}
}
return replaceMap
} | go | func (s *wfScope) replaceMap() map[string]string {
replaceMap := make(map[string]string)
for key, val := range s.scope {
valStr, ok := val.(string)
if ok {
replaceMap[key] = valStr
}
}
return replaceMap
} | [
"func",
"(",
"s",
"*",
"wfScope",
")",
"replaceMap",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"replaceMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"for",
"key",
",",
"val",
":=",
"range",
"s",
".",
"scope",
... | // replaceMap returns a replacement map of strings intended to be used simple string substitution | [
"replaceMap",
"returns",
"a",
"replacement",
"map",
"of",
"strings",
"intended",
"to",
"be",
"used",
"simple",
"string",
"substitution"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/controller/scope.go#L17-L26 | train |
argoproj/argo | workflow/controller/scope.go | resolveVar | func (s *wfScope) resolveVar(v string) (interface{}, error) {
v = strings.TrimPrefix(v, "{{")
v = strings.TrimSuffix(v, "}}")
parts := strings.Split(v, ".")
prefix := parts[0]
switch prefix {
case "steps", "tasks", "workflow":
val, ok := s.scope[v]
if ok {
return val, nil
}
case "inputs":
art := s.tmp... | go | func (s *wfScope) resolveVar(v string) (interface{}, error) {
v = strings.TrimPrefix(v, "{{")
v = strings.TrimSuffix(v, "}}")
parts := strings.Split(v, ".")
prefix := parts[0]
switch prefix {
case "steps", "tasks", "workflow":
val, ok := s.scope[v]
if ok {
return val, nil
}
case "inputs":
art := s.tmp... | [
"func",
"(",
"s",
"*",
"wfScope",
")",
"resolveVar",
"(",
"v",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"v",
"=",
"strings",
".",
"TrimPrefix",
"(",
"v",
",",
"\"",
"\"",
")",
"\n",
"v",
"=",
"strings",
".",
"TrimSuffix"... | // resolveVar resolves a parameter or artifact | [
"resolveVar",
"resolves",
"a",
"parameter",
"or",
"artifact"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/controller/scope.go#L37-L55 | train |
argoproj/argo | workflow/artifacts/hdfs/hdfs.go | ValidateArtifact | func ValidateArtifact(errPrefix string, art *wfv1.HDFSArtifact) error {
if len(art.Addresses) == 0 {
return errors.Errorf(errors.CodeBadRequest, "%s.addresses is required", errPrefix)
}
if art.Path == "" {
return errors.Errorf(errors.CodeBadRequest, "%s.path is required", errPrefix)
}
if !filepath.IsAbs(art.Pa... | go | func ValidateArtifact(errPrefix string, art *wfv1.HDFSArtifact) error {
if len(art.Addresses) == 0 {
return errors.Errorf(errors.CodeBadRequest, "%s.addresses is required", errPrefix)
}
if art.Path == "" {
return errors.Errorf(errors.CodeBadRequest, "%s.path is required", errPrefix)
}
if !filepath.IsAbs(art.Pa... | [
"func",
"ValidateArtifact",
"(",
"errPrefix",
"string",
",",
"art",
"*",
"wfv1",
".",
"HDFSArtifact",
")",
"error",
"{",
"if",
"len",
"(",
"art",
".",
"Addresses",
")",
"==",
"0",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"errors",
".",
"CodeBadReques... | // ValidateArtifact validates HDFS artifact | [
"ValidateArtifact",
"validates",
"HDFS",
"artifact"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/artifacts/hdfs/hdfs.go#L48-L72 | train |
argoproj/argo | workflow/artifacts/hdfs/hdfs.go | CreateDriver | func CreateDriver(ci common.ResourceInterface, art *wfv1.HDFSArtifact) (*ArtifactDriver, error) {
var krbConfig string
var krbOptions *KrbOptions
var err error
namespace := ci.GetNamespace()
if art.KrbConfigConfigMap != nil && art.KrbConfigConfigMap.Name != "" {
krbConfig, err = ci.GetConfigMapKey(namespace, a... | go | func CreateDriver(ci common.ResourceInterface, art *wfv1.HDFSArtifact) (*ArtifactDriver, error) {
var krbConfig string
var krbOptions *KrbOptions
var err error
namespace := ci.GetNamespace()
if art.KrbConfigConfigMap != nil && art.KrbConfigConfigMap.Name != "" {
krbConfig, err = ci.GetConfigMapKey(namespace, a... | [
"func",
"CreateDriver",
"(",
"ci",
"common",
".",
"ResourceInterface",
",",
"art",
"*",
"wfv1",
".",
"HDFSArtifact",
")",
"(",
"*",
"ArtifactDriver",
",",
"error",
")",
"{",
"var",
"krbConfig",
"string",
"\n",
"var",
"krbOptions",
"*",
"KrbOptions",
"\n",
... | // CreateDriver constructs ArtifactDriver | [
"CreateDriver",
"constructs",
"ArtifactDriver"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/artifacts/hdfs/hdfs.go#L75-L133 | train |
argoproj/argo | workflow/artifacts/hdfs/hdfs.go | Load | func (driver *ArtifactDriver) Load(inputArtifact *wfv1.Artifact, path string) error {
hdfscli, err := createHDFSClient(driver.Addresses, driver.HDFSUser, driver.KrbOptions)
if err != nil {
return err
}
defer util.Close(hdfscli)
srcStat, err := hdfscli.Stat(driver.Path)
if err != nil {
return err
}
if srcSt... | go | func (driver *ArtifactDriver) Load(inputArtifact *wfv1.Artifact, path string) error {
hdfscli, err := createHDFSClient(driver.Addresses, driver.HDFSUser, driver.KrbOptions)
if err != nil {
return err
}
defer util.Close(hdfscli)
srcStat, err := hdfscli.Stat(driver.Path)
if err != nil {
return err
}
if srcSt... | [
"func",
"(",
"driver",
"*",
"ArtifactDriver",
")",
"Load",
"(",
"inputArtifact",
"*",
"wfv1",
".",
"Artifact",
",",
"path",
"string",
")",
"error",
"{",
"hdfscli",
",",
"err",
":=",
"createHDFSClient",
"(",
"driver",
".",
"Addresses",
",",
"driver",
".",
... | // Load downloads artifacts from HDFS compliant storage | [
"Load",
"downloads",
"artifacts",
"from",
"HDFS",
"compliant",
"storage"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/artifacts/hdfs/hdfs.go#L136-L175 | train |
argoproj/argo | workflow/artifacts/hdfs/hdfs.go | Save | func (driver *ArtifactDriver) Save(path string, outputArtifact *wfv1.Artifact) error {
hdfscli, err := createHDFSClient(driver.Addresses, driver.HDFSUser, driver.KrbOptions)
if err != nil {
return err
}
defer util.Close(hdfscli)
isDir, err := file.IsDirectory(path)
if err != nil {
return err
}
if isDir {
... | go | func (driver *ArtifactDriver) Save(path string, outputArtifact *wfv1.Artifact) error {
hdfscli, err := createHDFSClient(driver.Addresses, driver.HDFSUser, driver.KrbOptions)
if err != nil {
return err
}
defer util.Close(hdfscli)
isDir, err := file.IsDirectory(path)
if err != nil {
return err
}
if isDir {
... | [
"func",
"(",
"driver",
"*",
"ArtifactDriver",
")",
"Save",
"(",
"path",
"string",
",",
"outputArtifact",
"*",
"wfv1",
".",
"Artifact",
")",
"error",
"{",
"hdfscli",
",",
"err",
":=",
"createHDFSClient",
"(",
"driver",
".",
"Addresses",
",",
"driver",
".",
... | // Save saves an artifact to HDFS compliant storage | [
"Save",
"saves",
"an",
"artifact",
"to",
"HDFS",
"compliant",
"storage"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/artifacts/hdfs/hdfs.go#L178-L217 | train |
argoproj/argo | workflow/ttlcontroller/ttlcontroller.go | NewController | func NewController(config *rest.Config, wfClientset wfclientset.Interface, namespace, instanceID string) *Controller {
filterCompletedWithTTL := func(options *metav1.ListOptions) {
// completed equals (true)
completedReq, err := labels.NewRequirement(common.LabelKeyCompleted, selection.Equals, []string{"true"})
... | go | func NewController(config *rest.Config, wfClientset wfclientset.Interface, namespace, instanceID string) *Controller {
filterCompletedWithTTL := func(options *metav1.ListOptions) {
// completed equals (true)
completedReq, err := labels.NewRequirement(common.LabelKeyCompleted, selection.Equals, []string{"true"})
... | [
"func",
"NewController",
"(",
"config",
"*",
"rest",
".",
"Config",
",",
"wfClientset",
"wfclientset",
".",
"Interface",
",",
"namespace",
",",
"instanceID",
"string",
")",
"*",
"Controller",
"{",
"filterCompletedWithTTL",
":=",
"func",
"(",
"options",
"*",
"m... | // NewController returns a new workflow ttl controller | [
"NewController",
"returns",
"a",
"new",
"workflow",
"ttl",
"controller"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/ttlcontroller/ttlcontroller.go#L39-L69 | train |
argoproj/argo | workflow/ttlcontroller/ttlcontroller.go | enqueueWF | func (c *Controller) enqueueWF(obj interface{}) {
un, ok := obj.(*unstructured.Unstructured)
if !ok {
log.Warnf("'%v' is not an unstructured", obj)
return
}
wf, err := util.FromUnstructured(un)
if err != nil {
log.Warnf("Failed to unmarshal workflow %v object: %v", obj, err)
return
}
now := c.clock.Now()... | go | func (c *Controller) enqueueWF(obj interface{}) {
un, ok := obj.(*unstructured.Unstructured)
if !ok {
log.Warnf("'%v' is not an unstructured", obj)
return
}
wf, err := util.FromUnstructured(un)
if err != nil {
log.Warnf("Failed to unmarshal workflow %v object: %v", obj, err)
return
}
now := c.clock.Now()... | [
"func",
"(",
"c",
"*",
"Controller",
")",
"enqueueWF",
"(",
"obj",
"interface",
"{",
"}",
")",
"{",
"un",
",",
"ok",
":=",
"obj",
".",
"(",
"*",
"unstructured",
".",
"Unstructured",
")",
"\n",
"if",
"!",
"ok",
"{",
"log",
".",
"Warnf",
"(",
"\"",... | // enqueueWF conditionally queues a workflow to the ttl queue if it is within the deletion period | [
"enqueueWF",
"conditionally",
"queues",
"a",
"workflow",
"to",
"the",
"ttl",
"queue",
"if",
"it",
"is",
"within",
"the",
"deletion",
"period"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/ttlcontroller/ttlcontroller.go#L132-L161 | train |
argoproj/argo | workflow/metrics/server.go | RunServer | func RunServer(ctx context.Context, config PrometheusConfig, registry *prometheus.Registry) {
mux := http.NewServeMux()
mux.Handle(config.Path, promhttp.HandlerFor(registry, promhttp.HandlerOpts{}))
srv := &http.Server{Addr: fmt.Sprintf(":%s", config.Port), Handler: mux}
defer func() {
if cerr := srv.Close(); ce... | go | func RunServer(ctx context.Context, config PrometheusConfig, registry *prometheus.Registry) {
mux := http.NewServeMux()
mux.Handle(config.Path, promhttp.HandlerFor(registry, promhttp.HandlerOpts{}))
srv := &http.Server{Addr: fmt.Sprintf(":%s", config.Port), Handler: mux}
defer func() {
if cerr := srv.Close(); ce... | [
"func",
"RunServer",
"(",
"ctx",
"context",
".",
"Context",
",",
"config",
"PrometheusConfig",
",",
"registry",
"*",
"prometheus",
".",
"Registry",
")",
"{",
"mux",
":=",
"http",
".",
"NewServeMux",
"(",
")",
"\n",
"mux",
".",
"Handle",
"(",
"config",
".... | // RunServer starts a metrics server | [
"RunServer",
"starts",
"a",
"metrics",
"server"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/metrics/server.go#L21-L38 | train |
argoproj/argo | workflow/common/util.go | ExecPodContainer | func ExecPodContainer(restConfig *rest.Config, namespace string, pod string, container string, stdout bool, stderr bool, command ...string) (remotecommand.Executor, error) {
clientset, err := kubernetes.NewForConfig(restConfig)
if err != nil {
return nil, errors.InternalWrapError(err)
}
execRequest := clientset.... | go | func ExecPodContainer(restConfig *rest.Config, namespace string, pod string, container string, stdout bool, stderr bool, command ...string) (remotecommand.Executor, error) {
clientset, err := kubernetes.NewForConfig(restConfig)
if err != nil {
return nil, errors.InternalWrapError(err)
}
execRequest := clientset.... | [
"func",
"ExecPodContainer",
"(",
"restConfig",
"*",
"rest",
".",
"Config",
",",
"namespace",
"string",
",",
"pod",
"string",
",",
"container",
"string",
",",
"stdout",
"bool",
",",
"stderr",
"bool",
",",
"command",
"...",
"string",
")",
"(",
"remotecommand",... | // ExecPodContainer runs a command in a container in a pod and returns the remotecommand.Executor | [
"ExecPodContainer",
"runs",
"a",
"command",
"in",
"a",
"container",
"in",
"a",
"pod",
"and",
"returns",
"the",
"remotecommand",
".",
"Executor"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/common/util.go#L194-L220 | train |
argoproj/argo | workflow/common/util.go | GetExecutorOutput | func GetExecutorOutput(exec remotecommand.Executor) (*bytes.Buffer, *bytes.Buffer, error) {
var stdOut bytes.Buffer
var stdErr bytes.Buffer
err := exec.Stream(remotecommand.StreamOptions{
Stdout: &stdOut,
Stderr: &stdErr,
Tty: false,
})
if err != nil {
return nil, nil, errors.InternalWrapError(err)
}
... | go | func GetExecutorOutput(exec remotecommand.Executor) (*bytes.Buffer, *bytes.Buffer, error) {
var stdOut bytes.Buffer
var stdErr bytes.Buffer
err := exec.Stream(remotecommand.StreamOptions{
Stdout: &stdOut,
Stderr: &stdErr,
Tty: false,
})
if err != nil {
return nil, nil, errors.InternalWrapError(err)
}
... | [
"func",
"GetExecutorOutput",
"(",
"exec",
"remotecommand",
".",
"Executor",
")",
"(",
"*",
"bytes",
".",
"Buffer",
",",
"*",
"bytes",
".",
"Buffer",
",",
"error",
")",
"{",
"var",
"stdOut",
"bytes",
".",
"Buffer",
"\n",
"var",
"stdErr",
"bytes",
".",
"... | // GetExecutorOutput returns the output of an remotecommand.Executor | [
"GetExecutorOutput",
"returns",
"the",
"output",
"of",
"an",
"remotecommand",
".",
"Executor"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/common/util.go#L223-L235 | train |
argoproj/argo | workflow/common/util.go | substituteParams | func substituteParams(tmpl *wfv1.Template, globalParams, localParams map[string]string) (*wfv1.Template, error) {
tmplBytes, err := json.Marshal(tmpl)
if err != nil {
return nil, errors.InternalWrapError(err)
}
// First replace globals & locals, then replace inputs because globals could be referenced in the input... | go | func substituteParams(tmpl *wfv1.Template, globalParams, localParams map[string]string) (*wfv1.Template, error) {
tmplBytes, err := json.Marshal(tmpl)
if err != nil {
return nil, errors.InternalWrapError(err)
}
// First replace globals & locals, then replace inputs because globals could be referenced in the input... | [
"func",
"substituteParams",
"(",
"tmpl",
"*",
"wfv1",
".",
"Template",
",",
"globalParams",
",",
"localParams",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"*",
"wfv1",
".",
"Template",
",",
"error",
")",
"{",
"tmplBytes",
",",
"err",
":=",
"json",
... | // substituteParams returns a new copy of the template with global, pod, and input parameters substituted | [
"substituteParams",
"returns",
"a",
"new",
"copy",
"of",
"the",
"template",
"with",
"global",
"pod",
"and",
"input",
"parameters",
"substituted"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/common/util.go#L297-L355 | train |
argoproj/argo | workflow/common/util.go | Replace | func Replace(fstTmpl *fasttemplate.Template, replaceMap map[string]string, allowUnresolved bool) (string, error) {
var unresolvedErr error
replacedTmpl := fstTmpl.ExecuteFuncString(func(w io.Writer, tag string) (int, error) {
replacement, ok := replaceMap[tag]
if !ok {
if allowUnresolved {
// just write th... | go | func Replace(fstTmpl *fasttemplate.Template, replaceMap map[string]string, allowUnresolved bool) (string, error) {
var unresolvedErr error
replacedTmpl := fstTmpl.ExecuteFuncString(func(w io.Writer, tag string) (int, error) {
replacement, ok := replaceMap[tag]
if !ok {
if allowUnresolved {
// just write th... | [
"func",
"Replace",
"(",
"fstTmpl",
"*",
"fasttemplate",
".",
"Template",
",",
"replaceMap",
"map",
"[",
"string",
"]",
"string",
",",
"allowUnresolved",
"bool",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"unresolvedErr",
"error",
"\n",
"replacedTmpl"... | // Replace executes basic string substitution of a template with replacement values.
// allowUnresolved indicates whether or not it is acceptable to have unresolved variables
// remaining in the substituted template. prefixFilter will apply the replacements only
// to variables with the specified prefix | [
"Replace",
"executes",
"basic",
"string",
"substitution",
"of",
"a",
"template",
"with",
"replacement",
"values",
".",
"allowUnresolved",
"indicates",
"whether",
"or",
"not",
"it",
"is",
"acceptable",
"to",
"have",
"unresolved",
"variables",
"remaining",
"in",
"th... | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/common/util.go#L361-L383 | train |
argoproj/argo | workflow/common/util.go | AddPodAnnotation | func AddPodAnnotation(c kubernetes.Interface, podName, namespace, key, value string) error {
return addPodMetadata(c, "annotations", podName, namespace, key, value)
} | go | func AddPodAnnotation(c kubernetes.Interface, podName, namespace, key, value string) error {
return addPodMetadata(c, "annotations", podName, namespace, key, value)
} | [
"func",
"AddPodAnnotation",
"(",
"c",
"kubernetes",
".",
"Interface",
",",
"podName",
",",
"namespace",
",",
"key",
",",
"value",
"string",
")",
"error",
"{",
"return",
"addPodMetadata",
"(",
"c",
",",
"\"",
"\"",
",",
"podName",
",",
"namespace",
",",
"... | // AddPodAnnotation adds an annotation to pod | [
"AddPodAnnotation",
"adds",
"an",
"annotation",
"to",
"pod"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/common/util.go#L405-L407 | train |
argoproj/argo | workflow/common/util.go | addPodMetadata | func addPodMetadata(c kubernetes.Interface, field, podName, namespace, key, value string) error {
metadata := map[string]interface{}{
"metadata": map[string]interface{}{
field: map[string]string{
key: value,
},
},
}
var err error
patch, err := json.Marshal(metadata)
if err != nil {
return errors.In... | go | func addPodMetadata(c kubernetes.Interface, field, podName, namespace, key, value string) error {
metadata := map[string]interface{}{
"metadata": map[string]interface{}{
field: map[string]string{
key: value,
},
},
}
var err error
patch, err := json.Marshal(metadata)
if err != nil {
return errors.In... | [
"func",
"addPodMetadata",
"(",
"c",
"kubernetes",
".",
"Interface",
",",
"field",
",",
"podName",
",",
"namespace",
",",
"key",
",",
"value",
"string",
")",
"error",
"{",
"metadata",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\... | // addPodMetadata is helper to either add a pod label or annotation to the pod | [
"addPodMetadata",
"is",
"helper",
"to",
"either",
"add",
"a",
"pod",
"label",
"or",
"annotation",
"to",
"the",
"pod"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/common/util.go#L415-L440 | train |
argoproj/argo | workflow/common/util.go | IsPodTemplate | func IsPodTemplate(tmpl *wfv1.Template) bool {
if tmpl.Container != nil || tmpl.Script != nil || tmpl.Resource != nil {
return true
}
return false
} | go | func IsPodTemplate(tmpl *wfv1.Template) bool {
if tmpl.Container != nil || tmpl.Script != nil || tmpl.Resource != nil {
return true
}
return false
} | [
"func",
"IsPodTemplate",
"(",
"tmpl",
"*",
"wfv1",
".",
"Template",
")",
"bool",
"{",
"if",
"tmpl",
".",
"Container",
"!=",
"nil",
"||",
"tmpl",
".",
"Script",
"!=",
"nil",
"||",
"tmpl",
".",
"Resource",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",... | // IsPodTemplate returns whether the template corresponds to a pod | [
"IsPodTemplate",
"returns",
"whether",
"the",
"template",
"corresponds",
"to",
"a",
"pod"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/common/util.go#L443-L448 | train |
argoproj/argo | workflow/common/util.go | GetTaskAncestry | func GetTaskAncestry(taskName string, tasks []wfv1.DAGTask) []string {
taskByName := make(map[string]wfv1.DAGTask)
for _, task := range tasks {
taskByName[task.Name] = task
}
visited := make(map[string]bool)
var getAncestry func(s string)
getAncestry = func(currTask string) {
task := taskByName[currTask]
f... | go | func GetTaskAncestry(taskName string, tasks []wfv1.DAGTask) []string {
taskByName := make(map[string]wfv1.DAGTask)
for _, task := range tasks {
taskByName[task.Name] = task
}
visited := make(map[string]bool)
var getAncestry func(s string)
getAncestry = func(currTask string) {
task := taskByName[currTask]
f... | [
"func",
"GetTaskAncestry",
"(",
"taskName",
"string",
",",
"tasks",
"[",
"]",
"wfv1",
".",
"DAGTask",
")",
"[",
"]",
"string",
"{",
"taskByName",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"wfv1",
".",
"DAGTask",
")",
"\n",
"for",
"_",
",",
"task"... | // GetTaskAncestry returns a list of taskNames which are ancestors of this task | [
"GetTaskAncestry",
"returns",
"a",
"list",
"of",
"taskNames",
"which",
"are",
"ancestors",
"of",
"this",
"task"
] | 4e37a444bde2a034885d0db35f7b38684505063e | https://github.com/argoproj/argo/blob/4e37a444bde2a034885d0db35f7b38684505063e/workflow/common/util.go#L451-L475 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.