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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
deis/deis | client/parser/certs.go | Certs | func Certs(argv []string) error {
usage := `
Valid commands for certs:
certs:list list SSL certificates for an app
certs:add add an SSL certificate to an app
certs:remove remove an SSL certificate from an app
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "certs:list":
return certsList(argv)
case "certs:add":
return certAdd(argv)
case "certs:remove":
return certRemove(argv)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "certs" {
argv[0] = "certs:list"
return certsList(argv)
}
PrintUsage()
return nil
}
} | go | func Certs(argv []string) error {
usage := `
Valid commands for certs:
certs:list list SSL certificates for an app
certs:add add an SSL certificate to an app
certs:remove remove an SSL certificate from an app
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "certs:list":
return certsList(argv)
case "certs:add":
return certAdd(argv)
case "certs:remove":
return certRemove(argv)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "certs" {
argv[0] = "certs:list"
return certsList(argv)
}
PrintUsage()
return nil
}
} | [
"func",
"Certs",
"(",
"argv",
"[",
"]",
"string",
")",
"error",
"{",
"usage",
":=",
"`\nValid commands for certs:\n\ncerts:list list SSL certificates for an app\ncerts:add add an SSL certificate to an app\ncerts:remove remove an SSL certificate from an app\n\nUse 'deis help [command]' to learn more.\n`",
"\n\n",
"switch",
"argv",
"[",
"0",
"]",
"{",
"case",
"\"",
"\"",
":",
"return",
"certsList",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"certAdd",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"certRemove",
"(",
"argv",
")",
"\n",
"default",
":",
"if",
"printHelp",
"(",
"argv",
",",
"usage",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"argv",
"[",
"0",
"]",
"==",
"\"",
"\"",
"{",
"argv",
"[",
"0",
"]",
"=",
"\"",
"\"",
"\n",
"return",
"certsList",
"(",
"argv",
")",
"\n",
"}",
"\n\n",
"PrintUsage",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // Certs routes certs commands to their specific function. | [
"Certs",
"routes",
"certs",
"commands",
"to",
"their",
"specific",
"function",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/parser/certs.go#L9-L40 | train |
deis/deis | client/deis.go | prepareCmdArgs | func prepareCmdArgs(command string, argv []string) []string {
cmdArgv := []string{extensionPrefix + command}
cmdSplit := strings.Split(argv[0], command+":")
if len(cmdSplit) > 1 {
cmdArgv = append(cmdArgv, cmdSplit[1])
}
return append(cmdArgv, argv[1:]...)
} | go | func prepareCmdArgs(command string, argv []string) []string {
cmdArgv := []string{extensionPrefix + command}
cmdSplit := strings.Split(argv[0], command+":")
if len(cmdSplit) > 1 {
cmdArgv = append(cmdArgv, cmdSplit[1])
}
return append(cmdArgv, argv[1:]...)
} | [
"func",
"prepareCmdArgs",
"(",
"command",
"string",
",",
"argv",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"cmdArgv",
":=",
"[",
"]",
"string",
"{",
"extensionPrefix",
"+",
"command",
"}",
"\n",
"cmdSplit",
":=",
"strings",
".",
"Split",
"(",
"argv",
"[",
"0",
"]",
",",
"command",
"+",
"\"",
"\"",
")",
"\n\n",
"if",
"len",
"(",
"cmdSplit",
")",
">",
"1",
"{",
"cmdArgv",
"=",
"append",
"(",
"cmdArgv",
",",
"cmdSplit",
"[",
"1",
"]",
")",
"\n",
"}",
"\n\n",
"return",
"append",
"(",
"cmdArgv",
",",
"argv",
"[",
"1",
":",
"]",
"...",
")",
"\n",
"}"
] | // split original command and pass its first element in arguments | [
"split",
"original",
"command",
"and",
"pass",
"its",
"first",
"element",
"in",
"arguments"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/deis.go#L183-L192 | train |
deis/deis | router/cmd/boot/boot.go | waitForInitialConfd | func waitForInitialConfd(etcd string, timeout time.Duration) {
for {
var buffer bytes.Buffer
output := bufio.NewWriter(&buffer)
log.Debugf("Connecting to etcd server %s", etcd)
cmd := exec.Command("confd", "-node", etcd, "-onetime", "--log-level", "error")
cmd.Stdout = output
cmd.Stderr = output
err := cmd.Run()
output.Flush()
if err == nil {
break
}
log.Info("waiting for confd to write initial templates...")
log.Debugf("\n%s", buffer.String())
time.Sleep(timeout)
}
} | go | func waitForInitialConfd(etcd string, timeout time.Duration) {
for {
var buffer bytes.Buffer
output := bufio.NewWriter(&buffer)
log.Debugf("Connecting to etcd server %s", etcd)
cmd := exec.Command("confd", "-node", etcd, "-onetime", "--log-level", "error")
cmd.Stdout = output
cmd.Stderr = output
err := cmd.Run()
output.Flush()
if err == nil {
break
}
log.Info("waiting for confd to write initial templates...")
log.Debugf("\n%s", buffer.String())
time.Sleep(timeout)
}
} | [
"func",
"waitForInitialConfd",
"(",
"etcd",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"{",
"for",
"{",
"var",
"buffer",
"bytes",
".",
"Buffer",
"\n",
"output",
":=",
"bufio",
".",
"NewWriter",
"(",
"&",
"buffer",
")",
"\n",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"etcd",
")",
"\n",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"etcd",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"cmd",
".",
"Stdout",
"=",
"output",
"\n",
"cmd",
".",
"Stderr",
"=",
"output",
"\n\n",
"err",
":=",
"cmd",
".",
"Run",
"(",
")",
"\n",
"output",
".",
"Flush",
"(",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"break",
"\n",
"}",
"\n\n",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"log",
".",
"Debugf",
"(",
"\"",
"\\n",
"\"",
",",
"buffer",
".",
"String",
"(",
")",
")",
"\n",
"time",
".",
"Sleep",
"(",
"timeout",
")",
"\n",
"}",
"\n",
"}"
] | // Wait until the compilation of the templates | [
"Wait",
"until",
"the",
"compilation",
"of",
"the",
"templates"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/router/cmd/boot/boot.go#L108-L127 | train |
deis/deis | deisctl/cmd/platform.go | InstallPlatform | func InstallPlatform(b backend.Backend, cb config.Backend, checkKeys func(config.Backend) error, stateless bool) error {
if err := checkKeys(cb); err != nil {
return err
}
if stateless {
fmt.Println("Warning: With a stateless control plane, some components require manual configuration.")
fmt.Println("See the official Deis documentation for details on running a stateless control plane.")
fmt.Println("http://docs.deis.io/en/latest/managing_deis/running-deis-without-ceph/")
}
var wg sync.WaitGroup
io.WriteString(Stdout, prettyprint.DeisIfy("Installing Deis..."))
installDefaultServices(b, stateless, &wg, Stdout, Stderr)
wg.Wait()
fmt.Fprintln(Stdout, "Done.")
fmt.Fprintln(Stdout, "")
if stateless {
fmt.Fprintln(Stdout, "Please run `deisctl start stateless-platform` to boot up Deis.")
} else {
fmt.Fprintln(Stdout, "Please run `deisctl start platform` to boot up Deis.")
}
return nil
} | go | func InstallPlatform(b backend.Backend, cb config.Backend, checkKeys func(config.Backend) error, stateless bool) error {
if err := checkKeys(cb); err != nil {
return err
}
if stateless {
fmt.Println("Warning: With a stateless control plane, some components require manual configuration.")
fmt.Println("See the official Deis documentation for details on running a stateless control plane.")
fmt.Println("http://docs.deis.io/en/latest/managing_deis/running-deis-without-ceph/")
}
var wg sync.WaitGroup
io.WriteString(Stdout, prettyprint.DeisIfy("Installing Deis..."))
installDefaultServices(b, stateless, &wg, Stdout, Stderr)
wg.Wait()
fmt.Fprintln(Stdout, "Done.")
fmt.Fprintln(Stdout, "")
if stateless {
fmt.Fprintln(Stdout, "Please run `deisctl start stateless-platform` to boot up Deis.")
} else {
fmt.Fprintln(Stdout, "Please run `deisctl start platform` to boot up Deis.")
}
return nil
} | [
"func",
"InstallPlatform",
"(",
"b",
"backend",
".",
"Backend",
",",
"cb",
"config",
".",
"Backend",
",",
"checkKeys",
"func",
"(",
"config",
".",
"Backend",
")",
"error",
",",
"stateless",
"bool",
")",
"error",
"{",
"if",
"err",
":=",
"checkKeys",
"(",
"cb",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"stateless",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n\n",
"io",
".",
"WriteString",
"(",
"Stdout",
",",
"prettyprint",
".",
"DeisIfy",
"(",
"\"",
"\"",
")",
")",
"\n\n",
"installDefaultServices",
"(",
"b",
",",
"stateless",
",",
"&",
"wg",
",",
"Stdout",
",",
"Stderr",
")",
"\n\n",
"wg",
".",
"Wait",
"(",
")",
"\n\n",
"fmt",
".",
"Fprintln",
"(",
"Stdout",
",",
"\"",
"\"",
")",
"\n",
"fmt",
".",
"Fprintln",
"(",
"Stdout",
",",
"\"",
"\"",
")",
"\n",
"if",
"stateless",
"{",
"fmt",
".",
"Fprintln",
"(",
"Stdout",
",",
"\"",
"\"",
")",
"\n",
"}",
"else",
"{",
"fmt",
".",
"Fprintln",
"(",
"Stdout",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // InstallPlatform loads all components' definitions from local unit files.
// After InstallPlatform, all components will be available for StartPlatform. | [
"InstallPlatform",
"loads",
"all",
"components",
"definitions",
"from",
"local",
"unit",
"files",
".",
"After",
"InstallPlatform",
"all",
"components",
"will",
"be",
"available",
"for",
"StartPlatform",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/cmd/platform.go#L15-L43 | train |
deis/deis | deisctl/cmd/platform.go | StartPlatform | func StartPlatform(b backend.Backend, stateless bool) error {
var wg sync.WaitGroup
io.WriteString(Stdout, prettyprint.DeisIfy("Starting Deis..."))
startDefaultServices(b, stateless, &wg, Stdout, Stderr)
wg.Wait()
fmt.Fprintln(Stdout, "Done.\n ")
fmt.Fprintln(Stdout, "Please set up an administrative account. See 'deis help register'")
return nil
} | go | func StartPlatform(b backend.Backend, stateless bool) error {
var wg sync.WaitGroup
io.WriteString(Stdout, prettyprint.DeisIfy("Starting Deis..."))
startDefaultServices(b, stateless, &wg, Stdout, Stderr)
wg.Wait()
fmt.Fprintln(Stdout, "Done.\n ")
fmt.Fprintln(Stdout, "Please set up an administrative account. See 'deis help register'")
return nil
} | [
"func",
"StartPlatform",
"(",
"b",
"backend",
".",
"Backend",
",",
"stateless",
"bool",
")",
"error",
"{",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n\n",
"io",
".",
"WriteString",
"(",
"Stdout",
",",
"prettyprint",
".",
"DeisIfy",
"(",
"\"",
"\"",
")",
")",
"\n\n",
"startDefaultServices",
"(",
"b",
",",
"stateless",
",",
"&",
"wg",
",",
"Stdout",
",",
"Stderr",
")",
"\n\n",
"wg",
".",
"Wait",
"(",
")",
"\n\n",
"fmt",
".",
"Fprintln",
"(",
"Stdout",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"fmt",
".",
"Fprintln",
"(",
"Stdout",
",",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // StartPlatform activates all components. | [
"StartPlatform",
"activates",
"all",
"components",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/cmd/platform.go#L46-L59 | train |
deis/deis | client/cmd/tags.go | TagsList | func TagsList(appID string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
config, err := config.List(c, appID)
fmt.Printf("=== %s Tags\n", appID)
tagMap := make(map[string]string)
for key, value := range config.Tags {
tagMap[key] = fmt.Sprintf("%v", value)
}
fmt.Print(prettyprint.PrettyTabs(tagMap, 5))
return nil
} | go | func TagsList(appID string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
config, err := config.List(c, appID)
fmt.Printf("=== %s Tags\n", appID)
tagMap := make(map[string]string)
for key, value := range config.Tags {
tagMap[key] = fmt.Sprintf("%v", value)
}
fmt.Print(prettyprint.PrettyTabs(tagMap, 5))
return nil
} | [
"func",
"TagsList",
"(",
"appID",
"string",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"load",
"(",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"config",
",",
"err",
":=",
"config",
".",
"List",
"(",
"c",
",",
"appID",
")",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"appID",
")",
"\n\n",
"tagMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n\n",
"for",
"key",
",",
"value",
":=",
"range",
"config",
".",
"Tags",
"{",
"tagMap",
"[",
"key",
"]",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"value",
")",
"\n",
"}",
"\n\n",
"fmt",
".",
"Print",
"(",
"prettyprint",
".",
"PrettyTabs",
"(",
"tagMap",
",",
"5",
")",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // TagsList lists an app's tags. | [
"TagsList",
"lists",
"an",
"app",
"s",
"tags",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/tags.go#L14-L34 | train |
deis/deis | client/cmd/tags.go | TagsUnset | func TagsUnset(appID string, tags []string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
fmt.Print("Applying tags... ")
quit := progress()
configObj := api.Config{}
tagsMap := make(map[string]interface{})
for _, tag := range tags {
tagsMap[tag] = nil
}
configObj.Tags = tagsMap
_, err = config.Set(c, appID, configObj)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Print("done\n\n")
return TagsList(appID)
} | go | func TagsUnset(appID string, tags []string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
fmt.Print("Applying tags... ")
quit := progress()
configObj := api.Config{}
tagsMap := make(map[string]interface{})
for _, tag := range tags {
tagsMap[tag] = nil
}
configObj.Tags = tagsMap
_, err = config.Set(c, appID, configObj)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Print("done\n\n")
return TagsList(appID)
} | [
"func",
"TagsUnset",
"(",
"appID",
"string",
",",
"tags",
"[",
"]",
"string",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"load",
"(",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Print",
"(",
"\"",
"\"",
")",
"\n\n",
"quit",
":=",
"progress",
"(",
")",
"\n\n",
"configObj",
":=",
"api",
".",
"Config",
"{",
"}",
"\n\n",
"tagsMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n\n",
"for",
"_",
",",
"tag",
":=",
"range",
"tags",
"{",
"tagsMap",
"[",
"tag",
"]",
"=",
"nil",
"\n",
"}",
"\n\n",
"configObj",
".",
"Tags",
"=",
"tagsMap",
"\n\n",
"_",
",",
"err",
"=",
"config",
".",
"Set",
"(",
"c",
",",
"appID",
",",
"configObj",
")",
"\n\n",
"quit",
"<-",
"true",
"\n",
"<-",
"quit",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Print",
"(",
"\"",
"\\n",
"\\n",
"\"",
")",
"\n\n",
"return",
"TagsList",
"(",
"appID",
")",
"\n",
"}"
] | // TagsUnset removes an app's tags. | [
"TagsUnset",
"removes",
"an",
"app",
"s",
"tags",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/tags.go#L67-L100 | train |
deis/deis | router/logger/stdout_formatter.go | Format | func (f *StdOutFormatter) Format(entry *logrus.Entry) ([]byte, error) {
b := &bytes.Buffer{}
fmt.Fprintf(b, "[%s] - %s\n", strings.ToUpper(entry.Level.String()), entry.Message)
return b.Bytes(), nil
} | go | func (f *StdOutFormatter) Format(entry *logrus.Entry) ([]byte, error) {
b := &bytes.Buffer{}
fmt.Fprintf(b, "[%s] - %s\n", strings.ToUpper(entry.Level.String()), entry.Message)
return b.Bytes(), nil
} | [
"func",
"(",
"f",
"*",
"StdOutFormatter",
")",
"Format",
"(",
"entry",
"*",
"logrus",
".",
"Entry",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"b",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"fmt",
".",
"Fprintf",
"(",
"b",
",",
"\"",
"\\n",
"\"",
",",
"strings",
".",
"ToUpper",
"(",
"entry",
".",
"Level",
".",
"String",
"(",
")",
")",
",",
"entry",
".",
"Message",
")",
"\n",
"return",
"b",
".",
"Bytes",
"(",
")",
",",
"nil",
"\n",
"}"
] | // Format rewrites a log entry for stdout as a byte array. | [
"Format",
"rewrites",
"a",
"log",
"entry",
"for",
"stdout",
"as",
"a",
"byte",
"array",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/router/logger/stdout_formatter.go#L16-L20 | train |
deis/deis | client/parser/version.go | Version | func Version(argv []string) error {
usage := `
Displays the client version.
Usage: deis version
Use 'deis help [command]' to learn more.
`
if _, err := docopt.Parse(usage, argv, true, "", false, true); err != nil {
return err
}
fmt.Println(version.Version)
return nil
} | go | func Version(argv []string) error {
usage := `
Displays the client version.
Usage: deis version
Use 'deis help [command]' to learn more.
`
if _, err := docopt.Parse(usage, argv, true, "", false, true); err != nil {
return err
}
fmt.Println(version.Version)
return nil
} | [
"func",
"Version",
"(",
"argv",
"[",
"]",
"string",
")",
"error",
"{",
"usage",
":=",
"`\nDisplays the client version.\n\nUsage: deis version\n\nUse 'deis help [command]' to learn more.\n`",
"\n",
"if",
"_",
",",
"err",
":=",
"docopt",
".",
"Parse",
"(",
"usage",
",",
"argv",
",",
"true",
",",
"\"",
"\"",
",",
"false",
",",
"true",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Println",
"(",
"version",
".",
"Version",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // Version displays the client version | [
"Version",
"displays",
"the",
"client",
"version"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/parser/version.go#L11-L25 | train |
deis/deis | deisctl/config/config.go | Config | func Config(target string, action string, key []string, cb Backend) error {
return doConfig(target, action, key, cb, os.Stdout)
} | go | func Config(target string, action string, key []string, cb Backend) error {
return doConfig(target, action, key, cb, os.Stdout)
} | [
"func",
"Config",
"(",
"target",
"string",
",",
"action",
"string",
",",
"key",
"[",
"]",
"string",
",",
"cb",
"Backend",
")",
"error",
"{",
"return",
"doConfig",
"(",
"target",
",",
"action",
",",
"key",
",",
"cb",
",",
"os",
".",
"Stdout",
")",
"\n",
"}"
] | // Config runs the config subcommand | [
"Config",
"runs",
"the",
"config",
"subcommand"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/config/config.go#L25-L27 | train |
deis/deis | deisctl/config/config.go | CheckConfig | func CheckConfig(root string, k string, cb Backend) error {
_, err := doConfigGet(cb, root, []string{k})
if err != nil {
return err
}
return nil
} | go | func CheckConfig(root string, k string, cb Backend) error {
_, err := doConfigGet(cb, root, []string{k})
if err != nil {
return err
}
return nil
} | [
"func",
"CheckConfig",
"(",
"root",
"string",
",",
"k",
"string",
",",
"cb",
"Backend",
")",
"error",
"{",
"_",
",",
"err",
":=",
"doConfigGet",
"(",
"cb",
",",
"root",
",",
"[",
"]",
"string",
"{",
"k",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // CheckConfig looks for a value at a keyspace path
// and returns an error if a value is not found | [
"CheckConfig",
"looks",
"for",
"a",
"value",
"at",
"a",
"keyspace",
"path",
"and",
"returns",
"an",
"error",
"if",
"a",
"value",
"is",
"not",
"found"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/config/config.go#L31-L39 | train |
deis/deis | deisctl/config/config.go | valueForPath | func valueForPath(path string, v string) (string, error) {
// check if path is part of fileKeys
for _, p := range fileKeys {
if path == p {
// read value from filesystem
bytes, err := ioutil.ReadFile(utils.ResolvePath(v))
if err != nil {
return "", err
}
// see if we should return base64 encoded value
for _, pp := range b64Keys {
if path == pp {
return base64.StdEncoding.EncodeToString(bytes), nil
}
}
return string(bytes), nil
}
}
return v, nil
} | go | func valueForPath(path string, v string) (string, error) {
// check if path is part of fileKeys
for _, p := range fileKeys {
if path == p {
// read value from filesystem
bytes, err := ioutil.ReadFile(utils.ResolvePath(v))
if err != nil {
return "", err
}
// see if we should return base64 encoded value
for _, pp := range b64Keys {
if path == pp {
return base64.StdEncoding.EncodeToString(bytes), nil
}
}
return string(bytes), nil
}
}
return v, nil
} | [
"func",
"valueForPath",
"(",
"path",
"string",
",",
"v",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"// check if path is part of fileKeys",
"for",
"_",
",",
"p",
":=",
"range",
"fileKeys",
"{",
"if",
"path",
"==",
"p",
"{",
"// read value from filesystem",
"bytes",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"utils",
".",
"ResolvePath",
"(",
"v",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"// see if we should return base64 encoded value",
"for",
"_",
",",
"pp",
":=",
"range",
"b64Keys",
"{",
"if",
"path",
"==",
"pp",
"{",
"return",
"base64",
".",
"StdEncoding",
".",
"EncodeToString",
"(",
"bytes",
")",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"string",
"(",
"bytes",
")",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"v",
",",
"nil",
"\n\n",
"}"
] | // valueForPath returns the canonical value for a user-defined path and value | [
"valueForPath",
"returns",
"the",
"canonical",
"value",
"for",
"a",
"user",
"-",
"defined",
"path",
"and",
"value"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/config/config.go#L123-L149 | train |
deis/deis | deisctl/backend/fleet/status.go | printUnitStatus | func (c *FleetClient) printUnitStatus(name string) int {
u, err := c.Fleet.Unit(name)
switch {
case suToGlobal(*u):
fmt.Fprintf(c.errWriter, "Unable to get status for global unit %s. Check the status on the host using systemctl.\n", name)
return 1
case err != nil:
fmt.Fprintf(c.errWriter, "Error retrieving Unit %s: %v\n", name, err)
return 1
case u == nil:
fmt.Fprintf(c.errWriter, "Unit %s does not exist.\n", name)
return 1
case u.CurrentState == "":
fmt.Fprintf(c.errWriter, "Unit %s does not appear to be running.\n", name)
return 1
}
cmd := fmt.Sprintf("systemctl status -l %s", name)
return c.runCommand(cmd, u.MachineID)
} | go | func (c *FleetClient) printUnitStatus(name string) int {
u, err := c.Fleet.Unit(name)
switch {
case suToGlobal(*u):
fmt.Fprintf(c.errWriter, "Unable to get status for global unit %s. Check the status on the host using systemctl.\n", name)
return 1
case err != nil:
fmt.Fprintf(c.errWriter, "Error retrieving Unit %s: %v\n", name, err)
return 1
case u == nil:
fmt.Fprintf(c.errWriter, "Unit %s does not exist.\n", name)
return 1
case u.CurrentState == "":
fmt.Fprintf(c.errWriter, "Unit %s does not appear to be running.\n", name)
return 1
}
cmd := fmt.Sprintf("systemctl status -l %s", name)
return c.runCommand(cmd, u.MachineID)
} | [
"func",
"(",
"c",
"*",
"FleetClient",
")",
"printUnitStatus",
"(",
"name",
"string",
")",
"int",
"{",
"u",
",",
"err",
":=",
"c",
".",
"Fleet",
".",
"Unit",
"(",
"name",
")",
"\n",
"switch",
"{",
"case",
"suToGlobal",
"(",
"*",
"u",
")",
":",
"fmt",
".",
"Fprintf",
"(",
"c",
".",
"errWriter",
",",
"\"",
"\\n",
"\"",
",",
"name",
")",
"\n",
"return",
"1",
"\n",
"case",
"err",
"!=",
"nil",
":",
"fmt",
".",
"Fprintf",
"(",
"c",
".",
"errWriter",
",",
"\"",
"\\n",
"\"",
",",
"name",
",",
"err",
")",
"\n",
"return",
"1",
"\n",
"case",
"u",
"==",
"nil",
":",
"fmt",
".",
"Fprintf",
"(",
"c",
".",
"errWriter",
",",
"\"",
"\\n",
"\"",
",",
"name",
")",
"\n",
"return",
"1",
"\n",
"case",
"u",
".",
"CurrentState",
"==",
"\"",
"\"",
":",
"fmt",
".",
"Fprintf",
"(",
"c",
".",
"errWriter",
",",
"\"",
"\\n",
"\"",
",",
"name",
")",
"\n",
"return",
"1",
"\n",
"}",
"\n",
"cmd",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"name",
")",
"\n",
"return",
"c",
".",
"runCommand",
"(",
"cmd",
",",
"u",
".",
"MachineID",
")",
"\n",
"}"
] | // printUnitStatus displays the systemd status for a given unit | [
"printUnitStatus",
"displays",
"the",
"systemd",
"status",
"for",
"a",
"given",
"unit"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/status.go#L21-L39 | train |
deis/deis | deisctl/backend/fleet/create.go | Create | func (c *FleetClient) Create(
targets []string, wg *sync.WaitGroup, out, ew io.Writer) {
units := make([]*schema.Unit, len(targets))
for i, target := range targets {
unitName, unitFile, err := c.createUnitFile(target)
if err != nil {
fmt.Fprintf(ew, "Error creating: %s\n", err)
return
}
units[i] = &schema.Unit{
Name: unitName,
Options: schema.MapUnitFileToSchemaUnitOptions(unitFile),
}
}
for _, unit := range units {
wg.Add(1)
go doCreate(c, unit, wg, out, ew)
}
} | go | func (c *FleetClient) Create(
targets []string, wg *sync.WaitGroup, out, ew io.Writer) {
units := make([]*schema.Unit, len(targets))
for i, target := range targets {
unitName, unitFile, err := c.createUnitFile(target)
if err != nil {
fmt.Fprintf(ew, "Error creating: %s\n", err)
return
}
units[i] = &schema.Unit{
Name: unitName,
Options: schema.MapUnitFileToSchemaUnitOptions(unitFile),
}
}
for _, unit := range units {
wg.Add(1)
go doCreate(c, unit, wg, out, ew)
}
} | [
"func",
"(",
"c",
"*",
"FleetClient",
")",
"Create",
"(",
"targets",
"[",
"]",
"string",
",",
"wg",
"*",
"sync",
".",
"WaitGroup",
",",
"out",
",",
"ew",
"io",
".",
"Writer",
")",
"{",
"units",
":=",
"make",
"(",
"[",
"]",
"*",
"schema",
".",
"Unit",
",",
"len",
"(",
"targets",
")",
")",
"\n\n",
"for",
"i",
",",
"target",
":=",
"range",
"targets",
"{",
"unitName",
",",
"unitFile",
",",
"err",
":=",
"c",
".",
"createUnitFile",
"(",
"target",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Fprintf",
"(",
"ew",
",",
"\"",
"\\n",
"\"",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n",
"units",
"[",
"i",
"]",
"=",
"&",
"schema",
".",
"Unit",
"{",
"Name",
":",
"unitName",
",",
"Options",
":",
"schema",
".",
"MapUnitFileToSchemaUnitOptions",
"(",
"unitFile",
")",
",",
"}",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"unit",
":=",
"range",
"units",
"{",
"wg",
".",
"Add",
"(",
"1",
")",
"\n",
"go",
"doCreate",
"(",
"c",
",",
"unit",
",",
"wg",
",",
"out",
",",
"ew",
")",
"\n",
"}",
"\n",
"}"
] | // Create schedules unit files for the given components. | [
"Create",
"schedules",
"unit",
"files",
"for",
"the",
"given",
"components",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/create.go#L19-L40 | train |
deis/deis | deisctl/backend/fleet/create.go | createServiceUnit | func (c *FleetClient) createServiceUnit(component string, num int) (name string, uf *unit.UnitFile, err error) {
name, err = formatUnitName(component, num)
if err != nil {
return "", nil, err
}
decorateStr, err := c.configBackend.GetWithDefault("/deis/platform/enablePlacementOptions", "false")
if err != nil {
return "", nil, err
}
decorate, err := strconv.ParseBool(decorateStr)
if err != nil {
return "", nil, err
}
uf, err = NewUnit(component, c.templatePaths, decorate)
if err != nil {
return
}
return name, uf, nil
} | go | func (c *FleetClient) createServiceUnit(component string, num int) (name string, uf *unit.UnitFile, err error) {
name, err = formatUnitName(component, num)
if err != nil {
return "", nil, err
}
decorateStr, err := c.configBackend.GetWithDefault("/deis/platform/enablePlacementOptions", "false")
if err != nil {
return "", nil, err
}
decorate, err := strconv.ParseBool(decorateStr)
if err != nil {
return "", nil, err
}
uf, err = NewUnit(component, c.templatePaths, decorate)
if err != nil {
return
}
return name, uf, nil
} | [
"func",
"(",
"c",
"*",
"FleetClient",
")",
"createServiceUnit",
"(",
"component",
"string",
",",
"num",
"int",
")",
"(",
"name",
"string",
",",
"uf",
"*",
"unit",
".",
"UnitFile",
",",
"err",
"error",
")",
"{",
"name",
",",
"err",
"=",
"formatUnitName",
"(",
"component",
",",
"num",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"nil",
",",
"err",
"\n",
"}",
"\n",
"decorateStr",
",",
"err",
":=",
"c",
".",
"configBackend",
".",
"GetWithDefault",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"nil",
",",
"err",
"\n",
"}",
"\n",
"decorate",
",",
"err",
":=",
"strconv",
".",
"ParseBool",
"(",
"decorateStr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"nil",
",",
"err",
"\n",
"}",
"\n",
"uf",
",",
"err",
"=",
"NewUnit",
"(",
"component",
",",
"c",
".",
"templatePaths",
",",
"decorate",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"return",
"name",
",",
"uf",
",",
"nil",
"\n",
"}"
] | // Create normal service unit | [
"Create",
"normal",
"service",
"unit"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/create.go#L95-L113 | train |
deis/deis | deisctl/backend/fleet/list_machines.go | ListMachines | func (c *FleetClient) ListMachines() (err error) {
machines, err := c.Fleet.Machines()
if err != nil {
return err
}
c.printMachines(machines)
return
} | go | func (c *FleetClient) ListMachines() (err error) {
machines, err := c.Fleet.Machines()
if err != nil {
return err
}
c.printMachines(machines)
return
} | [
"func",
"(",
"c",
"*",
"FleetClient",
")",
"ListMachines",
"(",
")",
"(",
"err",
"error",
")",
"{",
"machines",
",",
"err",
":=",
"c",
".",
"Fleet",
".",
"Machines",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"c",
".",
"printMachines",
"(",
"machines",
")",
"\n",
"return",
"\n",
"}"
] | // ListMachines prints all nodes to Stdout | [
"ListMachines",
"prints",
"all",
"nodes",
"to",
"Stdout"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/list_machines.go#L38-L46 | train |
deis/deis | client/cmd/users.go | UsersList | func UsersList(results int) error {
c, err := client.New()
if err != nil {
return err
}
if results == defaultLimit {
results = c.ResponseLimit
}
users, count, err := users.List(c, results)
if err != nil {
return err
}
fmt.Printf("=== Users%s", limitCount(len(users), count))
sort.Sort(users)
for _, user := range users {
fmt.Println(user.Username)
}
return nil
} | go | func UsersList(results int) error {
c, err := client.New()
if err != nil {
return err
}
if results == defaultLimit {
results = c.ResponseLimit
}
users, count, err := users.List(c, results)
if err != nil {
return err
}
fmt.Printf("=== Users%s", limitCount(len(users), count))
sort.Sort(users)
for _, user := range users {
fmt.Println(user.Username)
}
return nil
} | [
"func",
"UsersList",
"(",
"results",
"int",
")",
"error",
"{",
"c",
",",
"err",
":=",
"client",
".",
"New",
"(",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"results",
"==",
"defaultLimit",
"{",
"results",
"=",
"c",
".",
"ResponseLimit",
"\n",
"}",
"\n\n",
"users",
",",
"count",
",",
"err",
":=",
"users",
".",
"List",
"(",
"c",
",",
"results",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"limitCount",
"(",
"len",
"(",
"users",
")",
",",
"count",
")",
")",
"\n\n",
"sort",
".",
"Sort",
"(",
"users",
")",
"\n\n",
"for",
"_",
",",
"user",
":=",
"range",
"users",
"{",
"fmt",
".",
"Println",
"(",
"user",
".",
"Username",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // UsersList lists users registered with the controller. | [
"UsersList",
"lists",
"users",
"registered",
"with",
"the",
"controller",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/users.go#L12-L37 | train |
deis/deis | logger/syslogish/server.go | DestroyLogs | func (s *Server) DestroyLogs(app string) error {
// Get a read lock to ensure the storage adapater pointer can't be updated by another
// goroutine in the time between we check if it's nil and the time we invoke .Destroy() upon
// it.
s.adapterMutex.RLock()
defer s.adapterMutex.RUnlock()
if s.storageAdapter == nil {
return fmt.Errorf("Could not destroy logs for '%s'. No storage adapter specified.", app)
}
return s.storageAdapter.Destroy(app)
} | go | func (s *Server) DestroyLogs(app string) error {
// Get a read lock to ensure the storage adapater pointer can't be updated by another
// goroutine in the time between we check if it's nil and the time we invoke .Destroy() upon
// it.
s.adapterMutex.RLock()
defer s.adapterMutex.RUnlock()
if s.storageAdapter == nil {
return fmt.Errorf("Could not destroy logs for '%s'. No storage adapter specified.", app)
}
return s.storageAdapter.Destroy(app)
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"DestroyLogs",
"(",
"app",
"string",
")",
"error",
"{",
"// Get a read lock to ensure the storage adapater pointer can't be updated by another",
"// goroutine in the time between we check if it's nil and the time we invoke .Destroy() upon",
"// it.",
"s",
".",
"adapterMutex",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"adapterMutex",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"s",
".",
"storageAdapter",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"app",
")",
"\n",
"}",
"\n",
"return",
"s",
".",
"storageAdapter",
".",
"Destroy",
"(",
"app",
")",
"\n",
"}"
] | // DestroyLogs deletes all logs for a specified app by delegating to the server's underlying
// storage.Adapter. | [
"DestroyLogs",
"deletes",
"all",
"logs",
"for",
"a",
"specified",
"app",
"by",
"delegating",
"to",
"the",
"server",
"s",
"underlying",
"storage",
".",
"Adapter",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/syslogish/server.go#L188-L198 | train |
deis/deis | logger/syslogish/server.go | ReopenLogs | func (s *Server) ReopenLogs() error {
// Get a read lock to ensure the storage adapater pointer can't be updated by another
// goroutine in the time between we check if it's nil and the time we invoke .Reopen() upon
// it.
s.adapterMutex.RLock()
defer s.adapterMutex.RUnlock()
if s.storageAdapter == nil {
return errors.New("Could not reopen logs. No storage adapter specified.")
}
return s.storageAdapter.Reopen()
} | go | func (s *Server) ReopenLogs() error {
// Get a read lock to ensure the storage adapater pointer can't be updated by another
// goroutine in the time between we check if it's nil and the time we invoke .Reopen() upon
// it.
s.adapterMutex.RLock()
defer s.adapterMutex.RUnlock()
if s.storageAdapter == nil {
return errors.New("Could not reopen logs. No storage adapter specified.")
}
return s.storageAdapter.Reopen()
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"ReopenLogs",
"(",
")",
"error",
"{",
"// Get a read lock to ensure the storage adapater pointer can't be updated by another",
"// goroutine in the time between we check if it's nil and the time we invoke .Reopen() upon",
"// it.",
"s",
".",
"adapterMutex",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"adapterMutex",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"s",
".",
"storageAdapter",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"s",
".",
"storageAdapter",
".",
"Reopen",
"(",
")",
"\n",
"}"
] | // ReopenLogs delegate to the server's underlying storage.Adapter to, if applicable, refresh
// references to underlying storage mechanisms. This is useful, for instance, to ensure logging
// continues smoothly after log rotation when file-based storage is in use. | [
"ReopenLogs",
"delegate",
"to",
"the",
"server",
"s",
"underlying",
"storage",
".",
"Adapter",
"to",
"if",
"applicable",
"refresh",
"references",
"to",
"underlying",
"storage",
"mechanisms",
".",
"This",
"is",
"useful",
"for",
"instance",
"to",
"ensure",
"logging",
"continues",
"smoothly",
"after",
"log",
"rotation",
"when",
"file",
"-",
"based",
"storage",
"is",
"in",
"use",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/syslogish/server.go#L203-L213 | train |
deis/deis | client/parser/limits.go | Limits | func Limits(argv []string) error {
usage := `
Valid commands for limits:
limits:list list resource limits for an app
limits:set set resource limits for an app
limits:unset unset resource limits for an app
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "limits:list":
return limitsList(argv)
case "limits:set":
return limitSet(argv)
case "limits:unset":
return limitUnset(argv)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "limits" {
argv[0] = "limits:list"
return limitsList(argv)
}
PrintUsage()
return nil
}
} | go | func Limits(argv []string) error {
usage := `
Valid commands for limits:
limits:list list resource limits for an app
limits:set set resource limits for an app
limits:unset unset resource limits for an app
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "limits:list":
return limitsList(argv)
case "limits:set":
return limitSet(argv)
case "limits:unset":
return limitUnset(argv)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "limits" {
argv[0] = "limits:list"
return limitsList(argv)
}
PrintUsage()
return nil
}
} | [
"func",
"Limits",
"(",
"argv",
"[",
"]",
"string",
")",
"error",
"{",
"usage",
":=",
"`\nValid commands for limits:\n\nlimits:list list resource limits for an app\nlimits:set set resource limits for an app\nlimits:unset unset resource limits for an app\n\nUse 'deis help [command]' to learn more.\n`",
"\n\n",
"switch",
"argv",
"[",
"0",
"]",
"{",
"case",
"\"",
"\"",
":",
"return",
"limitsList",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"limitSet",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"limitUnset",
"(",
"argv",
")",
"\n",
"default",
":",
"if",
"printHelp",
"(",
"argv",
",",
"usage",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"argv",
"[",
"0",
"]",
"==",
"\"",
"\"",
"{",
"argv",
"[",
"0",
"]",
"=",
"\"",
"\"",
"\n",
"return",
"limitsList",
"(",
"argv",
")",
"\n",
"}",
"\n\n",
"PrintUsage",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // Limits routes limits commands to their specific function | [
"Limits",
"routes",
"limits",
"commands",
"to",
"their",
"specific",
"function"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/parser/limits.go#L9-L40 | train |
deis/deis | client/parser/builds.go | Builds | func Builds(argv []string) error {
usage := `
Valid commands for builds:
builds:list list build history for an application
builds:create imports an image and deploys as a new release
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "builds:list":
return buildsList(argv)
case "builds:create":
return buildsCreate(argv)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "builds" {
argv[0] = "builds:list"
return buildsList(argv)
}
PrintUsage()
return nil
}
} | go | func Builds(argv []string) error {
usage := `
Valid commands for builds:
builds:list list build history for an application
builds:create imports an image and deploys as a new release
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "builds:list":
return buildsList(argv)
case "builds:create":
return buildsCreate(argv)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "builds" {
argv[0] = "builds:list"
return buildsList(argv)
}
PrintUsage()
return nil
}
} | [
"func",
"Builds",
"(",
"argv",
"[",
"]",
"string",
")",
"error",
"{",
"usage",
":=",
"`\nValid commands for builds:\n\nbuilds:list list build history for an application\nbuilds:create imports an image and deploys as a new release\n\nUse 'deis help [command]' to learn more.\n`",
"\n\n",
"switch",
"argv",
"[",
"0",
"]",
"{",
"case",
"\"",
"\"",
":",
"return",
"buildsList",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"buildsCreate",
"(",
"argv",
")",
"\n",
"default",
":",
"if",
"printHelp",
"(",
"argv",
",",
"usage",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"argv",
"[",
"0",
"]",
"==",
"\"",
"\"",
"{",
"argv",
"[",
"0",
"]",
"=",
"\"",
"\"",
"\n",
"return",
"buildsList",
"(",
"argv",
")",
"\n",
"}",
"\n\n",
"PrintUsage",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // Builds routes build commands to their specific function. | [
"Builds",
"routes",
"build",
"commands",
"to",
"their",
"specific",
"function",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/parser/builds.go#L9-L37 | train |
deis/deis | deisctl/backend/fleet/rolling_restart.go | RollingRestart | func (c *FleetClient) RollingRestart(component string, wg *sync.WaitGroup, out, ew io.Writer) {
if component != "router" {
fmt.Fprint(ew, "invalid component. supported for: router")
return
}
components, err := c.Units(component)
if err != nil {
io.WriteString(ew, err.Error())
return
}
if len(components) < 1 {
fmt.Fprint(ew, "rolling restart requires at least 1 component")
return
}
for num := range components {
unitName := fmt.Sprintf("%s@%v", component, num+1)
c.Stop([]string{unitName}, wg, out, ew)
wg.Wait()
c.Destroy([]string{unitName}, wg, out, ew)
wg.Wait()
c.Create([]string{unitName}, wg, out, ew)
wg.Wait()
c.Start([]string{unitName}, wg, out, ew)
wg.Wait()
}
} | go | func (c *FleetClient) RollingRestart(component string, wg *sync.WaitGroup, out, ew io.Writer) {
if component != "router" {
fmt.Fprint(ew, "invalid component. supported for: router")
return
}
components, err := c.Units(component)
if err != nil {
io.WriteString(ew, err.Error())
return
}
if len(components) < 1 {
fmt.Fprint(ew, "rolling restart requires at least 1 component")
return
}
for num := range components {
unitName := fmt.Sprintf("%s@%v", component, num+1)
c.Stop([]string{unitName}, wg, out, ew)
wg.Wait()
c.Destroy([]string{unitName}, wg, out, ew)
wg.Wait()
c.Create([]string{unitName}, wg, out, ew)
wg.Wait()
c.Start([]string{unitName}, wg, out, ew)
wg.Wait()
}
} | [
"func",
"(",
"c",
"*",
"FleetClient",
")",
"RollingRestart",
"(",
"component",
"string",
",",
"wg",
"*",
"sync",
".",
"WaitGroup",
",",
"out",
",",
"ew",
"io",
".",
"Writer",
")",
"{",
"if",
"component",
"!=",
"\"",
"\"",
"{",
"fmt",
".",
"Fprint",
"(",
"ew",
",",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"components",
",",
"err",
":=",
"c",
".",
"Units",
"(",
"component",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"io",
".",
"WriteString",
"(",
"ew",
",",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"return",
"\n",
"}",
"\n",
"if",
"len",
"(",
"components",
")",
"<",
"1",
"{",
"fmt",
".",
"Fprint",
"(",
"ew",
",",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"for",
"num",
":=",
"range",
"components",
"{",
"unitName",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"component",
",",
"num",
"+",
"1",
")",
"\n\n",
"c",
".",
"Stop",
"(",
"[",
"]",
"string",
"{",
"unitName",
"}",
",",
"wg",
",",
"out",
",",
"ew",
")",
"\n",
"wg",
".",
"Wait",
"(",
")",
"\n",
"c",
".",
"Destroy",
"(",
"[",
"]",
"string",
"{",
"unitName",
"}",
",",
"wg",
",",
"out",
",",
"ew",
")",
"\n",
"wg",
".",
"Wait",
"(",
")",
"\n",
"c",
".",
"Create",
"(",
"[",
"]",
"string",
"{",
"unitName",
"}",
",",
"wg",
",",
"out",
",",
"ew",
")",
"\n",
"wg",
".",
"Wait",
"(",
")",
"\n",
"c",
".",
"Start",
"(",
"[",
"]",
"string",
"{",
"unitName",
"}",
",",
"wg",
",",
"out",
",",
"ew",
")",
"\n",
"wg",
".",
"Wait",
"(",
")",
"\n",
"}",
"\n",
"}"
] | // RollingRestart for instance units | [
"RollingRestart",
"for",
"instance",
"units"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/rolling_restart.go#L10-L37 | train |
deis/deis | deisctl/backend/fleet/unit.go | Units | func (c *FleetClient) Units(target string) (units []string, err error) {
allUnits, err := c.Fleet.Units()
if err != nil {
return
}
// Look for units starting with the given target name first. If the given
// name starts with "deis-", this will easily locate platform components,
// but we search without canonicalizing the target name FIRST so we have the
// opportunity to locate application containers (whose containers do not
// adhere to the same naming convention as the platform's own components).
for _, u := range allUnits {
if strings.HasPrefix(u.Name, target) {
units = append(units, u.Name)
}
}
// If none are found, canonicalize the target string and search again. This
// will locate platform components that were referenced by a target string
// NOT already beginning with "deis-".
if len(units) == 0 {
canonTarget := strings.ToLower(target)
if !strings.HasPrefix(canonTarget, "deis-") {
canonTarget = "deis-" + canonTarget
}
for _, u := range allUnits {
if strings.HasPrefix(u.Name, canonTarget) {
units = append(units, u.Name)
}
}
}
// If still nothing is found, then we have an error on our hands.
if len(units) == 0 {
err = fmt.Errorf("could not find unit: %s", target)
}
return
} | go | func (c *FleetClient) Units(target string) (units []string, err error) {
allUnits, err := c.Fleet.Units()
if err != nil {
return
}
// Look for units starting with the given target name first. If the given
// name starts with "deis-", this will easily locate platform components,
// but we search without canonicalizing the target name FIRST so we have the
// opportunity to locate application containers (whose containers do not
// adhere to the same naming convention as the platform's own components).
for _, u := range allUnits {
if strings.HasPrefix(u.Name, target) {
units = append(units, u.Name)
}
}
// If none are found, canonicalize the target string and search again. This
// will locate platform components that were referenced by a target string
// NOT already beginning with "deis-".
if len(units) == 0 {
canonTarget := strings.ToLower(target)
if !strings.HasPrefix(canonTarget, "deis-") {
canonTarget = "deis-" + canonTarget
}
for _, u := range allUnits {
if strings.HasPrefix(u.Name, canonTarget) {
units = append(units, u.Name)
}
}
}
// If still nothing is found, then we have an error on our hands.
if len(units) == 0 {
err = fmt.Errorf("could not find unit: %s", target)
}
return
} | [
"func",
"(",
"c",
"*",
"FleetClient",
")",
"Units",
"(",
"target",
"string",
")",
"(",
"units",
"[",
"]",
"string",
",",
"err",
"error",
")",
"{",
"allUnits",
",",
"err",
":=",
"c",
".",
"Fleet",
".",
"Units",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"// Look for units starting with the given target name first. If the given",
"// name starts with \"deis-\", this will easily locate platform components,",
"// but we search without canonicalizing the target name FIRST so we have the",
"// opportunity to locate application containers (whose containers do not",
"// adhere to the same naming convention as the platform's own components).",
"for",
"_",
",",
"u",
":=",
"range",
"allUnits",
"{",
"if",
"strings",
".",
"HasPrefix",
"(",
"u",
".",
"Name",
",",
"target",
")",
"{",
"units",
"=",
"append",
"(",
"units",
",",
"u",
".",
"Name",
")",
"\n",
"}",
"\n",
"}",
"\n",
"// If none are found, canonicalize the target string and search again. This",
"// will locate platform components that were referenced by a target string",
"// NOT already beginning with \"deis-\".",
"if",
"len",
"(",
"units",
")",
"==",
"0",
"{",
"canonTarget",
":=",
"strings",
".",
"ToLower",
"(",
"target",
")",
"\n",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"canonTarget",
",",
"\"",
"\"",
")",
"{",
"canonTarget",
"=",
"\"",
"\"",
"+",
"canonTarget",
"\n",
"}",
"\n",
"for",
"_",
",",
"u",
":=",
"range",
"allUnits",
"{",
"if",
"strings",
".",
"HasPrefix",
"(",
"u",
".",
"Name",
",",
"canonTarget",
")",
"{",
"units",
"=",
"append",
"(",
"units",
",",
"u",
".",
"Name",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"// If still nothing is found, then we have an error on our hands.",
"if",
"len",
"(",
"units",
")",
"==",
"0",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"target",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // Units returns a list of units filtered by target | [
"Units",
"returns",
"a",
"list",
"of",
"units",
"filtered",
"by",
"target"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/unit.go#L30-L64 | train |
deis/deis | deisctl/backend/fleet/unit.go | nextUnit | func (c *FleetClient) nextUnit(component string) (num int, err error) {
units, err := c.Units(component)
if err != nil {
return
}
num, err = nextUnitNum(units)
if err != nil {
return
}
return
} | go | func (c *FleetClient) nextUnit(component string) (num int, err error) {
units, err := c.Units(component)
if err != nil {
return
}
num, err = nextUnitNum(units)
if err != nil {
return
}
return
} | [
"func",
"(",
"c",
"*",
"FleetClient",
")",
"nextUnit",
"(",
"component",
"string",
")",
"(",
"num",
"int",
",",
"err",
"error",
")",
"{",
"units",
",",
"err",
":=",
"c",
".",
"Units",
"(",
"component",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"num",
",",
"err",
"=",
"nextUnitNum",
"(",
"units",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // nextUnit returns the next unit number for a given component | [
"nextUnit",
"returns",
"the",
"next",
"unit",
"number",
"for",
"a",
"given",
"component"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/unit.go#L67-L77 | train |
deis/deis | deisctl/backend/fleet/unit.go | lastUnit | func (c *FleetClient) lastUnit(component string) (num int, err error) {
units, err := c.Units(component)
if err != nil {
return
}
num, err = lastUnitNum(units)
if err != nil {
return
}
return
} | go | func (c *FleetClient) lastUnit(component string) (num int, err error) {
units, err := c.Units(component)
if err != nil {
return
}
num, err = lastUnitNum(units)
if err != nil {
return
}
return
} | [
"func",
"(",
"c",
"*",
"FleetClient",
")",
"lastUnit",
"(",
"component",
"string",
")",
"(",
"num",
"int",
",",
"err",
"error",
")",
"{",
"units",
",",
"err",
":=",
"c",
".",
"Units",
"(",
"component",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"num",
",",
"err",
"=",
"lastUnitNum",
"(",
"units",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // lastUnit returns the last unit number for a given component | [
"lastUnit",
"returns",
"the",
"last",
"unit",
"number",
"for",
"a",
"given",
"component"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/unit.go#L80-L90 | train |
deis/deis | deisctl/backend/fleet/unit.go | NewUnit | func NewUnit(component string, templatePaths []string, decorate bool) (uf *unit.UnitFile, err error) {
template, err := readTemplate(component, templatePaths)
if err != nil {
return
}
if decorate {
decorator, err := readDecorator(component)
if err != nil {
return nil, err
}
uf, err = unit.NewUnitFile(string(template) + "\n" + string(decorator))
} else {
uf, err = unit.NewUnitFile(string(template))
}
return
} | go | func NewUnit(component string, templatePaths []string, decorate bool) (uf *unit.UnitFile, err error) {
template, err := readTemplate(component, templatePaths)
if err != nil {
return
}
if decorate {
decorator, err := readDecorator(component)
if err != nil {
return nil, err
}
uf, err = unit.NewUnitFile(string(template) + "\n" + string(decorator))
} else {
uf, err = unit.NewUnitFile(string(template))
}
return
} | [
"func",
"NewUnit",
"(",
"component",
"string",
",",
"templatePaths",
"[",
"]",
"string",
",",
"decorate",
"bool",
")",
"(",
"uf",
"*",
"unit",
".",
"UnitFile",
",",
"err",
"error",
")",
"{",
"template",
",",
"err",
":=",
"readTemplate",
"(",
"component",
",",
"templatePaths",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"if",
"decorate",
"{",
"decorator",
",",
"err",
":=",
"readDecorator",
"(",
"component",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"uf",
",",
"err",
"=",
"unit",
".",
"NewUnitFile",
"(",
"string",
"(",
"template",
")",
"+",
"\"",
"\\n",
"\"",
"+",
"string",
"(",
"decorator",
")",
")",
"\n",
"}",
"else",
"{",
"uf",
",",
"err",
"=",
"unit",
".",
"NewUnitFile",
"(",
"string",
"(",
"template",
")",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // NewUnit takes a component type and returns a Fleet unit
// that includes the relevant systemd service template | [
"NewUnit",
"takes",
"a",
"component",
"type",
"and",
"returns",
"a",
"Fleet",
"unit",
"that",
"includes",
"the",
"relevant",
"systemd",
"service",
"template"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/unit.go#L94-L109 | train |
deis/deis | deisctl/backend/fleet/unit.go | formatUnitName | func formatUnitName(component string, num int) (unitName string, err error) {
component = strings.TrimPrefix(component, "deis-")
if num == 0 {
return "deis-" + component + ".service", nil
}
return "deis-" + component + "@" + strconv.Itoa(num) + ".service", nil
} | go | func formatUnitName(component string, num int) (unitName string, err error) {
component = strings.TrimPrefix(component, "deis-")
if num == 0 {
return "deis-" + component + ".service", nil
}
return "deis-" + component + "@" + strconv.Itoa(num) + ".service", nil
} | [
"func",
"formatUnitName",
"(",
"component",
"string",
",",
"num",
"int",
")",
"(",
"unitName",
"string",
",",
"err",
"error",
")",
"{",
"component",
"=",
"strings",
".",
"TrimPrefix",
"(",
"component",
",",
"\"",
"\"",
")",
"\n",
"if",
"num",
"==",
"0",
"{",
"return",
"\"",
"\"",
"+",
"component",
"+",
"\"",
"\"",
",",
"nil",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"+",
"component",
"+",
"\"",
"\"",
"+",
"strconv",
".",
"Itoa",
"(",
"num",
")",
"+",
"\"",
"\"",
",",
"nil",
"\n",
"}"
] | // formatUnitName returns a properly formatted systemd service name
// using the given component type and number | [
"formatUnitName",
"returns",
"a",
"properly",
"formatted",
"systemd",
"service",
"name",
"using",
"the",
"given",
"component",
"type",
"and",
"number"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/unit.go#L113-L119 | train |
deis/deis | deisctl/backend/fleet/unit.go | readTemplate | func readTemplate(component string, templatePaths []string) (out []byte, err error) {
templateName := "deis-" + component + ".service"
var templateFile string
// look in $DEISCTL_UNITS env var, then the local and global root paths
for _, p := range templatePaths {
if p == "" {
continue
}
filename := path.Join(p, templateName)
if _, err := os.Stat(filename); err == nil {
templateFile = filename
break
}
}
if templateFile == "" {
return nil, fmt.Errorf("Could not find unit template for %v", component)
}
out, err = ioutil.ReadFile(templateFile)
if err != nil {
return
}
return
} | go | func readTemplate(component string, templatePaths []string) (out []byte, err error) {
templateName := "deis-" + component + ".service"
var templateFile string
// look in $DEISCTL_UNITS env var, then the local and global root paths
for _, p := range templatePaths {
if p == "" {
continue
}
filename := path.Join(p, templateName)
if _, err := os.Stat(filename); err == nil {
templateFile = filename
break
}
}
if templateFile == "" {
return nil, fmt.Errorf("Could not find unit template for %v", component)
}
out, err = ioutil.ReadFile(templateFile)
if err != nil {
return
}
return
} | [
"func",
"readTemplate",
"(",
"component",
"string",
",",
"templatePaths",
"[",
"]",
"string",
")",
"(",
"out",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"templateName",
":=",
"\"",
"\"",
"+",
"component",
"+",
"\"",
"\"",
"\n",
"var",
"templateFile",
"string",
"\n\n",
"// look in $DEISCTL_UNITS env var, then the local and global root paths",
"for",
"_",
",",
"p",
":=",
"range",
"templatePaths",
"{",
"if",
"p",
"==",
"\"",
"\"",
"{",
"continue",
"\n",
"}",
"\n",
"filename",
":=",
"path",
".",
"Join",
"(",
"p",
",",
"templateName",
")",
"\n",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"filename",
")",
";",
"err",
"==",
"nil",
"{",
"templateFile",
"=",
"filename",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"templateFile",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"component",
")",
"\n",
"}",
"\n",
"out",
",",
"err",
"=",
"ioutil",
".",
"ReadFile",
"(",
"templateFile",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // readTemplate returns the contents of a systemd template for the given component | [
"readTemplate",
"returns",
"the",
"contents",
"of",
"a",
"systemd",
"template",
"for",
"the",
"given",
"component"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/unit.go#L122-L146 | train |
deis/deis | deisctl/backend/fleet/unit.go | readDecorator | func readDecorator(component string) (out []byte, err error) {
decoratorName := "deis-" + component + ".service.decorator"
var decoratorFile string
// look in $DEISCTL_UNITS env var, then the local and global root paths
for _, p := range decoratorPaths {
filename := path.Join(p, decoratorName)
if _, err := os.Stat(filename); err == nil {
decoratorFile = filename
break
}
}
if decoratorFile == "" {
return
}
out, err = ioutil.ReadFile(decoratorFile)
return
} | go | func readDecorator(component string) (out []byte, err error) {
decoratorName := "deis-" + component + ".service.decorator"
var decoratorFile string
// look in $DEISCTL_UNITS env var, then the local and global root paths
for _, p := range decoratorPaths {
filename := path.Join(p, decoratorName)
if _, err := os.Stat(filename); err == nil {
decoratorFile = filename
break
}
}
if decoratorFile == "" {
return
}
out, err = ioutil.ReadFile(decoratorFile)
return
} | [
"func",
"readDecorator",
"(",
"component",
"string",
")",
"(",
"out",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"decoratorName",
":=",
"\"",
"\"",
"+",
"component",
"+",
"\"",
"\"",
"\n",
"var",
"decoratorFile",
"string",
"\n\n",
"// look in $DEISCTL_UNITS env var, then the local and global root paths",
"for",
"_",
",",
"p",
":=",
"range",
"decoratorPaths",
"{",
"filename",
":=",
"path",
".",
"Join",
"(",
"p",
",",
"decoratorName",
")",
"\n",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"filename",
")",
";",
"err",
"==",
"nil",
"{",
"decoratorFile",
"=",
"filename",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"decoratorFile",
"==",
"\"",
"\"",
"{",
"return",
"\n",
"}",
"\n",
"out",
",",
"err",
"=",
"ioutil",
".",
"ReadFile",
"(",
"decoratorFile",
")",
"\n",
"return",
"\n",
"}"
] | // readDecorator returns the contents of a file containing a snippet that can
// optionally be grafted on to the end of a corresponding systemd unit to
// achieve isolation of the control plane, data plane, and router mesh | [
"readDecorator",
"returns",
"the",
"contents",
"of",
"a",
"file",
"containing",
"a",
"snippet",
"that",
"can",
"optionally",
"be",
"grafted",
"on",
"to",
"the",
"end",
"of",
"a",
"corresponding",
"systemd",
"unit",
"to",
"achieve",
"isolation",
"of",
"the",
"control",
"plane",
"data",
"plane",
"and",
"router",
"mesh"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/unit.go#L151-L169 | train |
deis/deis | logger/storage/ringbuffer/adapter.go | NewStorageAdapter | func NewStorageAdapter(bufferSize int) (*adapter, error) {
if bufferSize <= 0 {
return nil, fmt.Errorf("Invalid ringBuffer size: %d", bufferSize)
}
return &adapter{bufferSize: bufferSize, ringBuffers: make(map[string]*ringBuffer)}, nil
} | go | func NewStorageAdapter(bufferSize int) (*adapter, error) {
if bufferSize <= 0 {
return nil, fmt.Errorf("Invalid ringBuffer size: %d", bufferSize)
}
return &adapter{bufferSize: bufferSize, ringBuffers: make(map[string]*ringBuffer)}, nil
} | [
"func",
"NewStorageAdapter",
"(",
"bufferSize",
"int",
")",
"(",
"*",
"adapter",
",",
"error",
")",
"{",
"if",
"bufferSize",
"<=",
"0",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"bufferSize",
")",
"\n",
"}",
"\n",
"return",
"&",
"adapter",
"{",
"bufferSize",
":",
"bufferSize",
",",
"ringBuffers",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"ringBuffer",
")",
"}",
",",
"nil",
"\n",
"}"
] | // NewStorageAdapter returns a pointer to a new instance of an in-memory storage.Adapter. | [
"NewStorageAdapter",
"returns",
"a",
"pointer",
"to",
"a",
"new",
"instance",
"of",
"an",
"in",
"-",
"memory",
"storage",
".",
"Adapter",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/storage/ringbuffer/adapter.go#L58-L63 | train |
deis/deis | logger/storage/ringbuffer/adapter.go | Write | func (a *adapter) Write(app string, message string) error {
// Check first if we might actually have to add to the map of ringBuffer pointers so we can avoid
// waiting for / obtaining a lock unnecessarily
rb, ok := a.ringBuffers[app]
if !ok {
// Ensure only one goroutine at a time can be adding a ringBuffer to the map of ringBuffers
// pointers
a.mutex.Lock()
defer a.mutex.Unlock()
rb, ok = a.ringBuffers[app]
if !ok {
rb = newRingBuffer(a.bufferSize)
a.ringBuffers[app] = rb
}
}
rb.write(message)
return nil
} | go | func (a *adapter) Write(app string, message string) error {
// Check first if we might actually have to add to the map of ringBuffer pointers so we can avoid
// waiting for / obtaining a lock unnecessarily
rb, ok := a.ringBuffers[app]
if !ok {
// Ensure only one goroutine at a time can be adding a ringBuffer to the map of ringBuffers
// pointers
a.mutex.Lock()
defer a.mutex.Unlock()
rb, ok = a.ringBuffers[app]
if !ok {
rb = newRingBuffer(a.bufferSize)
a.ringBuffers[app] = rb
}
}
rb.write(message)
return nil
} | [
"func",
"(",
"a",
"*",
"adapter",
")",
"Write",
"(",
"app",
"string",
",",
"message",
"string",
")",
"error",
"{",
"// Check first if we might actually have to add to the map of ringBuffer pointers so we can avoid",
"// waiting for / obtaining a lock unnecessarily",
"rb",
",",
"ok",
":=",
"a",
".",
"ringBuffers",
"[",
"app",
"]",
"\n",
"if",
"!",
"ok",
"{",
"// Ensure only one goroutine at a time can be adding a ringBuffer to the map of ringBuffers",
"// pointers",
"a",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"a",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"rb",
",",
"ok",
"=",
"a",
".",
"ringBuffers",
"[",
"app",
"]",
"\n",
"if",
"!",
"ok",
"{",
"rb",
"=",
"newRingBuffer",
"(",
"a",
".",
"bufferSize",
")",
"\n",
"a",
".",
"ringBuffers",
"[",
"app",
"]",
"=",
"rb",
"\n",
"}",
"\n",
"}",
"\n",
"rb",
".",
"write",
"(",
"message",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // Write adds a log message to to an app-specific ringBuffer | [
"Write",
"adds",
"a",
"log",
"message",
"to",
"to",
"an",
"app",
"-",
"specific",
"ringBuffer"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/storage/ringbuffer/adapter.go#L66-L83 | train |
deis/deis | logger/storage/ringbuffer/adapter.go | Read | func (a *adapter) Read(app string, lines int) ([]string, error) {
rb, ok := a.ringBuffers[app]
if ok {
return rb.read(lines), nil
}
return nil, fmt.Errorf("Could not find logs for '%s'", app)
} | go | func (a *adapter) Read(app string, lines int) ([]string, error) {
rb, ok := a.ringBuffers[app]
if ok {
return rb.read(lines), nil
}
return nil, fmt.Errorf("Could not find logs for '%s'", app)
} | [
"func",
"(",
"a",
"*",
"adapter",
")",
"Read",
"(",
"app",
"string",
",",
"lines",
"int",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"rb",
",",
"ok",
":=",
"a",
".",
"ringBuffers",
"[",
"app",
"]",
"\n",
"if",
"ok",
"{",
"return",
"rb",
".",
"read",
"(",
"lines",
")",
",",
"nil",
"\n",
"}",
"\n",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"app",
")",
"\n",
"}"
] | // Read retrieves a specified number of log lines from an app-specific ringBuffer | [
"Read",
"retrieves",
"a",
"specified",
"number",
"of",
"log",
"lines",
"from",
"an",
"app",
"-",
"specific",
"ringBuffer"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/storage/ringbuffer/adapter.go#L86-L92 | train |
deis/deis | client/parser/config.go | Config | func Config(argv []string) error {
usage := `
Valid commands for config:
config:list list environment variables for an app
config:set set environment variables for an app
config:unset unset environment variables for an app
config:pull extract environment variables to .env
config:push set environment variables from .env
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "config:list":
return configList(argv)
case "config:set":
return configSet(argv)
case "config:unset":
return configUnset(argv)
case "config:pull":
return configPull(argv)
case "config:push":
return configPush(argv)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "config" {
argv[0] = "config:list"
return configList(argv)
}
PrintUsage()
return nil
}
} | go | func Config(argv []string) error {
usage := `
Valid commands for config:
config:list list environment variables for an app
config:set set environment variables for an app
config:unset unset environment variables for an app
config:pull extract environment variables to .env
config:push set environment variables from .env
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "config:list":
return configList(argv)
case "config:set":
return configSet(argv)
case "config:unset":
return configUnset(argv)
case "config:pull":
return configPull(argv)
case "config:push":
return configPush(argv)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "config" {
argv[0] = "config:list"
return configList(argv)
}
PrintUsage()
return nil
}
} | [
"func",
"Config",
"(",
"argv",
"[",
"]",
"string",
")",
"error",
"{",
"usage",
":=",
"`\nValid commands for config:\n\nconfig:list list environment variables for an app\nconfig:set set environment variables for an app\nconfig:unset unset environment variables for an app\nconfig:pull extract environment variables to .env\nconfig:push set environment variables from .env\n\nUse 'deis help [command]' to learn more.\n`",
"\n\n",
"switch",
"argv",
"[",
"0",
"]",
"{",
"case",
"\"",
"\"",
":",
"return",
"configList",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"configSet",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"configUnset",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"configPull",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"configPush",
"(",
"argv",
")",
"\n",
"default",
":",
"if",
"printHelp",
"(",
"argv",
",",
"usage",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"argv",
"[",
"0",
"]",
"==",
"\"",
"\"",
"{",
"argv",
"[",
"0",
"]",
"=",
"\"",
"\"",
"\n",
"return",
"configList",
"(",
"argv",
")",
"\n",
"}",
"\n\n",
"PrintUsage",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // Config routes config commands to their specific function. | [
"Config",
"routes",
"config",
"commands",
"to",
"their",
"specific",
"function",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/parser/config.go#L9-L46 | train |
deis/deis | Godeps/_workspace/src/gopkg.in/tomb.v1/tomb.go | Wait | func (t *Tomb) Wait() error {
t.init()
<-t.dead
t.m.Lock()
reason := t.reason
t.m.Unlock()
return reason
} | go | func (t *Tomb) Wait() error {
t.init()
<-t.dead
t.m.Lock()
reason := t.reason
t.m.Unlock()
return reason
} | [
"func",
"(",
"t",
"*",
"Tomb",
")",
"Wait",
"(",
")",
"error",
"{",
"t",
".",
"init",
"(",
")",
"\n",
"<-",
"t",
".",
"dead",
"\n",
"t",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"reason",
":=",
"t",
".",
"reason",
"\n",
"t",
".",
"m",
".",
"Unlock",
"(",
")",
"\n",
"return",
"reason",
"\n",
"}"
] | // Wait blocks until the goroutine is in a dead state and returns the
// reason for its death. | [
"Wait",
"blocks",
"until",
"the",
"goroutine",
"is",
"in",
"a",
"dead",
"state",
"and",
"returns",
"the",
"reason",
"for",
"its",
"death",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/Godeps/_workspace/src/gopkg.in/tomb.v1/tomb.go#L111-L118 | train |
deis/deis | Godeps/_workspace/src/gopkg.in/tomb.v1/tomb.go | Kill | func (t *Tomb) Kill(reason error) {
t.init()
t.m.Lock()
defer t.m.Unlock()
if reason == ErrDying {
if t.reason == ErrStillAlive {
panic("tomb: Kill with ErrDying while still alive")
}
return
}
if t.reason == nil || t.reason == ErrStillAlive {
t.reason = reason
}
// If the receive on t.dying succeeds, then
// it can only be because we have already closed it.
// If it blocks, then we know that it needs to be closed.
select {
case <-t.dying:
default:
close(t.dying)
}
} | go | func (t *Tomb) Kill(reason error) {
t.init()
t.m.Lock()
defer t.m.Unlock()
if reason == ErrDying {
if t.reason == ErrStillAlive {
panic("tomb: Kill with ErrDying while still alive")
}
return
}
if t.reason == nil || t.reason == ErrStillAlive {
t.reason = reason
}
// If the receive on t.dying succeeds, then
// it can only be because we have already closed it.
// If it blocks, then we know that it needs to be closed.
select {
case <-t.dying:
default:
close(t.dying)
}
} | [
"func",
"(",
"t",
"*",
"Tomb",
")",
"Kill",
"(",
"reason",
"error",
")",
"{",
"t",
".",
"init",
"(",
")",
"\n",
"t",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"t",
".",
"m",
".",
"Unlock",
"(",
")",
"\n",
"if",
"reason",
"==",
"ErrDying",
"{",
"if",
"t",
".",
"reason",
"==",
"ErrStillAlive",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}",
"\n",
"if",
"t",
".",
"reason",
"==",
"nil",
"||",
"t",
".",
"reason",
"==",
"ErrStillAlive",
"{",
"t",
".",
"reason",
"=",
"reason",
"\n",
"}",
"\n",
"// If the receive on t.dying succeeds, then",
"// it can only be because we have already closed it.",
"// If it blocks, then we know that it needs to be closed.",
"select",
"{",
"case",
"<-",
"t",
".",
"dying",
":",
"default",
":",
"close",
"(",
"t",
".",
"dying",
")",
"\n",
"}",
"\n",
"}"
] | // Kill flags the goroutine as dying for the given reason.
// Kill may be called multiple times, but only the first
// non-nil error is recorded as the reason for termination.
//
// If reason is ErrDying, the previous reason isn't replaced
// even if it is nil. It's a runtime error to call Kill with
// ErrDying if t is not in a dying state. | [
"Kill",
"flags",
"the",
"goroutine",
"as",
"dying",
"for",
"the",
"given",
"reason",
".",
"Kill",
"may",
"be",
"called",
"multiple",
"times",
"but",
"only",
"the",
"first",
"non",
"-",
"nil",
"error",
"is",
"recorded",
"as",
"the",
"reason",
"for",
"termination",
".",
"If",
"reason",
"is",
"ErrDying",
"the",
"previous",
"reason",
"isn",
"t",
"replaced",
"even",
"if",
"it",
"is",
"nil",
".",
"It",
"s",
"a",
"runtime",
"error",
"to",
"call",
"Kill",
"with",
"ErrDying",
"if",
"t",
"is",
"not",
"in",
"a",
"dying",
"state",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/Godeps/_workspace/src/gopkg.in/tomb.v1/tomb.go#L137-L158 | train |
deis/deis | Godeps/_workspace/src/gopkg.in/tomb.v1/tomb.go | Killf | func (t *Tomb) Killf(f string, a ...interface{}) error {
err := fmt.Errorf(f, a...)
t.Kill(err)
return err
} | go | func (t *Tomb) Killf(f string, a ...interface{}) error {
err := fmt.Errorf(f, a...)
t.Kill(err)
return err
} | [
"func",
"(",
"t",
"*",
"Tomb",
")",
"Killf",
"(",
"f",
"string",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"err",
":=",
"fmt",
".",
"Errorf",
"(",
"f",
",",
"a",
"...",
")",
"\n",
"t",
".",
"Kill",
"(",
"err",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Killf works like Kill, but builds the reason providing the received
// arguments to fmt.Errorf. The generated error is also returned. | [
"Killf",
"works",
"like",
"Kill",
"but",
"builds",
"the",
"reason",
"providing",
"the",
"received",
"arguments",
"to",
"fmt",
".",
"Errorf",
".",
"The",
"generated",
"error",
"is",
"also",
"returned",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/Godeps/_workspace/src/gopkg.in/tomb.v1/tomb.go#L162-L166 | train |
deis/deis | Godeps/_workspace/src/gopkg.in/tomb.v1/tomb.go | Err | func (t *Tomb) Err() (reason error) {
t.init()
t.m.Lock()
reason = t.reason
t.m.Unlock()
return
} | go | func (t *Tomb) Err() (reason error) {
t.init()
t.m.Lock()
reason = t.reason
t.m.Unlock()
return
} | [
"func",
"(",
"t",
"*",
"Tomb",
")",
"Err",
"(",
")",
"(",
"reason",
"error",
")",
"{",
"t",
".",
"init",
"(",
")",
"\n",
"t",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"reason",
"=",
"t",
".",
"reason",
"\n",
"t",
".",
"m",
".",
"Unlock",
"(",
")",
"\n",
"return",
"\n",
"}"
] | // Err returns the reason for the goroutine death provided via Kill
// or Killf, or ErrStillAlive when the goroutine is still alive. | [
"Err",
"returns",
"the",
"reason",
"for",
"the",
"goroutine",
"death",
"provided",
"via",
"Kill",
"or",
"Killf",
"or",
"ErrStillAlive",
"when",
"the",
"goroutine",
"is",
"still",
"alive",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/Godeps/_workspace/src/gopkg.in/tomb.v1/tomb.go#L170-L176 | train |
deis/deis | client/cmd/builds.go | BuildsList | func BuildsList(appID string, results int) error {
c, appID, err := load(appID)
if err != nil {
return err
}
if results == defaultLimit {
results = c.ResponseLimit
}
builds, count, err := builds.List(c, appID, results)
if err != nil {
return err
}
fmt.Printf("=== %s Builds%s", appID, limitCount(len(builds), count))
for _, build := range builds {
fmt.Println(build.UUID, build.Created)
}
return nil
} | go | func BuildsList(appID string, results int) error {
c, appID, err := load(appID)
if err != nil {
return err
}
if results == defaultLimit {
results = c.ResponseLimit
}
builds, count, err := builds.List(c, appID, results)
if err != nil {
return err
}
fmt.Printf("=== %s Builds%s", appID, limitCount(len(builds), count))
for _, build := range builds {
fmt.Println(build.UUID, build.Created)
}
return nil
} | [
"func",
"BuildsList",
"(",
"appID",
"string",
",",
"results",
"int",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"load",
"(",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"results",
"==",
"defaultLimit",
"{",
"results",
"=",
"c",
".",
"ResponseLimit",
"\n",
"}",
"\n\n",
"builds",
",",
"count",
",",
"err",
":=",
"builds",
".",
"List",
"(",
"c",
",",
"appID",
",",
"results",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"appID",
",",
"limitCount",
"(",
"len",
"(",
"builds",
")",
",",
"count",
")",
")",
"\n\n",
"for",
"_",
",",
"build",
":=",
"range",
"builds",
"{",
"fmt",
".",
"Println",
"(",
"build",
".",
"UUID",
",",
"build",
".",
"Created",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // BuildsList lists an app's builds. | [
"BuildsList",
"lists",
"an",
"app",
"s",
"builds",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/builds.go#L14-L37 | train |
deis/deis | client/cmd/builds.go | BuildsCreate | func BuildsCreate(appID, image, procfile string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
procfileMap := make(map[string]string)
if procfile != "" {
if procfileMap, err = parseProcfile([]byte(procfile)); err != nil {
return err
}
} else if _, err := os.Stat("Procfile"); err == nil {
contents, err := ioutil.ReadFile("Procfile")
if err != nil {
return err
}
if procfileMap, err = parseProcfile(contents); err != nil {
return err
}
}
fmt.Print("Creating build... ")
quit := progress()
_, err = builds.New(c, appID, image, procfileMap)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Println("done")
return nil
} | go | func BuildsCreate(appID, image, procfile string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
procfileMap := make(map[string]string)
if procfile != "" {
if procfileMap, err = parseProcfile([]byte(procfile)); err != nil {
return err
}
} else if _, err := os.Stat("Procfile"); err == nil {
contents, err := ioutil.ReadFile("Procfile")
if err != nil {
return err
}
if procfileMap, err = parseProcfile(contents); err != nil {
return err
}
}
fmt.Print("Creating build... ")
quit := progress()
_, err = builds.New(c, appID, image, procfileMap)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Println("done")
return nil
} | [
"func",
"BuildsCreate",
"(",
"appID",
",",
"image",
",",
"procfile",
"string",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"load",
"(",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"procfileMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n\n",
"if",
"procfile",
"!=",
"\"",
"\"",
"{",
"if",
"procfileMap",
",",
"err",
"=",
"parseProcfile",
"(",
"[",
"]",
"byte",
"(",
"procfile",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"else",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"\"",
"\"",
")",
";",
"err",
"==",
"nil",
"{",
"contents",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"procfileMap",
",",
"err",
"=",
"parseProcfile",
"(",
"contents",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"fmt",
".",
"Print",
"(",
"\"",
"\"",
")",
"\n",
"quit",
":=",
"progress",
"(",
")",
"\n",
"_",
",",
"err",
"=",
"builds",
".",
"New",
"(",
"c",
",",
"appID",
",",
"image",
",",
"procfileMap",
")",
"\n",
"quit",
"<-",
"true",
"\n",
"<-",
"quit",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // BuildsCreate creates a build for an app. | [
"BuildsCreate",
"creates",
"a",
"build",
"for",
"an",
"app",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/builds.go#L40-L77 | train |
deis/deis | client/cmd/apps.go | AppCreate | func AppCreate(id string, buildpack string, remote string, noRemote bool) error {
c, err := client.New()
if err != nil {
return err
}
fmt.Print("Creating Application... ")
quit := progress()
app, err := apps.New(c, id)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Printf("done, created %s\n", app.ID)
if buildpack != "" {
configValues := api.Config{
Values: map[string]interface{}{
"BUILDPACK_URL": buildpack,
},
}
if _, err = config.Set(c, app.ID, configValues); err != nil {
return err
}
}
if !noRemote {
if err = git.CreateRemote(c.ControllerURL.Host, remote, app.ID); err != nil {
if err.Error() == "exit status 128" {
fmt.Println("To replace the existing git remote entry, run:")
fmt.Printf(" git remote rename deis deis.old && deis git:remote -a %s\n", app.ID)
}
return err
}
}
fmt.Println("remote available at", git.RemoteURL(c.ControllerURL.Host, app.ID))
return nil
} | go | func AppCreate(id string, buildpack string, remote string, noRemote bool) error {
c, err := client.New()
if err != nil {
return err
}
fmt.Print("Creating Application... ")
quit := progress()
app, err := apps.New(c, id)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Printf("done, created %s\n", app.ID)
if buildpack != "" {
configValues := api.Config{
Values: map[string]interface{}{
"BUILDPACK_URL": buildpack,
},
}
if _, err = config.Set(c, app.ID, configValues); err != nil {
return err
}
}
if !noRemote {
if err = git.CreateRemote(c.ControllerURL.Host, remote, app.ID); err != nil {
if err.Error() == "exit status 128" {
fmt.Println("To replace the existing git remote entry, run:")
fmt.Printf(" git remote rename deis deis.old && deis git:remote -a %s\n", app.ID)
}
return err
}
}
fmt.Println("remote available at", git.RemoteURL(c.ControllerURL.Host, app.ID))
return nil
} | [
"func",
"AppCreate",
"(",
"id",
"string",
",",
"buildpack",
"string",
",",
"remote",
"string",
",",
"noRemote",
"bool",
")",
"error",
"{",
"c",
",",
"err",
":=",
"client",
".",
"New",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Print",
"(",
"\"",
"\"",
")",
"\n",
"quit",
":=",
"progress",
"(",
")",
"\n",
"app",
",",
"err",
":=",
"apps",
".",
"New",
"(",
"c",
",",
"id",
")",
"\n\n",
"quit",
"<-",
"true",
"\n",
"<-",
"quit",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"app",
".",
"ID",
")",
"\n\n",
"if",
"buildpack",
"!=",
"\"",
"\"",
"{",
"configValues",
":=",
"api",
".",
"Config",
"{",
"Values",
":",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"buildpack",
",",
"}",
",",
"}",
"\n",
"if",
"_",
",",
"err",
"=",
"config",
".",
"Set",
"(",
"c",
",",
"app",
".",
"ID",
",",
"configValues",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"!",
"noRemote",
"{",
"if",
"err",
"=",
"git",
".",
"CreateRemote",
"(",
"c",
".",
"ControllerURL",
".",
"Host",
",",
"remote",
",",
"app",
".",
"ID",
")",
";",
"err",
"!=",
"nil",
"{",
"if",
"err",
".",
"Error",
"(",
")",
"==",
"\"",
"\"",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"app",
".",
"ID",
")",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"git",
".",
"RemoteURL",
"(",
"c",
".",
"ControllerURL",
".",
"Host",
",",
"app",
".",
"ID",
")",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // AppCreate creates an app. | [
"AppCreate",
"creates",
"an",
"app",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/apps.go#L21-L64 | train |
deis/deis | client/cmd/apps.go | AppsList | func AppsList(results int) error {
c, err := client.New()
if err != nil {
return err
}
if results == defaultLimit {
results = c.ResponseLimit
}
apps, count, err := apps.List(c, results)
if err != nil {
return err
}
fmt.Printf("=== Apps%s", limitCount(len(apps), count))
sort.Sort(apps)
for _, app := range apps {
fmt.Println(app.ID)
}
return nil
} | go | func AppsList(results int) error {
c, err := client.New()
if err != nil {
return err
}
if results == defaultLimit {
results = c.ResponseLimit
}
apps, count, err := apps.List(c, results)
if err != nil {
return err
}
fmt.Printf("=== Apps%s", limitCount(len(apps), count))
sort.Sort(apps)
for _, app := range apps {
fmt.Println(app.ID)
}
return nil
} | [
"func",
"AppsList",
"(",
"results",
"int",
")",
"error",
"{",
"c",
",",
"err",
":=",
"client",
".",
"New",
"(",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"results",
"==",
"defaultLimit",
"{",
"results",
"=",
"c",
".",
"ResponseLimit",
"\n",
"}",
"\n\n",
"apps",
",",
"count",
",",
"err",
":=",
"apps",
".",
"List",
"(",
"c",
",",
"results",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"limitCount",
"(",
"len",
"(",
"apps",
")",
",",
"count",
")",
")",
"\n\n",
"sort",
".",
"Sort",
"(",
"apps",
")",
"\n",
"for",
"_",
",",
"app",
":=",
"range",
"apps",
"{",
"fmt",
".",
"Println",
"(",
"app",
".",
"ID",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // AppsList lists apps on the Deis controller. | [
"AppsList",
"lists",
"apps",
"on",
"the",
"Deis",
"controller",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/apps.go#L67-L91 | train |
deis/deis | client/cmd/apps.go | AppInfo | func AppInfo(appID string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
app, err := apps.Get(c, appID)
if err != nil {
return err
}
fmt.Printf("=== %s Application\n", app.ID)
fmt.Println("updated: ", app.Updated)
fmt.Println("uuid: ", app.UUID)
fmt.Println("created: ", app.Created)
fmt.Println("url: ", app.URL)
fmt.Println("owner: ", app.Owner)
fmt.Println("id: ", app.ID)
fmt.Println()
// print the app processes
if err = PsList(app.ID, defaultLimit); err != nil {
return err
}
fmt.Println()
// print the app domains
if err = DomainsList(app.ID, defaultLimit); err != nil {
return err
}
fmt.Println()
return nil
} | go | func AppInfo(appID string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
app, err := apps.Get(c, appID)
if err != nil {
return err
}
fmt.Printf("=== %s Application\n", app.ID)
fmt.Println("updated: ", app.Updated)
fmt.Println("uuid: ", app.UUID)
fmt.Println("created: ", app.Created)
fmt.Println("url: ", app.URL)
fmt.Println("owner: ", app.Owner)
fmt.Println("id: ", app.ID)
fmt.Println()
// print the app processes
if err = PsList(app.ID, defaultLimit); err != nil {
return err
}
fmt.Println()
// print the app domains
if err = DomainsList(app.ID, defaultLimit); err != nil {
return err
}
fmt.Println()
return nil
} | [
"func",
"AppInfo",
"(",
"appID",
"string",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"load",
"(",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"app",
",",
"err",
":=",
"apps",
".",
"Get",
"(",
"c",
",",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"app",
".",
"ID",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"app",
".",
"Updated",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"app",
".",
"UUID",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"app",
".",
"Created",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"app",
".",
"URL",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"app",
".",
"Owner",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"app",
".",
"ID",
")",
"\n\n",
"fmt",
".",
"Println",
"(",
")",
"\n",
"// print the app processes",
"if",
"err",
"=",
"PsList",
"(",
"app",
".",
"ID",
",",
"defaultLimit",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Println",
"(",
")",
"\n",
"// print the app domains",
"if",
"err",
"=",
"DomainsList",
"(",
"app",
".",
"ID",
",",
"defaultLimit",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Println",
"(",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // AppInfo prints info about app. | [
"AppInfo",
"prints",
"info",
"about",
"app",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/apps.go#L94-L130 | train |
deis/deis | client/cmd/apps.go | AppOpen | func AppOpen(appID string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
app, err := apps.Get(c, appID)
if err != nil {
return err
}
u := app.URL
if !(strings.HasPrefix(u, "http://") || strings.HasPrefix(u, "https://")) {
u = "http://" + u
}
return webbrowser.Webbrowser(u)
} | go | func AppOpen(appID string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
app, err := apps.Get(c, appID)
if err != nil {
return err
}
u := app.URL
if !(strings.HasPrefix(u, "http://") || strings.HasPrefix(u, "https://")) {
u = "http://" + u
}
return webbrowser.Webbrowser(u)
} | [
"func",
"AppOpen",
"(",
"appID",
"string",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"load",
"(",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"app",
",",
"err",
":=",
"apps",
".",
"Get",
"(",
"c",
",",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"u",
":=",
"app",
".",
"URL",
"\n",
"if",
"!",
"(",
"strings",
".",
"HasPrefix",
"(",
"u",
",",
"\"",
"\"",
")",
"||",
"strings",
".",
"HasPrefix",
"(",
"u",
",",
"\"",
"\"",
")",
")",
"{",
"u",
"=",
"\"",
"\"",
"+",
"u",
"\n",
"}",
"\n\n",
"return",
"webbrowser",
".",
"Webbrowser",
"(",
"u",
")",
"\n",
"}"
] | // AppOpen opens an app in the default webbrowser. | [
"AppOpen",
"opens",
"an",
"app",
"in",
"the",
"default",
"webbrowser",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/apps.go#L133-L152 | train |
deis/deis | client/cmd/apps.go | AppLogs | func AppLogs(appID string, lines int) error {
c, appID, err := load(appID)
if err != nil {
return err
}
logs, err := apps.Logs(c, appID, lines)
if err != nil {
return err
}
return printLogs(logs)
} | go | func AppLogs(appID string, lines int) error {
c, appID, err := load(appID)
if err != nil {
return err
}
logs, err := apps.Logs(c, appID, lines)
if err != nil {
return err
}
return printLogs(logs)
} | [
"func",
"AppLogs",
"(",
"appID",
"string",
",",
"lines",
"int",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"load",
"(",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"logs",
",",
"err",
":=",
"apps",
".",
"Logs",
"(",
"c",
",",
"appID",
",",
"lines",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"printLogs",
"(",
"logs",
")",
"\n",
"}"
] | // AppLogs returns the logs from an app. | [
"AppLogs",
"returns",
"the",
"logs",
"from",
"an",
"app",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/apps.go#L155-L169 | train |
deis/deis | client/cmd/apps.go | printLogs | func printLogs(logs string) error {
for _, log := range strings.Split(logs, "\n") {
category := "unknown"
parts := strings.Split(strings.Split(log, ": ")[0], " ")
if len(parts) >= 2 {
category = parts[1]
}
colorVars := map[string]string{
"Color": chooseColor(category),
"Log": log,
}
fmt.Println(prettyprint.ColorizeVars("{{.V.Color}}{{.V.Log}}{{.C.Default}}", colorVars))
}
return nil
} | go | func printLogs(logs string) error {
for _, log := range strings.Split(logs, "\n") {
category := "unknown"
parts := strings.Split(strings.Split(log, ": ")[0], " ")
if len(parts) >= 2 {
category = parts[1]
}
colorVars := map[string]string{
"Color": chooseColor(category),
"Log": log,
}
fmt.Println(prettyprint.ColorizeVars("{{.V.Color}}{{.V.Log}}{{.C.Default}}", colorVars))
}
return nil
} | [
"func",
"printLogs",
"(",
"logs",
"string",
")",
"error",
"{",
"for",
"_",
",",
"log",
":=",
"range",
"strings",
".",
"Split",
"(",
"logs",
",",
"\"",
"\\n",
"\"",
")",
"{",
"category",
":=",
"\"",
"\"",
"\n",
"parts",
":=",
"strings",
".",
"Split",
"(",
"strings",
".",
"Split",
"(",
"log",
",",
"\"",
"\"",
")",
"[",
"0",
"]",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"parts",
")",
">=",
"2",
"{",
"category",
"=",
"parts",
"[",
"1",
"]",
"\n",
"}",
"\n",
"colorVars",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"chooseColor",
"(",
"category",
")",
",",
"\"",
"\"",
":",
"log",
",",
"}",
"\n",
"fmt",
".",
"Println",
"(",
"prettyprint",
".",
"ColorizeVars",
"(",
"\"",
"\"",
",",
"colorVars",
")",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // printLogs prints each log line with a color matched to its category. | [
"printLogs",
"prints",
"each",
"log",
"line",
"with",
"a",
"color",
"matched",
"to",
"its",
"category",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/apps.go#L172-L187 | train |
deis/deis | client/cmd/apps.go | AppRun | func AppRun(appID, command string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
fmt.Printf("Running '%s'...\n", command)
out, err := apps.Run(c, appID, command)
if err != nil {
return err
}
fmt.Print(out.Output)
os.Exit(out.ReturnCode)
return nil
} | go | func AppRun(appID, command string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
fmt.Printf("Running '%s'...\n", command)
out, err := apps.Run(c, appID, command)
if err != nil {
return err
}
fmt.Print(out.Output)
os.Exit(out.ReturnCode)
return nil
} | [
"func",
"AppRun",
"(",
"appID",
",",
"command",
"string",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"load",
"(",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"command",
")",
"\n\n",
"out",
",",
"err",
":=",
"apps",
".",
"Run",
"(",
"c",
",",
"appID",
",",
"command",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Print",
"(",
"out",
".",
"Output",
")",
"\n",
"os",
".",
"Exit",
"(",
"out",
".",
"ReturnCode",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // AppRun runs a one time command in the app. | [
"AppRun",
"runs",
"a",
"one",
"time",
"command",
"in",
"the",
"app",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/apps.go#L190-L208 | train |
deis/deis | client/cmd/apps.go | AppDestroy | func AppDestroy(appID, confirm string) error {
gitSession := false
c, err := client.New()
if err != nil {
return err
}
if appID == "" {
appID, err = git.DetectAppName(c.ControllerURL.Host)
if err != nil {
return err
}
gitSession = true
}
if confirm == "" {
fmt.Printf(` ! WARNING: Potentially Destructive Action
! This command will destroy the application: %s
! To proceed, type "%s" or re-run this command with --confirm=%s
> `, appID, appID, appID)
fmt.Scanln(&confirm)
}
if confirm != appID {
return fmt.Errorf("App %s does not match confirm %s, aborting.", appID, confirm)
}
startTime := time.Now()
fmt.Printf("Destroying %s...\n", appID)
if err = apps.Delete(c, appID); err != nil {
return err
}
fmt.Printf("done in %ds\n", int(time.Since(startTime).Seconds()))
if gitSession {
return git.DeleteRemote(appID)
}
return nil
} | go | func AppDestroy(appID, confirm string) error {
gitSession := false
c, err := client.New()
if err != nil {
return err
}
if appID == "" {
appID, err = git.DetectAppName(c.ControllerURL.Host)
if err != nil {
return err
}
gitSession = true
}
if confirm == "" {
fmt.Printf(` ! WARNING: Potentially Destructive Action
! This command will destroy the application: %s
! To proceed, type "%s" or re-run this command with --confirm=%s
> `, appID, appID, appID)
fmt.Scanln(&confirm)
}
if confirm != appID {
return fmt.Errorf("App %s does not match confirm %s, aborting.", appID, confirm)
}
startTime := time.Now()
fmt.Printf("Destroying %s...\n", appID)
if err = apps.Delete(c, appID); err != nil {
return err
}
fmt.Printf("done in %ds\n", int(time.Since(startTime).Seconds()))
if gitSession {
return git.DeleteRemote(appID)
}
return nil
} | [
"func",
"AppDestroy",
"(",
"appID",
",",
"confirm",
"string",
")",
"error",
"{",
"gitSession",
":=",
"false",
"\n\n",
"c",
",",
"err",
":=",
"client",
".",
"New",
"(",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"appID",
"==",
"\"",
"\"",
"{",
"appID",
",",
"err",
"=",
"git",
".",
"DetectAppName",
"(",
"c",
".",
"ControllerURL",
".",
"Host",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"gitSession",
"=",
"true",
"\n",
"}",
"\n\n",
"if",
"confirm",
"==",
"\"",
"\"",
"{",
"fmt",
".",
"Printf",
"(",
"` ! WARNING: Potentially Destructive Action\n ! This command will destroy the application: %s\n ! To proceed, type \"%s\" or re-run this command with --confirm=%s\n\n> `",
",",
"appID",
",",
"appID",
",",
"appID",
")",
"\n\n",
"fmt",
".",
"Scanln",
"(",
"&",
"confirm",
")",
"\n",
"}",
"\n\n",
"if",
"confirm",
"!=",
"appID",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"appID",
",",
"confirm",
")",
"\n",
"}",
"\n\n",
"startTime",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"appID",
")",
"\n\n",
"if",
"err",
"=",
"apps",
".",
"Delete",
"(",
"c",
",",
"appID",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"int",
"(",
"time",
".",
"Since",
"(",
"startTime",
")",
".",
"Seconds",
"(",
")",
")",
")",
"\n\n",
"if",
"gitSession",
"{",
"return",
"git",
".",
"DeleteRemote",
"(",
"appID",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // AppDestroy destroys an app. | [
"AppDestroy",
"destroys",
"an",
"app",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/apps.go#L211-L258 | train |
deis/deis | client/cmd/apps.go | AppTransfer | func AppTransfer(appID, username string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
fmt.Printf("Transferring %s to %s... ", appID, username)
err = apps.Transfer(c, appID, username)
if err != nil {
return err
}
fmt.Println("done")
return nil
} | go | func AppTransfer(appID, username string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
fmt.Printf("Transferring %s to %s... ", appID, username)
err = apps.Transfer(c, appID, username)
if err != nil {
return err
}
fmt.Println("done")
return nil
} | [
"func",
"AppTransfer",
"(",
"appID",
",",
"username",
"string",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"load",
"(",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"appID",
",",
"username",
")",
"\n\n",
"err",
"=",
"apps",
".",
"Transfer",
"(",
"c",
",",
"appID",
",",
"username",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // AppTransfer transfers app ownership to another user. | [
"AppTransfer",
"transfers",
"app",
"ownership",
"to",
"another",
"user",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/apps.go#L261-L279 | train |
deis/deis | client/controller/models/users/users.go | List | func List(c *client.Client, results int) (api.Users, int, error) {
body, count, err := c.LimitedRequest("/v1/users/", results)
if err != nil {
return []api.User{}, -1, err
}
var users []api.User
if err = json.Unmarshal([]byte(body), &users); err != nil {
return []api.User{}, -1, err
}
return users, count, nil
} | go | func List(c *client.Client, results int) (api.Users, int, error) {
body, count, err := c.LimitedRequest("/v1/users/", results)
if err != nil {
return []api.User{}, -1, err
}
var users []api.User
if err = json.Unmarshal([]byte(body), &users); err != nil {
return []api.User{}, -1, err
}
return users, count, nil
} | [
"func",
"List",
"(",
"c",
"*",
"client",
".",
"Client",
",",
"results",
"int",
")",
"(",
"api",
".",
"Users",
",",
"int",
",",
"error",
")",
"{",
"body",
",",
"count",
",",
"err",
":=",
"c",
".",
"LimitedRequest",
"(",
"\"",
"\"",
",",
"results",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"[",
"]",
"api",
".",
"User",
"{",
"}",
",",
"-",
"1",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"users",
"[",
"]",
"api",
".",
"User",
"\n",
"if",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"body",
")",
",",
"&",
"users",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"[",
"]",
"api",
".",
"User",
"{",
"}",
",",
"-",
"1",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"users",
",",
"count",
",",
"nil",
"\n",
"}"
] | // List users registered with the controller. | [
"List",
"users",
"registered",
"with",
"the",
"controller",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/users/users.go#L11-L24 | train |
deis/deis | client/parser/apps.go | Apps | func Apps(argv []string) error {
usage := `
Valid commands for apps:
apps:create create a new application
apps:list list accessible applications
apps:info view info about an application
apps:open open the application in a browser
apps:logs view aggregated application logs
apps:run run a command in an ephemeral app container
apps:destroy destroy an application
apps:transfer transfer app ownership to another user
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "apps:create":
return appCreate(argv)
case "apps:list":
return appsList(argv)
case "apps:info":
return appInfo(argv)
case "apps:open":
return appOpen(argv)
case "apps:logs":
return appLogs(argv)
case "apps:run":
return appRun(argv)
case "apps:destroy":
return appDestroy(argv)
case "apps:transfer":
return appTransfer(argv)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "apps" {
argv[0] = "apps:list"
return appsList(argv)
}
PrintUsage()
return nil
}
} | go | func Apps(argv []string) error {
usage := `
Valid commands for apps:
apps:create create a new application
apps:list list accessible applications
apps:info view info about an application
apps:open open the application in a browser
apps:logs view aggregated application logs
apps:run run a command in an ephemeral app container
apps:destroy destroy an application
apps:transfer transfer app ownership to another user
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "apps:create":
return appCreate(argv)
case "apps:list":
return appsList(argv)
case "apps:info":
return appInfo(argv)
case "apps:open":
return appOpen(argv)
case "apps:logs":
return appLogs(argv)
case "apps:run":
return appRun(argv)
case "apps:destroy":
return appDestroy(argv)
case "apps:transfer":
return appTransfer(argv)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "apps" {
argv[0] = "apps:list"
return appsList(argv)
}
PrintUsage()
return nil
}
} | [
"func",
"Apps",
"(",
"argv",
"[",
"]",
"string",
")",
"error",
"{",
"usage",
":=",
"`\nValid commands for apps:\n\napps:create create a new application\napps:list list accessible applications\napps:info view info about an application\napps:open open the application in a browser\napps:logs view aggregated application logs\napps:run run a command in an ephemeral app container\napps:destroy destroy an application\napps:transfer transfer app ownership to another user\n\nUse 'deis help [command]' to learn more.\n`",
"\n\n",
"switch",
"argv",
"[",
"0",
"]",
"{",
"case",
"\"",
"\"",
":",
"return",
"appCreate",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"appsList",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"appInfo",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"appOpen",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"appLogs",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"appRun",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"appDestroy",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"appTransfer",
"(",
"argv",
")",
"\n",
"default",
":",
"if",
"printHelp",
"(",
"argv",
",",
"usage",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"argv",
"[",
"0",
"]",
"==",
"\"",
"\"",
"{",
"argv",
"[",
"0",
"]",
"=",
"\"",
"\"",
"\n",
"return",
"appsList",
"(",
"argv",
")",
"\n",
"}",
"\n\n",
"PrintUsage",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // Apps routes app commands to their specific function. | [
"Apps",
"routes",
"app",
"commands",
"to",
"their",
"specific",
"function",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/parser/apps.go#L12-L58 | train |
deis/deis | client/controller/client/http.go | CreateHTTPClient | func CreateHTTPClient(sslVerify bool) *http.Client {
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: !sslVerify},
DisableKeepAlives: true,
}
return &http.Client{Transport: tr}
} | go | func CreateHTTPClient(sslVerify bool) *http.Client {
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: !sslVerify},
DisableKeepAlives: true,
}
return &http.Client{Transport: tr}
} | [
"func",
"CreateHTTPClient",
"(",
"sslVerify",
"bool",
")",
"*",
"http",
".",
"Client",
"{",
"tr",
":=",
"&",
"http",
".",
"Transport",
"{",
"TLSClientConfig",
":",
"&",
"tls",
".",
"Config",
"{",
"InsecureSkipVerify",
":",
"!",
"sslVerify",
"}",
",",
"DisableKeepAlives",
":",
"true",
",",
"}",
"\n",
"return",
"&",
"http",
".",
"Client",
"{",
"Transport",
":",
"tr",
"}",
"\n",
"}"
] | // CreateHTTPClient creates a HTTP Client with proper SSL options. | [
"CreateHTTPClient",
"creates",
"a",
"HTTP",
"Client",
"with",
"proper",
"SSL",
"options",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/client/http.go#L20-L26 | train |
deis/deis | client/controller/client/http.go | Request | func (c Client) Request(method string, path string, body []byte) (*http.Response, error) {
url := c.ControllerURL
if strings.Contains(path, "?") {
parts := strings.Split(path, "?")
url.Path = parts[0]
url.RawQuery = parts[1]
} else {
url.Path = path
}
req, err := http.NewRequest(method, url.String(), bytes.NewBuffer(body))
if err != nil {
return nil, err
}
req.Header.Add("Content-Type", "application/json")
if c.Token != "" {
req.Header.Add("Authorization", "token "+c.Token)
}
addUserAgent(&req.Header)
res, err := c.HTTPClient.Do(req)
if err != nil {
return nil, err
}
if err = checkForErrors(res, ""); err != nil {
return nil, err
}
checkAPICompatibility(res.Header.Get("DEIS_API_VERSION"))
return res, nil
} | go | func (c Client) Request(method string, path string, body []byte) (*http.Response, error) {
url := c.ControllerURL
if strings.Contains(path, "?") {
parts := strings.Split(path, "?")
url.Path = parts[0]
url.RawQuery = parts[1]
} else {
url.Path = path
}
req, err := http.NewRequest(method, url.String(), bytes.NewBuffer(body))
if err != nil {
return nil, err
}
req.Header.Add("Content-Type", "application/json")
if c.Token != "" {
req.Header.Add("Authorization", "token "+c.Token)
}
addUserAgent(&req.Header)
res, err := c.HTTPClient.Do(req)
if err != nil {
return nil, err
}
if err = checkForErrors(res, ""); err != nil {
return nil, err
}
checkAPICompatibility(res.Header.Get("DEIS_API_VERSION"))
return res, nil
} | [
"func",
"(",
"c",
"Client",
")",
"Request",
"(",
"method",
"string",
",",
"path",
"string",
",",
"body",
"[",
"]",
"byte",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"url",
":=",
"c",
".",
"ControllerURL",
"\n\n",
"if",
"strings",
".",
"Contains",
"(",
"path",
",",
"\"",
"\"",
")",
"{",
"parts",
":=",
"strings",
".",
"Split",
"(",
"path",
",",
"\"",
"\"",
")",
"\n",
"url",
".",
"Path",
"=",
"parts",
"[",
"0",
"]",
"\n",
"url",
".",
"RawQuery",
"=",
"parts",
"[",
"1",
"]",
"\n",
"}",
"else",
"{",
"url",
".",
"Path",
"=",
"path",
"\n",
"}",
"\n\n",
"req",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"method",
",",
"url",
".",
"String",
"(",
")",
",",
"bytes",
".",
"NewBuffer",
"(",
"body",
")",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"req",
".",
"Header",
".",
"Add",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n\n",
"if",
"c",
".",
"Token",
"!=",
"\"",
"\"",
"{",
"req",
".",
"Header",
".",
"Add",
"(",
"\"",
"\"",
",",
"\"",
"\"",
"+",
"c",
".",
"Token",
")",
"\n",
"}",
"\n\n",
"addUserAgent",
"(",
"&",
"req",
".",
"Header",
")",
"\n\n",
"res",
",",
"err",
":=",
"c",
".",
"HTTPClient",
".",
"Do",
"(",
"req",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"err",
"=",
"checkForErrors",
"(",
"res",
",",
"\"",
"\"",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"checkAPICompatibility",
"(",
"res",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
")",
"\n\n",
"return",
"res",
",",
"nil",
"\n",
"}"
] | // Request makes a HTTP request on the controller. | [
"Request",
"makes",
"a",
"HTTP",
"request",
"on",
"the",
"controller",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/client/http.go#L29-L67 | train |
deis/deis | client/controller/client/http.go | BasicRequest | func (c Client) BasicRequest(method string, path string, body []byte) (string, error) {
res, err := c.Request(method, path, body)
if err != nil {
return "", err
}
defer res.Body.Close()
resBody, err := ioutil.ReadAll(res.Body)
if err != nil {
return "", err
}
return string(resBody), checkForErrors(res, string(resBody))
} | go | func (c Client) BasicRequest(method string, path string, body []byte) (string, error) {
res, err := c.Request(method, path, body)
if err != nil {
return "", err
}
defer res.Body.Close()
resBody, err := ioutil.ReadAll(res.Body)
if err != nil {
return "", err
}
return string(resBody), checkForErrors(res, string(resBody))
} | [
"func",
"(",
"c",
"Client",
")",
"BasicRequest",
"(",
"method",
"string",
",",
"path",
"string",
",",
"body",
"[",
"]",
"byte",
")",
"(",
"string",
",",
"error",
")",
"{",
"res",
",",
"err",
":=",
"c",
".",
"Request",
"(",
"method",
",",
"path",
",",
"body",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"defer",
"res",
".",
"Body",
".",
"Close",
"(",
")",
"\n\n",
"resBody",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"res",
".",
"Body",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"return",
"string",
"(",
"resBody",
")",
",",
"checkForErrors",
"(",
"res",
",",
"string",
"(",
"resBody",
")",
")",
"\n",
"}"
] | // BasicRequest makes a simple http request on the controller. | [
"BasicRequest",
"makes",
"a",
"simple",
"http",
"request",
"on",
"the",
"controller",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/client/http.go#L92-L106 | train |
deis/deis | logger/drain/factory.go | NewDrain | func NewDrain(drainURL string) (LogDrain, error) {
if drainURL == "" {
// nil means no drain-- which is valid
return nil, nil
}
// Any of these three can use the same drain implementation
if strings.HasPrefix(drainURL, "udp://") || strings.HasPrefix(drainURL, "syslog://") || strings.HasPrefix(drainURL, "tcp://") {
drain, err := simple.NewDrain(drainURL)
if err != nil {
return nil, err
}
return drain, nil
}
// TODO: Add more drain implementations-- TLS over TCP and HTTP/S
return nil, fmt.Errorf("Cannot construct a drain for URL: '%s'", drainURL)
} | go | func NewDrain(drainURL string) (LogDrain, error) {
if drainURL == "" {
// nil means no drain-- which is valid
return nil, nil
}
// Any of these three can use the same drain implementation
if strings.HasPrefix(drainURL, "udp://") || strings.HasPrefix(drainURL, "syslog://") || strings.HasPrefix(drainURL, "tcp://") {
drain, err := simple.NewDrain(drainURL)
if err != nil {
return nil, err
}
return drain, nil
}
// TODO: Add more drain implementations-- TLS over TCP and HTTP/S
return nil, fmt.Errorf("Cannot construct a drain for URL: '%s'", drainURL)
} | [
"func",
"NewDrain",
"(",
"drainURL",
"string",
")",
"(",
"LogDrain",
",",
"error",
")",
"{",
"if",
"drainURL",
"==",
"\"",
"\"",
"{",
"// nil means no drain-- which is valid",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"// Any of these three can use the same drain implementation",
"if",
"strings",
".",
"HasPrefix",
"(",
"drainURL",
",",
"\"",
"\"",
")",
"||",
"strings",
".",
"HasPrefix",
"(",
"drainURL",
",",
"\"",
"\"",
")",
"||",
"strings",
".",
"HasPrefix",
"(",
"drainURL",
",",
"\"",
"\"",
")",
"{",
"drain",
",",
"err",
":=",
"simple",
".",
"NewDrain",
"(",
"drainURL",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"drain",
",",
"nil",
"\n",
"}",
"\n",
"// TODO: Add more drain implementations-- TLS over TCP and HTTP/S",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"drainURL",
")",
"\n",
"}"
] | // NewDrain returns a pointer to an appropriate implementation of the LogDrain interface, as
// determined by the drainURL it is passed. | [
"NewDrain",
"returns",
"a",
"pointer",
"to",
"an",
"appropriate",
"implementation",
"of",
"the",
"LogDrain",
"interface",
"as",
"determined",
"by",
"the",
"drainURL",
"it",
"is",
"passed",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/drain/factory.go#L12-L27 | train |
deis/deis | logger/configurer/configurer.go | NewConfigurer | func NewConfigurer(etcdHost string, etcdPort int, etcdPath string, configInterval int,
syslogishServer *syslogish.Server) (*Configurer, error) {
etcdClient := etcd.NewClient([]string{fmt.Sprintf("http://%s:%d", etcdHost, etcdPort)})
ticker := time.NewTicker(time.Duration(configInterval) * time.Second)
configurer := &Configurer{
etcdClient: etcdClient,
etcdPath: etcdPath,
syslogishServer: syslogishServer,
ticker: ticker,
}
// Support legacy behavior that allows default drain uri to be specified using a drain-uri flag
if _, err := etcdClient.Get(etcdPath+"/drain", false, false); err != nil {
etcdErr, ok := err.(*etcd.EtcdError)
// Error code 100 is key not found
if ok && etcdErr.ErrorCode == 100 {
configurer.setEtcd("/drain", DefaultDrainURI)
} else {
log.Println(err)
}
}
return configurer, nil
} | go | func NewConfigurer(etcdHost string, etcdPort int, etcdPath string, configInterval int,
syslogishServer *syslogish.Server) (*Configurer, error) {
etcdClient := etcd.NewClient([]string{fmt.Sprintf("http://%s:%d", etcdHost, etcdPort)})
ticker := time.NewTicker(time.Duration(configInterval) * time.Second)
configurer := &Configurer{
etcdClient: etcdClient,
etcdPath: etcdPath,
syslogishServer: syslogishServer,
ticker: ticker,
}
// Support legacy behavior that allows default drain uri to be specified using a drain-uri flag
if _, err := etcdClient.Get(etcdPath+"/drain", false, false); err != nil {
etcdErr, ok := err.(*etcd.EtcdError)
// Error code 100 is key not found
if ok && etcdErr.ErrorCode == 100 {
configurer.setEtcd("/drain", DefaultDrainURI)
} else {
log.Println(err)
}
}
return configurer, nil
} | [
"func",
"NewConfigurer",
"(",
"etcdHost",
"string",
",",
"etcdPort",
"int",
",",
"etcdPath",
"string",
",",
"configInterval",
"int",
",",
"syslogishServer",
"*",
"syslogish",
".",
"Server",
")",
"(",
"*",
"Configurer",
",",
"error",
")",
"{",
"etcdClient",
":=",
"etcd",
".",
"NewClient",
"(",
"[",
"]",
"string",
"{",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"etcdHost",
",",
"etcdPort",
")",
"}",
")",
"\n",
"ticker",
":=",
"time",
".",
"NewTicker",
"(",
"time",
".",
"Duration",
"(",
"configInterval",
")",
"*",
"time",
".",
"Second",
")",
"\n",
"configurer",
":=",
"&",
"Configurer",
"{",
"etcdClient",
":",
"etcdClient",
",",
"etcdPath",
":",
"etcdPath",
",",
"syslogishServer",
":",
"syslogishServer",
",",
"ticker",
":",
"ticker",
",",
"}",
"\n\n",
"// Support legacy behavior that allows default drain uri to be specified using a drain-uri flag",
"if",
"_",
",",
"err",
":=",
"etcdClient",
".",
"Get",
"(",
"etcdPath",
"+",
"\"",
"\"",
",",
"false",
",",
"false",
")",
";",
"err",
"!=",
"nil",
"{",
"etcdErr",
",",
"ok",
":=",
"err",
".",
"(",
"*",
"etcd",
".",
"EtcdError",
")",
"\n",
"// Error code 100 is key not found",
"if",
"ok",
"&&",
"etcdErr",
".",
"ErrorCode",
"==",
"100",
"{",
"configurer",
".",
"setEtcd",
"(",
"\"",
"\"",
",",
"DefaultDrainURI",
")",
"\n",
"}",
"else",
"{",
"log",
".",
"Println",
"(",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"configurer",
",",
"nil",
"\n",
"}"
] | // NewConfigurer returns a pointer to a new Configurer instance. | [
"NewConfigurer",
"returns",
"a",
"pointer",
"to",
"a",
"new",
"Configurer",
"instance",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/configurer/configurer.go#L30-L53 | train |
deis/deis | logger/configurer/configurer.go | Start | func (c *Configurer) Start() {
// Should only ever be called once
if !c.running {
c.running = true
go c.configure()
log.Println("configurer running")
}
} | go | func (c *Configurer) Start() {
// Should only ever be called once
if !c.running {
c.running = true
go c.configure()
log.Println("configurer running")
}
} | [
"func",
"(",
"c",
"*",
"Configurer",
")",
"Start",
"(",
")",
"{",
"// Should only ever be called once",
"if",
"!",
"c",
".",
"running",
"{",
"c",
".",
"running",
"=",
"true",
"\n",
"go",
"c",
".",
"configure",
"(",
")",
"\n",
"log",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}"
] | // Start begins the configurer's main loop. | [
"Start",
"begins",
"the",
"configurer",
"s",
"main",
"loop",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/configurer/configurer.go#L56-L63 | train |
deis/deis | client/parser/domains.go | Domains | func Domains(argv []string) error {
usage := `
Valid commands for domains:
domains:add bind a domain to an application
domains:list list domains bound to an application
domains:remove unbind a domain from an application
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "domains:add":
return domainsAdd(argv)
case "domains:list":
return domainsList(argv)
case "domains:remove":
return domainsRemove(argv)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "domains" {
argv[0] = "domains:list"
return domainsList(argv)
}
PrintUsage()
return nil
}
} | go | func Domains(argv []string) error {
usage := `
Valid commands for domains:
domains:add bind a domain to an application
domains:list list domains bound to an application
domains:remove unbind a domain from an application
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "domains:add":
return domainsAdd(argv)
case "domains:list":
return domainsList(argv)
case "domains:remove":
return domainsRemove(argv)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "domains" {
argv[0] = "domains:list"
return domainsList(argv)
}
PrintUsage()
return nil
}
} | [
"func",
"Domains",
"(",
"argv",
"[",
"]",
"string",
")",
"error",
"{",
"usage",
":=",
"`\nValid commands for domains:\n\ndomains:add bind a domain to an application\ndomains:list list domains bound to an application\ndomains:remove unbind a domain from an application\n\nUse 'deis help [command]' to learn more.\n`",
"\n",
"switch",
"argv",
"[",
"0",
"]",
"{",
"case",
"\"",
"\"",
":",
"return",
"domainsAdd",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"domainsList",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"domainsRemove",
"(",
"argv",
")",
"\n",
"default",
":",
"if",
"printHelp",
"(",
"argv",
",",
"usage",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"argv",
"[",
"0",
"]",
"==",
"\"",
"\"",
"{",
"argv",
"[",
"0",
"]",
"=",
"\"",
"\"",
"\n",
"return",
"domainsList",
"(",
"argv",
")",
"\n",
"}",
"\n\n",
"PrintUsage",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // Domains routes domain commands to their specific function. | [
"Domains",
"routes",
"domain",
"commands",
"to",
"their",
"specific",
"function",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/parser/domains.go#L9-L39 | train |
deis/deis | client/controller/client/client.go | New | func New() (*Client, error) {
filename := locateSettingsFile()
if _, err := os.Stat(filename); err != nil {
if os.IsNotExist(err) {
return nil, errors.New("Not logged in. Use 'deis login' or 'deis register' to get started.")
}
return nil, err
}
contents, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
settings := settingsFile{}
if err = json.Unmarshal(contents, &settings); err != nil {
return nil, err
}
u, err := url.Parse(settings.Controller)
if err != nil {
return nil, err
}
if settings.Limit <= 0 {
settings.Limit = DefaultResponseLimit
}
return &Client{HTTPClient: CreateHTTPClient(settings.SslVerify), SSLVerify: settings.SslVerify,
ControllerURL: *u, Token: settings.Token, Username: settings.Username,
ResponseLimit: settings.Limit}, nil
} | go | func New() (*Client, error) {
filename := locateSettingsFile()
if _, err := os.Stat(filename); err != nil {
if os.IsNotExist(err) {
return nil, errors.New("Not logged in. Use 'deis login' or 'deis register' to get started.")
}
return nil, err
}
contents, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
settings := settingsFile{}
if err = json.Unmarshal(contents, &settings); err != nil {
return nil, err
}
u, err := url.Parse(settings.Controller)
if err != nil {
return nil, err
}
if settings.Limit <= 0 {
settings.Limit = DefaultResponseLimit
}
return &Client{HTTPClient: CreateHTTPClient(settings.SslVerify), SSLVerify: settings.SslVerify,
ControllerURL: *u, Token: settings.Token, Username: settings.Username,
ResponseLimit: settings.Limit}, nil
} | [
"func",
"New",
"(",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"filename",
":=",
"locateSettingsFile",
"(",
")",
"\n\n",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"filename",
")",
";",
"err",
"!=",
"nil",
"{",
"if",
"os",
".",
"IsNotExist",
"(",
"err",
")",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"contents",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"settings",
":=",
"settingsFile",
"{",
"}",
"\n",
"if",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"contents",
",",
"&",
"settings",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"settings",
".",
"Controller",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"settings",
".",
"Limit",
"<=",
"0",
"{",
"settings",
".",
"Limit",
"=",
"DefaultResponseLimit",
"\n",
"}",
"\n\n",
"return",
"&",
"Client",
"{",
"HTTPClient",
":",
"CreateHTTPClient",
"(",
"settings",
".",
"SslVerify",
")",
",",
"SSLVerify",
":",
"settings",
".",
"SslVerify",
",",
"ControllerURL",
":",
"*",
"u",
",",
"Token",
":",
"settings",
".",
"Token",
",",
"Username",
":",
"settings",
".",
"Username",
",",
"ResponseLimit",
":",
"settings",
".",
"Limit",
"}",
",",
"nil",
"\n",
"}"
] | // New creates a new client from a settings file. | [
"New",
"creates",
"a",
"new",
"client",
"from",
"a",
"settings",
"file",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/client/client.go#L47-L80 | train |
deis/deis | client/controller/client/client.go | Save | func (c Client) Save() error {
settings := settingsFile{Username: c.Username, SslVerify: c.SSLVerify,
Controller: c.ControllerURL.String(), Token: c.Token, Limit: c.ResponseLimit}
if settings.Limit <= 0 {
settings.Limit = DefaultResponseLimit
}
settingsContents, err := json.Marshal(settings)
if err != nil {
return err
}
if err = os.MkdirAll(path.Join(FindHome(), "/.deis/"), 0700); err != nil {
return err
}
return ioutil.WriteFile(locateSettingsFile(), settingsContents, 0600)
} | go | func (c Client) Save() error {
settings := settingsFile{Username: c.Username, SslVerify: c.SSLVerify,
Controller: c.ControllerURL.String(), Token: c.Token, Limit: c.ResponseLimit}
if settings.Limit <= 0 {
settings.Limit = DefaultResponseLimit
}
settingsContents, err := json.Marshal(settings)
if err != nil {
return err
}
if err = os.MkdirAll(path.Join(FindHome(), "/.deis/"), 0700); err != nil {
return err
}
return ioutil.WriteFile(locateSettingsFile(), settingsContents, 0600)
} | [
"func",
"(",
"c",
"Client",
")",
"Save",
"(",
")",
"error",
"{",
"settings",
":=",
"settingsFile",
"{",
"Username",
":",
"c",
".",
"Username",
",",
"SslVerify",
":",
"c",
".",
"SSLVerify",
",",
"Controller",
":",
"c",
".",
"ControllerURL",
".",
"String",
"(",
")",
",",
"Token",
":",
"c",
".",
"Token",
",",
"Limit",
":",
"c",
".",
"ResponseLimit",
"}",
"\n\n",
"if",
"settings",
".",
"Limit",
"<=",
"0",
"{",
"settings",
".",
"Limit",
"=",
"DefaultResponseLimit",
"\n",
"}",
"\n\n",
"settingsContents",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"settings",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"err",
"=",
"os",
".",
"MkdirAll",
"(",
"path",
".",
"Join",
"(",
"FindHome",
"(",
")",
",",
"\"",
"\"",
")",
",",
"0700",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"ioutil",
".",
"WriteFile",
"(",
"locateSettingsFile",
"(",
")",
",",
"settingsContents",
",",
"0600",
")",
"\n",
"}"
] | // Save settings to a file | [
"Save",
"settings",
"to",
"a",
"file"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/client/client.go#L83-L102 | train |
deis/deis | client/controller/client/client.go | Delete | func Delete() error {
filename := locateSettingsFile()
if _, err := os.Stat(filename); err != nil {
if os.IsNotExist(err) {
return nil
}
return err
}
if err := os.Remove(filename); err != nil {
return err
}
return nil
} | go | func Delete() error {
filename := locateSettingsFile()
if _, err := os.Stat(filename); err != nil {
if os.IsNotExist(err) {
return nil
}
return err
}
if err := os.Remove(filename); err != nil {
return err
}
return nil
} | [
"func",
"Delete",
"(",
")",
"error",
"{",
"filename",
":=",
"locateSettingsFile",
"(",
")",
"\n\n",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"filename",
")",
";",
"err",
"!=",
"nil",
"{",
"if",
"os",
".",
"IsNotExist",
"(",
"err",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"os",
".",
"Remove",
"(",
"filename",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // Delete user's settings file. | [
"Delete",
"user",
"s",
"settings",
"file",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/client/client.go#L105-L121 | train |
deis/deis | client/controller/models/certs/certs.go | New | func New(c *client.Client, cert string, key string, commonName string) (api.Cert, error) {
req := api.CertCreateRequest{Certificate: cert, Key: key, Name: commonName}
reqBody, err := json.Marshal(req)
if err != nil {
return api.Cert{}, err
}
resBody, err := c.BasicRequest("POST", "/v1/certs/", reqBody)
if err != nil {
return api.Cert{}, err
}
resCert := api.Cert{}
if err = json.Unmarshal([]byte(resBody), &resCert); err != nil {
return api.Cert{}, err
}
return resCert, nil
} | go | func New(c *client.Client, cert string, key string, commonName string) (api.Cert, error) {
req := api.CertCreateRequest{Certificate: cert, Key: key, Name: commonName}
reqBody, err := json.Marshal(req)
if err != nil {
return api.Cert{}, err
}
resBody, err := c.BasicRequest("POST", "/v1/certs/", reqBody)
if err != nil {
return api.Cert{}, err
}
resCert := api.Cert{}
if err = json.Unmarshal([]byte(resBody), &resCert); err != nil {
return api.Cert{}, err
}
return resCert, nil
} | [
"func",
"New",
"(",
"c",
"*",
"client",
".",
"Client",
",",
"cert",
"string",
",",
"key",
"string",
",",
"commonName",
"string",
")",
"(",
"api",
".",
"Cert",
",",
"error",
")",
"{",
"req",
":=",
"api",
".",
"CertCreateRequest",
"{",
"Certificate",
":",
"cert",
",",
"Key",
":",
"key",
",",
"Name",
":",
"commonName",
"}",
"\n",
"reqBody",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"req",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"api",
".",
"Cert",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"resBody",
",",
"err",
":=",
"c",
".",
"BasicRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"reqBody",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"api",
".",
"Cert",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"resCert",
":=",
"api",
".",
"Cert",
"{",
"}",
"\n",
"if",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"resBody",
")",
",",
"&",
"resCert",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"api",
".",
"Cert",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"resCert",
",",
"nil",
"\n",
"}"
] | // New creates a new cert. | [
"New",
"creates",
"a",
"new",
"cert",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/certs/certs.go#L28-L48 | train |
deis/deis | client/controller/models/certs/certs.go | Delete | func Delete(c *client.Client, commonName string) error {
u := fmt.Sprintf("/v1/certs/%s", commonName)
_, err := c.BasicRequest("DELETE", u, nil)
return err
} | go | func Delete(c *client.Client, commonName string) error {
u := fmt.Sprintf("/v1/certs/%s", commonName)
_, err := c.BasicRequest("DELETE", u, nil)
return err
} | [
"func",
"Delete",
"(",
"c",
"*",
"client",
".",
"Client",
",",
"commonName",
"string",
")",
"error",
"{",
"u",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"commonName",
")",
"\n\n",
"_",
",",
"err",
":=",
"c",
".",
"BasicRequest",
"(",
"\"",
"\"",
",",
"u",
",",
"nil",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Delete removes a cert. | [
"Delete",
"removes",
"a",
"cert",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/certs/certs.go#L51-L56 | train |
deis/deis | client/cmd/domains.go | DomainsList | func DomainsList(appID string, results int) error {
c, appID, err := load(appID)
if err != nil {
return err
}
if results == defaultLimit {
results = c.ResponseLimit
}
domains, count, err := domains.List(c, appID, results)
if err != nil {
return err
}
fmt.Printf("=== %s Domains%s", appID, limitCount(len(domains), count))
sort.Sort(domains)
for _, domain := range domains {
fmt.Println(domain.Domain)
}
return nil
} | go | func DomainsList(appID string, results int) error {
c, appID, err := load(appID)
if err != nil {
return err
}
if results == defaultLimit {
results = c.ResponseLimit
}
domains, count, err := domains.List(c, appID, results)
if err != nil {
return err
}
fmt.Printf("=== %s Domains%s", appID, limitCount(len(domains), count))
sort.Sort(domains)
for _, domain := range domains {
fmt.Println(domain.Domain)
}
return nil
} | [
"func",
"DomainsList",
"(",
"appID",
"string",
",",
"results",
"int",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"load",
"(",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"results",
"==",
"defaultLimit",
"{",
"results",
"=",
"c",
".",
"ResponseLimit",
"\n",
"}",
"\n\n",
"domains",
",",
"count",
",",
"err",
":=",
"domains",
".",
"List",
"(",
"c",
",",
"appID",
",",
"results",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"appID",
",",
"limitCount",
"(",
"len",
"(",
"domains",
")",
",",
"count",
")",
")",
"\n\n",
"sort",
".",
"Sort",
"(",
"domains",
")",
"\n\n",
"for",
"_",
",",
"domain",
":=",
"range",
"domains",
"{",
"fmt",
".",
"Println",
"(",
"domain",
".",
"Domain",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // DomainsList lists domains registered with an app. | [
"DomainsList",
"lists",
"domains",
"registered",
"with",
"an",
"app",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/domains.go#L11-L36 | train |
deis/deis | client/cmd/domains.go | DomainsAdd | func DomainsAdd(appID, domain string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
fmt.Printf("Adding %s to %s... ", domain, appID)
quit := progress()
_, err = domains.New(c, appID, domain)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Println("done")
return nil
} | go | func DomainsAdd(appID, domain string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
fmt.Printf("Adding %s to %s... ", domain, appID)
quit := progress()
_, err = domains.New(c, appID, domain)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Println("done")
return nil
} | [
"func",
"DomainsAdd",
"(",
"appID",
",",
"domain",
"string",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"load",
"(",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"domain",
",",
"appID",
")",
"\n\n",
"quit",
":=",
"progress",
"(",
")",
"\n",
"_",
",",
"err",
"=",
"domains",
".",
"New",
"(",
"c",
",",
"appID",
",",
"domain",
")",
"\n",
"quit",
"<-",
"true",
"\n",
"<-",
"quit",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // DomainsAdd adds a domain to an app. | [
"DomainsAdd",
"adds",
"a",
"domain",
"to",
"an",
"app",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/domains.go#L39-L59 | train |
deis/deis | client/cmd/domains.go | DomainsRemove | func DomainsRemove(appID, domain string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
fmt.Printf("Removing %s from %s... ", domain, appID)
quit := progress()
err = domains.Delete(c, appID, domain)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Println("done")
return nil
} | go | func DomainsRemove(appID, domain string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
fmt.Printf("Removing %s from %s... ", domain, appID)
quit := progress()
err = domains.Delete(c, appID, domain)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Println("done")
return nil
} | [
"func",
"DomainsRemove",
"(",
"appID",
",",
"domain",
"string",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"load",
"(",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"domain",
",",
"appID",
")",
"\n\n",
"quit",
":=",
"progress",
"(",
")",
"\n",
"err",
"=",
"domains",
".",
"Delete",
"(",
"c",
",",
"appID",
",",
"domain",
")",
"\n",
"quit",
"<-",
"true",
"\n",
"<-",
"quit",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // DomainsRemove removes a domain registered with an app. | [
"DomainsRemove",
"removes",
"a",
"domain",
"registered",
"with",
"an",
"app",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/domains.go#L62-L82 | train |
deis/deis | client/parser/auth.go | Auth | func Auth(argv []string) error {
usage := `
Valid commands for auth:
auth:register register a new user
auth:login authenticate against a controller
auth:logout clear the current user session
auth:passwd change the password for the current user
auth:whoami display the current user
auth:cancel remove the current user account
auth:regenerate regenerate user tokens
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "auth:register":
return authRegister(argv)
case "auth:login":
return authLogin(argv)
case "auth:logout":
return authLogout(argv)
case "auth:passwd":
return authPasswd(argv)
case "auth:whoami":
return authWhoami(argv)
case "auth:cancel":
return authCancel(argv)
case "auth:regenerate":
return authRegenerate(argv)
case "auth":
fmt.Print(usage)
return nil
default:
PrintUsage()
return nil
}
} | go | func Auth(argv []string) error {
usage := `
Valid commands for auth:
auth:register register a new user
auth:login authenticate against a controller
auth:logout clear the current user session
auth:passwd change the password for the current user
auth:whoami display the current user
auth:cancel remove the current user account
auth:regenerate regenerate user tokens
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "auth:register":
return authRegister(argv)
case "auth:login":
return authLogin(argv)
case "auth:logout":
return authLogout(argv)
case "auth:passwd":
return authPasswd(argv)
case "auth:whoami":
return authWhoami(argv)
case "auth:cancel":
return authCancel(argv)
case "auth:regenerate":
return authRegenerate(argv)
case "auth":
fmt.Print(usage)
return nil
default:
PrintUsage()
return nil
}
} | [
"func",
"Auth",
"(",
"argv",
"[",
"]",
"string",
")",
"error",
"{",
"usage",
":=",
"`\nValid commands for auth:\n\nauth:register register a new user\nauth:login authenticate against a controller\nauth:logout clear the current user session\nauth:passwd change the password for the current user\nauth:whoami display the current user\nauth:cancel remove the current user account\nauth:regenerate regenerate user tokens\n\nUse 'deis help [command]' to learn more.\n`",
"\n\n",
"switch",
"argv",
"[",
"0",
"]",
"{",
"case",
"\"",
"\"",
":",
"return",
"authRegister",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"authLogin",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"authLogout",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"authPasswd",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"authWhoami",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"authCancel",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"authRegenerate",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"fmt",
".",
"Print",
"(",
"usage",
")",
"\n",
"return",
"nil",
"\n",
"default",
":",
"PrintUsage",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // Auth routes auth commands to the specific function. | [
"Auth",
"routes",
"auth",
"commands",
"to",
"the",
"specific",
"function",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/parser/auth.go#L11-L48 | train |
deis/deis | client/controller/models/builds/builds.go | New | func New(c *client.Client, appID string, image string,
procfile map[string]string) (api.Build, error) {
u := fmt.Sprintf("/v1/apps/%s/builds/", appID)
req := api.CreateBuildRequest{Image: image, Procfile: procfile}
body, err := json.Marshal(req)
if err != nil {
return api.Build{}, err
}
resBody, err := c.BasicRequest("POST", u, body)
if err != nil {
return api.Build{}, err
}
build := api.Build{}
if err = json.Unmarshal([]byte(resBody), &build); err != nil {
return api.Build{}, err
}
return build, nil
} | go | func New(c *client.Client, appID string, image string,
procfile map[string]string) (api.Build, error) {
u := fmt.Sprintf("/v1/apps/%s/builds/", appID)
req := api.CreateBuildRequest{Image: image, Procfile: procfile}
body, err := json.Marshal(req)
if err != nil {
return api.Build{}, err
}
resBody, err := c.BasicRequest("POST", u, body)
if err != nil {
return api.Build{}, err
}
build := api.Build{}
if err = json.Unmarshal([]byte(resBody), &build); err != nil {
return api.Build{}, err
}
return build, nil
} | [
"func",
"New",
"(",
"c",
"*",
"client",
".",
"Client",
",",
"appID",
"string",
",",
"image",
"string",
",",
"procfile",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"api",
".",
"Build",
",",
"error",
")",
"{",
"u",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"appID",
")",
"\n\n",
"req",
":=",
"api",
".",
"CreateBuildRequest",
"{",
"Image",
":",
"image",
",",
"Procfile",
":",
"procfile",
"}",
"\n\n",
"body",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"req",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"api",
".",
"Build",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"resBody",
",",
"err",
":=",
"c",
".",
"BasicRequest",
"(",
"\"",
"\"",
",",
"u",
",",
"body",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"api",
".",
"Build",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"build",
":=",
"api",
".",
"Build",
"{",
"}",
"\n",
"if",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"resBody",
")",
",",
"&",
"build",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"api",
".",
"Build",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"build",
",",
"nil",
"\n",
"}"
] | // New creates a build for an app. | [
"New",
"creates",
"a",
"build",
"for",
"an",
"app",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/builds/builds.go#L29-L54 | train |
deis/deis | builder/utils.go | YamlToJSON | func YamlToJSON(bytes []byte) (string, error) {
var anomaly map[string]string
if err := yaml.Unmarshal(bytes, &anomaly); err != nil {
return "", err
}
retVal, err := json.Marshal(&anomaly)
if err != nil {
return "", err
}
return string(retVal), nil
} | go | func YamlToJSON(bytes []byte) (string, error) {
var anomaly map[string]string
if err := yaml.Unmarshal(bytes, &anomaly); err != nil {
return "", err
}
retVal, err := json.Marshal(&anomaly)
if err != nil {
return "", err
}
return string(retVal), nil
} | [
"func",
"YamlToJSON",
"(",
"bytes",
"[",
"]",
"byte",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"anomaly",
"map",
"[",
"string",
"]",
"string",
"\n\n",
"if",
"err",
":=",
"yaml",
".",
"Unmarshal",
"(",
"bytes",
",",
"&",
"anomaly",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"retVal",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"&",
"anomaly",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"string",
"(",
"retVal",
")",
",",
"nil",
"\n",
"}"
] | // YamlToJSON takes an input yaml string, parses it and returns a string formatted as json. | [
"YamlToJSON",
"takes",
"an",
"input",
"yaml",
"string",
"parses",
"it",
"and",
"returns",
"a",
"string",
"formatted",
"as",
"json",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/utils.go#L11-L25 | train |
deis/deis | builder/utils.go | ParseConfig | func ParseConfig(body []byte) (*Config, error) {
var config Config
err := json.Unmarshal(body, &config)
return &config, err
} | go | func ParseConfig(body []byte) (*Config, error) {
var config Config
err := json.Unmarshal(body, &config)
return &config, err
} | [
"func",
"ParseConfig",
"(",
"body",
"[",
"]",
"byte",
")",
"(",
"*",
"Config",
",",
"error",
")",
"{",
"var",
"config",
"Config",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"body",
",",
"&",
"config",
")",
"\n",
"return",
"&",
"config",
",",
"err",
"\n",
"}"
] | // ParseConfig takes a response body from the controller and returns a Config object. | [
"ParseConfig",
"takes",
"a",
"response",
"body",
"from",
"the",
"controller",
"and",
"returns",
"a",
"Config",
"object",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/utils.go#L28-L32 | train |
deis/deis | builder/utils.go | ParseDomain | func ParseDomain(bytes []byte) (string, error) {
var hook BuildHookResponse
if err := json.Unmarshal(bytes, &hook); err != nil {
return "", err
}
if hook.Domains == nil {
return "", fmt.Errorf("invalid application domain")
}
if len(hook.Domains) < 1 {
return "", fmt.Errorf("invalid application domain")
}
return hook.Domains[0], nil
} | go | func ParseDomain(bytes []byte) (string, error) {
var hook BuildHookResponse
if err := json.Unmarshal(bytes, &hook); err != nil {
return "", err
}
if hook.Domains == nil {
return "", fmt.Errorf("invalid application domain")
}
if len(hook.Domains) < 1 {
return "", fmt.Errorf("invalid application domain")
}
return hook.Domains[0], nil
} | [
"func",
"ParseDomain",
"(",
"bytes",
"[",
"]",
"byte",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"hook",
"BuildHookResponse",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"bytes",
",",
"&",
"hook",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"hook",
".",
"Domains",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"hook",
".",
"Domains",
")",
"<",
"1",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"hook",
".",
"Domains",
"[",
"0",
"]",
",",
"nil",
"\n",
"}"
] | // ParseDomain returns the domain field from the bytes of a build hook response. | [
"ParseDomain",
"returns",
"the",
"domain",
"field",
"from",
"the",
"bytes",
"of",
"a",
"build",
"hook",
"response",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/utils.go#L35-L50 | train |
deis/deis | builder/utils.go | ParseReleaseVersion | func ParseReleaseVersion(bytes []byte) (int, error) {
var hook BuildHookResponse
if err := json.Unmarshal(bytes, &hook); err != nil {
return 0, fmt.Errorf("invalid application json configuration")
}
if hook.Release == nil {
return 0, fmt.Errorf("invalid application version")
}
return hook.Release["version"], nil
} | go | func ParseReleaseVersion(bytes []byte) (int, error) {
var hook BuildHookResponse
if err := json.Unmarshal(bytes, &hook); err != nil {
return 0, fmt.Errorf("invalid application json configuration")
}
if hook.Release == nil {
return 0, fmt.Errorf("invalid application version")
}
return hook.Release["version"], nil
} | [
"func",
"ParseReleaseVersion",
"(",
"bytes",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"var",
"hook",
"BuildHookResponse",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"bytes",
",",
"&",
"hook",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"hook",
".",
"Release",
"==",
"nil",
"{",
"return",
"0",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"hook",
".",
"Release",
"[",
"\"",
"\"",
"]",
",",
"nil",
"\n",
"}"
] | // ParseReleaseVersion returns the version field from the bytes of a build hook response. | [
"ParseReleaseVersion",
"returns",
"the",
"version",
"field",
"from",
"the",
"bytes",
"of",
"a",
"build",
"hook",
"response",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/utils.go#L53-L64 | train |
deis/deis | builder/utils.go | GetDefaultType | func GetDefaultType(bytes []byte) (string, error) {
type YamlTypeMap struct {
DefaultProcessTypes ProcessType `yaml:"default_process_types"`
}
var p YamlTypeMap
if err := yaml.Unmarshal(bytes, &p); err != nil {
return "", err
}
retVal, err := json.Marshal(&p.DefaultProcessTypes)
if err != nil {
return "", err
}
if len(p.DefaultProcessTypes) == 0 {
return "{}", nil
}
return string(retVal), nil
} | go | func GetDefaultType(bytes []byte) (string, error) {
type YamlTypeMap struct {
DefaultProcessTypes ProcessType `yaml:"default_process_types"`
}
var p YamlTypeMap
if err := yaml.Unmarshal(bytes, &p); err != nil {
return "", err
}
retVal, err := json.Marshal(&p.DefaultProcessTypes)
if err != nil {
return "", err
}
if len(p.DefaultProcessTypes) == 0 {
return "{}", nil
}
return string(retVal), nil
} | [
"func",
"GetDefaultType",
"(",
"bytes",
"[",
"]",
"byte",
")",
"(",
"string",
",",
"error",
")",
"{",
"type",
"YamlTypeMap",
"struct",
"{",
"DefaultProcessTypes",
"ProcessType",
"`yaml:\"default_process_types\"`",
"\n",
"}",
"\n\n",
"var",
"p",
"YamlTypeMap",
"\n\n",
"if",
"err",
":=",
"yaml",
".",
"Unmarshal",
"(",
"bytes",
",",
"&",
"p",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"retVal",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"&",
"p",
".",
"DefaultProcessTypes",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"p",
".",
"DefaultProcessTypes",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
",",
"nil",
"\n",
"}",
"\n\n",
"return",
"string",
"(",
"retVal",
")",
",",
"nil",
"\n",
"}"
] | // GetDefaultType returns the default process types given a YAML byte array. | [
"GetDefaultType",
"returns",
"the",
"default",
"process",
"types",
"given",
"a",
"YAML",
"byte",
"array",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/utils.go#L67-L89 | train |
deis/deis | client/parser/git.go | Git | func Git(argv []string) error {
usage := `
Valid commands for git:
git:remote Adds git remote of application to repository
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "git:remote":
return gitRemote(argv)
case "git":
fmt.Print(usage)
return nil
default:
PrintUsage()
return nil
}
} | go | func Git(argv []string) error {
usage := `
Valid commands for git:
git:remote Adds git remote of application to repository
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "git:remote":
return gitRemote(argv)
case "git":
fmt.Print(usage)
return nil
default:
PrintUsage()
return nil
}
} | [
"func",
"Git",
"(",
"argv",
"[",
"]",
"string",
")",
"error",
"{",
"usage",
":=",
"`\nValid commands for git:\n\ngit:remote Adds git remote of application to repository\n\nUse 'deis help [command]' to learn more.\n`",
"\n\n",
"switch",
"argv",
"[",
"0",
"]",
"{",
"case",
"\"",
"\"",
":",
"return",
"gitRemote",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"fmt",
".",
"Print",
"(",
"usage",
")",
"\n",
"return",
"nil",
"\n",
"default",
":",
"PrintUsage",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // Git routes git commands to their specific function. | [
"Git",
"routes",
"git",
"commands",
"to",
"their",
"specific",
"function",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/parser/git.go#L11-L30 | train |
deis/deis | builder/sshd/sshd.go | compareKeys | func compareKeys(a, b ssh.PublicKey) bool {
if a.Type() != b.Type() {
return false
}
// The best way to compare just the key seems to be to marshal both and
// then compare the output byte sequence.
return subtle.ConstantTimeCompare(a.Marshal(), b.Marshal()) == 1
} | go | func compareKeys(a, b ssh.PublicKey) bool {
if a.Type() != b.Type() {
return false
}
// The best way to compare just the key seems to be to marshal both and
// then compare the output byte sequence.
return subtle.ConstantTimeCompare(a.Marshal(), b.Marshal()) == 1
} | [
"func",
"compareKeys",
"(",
"a",
",",
"b",
"ssh",
".",
"PublicKey",
")",
"bool",
"{",
"if",
"a",
".",
"Type",
"(",
")",
"!=",
"b",
".",
"Type",
"(",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"// The best way to compare just the key seems to be to marshal both and",
"// then compare the output byte sequence.",
"return",
"subtle",
".",
"ConstantTimeCompare",
"(",
"a",
".",
"Marshal",
"(",
")",
",",
"b",
".",
"Marshal",
"(",
")",
")",
"==",
"1",
"\n",
"}"
] | // compareKeys compares to key files and returns true of they match. | [
"compareKeys",
"compares",
"to",
"key",
"files",
"and",
"returns",
"true",
"of",
"they",
"match",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/sshd/sshd.go#L145-L152 | train |
deis/deis | builder/sshd/sshd.go | Fingerprint | func Fingerprint(key ssh.PublicKey) string {
hash := md5.Sum(key.Marshal())
buf := make([]byte, hex.EncodedLen(len(hash)))
hex.Encode(buf, hash[:])
// We need this in colon notation:
fp := make([]byte, len(buf)+15)
i, j := 0, 0
for ; i < len(buf); i++ {
if i > 0 && i%2 == 0 {
fp[j] = ':'
j++
}
fp[j] = buf[i]
j++
}
return string(fp)
} | go | func Fingerprint(key ssh.PublicKey) string {
hash := md5.Sum(key.Marshal())
buf := make([]byte, hex.EncodedLen(len(hash)))
hex.Encode(buf, hash[:])
// We need this in colon notation:
fp := make([]byte, len(buf)+15)
i, j := 0, 0
for ; i < len(buf); i++ {
if i > 0 && i%2 == 0 {
fp[j] = ':'
j++
}
fp[j] = buf[i]
j++
}
return string(fp)
} | [
"func",
"Fingerprint",
"(",
"key",
"ssh",
".",
"PublicKey",
")",
"string",
"{",
"hash",
":=",
"md5",
".",
"Sum",
"(",
"key",
".",
"Marshal",
"(",
")",
")",
"\n",
"buf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"hex",
".",
"EncodedLen",
"(",
"len",
"(",
"hash",
")",
")",
")",
"\n",
"hex",
".",
"Encode",
"(",
"buf",
",",
"hash",
"[",
":",
"]",
")",
"\n",
"// We need this in colon notation:",
"fp",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"len",
"(",
"buf",
")",
"+",
"15",
")",
"\n\n",
"i",
",",
"j",
":=",
"0",
",",
"0",
"\n",
"for",
";",
"i",
"<",
"len",
"(",
"buf",
")",
";",
"i",
"++",
"{",
"if",
"i",
">",
"0",
"&&",
"i",
"%",
"2",
"==",
"0",
"{",
"fp",
"[",
"j",
"]",
"=",
"':'",
"\n",
"j",
"++",
"\n",
"}",
"\n",
"fp",
"[",
"j",
"]",
"=",
"buf",
"[",
"i",
"]",
"\n",
"j",
"++",
"\n",
"}",
"\n\n",
"return",
"string",
"(",
"fp",
")",
"\n",
"}"
] | // Fingerprint generates a colon-separated fingerprint string from a public key. | [
"Fingerprint",
"generates",
"a",
"colon",
"-",
"separated",
"fingerprint",
"string",
"from",
"a",
"public",
"key",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/sshd/sshd.go#L210-L228 | train |
deis/deis | client/cmd/config.go | ConfigList | func ConfigList(appID string, oneLine bool) error {
c, appID, err := load(appID)
if err != nil {
return err
}
config, err := config.List(c, appID)
if err != nil {
return err
}
var keys []string
for k := range config.Values {
keys = append(keys, k)
}
sort.Strings(keys)
if oneLine {
for _, key := range keys {
fmt.Printf("%s=%s ", key, config.Values[key])
}
fmt.Println()
} else {
fmt.Printf("=== %s Config\n", appID)
configMap := make(map[string]string)
// config.Values is type interface, so it needs to be converted to a string
for _, key := range keys {
configMap[key] = fmt.Sprintf("%v", config.Values[key])
}
fmt.Print(prettyprint.PrettyTabs(configMap, 6))
}
return nil
} | go | func ConfigList(appID string, oneLine bool) error {
c, appID, err := load(appID)
if err != nil {
return err
}
config, err := config.List(c, appID)
if err != nil {
return err
}
var keys []string
for k := range config.Values {
keys = append(keys, k)
}
sort.Strings(keys)
if oneLine {
for _, key := range keys {
fmt.Printf("%s=%s ", key, config.Values[key])
}
fmt.Println()
} else {
fmt.Printf("=== %s Config\n", appID)
configMap := make(map[string]string)
// config.Values is type interface, so it needs to be converted to a string
for _, key := range keys {
configMap[key] = fmt.Sprintf("%v", config.Values[key])
}
fmt.Print(prettyprint.PrettyTabs(configMap, 6))
}
return nil
} | [
"func",
"ConfigList",
"(",
"appID",
"string",
",",
"oneLine",
"bool",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"load",
"(",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"config",
",",
"err",
":=",
"config",
".",
"List",
"(",
"c",
",",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"var",
"keys",
"[",
"]",
"string",
"\n",
"for",
"k",
":=",
"range",
"config",
".",
"Values",
"{",
"keys",
"=",
"append",
"(",
"keys",
",",
"k",
")",
"\n",
"}",
"\n",
"sort",
".",
"Strings",
"(",
"keys",
")",
"\n\n",
"if",
"oneLine",
"{",
"for",
"_",
",",
"key",
":=",
"range",
"keys",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"key",
",",
"config",
".",
"Values",
"[",
"key",
"]",
")",
"\n",
"}",
"\n",
"fmt",
".",
"Println",
"(",
")",
"\n",
"}",
"else",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"appID",
")",
"\n\n",
"configMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n\n",
"// config.Values is type interface, so it needs to be converted to a string",
"for",
"_",
",",
"key",
":=",
"range",
"keys",
"{",
"configMap",
"[",
"key",
"]",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"config",
".",
"Values",
"[",
"key",
"]",
")",
"\n",
"}",
"\n\n",
"fmt",
".",
"Print",
"(",
"prettyprint",
".",
"PrettyTabs",
"(",
"configMap",
",",
"6",
")",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // ConfigList lists an app's config. | [
"ConfigList",
"lists",
"an",
"app",
"s",
"config",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/config.go#L19-L57 | train |
deis/deis | client/cmd/config.go | ConfigSet | func ConfigSet(appID string, configVars []string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
configMap := parseConfig(configVars)
value, ok := configMap["SSH_KEY"]
if ok {
sshKey := value.(string)
if _, err := os.Stat(value.(string)); err == nil {
contents, err := ioutil.ReadFile(value.(string))
if err != nil {
return err
}
sshKey = string(contents)
}
sshRegex := regexp.MustCompile("^-.+ .SA PRIVATE KEY-*")
if !sshRegex.MatchString(sshKey) {
return fmt.Errorf("Could not parse SSH private key:\n %s", sshKey)
}
configMap["SSH_KEY"] = base64.StdEncoding.EncodeToString([]byte(sshKey))
}
fmt.Print("Creating config... ")
quit := progress()
configObj := api.Config{Values: configMap}
configObj, err = config.Set(c, appID, configObj)
quit <- true
<-quit
if err != nil {
return err
}
if release, ok := configObj.Values["DEIS_RELEASE"]; ok {
fmt.Printf("done, %s\n\n", release)
} else {
fmt.Print("done\n\n")
}
return ConfigList(appID, false)
} | go | func ConfigSet(appID string, configVars []string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
configMap := parseConfig(configVars)
value, ok := configMap["SSH_KEY"]
if ok {
sshKey := value.(string)
if _, err := os.Stat(value.(string)); err == nil {
contents, err := ioutil.ReadFile(value.(string))
if err != nil {
return err
}
sshKey = string(contents)
}
sshRegex := regexp.MustCompile("^-.+ .SA PRIVATE KEY-*")
if !sshRegex.MatchString(sshKey) {
return fmt.Errorf("Could not parse SSH private key:\n %s", sshKey)
}
configMap["SSH_KEY"] = base64.StdEncoding.EncodeToString([]byte(sshKey))
}
fmt.Print("Creating config... ")
quit := progress()
configObj := api.Config{Values: configMap}
configObj, err = config.Set(c, appID, configObj)
quit <- true
<-quit
if err != nil {
return err
}
if release, ok := configObj.Values["DEIS_RELEASE"]; ok {
fmt.Printf("done, %s\n\n", release)
} else {
fmt.Print("done\n\n")
}
return ConfigList(appID, false)
} | [
"func",
"ConfigSet",
"(",
"appID",
"string",
",",
"configVars",
"[",
"]",
"string",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"load",
"(",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"configMap",
":=",
"parseConfig",
"(",
"configVars",
")",
"\n\n",
"value",
",",
"ok",
":=",
"configMap",
"[",
"\"",
"\"",
"]",
"\n\n",
"if",
"ok",
"{",
"sshKey",
":=",
"value",
".",
"(",
"string",
")",
"\n\n",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"value",
".",
"(",
"string",
")",
")",
";",
"err",
"==",
"nil",
"{",
"contents",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"value",
".",
"(",
"string",
")",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"sshKey",
"=",
"string",
"(",
"contents",
")",
"\n",
"}",
"\n\n",
"sshRegex",
":=",
"regexp",
".",
"MustCompile",
"(",
"\"",
"\"",
")",
"\n\n",
"if",
"!",
"sshRegex",
".",
"MatchString",
"(",
"sshKey",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\n",
"\"",
",",
"sshKey",
")",
"\n",
"}",
"\n\n",
"configMap",
"[",
"\"",
"\"",
"]",
"=",
"base64",
".",
"StdEncoding",
".",
"EncodeToString",
"(",
"[",
"]",
"byte",
"(",
"sshKey",
")",
")",
"\n",
"}",
"\n\n",
"fmt",
".",
"Print",
"(",
"\"",
"\"",
")",
"\n\n",
"quit",
":=",
"progress",
"(",
")",
"\n",
"configObj",
":=",
"api",
".",
"Config",
"{",
"Values",
":",
"configMap",
"}",
"\n",
"configObj",
",",
"err",
"=",
"config",
".",
"Set",
"(",
"c",
",",
"appID",
",",
"configObj",
")",
"\n\n",
"quit",
"<-",
"true",
"\n",
"<-",
"quit",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"release",
",",
"ok",
":=",
"configObj",
".",
"Values",
"[",
"\"",
"\"",
"]",
";",
"ok",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\\n",
"\"",
",",
"release",
")",
"\n",
"}",
"else",
"{",
"fmt",
".",
"Print",
"(",
"\"",
"\\n",
"\\n",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"ConfigList",
"(",
"appID",
",",
"false",
")",
"\n",
"}"
] | // ConfigSet sets an app's config variables. | [
"ConfigSet",
"sets",
"an",
"app",
"s",
"config",
"variables",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/config.go#L60-L113 | train |
deis/deis | client/cmd/config.go | ConfigUnset | func ConfigUnset(appID string, configVars []string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
fmt.Print("Removing config... ")
quit := progress()
configObj := api.Config{}
valuesMap := make(map[string]interface{})
for _, configVar := range configVars {
valuesMap[configVar] = nil
}
configObj.Values = valuesMap
_, err = config.Set(c, appID, configObj)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Print("done\n\n")
return ConfigList(appID, false)
} | go | func ConfigUnset(appID string, configVars []string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
fmt.Print("Removing config... ")
quit := progress()
configObj := api.Config{}
valuesMap := make(map[string]interface{})
for _, configVar := range configVars {
valuesMap[configVar] = nil
}
configObj.Values = valuesMap
_, err = config.Set(c, appID, configObj)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Print("done\n\n")
return ConfigList(appID, false)
} | [
"func",
"ConfigUnset",
"(",
"appID",
"string",
",",
"configVars",
"[",
"]",
"string",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"load",
"(",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Print",
"(",
"\"",
"\"",
")",
"\n\n",
"quit",
":=",
"progress",
"(",
")",
"\n\n",
"configObj",
":=",
"api",
".",
"Config",
"{",
"}",
"\n\n",
"valuesMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n\n",
"for",
"_",
",",
"configVar",
":=",
"range",
"configVars",
"{",
"valuesMap",
"[",
"configVar",
"]",
"=",
"nil",
"\n",
"}",
"\n\n",
"configObj",
".",
"Values",
"=",
"valuesMap",
"\n\n",
"_",
",",
"err",
"=",
"config",
".",
"Set",
"(",
"c",
",",
"appID",
",",
"configObj",
")",
"\n\n",
"quit",
"<-",
"true",
"\n",
"<-",
"quit",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Print",
"(",
"\"",
"\\n",
"\\n",
"\"",
")",
"\n\n",
"return",
"ConfigList",
"(",
"appID",
",",
"false",
")",
"\n",
"}"
] | // ConfigUnset removes a config variable from an app. | [
"ConfigUnset",
"removes",
"a",
"config",
"variable",
"from",
"an",
"app",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/config.go#L116-L149 | train |
deis/deis | client/cmd/config.go | ConfigPull | func ConfigPull(appID string, interactive bool, overwrite bool) error {
filename := ".env"
if !overwrite {
if _, err := os.Stat(filename); err == nil {
return fmt.Errorf("%s already exists, pass -o to overwrite", filename)
}
}
c, appID, err := load(appID)
if err != nil {
return err
}
configVars, err := config.List(c, appID)
if interactive {
contents, err := ioutil.ReadFile(filename)
if err != nil {
return err
}
localConfigVars := strings.Split(string(contents), "\n")
configMap := parseConfig(localConfigVars[:len(localConfigVars)-1])
for key, value := range configVars.Values {
localValue, ok := configMap[key]
if ok {
if value != localValue {
var confirm string
fmt.Printf("%s: overwrite %s with %s? (y/N) ", key, localValue, value)
fmt.Scanln(&confirm)
if strings.ToLower(confirm) == "y" {
configMap[key] = value
}
}
} else {
configMap[key] = value
}
}
return ioutil.WriteFile(filename, []byte(formatConfig(configMap)), 0755)
}
return ioutil.WriteFile(filename, []byte(formatConfig(configVars.Values)), 0755)
} | go | func ConfigPull(appID string, interactive bool, overwrite bool) error {
filename := ".env"
if !overwrite {
if _, err := os.Stat(filename); err == nil {
return fmt.Errorf("%s already exists, pass -o to overwrite", filename)
}
}
c, appID, err := load(appID)
if err != nil {
return err
}
configVars, err := config.List(c, appID)
if interactive {
contents, err := ioutil.ReadFile(filename)
if err != nil {
return err
}
localConfigVars := strings.Split(string(contents), "\n")
configMap := parseConfig(localConfigVars[:len(localConfigVars)-1])
for key, value := range configVars.Values {
localValue, ok := configMap[key]
if ok {
if value != localValue {
var confirm string
fmt.Printf("%s: overwrite %s with %s? (y/N) ", key, localValue, value)
fmt.Scanln(&confirm)
if strings.ToLower(confirm) == "y" {
configMap[key] = value
}
}
} else {
configMap[key] = value
}
}
return ioutil.WriteFile(filename, []byte(formatConfig(configMap)), 0755)
}
return ioutil.WriteFile(filename, []byte(formatConfig(configVars.Values)), 0755)
} | [
"func",
"ConfigPull",
"(",
"appID",
"string",
",",
"interactive",
"bool",
",",
"overwrite",
"bool",
")",
"error",
"{",
"filename",
":=",
"\"",
"\"",
"\n\n",
"if",
"!",
"overwrite",
"{",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"filename",
")",
";",
"err",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"filename",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"c",
",",
"appID",
",",
"err",
":=",
"load",
"(",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"configVars",
",",
"err",
":=",
"config",
".",
"List",
"(",
"c",
",",
"appID",
")",
"\n\n",
"if",
"interactive",
"{",
"contents",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"filename",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"localConfigVars",
":=",
"strings",
".",
"Split",
"(",
"string",
"(",
"contents",
")",
",",
"\"",
"\\n",
"\"",
")",
"\n\n",
"configMap",
":=",
"parseConfig",
"(",
"localConfigVars",
"[",
":",
"len",
"(",
"localConfigVars",
")",
"-",
"1",
"]",
")",
"\n\n",
"for",
"key",
",",
"value",
":=",
"range",
"configVars",
".",
"Values",
"{",
"localValue",
",",
"ok",
":=",
"configMap",
"[",
"key",
"]",
"\n\n",
"if",
"ok",
"{",
"if",
"value",
"!=",
"localValue",
"{",
"var",
"confirm",
"string",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"key",
",",
"localValue",
",",
"value",
")",
"\n\n",
"fmt",
".",
"Scanln",
"(",
"&",
"confirm",
")",
"\n\n",
"if",
"strings",
".",
"ToLower",
"(",
"confirm",
")",
"==",
"\"",
"\"",
"{",
"configMap",
"[",
"key",
"]",
"=",
"value",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"else",
"{",
"configMap",
"[",
"key",
"]",
"=",
"value",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"ioutil",
".",
"WriteFile",
"(",
"filename",
",",
"[",
"]",
"byte",
"(",
"formatConfig",
"(",
"configMap",
")",
")",
",",
"0755",
")",
"\n",
"}",
"\n\n",
"return",
"ioutil",
".",
"WriteFile",
"(",
"filename",
",",
"[",
"]",
"byte",
"(",
"formatConfig",
"(",
"configVars",
".",
"Values",
")",
")",
",",
"0755",
")",
"\n",
"}"
] | // ConfigPull pulls an app's config to a file. | [
"ConfigPull",
"pulls",
"an",
"app",
"s",
"config",
"to",
"a",
"file",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/config.go#L152-L202 | train |
deis/deis | client/cmd/config.go | ConfigPush | func ConfigPush(appID string, fileName string) error {
contents, err := ioutil.ReadFile(fileName)
if err != nil {
return err
}
config := strings.Split(string(contents), "\n")
return ConfigSet(appID, config[:len(config)-1])
} | go | func ConfigPush(appID string, fileName string) error {
contents, err := ioutil.ReadFile(fileName)
if err != nil {
return err
}
config := strings.Split(string(contents), "\n")
return ConfigSet(appID, config[:len(config)-1])
} | [
"func",
"ConfigPush",
"(",
"appID",
"string",
",",
"fileName",
"string",
")",
"error",
"{",
"contents",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"fileName",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"config",
":=",
"strings",
".",
"Split",
"(",
"string",
"(",
"contents",
")",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"return",
"ConfigSet",
"(",
"appID",
",",
"config",
"[",
":",
"len",
"(",
"config",
")",
"-",
"1",
"]",
")",
"\n",
"}"
] | // ConfigPush pushes an app's config from a file. | [
"ConfigPush",
"pushes",
"an",
"app",
"s",
"config",
"from",
"a",
"file",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/config.go#L205-L214 | train |
deis/deis | deisctl/backend/fleet/stop.go | Stop | func (c *FleetClient) Stop(targets []string, wg *sync.WaitGroup, out, ew io.Writer) {
// expand @* targets
expandedTargets, err := c.expandTargets(targets)
if err != nil {
fmt.Fprintln(ew, err.Error())
return
}
for _, target := range expandedTargets {
wg.Add(1)
go doStop(c, target, wg, out, ew)
}
return
} | go | func (c *FleetClient) Stop(targets []string, wg *sync.WaitGroup, out, ew io.Writer) {
// expand @* targets
expandedTargets, err := c.expandTargets(targets)
if err != nil {
fmt.Fprintln(ew, err.Error())
return
}
for _, target := range expandedTargets {
wg.Add(1)
go doStop(c, target, wg, out, ew)
}
return
} | [
"func",
"(",
"c",
"*",
"FleetClient",
")",
"Stop",
"(",
"targets",
"[",
"]",
"string",
",",
"wg",
"*",
"sync",
".",
"WaitGroup",
",",
"out",
",",
"ew",
"io",
".",
"Writer",
")",
"{",
"// expand @* targets",
"expandedTargets",
",",
"err",
":=",
"c",
".",
"expandTargets",
"(",
"targets",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Fprintln",
"(",
"ew",
",",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"target",
":=",
"range",
"expandedTargets",
"{",
"wg",
".",
"Add",
"(",
"1",
")",
"\n",
"go",
"doStop",
"(",
"c",
",",
"target",
",",
"wg",
",",
"out",
",",
"ew",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // Stop units and wait for their desiredState | [
"Stop",
"units",
"and",
"wait",
"for",
"their",
"desiredState"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/stop.go#L16-L29 | train |
deis/deis | builder/etcd/etcd.go | genSSHKeys | func genSSHKeys(c cookoo.Context) error {
// Generate a new key
out, err := exec.Command("ssh-keygen", "-A").CombinedOutput()
if err != nil {
log.Infof(c, "ssh-keygen: %s", out)
log.Errf(c, "Failed to generate SSH keys: %s", err)
return err
}
return nil
} | go | func genSSHKeys(c cookoo.Context) error {
// Generate a new key
out, err := exec.Command("ssh-keygen", "-A").CombinedOutput()
if err != nil {
log.Infof(c, "ssh-keygen: %s", out)
log.Errf(c, "Failed to generate SSH keys: %s", err)
return err
}
return nil
} | [
"func",
"genSSHKeys",
"(",
"c",
"cookoo",
".",
"Context",
")",
"error",
"{",
"// Generate a new key",
"out",
",",
"err",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
".",
"CombinedOutput",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Infof",
"(",
"c",
",",
"\"",
"\"",
",",
"out",
")",
"\n",
"log",
".",
"Errf",
"(",
"c",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // genSshKeys generates the default set of SSH host keys. | [
"genSshKeys",
"generates",
"the",
"default",
"set",
"of",
"SSH",
"host",
"keys",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/etcd/etcd.go#L314-L323 | train |
deis/deis | builder/etcd/etcd.go | checkRetry | func checkRetry(c *etcd.Cluster, numReqs int, last http.Response, err error) error {
if numReqs > retryCycles*len(c.Machines) {
return fmt.Errorf("Tried and failed %d cluster connections: %s", retryCycles, err)
}
switch last.StatusCode {
case 0:
return nil
case 500:
time.Sleep(retrySleep)
return nil
case 200:
return nil
default:
return fmt.Errorf("Unhandled HTTP Error: %s %d", last.Status, last.StatusCode)
}
} | go | func checkRetry(c *etcd.Cluster, numReqs int, last http.Response, err error) error {
if numReqs > retryCycles*len(c.Machines) {
return fmt.Errorf("Tried and failed %d cluster connections: %s", retryCycles, err)
}
switch last.StatusCode {
case 0:
return nil
case 500:
time.Sleep(retrySleep)
return nil
case 200:
return nil
default:
return fmt.Errorf("Unhandled HTTP Error: %s %d", last.Status, last.StatusCode)
}
} | [
"func",
"checkRetry",
"(",
"c",
"*",
"etcd",
".",
"Cluster",
",",
"numReqs",
"int",
",",
"last",
"http",
".",
"Response",
",",
"err",
"error",
")",
"error",
"{",
"if",
"numReqs",
">",
"retryCycles",
"*",
"len",
"(",
"c",
".",
"Machines",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"retryCycles",
",",
"err",
")",
"\n",
"}",
"\n\n",
"switch",
"last",
".",
"StatusCode",
"{",
"case",
"0",
":",
"return",
"nil",
"\n",
"case",
"500",
":",
"time",
".",
"Sleep",
"(",
"retrySleep",
")",
"\n",
"return",
"nil",
"\n",
"case",
"200",
":",
"return",
"nil",
"\n",
"default",
":",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"last",
".",
"Status",
",",
"last",
".",
"StatusCode",
")",
"\n",
"}",
"\n",
"}"
] | // checkRetry overrides etcd.DefaultCheckRetry.
//
// It adds configurable number of retries and configurable timesouts. | [
"checkRetry",
"overrides",
"etcd",
".",
"DefaultCheckRetry",
".",
"It",
"adds",
"configurable",
"number",
"of",
"retries",
"and",
"configurable",
"timesouts",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/etcd/etcd.go#L519-L535 | train |
deis/deis | deisctl/backend/fleet/start.go | Start | func (c *FleetClient) Start(targets []string, wg *sync.WaitGroup, out, ew io.Writer) {
// expand @* targets
expandedTargets, err := c.expandTargets(targets)
if err != nil {
io.WriteString(ew, err.Error())
return
}
for _, target := range expandedTargets {
wg.Add(1)
go doStart(c, target, wg, out, ew)
}
return
} | go | func (c *FleetClient) Start(targets []string, wg *sync.WaitGroup, out, ew io.Writer) {
// expand @* targets
expandedTargets, err := c.expandTargets(targets)
if err != nil {
io.WriteString(ew, err.Error())
return
}
for _, target := range expandedTargets {
wg.Add(1)
go doStart(c, target, wg, out, ew)
}
return
} | [
"func",
"(",
"c",
"*",
"FleetClient",
")",
"Start",
"(",
"targets",
"[",
"]",
"string",
",",
"wg",
"*",
"sync",
".",
"WaitGroup",
",",
"out",
",",
"ew",
"io",
".",
"Writer",
")",
"{",
"// expand @* targets",
"expandedTargets",
",",
"err",
":=",
"c",
".",
"expandTargets",
"(",
"targets",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"io",
".",
"WriteString",
"(",
"ew",
",",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"target",
":=",
"range",
"expandedTargets",
"{",
"wg",
".",
"Add",
"(",
"1",
")",
"\n",
"go",
"doStart",
"(",
"c",
",",
"target",
",",
"wg",
",",
"out",
",",
"ew",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // Start units and wait for their desiredState | [
"Start",
"units",
"and",
"wait",
"for",
"their",
"desiredState"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/start.go#L14-L27 | train |
deis/deis | deisctl/cmd/cmd.go | Scale | func Scale(targets []string, b backend.Backend) error {
var wg sync.WaitGroup
for _, target := range targets {
component, num, err := splitScaleTarget(target)
if err != nil {
return err
}
// the router, registry, and store-gateway are the only component that can scale at the moment
if !strings.Contains(component, "router") && !strings.Contains(component, "registry") && !strings.Contains(component, "store-gateway") {
return fmt.Errorf("cannot scale %s component", component)
}
b.Scale(component, num, &wg, Stdout, Stderr)
wg.Wait()
}
return nil
} | go | func Scale(targets []string, b backend.Backend) error {
var wg sync.WaitGroup
for _, target := range targets {
component, num, err := splitScaleTarget(target)
if err != nil {
return err
}
// the router, registry, and store-gateway are the only component that can scale at the moment
if !strings.Contains(component, "router") && !strings.Contains(component, "registry") && !strings.Contains(component, "store-gateway") {
return fmt.Errorf("cannot scale %s component", component)
}
b.Scale(component, num, &wg, Stdout, Stderr)
wg.Wait()
}
return nil
} | [
"func",
"Scale",
"(",
"targets",
"[",
"]",
"string",
",",
"b",
"backend",
".",
"Backend",
")",
"error",
"{",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n\n",
"for",
"_",
",",
"target",
":=",
"range",
"targets",
"{",
"component",
",",
"num",
",",
"err",
":=",
"splitScaleTarget",
"(",
"target",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"// the router, registry, and store-gateway are the only component that can scale at the moment",
"if",
"!",
"strings",
".",
"Contains",
"(",
"component",
",",
"\"",
"\"",
")",
"&&",
"!",
"strings",
".",
"Contains",
"(",
"component",
",",
"\"",
"\"",
")",
"&&",
"!",
"strings",
".",
"Contains",
"(",
"component",
",",
"\"",
"\"",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"component",
")",
"\n",
"}",
"\n",
"b",
".",
"Scale",
"(",
"component",
",",
"num",
",",
"&",
"wg",
",",
"Stdout",
",",
"Stderr",
")",
"\n",
"wg",
".",
"Wait",
"(",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Scale grows or shrinks the number of running components.
// Currently "router", "registry" and "store-gateway" are the only types that can be scaled. | [
"Scale",
"grows",
"or",
"shrinks",
"the",
"number",
"of",
"running",
"components",
".",
"Currently",
"router",
"registry",
"and",
"store",
"-",
"gateway",
"are",
"the",
"only",
"types",
"that",
"can",
"be",
"scaled",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/cmd/cmd.go#L56-L72 | train |
deis/deis | deisctl/cmd/cmd.go | Start | func Start(targets []string, b backend.Backend) error {
// if target is platform, install all services
if len(targets) == 1 {
switch targets[0] {
case PlatformCommand:
return StartPlatform(b, false)
case StatelessPlatformCommand:
return StartPlatform(b, true)
}
}
var wg sync.WaitGroup
b.Start(targets, &wg, Stdout, Stderr)
wg.Wait()
return nil
} | go | func Start(targets []string, b backend.Backend) error {
// if target is platform, install all services
if len(targets) == 1 {
switch targets[0] {
case PlatformCommand:
return StartPlatform(b, false)
case StatelessPlatformCommand:
return StartPlatform(b, true)
}
}
var wg sync.WaitGroup
b.Start(targets, &wg, Stdout, Stderr)
wg.Wait()
return nil
} | [
"func",
"Start",
"(",
"targets",
"[",
"]",
"string",
",",
"b",
"backend",
".",
"Backend",
")",
"error",
"{",
"// if target is platform, install all services",
"if",
"len",
"(",
"targets",
")",
"==",
"1",
"{",
"switch",
"targets",
"[",
"0",
"]",
"{",
"case",
"PlatformCommand",
":",
"return",
"StartPlatform",
"(",
"b",
",",
"false",
")",
"\n",
"case",
"StatelessPlatformCommand",
":",
"return",
"StartPlatform",
"(",
"b",
",",
"true",
")",
"\n",
"}",
"\n",
"}",
"\n",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n\n",
"b",
".",
"Start",
"(",
"targets",
",",
"&",
"wg",
",",
"Stdout",
",",
"Stderr",
")",
"\n",
"wg",
".",
"Wait",
"(",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // Start activates the specified components. | [
"Start",
"activates",
"the",
"specified",
"components",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/cmd/cmd.go#L75-L92 | train |
deis/deis | deisctl/cmd/cmd.go | RollingRestart | func RollingRestart(target string, b backend.Backend) error {
var wg sync.WaitGroup
b.RollingRestart(target, &wg, Stdout, Stderr)
wg.Wait()
return nil
} | go | func RollingRestart(target string, b backend.Backend) error {
var wg sync.WaitGroup
b.RollingRestart(target, &wg, Stdout, Stderr)
wg.Wait()
return nil
} | [
"func",
"RollingRestart",
"(",
"target",
"string",
",",
"b",
"backend",
".",
"Backend",
")",
"error",
"{",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n\n",
"b",
".",
"RollingRestart",
"(",
"target",
",",
"&",
"wg",
",",
"Stdout",
",",
"Stderr",
")",
"\n",
"wg",
".",
"Wait",
"(",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // RollingRestart restart instance unit in a rolling manner | [
"RollingRestart",
"restart",
"instance",
"unit",
"in",
"a",
"rolling",
"manner"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/cmd/cmd.go#L95-L102 | train |
deis/deis | deisctl/cmd/cmd.go | CheckRequiredKeys | func CheckRequiredKeys(cb config.Backend) error {
if err := config.CheckConfig("/deis/platform/", "domain", cb); err != nil {
return fmt.Errorf(`Missing platform domain, use:
deisctl config platform set domain=<your-domain>`)
}
if err := config.CheckConfig("/deis/platform/", "sshPrivateKey", cb); err != nil {
fmt.Printf(`Warning: Missing sshPrivateKey, "deis run" will be unavailable. Use:
deisctl config platform set sshPrivateKey=<path-to-key>
`)
}
return nil
} | go | func CheckRequiredKeys(cb config.Backend) error {
if err := config.CheckConfig("/deis/platform/", "domain", cb); err != nil {
return fmt.Errorf(`Missing platform domain, use:
deisctl config platform set domain=<your-domain>`)
}
if err := config.CheckConfig("/deis/platform/", "sshPrivateKey", cb); err != nil {
fmt.Printf(`Warning: Missing sshPrivateKey, "deis run" will be unavailable. Use:
deisctl config platform set sshPrivateKey=<path-to-key>
`)
}
return nil
} | [
"func",
"CheckRequiredKeys",
"(",
"cb",
"config",
".",
"Backend",
")",
"error",
"{",
"if",
"err",
":=",
"config",
".",
"CheckConfig",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"cb",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"`Missing platform domain, use:\ndeisctl config platform set domain=<your-domain>`",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"config",
".",
"CheckConfig",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"cb",
")",
";",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Printf",
"(",
"`Warning: Missing sshPrivateKey, \"deis run\" will be unavailable. Use:\ndeisctl config platform set sshPrivateKey=<path-to-key>\n`",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // CheckRequiredKeys exist in config backend | [
"CheckRequiredKeys",
"exist",
"in",
"config",
"backend"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/cmd/cmd.go#L105-L117 | train |
deis/deis | deisctl/cmd/cmd.go | Restart | func Restart(targets []string, b backend.Backend) error {
// act as if the user called "stop" and then "start"
if err := Stop(targets, b); err != nil {
return err
}
return Start(targets, b)
} | go | func Restart(targets []string, b backend.Backend) error {
// act as if the user called "stop" and then "start"
if err := Stop(targets, b); err != nil {
return err
}
return Start(targets, b)
} | [
"func",
"Restart",
"(",
"targets",
"[",
"]",
"string",
",",
"b",
"backend",
".",
"Backend",
")",
"error",
"{",
"// act as if the user called \"stop\" and then \"start\"",
"if",
"err",
":=",
"Stop",
"(",
"targets",
",",
"b",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"Start",
"(",
"targets",
",",
"b",
")",
"\n",
"}"
] | // Restart stops and then starts the specified components. | [
"Restart",
"stops",
"and",
"then",
"starts",
"the",
"specified",
"components",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/cmd/cmd.go#L241-L249 | train |
deis/deis | deisctl/cmd/cmd.go | Journal | func Journal(targets []string, b backend.Backend) error {
for _, target := range targets {
if err := b.Journal(target); err != nil {
return err
}
}
return nil
} | go | func Journal(targets []string, b backend.Backend) error {
for _, target := range targets {
if err := b.Journal(target); err != nil {
return err
}
}
return nil
} | [
"func",
"Journal",
"(",
"targets",
"[",
"]",
"string",
",",
"b",
"backend",
".",
"Backend",
")",
"error",
"{",
"for",
"_",
",",
"target",
":=",
"range",
"targets",
"{",
"if",
"err",
":=",
"b",
".",
"Journal",
"(",
"target",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Journal prints log output for the specified components. | [
"Journal",
"prints",
"log",
"output",
"for",
"the",
"specified",
"components",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/cmd/cmd.go#L263-L271 | train |
deis/deis | deisctl/cmd/cmd.go | Uninstall | func Uninstall(targets []string, b backend.Backend) error {
if len(targets) == 1 {
switch targets[0] {
case PlatformCommand:
return UninstallPlatform(b, false)
case StatelessPlatformCommand:
return UninstallPlatform(b, true)
}
}
var wg sync.WaitGroup
// uninstall the specific target
b.Destroy(targets, &wg, Stdout, Stderr)
wg.Wait()
return nil
} | go | func Uninstall(targets []string, b backend.Backend) error {
if len(targets) == 1 {
switch targets[0] {
case PlatformCommand:
return UninstallPlatform(b, false)
case StatelessPlatformCommand:
return UninstallPlatform(b, true)
}
}
var wg sync.WaitGroup
// uninstall the specific target
b.Destroy(targets, &wg, Stdout, Stderr)
wg.Wait()
return nil
} | [
"func",
"Uninstall",
"(",
"targets",
"[",
"]",
"string",
",",
"b",
"backend",
".",
"Backend",
")",
"error",
"{",
"if",
"len",
"(",
"targets",
")",
"==",
"1",
"{",
"switch",
"targets",
"[",
"0",
"]",
"{",
"case",
"PlatformCommand",
":",
"return",
"UninstallPlatform",
"(",
"b",
",",
"false",
")",
"\n",
"case",
"StatelessPlatformCommand",
":",
"return",
"UninstallPlatform",
"(",
"b",
",",
"true",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n\n",
"// uninstall the specific target",
"b",
".",
"Destroy",
"(",
"targets",
",",
"&",
"wg",
",",
"Stdout",
",",
"Stderr",
")",
"\n",
"wg",
".",
"Wait",
"(",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // Uninstall unloads the definitions of the specified components.
// After Uninstall, the components will be unavailable until Install is called. | [
"Uninstall",
"unloads",
"the",
"definitions",
"of",
"the",
"specified",
"components",
".",
"After",
"Uninstall",
"the",
"components",
"will",
"be",
"unavailable",
"until",
"Install",
"is",
"called",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/cmd/cmd.go#L335-L352 | train |
deis/deis | deisctl/cmd/cmd.go | RefreshUnits | func RefreshUnits(unitDir, tag, rootURL string) error {
unitDir = utils.ResolvePath(unitDir)
decoratorDir := filepath.Join(unitDir, "decorators")
// create the target dir if necessary
if err := os.MkdirAll(decoratorDir, 0755); err != nil {
return err
}
// download and save the unit files to the specified path
for _, unit := range units.Names {
unitSrc := rootURL + tag + "/deisctl/units/" + unit + ".service"
unitDest := filepath.Join(unitDir, unit+".service")
if err := net.Download(unitSrc, unitDest); err != nil {
return err
}
fmt.Printf("Refreshed %s unit from %s\n", unit, tag)
decoratorSrc := rootURL + tag + "/deisctl/units/decorators/" + unit + ".service.decorator"
decoratorDest := filepath.Join(decoratorDir, unit+".service.decorator")
if err := net.Download(decoratorSrc, decoratorDest); err != nil {
if err.Error() == "404 Not Found" {
fmt.Printf("Decorator for %s not found in %s\n", unit, tag)
} else {
return err
}
} else {
fmt.Printf("Refreshed %s decorator from %s\n", unit, tag)
}
}
return nil
} | go | func RefreshUnits(unitDir, tag, rootURL string) error {
unitDir = utils.ResolvePath(unitDir)
decoratorDir := filepath.Join(unitDir, "decorators")
// create the target dir if necessary
if err := os.MkdirAll(decoratorDir, 0755); err != nil {
return err
}
// download and save the unit files to the specified path
for _, unit := range units.Names {
unitSrc := rootURL + tag + "/deisctl/units/" + unit + ".service"
unitDest := filepath.Join(unitDir, unit+".service")
if err := net.Download(unitSrc, unitDest); err != nil {
return err
}
fmt.Printf("Refreshed %s unit from %s\n", unit, tag)
decoratorSrc := rootURL + tag + "/deisctl/units/decorators/" + unit + ".service.decorator"
decoratorDest := filepath.Join(decoratorDir, unit+".service.decorator")
if err := net.Download(decoratorSrc, decoratorDest); err != nil {
if err.Error() == "404 Not Found" {
fmt.Printf("Decorator for %s not found in %s\n", unit, tag)
} else {
return err
}
} else {
fmt.Printf("Refreshed %s decorator from %s\n", unit, tag)
}
}
return nil
} | [
"func",
"RefreshUnits",
"(",
"unitDir",
",",
"tag",
",",
"rootURL",
"string",
")",
"error",
"{",
"unitDir",
"=",
"utils",
".",
"ResolvePath",
"(",
"unitDir",
")",
"\n",
"decoratorDir",
":=",
"filepath",
".",
"Join",
"(",
"unitDir",
",",
"\"",
"\"",
")",
"\n",
"// create the target dir if necessary",
"if",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"decoratorDir",
",",
"0755",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"// download and save the unit files to the specified path",
"for",
"_",
",",
"unit",
":=",
"range",
"units",
".",
"Names",
"{",
"unitSrc",
":=",
"rootURL",
"+",
"tag",
"+",
"\"",
"\"",
"+",
"unit",
"+",
"\"",
"\"",
"\n",
"unitDest",
":=",
"filepath",
".",
"Join",
"(",
"unitDir",
",",
"unit",
"+",
"\"",
"\"",
")",
"\n",
"if",
"err",
":=",
"net",
".",
"Download",
"(",
"unitSrc",
",",
"unitDest",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"unit",
",",
"tag",
")",
"\n",
"decoratorSrc",
":=",
"rootURL",
"+",
"tag",
"+",
"\"",
"\"",
"+",
"unit",
"+",
"\"",
"\"",
"\n",
"decoratorDest",
":=",
"filepath",
".",
"Join",
"(",
"decoratorDir",
",",
"unit",
"+",
"\"",
"\"",
")",
"\n",
"if",
"err",
":=",
"net",
".",
"Download",
"(",
"decoratorSrc",
",",
"decoratorDest",
")",
";",
"err",
"!=",
"nil",
"{",
"if",
"err",
".",
"Error",
"(",
")",
"==",
"\"",
"\"",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"unit",
",",
"tag",
")",
"\n",
"}",
"else",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"else",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"unit",
",",
"tag",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // RefreshUnits overwrites local unit files with those requested.
// Downloading from the Deis project GitHub URL by tag or SHA is the only mechanism
// currently supported. | [
"RefreshUnits",
"overwrites",
"local",
"unit",
"files",
"with",
"those",
"requested",
".",
"Downloading",
"from",
"the",
"Deis",
"project",
"GitHub",
"URL",
"by",
"tag",
"or",
"SHA",
"is",
"the",
"only",
"mechanism",
"currently",
"supported",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/cmd/cmd.go#L425-L453 | train |
deis/deis | deisctl/cmd/cmd.go | SSH | func SSH(target string, cmd []string, b backend.Backend) error {
if len(cmd) > 0 {
return b.SSHExec(target, strings.Join(cmd, " "))
}
return b.SSH(target)
} | go | func SSH(target string, cmd []string, b backend.Backend) error {
if len(cmd) > 0 {
return b.SSHExec(target, strings.Join(cmd, " "))
}
return b.SSH(target)
} | [
"func",
"SSH",
"(",
"target",
"string",
",",
"cmd",
"[",
"]",
"string",
",",
"b",
"backend",
".",
"Backend",
")",
"error",
"{",
"if",
"len",
"(",
"cmd",
")",
">",
"0",
"{",
"return",
"b",
".",
"SSHExec",
"(",
"target",
",",
"strings",
".",
"Join",
"(",
"cmd",
",",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n\n",
"return",
"b",
".",
"SSH",
"(",
"target",
")",
"\n",
"}"
] | // SSH opens an interactive shell on a machine in the cluster | [
"SSH",
"opens",
"an",
"interactive",
"shell",
"on",
"a",
"machine",
"in",
"the",
"cluster"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/cmd/cmd.go#L456-L463 | train |
deis/deis | client/parser/tags.go | Tags | func Tags(argv []string) error {
usage := `
Valid commands for tags:
tags:list list tags for an app
tags:set set tags for an app
tags:unset unset tags for an app
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "tags:list":
return tagsList(argv)
case "tags:set":
return tagsSet(argv)
case "tags:unset":
return tagsUnset(argv)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "tags" {
argv[0] = "tags:list"
return tagsList(argv)
}
PrintUsage()
return nil
}
} | go | func Tags(argv []string) error {
usage := `
Valid commands for tags:
tags:list list tags for an app
tags:set set tags for an app
tags:unset unset tags for an app
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "tags:list":
return tagsList(argv)
case "tags:set":
return tagsSet(argv)
case "tags:unset":
return tagsUnset(argv)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "tags" {
argv[0] = "tags:list"
return tagsList(argv)
}
PrintUsage()
return nil
}
} | [
"func",
"Tags",
"(",
"argv",
"[",
"]",
"string",
")",
"error",
"{",
"usage",
":=",
"`\nValid commands for tags:\n\ntags:list list tags for an app\ntags:set set tags for an app\ntags:unset unset tags for an app\n\nUse 'deis help [command]' to learn more.\n`",
"\n\n",
"switch",
"argv",
"[",
"0",
"]",
"{",
"case",
"\"",
"\"",
":",
"return",
"tagsList",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"tagsSet",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"tagsUnset",
"(",
"argv",
")",
"\n",
"default",
":",
"if",
"printHelp",
"(",
"argv",
",",
"usage",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"argv",
"[",
"0",
"]",
"==",
"\"",
"\"",
"{",
"argv",
"[",
"0",
"]",
"=",
"\"",
"\"",
"\n",
"return",
"tagsList",
"(",
"argv",
")",
"\n",
"}",
"\n\n",
"PrintUsage",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // Tags routes tags commands to their specific function | [
"Tags",
"routes",
"tags",
"commands",
"to",
"their",
"specific",
"function"
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/parser/tags.go#L9-L40 | train |
deis/deis | logger/storage/factory.go | NewAdapter | func NewAdapter(storeageAdapterType string) (Adapter, error) {
if storeageAdapterType == "" || storeageAdapterType == "file" {
adapter, err := file.NewStorageAdapter(LogRoot)
if err != nil {
return nil, err
}
return adapter, nil
}
match := memoryAdapterRegex.FindStringSubmatch(storeageAdapterType)
if match == nil {
return nil, fmt.Errorf("Unrecognized storage adapter type: '%s'", storeageAdapterType)
}
sizeStr := match[1]
if sizeStr == "" {
sizeStr = "1000"
}
size, err := strconv.Atoi(sizeStr)
if err != nil {
return nil, err
}
adapter, err := ringbuffer.NewStorageAdapter(size)
if err != nil {
return nil, err
}
return adapter, nil
} | go | func NewAdapter(storeageAdapterType string) (Adapter, error) {
if storeageAdapterType == "" || storeageAdapterType == "file" {
adapter, err := file.NewStorageAdapter(LogRoot)
if err != nil {
return nil, err
}
return adapter, nil
}
match := memoryAdapterRegex.FindStringSubmatch(storeageAdapterType)
if match == nil {
return nil, fmt.Errorf("Unrecognized storage adapter type: '%s'", storeageAdapterType)
}
sizeStr := match[1]
if sizeStr == "" {
sizeStr = "1000"
}
size, err := strconv.Atoi(sizeStr)
if err != nil {
return nil, err
}
adapter, err := ringbuffer.NewStorageAdapter(size)
if err != nil {
return nil, err
}
return adapter, nil
} | [
"func",
"NewAdapter",
"(",
"storeageAdapterType",
"string",
")",
"(",
"Adapter",
",",
"error",
")",
"{",
"if",
"storeageAdapterType",
"==",
"\"",
"\"",
"||",
"storeageAdapterType",
"==",
"\"",
"\"",
"{",
"adapter",
",",
"err",
":=",
"file",
".",
"NewStorageAdapter",
"(",
"LogRoot",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"adapter",
",",
"nil",
"\n",
"}",
"\n",
"match",
":=",
"memoryAdapterRegex",
".",
"FindStringSubmatch",
"(",
"storeageAdapterType",
")",
"\n",
"if",
"match",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"storeageAdapterType",
")",
"\n",
"}",
"\n",
"sizeStr",
":=",
"match",
"[",
"1",
"]",
"\n",
"if",
"sizeStr",
"==",
"\"",
"\"",
"{",
"sizeStr",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"size",
",",
"err",
":=",
"strconv",
".",
"Atoi",
"(",
"sizeStr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"adapter",
",",
"err",
":=",
"ringbuffer",
".",
"NewStorageAdapter",
"(",
"size",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"adapter",
",",
"nil",
"\n",
"}"
] | // NewAdapter returns a pointer to an appropriate implementation of the Adapter interface, as
// determined by the storeageAdapterType string it is passed. | [
"NewAdapter",
"returns",
"a",
"pointer",
"to",
"an",
"appropriate",
"implementation",
"of",
"the",
"Adapter",
"interface",
"as",
"determined",
"by",
"the",
"storeageAdapterType",
"string",
"it",
"is",
"passed",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/storage/factory.go#L23-L48 | train |
deis/deis | builder/docker/docker.go | Start | func Start(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt) {
// Allow insecure Docker registries on all private network ranges in RFC 1918 and RFC 6598.
dargs := []string{
"-d",
"--bip=172.19.42.1/16",
"--insecure-registry",
"10.0.0.0/8",
"--insecure-registry",
"172.16.0.0/12",
"--insecure-registry",
"192.168.0.0/16",
"--insecure-registry",
"100.64.0.0/10",
"--exec-opt",
"native.cgroupdriver=cgroupfs",
}
// For overlay-ish filesystems, force the overlay to kick in if it exists.
// Then we can check the fstype.
if err := os.MkdirAll("/", 0700); err == nil {
cmd := exec.Command("findmnt", "--noheadings", "--output", "FSTYPE", "--target", "/")
if out, err := cmd.Output(); err == nil && strings.TrimSpace(string(out)) == "overlay" {
dargs = append(dargs, "--storage-driver=overlay")
} else {
log.Infof(c, "File system type: '%s' (%v)", out, err)
}
}
log.Infof(c, "Starting docker with %s", strings.Join(dargs, " "))
cmd := exec.Command("docker", dargs...)
if err := cmd.Start(); err != nil {
log.Errf(c, "Failed to start Docker. %s", err)
return -1, err
}
// Get the PID and return it.
return cmd.Process.Pid, nil
} | go | func Start(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt) {
// Allow insecure Docker registries on all private network ranges in RFC 1918 and RFC 6598.
dargs := []string{
"-d",
"--bip=172.19.42.1/16",
"--insecure-registry",
"10.0.0.0/8",
"--insecure-registry",
"172.16.0.0/12",
"--insecure-registry",
"192.168.0.0/16",
"--insecure-registry",
"100.64.0.0/10",
"--exec-opt",
"native.cgroupdriver=cgroupfs",
}
// For overlay-ish filesystems, force the overlay to kick in if it exists.
// Then we can check the fstype.
if err := os.MkdirAll("/", 0700); err == nil {
cmd := exec.Command("findmnt", "--noheadings", "--output", "FSTYPE", "--target", "/")
if out, err := cmd.Output(); err == nil && strings.TrimSpace(string(out)) == "overlay" {
dargs = append(dargs, "--storage-driver=overlay")
} else {
log.Infof(c, "File system type: '%s' (%v)", out, err)
}
}
log.Infof(c, "Starting docker with %s", strings.Join(dargs, " "))
cmd := exec.Command("docker", dargs...)
if err := cmd.Start(); err != nil {
log.Errf(c, "Failed to start Docker. %s", err)
return -1, err
}
// Get the PID and return it.
return cmd.Process.Pid, nil
} | [
"func",
"Start",
"(",
"c",
"cookoo",
".",
"Context",
",",
"p",
"*",
"cookoo",
".",
"Params",
")",
"(",
"interface",
"{",
"}",
",",
"cookoo",
".",
"Interrupt",
")",
"{",
"// Allow insecure Docker registries on all private network ranges in RFC 1918 and RFC 6598.",
"dargs",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"}",
"\n\n",
"// For overlay-ish filesystems, force the overlay to kick in if it exists.",
"// Then we can check the fstype.",
"if",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"\"",
"\"",
",",
"0700",
")",
";",
"err",
"==",
"nil",
"{",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n\n",
"if",
"out",
",",
"err",
":=",
"cmd",
".",
"Output",
"(",
")",
";",
"err",
"==",
"nil",
"&&",
"strings",
".",
"TrimSpace",
"(",
"string",
"(",
"out",
")",
")",
"==",
"\"",
"\"",
"{",
"dargs",
"=",
"append",
"(",
"dargs",
",",
"\"",
"\"",
")",
"\n",
"}",
"else",
"{",
"log",
".",
"Infof",
"(",
"c",
",",
"\"",
"\"",
",",
"out",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"log",
".",
"Infof",
"(",
"c",
",",
"\"",
"\"",
",",
"strings",
".",
"Join",
"(",
"dargs",
",",
"\"",
"\"",
")",
")",
"\n",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"dargs",
"...",
")",
"\n",
"if",
"err",
":=",
"cmd",
".",
"Start",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Errf",
"(",
"c",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"-",
"1",
",",
"err",
"\n",
"}",
"\n",
"// Get the PID and return it.",
"return",
"cmd",
".",
"Process",
".",
"Pid",
",",
"nil",
"\n",
"}"
] | // Start starts a Docker daemon.
//
// This assumes the presence of the docker client on the host. It does not use
// the API. | [
"Start",
"starts",
"a",
"Docker",
"daemon",
".",
"This",
"assumes",
"the",
"presence",
"of",
"the",
"docker",
"client",
"on",
"the",
"host",
".",
"It",
"does",
"not",
"use",
"the",
"API",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/docker/docker.go#L62-L100 | train |
deis/deis | client/parser/releases.go | Releases | func Releases(argv []string) error {
usage := `
Valid commands for releases:
releases:list list an application's release history
releases:info print information about a specific release
releases:rollback return to a previous release
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "releases:list":
return releasesList(argv)
case "releases:info":
return releasesInfo(argv)
case "releases:rollback":
return releasesRollback(argv)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "releases" {
argv[0] = "releases:list"
return releasesList(argv)
}
PrintUsage()
return nil
}
} | go | func Releases(argv []string) error {
usage := `
Valid commands for releases:
releases:list list an application's release history
releases:info print information about a specific release
releases:rollback return to a previous release
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "releases:list":
return releasesList(argv)
case "releases:info":
return releasesInfo(argv)
case "releases:rollback":
return releasesRollback(argv)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "releases" {
argv[0] = "releases:list"
return releasesList(argv)
}
PrintUsage()
return nil
}
} | [
"func",
"Releases",
"(",
"argv",
"[",
"]",
"string",
")",
"error",
"{",
"usage",
":=",
"`\nValid commands for releases:\n\nreleases:list list an application's release history\nreleases:info print information about a specific release\nreleases:rollback return to a previous release\n\nUse 'deis help [command]' to learn more.\n`",
"\n\n",
"switch",
"argv",
"[",
"0",
"]",
"{",
"case",
"\"",
"\"",
":",
"return",
"releasesList",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"releasesInfo",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"releasesRollback",
"(",
"argv",
")",
"\n",
"default",
":",
"if",
"printHelp",
"(",
"argv",
",",
"usage",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"argv",
"[",
"0",
"]",
"==",
"\"",
"\"",
"{",
"argv",
"[",
"0",
"]",
"=",
"\"",
"\"",
"\n",
"return",
"releasesList",
"(",
"argv",
")",
"\n",
"}",
"\n\n",
"PrintUsage",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // Releases routes releases commands to their specific function. | [
"Releases",
"routes",
"releases",
"commands",
"to",
"their",
"specific",
"function",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/parser/releases.go#L12-L43 | train |
deis/deis | client/pkg/git/git.go | CreateRemote | func CreateRemote(host, remote, appID string) error {
cmd := exec.Command("git", "remote", "add", remote, RemoteURL(host, appID))
stderr, err := cmd.StderrPipe()
if err != nil {
return err
}
if err = cmd.Start(); err != nil {
return err
}
output, _ := ioutil.ReadAll(stderr)
fmt.Print(string(output))
if err := cmd.Wait(); err != nil {
return err
}
fmt.Printf("Git remote %s added\n", remote)
return nil
} | go | func CreateRemote(host, remote, appID string) error {
cmd := exec.Command("git", "remote", "add", remote, RemoteURL(host, appID))
stderr, err := cmd.StderrPipe()
if err != nil {
return err
}
if err = cmd.Start(); err != nil {
return err
}
output, _ := ioutil.ReadAll(stderr)
fmt.Print(string(output))
if err := cmd.Wait(); err != nil {
return err
}
fmt.Printf("Git remote %s added\n", remote)
return nil
} | [
"func",
"CreateRemote",
"(",
"host",
",",
"remote",
",",
"appID",
"string",
")",
"error",
"{",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"remote",
",",
"RemoteURL",
"(",
"host",
",",
"appID",
")",
")",
"\n",
"stderr",
",",
"err",
":=",
"cmd",
".",
"StderrPipe",
"(",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"err",
"=",
"cmd",
".",
"Start",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"output",
",",
"_",
":=",
"ioutil",
".",
"ReadAll",
"(",
"stderr",
")",
"\n",
"fmt",
".",
"Print",
"(",
"string",
"(",
"output",
")",
")",
"\n\n",
"if",
"err",
":=",
"cmd",
".",
"Wait",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"remote",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // CreateRemote adds a git remote in the current directory. | [
"CreateRemote",
"adds",
"a",
"git",
"remote",
"in",
"the",
"current",
"directory",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/pkg/git/git.go#L14-L36 | train |
deis/deis | client/pkg/git/git.go | DeleteRemote | func DeleteRemote(appID string) error {
name, err := remoteNameFromAppID(appID)
if err != nil {
return err
}
if _, err = exec.Command("git", "remote", "remove", name).Output(); err != nil {
return err
}
fmt.Printf("Git remote %s removed\n", name)
return nil
} | go | func DeleteRemote(appID string) error {
name, err := remoteNameFromAppID(appID)
if err != nil {
return err
}
if _, err = exec.Command("git", "remote", "remove", name).Output(); err != nil {
return err
}
fmt.Printf("Git remote %s removed\n", name)
return nil
} | [
"func",
"DeleteRemote",
"(",
"appID",
"string",
")",
"error",
"{",
"name",
",",
"err",
":=",
"remoteNameFromAppID",
"(",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"_",
",",
"err",
"=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"name",
")",
".",
"Output",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"name",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // DeleteRemote removes a git remote in the current directory. | [
"DeleteRemote",
"removes",
"a",
"git",
"remote",
"in",
"the",
"current",
"directory",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/pkg/git/git.go#L39-L53 | train |
deis/deis | client/pkg/git/git.go | DetectAppName | func DetectAppName(host string) (string, error) {
remote, err := findRemote(host)
// Don't return an error if remote can't be found, return directory name instead.
if err != nil {
dir, err := os.Getwd()
return strings.ToLower(path.Base(dir)), err
}
ss := strings.Split(remote, "/")
return strings.Split(ss[len(ss)-1], ".")[0], nil
} | go | func DetectAppName(host string) (string, error) {
remote, err := findRemote(host)
// Don't return an error if remote can't be found, return directory name instead.
if err != nil {
dir, err := os.Getwd()
return strings.ToLower(path.Base(dir)), err
}
ss := strings.Split(remote, "/")
return strings.Split(ss[len(ss)-1], ".")[0], nil
} | [
"func",
"DetectAppName",
"(",
"host",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"remote",
",",
"err",
":=",
"findRemote",
"(",
"host",
")",
"\n\n",
"// Don't return an error if remote can't be found, return directory name instead.",
"if",
"err",
"!=",
"nil",
"{",
"dir",
",",
"err",
":=",
"os",
".",
"Getwd",
"(",
")",
"\n",
"return",
"strings",
".",
"ToLower",
"(",
"path",
".",
"Base",
"(",
"dir",
")",
")",
",",
"err",
"\n",
"}",
"\n\n",
"ss",
":=",
"strings",
".",
"Split",
"(",
"remote",
",",
"\"",
"\"",
")",
"\n",
"return",
"strings",
".",
"Split",
"(",
"ss",
"[",
"len",
"(",
"ss",
")",
"-",
"1",
"]",
",",
"\"",
"\"",
")",
"[",
"0",
"]",
",",
"nil",
"\n",
"}"
] | // DetectAppName detects if there is deis remote in git. | [
"DetectAppName",
"detects",
"if",
"there",
"is",
"deis",
"remote",
"in",
"git",
"."
] | 1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410 | https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/pkg/git/git.go#L74-L85 | 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.