id
int32 0
167k
| repo
stringlengths 5
54
| path
stringlengths 4
155
| func_name
stringlengths 1
118
| original_string
stringlengths 52
85.5k
| language
stringclasses 1
value | code
stringlengths 52
85.5k
| code_tokens
listlengths 21
1.41k
| docstring
stringlengths 6
2.61k
| docstring_tokens
listlengths 3
215
| sha
stringlengths 40
40
| url
stringlengths 85
252
|
---|---|---|---|---|---|---|---|---|---|---|---|
142,800 |
deis/deis
|
deisctl/config/etcd/etcd.go
|
NewConfigBackend
|
func NewConfigBackend() (*ConfigBackend, error) {
var dial func(string, string) (net.Conn, error)
sshTimeout := time.Duration(fleet.Flags.SSHTimeout*1000) * time.Millisecond
tun := getTunnelFlag()
if tun != "" {
sshClient, err := ssh.NewSSHClient("core", tun, getChecker(), false, sshTimeout)
if err != nil {
return nil, fmt.Errorf("failed initializing SSH client: %v", err)
}
dial = func(network, addr string) (net.Conn, error) {
tcpaddr, err := net.ResolveTCPAddr(network, addr)
if err != nil {
return nil, err
}
return sshClient.DialTCP(network, nil, tcpaddr)
}
}
tlsConfig, err := pkg.ReadTLSConfigFiles(fleet.Flags.EtcdCAFile,
fleet.Flags.EtcdCertFile, fleet.Flags.EtcdKeyFile)
if err != nil {
return nil, err
}
trans := http.Transport{
Dial: dial,
TLSClientConfig: tlsConfig,
}
timeout := time.Duration(fleet.Flags.RequestTimeout*1000) * time.Millisecond
machines := []string{fleet.Flags.Endpoint}
c := etcdlib.NewClient(machines)
c.SetDialTimeout(timeout)
// use custom transport with SSH tunnel capability
c.SetTransport(&trans)
return &ConfigBackend{etcdlib: c}, nil
}
|
go
|
func NewConfigBackend() (*ConfigBackend, error) {
var dial func(string, string) (net.Conn, error)
sshTimeout := time.Duration(fleet.Flags.SSHTimeout*1000) * time.Millisecond
tun := getTunnelFlag()
if tun != "" {
sshClient, err := ssh.NewSSHClient("core", tun, getChecker(), false, sshTimeout)
if err != nil {
return nil, fmt.Errorf("failed initializing SSH client: %v", err)
}
dial = func(network, addr string) (net.Conn, error) {
tcpaddr, err := net.ResolveTCPAddr(network, addr)
if err != nil {
return nil, err
}
return sshClient.DialTCP(network, nil, tcpaddr)
}
}
tlsConfig, err := pkg.ReadTLSConfigFiles(fleet.Flags.EtcdCAFile,
fleet.Flags.EtcdCertFile, fleet.Flags.EtcdKeyFile)
if err != nil {
return nil, err
}
trans := http.Transport{
Dial: dial,
TLSClientConfig: tlsConfig,
}
timeout := time.Duration(fleet.Flags.RequestTimeout*1000) * time.Millisecond
machines := []string{fleet.Flags.Endpoint}
c := etcdlib.NewClient(machines)
c.SetDialTimeout(timeout)
// use custom transport with SSH tunnel capability
c.SetTransport(&trans)
return &ConfigBackend{etcdlib: c}, nil
}
|
[
"func",
"NewConfigBackend",
"(",
")",
"(",
"*",
"ConfigBackend",
",",
"error",
")",
"{",
"var",
"dial",
"func",
"(",
"string",
",",
"string",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"\n",
"sshTimeout",
":=",
"time",
".",
"Duration",
"(",
"fleet",
".",
"Flags",
".",
"SSHTimeout",
"*",
"1000",
")",
"*",
"time",
".",
"Millisecond",
"\n",
"tun",
":=",
"getTunnelFlag",
"(",
")",
"\n",
"if",
"tun",
"!=",
"\"",
"\"",
"{",
"sshClient",
",",
"err",
":=",
"ssh",
".",
"NewSSHClient",
"(",
"\"",
"\"",
",",
"tun",
",",
"getChecker",
"(",
")",
",",
"false",
",",
"sshTimeout",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"dial",
"=",
"func",
"(",
"network",
",",
"addr",
"string",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"tcpaddr",
",",
"err",
":=",
"net",
".",
"ResolveTCPAddr",
"(",
"network",
",",
"addr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"sshClient",
".",
"DialTCP",
"(",
"network",
",",
"nil",
",",
"tcpaddr",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"tlsConfig",
",",
"err",
":=",
"pkg",
".",
"ReadTLSConfigFiles",
"(",
"fleet",
".",
"Flags",
".",
"EtcdCAFile",
",",
"fleet",
".",
"Flags",
".",
"EtcdCertFile",
",",
"fleet",
".",
"Flags",
".",
"EtcdKeyFile",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"trans",
":=",
"http",
".",
"Transport",
"{",
"Dial",
":",
"dial",
",",
"TLSClientConfig",
":",
"tlsConfig",
",",
"}",
"\n\n",
"timeout",
":=",
"time",
".",
"Duration",
"(",
"fleet",
".",
"Flags",
".",
"RequestTimeout",
"*",
"1000",
")",
"*",
"time",
".",
"Millisecond",
"\n",
"machines",
":=",
"[",
"]",
"string",
"{",
"fleet",
".",
"Flags",
".",
"Endpoint",
"}",
"\n\n",
"c",
":=",
"etcdlib",
".",
"NewClient",
"(",
"machines",
")",
"\n",
"c",
".",
"SetDialTimeout",
"(",
"timeout",
")",
"\n\n",
"// use custom transport with SSH tunnel capability",
"c",
".",
"SetTransport",
"(",
"&",
"trans",
")",
"\n\n",
"return",
"&",
"ConfigBackend",
"{",
"etcdlib",
":",
"c",
"}",
",",
"nil",
"\n",
"}"
] |
// NewConfigBackend returns this etcd-based implementation of the config.Backend
// interface
|
[
"NewConfigBackend",
"returns",
"this",
"etcd",
"-",
"based",
"implementation",
"of",
"the",
"config",
".",
"Backend",
"interface"
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/config/etcd/etcd.go#L131-L171
|
142,801 |
deis/deis
|
logger/drain/simple/drain.go
|
NewDrain
|
func NewDrain(drainURL string) (*logDrain, error) {
u, err := url.Parse(drainURL)
if err != nil {
return nil, err
}
var proto string
if u.Scheme == "udp" || u.Scheme == "syslog" {
proto = "udp"
} else if u.Scheme == "tcp" {
proto = "tcp"
} else {
return nil, fmt.Errorf("Invalid drain url scheme: %s", u.Scheme)
}
return &logDrain{proto: proto, uri: u.Host + u.Path}, nil
}
|
go
|
func NewDrain(drainURL string) (*logDrain, error) {
u, err := url.Parse(drainURL)
if err != nil {
return nil, err
}
var proto string
if u.Scheme == "udp" || u.Scheme == "syslog" {
proto = "udp"
} else if u.Scheme == "tcp" {
proto = "tcp"
} else {
return nil, fmt.Errorf("Invalid drain url scheme: %s", u.Scheme)
}
return &logDrain{proto: proto, uri: u.Host + u.Path}, nil
}
|
[
"func",
"NewDrain",
"(",
"drainURL",
"string",
")",
"(",
"*",
"logDrain",
",",
"error",
")",
"{",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"drainURL",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"var",
"proto",
"string",
"\n",
"if",
"u",
".",
"Scheme",
"==",
"\"",
"\"",
"||",
"u",
".",
"Scheme",
"==",
"\"",
"\"",
"{",
"proto",
"=",
"\"",
"\"",
"\n",
"}",
"else",
"if",
"u",
".",
"Scheme",
"==",
"\"",
"\"",
"{",
"proto",
"=",
"\"",
"\"",
"\n",
"}",
"else",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"u",
".",
"Scheme",
")",
"\n",
"}",
"\n",
"return",
"&",
"logDrain",
"{",
"proto",
":",
"proto",
",",
"uri",
":",
"u",
".",
"Host",
"+",
"u",
".",
"Path",
"}",
",",
"nil",
"\n",
"}"
] |
// NewDrain returns a pointer to a new instance of a drain.LogDrain
|
[
"NewDrain",
"returns",
"a",
"pointer",
"to",
"a",
"new",
"instance",
"of",
"a",
"drain",
".",
"LogDrain"
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/drain/simple/drain.go#L45-L59
|
142,802 |
deis/deis
|
logger/drain/simple/drain.go
|
Send
|
func (d *logDrain) Send(message string) error {
if d.muted {
return nil
}
d.mutex.Lock()
defer d.mutex.Unlock()
conn, err := d.getConnection(false)
if err != nil {
return err
}
_, err = fmt.Fprintln(conn, message)
if err != nil {
// Try again with a new connection in case the issue was a broken pipe
conn, err = d.getConnection(true)
if err != nil {
return err
}
_, err = fmt.Fprintln(conn, message)
if err != nil {
return err
}
}
return nil
}
|
go
|
func (d *logDrain) Send(message string) error {
if d.muted {
return nil
}
d.mutex.Lock()
defer d.mutex.Unlock()
conn, err := d.getConnection(false)
if err != nil {
return err
}
_, err = fmt.Fprintln(conn, message)
if err != nil {
// Try again with a new connection in case the issue was a broken pipe
conn, err = d.getConnection(true)
if err != nil {
return err
}
_, err = fmt.Fprintln(conn, message)
if err != nil {
return err
}
}
return nil
}
|
[
"func",
"(",
"d",
"*",
"logDrain",
")",
"Send",
"(",
"message",
"string",
")",
"error",
"{",
"if",
"d",
".",
"muted",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"d",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"d",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"conn",
",",
"err",
":=",
"d",
".",
"getConnection",
"(",
"false",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"_",
",",
"err",
"=",
"fmt",
".",
"Fprintln",
"(",
"conn",
",",
"message",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// Try again with a new connection in case the issue was a broken pipe",
"conn",
",",
"err",
"=",
"d",
".",
"getConnection",
"(",
"true",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"_",
",",
"err",
"=",
"fmt",
".",
"Fprintln",
"(",
"conn",
",",
"message",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
// Send forwards the provided log message to an external destination
|
[
"Send",
"forwards",
"the",
"provided",
"log",
"message",
"to",
"an",
"external",
"destination"
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/drain/simple/drain.go#L62-L85
|
142,803 |
deis/deis
|
logger/drain/simple/drain.go
|
getConnection
|
func (d *logDrain) getConnection(forceNew bool) (net.Conn, error) {
// If we have a connection, it's not old, and we're not focing a new one...
if d.conn != nil && !forceNew {
// then return the existing connection
return d.conn, nil
}
// If ANY of those conditions weren't met, it's time for a new connection.
// If we have an existing one, close it and nil it out, too for good measure.
if d.conn != nil {
if err := d.conn.Close(); err != nil {
log.Println("drain: Error closing connection. Drain may be leaking connections.", err)
}
d.conn = nil
}
// Try a few times...
var err error
for attempt := 1; attempt <= maxFailedConns; attempt++ {
d.conn, err = net.DialTimeout(d.proto, d.uri, dialTimeout)
if err == nil {
// We got our connection...
// Make it good for only so long. See comment above on connRefreshInterval.
err = d.conn.SetWriteDeadline(time.Now().Add(connRefreshInterval))
if err != nil {
return nil, err
}
// Break out of the loop and return
return d.conn, nil
}
}
// Multiple attempts to dial have failed. Whatever the problem is, we shouldn't expect that
// it will resolve itself quickly.
log.Printf("drain: Experienced %d consecutive failed connection attempts; muting drain for %s.", maxFailedConns, mutePeriod)
// Immediately "mute" the drain. This will prevent us from wasting resources repeatedly dialing
// and failing while the message queue gets backed up. This will give the network a break and
// allow us to empty the queue.
d.muted = true
// Unmute the drain when the mute interval has elapsed
go func() {
time.Sleep(mutePeriod)
d.muted = false
}()
// Return the error from the last failed connection attempt
return nil, err
}
|
go
|
func (d *logDrain) getConnection(forceNew bool) (net.Conn, error) {
// If we have a connection, it's not old, and we're not focing a new one...
if d.conn != nil && !forceNew {
// then return the existing connection
return d.conn, nil
}
// If ANY of those conditions weren't met, it's time for a new connection.
// If we have an existing one, close it and nil it out, too for good measure.
if d.conn != nil {
if err := d.conn.Close(); err != nil {
log.Println("drain: Error closing connection. Drain may be leaking connections.", err)
}
d.conn = nil
}
// Try a few times...
var err error
for attempt := 1; attempt <= maxFailedConns; attempt++ {
d.conn, err = net.DialTimeout(d.proto, d.uri, dialTimeout)
if err == nil {
// We got our connection...
// Make it good for only so long. See comment above on connRefreshInterval.
err = d.conn.SetWriteDeadline(time.Now().Add(connRefreshInterval))
if err != nil {
return nil, err
}
// Break out of the loop and return
return d.conn, nil
}
}
// Multiple attempts to dial have failed. Whatever the problem is, we shouldn't expect that
// it will resolve itself quickly.
log.Printf("drain: Experienced %d consecutive failed connection attempts; muting drain for %s.", maxFailedConns, mutePeriod)
// Immediately "mute" the drain. This will prevent us from wasting resources repeatedly dialing
// and failing while the message queue gets backed up. This will give the network a break and
// allow us to empty the queue.
d.muted = true
// Unmute the drain when the mute interval has elapsed
go func() {
time.Sleep(mutePeriod)
d.muted = false
}()
// Return the error from the last failed connection attempt
return nil, err
}
|
[
"func",
"(",
"d",
"*",
"logDrain",
")",
"getConnection",
"(",
"forceNew",
"bool",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"// If we have a connection, it's not old, and we're not focing a new one...",
"if",
"d",
".",
"conn",
"!=",
"nil",
"&&",
"!",
"forceNew",
"{",
"// then return the existing connection",
"return",
"d",
".",
"conn",
",",
"nil",
"\n",
"}",
"\n",
"// If ANY of those conditions weren't met, it's time for a new connection.",
"// If we have an existing one, close it and nil it out, too for good measure.",
"if",
"d",
".",
"conn",
"!=",
"nil",
"{",
"if",
"err",
":=",
"d",
".",
"conn",
".",
"Close",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Println",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"d",
".",
"conn",
"=",
"nil",
"\n",
"}",
"\n",
"// Try a few times...",
"var",
"err",
"error",
"\n",
"for",
"attempt",
":=",
"1",
";",
"attempt",
"<=",
"maxFailedConns",
";",
"attempt",
"++",
"{",
"d",
".",
"conn",
",",
"err",
"=",
"net",
".",
"DialTimeout",
"(",
"d",
".",
"proto",
",",
"d",
".",
"uri",
",",
"dialTimeout",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"// We got our connection...",
"// Make it good for only so long. See comment above on connRefreshInterval.",
"err",
"=",
"d",
".",
"conn",
".",
"SetWriteDeadline",
"(",
"time",
".",
"Now",
"(",
")",
".",
"Add",
"(",
"connRefreshInterval",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"// Break out of the loop and return",
"return",
"d",
".",
"conn",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n",
"// Multiple attempts to dial have failed. Whatever the problem is, we shouldn't expect that",
"// it will resolve itself quickly.",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"maxFailedConns",
",",
"mutePeriod",
")",
"\n",
"// Immediately \"mute\" the drain. This will prevent us from wasting resources repeatedly dialing",
"// and failing while the message queue gets backed up. This will give the network a break and",
"// allow us to empty the queue.",
"d",
".",
"muted",
"=",
"true",
"\n",
"// Unmute the drain when the mute interval has elapsed",
"go",
"func",
"(",
")",
"{",
"time",
".",
"Sleep",
"(",
"mutePeriod",
")",
"\n",
"d",
".",
"muted",
"=",
"false",
"\n",
"}",
"(",
")",
"\n",
"// Return the error from the last failed connection attempt",
"return",
"nil",
",",
"err",
"\n",
"}"
] |
// getConnection returns a usable connection, often without needing to redial, but still
// redialing when advised.
|
[
"getConnection",
"returns",
"a",
"usable",
"connection",
"often",
"without",
"needing",
"to",
"redial",
"but",
"still",
"redialing",
"when",
"advised",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/drain/simple/drain.go#L89-L132
|
142,804 |
deis/deis
|
client/cmd/releases.go
|
ReleasesList
|
func ReleasesList(appID string, results int) error {
c, appID, err := load(appID)
if err != nil {
return err
}
if results == defaultLimit {
results = c.ResponseLimit
}
releases, count, err := releases.List(c, appID, results)
fmt.Printf("=== %s Releases%s", appID, limitCount(len(releases), count))
w := new(tabwriter.Writer)
w.Init(os.Stdout, 0, 8, 1, '\t', 0)
for _, r := range releases {
fmt.Fprintf(w, "v%d\t%s\t%s\n", r.Version, r.Created, r.Summary)
}
w.Flush()
return nil
}
|
go
|
func ReleasesList(appID string, results int) error {
c, appID, err := load(appID)
if err != nil {
return err
}
if results == defaultLimit {
results = c.ResponseLimit
}
releases, count, err := releases.List(c, appID, results)
fmt.Printf("=== %s Releases%s", appID, limitCount(len(releases), count))
w := new(tabwriter.Writer)
w.Init(os.Stdout, 0, 8, 1, '\t', 0)
for _, r := range releases {
fmt.Fprintf(w, "v%d\t%s\t%s\n", r.Version, r.Created, r.Summary)
}
w.Flush()
return nil
}
|
[
"func",
"ReleasesList",
"(",
"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",
"releases",
",",
"count",
",",
"err",
":=",
"releases",
".",
"List",
"(",
"c",
",",
"appID",
",",
"results",
")",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"appID",
",",
"limitCount",
"(",
"len",
"(",
"releases",
")",
",",
"count",
")",
")",
"\n\n",
"w",
":=",
"new",
"(",
"tabwriter",
".",
"Writer",
")",
"\n\n",
"w",
".",
"Init",
"(",
"os",
".",
"Stdout",
",",
"0",
",",
"8",
",",
"1",
",",
"'\\t'",
",",
"0",
")",
"\n",
"for",
"_",
",",
"r",
":=",
"range",
"releases",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\t",
"\\n",
"\"",
",",
"r",
".",
"Version",
",",
"r",
".",
"Created",
",",
"r",
".",
"Summary",
")",
"\n",
"}",
"\n",
"w",
".",
"Flush",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
// ReleasesList lists an app's releases.
|
[
"ReleasesList",
"lists",
"an",
"app",
"s",
"releases",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/releases.go#L12-L35
|
142,805 |
deis/deis
|
client/cmd/releases.go
|
ReleasesInfo
|
func ReleasesInfo(appID string, version int) error {
c, appID, err := load(appID)
if err != nil {
return err
}
r, err := releases.Get(c, appID, version)
if err != nil {
return err
}
fmt.Printf("=== %s Release v%d\n", appID, version)
if r.Build != "" {
fmt.Println("build: ", r.Build)
}
fmt.Println("config: ", r.Config)
fmt.Println("owner: ", r.Owner)
fmt.Println("created: ", r.Created)
fmt.Println("summary: ", r.Summary)
fmt.Println("updated: ", r.Updated)
fmt.Println("uuid: ", r.UUID)
return nil
}
|
go
|
func ReleasesInfo(appID string, version int) error {
c, appID, err := load(appID)
if err != nil {
return err
}
r, err := releases.Get(c, appID, version)
if err != nil {
return err
}
fmt.Printf("=== %s Release v%d\n", appID, version)
if r.Build != "" {
fmt.Println("build: ", r.Build)
}
fmt.Println("config: ", r.Config)
fmt.Println("owner: ", r.Owner)
fmt.Println("created: ", r.Created)
fmt.Println("summary: ", r.Summary)
fmt.Println("updated: ", r.Updated)
fmt.Println("uuid: ", r.UUID)
return nil
}
|
[
"func",
"ReleasesInfo",
"(",
"appID",
"string",
",",
"version",
"int",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"load",
"(",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"r",
",",
"err",
":=",
"releases",
".",
"Get",
"(",
"c",
",",
"appID",
",",
"version",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"appID",
",",
"version",
")",
"\n",
"if",
"r",
".",
"Build",
"!=",
"\"",
"\"",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"r",
".",
"Build",
")",
"\n",
"}",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"r",
".",
"Config",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"r",
".",
"Owner",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"r",
".",
"Created",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"r",
".",
"Summary",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"r",
".",
"Updated",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"r",
".",
"UUID",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
// ReleasesInfo prints info about a specific release.
|
[
"ReleasesInfo",
"prints",
"info",
"about",
"a",
"specific",
"release",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/releases.go#L38-L63
|
142,806 |
deis/deis
|
client/cmd/releases.go
|
ReleasesRollback
|
func ReleasesRollback(appID string, version int) error {
c, appID, err := load(appID)
if err != nil {
return err
}
if version == -1 {
fmt.Print("Rolling back one release... ")
} else {
fmt.Printf("Rolling back to v%d... ", version)
}
quit := progress()
newVersion, err := releases.Rollback(c, appID, version)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Printf("done, v%d\n", newVersion)
return nil
}
|
go
|
func ReleasesRollback(appID string, version int) error {
c, appID, err := load(appID)
if err != nil {
return err
}
if version == -1 {
fmt.Print("Rolling back one release... ")
} else {
fmt.Printf("Rolling back to v%d... ", version)
}
quit := progress()
newVersion, err := releases.Rollback(c, appID, version)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Printf("done, v%d\n", newVersion)
return nil
}
|
[
"func",
"ReleasesRollback",
"(",
"appID",
"string",
",",
"version",
"int",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"load",
"(",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"version",
"==",
"-",
"1",
"{",
"fmt",
".",
"Print",
"(",
"\"",
"\"",
")",
"\n",
"}",
"else",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"version",
")",
"\n",
"}",
"\n\n",
"quit",
":=",
"progress",
"(",
")",
"\n",
"newVersion",
",",
"err",
":=",
"releases",
".",
"Rollback",
"(",
"c",
",",
"appID",
",",
"version",
")",
"\n",
"quit",
"<-",
"true",
"\n",
"<-",
"quit",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"newVersion",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
// ReleasesRollback rolls an app back to a previous release.
|
[
"ReleasesRollback",
"rolls",
"an",
"app",
"back",
"to",
"a",
"previous",
"release",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/releases.go#L66-L91
|
142,807 |
deis/deis
|
Godeps/_workspace/src/google.golang.org/api/googleapi/googleapi.go
|
IsNotModified
|
func IsNotModified(err error) bool {
if err == nil {
return false
}
ae, ok := err.(*Error)
return ok && ae.Code == http.StatusNotModified
}
|
go
|
func IsNotModified(err error) bool {
if err == nil {
return false
}
ae, ok := err.(*Error)
return ok && ae.Code == http.StatusNotModified
}
|
[
"func",
"IsNotModified",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"ae",
",",
"ok",
":=",
"err",
".",
"(",
"*",
"Error",
")",
"\n",
"return",
"ok",
"&&",
"ae",
".",
"Code",
"==",
"http",
".",
"StatusNotModified",
"\n",
"}"
] |
// IsNotModified reports whether err is the result of the
// server replying with http.StatusNotModified.
// Such error values are sometimes returned by "Do" methods
// on calls when If-None-Match is used.
|
[
"IsNotModified",
"reports",
"whether",
"err",
"is",
"the",
"result",
"of",
"the",
"server",
"replying",
"with",
"http",
".",
"StatusNotModified",
".",
"Such",
"error",
"values",
"are",
"sometimes",
"returned",
"by",
"Do",
"methods",
"on",
"calls",
"when",
"If",
"-",
"None",
"-",
"Match",
"is",
"used",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/Godeps/_workspace/src/google.golang.org/api/googleapi/googleapi.go#L141-L147
|
142,808 |
deis/deis
|
Godeps/_workspace/src/google.golang.org/api/googleapi/googleapi.go
|
ProcessMediaOptions
|
func ProcessMediaOptions(opts []MediaOption) *MediaOptions {
mo := &MediaOptions{ChunkSize: DefaultUploadChunkSize}
for _, o := range opts {
o.setOptions(mo)
}
return mo
}
|
go
|
func ProcessMediaOptions(opts []MediaOption) *MediaOptions {
mo := &MediaOptions{ChunkSize: DefaultUploadChunkSize}
for _, o := range opts {
o.setOptions(mo)
}
return mo
}
|
[
"func",
"ProcessMediaOptions",
"(",
"opts",
"[",
"]",
"MediaOption",
")",
"*",
"MediaOptions",
"{",
"mo",
":=",
"&",
"MediaOptions",
"{",
"ChunkSize",
":",
"DefaultUploadChunkSize",
"}",
"\n",
"for",
"_",
",",
"o",
":=",
"range",
"opts",
"{",
"o",
".",
"setOptions",
"(",
"mo",
")",
"\n",
"}",
"\n",
"return",
"mo",
"\n",
"}"
] |
// ProcessMediaOptions stores options from opts in a MediaOptions.
// It is not used by developers directly.
|
[
"ProcessMediaOptions",
"stores",
"options",
"from",
"opts",
"in",
"a",
"MediaOptions",
".",
"It",
"is",
"not",
"used",
"by",
"developers",
"directly",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/Godeps/_workspace/src/google.golang.org/api/googleapi/googleapi.go#L257-L263
|
142,809 |
deis/deis
|
Godeps/_workspace/src/google.golang.org/api/googleapi/googleapi.go
|
SetOpaque
|
func SetOpaque(u *url.URL) {
u.Opaque = "//" + u.Host + u.Path
if !has4860Fix {
u.Opaque = u.Scheme + ":" + u.Opaque
}
}
|
go
|
func SetOpaque(u *url.URL) {
u.Opaque = "//" + u.Host + u.Path
if !has4860Fix {
u.Opaque = u.Scheme + ":" + u.Opaque
}
}
|
[
"func",
"SetOpaque",
"(",
"u",
"*",
"url",
".",
"URL",
")",
"{",
"u",
".",
"Opaque",
"=",
"\"",
"\"",
"+",
"u",
".",
"Host",
"+",
"u",
".",
"Path",
"\n",
"if",
"!",
"has4860Fix",
"{",
"u",
".",
"Opaque",
"=",
"u",
".",
"Scheme",
"+",
"\"",
"\"",
"+",
"u",
".",
"Opaque",
"\n",
"}",
"\n",
"}"
] |
// SetOpaque sets u.Opaque from u.Path such that HTTP requests to it
// don't alter any hex-escaped characters in u.Path.
|
[
"SetOpaque",
"sets",
"u",
".",
"Opaque",
"from",
"u",
".",
"Path",
"such",
"that",
"HTTP",
"requests",
"to",
"it",
"don",
"t",
"alter",
"any",
"hex",
"-",
"escaped",
"characters",
"in",
"u",
".",
"Path",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/Godeps/_workspace/src/google.golang.org/api/googleapi/googleapi.go#L294-L299
|
142,810 |
deis/deis
|
Godeps/_workspace/src/google.golang.org/api/googleapi/googleapi.go
|
CloseBody
|
func CloseBody(res *http.Response) {
if res == nil || res.Body == nil {
return
}
// Justification for 3 byte reads: two for up to "\r\n" after
// a JSON/XML document, and then 1 to see EOF if we haven't yet.
// TODO(bradfitz): detect Go 1.3+ and skip these reads.
// See https://codereview.appspot.com/58240043
// and https://codereview.appspot.com/49570044
buf := make([]byte, 1)
for i := 0; i < 3; i++ {
_, err := res.Body.Read(buf)
if err != nil {
break
}
}
res.Body.Close()
}
|
go
|
func CloseBody(res *http.Response) {
if res == nil || res.Body == nil {
return
}
// Justification for 3 byte reads: two for up to "\r\n" after
// a JSON/XML document, and then 1 to see EOF if we haven't yet.
// TODO(bradfitz): detect Go 1.3+ and skip these reads.
// See https://codereview.appspot.com/58240043
// and https://codereview.appspot.com/49570044
buf := make([]byte, 1)
for i := 0; i < 3; i++ {
_, err := res.Body.Read(buf)
if err != nil {
break
}
}
res.Body.Close()
}
|
[
"func",
"CloseBody",
"(",
"res",
"*",
"http",
".",
"Response",
")",
"{",
"if",
"res",
"==",
"nil",
"||",
"res",
".",
"Body",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"// Justification for 3 byte reads: two for up to \"\\r\\n\" after",
"// a JSON/XML document, and then 1 to see EOF if we haven't yet.",
"// TODO(bradfitz): detect Go 1.3+ and skip these reads.",
"// See https://codereview.appspot.com/58240043",
"// and https://codereview.appspot.com/49570044",
"buf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"1",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"3",
";",
"i",
"++",
"{",
"_",
",",
"err",
":=",
"res",
".",
"Body",
".",
"Read",
"(",
"buf",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"res",
".",
"Body",
".",
"Close",
"(",
")",
"\n\n",
"}"
] |
// CloseBody is used to close res.Body.
// Prior to calling Close, it also tries to Read a small amount to see an EOF.
// Not seeing an EOF can prevent HTTP Transports from reusing connections.
|
[
"CloseBody",
"is",
"used",
"to",
"close",
"res",
".",
"Body",
".",
"Prior",
"to",
"calling",
"Close",
"it",
"also",
"tries",
"to",
"Read",
"a",
"small",
"amount",
"to",
"see",
"an",
"EOF",
".",
"Not",
"seeing",
"an",
"EOF",
"can",
"prevent",
"HTTP",
"Transports",
"from",
"reusing",
"connections",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/Godeps/_workspace/src/google.golang.org/api/googleapi/googleapi.go#L316-L334
|
142,811 |
deis/deis
|
Godeps/_workspace/src/google.golang.org/api/googleapi/googleapi.go
|
CombineFields
|
func CombineFields(s []Field) string {
r := make([]string, len(s))
for i, v := range s {
r[i] = string(v)
}
return strings.Join(r, ",")
}
|
go
|
func CombineFields(s []Field) string {
r := make([]string, len(s))
for i, v := range s {
r[i] = string(v)
}
return strings.Join(r, ",")
}
|
[
"func",
"CombineFields",
"(",
"s",
"[",
"]",
"Field",
")",
"string",
"{",
"r",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"s",
")",
")",
"\n",
"for",
"i",
",",
"v",
":=",
"range",
"s",
"{",
"r",
"[",
"i",
"]",
"=",
"string",
"(",
"v",
")",
"\n",
"}",
"\n",
"return",
"strings",
".",
"Join",
"(",
"r",
",",
"\"",
"\"",
")",
"\n",
"}"
] |
// CombineFields combines fields into a single string.
|
[
"CombineFields",
"combines",
"fields",
"into",
"a",
"single",
"string",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/Godeps/_workspace/src/google.golang.org/api/googleapi/googleapi.go#L382-L388
|
142,812 |
deis/deis
|
client/cmd/auth.go
|
Register
|
func Register(controller string, username string, password string, email string,
sslVerify bool) error {
u, err := url.Parse(controller)
httpClient := client.CreateHTTPClient(sslVerify)
if err != nil {
return err
}
controllerURL, err := chooseScheme(*u)
if err != nil {
return err
}
if err = client.CheckConnection(httpClient, controllerURL); err != nil {
return err
}
if username == "" {
fmt.Print("username: ")
fmt.Scanln(&username)
}
if password == "" {
fmt.Print("password: ")
password, err = readPassword()
fmt.Printf("\npassword (confirm): ")
passwordConfirm, err := readPassword()
fmt.Println()
if err != nil {
return err
}
if password != passwordConfirm {
return errors.New("Password mismatch, aborting registration.")
}
}
if email == "" {
fmt.Print("email: ")
fmt.Scanln(&email)
}
c := &client.Client{ControllerURL: controllerURL, SSLVerify: sslVerify, HTTPClient: httpClient}
tempClient, err := client.New()
if err == nil {
c.Token = tempClient.Token
}
err = auth.Register(c, username, password, email)
c.Token = ""
if err != nil {
fmt.Fprint(os.Stderr, "Registration failed: ")
return err
}
fmt.Printf("Registered %s\n", username)
return doLogin(c, username, password)
}
|
go
|
func Register(controller string, username string, password string, email string,
sslVerify bool) error {
u, err := url.Parse(controller)
httpClient := client.CreateHTTPClient(sslVerify)
if err != nil {
return err
}
controllerURL, err := chooseScheme(*u)
if err != nil {
return err
}
if err = client.CheckConnection(httpClient, controllerURL); err != nil {
return err
}
if username == "" {
fmt.Print("username: ")
fmt.Scanln(&username)
}
if password == "" {
fmt.Print("password: ")
password, err = readPassword()
fmt.Printf("\npassword (confirm): ")
passwordConfirm, err := readPassword()
fmt.Println()
if err != nil {
return err
}
if password != passwordConfirm {
return errors.New("Password mismatch, aborting registration.")
}
}
if email == "" {
fmt.Print("email: ")
fmt.Scanln(&email)
}
c := &client.Client{ControllerURL: controllerURL, SSLVerify: sslVerify, HTTPClient: httpClient}
tempClient, err := client.New()
if err == nil {
c.Token = tempClient.Token
}
err = auth.Register(c, username, password, email)
c.Token = ""
if err != nil {
fmt.Fprint(os.Stderr, "Registration failed: ")
return err
}
fmt.Printf("Registered %s\n", username)
return doLogin(c, username, password)
}
|
[
"func",
"Register",
"(",
"controller",
"string",
",",
"username",
"string",
",",
"password",
"string",
",",
"email",
"string",
",",
"sslVerify",
"bool",
")",
"error",
"{",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"controller",
")",
"\n",
"httpClient",
":=",
"client",
".",
"CreateHTTPClient",
"(",
"sslVerify",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"controllerURL",
",",
"err",
":=",
"chooseScheme",
"(",
"*",
"u",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"err",
"=",
"client",
".",
"CheckConnection",
"(",
"httpClient",
",",
"controllerURL",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"username",
"==",
"\"",
"\"",
"{",
"fmt",
".",
"Print",
"(",
"\"",
"\"",
")",
"\n",
"fmt",
".",
"Scanln",
"(",
"&",
"username",
")",
"\n",
"}",
"\n\n",
"if",
"password",
"==",
"\"",
"\"",
"{",
"fmt",
".",
"Print",
"(",
"\"",
"\"",
")",
"\n",
"password",
",",
"err",
"=",
"readPassword",
"(",
")",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"passwordConfirm",
",",
"err",
":=",
"readPassword",
"(",
")",
"\n",
"fmt",
".",
"Println",
"(",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"password",
"!=",
"passwordConfirm",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"email",
"==",
"\"",
"\"",
"{",
"fmt",
".",
"Print",
"(",
"\"",
"\"",
")",
"\n",
"fmt",
".",
"Scanln",
"(",
"&",
"email",
")",
"\n",
"}",
"\n\n",
"c",
":=",
"&",
"client",
".",
"Client",
"{",
"ControllerURL",
":",
"controllerURL",
",",
"SSLVerify",
":",
"sslVerify",
",",
"HTTPClient",
":",
"httpClient",
"}",
"\n\n",
"tempClient",
",",
"err",
":=",
"client",
".",
"New",
"(",
")",
"\n\n",
"if",
"err",
"==",
"nil",
"{",
"c",
".",
"Token",
"=",
"tempClient",
".",
"Token",
"\n",
"}",
"\n\n",
"err",
"=",
"auth",
".",
"Register",
"(",
"c",
",",
"username",
",",
"password",
",",
"email",
")",
"\n\n",
"c",
".",
"Token",
"=",
"\"",
"\"",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Fprint",
"(",
"os",
".",
"Stderr",
",",
"\"",
"\"",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"username",
")",
"\n",
"return",
"doLogin",
"(",
"c",
",",
"username",
",",
"password",
")",
"\n",
"}"
] |
// Register creates a account on a Deis controller.
|
[
"Register",
"creates",
"a",
"account",
"on",
"a",
"Deis",
"controller",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/auth.go#L18-L83
|
142,813 |
deis/deis
|
client/cmd/auth.go
|
Login
|
func Login(controller string, username string, password string, sslVerify bool) error {
u, err := url.Parse(controller)
if err != nil {
return err
}
controllerURL, err := chooseScheme(*u)
httpClient := client.CreateHTTPClient(sslVerify)
if err != nil {
return err
}
if err = client.CheckConnection(httpClient, controllerURL); err != nil {
return err
}
if username == "" {
fmt.Print("username: ")
fmt.Scanln(&username)
}
if password == "" {
fmt.Print("password: ")
password, err = readPassword()
fmt.Println()
if err != nil {
return err
}
}
c := &client.Client{ControllerURL: controllerURL, SSLVerify: sslVerify, HTTPClient: httpClient}
return doLogin(c, username, password)
}
|
go
|
func Login(controller string, username string, password string, sslVerify bool) error {
u, err := url.Parse(controller)
if err != nil {
return err
}
controllerURL, err := chooseScheme(*u)
httpClient := client.CreateHTTPClient(sslVerify)
if err != nil {
return err
}
if err = client.CheckConnection(httpClient, controllerURL); err != nil {
return err
}
if username == "" {
fmt.Print("username: ")
fmt.Scanln(&username)
}
if password == "" {
fmt.Print("password: ")
password, err = readPassword()
fmt.Println()
if err != nil {
return err
}
}
c := &client.Client{ControllerURL: controllerURL, SSLVerify: sslVerify, HTTPClient: httpClient}
return doLogin(c, username, password)
}
|
[
"func",
"Login",
"(",
"controller",
"string",
",",
"username",
"string",
",",
"password",
"string",
",",
"sslVerify",
"bool",
")",
"error",
"{",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"controller",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"controllerURL",
",",
"err",
":=",
"chooseScheme",
"(",
"*",
"u",
")",
"\n",
"httpClient",
":=",
"client",
".",
"CreateHTTPClient",
"(",
"sslVerify",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"err",
"=",
"client",
".",
"CheckConnection",
"(",
"httpClient",
",",
"controllerURL",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"username",
"==",
"\"",
"\"",
"{",
"fmt",
".",
"Print",
"(",
"\"",
"\"",
")",
"\n",
"fmt",
".",
"Scanln",
"(",
"&",
"username",
")",
"\n",
"}",
"\n\n",
"if",
"password",
"==",
"\"",
"\"",
"{",
"fmt",
".",
"Print",
"(",
"\"",
"\"",
")",
"\n",
"password",
",",
"err",
"=",
"readPassword",
"(",
")",
"\n",
"fmt",
".",
"Println",
"(",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"c",
":=",
"&",
"client",
".",
"Client",
"{",
"ControllerURL",
":",
"controllerURL",
",",
"SSLVerify",
":",
"sslVerify",
",",
"HTTPClient",
":",
"httpClient",
"}",
"\n\n",
"return",
"doLogin",
"(",
"c",
",",
"username",
",",
"password",
")",
"\n",
"}"
] |
// Login to a Deis controller.
|
[
"Login",
"to",
"a",
"Deis",
"controller",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/auth.go#L106-L142
|
142,814 |
deis/deis
|
client/cmd/auth.go
|
Logout
|
func Logout() error {
if err := client.Delete(); err != nil {
return err
}
fmt.Println("Logged out")
return nil
}
|
go
|
func Logout() error {
if err := client.Delete(); err != nil {
return err
}
fmt.Println("Logged out")
return nil
}
|
[
"func",
"Logout",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"client",
".",
"Delete",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
// Logout from a Deis controller.
|
[
"Logout",
"from",
"a",
"Deis",
"controller",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/auth.go#L145-L152
|
142,815 |
deis/deis
|
client/cmd/auth.go
|
Cancel
|
func Cancel(username string, password string, yes bool) error {
c, err := client.New()
if err != nil {
return err
}
if username == "" || password != "" {
fmt.Println("Please log in again in order to cancel this account")
if err = Login(c.ControllerURL.String(), username, password, c.SSLVerify); err != nil {
return err
}
}
if yes == false {
confirm := ""
c, err = client.New()
if err != nil {
return err
}
deletedUser := username
if deletedUser == "" {
deletedUser = c.Username
}
fmt.Printf("cancel account %s at %s? (y/N): ", deletedUser, c.ControllerURL.String())
fmt.Scanln(&confirm)
if strings.ToLower(confirm) == "y" {
yes = true
}
}
if yes == false {
fmt.Fprintln(os.Stderr, "Account not changed")
return nil
}
err = auth.Delete(c, username)
cleanup := fmt.Errorf("\n%s %s\n\n", "409", "Conflict")
if reflect.DeepEqual(err, cleanup) {
fmt.Printf("%s still has application associated with it. Transfer ownership or delete them first\n", username)
return nil
} else if err != nil {
return err
}
// If user targets themselves, logout.
if username == "" || c.Username == username {
if err := client.Delete(); err != nil {
return err
}
}
fmt.Println("Account cancelled")
return nil
}
|
go
|
func Cancel(username string, password string, yes bool) error {
c, err := client.New()
if err != nil {
return err
}
if username == "" || password != "" {
fmt.Println("Please log in again in order to cancel this account")
if err = Login(c.ControllerURL.String(), username, password, c.SSLVerify); err != nil {
return err
}
}
if yes == false {
confirm := ""
c, err = client.New()
if err != nil {
return err
}
deletedUser := username
if deletedUser == "" {
deletedUser = c.Username
}
fmt.Printf("cancel account %s at %s? (y/N): ", deletedUser, c.ControllerURL.String())
fmt.Scanln(&confirm)
if strings.ToLower(confirm) == "y" {
yes = true
}
}
if yes == false {
fmt.Fprintln(os.Stderr, "Account not changed")
return nil
}
err = auth.Delete(c, username)
cleanup := fmt.Errorf("\n%s %s\n\n", "409", "Conflict")
if reflect.DeepEqual(err, cleanup) {
fmt.Printf("%s still has application associated with it. Transfer ownership or delete them first\n", username)
return nil
} else if err != nil {
return err
}
// If user targets themselves, logout.
if username == "" || c.Username == username {
if err := client.Delete(); err != nil {
return err
}
}
fmt.Println("Account cancelled")
return nil
}
|
[
"func",
"Cancel",
"(",
"username",
"string",
",",
"password",
"string",
",",
"yes",
"bool",
")",
"error",
"{",
"c",
",",
"err",
":=",
"client",
".",
"New",
"(",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"username",
"==",
"\"",
"\"",
"||",
"password",
"!=",
"\"",
"\"",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n\n",
"if",
"err",
"=",
"Login",
"(",
"c",
".",
"ControllerURL",
".",
"String",
"(",
")",
",",
"username",
",",
"password",
",",
"c",
".",
"SSLVerify",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"yes",
"==",
"false",
"{",
"confirm",
":=",
"\"",
"\"",
"\n\n",
"c",
",",
"err",
"=",
"client",
".",
"New",
"(",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"deletedUser",
":=",
"username",
"\n\n",
"if",
"deletedUser",
"==",
"\"",
"\"",
"{",
"deletedUser",
"=",
"c",
".",
"Username",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"deletedUser",
",",
"c",
".",
"ControllerURL",
".",
"String",
"(",
")",
")",
"\n",
"fmt",
".",
"Scanln",
"(",
"&",
"confirm",
")",
"\n\n",
"if",
"strings",
".",
"ToLower",
"(",
"confirm",
")",
"==",
"\"",
"\"",
"{",
"yes",
"=",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"yes",
"==",
"false",
"{",
"fmt",
".",
"Fprintln",
"(",
"os",
".",
"Stderr",
",",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"err",
"=",
"auth",
".",
"Delete",
"(",
"c",
",",
"username",
")",
"\n\n",
"cleanup",
":=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\n",
"\\n",
"\\n",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"reflect",
".",
"DeepEqual",
"(",
"err",
",",
"cleanup",
")",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"username",
")",
"\n",
"return",
"nil",
"\n",
"}",
"else",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// If user targets themselves, logout.",
"if",
"username",
"==",
"\"",
"\"",
"||",
"c",
".",
"Username",
"==",
"username",
"{",
"if",
"err",
":=",
"client",
".",
"Delete",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
// Cancel deletes a user's account.
|
[
"Cancel",
"deletes",
"a",
"user",
"s",
"account",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/auth.go#L201-L263
|
142,816 |
deis/deis
|
client/cmd/auth.go
|
Whoami
|
func Whoami() error {
c, err := client.New()
if err != nil {
return err
}
fmt.Printf("You are %s at %s\n", c.Username, c.ControllerURL.String())
return nil
}
|
go
|
func Whoami() error {
c, err := client.New()
if err != nil {
return err
}
fmt.Printf("You are %s at %s\n", c.Username, c.ControllerURL.String())
return nil
}
|
[
"func",
"Whoami",
"(",
")",
"error",
"{",
"c",
",",
"err",
":=",
"client",
".",
"New",
"(",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"c",
".",
"Username",
",",
"c",
".",
"ControllerURL",
".",
"String",
"(",
")",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
// Whoami prints the logged in user.
|
[
"Whoami",
"prints",
"the",
"logged",
"in",
"user",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/auth.go#L266-L275
|
142,817 |
deis/deis
|
client/cmd/auth.go
|
Regenerate
|
func Regenerate(username string, all bool) error {
c, err := client.New()
if err != nil {
return err
}
token, err := auth.Regenerate(c, username, all)
if err != nil {
return err
}
if username == "" && all == false {
c.Token = token
err = c.Save()
if err != nil {
return err
}
}
fmt.Println("Token Regenerated")
return nil
}
|
go
|
func Regenerate(username string, all bool) error {
c, err := client.New()
if err != nil {
return err
}
token, err := auth.Regenerate(c, username, all)
if err != nil {
return err
}
if username == "" && all == false {
c.Token = token
err = c.Save()
if err != nil {
return err
}
}
fmt.Println("Token Regenerated")
return nil
}
|
[
"func",
"Regenerate",
"(",
"username",
"string",
",",
"all",
"bool",
")",
"error",
"{",
"c",
",",
"err",
":=",
"client",
".",
"New",
"(",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"token",
",",
"err",
":=",
"auth",
".",
"Regenerate",
"(",
"c",
",",
"username",
",",
"all",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"username",
"==",
"\"",
"\"",
"&&",
"all",
"==",
"false",
"{",
"c",
".",
"Token",
"=",
"token",
"\n\n",
"err",
"=",
"c",
".",
"Save",
"(",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
// Regenerate regenenerates a user's token.
|
[
"Regenerate",
"regenenerates",
"a",
"user",
"s",
"token",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/auth.go#L278-L303
|
142,818 |
deis/deis
|
client/cmd/certs.go
|
CertsList
|
func CertsList(results int) error {
c, err := client.New()
if err != nil {
return err
}
if results == defaultLimit {
results = c.ResponseLimit
}
certList, _, err := certs.List(c, results)
if err != nil {
return err
}
if len(certList) == 0 {
fmt.Println("No certs")
return nil
}
certMap := make(map[string]string)
nameMax := 0
expiresMax := 0
for _, cert := range certList {
certMap[cert.Name] = cert.Expires
if len(cert.Name) > nameMax {
nameMax = len(cert.Name)
}
if len(cert.Expires) > nameMax {
expiresMax = len(cert.Expires)
}
}
nameHeader := "Common Name"
expiresHeader := "Expires"
tabSpaces := 5
bufferSpaces := tabSpaces
if nameMax < len(nameHeader) {
tabSpaces += len(nameHeader) - nameMax
nameMax = len(nameHeader)
} else {
bufferSpaces += nameMax - len(nameHeader)
}
if expiresMax < len(expiresHeader) {
expiresMax = len(expiresHeader)
}
fmt.Printf("%s%s%s\n", nameHeader, strings.Repeat(" ", bufferSpaces), expiresHeader)
fmt.Printf("%s%s%s\n", strings.Repeat("-", nameMax), strings.Repeat(" ", 5),
strings.Repeat("-", expiresMax))
fmt.Print(prettyprint.PrettyTabs(certMap, tabSpaces))
return nil
}
|
go
|
func CertsList(results int) error {
c, err := client.New()
if err != nil {
return err
}
if results == defaultLimit {
results = c.ResponseLimit
}
certList, _, err := certs.List(c, results)
if err != nil {
return err
}
if len(certList) == 0 {
fmt.Println("No certs")
return nil
}
certMap := make(map[string]string)
nameMax := 0
expiresMax := 0
for _, cert := range certList {
certMap[cert.Name] = cert.Expires
if len(cert.Name) > nameMax {
nameMax = len(cert.Name)
}
if len(cert.Expires) > nameMax {
expiresMax = len(cert.Expires)
}
}
nameHeader := "Common Name"
expiresHeader := "Expires"
tabSpaces := 5
bufferSpaces := tabSpaces
if nameMax < len(nameHeader) {
tabSpaces += len(nameHeader) - nameMax
nameMax = len(nameHeader)
} else {
bufferSpaces += nameMax - len(nameHeader)
}
if expiresMax < len(expiresHeader) {
expiresMax = len(expiresHeader)
}
fmt.Printf("%s%s%s\n", nameHeader, strings.Repeat(" ", bufferSpaces), expiresHeader)
fmt.Printf("%s%s%s\n", strings.Repeat("-", nameMax), strings.Repeat(" ", 5),
strings.Repeat("-", expiresMax))
fmt.Print(prettyprint.PrettyTabs(certMap, tabSpaces))
return nil
}
|
[
"func",
"CertsList",
"(",
"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",
"certList",
",",
"_",
",",
"err",
":=",
"certs",
".",
"List",
"(",
"c",
",",
"results",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"certList",
")",
"==",
"0",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"certMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"nameMax",
":=",
"0",
"\n",
"expiresMax",
":=",
"0",
"\n",
"for",
"_",
",",
"cert",
":=",
"range",
"certList",
"{",
"certMap",
"[",
"cert",
".",
"Name",
"]",
"=",
"cert",
".",
"Expires",
"\n\n",
"if",
"len",
"(",
"cert",
".",
"Name",
")",
">",
"nameMax",
"{",
"nameMax",
"=",
"len",
"(",
"cert",
".",
"Name",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"cert",
".",
"Expires",
")",
">",
"nameMax",
"{",
"expiresMax",
"=",
"len",
"(",
"cert",
".",
"Expires",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"nameHeader",
":=",
"\"",
"\"",
"\n",
"expiresHeader",
":=",
"\"",
"\"",
"\n",
"tabSpaces",
":=",
"5",
"\n",
"bufferSpaces",
":=",
"tabSpaces",
"\n\n",
"if",
"nameMax",
"<",
"len",
"(",
"nameHeader",
")",
"{",
"tabSpaces",
"+=",
"len",
"(",
"nameHeader",
")",
"-",
"nameMax",
"\n",
"nameMax",
"=",
"len",
"(",
"nameHeader",
")",
"\n",
"}",
"else",
"{",
"bufferSpaces",
"+=",
"nameMax",
"-",
"len",
"(",
"nameHeader",
")",
"\n",
"}",
"\n\n",
"if",
"expiresMax",
"<",
"len",
"(",
"expiresHeader",
")",
"{",
"expiresMax",
"=",
"len",
"(",
"expiresHeader",
")",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"nameHeader",
",",
"strings",
".",
"Repeat",
"(",
"\"",
"\"",
",",
"bufferSpaces",
")",
",",
"expiresHeader",
")",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"strings",
".",
"Repeat",
"(",
"\"",
"\"",
",",
"nameMax",
")",
",",
"strings",
".",
"Repeat",
"(",
"\"",
"\"",
",",
"5",
")",
",",
"strings",
".",
"Repeat",
"(",
"\"",
"\"",
",",
"expiresMax",
")",
")",
"\n",
"fmt",
".",
"Print",
"(",
"prettyprint",
".",
"PrettyTabs",
"(",
"certMap",
",",
"tabSpaces",
")",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
// CertsList lists certs registered with the controller.
|
[
"CertsList",
"lists",
"certs",
"registered",
"with",
"the",
"controller",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/certs.go#L15-L72
|
142,819 |
deis/deis
|
client/cmd/certs.go
|
CertAdd
|
func CertAdd(cert, key, commonName, sans string) error {
c, err := client.New()
if err != nil {
return err
}
fmt.Print("Adding SSL endpoint... ")
quit := progress()
err = processCertsAdd(c, cert, key, commonName, sans)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Println("done")
return nil
}
|
go
|
func CertAdd(cert, key, commonName, sans string) error {
c, err := client.New()
if err != nil {
return err
}
fmt.Print("Adding SSL endpoint... ")
quit := progress()
err = processCertsAdd(c, cert, key, commonName, sans)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Println("done")
return nil
}
|
[
"func",
"CertAdd",
"(",
"cert",
",",
"key",
",",
"commonName",
",",
"sans",
"string",
")",
"error",
"{",
"c",
",",
"err",
":=",
"client",
".",
"New",
"(",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Print",
"(",
"\"",
"\"",
")",
"\n",
"quit",
":=",
"progress",
"(",
")",
"\n",
"err",
"=",
"processCertsAdd",
"(",
"c",
",",
"cert",
",",
"key",
",",
"commonName",
",",
"sans",
")",
"\n",
"quit",
"<-",
"true",
"\n",
"<-",
"quit",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
// CertAdd adds a cert to the controller.
|
[
"CertAdd",
"adds",
"a",
"cert",
"to",
"the",
"controller",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/certs.go#L75-L94
|
142,820 |
deis/deis
|
client/cmd/certs.go
|
CertRemove
|
func CertRemove(commonName string) error {
c, err := client.New()
if err != nil {
return err
}
fmt.Printf("Removing %s... ", commonName)
quit := progress()
certs.Delete(c, commonName)
quit <- true
<-quit
if err == nil {
fmt.Println("done")
}
return err
}
|
go
|
func CertRemove(commonName string) error {
c, err := client.New()
if err != nil {
return err
}
fmt.Printf("Removing %s... ", commonName)
quit := progress()
certs.Delete(c, commonName)
quit <- true
<-quit
if err == nil {
fmt.Println("done")
}
return err
}
|
[
"func",
"CertRemove",
"(",
"commonName",
"string",
")",
"error",
"{",
"c",
",",
"err",
":=",
"client",
".",
"New",
"(",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"commonName",
")",
"\n",
"quit",
":=",
"progress",
"(",
")",
"\n\n",
"certs",
".",
"Delete",
"(",
"c",
",",
"commonName",
")",
"\n\n",
"quit",
"<-",
"true",
"\n",
"<-",
"quit",
"\n\n",
"if",
"err",
"==",
"nil",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"err",
"\n",
"}"
] |
// CertRemove deletes a cert from the controller.
|
[
"CertRemove",
"deletes",
"a",
"cert",
"from",
"the",
"controller",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/certs.go#L127-L147
|
142,821 |
deis/deis
|
deisctl/backend/fleet/ssh.go
|
SSH
|
func (c *FleetClient) SSH(name string) error {
sshClient, _, err := c.sshConnect(name)
if err != nil {
return err
}
defer sshClient.Close()
err = ssh.Shell(sshClient)
return err
}
|
go
|
func (c *FleetClient) SSH(name string) error {
sshClient, _, err := c.sshConnect(name)
if err != nil {
return err
}
defer sshClient.Close()
err = ssh.Shell(sshClient)
return err
}
|
[
"func",
"(",
"c",
"*",
"FleetClient",
")",
"SSH",
"(",
"name",
"string",
")",
"error",
"{",
"sshClient",
",",
"_",
",",
"err",
":=",
"c",
".",
"sshConnect",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"defer",
"sshClient",
".",
"Close",
"(",
")",
"\n",
"err",
"=",
"ssh",
".",
"Shell",
"(",
"sshClient",
")",
"\n",
"return",
"err",
"\n",
"}"
] |
// SSH opens an interactive shell to a machine in the cluster
|
[
"SSH",
"opens",
"an",
"interactive",
"shell",
"to",
"a",
"machine",
"in",
"the",
"cluster"
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/ssh.go#L16-L25
|
142,822 |
deis/deis
|
deisctl/backend/fleet/ssh.go
|
findUnit
|
func (c *FleetClient) findUnit(name string) (machID string, err error) {
u, err := c.Fleet.Unit(name)
switch {
case err != nil:
return "", fmt.Errorf("Error retrieving Unit %s: %v", name, err)
case suToGlobal(*u):
return "", fmt.Errorf("Unable to connect to global unit %s.\n", name)
case u == nil:
return "", fmt.Errorf("Unit %s does not exist.\n", name)
case u.CurrentState == "":
return "", fmt.Errorf("Unit %s does not appear to be running.\n", name)
}
return u.MachineID, nil
}
|
go
|
func (c *FleetClient) findUnit(name string) (machID string, err error) {
u, err := c.Fleet.Unit(name)
switch {
case err != nil:
return "", fmt.Errorf("Error retrieving Unit %s: %v", name, err)
case suToGlobal(*u):
return "", fmt.Errorf("Unable to connect to global unit %s.\n", name)
case u == nil:
return "", fmt.Errorf("Unit %s does not exist.\n", name)
case u.CurrentState == "":
return "", fmt.Errorf("Unit %s does not appear to be running.\n", name)
}
return u.MachineID, nil
}
|
[
"func",
"(",
"c",
"*",
"FleetClient",
")",
"findUnit",
"(",
"name",
"string",
")",
"(",
"machID",
"string",
",",
"err",
"error",
")",
"{",
"u",
",",
"err",
":=",
"c",
".",
"Fleet",
".",
"Unit",
"(",
"name",
")",
"\n",
"switch",
"{",
"case",
"err",
"!=",
"nil",
":",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"name",
",",
"err",
")",
"\n",
"case",
"suToGlobal",
"(",
"*",
"u",
")",
":",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\n",
"\"",
",",
"name",
")",
"\n",
"case",
"u",
"==",
"nil",
":",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\n",
"\"",
",",
"name",
")",
"\n",
"case",
"u",
".",
"CurrentState",
"==",
"\"",
"\"",
":",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\n",
"\"",
",",
"name",
")",
"\n",
"}",
"\n\n",
"return",
"u",
".",
"MachineID",
",",
"nil",
"\n",
"}"
] |
// findUnits returns the machine ID of a running unit
|
[
"findUnits",
"returns",
"the",
"machine",
"ID",
"of",
"a",
"running",
"unit"
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/ssh.go#L152-L166
|
142,823 |
deis/deis
|
client/cmd/perms.go
|
PermsList
|
func PermsList(appID string, admin bool, results int) error {
c, appID, err := permsLoad(appID, admin)
if err != nil {
return err
}
var users []string
var count int
if admin {
if results == defaultLimit {
results = c.ResponseLimit
}
users, count, err = perms.ListAdmins(c, results)
} else {
users, err = perms.List(c, appID)
}
if err != nil {
return err
}
if admin {
fmt.Printf("=== Administrators%s", limitCount(len(users), count))
} else {
fmt.Printf("=== %s's Users\n", appID)
}
sort.Strings(users)
for _, user := range users {
fmt.Println(user)
}
return nil
}
|
go
|
func PermsList(appID string, admin bool, results int) error {
c, appID, err := permsLoad(appID, admin)
if err != nil {
return err
}
var users []string
var count int
if admin {
if results == defaultLimit {
results = c.ResponseLimit
}
users, count, err = perms.ListAdmins(c, results)
} else {
users, err = perms.List(c, appID)
}
if err != nil {
return err
}
if admin {
fmt.Printf("=== Administrators%s", limitCount(len(users), count))
} else {
fmt.Printf("=== %s's Users\n", appID)
}
sort.Strings(users)
for _, user := range users {
fmt.Println(user)
}
return nil
}
|
[
"func",
"PermsList",
"(",
"appID",
"string",
",",
"admin",
"bool",
",",
"results",
"int",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"permsLoad",
"(",
"appID",
",",
"admin",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"var",
"users",
"[",
"]",
"string",
"\n",
"var",
"count",
"int",
"\n\n",
"if",
"admin",
"{",
"if",
"results",
"==",
"defaultLimit",
"{",
"results",
"=",
"c",
".",
"ResponseLimit",
"\n",
"}",
"\n",
"users",
",",
"count",
",",
"err",
"=",
"perms",
".",
"ListAdmins",
"(",
"c",
",",
"results",
")",
"\n",
"}",
"else",
"{",
"users",
",",
"err",
"=",
"perms",
".",
"List",
"(",
"c",
",",
"appID",
")",
"\n",
"}",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"admin",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"limitCount",
"(",
"len",
"(",
"users",
")",
",",
"count",
")",
")",
"\n",
"}",
"else",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"appID",
")",
"\n",
"}",
"\n\n",
"sort",
".",
"Strings",
"(",
"users",
")",
"\n\n",
"for",
"_",
",",
"user",
":=",
"range",
"users",
"{",
"fmt",
".",
"Println",
"(",
"user",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
// PermsList prints which users have permissions.
|
[
"PermsList",
"prints",
"which",
"users",
"have",
"permissions",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/perms.go#L13-L49
|
142,824 |
deis/deis
|
client/cmd/perms.go
|
PermCreate
|
func PermCreate(appID string, username string, admin bool) error {
c, appID, err := permsLoad(appID, admin)
if err != nil {
return err
}
if admin {
fmt.Printf("Adding %s to system administrators... ", username)
err = perms.NewAdmin(c, username)
} else {
fmt.Printf("Adding %s to %s collaborators... ", username, appID)
err = perms.New(c, appID, username)
}
if err != nil {
return err
}
fmt.Println("done")
return nil
}
|
go
|
func PermCreate(appID string, username string, admin bool) error {
c, appID, err := permsLoad(appID, admin)
if err != nil {
return err
}
if admin {
fmt.Printf("Adding %s to system administrators... ", username)
err = perms.NewAdmin(c, username)
} else {
fmt.Printf("Adding %s to %s collaborators... ", username, appID)
err = perms.New(c, appID, username)
}
if err != nil {
return err
}
fmt.Println("done")
return nil
}
|
[
"func",
"PermCreate",
"(",
"appID",
"string",
",",
"username",
"string",
",",
"admin",
"bool",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"permsLoad",
"(",
"appID",
",",
"admin",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"admin",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"username",
")",
"\n",
"err",
"=",
"perms",
".",
"NewAdmin",
"(",
"c",
",",
"username",
")",
"\n",
"}",
"else",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"username",
",",
"appID",
")",
"\n",
"err",
"=",
"perms",
".",
"New",
"(",
"c",
",",
"appID",
",",
"username",
")",
"\n",
"}",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
// PermCreate adds a user to an app or makes them an administrator.
|
[
"PermCreate",
"adds",
"a",
"user",
"to",
"an",
"app",
"or",
"makes",
"them",
"an",
"administrator",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/perms.go#L52-L75
|
142,825 |
deis/deis
|
client/cmd/perms.go
|
PermDelete
|
func PermDelete(appID string, username string, admin bool) error {
c, appID, err := permsLoad(appID, admin)
if err != nil {
return err
}
if admin {
fmt.Printf("Removing %s from system administrators... ", username)
err = perms.DeleteAdmin(c, username)
} else {
fmt.Printf("Removing %s from %s collaborators... ", username, appID)
err = perms.Delete(c, appID, username)
}
if err != nil {
return err
}
fmt.Println("done")
return nil
}
|
go
|
func PermDelete(appID string, username string, admin bool) error {
c, appID, err := permsLoad(appID, admin)
if err != nil {
return err
}
if admin {
fmt.Printf("Removing %s from system administrators... ", username)
err = perms.DeleteAdmin(c, username)
} else {
fmt.Printf("Removing %s from %s collaborators... ", username, appID)
err = perms.Delete(c, appID, username)
}
if err != nil {
return err
}
fmt.Println("done")
return nil
}
|
[
"func",
"PermDelete",
"(",
"appID",
"string",
",",
"username",
"string",
",",
"admin",
"bool",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"permsLoad",
"(",
"appID",
",",
"admin",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"admin",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"username",
")",
"\n",
"err",
"=",
"perms",
".",
"DeleteAdmin",
"(",
"c",
",",
"username",
")",
"\n",
"}",
"else",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"username",
",",
"appID",
")",
"\n",
"err",
"=",
"perms",
".",
"Delete",
"(",
"c",
",",
"appID",
",",
"username",
")",
"\n",
"}",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
// PermDelete removes a user from an app or revokes admin privilages.
|
[
"PermDelete",
"removes",
"a",
"user",
"from",
"an",
"app",
"or",
"revokes",
"admin",
"privilages",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/perms.go#L78-L101
|
142,826 |
deis/deis
|
logger/storage/file/adapter.go
|
NewStorageAdapter
|
func NewStorageAdapter(logRoot string) (*adapter, error) {
src, err := os.Stat(logRoot)
if err != nil {
return nil, fmt.Errorf("Directory %s does not exist", logRoot)
}
if !src.IsDir() {
return nil, fmt.Errorf("%s is not a directory", logRoot)
}
return &adapter{logRoot: logRoot, files: make(map[string]*os.File)}, nil
}
|
go
|
func NewStorageAdapter(logRoot string) (*adapter, error) {
src, err := os.Stat(logRoot)
if err != nil {
return nil, fmt.Errorf("Directory %s does not exist", logRoot)
}
if !src.IsDir() {
return nil, fmt.Errorf("%s is not a directory", logRoot)
}
return &adapter{logRoot: logRoot, files: make(map[string]*os.File)}, nil
}
|
[
"func",
"NewStorageAdapter",
"(",
"logRoot",
"string",
")",
"(",
"*",
"adapter",
",",
"error",
")",
"{",
"src",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"logRoot",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"logRoot",
")",
"\n",
"}",
"\n",
"if",
"!",
"src",
".",
"IsDir",
"(",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"logRoot",
")",
"\n",
"}",
"\n",
"return",
"&",
"adapter",
"{",
"logRoot",
":",
"logRoot",
",",
"files",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"os",
".",
"File",
")",
"}",
",",
"nil",
"\n",
"}"
] |
// NewStorageAdapter returns a pointer to a new instance of a file-based storage.Adapter.
|
[
"NewStorageAdapter",
"returns",
"a",
"pointer",
"to",
"a",
"new",
"instance",
"of",
"a",
"file",
"-",
"based",
"storage",
".",
"Adapter",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/storage/file/adapter.go#L20-L29
|
142,827 |
deis/deis
|
logger/storage/file/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 file pointers so we can avoid
// waiting for / obtaining a lock unnecessarily
f, ok := a.files[app]
if !ok {
// Ensure only one goroutine at a time can be adding a file pointer to the map of file
// pointers
a.mutex.Lock()
defer a.mutex.Unlock()
f, ok = a.files[app]
if !ok {
var err error
f, err = a.getFile(app)
if err != nil {
return err
}
a.files[app] = f
}
}
if _, err := f.WriteString(message + "\n"); err != nil {
return err
}
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 file pointers so we can avoid
// waiting for / obtaining a lock unnecessarily
f, ok := a.files[app]
if !ok {
// Ensure only one goroutine at a time can be adding a file pointer to the map of file
// pointers
a.mutex.Lock()
defer a.mutex.Unlock()
f, ok = a.files[app]
if !ok {
var err error
f, err = a.getFile(app)
if err != nil {
return err
}
a.files[app] = f
}
}
if _, err := f.WriteString(message + "\n"); err != nil {
return err
}
return nil
}
|
[
"func",
"(",
"a",
"*",
"adapter",
")",
"Write",
"(",
"app",
"string",
",",
"message",
"string",
")",
"error",
"{",
"// Check first if we might actually have to add to the map of file pointers so we can avoid",
"// waiting for / obtaining a lock unnecessarily",
"f",
",",
"ok",
":=",
"a",
".",
"files",
"[",
"app",
"]",
"\n",
"if",
"!",
"ok",
"{",
"// Ensure only one goroutine at a time can be adding a file pointer to the map of file",
"// pointers",
"a",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"a",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"f",
",",
"ok",
"=",
"a",
".",
"files",
"[",
"app",
"]",
"\n",
"if",
"!",
"ok",
"{",
"var",
"err",
"error",
"\n",
"f",
",",
"err",
"=",
"a",
".",
"getFile",
"(",
"app",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"a",
".",
"files",
"[",
"app",
"]",
"=",
"f",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"_",
",",
"err",
":=",
"f",
".",
"WriteString",
"(",
"message",
"+",
"\"",
"\\n",
"\"",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
// Write adds a log message to to an app-specific log file
|
[
"Write",
"adds",
"a",
"log",
"message",
"to",
"to",
"an",
"app",
"-",
"specific",
"log",
"file"
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/storage/file/adapter.go#L32-L55
|
142,828 |
deis/deis
|
logger/storage/file/adapter.go
|
Read
|
func (a *adapter) Read(app string, lines int) ([]string, error) {
if lines <= 0 {
return []string{}, nil
}
filePath := a.getFilePath(app)
exists, err := fileExists(filePath)
if err != nil {
return nil, err
}
if !exists {
return nil, fmt.Errorf("Could not find logs for '%s'", app)
}
logBytes, err := exec.Command("tail", "-n", strconv.Itoa(lines), filePath).Output()
if err != nil {
return nil, err
}
logStrs := strings.Split(string(logBytes), "\n")
return logStrs[:len(logStrs)-1], nil
}
|
go
|
func (a *adapter) Read(app string, lines int) ([]string, error) {
if lines <= 0 {
return []string{}, nil
}
filePath := a.getFilePath(app)
exists, err := fileExists(filePath)
if err != nil {
return nil, err
}
if !exists {
return nil, fmt.Errorf("Could not find logs for '%s'", app)
}
logBytes, err := exec.Command("tail", "-n", strconv.Itoa(lines), filePath).Output()
if err != nil {
return nil, err
}
logStrs := strings.Split(string(logBytes), "\n")
return logStrs[:len(logStrs)-1], nil
}
|
[
"func",
"(",
"a",
"*",
"adapter",
")",
"Read",
"(",
"app",
"string",
",",
"lines",
"int",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"if",
"lines",
"<=",
"0",
"{",
"return",
"[",
"]",
"string",
"{",
"}",
",",
"nil",
"\n",
"}",
"\n",
"filePath",
":=",
"a",
".",
"getFilePath",
"(",
"app",
")",
"\n",
"exists",
",",
"err",
":=",
"fileExists",
"(",
"filePath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"!",
"exists",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"app",
")",
"\n",
"}",
"\n",
"logBytes",
",",
"err",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"strconv",
".",
"Itoa",
"(",
"lines",
")",
",",
"filePath",
")",
".",
"Output",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"logStrs",
":=",
"strings",
".",
"Split",
"(",
"string",
"(",
"logBytes",
")",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"return",
"logStrs",
"[",
":",
"len",
"(",
"logStrs",
")",
"-",
"1",
"]",
",",
"nil",
"\n",
"}"
] |
// Read retrieves a specified number of log lines from an app-specific log file
|
[
"Read",
"retrieves",
"a",
"specified",
"number",
"of",
"log",
"lines",
"from",
"an",
"app",
"-",
"specific",
"log",
"file"
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/storage/file/adapter.go#L58-L76
|
142,829 |
deis/deis
|
client/parser/perms.go
|
Perms
|
func Perms(argv []string) error {
usage := `
Valid commands for perms:
perms:list list permissions granted on an app
perms:create create a new permission for a user
perms:delete delete a permission for a user
Use 'deis help perms:[command]' to learn more.
`
switch argv[0] {
case "perms:list":
return permsList(argv)
case "perms:create":
return permCreate(argv)
case "perms:delete":
return permDelete(argv)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "perms" {
argv[0] = "perms:list"
return permsList(argv)
}
PrintUsage()
return nil
}
}
|
go
|
func Perms(argv []string) error {
usage := `
Valid commands for perms:
perms:list list permissions granted on an app
perms:create create a new permission for a user
perms:delete delete a permission for a user
Use 'deis help perms:[command]' to learn more.
`
switch argv[0] {
case "perms:list":
return permsList(argv)
case "perms:create":
return permCreate(argv)
case "perms:delete":
return permDelete(argv)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "perms" {
argv[0] = "perms:list"
return permsList(argv)
}
PrintUsage()
return nil
}
}
|
[
"func",
"Perms",
"(",
"argv",
"[",
"]",
"string",
")",
"error",
"{",
"usage",
":=",
"`\nValid commands for perms:\n\nperms:list list permissions granted on an app\nperms:create create a new permission for a user\nperms:delete delete a permission for a user\n\nUse 'deis help perms:[command]' to learn more.\n`",
"\n",
"switch",
"argv",
"[",
"0",
"]",
"{",
"case",
"\"",
"\"",
":",
"return",
"permsList",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"permCreate",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"permDelete",
"(",
"argv",
")",
"\n",
"default",
":",
"if",
"printHelp",
"(",
"argv",
",",
"usage",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"argv",
"[",
"0",
"]",
"==",
"\"",
"\"",
"{",
"argv",
"[",
"0",
"]",
"=",
"\"",
"\"",
"\n",
"return",
"permsList",
"(",
"argv",
")",
"\n",
"}",
"\n\n",
"PrintUsage",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] |
// Perms routes perms commands to their specific function.
|
[
"Perms",
"routes",
"perms",
"commands",
"to",
"their",
"specific",
"function",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/parser/perms.go#L9-L39
|
142,830 |
deis/deis
|
client/parser/keys.go
|
Keys
|
func Keys(argv []string) error {
usage := `
Valid commands for SSH keys:
keys:list list SSH keys for the logged in user
keys:add add an SSH key
keys:remove remove an SSH key
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "keys:list":
return keysList(argv)
case "keys:add":
return keyAdd(argv)
case "keys:remove":
return keyRemove(argv)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "keys" {
argv[0] = "keys:list"
return keysList(argv)
}
PrintUsage()
return nil
}
}
|
go
|
func Keys(argv []string) error {
usage := `
Valid commands for SSH keys:
keys:list list SSH keys for the logged in user
keys:add add an SSH key
keys:remove remove an SSH key
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "keys:list":
return keysList(argv)
case "keys:add":
return keyAdd(argv)
case "keys:remove":
return keyRemove(argv)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "keys" {
argv[0] = "keys:list"
return keysList(argv)
}
PrintUsage()
return nil
}
}
|
[
"func",
"Keys",
"(",
"argv",
"[",
"]",
"string",
")",
"error",
"{",
"usage",
":=",
"`\nValid commands for SSH keys:\n\nkeys:list list SSH keys for the logged in user\nkeys:add add an SSH key\nkeys:remove remove an SSH key\n\nUse 'deis help [command]' to learn more.\n`",
"\n\n",
"switch",
"argv",
"[",
"0",
"]",
"{",
"case",
"\"",
"\"",
":",
"return",
"keysList",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"keyAdd",
"(",
"argv",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"keyRemove",
"(",
"argv",
")",
"\n",
"default",
":",
"if",
"printHelp",
"(",
"argv",
",",
"usage",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"argv",
"[",
"0",
"]",
"==",
"\"",
"\"",
"{",
"argv",
"[",
"0",
"]",
"=",
"\"",
"\"",
"\n",
"return",
"keysList",
"(",
"argv",
")",
"\n",
"}",
"\n\n",
"PrintUsage",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] |
// Keys routes key commands to the specific function.
|
[
"Keys",
"routes",
"key",
"commands",
"to",
"the",
"specific",
"function",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/parser/keys.go#L9-L40
|
142,831 |
deis/deis
|
client/cmd/limits.go
|
LimitsList
|
func LimitsList(appID string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
config, err := config.List(c, appID)
fmt.Printf("=== %s Limits\n\n", appID)
fmt.Println("--- Memory")
if len(config.Memory) == 0 {
fmt.Println("Unlimited")
} else {
memoryMap := make(map[string]string)
for key, value := range config.Memory {
memoryMap[key] = fmt.Sprintf("%v", value)
}
fmt.Print(prettyprint.PrettyTabs(memoryMap, 5))
}
fmt.Println("\n--- CPU")
if len(config.CPU) == 0 {
fmt.Println("Unlimited")
} else {
cpuMap := make(map[string]string)
for key, value := range config.CPU {
cpuMap[key] = strconv.Itoa(int(value.(float64)))
}
fmt.Print(prettyprint.PrettyTabs(cpuMap, 5))
}
return nil
}
|
go
|
func LimitsList(appID string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
config, err := config.List(c, appID)
fmt.Printf("=== %s Limits\n\n", appID)
fmt.Println("--- Memory")
if len(config.Memory) == 0 {
fmt.Println("Unlimited")
} else {
memoryMap := make(map[string]string)
for key, value := range config.Memory {
memoryMap[key] = fmt.Sprintf("%v", value)
}
fmt.Print(prettyprint.PrettyTabs(memoryMap, 5))
}
fmt.Println("\n--- CPU")
if len(config.CPU) == 0 {
fmt.Println("Unlimited")
} else {
cpuMap := make(map[string]string)
for key, value := range config.CPU {
cpuMap[key] = strconv.Itoa(int(value.(float64)))
}
fmt.Print(prettyprint.PrettyTabs(cpuMap, 5))
}
return nil
}
|
[
"func",
"LimitsList",
"(",
"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",
"\\n",
"\"",
",",
"appID",
")",
"\n\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"config",
".",
"Memory",
")",
"==",
"0",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"}",
"else",
"{",
"memoryMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n\n",
"for",
"key",
",",
"value",
":=",
"range",
"config",
".",
"Memory",
"{",
"memoryMap",
"[",
"key",
"]",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"value",
")",
"\n",
"}",
"\n\n",
"fmt",
".",
"Print",
"(",
"prettyprint",
".",
"PrettyTabs",
"(",
"memoryMap",
",",
"5",
")",
")",
"\n",
"}",
"\n\n",
"fmt",
".",
"Println",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"if",
"len",
"(",
"config",
".",
"CPU",
")",
"==",
"0",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"}",
"else",
"{",
"cpuMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n\n",
"for",
"key",
",",
"value",
":=",
"range",
"config",
".",
"CPU",
"{",
"cpuMap",
"[",
"key",
"]",
"=",
"strconv",
".",
"Itoa",
"(",
"int",
"(",
"value",
".",
"(",
"float64",
")",
")",
")",
"\n",
"}",
"\n\n",
"fmt",
".",
"Print",
"(",
"prettyprint",
".",
"PrettyTabs",
"(",
"cpuMap",
",",
"5",
")",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
// LimitsList lists an app's limits.
|
[
"LimitsList",
"lists",
"an",
"app",
"s",
"limits",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/limits.go#L15-L53
|
142,832 |
deis/deis
|
client/cmd/limits.go
|
LimitsSet
|
func LimitsSet(appID string, limits []string, limitType string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
limitsMap := parseLimits(limits)
fmt.Print("Applying limits... ")
quit := progress()
configObj := api.Config{}
if limitType == "cpu" {
configObj.CPU = limitsMap
} else {
configObj.Memory = limitsMap
}
_, err = config.Set(c, appID, configObj)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Print("done\n\n")
return LimitsList(appID)
}
|
go
|
func LimitsSet(appID string, limits []string, limitType string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
limitsMap := parseLimits(limits)
fmt.Print("Applying limits... ")
quit := progress()
configObj := api.Config{}
if limitType == "cpu" {
configObj.CPU = limitsMap
} else {
configObj.Memory = limitsMap
}
_, err = config.Set(c, appID, configObj)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Print("done\n\n")
return LimitsList(appID)
}
|
[
"func",
"LimitsSet",
"(",
"appID",
"string",
",",
"limits",
"[",
"]",
"string",
",",
"limitType",
"string",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"load",
"(",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"limitsMap",
":=",
"parseLimits",
"(",
"limits",
")",
"\n\n",
"fmt",
".",
"Print",
"(",
"\"",
"\"",
")",
"\n\n",
"quit",
":=",
"progress",
"(",
")",
"\n",
"configObj",
":=",
"api",
".",
"Config",
"{",
"}",
"\n\n",
"if",
"limitType",
"==",
"\"",
"\"",
"{",
"configObj",
".",
"CPU",
"=",
"limitsMap",
"\n",
"}",
"else",
"{",
"configObj",
".",
"Memory",
"=",
"limitsMap",
"\n",
"}",
"\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",
"LimitsList",
"(",
"appID",
")",
"\n",
"}"
] |
// LimitsSet sets an app's limits.
|
[
"LimitsSet",
"sets",
"an",
"app",
"s",
"limits",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/limits.go#L56-L88
|
142,833 |
deis/deis
|
client/cmd/limits.go
|
LimitsUnset
|
func LimitsUnset(appID string, limits []string, limitType string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
fmt.Print("Applying limits... ")
quit := progress()
configObj := api.Config{}
valuesMap := make(map[string]interface{})
for _, limit := range limits {
valuesMap[limit] = nil
}
if limitType == "cpu" {
configObj.CPU = valuesMap
} else {
configObj.Memory = valuesMap
}
_, err = config.Set(c, appID, configObj)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Print("done\n\n")
return LimitsList(appID)
}
|
go
|
func LimitsUnset(appID string, limits []string, limitType string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
fmt.Print("Applying limits... ")
quit := progress()
configObj := api.Config{}
valuesMap := make(map[string]interface{})
for _, limit := range limits {
valuesMap[limit] = nil
}
if limitType == "cpu" {
configObj.CPU = valuesMap
} else {
configObj.Memory = valuesMap
}
_, err = config.Set(c, appID, configObj)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Print("done\n\n")
return LimitsList(appID)
}
|
[
"func",
"LimitsUnset",
"(",
"appID",
"string",
",",
"limits",
"[",
"]",
"string",
",",
"limitType",
"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",
"_",
",",
"limit",
":=",
"range",
"limits",
"{",
"valuesMap",
"[",
"limit",
"]",
"=",
"nil",
"\n",
"}",
"\n\n",
"if",
"limitType",
"==",
"\"",
"\"",
"{",
"configObj",
".",
"CPU",
"=",
"valuesMap",
"\n",
"}",
"else",
"{",
"configObj",
".",
"Memory",
"=",
"valuesMap",
"\n",
"}",
"\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",
"LimitsList",
"(",
"appID",
")",
"\n",
"}"
] |
// LimitsUnset removes an app's limits.
|
[
"LimitsUnset",
"removes",
"an",
"app",
"s",
"limits",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/limits.go#L91-L128
|
142,834 |
deis/deis
|
client/controller/models/auth/auth.go
|
Register
|
func Register(c *client.Client, username, password, email string) error {
user := api.AuthRegisterRequest{Username: username, Password: password, Email: email}
body, err := json.Marshal(user)
if err != nil {
return err
}
_, err = c.BasicRequest("POST", "/v1/auth/register/", body)
return err
}
|
go
|
func Register(c *client.Client, username, password, email string) error {
user := api.AuthRegisterRequest{Username: username, Password: password, Email: email}
body, err := json.Marshal(user)
if err != nil {
return err
}
_, err = c.BasicRequest("POST", "/v1/auth/register/", body)
return err
}
|
[
"func",
"Register",
"(",
"c",
"*",
"client",
".",
"Client",
",",
"username",
",",
"password",
",",
"email",
"string",
")",
"error",
"{",
"user",
":=",
"api",
".",
"AuthRegisterRequest",
"{",
"Username",
":",
"username",
",",
"Password",
":",
"password",
",",
"Email",
":",
"email",
"}",
"\n",
"body",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"user",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"_",
",",
"err",
"=",
"c",
".",
"BasicRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"body",
")",
"\n",
"return",
"err",
"\n",
"}"
] |
// Register a new user with the controller.
|
[
"Register",
"a",
"new",
"user",
"with",
"the",
"controller",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/auth/auth.go#L11-L21
|
142,835 |
deis/deis
|
client/controller/models/auth/auth.go
|
Regenerate
|
func Regenerate(c *client.Client, username string, all bool) (string, error) {
var reqBody []byte
var err error
if all == true {
reqBody, err = json.Marshal(api.AuthRegenerateRequest{All: all})
} else if username != "" {
reqBody, err = json.Marshal(api.AuthRegenerateRequest{Name: username})
}
if err != nil {
return "", err
}
body, err := c.BasicRequest("POST", "/v1/auth/tokens/", reqBody)
if err != nil {
return "", err
}
if all == true {
return "", nil
}
token := api.AuthRegenerateResponse{}
if err = json.Unmarshal([]byte(body), &token); err != nil {
return "", err
}
return token.Token, nil
}
|
go
|
func Regenerate(c *client.Client, username string, all bool) (string, error) {
var reqBody []byte
var err error
if all == true {
reqBody, err = json.Marshal(api.AuthRegenerateRequest{All: all})
} else if username != "" {
reqBody, err = json.Marshal(api.AuthRegenerateRequest{Name: username})
}
if err != nil {
return "", err
}
body, err := c.BasicRequest("POST", "/v1/auth/tokens/", reqBody)
if err != nil {
return "", err
}
if all == true {
return "", nil
}
token := api.AuthRegenerateResponse{}
if err = json.Unmarshal([]byte(body), &token); err != nil {
return "", err
}
return token.Token, nil
}
|
[
"func",
"Regenerate",
"(",
"c",
"*",
"client",
".",
"Client",
",",
"username",
"string",
",",
"all",
"bool",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"reqBody",
"[",
"]",
"byte",
"\n",
"var",
"err",
"error",
"\n\n",
"if",
"all",
"==",
"true",
"{",
"reqBody",
",",
"err",
"=",
"json",
".",
"Marshal",
"(",
"api",
".",
"AuthRegenerateRequest",
"{",
"All",
":",
"all",
"}",
")",
"\n",
"}",
"else",
"if",
"username",
"!=",
"\"",
"\"",
"{",
"reqBody",
",",
"err",
"=",
"json",
".",
"Marshal",
"(",
"api",
".",
"AuthRegenerateRequest",
"{",
"Name",
":",
"username",
"}",
")",
"\n",
"}",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"body",
",",
"err",
":=",
"c",
".",
"BasicRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"reqBody",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"all",
"==",
"true",
"{",
"return",
"\"",
"\"",
",",
"nil",
"\n",
"}",
"\n\n",
"token",
":=",
"api",
".",
"AuthRegenerateResponse",
"{",
"}",
"\n",
"if",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"body",
")",
",",
"&",
"token",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"token",
".",
"Token",
",",
"nil",
"\n",
"}"
] |
// Regenerate user's auth tokens.
|
[
"Regenerate",
"user",
"s",
"auth",
"tokens",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/auth/auth.go#L65-L95
|
142,836 |
deis/deis
|
client/controller/models/apps/apps.go
|
List
|
func List(c *client.Client, results int) (api.Apps, int, error) {
body, count, err := c.LimitedRequest("/v1/apps/", results)
if err != nil {
return []api.App{}, -1, err
}
var apps []api.App
if err = json.Unmarshal([]byte(body), &apps); err != nil {
return []api.App{}, -1, err
}
return apps, count, nil
}
|
go
|
func List(c *client.Client, results int) (api.Apps, int, error) {
body, count, err := c.LimitedRequest("/v1/apps/", results)
if err != nil {
return []api.App{}, -1, err
}
var apps []api.App
if err = json.Unmarshal([]byte(body), &apps); err != nil {
return []api.App{}, -1, err
}
return apps, count, nil
}
|
[
"func",
"List",
"(",
"c",
"*",
"client",
".",
"Client",
",",
"results",
"int",
")",
"(",
"api",
".",
"Apps",
",",
"int",
",",
"error",
")",
"{",
"body",
",",
"count",
",",
"err",
":=",
"c",
".",
"LimitedRequest",
"(",
"\"",
"\"",
",",
"results",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"[",
"]",
"api",
".",
"App",
"{",
"}",
",",
"-",
"1",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"apps",
"[",
"]",
"api",
".",
"App",
"\n",
"if",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"body",
")",
",",
"&",
"apps",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"[",
"]",
"api",
".",
"App",
"{",
"}",
",",
"-",
"1",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"apps",
",",
"count",
",",
"nil",
"\n",
"}"
] |
// List lists apps on a Deis controller.
|
[
"List",
"lists",
"apps",
"on",
"a",
"Deis",
"controller",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/apps/apps.go#L14-L27
|
142,837 |
deis/deis
|
client/controller/models/apps/apps.go
|
New
|
func New(c *client.Client, id string) (api.App, error) {
body := []byte{}
var err error
if id != "" {
req := api.AppCreateRequest{ID: id}
body, err = json.Marshal(req)
if err != nil {
return api.App{}, err
}
}
resBody, err := c.BasicRequest("POST", "/v1/apps/", body)
if err != nil {
return api.App{}, err
}
app := api.App{}
if err = json.Unmarshal([]byte(resBody), &app); err != nil {
return api.App{}, err
}
return app, nil
}
|
go
|
func New(c *client.Client, id string) (api.App, error) {
body := []byte{}
var err error
if id != "" {
req := api.AppCreateRequest{ID: id}
body, err = json.Marshal(req)
if err != nil {
return api.App{}, err
}
}
resBody, err := c.BasicRequest("POST", "/v1/apps/", body)
if err != nil {
return api.App{}, err
}
app := api.App{}
if err = json.Unmarshal([]byte(resBody), &app); err != nil {
return api.App{}, err
}
return app, nil
}
|
[
"func",
"New",
"(",
"c",
"*",
"client",
".",
"Client",
",",
"id",
"string",
")",
"(",
"api",
".",
"App",
",",
"error",
")",
"{",
"body",
":=",
"[",
"]",
"byte",
"{",
"}",
"\n\n",
"var",
"err",
"error",
"\n",
"if",
"id",
"!=",
"\"",
"\"",
"{",
"req",
":=",
"api",
".",
"AppCreateRequest",
"{",
"ID",
":",
"id",
"}",
"\n",
"body",
",",
"err",
"=",
"json",
".",
"Marshal",
"(",
"req",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"api",
".",
"App",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"resBody",
",",
"err",
":=",
"c",
".",
"BasicRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"body",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"api",
".",
"App",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"app",
":=",
"api",
".",
"App",
"{",
"}",
"\n",
"if",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"resBody",
")",
",",
"&",
"app",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"api",
".",
"App",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"app",
",",
"nil",
"\n",
"}"
] |
// New creates a new app.
|
[
"New",
"creates",
"a",
"new",
"app",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/apps/apps.go#L30-L55
|
142,838 |
deis/deis
|
client/controller/models/apps/apps.go
|
Get
|
func Get(c *client.Client, appID string) (api.App, error) {
u := fmt.Sprintf("/v1/apps/%s/", appID)
body, err := c.BasicRequest("GET", u, nil)
if err != nil {
return api.App{}, err
}
app := api.App{}
if err = json.Unmarshal([]byte(body), &app); err != nil {
return api.App{}, err
}
return app, nil
}
|
go
|
func Get(c *client.Client, appID string) (api.App, error) {
u := fmt.Sprintf("/v1/apps/%s/", appID)
body, err := c.BasicRequest("GET", u, nil)
if err != nil {
return api.App{}, err
}
app := api.App{}
if err = json.Unmarshal([]byte(body), &app); err != nil {
return api.App{}, err
}
return app, nil
}
|
[
"func",
"Get",
"(",
"c",
"*",
"client",
".",
"Client",
",",
"appID",
"string",
")",
"(",
"api",
".",
"App",
",",
"error",
")",
"{",
"u",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"appID",
")",
"\n\n",
"body",
",",
"err",
":=",
"c",
".",
"BasicRequest",
"(",
"\"",
"\"",
",",
"u",
",",
"nil",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"api",
".",
"App",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"app",
":=",
"api",
".",
"App",
"{",
"}",
"\n\n",
"if",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"body",
")",
",",
"&",
"app",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"api",
".",
"App",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"app",
",",
"nil",
"\n",
"}"
] |
// Get app details from a Deis controller.
|
[
"Get",
"app",
"details",
"from",
"a",
"Deis",
"controller",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/apps/apps.go#L58-L74
|
142,839 |
deis/deis
|
client/controller/models/apps/apps.go
|
Logs
|
func Logs(c *client.Client, appID string, lines int) (string, error) {
u := fmt.Sprintf("/v1/apps/%s/logs", appID)
if lines > 0 {
u += "?log_lines=" + strconv.Itoa(lines)
}
body, err := c.BasicRequest("GET", u, nil)
if err != nil {
return "", err
}
return strings.Trim(body, `"`), nil
}
|
go
|
func Logs(c *client.Client, appID string, lines int) (string, error) {
u := fmt.Sprintf("/v1/apps/%s/logs", appID)
if lines > 0 {
u += "?log_lines=" + strconv.Itoa(lines)
}
body, err := c.BasicRequest("GET", u, nil)
if err != nil {
return "", err
}
return strings.Trim(body, `"`), nil
}
|
[
"func",
"Logs",
"(",
"c",
"*",
"client",
".",
"Client",
",",
"appID",
"string",
",",
"lines",
"int",
")",
"(",
"string",
",",
"error",
")",
"{",
"u",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"appID",
")",
"\n\n",
"if",
"lines",
">",
"0",
"{",
"u",
"+=",
"\"",
"\"",
"+",
"strconv",
".",
"Itoa",
"(",
"lines",
")",
"\n",
"}",
"\n\n",
"body",
",",
"err",
":=",
"c",
".",
"BasicRequest",
"(",
"\"",
"\"",
",",
"u",
",",
"nil",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"strings",
".",
"Trim",
"(",
"body",
",",
"`\"`",
")",
",",
"nil",
"\n",
"}"
] |
// Logs retrieves logs from an app.
|
[
"Logs",
"retrieves",
"logs",
"from",
"an",
"app",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/apps/apps.go#L77-L91
|
142,840 |
deis/deis
|
client/controller/models/apps/apps.go
|
Run
|
func Run(c *client.Client, appID string, command string) (api.AppRunResponse, error) {
req := api.AppRunRequest{Command: command}
body, err := json.Marshal(req)
if err != nil {
return api.AppRunResponse{}, err
}
u := fmt.Sprintf("/v1/apps/%s/run", appID)
resBody, err := c.BasicRequest("POST", u, body)
if err != nil {
return api.AppRunResponse{}, err
}
out := make([]interface{}, 2)
if err = json.Unmarshal([]byte(resBody), &out); err != nil {
return api.AppRunResponse{}, err
}
return api.AppRunResponse{Output: out[1].(string), ReturnCode: int(out[0].(float64))}, nil
}
|
go
|
func Run(c *client.Client, appID string, command string) (api.AppRunResponse, error) {
req := api.AppRunRequest{Command: command}
body, err := json.Marshal(req)
if err != nil {
return api.AppRunResponse{}, err
}
u := fmt.Sprintf("/v1/apps/%s/run", appID)
resBody, err := c.BasicRequest("POST", u, body)
if err != nil {
return api.AppRunResponse{}, err
}
out := make([]interface{}, 2)
if err = json.Unmarshal([]byte(resBody), &out); err != nil {
return api.AppRunResponse{}, err
}
return api.AppRunResponse{Output: out[1].(string), ReturnCode: int(out[0].(float64))}, nil
}
|
[
"func",
"Run",
"(",
"c",
"*",
"client",
".",
"Client",
",",
"appID",
"string",
",",
"command",
"string",
")",
"(",
"api",
".",
"AppRunResponse",
",",
"error",
")",
"{",
"req",
":=",
"api",
".",
"AppRunRequest",
"{",
"Command",
":",
"command",
"}",
"\n",
"body",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"req",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"api",
".",
"AppRunResponse",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"u",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"appID",
")",
"\n\n",
"resBody",
",",
"err",
":=",
"c",
".",
"BasicRequest",
"(",
"\"",
"\"",
",",
"u",
",",
"body",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"api",
".",
"AppRunResponse",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"out",
":=",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"2",
")",
"\n\n",
"if",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"resBody",
")",
",",
"&",
"out",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"api",
".",
"AppRunResponse",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"api",
".",
"AppRunResponse",
"{",
"Output",
":",
"out",
"[",
"1",
"]",
".",
"(",
"string",
")",
",",
"ReturnCode",
":",
"int",
"(",
"out",
"[",
"0",
"]",
".",
"(",
"float64",
")",
")",
"}",
",",
"nil",
"\n",
"}"
] |
// Run one time command in an app.
|
[
"Run",
"one",
"time",
"command",
"in",
"an",
"app",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/apps/apps.go#L94-L117
|
142,841 |
deis/deis
|
deisctl/backend/fleet/fleet.go
|
NewClient
|
func NewClient(cb config.Backend) (*FleetClient, error) {
client, err := getRegistryClient()
if err != nil {
return nil, err
}
// path hierarchy for finding systemd service templates
templatePaths := []string{
os.Getenv("DEISCTL_UNITS"),
path.Join(os.Getenv("HOME"), ".deis", "units"),
"/var/lib/deis/units",
}
out := new(tabwriter.Writer)
out.Init(os.Stdout, 0, 8, 1, '\t', 0)
return &FleetClient{Fleet: client, configBackend: cb, templatePaths: templatePaths, runner: sshCommandRunner{},
out: out, errWriter: os.Stderr}, nil
}
|
go
|
func NewClient(cb config.Backend) (*FleetClient, error) {
client, err := getRegistryClient()
if err != nil {
return nil, err
}
// path hierarchy for finding systemd service templates
templatePaths := []string{
os.Getenv("DEISCTL_UNITS"),
path.Join(os.Getenv("HOME"), ".deis", "units"),
"/var/lib/deis/units",
}
out := new(tabwriter.Writer)
out.Init(os.Stdout, 0, 8, 1, '\t', 0)
return &FleetClient{Fleet: client, configBackend: cb, templatePaths: templatePaths, runner: sshCommandRunner{},
out: out, errWriter: os.Stderr}, nil
}
|
[
"func",
"NewClient",
"(",
"cb",
"config",
".",
"Backend",
")",
"(",
"*",
"FleetClient",
",",
"error",
")",
"{",
"client",
",",
"err",
":=",
"getRegistryClient",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// path hierarchy for finding systemd service templates",
"templatePaths",
":=",
"[",
"]",
"string",
"{",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
",",
"path",
".",
"Join",
"(",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
",",
"\"",
"\"",
",",
"}",
"\n\n",
"out",
":=",
"new",
"(",
"tabwriter",
".",
"Writer",
")",
"\n",
"out",
".",
"Init",
"(",
"os",
".",
"Stdout",
",",
"0",
",",
"8",
",",
"1",
",",
"'\\t'",
",",
"0",
")",
"\n\n",
"return",
"&",
"FleetClient",
"{",
"Fleet",
":",
"client",
",",
"configBackend",
":",
"cb",
",",
"templatePaths",
":",
"templatePaths",
",",
"runner",
":",
"sshCommandRunner",
"{",
"}",
",",
"out",
":",
"out",
",",
"errWriter",
":",
"os",
".",
"Stderr",
"}",
",",
"nil",
"\n",
"}"
] |
// NewClient returns a client used to communicate with Fleet
// using the Registry API
|
[
"NewClient",
"returns",
"a",
"client",
"used",
"to",
"communicate",
"with",
"Fleet",
"using",
"the",
"Registry",
"API"
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/fleet.go#L31-L49
|
142,842 |
deis/deis
|
publisher/server/publisher.go
|
New
|
func New(dockerClient *docker.Client, etcdClient *etcd.Client, host, logLevel string) *Server {
return &Server{
DockerClient: dockerClient,
EtcdClient: etcdClient,
host: host,
logLevel: logLevel,
}
}
|
go
|
func New(dockerClient *docker.Client, etcdClient *etcd.Client, host, logLevel string) *Server {
return &Server{
DockerClient: dockerClient,
EtcdClient: etcdClient,
host: host,
logLevel: logLevel,
}
}
|
[
"func",
"New",
"(",
"dockerClient",
"*",
"docker",
".",
"Client",
",",
"etcdClient",
"*",
"etcd",
".",
"Client",
",",
"host",
",",
"logLevel",
"string",
")",
"*",
"Server",
"{",
"return",
"&",
"Server",
"{",
"DockerClient",
":",
"dockerClient",
",",
"EtcdClient",
":",
"etcdClient",
",",
"host",
":",
"host",
",",
"logLevel",
":",
"logLevel",
",",
"}",
"\n",
"}"
] |
// New returns a new instance of Server.
|
[
"New",
"returns",
"a",
"new",
"instance",
"of",
"Server",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/publisher/server/publisher.go#L37-L44
|
142,843 |
deis/deis
|
publisher/server/publisher.go
|
Listen
|
func (s *Server) Listen(ttl time.Duration) {
listener := make(chan *docker.APIEvents)
// TODO: figure out why we need to sleep for 10 milliseconds
// https://github.com/fsouza/go-dockerclient/blob/0236a64c6c4bd563ec277ba00e370cc753e1677c/event_test.go#L43
defer func() { time.Sleep(10 * time.Millisecond); s.DockerClient.RemoveEventListener(listener) }()
if err := s.DockerClient.AddEventListener(listener); err != nil {
log.Fatal(err)
}
for {
select {
case event := <-listener:
if event.Status == "start" {
container, err := s.getContainer(event.ID)
if err != nil {
log.Println(err)
continue
}
s.publishContainer(container, ttl)
} else if event.Status == "stop" {
s.removeContainer(event.ID)
}
}
}
}
|
go
|
func (s *Server) Listen(ttl time.Duration) {
listener := make(chan *docker.APIEvents)
// TODO: figure out why we need to sleep for 10 milliseconds
// https://github.com/fsouza/go-dockerclient/blob/0236a64c6c4bd563ec277ba00e370cc753e1677c/event_test.go#L43
defer func() { time.Sleep(10 * time.Millisecond); s.DockerClient.RemoveEventListener(listener) }()
if err := s.DockerClient.AddEventListener(listener); err != nil {
log.Fatal(err)
}
for {
select {
case event := <-listener:
if event.Status == "start" {
container, err := s.getContainer(event.ID)
if err != nil {
log.Println(err)
continue
}
s.publishContainer(container, ttl)
} else if event.Status == "stop" {
s.removeContainer(event.ID)
}
}
}
}
|
[
"func",
"(",
"s",
"*",
"Server",
")",
"Listen",
"(",
"ttl",
"time",
".",
"Duration",
")",
"{",
"listener",
":=",
"make",
"(",
"chan",
"*",
"docker",
".",
"APIEvents",
")",
"\n",
"// TODO: figure out why we need to sleep for 10 milliseconds",
"// https://github.com/fsouza/go-dockerclient/blob/0236a64c6c4bd563ec277ba00e370cc753e1677c/event_test.go#L43",
"defer",
"func",
"(",
")",
"{",
"time",
".",
"Sleep",
"(",
"10",
"*",
"time",
".",
"Millisecond",
")",
";",
"s",
".",
"DockerClient",
".",
"RemoveEventListener",
"(",
"listener",
")",
"}",
"(",
")",
"\n",
"if",
"err",
":=",
"s",
".",
"DockerClient",
".",
"AddEventListener",
"(",
"listener",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatal",
"(",
"err",
")",
"\n",
"}",
"\n",
"for",
"{",
"select",
"{",
"case",
"event",
":=",
"<-",
"listener",
":",
"if",
"event",
".",
"Status",
"==",
"\"",
"\"",
"{",
"container",
",",
"err",
":=",
"s",
".",
"getContainer",
"(",
"event",
".",
"ID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Println",
"(",
"err",
")",
"\n",
"continue",
"\n",
"}",
"\n",
"s",
".",
"publishContainer",
"(",
"container",
",",
"ttl",
")",
"\n",
"}",
"else",
"if",
"event",
".",
"Status",
"==",
"\"",
"\"",
"{",
"s",
".",
"removeContainer",
"(",
"event",
".",
"ID",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
// Listen adds an event listener to the docker client and publishes containers that were started.
|
[
"Listen",
"adds",
"an",
"event",
"listener",
"to",
"the",
"docker",
"client",
"and",
"publishes",
"containers",
"that",
"were",
"started",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/publisher/server/publisher.go#L47-L70
|
142,844 |
deis/deis
|
publisher/server/publisher.go
|
Poll
|
func (s *Server) Poll(ttl time.Duration) {
containers, err := s.DockerClient.ListContainers(docker.ListContainersOptions{})
if err != nil {
log.Fatal(err)
}
var wg sync.WaitGroup
for _, container := range containers {
wg.Add(1)
go func(container docker.APIContainers, ttl time.Duration) {
defer wg.Done()
// send container to channel for processing
s.publishContainer(&container, ttl)
}(container, ttl)
}
// Wait for all publish operations to complete.
wg.Wait()
}
|
go
|
func (s *Server) Poll(ttl time.Duration) {
containers, err := s.DockerClient.ListContainers(docker.ListContainersOptions{})
if err != nil {
log.Fatal(err)
}
var wg sync.WaitGroup
for _, container := range containers {
wg.Add(1)
go func(container docker.APIContainers, ttl time.Duration) {
defer wg.Done()
// send container to channel for processing
s.publishContainer(&container, ttl)
}(container, ttl)
}
// Wait for all publish operations to complete.
wg.Wait()
}
|
[
"func",
"(",
"s",
"*",
"Server",
")",
"Poll",
"(",
"ttl",
"time",
".",
"Duration",
")",
"{",
"containers",
",",
"err",
":=",
"s",
".",
"DockerClient",
".",
"ListContainers",
"(",
"docker",
".",
"ListContainersOptions",
"{",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatal",
"(",
"err",
")",
"\n",
"}",
"\n",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n",
"for",
"_",
",",
"container",
":=",
"range",
"containers",
"{",
"wg",
".",
"Add",
"(",
"1",
")",
"\n",
"go",
"func",
"(",
"container",
"docker",
".",
"APIContainers",
",",
"ttl",
"time",
".",
"Duration",
")",
"{",
"defer",
"wg",
".",
"Done",
"(",
")",
"\n",
"// send container to channel for processing",
"s",
".",
"publishContainer",
"(",
"&",
"container",
",",
"ttl",
")",
"\n",
"}",
"(",
"container",
",",
"ttl",
")",
"\n",
"}",
"\n",
"// Wait for all publish operations to complete.",
"wg",
".",
"Wait",
"(",
")",
"\n",
"}"
] |
// Poll lists all containers from the docker client every time the TTL comes up and publishes them to etcd
|
[
"Poll",
"lists",
"all",
"containers",
"from",
"the",
"docker",
"client",
"every",
"time",
"the",
"TTL",
"comes",
"up",
"and",
"publishes",
"them",
"to",
"etcd"
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/publisher/server/publisher.go#L73-L89
|
142,845 |
deis/deis
|
publisher/server/publisher.go
|
getContainer
|
func (s *Server) getContainer(id string) (*docker.APIContainers, error) {
containers, err := s.DockerClient.ListContainers(docker.ListContainersOptions{})
if err != nil {
return nil, err
}
for _, container := range containers {
// send container to channel for processing
if container.ID == id {
return &container, nil
}
}
return nil, fmt.Errorf("could not find container with id %v", id)
}
|
go
|
func (s *Server) getContainer(id string) (*docker.APIContainers, error) {
containers, err := s.DockerClient.ListContainers(docker.ListContainersOptions{})
if err != nil {
return nil, err
}
for _, container := range containers {
// send container to channel for processing
if container.ID == id {
return &container, nil
}
}
return nil, fmt.Errorf("could not find container with id %v", id)
}
|
[
"func",
"(",
"s",
"*",
"Server",
")",
"getContainer",
"(",
"id",
"string",
")",
"(",
"*",
"docker",
".",
"APIContainers",
",",
"error",
")",
"{",
"containers",
",",
"err",
":=",
"s",
".",
"DockerClient",
".",
"ListContainers",
"(",
"docker",
".",
"ListContainersOptions",
"{",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"for",
"_",
",",
"container",
":=",
"range",
"containers",
"{",
"// send container to channel for processing",
"if",
"container",
".",
"ID",
"==",
"id",
"{",
"return",
"&",
"container",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"id",
")",
"\n",
"}"
] |
// getContainer retrieves a container from the docker client based on id
|
[
"getContainer",
"retrieves",
"a",
"container",
"from",
"the",
"docker",
"client",
"based",
"on",
"id"
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/publisher/server/publisher.go#L92-L104
|
142,846 |
deis/deis
|
publisher/server/publisher.go
|
publishContainer
|
func (s *Server) publishContainer(container *docker.APIContainers, ttl time.Duration) {
r := regexp.MustCompile(appNameRegex)
for _, name := range container.Names {
// HACK: remove slash from container name
// see https://github.com/docker/docker/issues/7519
containerName := name[1:]
match := r.FindStringSubmatch(containerName)
if match == nil {
continue
}
appName := match[1]
appPath := fmt.Sprintf("%s/%s", appName, containerName)
keyPath := fmt.Sprintf("/deis/services/%s", appPath)
for _, p := range container.Ports {
var delay int
var timeout int
var err error
// lowest port wins (docker sorts the ports)
// TODO (bacongobbler): support multiple exposed ports
port := strconv.Itoa(int(p.PublicPort))
hostAndPort := s.host + ":" + port
if s.IsPublishableApp(containerName) && s.IsPortOpen(hostAndPort) {
configKey := fmt.Sprintf("/deis/config/%s/", appName)
// check if the user specified a healthcheck URL
healthcheckURL := s.getEtcd(configKey + "healthcheck_url")
initialDelay := s.getEtcd(configKey + "healthcheck_initial_delay")
if initialDelay != "" {
delay, err = strconv.Atoi(initialDelay)
if err != nil {
log.Println(err)
delay = 0
}
} else {
delay = 0
}
healthcheckTimeout := s.getEtcd(configKey + "healthcheck_timeout")
if healthcheckTimeout != "" {
timeout, err = strconv.Atoi(healthcheckTimeout)
if err != nil {
log.Println(err)
timeout = 1
}
} else {
timeout = 1
}
if healthcheckURL != "" {
if !s.HealthCheckOK("http://"+hostAndPort+healthcheckURL, delay, timeout) {
continue
}
}
s.setEtcd(keyPath, hostAndPort, uint64(ttl.Seconds()))
safeMap.Lock()
safeMap.data[container.ID] = appPath
safeMap.Unlock()
}
break
}
}
}
|
go
|
func (s *Server) publishContainer(container *docker.APIContainers, ttl time.Duration) {
r := regexp.MustCompile(appNameRegex)
for _, name := range container.Names {
// HACK: remove slash from container name
// see https://github.com/docker/docker/issues/7519
containerName := name[1:]
match := r.FindStringSubmatch(containerName)
if match == nil {
continue
}
appName := match[1]
appPath := fmt.Sprintf("%s/%s", appName, containerName)
keyPath := fmt.Sprintf("/deis/services/%s", appPath)
for _, p := range container.Ports {
var delay int
var timeout int
var err error
// lowest port wins (docker sorts the ports)
// TODO (bacongobbler): support multiple exposed ports
port := strconv.Itoa(int(p.PublicPort))
hostAndPort := s.host + ":" + port
if s.IsPublishableApp(containerName) && s.IsPortOpen(hostAndPort) {
configKey := fmt.Sprintf("/deis/config/%s/", appName)
// check if the user specified a healthcheck URL
healthcheckURL := s.getEtcd(configKey + "healthcheck_url")
initialDelay := s.getEtcd(configKey + "healthcheck_initial_delay")
if initialDelay != "" {
delay, err = strconv.Atoi(initialDelay)
if err != nil {
log.Println(err)
delay = 0
}
} else {
delay = 0
}
healthcheckTimeout := s.getEtcd(configKey + "healthcheck_timeout")
if healthcheckTimeout != "" {
timeout, err = strconv.Atoi(healthcheckTimeout)
if err != nil {
log.Println(err)
timeout = 1
}
} else {
timeout = 1
}
if healthcheckURL != "" {
if !s.HealthCheckOK("http://"+hostAndPort+healthcheckURL, delay, timeout) {
continue
}
}
s.setEtcd(keyPath, hostAndPort, uint64(ttl.Seconds()))
safeMap.Lock()
safeMap.data[container.ID] = appPath
safeMap.Unlock()
}
break
}
}
}
|
[
"func",
"(",
"s",
"*",
"Server",
")",
"publishContainer",
"(",
"container",
"*",
"docker",
".",
"APIContainers",
",",
"ttl",
"time",
".",
"Duration",
")",
"{",
"r",
":=",
"regexp",
".",
"MustCompile",
"(",
"appNameRegex",
")",
"\n",
"for",
"_",
",",
"name",
":=",
"range",
"container",
".",
"Names",
"{",
"// HACK: remove slash from container name",
"// see https://github.com/docker/docker/issues/7519",
"containerName",
":=",
"name",
"[",
"1",
":",
"]",
"\n",
"match",
":=",
"r",
".",
"FindStringSubmatch",
"(",
"containerName",
")",
"\n",
"if",
"match",
"==",
"nil",
"{",
"continue",
"\n",
"}",
"\n",
"appName",
":=",
"match",
"[",
"1",
"]",
"\n",
"appPath",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"appName",
",",
"containerName",
")",
"\n",
"keyPath",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"appPath",
")",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"container",
".",
"Ports",
"{",
"var",
"delay",
"int",
"\n",
"var",
"timeout",
"int",
"\n",
"var",
"err",
"error",
"\n",
"// lowest port wins (docker sorts the ports)",
"// TODO (bacongobbler): support multiple exposed ports",
"port",
":=",
"strconv",
".",
"Itoa",
"(",
"int",
"(",
"p",
".",
"PublicPort",
")",
")",
"\n",
"hostAndPort",
":=",
"s",
".",
"host",
"+",
"\"",
"\"",
"+",
"port",
"\n",
"if",
"s",
".",
"IsPublishableApp",
"(",
"containerName",
")",
"&&",
"s",
".",
"IsPortOpen",
"(",
"hostAndPort",
")",
"{",
"configKey",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"appName",
")",
"\n",
"// check if the user specified a healthcheck URL",
"healthcheckURL",
":=",
"s",
".",
"getEtcd",
"(",
"configKey",
"+",
"\"",
"\"",
")",
"\n",
"initialDelay",
":=",
"s",
".",
"getEtcd",
"(",
"configKey",
"+",
"\"",
"\"",
")",
"\n",
"if",
"initialDelay",
"!=",
"\"",
"\"",
"{",
"delay",
",",
"err",
"=",
"strconv",
".",
"Atoi",
"(",
"initialDelay",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Println",
"(",
"err",
")",
"\n",
"delay",
"=",
"0",
"\n",
"}",
"\n",
"}",
"else",
"{",
"delay",
"=",
"0",
"\n",
"}",
"\n",
"healthcheckTimeout",
":=",
"s",
".",
"getEtcd",
"(",
"configKey",
"+",
"\"",
"\"",
")",
"\n",
"if",
"healthcheckTimeout",
"!=",
"\"",
"\"",
"{",
"timeout",
",",
"err",
"=",
"strconv",
".",
"Atoi",
"(",
"healthcheckTimeout",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Println",
"(",
"err",
")",
"\n",
"timeout",
"=",
"1",
"\n",
"}",
"\n",
"}",
"else",
"{",
"timeout",
"=",
"1",
"\n",
"}",
"\n",
"if",
"healthcheckURL",
"!=",
"\"",
"\"",
"{",
"if",
"!",
"s",
".",
"HealthCheckOK",
"(",
"\"",
"\"",
"+",
"hostAndPort",
"+",
"healthcheckURL",
",",
"delay",
",",
"timeout",
")",
"{",
"continue",
"\n",
"}",
"\n",
"}",
"\n",
"s",
".",
"setEtcd",
"(",
"keyPath",
",",
"hostAndPort",
",",
"uint64",
"(",
"ttl",
".",
"Seconds",
"(",
")",
")",
")",
"\n",
"safeMap",
".",
"Lock",
"(",
")",
"\n",
"safeMap",
".",
"data",
"[",
"container",
".",
"ID",
"]",
"=",
"appPath",
"\n",
"safeMap",
".",
"Unlock",
"(",
")",
"\n",
"}",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
// publishContainer publishes the docker container to etcd.
|
[
"publishContainer",
"publishes",
"the",
"docker",
"container",
"to",
"etcd",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/publisher/server/publisher.go#L107-L165
|
142,847 |
deis/deis
|
publisher/server/publisher.go
|
removeContainer
|
func (s *Server) removeContainer(event string) {
safeMap.RLock()
appPath := safeMap.data[event]
safeMap.RUnlock()
if appPath != "" {
keyPath := fmt.Sprintf("/deis/services/%s", appPath)
log.Printf("stopped %s\n", keyPath)
s.removeEtcd(keyPath, false)
}
}
|
go
|
func (s *Server) removeContainer(event string) {
safeMap.RLock()
appPath := safeMap.data[event]
safeMap.RUnlock()
if appPath != "" {
keyPath := fmt.Sprintf("/deis/services/%s", appPath)
log.Printf("stopped %s\n", keyPath)
s.removeEtcd(keyPath, false)
}
}
|
[
"func",
"(",
"s",
"*",
"Server",
")",
"removeContainer",
"(",
"event",
"string",
")",
"{",
"safeMap",
".",
"RLock",
"(",
")",
"\n",
"appPath",
":=",
"safeMap",
".",
"data",
"[",
"event",
"]",
"\n",
"safeMap",
".",
"RUnlock",
"(",
")",
"\n\n",
"if",
"appPath",
"!=",
"\"",
"\"",
"{",
"keyPath",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"appPath",
")",
"\n",
"log",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"keyPath",
")",
"\n",
"s",
".",
"removeEtcd",
"(",
"keyPath",
",",
"false",
")",
"\n",
"}",
"\n",
"}"
] |
// removeContainer remove a container published by this component
|
[
"removeContainer",
"remove",
"a",
"container",
"published",
"by",
"this",
"component"
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/publisher/server/publisher.go#L168-L178
|
142,848 |
deis/deis
|
publisher/server/publisher.go
|
IsPublishableApp
|
func (s *Server) IsPublishableApp(name string) bool {
r := regexp.MustCompile(appNameRegex)
match := r.FindStringSubmatch(name)
if match == nil {
return false
}
appName := match[1]
version, err := strconv.Atoi(match[2])
if err != nil {
log.Println(err)
return false
}
if version >= latestRunningVersion(s.EtcdClient, appName) {
return true
}
return false
}
|
go
|
func (s *Server) IsPublishableApp(name string) bool {
r := regexp.MustCompile(appNameRegex)
match := r.FindStringSubmatch(name)
if match == nil {
return false
}
appName := match[1]
version, err := strconv.Atoi(match[2])
if err != nil {
log.Println(err)
return false
}
if version >= latestRunningVersion(s.EtcdClient, appName) {
return true
}
return false
}
|
[
"func",
"(",
"s",
"*",
"Server",
")",
"IsPublishableApp",
"(",
"name",
"string",
")",
"bool",
"{",
"r",
":=",
"regexp",
".",
"MustCompile",
"(",
"appNameRegex",
")",
"\n",
"match",
":=",
"r",
".",
"FindStringSubmatch",
"(",
"name",
")",
"\n",
"if",
"match",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"appName",
":=",
"match",
"[",
"1",
"]",
"\n",
"version",
",",
"err",
":=",
"strconv",
".",
"Atoi",
"(",
"match",
"[",
"2",
"]",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Println",
"(",
"err",
")",
"\n",
"return",
"false",
"\n",
"}",
"\n\n",
"if",
"version",
">=",
"latestRunningVersion",
"(",
"s",
".",
"EtcdClient",
",",
"appName",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] |
// IsPublishableApp determines if the application should be published to etcd.
|
[
"IsPublishableApp",
"determines",
"if",
"the",
"application",
"should",
"be",
"published",
"to",
"etcd",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/publisher/server/publisher.go#L181-L198
|
142,849 |
deis/deis
|
publisher/server/publisher.go
|
IsPortOpen
|
func (s *Server) IsPortOpen(hostAndPort string) bool {
portOpen := false
conn, err := net.Dial("tcp", hostAndPort)
if err == nil {
portOpen = true
defer conn.Close()
}
return portOpen
}
|
go
|
func (s *Server) IsPortOpen(hostAndPort string) bool {
portOpen := false
conn, err := net.Dial("tcp", hostAndPort)
if err == nil {
portOpen = true
defer conn.Close()
}
return portOpen
}
|
[
"func",
"(",
"s",
"*",
"Server",
")",
"IsPortOpen",
"(",
"hostAndPort",
"string",
")",
"bool",
"{",
"portOpen",
":=",
"false",
"\n",
"conn",
",",
"err",
":=",
"net",
".",
"Dial",
"(",
"\"",
"\"",
",",
"hostAndPort",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"portOpen",
"=",
"true",
"\n",
"defer",
"conn",
".",
"Close",
"(",
")",
"\n",
"}",
"\n",
"return",
"portOpen",
"\n",
"}"
] |
// IsPortOpen checks if the given port is accepting tcp connections
|
[
"IsPortOpen",
"checks",
"if",
"the",
"given",
"port",
"is",
"accepting",
"tcp",
"connections"
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/publisher/server/publisher.go#L201-L209
|
142,850 |
deis/deis
|
publisher/server/publisher.go
|
max
|
func max(n []int) int {
val := 0
for _, i := range n {
if i > val {
val = i
}
}
return val
}
|
go
|
func max(n []int) int {
val := 0
for _, i := range n {
if i > val {
val = i
}
}
return val
}
|
[
"func",
"max",
"(",
"n",
"[",
"]",
"int",
")",
"int",
"{",
"val",
":=",
"0",
"\n",
"for",
"_",
",",
"i",
":=",
"range",
"n",
"{",
"if",
"i",
">",
"val",
"{",
"val",
"=",
"i",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"val",
"\n",
"}"
] |
// max returns the maximum value in n
|
[
"max",
"returns",
"the",
"maximum",
"value",
"in",
"n"
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/publisher/server/publisher.go#L262-L270
|
142,851 |
deis/deis
|
publisher/server/publisher.go
|
getEtcd
|
func (s *Server) getEtcd(key string) string {
if s.logLevel == "debug" {
log.Println("get", key)
}
resp, err := s.EtcdClient.Get(key, false, false)
if err != nil {
return ""
}
if resp != nil && resp.Node != nil {
return resp.Node.Value
}
return ""
}
|
go
|
func (s *Server) getEtcd(key string) string {
if s.logLevel == "debug" {
log.Println("get", key)
}
resp, err := s.EtcdClient.Get(key, false, false)
if err != nil {
return ""
}
if resp != nil && resp.Node != nil {
return resp.Node.Value
}
return ""
}
|
[
"func",
"(",
"s",
"*",
"Server",
")",
"getEtcd",
"(",
"key",
"string",
")",
"string",
"{",
"if",
"s",
".",
"logLevel",
"==",
"\"",
"\"",
"{",
"log",
".",
"Println",
"(",
"\"",
"\"",
",",
"key",
")",
"\n",
"}",
"\n",
"resp",
",",
"err",
":=",
"s",
".",
"EtcdClient",
".",
"Get",
"(",
"key",
",",
"false",
",",
"false",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"if",
"resp",
"!=",
"nil",
"&&",
"resp",
".",
"Node",
"!=",
"nil",
"{",
"return",
"resp",
".",
"Node",
".",
"Value",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] |
// getEtcd retrieves the etcd key's value. Returns an empty string if the key was not found.
|
[
"getEtcd",
"retrieves",
"the",
"etcd",
"key",
"s",
"value",
".",
"Returns",
"an",
"empty",
"string",
"if",
"the",
"key",
"was",
"not",
"found",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/publisher/server/publisher.go#L273-L285
|
142,852 |
deis/deis
|
publisher/server/publisher.go
|
setEtcd
|
func (s *Server) setEtcd(key, value string, ttl uint64) {
if _, err := s.EtcdClient.Set(key, value, ttl); err != nil {
log.Println(err)
}
if s.logLevel == "debug" {
log.Println("set", key, "->", value)
}
}
|
go
|
func (s *Server) setEtcd(key, value string, ttl uint64) {
if _, err := s.EtcdClient.Set(key, value, ttl); err != nil {
log.Println(err)
}
if s.logLevel == "debug" {
log.Println("set", key, "->", value)
}
}
|
[
"func",
"(",
"s",
"*",
"Server",
")",
"setEtcd",
"(",
"key",
",",
"value",
"string",
",",
"ttl",
"uint64",
")",
"{",
"if",
"_",
",",
"err",
":=",
"s",
".",
"EtcdClient",
".",
"Set",
"(",
"key",
",",
"value",
",",
"ttl",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Println",
"(",
"err",
")",
"\n",
"}",
"\n",
"if",
"s",
".",
"logLevel",
"==",
"\"",
"\"",
"{",
"log",
".",
"Println",
"(",
"\"",
"\"",
",",
"key",
",",
"\"",
"\"",
",",
"value",
")",
"\n",
"}",
"\n",
"}"
] |
// setEtcd sets the corresponding etcd key with the value and ttl
|
[
"setEtcd",
"sets",
"the",
"corresponding",
"etcd",
"key",
"with",
"the",
"value",
"and",
"ttl"
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/publisher/server/publisher.go#L288-L295
|
142,853 |
deis/deis
|
publisher/server/publisher.go
|
removeEtcd
|
func (s *Server) removeEtcd(key string, recursive bool) {
if _, err := s.EtcdClient.Delete(key, recursive); err != nil {
log.Println(err)
}
if s.logLevel == "debug" {
log.Println("del", key)
}
}
|
go
|
func (s *Server) removeEtcd(key string, recursive bool) {
if _, err := s.EtcdClient.Delete(key, recursive); err != nil {
log.Println(err)
}
if s.logLevel == "debug" {
log.Println("del", key)
}
}
|
[
"func",
"(",
"s",
"*",
"Server",
")",
"removeEtcd",
"(",
"key",
"string",
",",
"recursive",
"bool",
")",
"{",
"if",
"_",
",",
"err",
":=",
"s",
".",
"EtcdClient",
".",
"Delete",
"(",
"key",
",",
"recursive",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Println",
"(",
"err",
")",
"\n",
"}",
"\n",
"if",
"s",
".",
"logLevel",
"==",
"\"",
"\"",
"{",
"log",
".",
"Println",
"(",
"\"",
"\"",
",",
"key",
")",
"\n",
"}",
"\n",
"}"
] |
// removeEtcd removes the corresponding etcd key
|
[
"removeEtcd",
"removes",
"the",
"corresponding",
"etcd",
"key"
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/publisher/server/publisher.go#L298-L305
|
142,854 |
deis/deis
|
client/controller/models/perms/perms.go
|
Delete
|
func Delete(c *client.Client, appID string, username string) error {
return doDelete(c, fmt.Sprintf("/v1/apps/%s/perms/%s", appID, username))
}
|
go
|
func Delete(c *client.Client, appID string, username string) error {
return doDelete(c, fmt.Sprintf("/v1/apps/%s/perms/%s", appID, username))
}
|
[
"func",
"Delete",
"(",
"c",
"*",
"client",
".",
"Client",
",",
"appID",
"string",
",",
"username",
"string",
")",
"error",
"{",
"return",
"doDelete",
"(",
"c",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"appID",
",",
"username",
")",
")",
"\n",
"}"
] |
// Delete removes a user from an app.
|
[
"Delete",
"removes",
"a",
"user",
"from",
"an",
"app",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/perms/perms.go#L78-L80
|
142,855 |
deis/deis
|
client/controller/models/perms/perms.go
|
DeleteAdmin
|
func DeleteAdmin(c *client.Client, username string) error {
return doDelete(c, fmt.Sprintf("/v1/admin/perms/%s", username))
}
|
go
|
func DeleteAdmin(c *client.Client, username string) error {
return doDelete(c, fmt.Sprintf("/v1/admin/perms/%s", username))
}
|
[
"func",
"DeleteAdmin",
"(",
"c",
"*",
"client",
".",
"Client",
",",
"username",
"string",
")",
"error",
"{",
"return",
"doDelete",
"(",
"c",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"username",
")",
")",
"\n",
"}"
] |
// DeleteAdmin removes administrative privilages from a user.
|
[
"DeleteAdmin",
"removes",
"administrative",
"privilages",
"from",
"a",
"user",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/perms/perms.go#L83-L85
|
142,856 |
deis/deis
|
client/cmd/utils.go
|
chooseColor
|
func chooseColor(input string) string {
var sum uint8
for _, char := range []byte(input) {
sum += uint8(char)
}
// Seven possible terminal colors
color := (sum % 7) + 1
if color == 7 {
color = 9
}
return fmt.Sprintf("\033[3%dm", color)
}
|
go
|
func chooseColor(input string) string {
var sum uint8
for _, char := range []byte(input) {
sum += uint8(char)
}
// Seven possible terminal colors
color := (sum % 7) + 1
if color == 7 {
color = 9
}
return fmt.Sprintf("\033[3%dm", color)
}
|
[
"func",
"chooseColor",
"(",
"input",
"string",
")",
"string",
"{",
"var",
"sum",
"uint8",
"\n\n",
"for",
"_",
",",
"char",
":=",
"range",
"[",
"]",
"byte",
"(",
"input",
")",
"{",
"sum",
"+=",
"uint8",
"(",
"char",
")",
"\n",
"}",
"\n\n",
"// Seven possible terminal colors",
"color",
":=",
"(",
"sum",
"%",
"7",
")",
"+",
"1",
"\n\n",
"if",
"color",
"==",
"7",
"{",
"color",
"=",
"9",
"\n",
"}",
"\n\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\033",
"\"",
",",
"color",
")",
"\n",
"}"
] |
// Choose an ANSI color by converting a string to an int.
|
[
"Choose",
"an",
"ANSI",
"color",
"by",
"converting",
"a",
"string",
"to",
"an",
"int",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/utils.go#L39-L54
|
142,857 |
deis/deis
|
deisctl/deisctl.go
|
removeGlobalArgs
|
func removeGlobalArgs(argv []string) []string {
var v []string
for _, a := range argv {
if !isGlobalArg(a) {
v = append(v, a)
}
}
return v
}
|
go
|
func removeGlobalArgs(argv []string) []string {
var v []string
for _, a := range argv {
if !isGlobalArg(a) {
v = append(v, a)
}
}
return v
}
|
[
"func",
"removeGlobalArgs",
"(",
"argv",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"var",
"v",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"a",
":=",
"range",
"argv",
"{",
"if",
"!",
"isGlobalArg",
"(",
"a",
")",
"{",
"v",
"=",
"append",
"(",
"v",
",",
"a",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"v",
"\n",
"}"
] |
// removeGlobalArgs returns the given args without any global option flags, to make
// re-parsing by subcommands easier.
|
[
"removeGlobalArgs",
"returns",
"the",
"given",
"args",
"without",
"any",
"global",
"option",
"flags",
"to",
"make",
"re",
"-",
"parsing",
"by",
"subcommands",
"easier",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/deisctl.go#L204-L212
|
142,858 |
deis/deis
|
deisctl/deisctl.go
|
setGlobalFlags
|
func setGlobalFlags(args map[string]interface{}, setTunnel bool) {
fleet.Flags.Endpoint = args["--endpoint"].(string)
fleet.Flags.EtcdKeyPrefix = args["--etcd-key-prefix"].(string)
fleet.Flags.EtcdKeyFile = args["--etcd-keyfile"].(string)
fleet.Flags.EtcdCertFile = args["--etcd-certfile"].(string)
fleet.Flags.EtcdCAFile = args["--etcd-cafile"].(string)
//fleet.Flags.UseAPI = args["--experimental-api"].(bool)
fleet.Flags.KnownHostsFile = args["--known-hosts-file"].(string)
fleet.Flags.StrictHostKeyChecking = args["--strict-host-key-checking"].(bool)
timeout, _ := strconv.ParseFloat(args["--request-timeout"].(string), 64)
fleet.Flags.RequestTimeout = timeout
sshTimeout, _ := strconv.ParseFloat(args["--ssh-timeout"].(string), 64)
fleet.Flags.SSHTimeout = sshTimeout
if setTunnel == true {
tunnel := args["--tunnel"].(string)
if tunnel != "" {
fleet.Flags.Tunnel = tunnel
} else {
fleet.Flags.Tunnel = os.Getenv("DEISCTL_TUNNEL")
}
}
}
|
go
|
func setGlobalFlags(args map[string]interface{}, setTunnel bool) {
fleet.Flags.Endpoint = args["--endpoint"].(string)
fleet.Flags.EtcdKeyPrefix = args["--etcd-key-prefix"].(string)
fleet.Flags.EtcdKeyFile = args["--etcd-keyfile"].(string)
fleet.Flags.EtcdCertFile = args["--etcd-certfile"].(string)
fleet.Flags.EtcdCAFile = args["--etcd-cafile"].(string)
//fleet.Flags.UseAPI = args["--experimental-api"].(bool)
fleet.Flags.KnownHostsFile = args["--known-hosts-file"].(string)
fleet.Flags.StrictHostKeyChecking = args["--strict-host-key-checking"].(bool)
timeout, _ := strconv.ParseFloat(args["--request-timeout"].(string), 64)
fleet.Flags.RequestTimeout = timeout
sshTimeout, _ := strconv.ParseFloat(args["--ssh-timeout"].(string), 64)
fleet.Flags.SSHTimeout = sshTimeout
if setTunnel == true {
tunnel := args["--tunnel"].(string)
if tunnel != "" {
fleet.Flags.Tunnel = tunnel
} else {
fleet.Flags.Tunnel = os.Getenv("DEISCTL_TUNNEL")
}
}
}
|
[
"func",
"setGlobalFlags",
"(",
"args",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"setTunnel",
"bool",
")",
"{",
"fleet",
".",
"Flags",
".",
"Endpoint",
"=",
"args",
"[",
"\"",
"\"",
"]",
".",
"(",
"string",
")",
"\n",
"fleet",
".",
"Flags",
".",
"EtcdKeyPrefix",
"=",
"args",
"[",
"\"",
"\"",
"]",
".",
"(",
"string",
")",
"\n",
"fleet",
".",
"Flags",
".",
"EtcdKeyFile",
"=",
"args",
"[",
"\"",
"\"",
"]",
".",
"(",
"string",
")",
"\n",
"fleet",
".",
"Flags",
".",
"EtcdCertFile",
"=",
"args",
"[",
"\"",
"\"",
"]",
".",
"(",
"string",
")",
"\n",
"fleet",
".",
"Flags",
".",
"EtcdCAFile",
"=",
"args",
"[",
"\"",
"\"",
"]",
".",
"(",
"string",
")",
"\n",
"//fleet.Flags.UseAPI = args[\"--experimental-api\"].(bool)",
"fleet",
".",
"Flags",
".",
"KnownHostsFile",
"=",
"args",
"[",
"\"",
"\"",
"]",
".",
"(",
"string",
")",
"\n",
"fleet",
".",
"Flags",
".",
"StrictHostKeyChecking",
"=",
"args",
"[",
"\"",
"\"",
"]",
".",
"(",
"bool",
")",
"\n",
"timeout",
",",
"_",
":=",
"strconv",
".",
"ParseFloat",
"(",
"args",
"[",
"\"",
"\"",
"]",
".",
"(",
"string",
")",
",",
"64",
")",
"\n",
"fleet",
".",
"Flags",
".",
"RequestTimeout",
"=",
"timeout",
"\n",
"sshTimeout",
",",
"_",
":=",
"strconv",
".",
"ParseFloat",
"(",
"args",
"[",
"\"",
"\"",
"]",
".",
"(",
"string",
")",
",",
"64",
")",
"\n",
"fleet",
".",
"Flags",
".",
"SSHTimeout",
"=",
"sshTimeout",
"\n",
"if",
"setTunnel",
"==",
"true",
"{",
"tunnel",
":=",
"args",
"[",
"\"",
"\"",
"]",
".",
"(",
"string",
")",
"\n",
"if",
"tunnel",
"!=",
"\"",
"\"",
"{",
"fleet",
".",
"Flags",
".",
"Tunnel",
"=",
"tunnel",
"\n",
"}",
"else",
"{",
"fleet",
".",
"Flags",
".",
"Tunnel",
"=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
// setGlobalFlags sets fleet provider options based on deisctl global flags.
|
[
"setGlobalFlags",
"sets",
"fleet",
"provider",
"options",
"based",
"on",
"deisctl",
"global",
"flags",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/deisctl.go#L215-L236
|
142,859 |
deis/deis
|
deisctl/backend/fleet/utils.go
|
expandTargets
|
func (c *FleetClient) expandTargets(targets []string) (expandedTargets []string, err error) {
for _, t := range targets {
// ensure unit name starts with "deis-"
if !strings.HasPrefix(t, "deis-") {
t = "deis-" + t
}
if strings.HasSuffix(t, "@*") {
var targets []string
targets, err = c.Units(strings.TrimSuffix(t, "@*"))
if err != nil {
return
}
expandedTargets = append(expandedTargets, targets...)
} else {
expandedTargets = append(expandedTargets, t)
}
}
return
}
|
go
|
func (c *FleetClient) expandTargets(targets []string) (expandedTargets []string, err error) {
for _, t := range targets {
// ensure unit name starts with "deis-"
if !strings.HasPrefix(t, "deis-") {
t = "deis-" + t
}
if strings.HasSuffix(t, "@*") {
var targets []string
targets, err = c.Units(strings.TrimSuffix(t, "@*"))
if err != nil {
return
}
expandedTargets = append(expandedTargets, targets...)
} else {
expandedTargets = append(expandedTargets, t)
}
}
return
}
|
[
"func",
"(",
"c",
"*",
"FleetClient",
")",
"expandTargets",
"(",
"targets",
"[",
"]",
"string",
")",
"(",
"expandedTargets",
"[",
"]",
"string",
",",
"err",
"error",
")",
"{",
"for",
"_",
",",
"t",
":=",
"range",
"targets",
"{",
"// ensure unit name starts with \"deis-\"",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"t",
",",
"\"",
"\"",
")",
"{",
"t",
"=",
"\"",
"\"",
"+",
"t",
"\n",
"}",
"\n",
"if",
"strings",
".",
"HasSuffix",
"(",
"t",
",",
"\"",
"\"",
")",
"{",
"var",
"targets",
"[",
"]",
"string",
"\n",
"targets",
",",
"err",
"=",
"c",
".",
"Units",
"(",
"strings",
".",
"TrimSuffix",
"(",
"t",
",",
"\"",
"\"",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"expandedTargets",
"=",
"append",
"(",
"expandedTargets",
",",
"targets",
"...",
")",
"\n",
"}",
"else",
"{",
"expandedTargets",
"=",
"append",
"(",
"expandedTargets",
",",
"t",
")",
"\n",
"}",
"\n\n",
"}",
"\n",
"return",
"\n",
"}"
] |
// expand a target to all installed units
|
[
"expand",
"a",
"target",
"to",
"all",
"installed",
"units"
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/utils.go#L89-L108
|
142,860 |
deis/deis
|
deisctl/backend/fleet/utils.go
|
randomValue
|
func randomValue(src []string) string {
s := rand.NewSource(int64(time.Now().Unix()))
r := rand.New(s)
idx := r.Intn(len(src))
return src[idx]
}
|
go
|
func randomValue(src []string) string {
s := rand.NewSource(int64(time.Now().Unix()))
r := rand.New(s)
idx := r.Intn(len(src))
return src[idx]
}
|
[
"func",
"randomValue",
"(",
"src",
"[",
"]",
"string",
")",
"string",
"{",
"s",
":=",
"rand",
".",
"NewSource",
"(",
"int64",
"(",
"time",
".",
"Now",
"(",
")",
".",
"Unix",
"(",
")",
")",
")",
"\n",
"r",
":=",
"rand",
".",
"New",
"(",
"s",
")",
"\n",
"idx",
":=",
"r",
".",
"Intn",
"(",
"len",
"(",
"src",
")",
")",
"\n",
"return",
"src",
"[",
"idx",
"]",
"\n",
"}"
] |
// randomValue returns a random string from a slice of string
|
[
"randomValue",
"returns",
"a",
"random",
"string",
"from",
"a",
"slice",
"of",
"string"
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/utils.go#L111-L116
|
142,861 |
deis/deis
|
client/pkg/webbrowser/webbrowser_darwin.go
|
Webbrowser
|
func Webbrowser(u string) (err error) {
_, err = exec.Command("open", u).Output()
return
}
|
go
|
func Webbrowser(u string) (err error) {
_, err = exec.Command("open", u).Output()
return
}
|
[
"func",
"Webbrowser",
"(",
"u",
"string",
")",
"(",
"err",
"error",
")",
"{",
"_",
",",
"err",
"=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"u",
")",
".",
"Output",
"(",
")",
"\n",
"return",
"\n",
"}"
] |
// Webbrowser opens a url with the default browser.
|
[
"Webbrowser",
"opens",
"a",
"url",
"with",
"the",
"default",
"browser",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/pkg/webbrowser/webbrowser_darwin.go#L8-L11
|
142,862 |
deis/deis
|
client/cmd/git.go
|
GitRemote
|
func GitRemote(appID, remote string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
return git.CreateRemote(c.ControllerURL.Host, remote, appID)
}
|
go
|
func GitRemote(appID, remote string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
return git.CreateRemote(c.ControllerURL.Host, remote, appID)
}
|
[
"func",
"GitRemote",
"(",
"appID",
",",
"remote",
"string",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"load",
"(",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"git",
".",
"CreateRemote",
"(",
"c",
".",
"ControllerURL",
".",
"Host",
",",
"remote",
",",
"appID",
")",
"\n",
"}"
] |
// GitRemote creates a git remote for a deis app.
|
[
"GitRemote",
"creates",
"a",
"git",
"remote",
"for",
"a",
"deis",
"app",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/git.go#L8-L16
|
142,863 |
deis/deis
|
client/cmd/ps.go
|
PsList
|
func PsList(appID string, results int) error {
c, appID, err := load(appID)
if err != nil {
return err
}
if results == defaultLimit {
results = c.ResponseLimit
}
processes, count, err := ps.List(c, appID, results)
if err != nil {
return err
}
printProcesses(appID, processes, count)
return nil
}
|
go
|
func PsList(appID string, results int) error {
c, appID, err := load(appID)
if err != nil {
return err
}
if results == defaultLimit {
results = c.ResponseLimit
}
processes, count, err := ps.List(c, appID, results)
if err != nil {
return err
}
printProcesses(appID, processes, count)
return nil
}
|
[
"func",
"PsList",
"(",
"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",
"processes",
",",
"count",
",",
"err",
":=",
"ps",
".",
"List",
"(",
"c",
",",
"appID",
",",
"results",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"printProcesses",
"(",
"appID",
",",
"processes",
",",
"count",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
// PsList lists an app's processes.
|
[
"PsList",
"lists",
"an",
"app",
"s",
"processes",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/ps.go#L16-L36
|
142,864 |
deis/deis
|
client/cmd/ps.go
|
PsScale
|
func PsScale(appID string, targets []string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
targetMap := make(map[string]int)
regex := regexp.MustCompile("^([A-z]+)=([0-9]+)$")
for _, target := range targets {
if regex.MatchString(target) {
captures := regex.FindStringSubmatch(target)
targetMap[captures[1]], err = strconv.Atoi(captures[2])
if err != nil {
return err
}
} else {
fmt.Printf("'%s' does not match the pattern 'type=num', ex: web=2\n", target)
}
}
fmt.Printf("Scaling processes... but first, %s!\n", drinkOfChoice())
startTime := time.Now()
quit := progress()
err = ps.Scale(c, appID, targetMap)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Printf("done in %ds\n", int(time.Since(startTime).Seconds()))
processes, count, err := ps.List(c, appID, c.ResponseLimit)
if err != nil {
return err
}
printProcesses(appID, processes, count)
return nil
}
|
go
|
func PsScale(appID string, targets []string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
targetMap := make(map[string]int)
regex := regexp.MustCompile("^([A-z]+)=([0-9]+)$")
for _, target := range targets {
if regex.MatchString(target) {
captures := regex.FindStringSubmatch(target)
targetMap[captures[1]], err = strconv.Atoi(captures[2])
if err != nil {
return err
}
} else {
fmt.Printf("'%s' does not match the pattern 'type=num', ex: web=2\n", target)
}
}
fmt.Printf("Scaling processes... but first, %s!\n", drinkOfChoice())
startTime := time.Now()
quit := progress()
err = ps.Scale(c, appID, targetMap)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Printf("done in %ds\n", int(time.Since(startTime).Seconds()))
processes, count, err := ps.List(c, appID, c.ResponseLimit)
if err != nil {
return err
}
printProcesses(appID, processes, count)
return nil
}
|
[
"func",
"PsScale",
"(",
"appID",
"string",
",",
"targets",
"[",
"]",
"string",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"load",
"(",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"targetMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"int",
")",
"\n",
"regex",
":=",
"regexp",
".",
"MustCompile",
"(",
"\"",
"\"",
")",
"\n\n",
"for",
"_",
",",
"target",
":=",
"range",
"targets",
"{",
"if",
"regex",
".",
"MatchString",
"(",
"target",
")",
"{",
"captures",
":=",
"regex",
".",
"FindStringSubmatch",
"(",
"target",
")",
"\n",
"targetMap",
"[",
"captures",
"[",
"1",
"]",
"]",
",",
"err",
"=",
"strconv",
".",
"Atoi",
"(",
"captures",
"[",
"2",
"]",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"else",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"target",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"drinkOfChoice",
"(",
")",
")",
"\n",
"startTime",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"quit",
":=",
"progress",
"(",
")",
"\n\n",
"err",
"=",
"ps",
".",
"Scale",
"(",
"c",
",",
"appID",
",",
"targetMap",
")",
"\n\n",
"quit",
"<-",
"true",
"\n",
"<-",
"quit",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"int",
"(",
"time",
".",
"Since",
"(",
"startTime",
")",
".",
"Seconds",
"(",
")",
")",
")",
"\n\n",
"processes",
",",
"count",
",",
"err",
":=",
"ps",
".",
"List",
"(",
"c",
",",
"appID",
",",
"c",
".",
"ResponseLimit",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"printProcesses",
"(",
"appID",
",",
"processes",
",",
"count",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
// PsScale scales an app's processes.
|
[
"PsScale",
"scales",
"an",
"app",
"s",
"processes",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/ps.go#L39-L85
|
142,865 |
deis/deis
|
client/cmd/ps.go
|
PsRestart
|
func PsRestart(appID, target string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
psType := ""
psNum := -1
if target != "" {
if strings.Contains(target, ".") {
parts := strings.Split(target, ".")
psType = parts[0]
psNum, err = strconv.Atoi(parts[1])
if err != nil {
return err
}
} else {
psType = target
}
}
fmt.Printf("Restarting processes... but first, %s!\n", drinkOfChoice())
startTime := time.Now()
quit := progress()
_, err = ps.Restart(c, appID, psType, psNum)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Printf("done in %ds\n", int(time.Since(startTime).Seconds()))
processes, count, err := ps.List(c, appID, c.ResponseLimit)
if err != nil {
return err
}
printProcesses(appID, processes, count)
return nil
}
|
go
|
func PsRestart(appID, target string) error {
c, appID, err := load(appID)
if err != nil {
return err
}
psType := ""
psNum := -1
if target != "" {
if strings.Contains(target, ".") {
parts := strings.Split(target, ".")
psType = parts[0]
psNum, err = strconv.Atoi(parts[1])
if err != nil {
return err
}
} else {
psType = target
}
}
fmt.Printf("Restarting processes... but first, %s!\n", drinkOfChoice())
startTime := time.Now()
quit := progress()
_, err = ps.Restart(c, appID, psType, psNum)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Printf("done in %ds\n", int(time.Since(startTime).Seconds()))
processes, count, err := ps.List(c, appID, c.ResponseLimit)
if err != nil {
return err
}
printProcesses(appID, processes, count)
return nil
}
|
[
"func",
"PsRestart",
"(",
"appID",
",",
"target",
"string",
")",
"error",
"{",
"c",
",",
"appID",
",",
"err",
":=",
"load",
"(",
"appID",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"psType",
":=",
"\"",
"\"",
"\n",
"psNum",
":=",
"-",
"1",
"\n\n",
"if",
"target",
"!=",
"\"",
"\"",
"{",
"if",
"strings",
".",
"Contains",
"(",
"target",
",",
"\"",
"\"",
")",
"{",
"parts",
":=",
"strings",
".",
"Split",
"(",
"target",
",",
"\"",
"\"",
")",
"\n",
"psType",
"=",
"parts",
"[",
"0",
"]",
"\n",
"psNum",
",",
"err",
"=",
"strconv",
".",
"Atoi",
"(",
"parts",
"[",
"1",
"]",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"else",
"{",
"psType",
"=",
"target",
"\n",
"}",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"drinkOfChoice",
"(",
")",
")",
"\n",
"startTime",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"quit",
":=",
"progress",
"(",
")",
"\n\n",
"_",
",",
"err",
"=",
"ps",
".",
"Restart",
"(",
"c",
",",
"appID",
",",
"psType",
",",
"psNum",
")",
"\n\n",
"quit",
"<-",
"true",
"\n",
"<-",
"quit",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"int",
"(",
"time",
".",
"Since",
"(",
"startTime",
")",
".",
"Seconds",
"(",
")",
")",
")",
"\n\n",
"processes",
",",
"count",
",",
"err",
":=",
"ps",
".",
"List",
"(",
"c",
",",
"appID",
",",
"c",
".",
"ResponseLimit",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"printProcesses",
"(",
"appID",
",",
"processes",
",",
"count",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
// PsRestart restarts an app's processes.
|
[
"PsRestart",
"restarts",
"an",
"app",
"s",
"processes",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/ps.go#L88-L135
|
142,866 |
deis/deis
|
deisctl/backend/fleet/list_units.go
|
ListUnits
|
func (c *FleetClient) ListUnits() (err error) {
var states []*schema.UnitState
unitStates, err := c.Fleet.UnitStates()
if err != nil {
return err
}
for _, us := range unitStates {
for _, prefix := range units.Names {
if strings.HasPrefix(us.Name, prefix) {
states = append(states, us)
break
}
}
}
c.printUnits(states)
return
}
|
go
|
func (c *FleetClient) ListUnits() (err error) {
var states []*schema.UnitState
unitStates, err := c.Fleet.UnitStates()
if err != nil {
return err
}
for _, us := range unitStates {
for _, prefix := range units.Names {
if strings.HasPrefix(us.Name, prefix) {
states = append(states, us)
break
}
}
}
c.printUnits(states)
return
}
|
[
"func",
"(",
"c",
"*",
"FleetClient",
")",
"ListUnits",
"(",
")",
"(",
"err",
"error",
")",
"{",
"var",
"states",
"[",
"]",
"*",
"schema",
".",
"UnitState",
"\n\n",
"unitStates",
",",
"err",
":=",
"c",
".",
"Fleet",
".",
"UnitStates",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"us",
":=",
"range",
"unitStates",
"{",
"for",
"_",
",",
"prefix",
":=",
"range",
"units",
".",
"Names",
"{",
"if",
"strings",
".",
"HasPrefix",
"(",
"us",
".",
"Name",
",",
"prefix",
")",
"{",
"states",
"=",
"append",
"(",
"states",
",",
"us",
")",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"c",
".",
"printUnits",
"(",
"states",
")",
"\n",
"return",
"\n",
"}"
] |
// ListUnits prints all Deis-related units to Stdout
|
[
"ListUnits",
"prints",
"all",
"Deis",
"-",
"related",
"units",
"to",
"Stdout"
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/list_units.go#L68-L86
|
142,867 |
deis/deis
|
client/controller/models/ps/ps.go
|
Scale
|
func Scale(c *client.Client, appID string, targets map[string]int) error {
u := fmt.Sprintf("/v1/apps/%s/scale/", appID)
body, err := json.Marshal(targets)
if err != nil {
return err
}
_, err = c.BasicRequest("POST", u, body)
return err
}
|
go
|
func Scale(c *client.Client, appID string, targets map[string]int) error {
u := fmt.Sprintf("/v1/apps/%s/scale/", appID)
body, err := json.Marshal(targets)
if err != nil {
return err
}
_, err = c.BasicRequest("POST", u, body)
return err
}
|
[
"func",
"Scale",
"(",
"c",
"*",
"client",
".",
"Client",
",",
"appID",
"string",
",",
"targets",
"map",
"[",
"string",
"]",
"int",
")",
"error",
"{",
"u",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"appID",
")",
"\n\n",
"body",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"targets",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"_",
",",
"err",
"=",
"c",
".",
"BasicRequest",
"(",
"\"",
"\"",
",",
"u",
",",
"body",
")",
"\n",
"return",
"err",
"\n",
"}"
] |
// Scale an app's processes.
|
[
"Scale",
"an",
"app",
"s",
"processes",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/ps/ps.go#L30-L41
|
142,868 |
deis/deis
|
client/controller/models/ps/ps.go
|
Restart
|
func Restart(c *client.Client, appID string, procType string, num int) ([]api.Process, error) {
u := fmt.Sprintf("/v1/apps/%s/containers/", appID)
if procType == "" {
u += "restart/"
} else {
if num == -1 {
u += procType + "/restart/"
} else {
u += procType + "/" + strconv.Itoa(num) + "/restart/"
}
}
body, err := c.BasicRequest("POST", u, nil)
if err != nil {
return []api.Process{}, err
}
procs := []api.Process{}
if err = json.Unmarshal([]byte(body), &procs); err != nil {
return []api.Process{}, err
}
return procs, nil
}
|
go
|
func Restart(c *client.Client, appID string, procType string, num int) ([]api.Process, error) {
u := fmt.Sprintf("/v1/apps/%s/containers/", appID)
if procType == "" {
u += "restart/"
} else {
if num == -1 {
u += procType + "/restart/"
} else {
u += procType + "/" + strconv.Itoa(num) + "/restart/"
}
}
body, err := c.BasicRequest("POST", u, nil)
if err != nil {
return []api.Process{}, err
}
procs := []api.Process{}
if err = json.Unmarshal([]byte(body), &procs); err != nil {
return []api.Process{}, err
}
return procs, nil
}
|
[
"func",
"Restart",
"(",
"c",
"*",
"client",
".",
"Client",
",",
"appID",
"string",
",",
"procType",
"string",
",",
"num",
"int",
")",
"(",
"[",
"]",
"api",
".",
"Process",
",",
"error",
")",
"{",
"u",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"appID",
")",
"\n\n",
"if",
"procType",
"==",
"\"",
"\"",
"{",
"u",
"+=",
"\"",
"\"",
"\n",
"}",
"else",
"{",
"if",
"num",
"==",
"-",
"1",
"{",
"u",
"+=",
"procType",
"+",
"\"",
"\"",
"\n",
"}",
"else",
"{",
"u",
"+=",
"procType",
"+",
"\"",
"\"",
"+",
"strconv",
".",
"Itoa",
"(",
"num",
")",
"+",
"\"",
"\"",
"\n",
"}",
"\n",
"}",
"\n\n",
"body",
",",
"err",
":=",
"c",
".",
"BasicRequest",
"(",
"\"",
"\"",
",",
"u",
",",
"nil",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"[",
"]",
"api",
".",
"Process",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"procs",
":=",
"[",
"]",
"api",
".",
"Process",
"{",
"}",
"\n",
"if",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"body",
")",
",",
"&",
"procs",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"[",
"]",
"api",
".",
"Process",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"procs",
",",
"nil",
"\n",
"}"
] |
// Restart an app's processes.
|
[
"Restart",
"an",
"app",
"s",
"processes",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/ps/ps.go#L44-L69
|
142,869 |
deis/deis
|
contrib/bumpver/bump.go
|
Command
|
func Command(argv []string) (returnCode int) {
usage := `
Updates the current semantic version number to a new one in the specified
source and doc files.
Usage:
bumpver [-f <current>] <version> <files>...
Options:
-f --from=<current> An explicit version string to replace. Otherwise, use
the first semantic version found in the first file.
`
argv = parseArgs(argv)
// parse command-line arguments
args, err := docopt.Parse(usage, argv, true, "bumpversion 0.1.0", true, false)
if err != nil {
return 1
}
if len(args) == 0 {
return 0
}
re := regexp.MustCompile(`(\d{1,3}\.\d{1,3}\.\d{1,3})`)
// validate that <version> is a proper semver string
version := (args["<version>"].(string))
if version != re.FindString(version) {
return onError(fmt.Errorf("Error: '%s' is not a valid semantic version string", version))
}
files := args["<files>"].([]string)
var from []byte
var data []byte
if args["--from"] != nil {
from = []byte(args["--from"].(string))
}
for _, name := range files {
src, err := ioutil.ReadFile(name)
if err != nil {
return onError(err)
}
if len(from) == 0 {
// find the first semver match in the file, if any
from = re.Find(src)
if from = re.Find(src); len(from) == 0 {
fmt.Printf("Skipped %s\n", name)
continue
}
}
// replace all occurrences in source and doc files
data = bytes.Replace(src, from, []byte(version), -1)
f, err := os.Create(name)
if err != nil {
return onError(err)
}
if _, err = f.Write(data); err != nil {
return onError(err)
}
fmt.Printf("Bumped %s\n", name)
}
return 0
}
|
go
|
func Command(argv []string) (returnCode int) {
usage := `
Updates the current semantic version number to a new one in the specified
source and doc files.
Usage:
bumpver [-f <current>] <version> <files>...
Options:
-f --from=<current> An explicit version string to replace. Otherwise, use
the first semantic version found in the first file.
`
argv = parseArgs(argv)
// parse command-line arguments
args, err := docopt.Parse(usage, argv, true, "bumpversion 0.1.0", true, false)
if err != nil {
return 1
}
if len(args) == 0 {
return 0
}
re := regexp.MustCompile(`(\d{1,3}\.\d{1,3}\.\d{1,3})`)
// validate that <version> is a proper semver string
version := (args["<version>"].(string))
if version != re.FindString(version) {
return onError(fmt.Errorf("Error: '%s' is not a valid semantic version string", version))
}
files := args["<files>"].([]string)
var from []byte
var data []byte
if args["--from"] != nil {
from = []byte(args["--from"].(string))
}
for _, name := range files {
src, err := ioutil.ReadFile(name)
if err != nil {
return onError(err)
}
if len(from) == 0 {
// find the first semver match in the file, if any
from = re.Find(src)
if from = re.Find(src); len(from) == 0 {
fmt.Printf("Skipped %s\n", name)
continue
}
}
// replace all occurrences in source and doc files
data = bytes.Replace(src, from, []byte(version), -1)
f, err := os.Create(name)
if err != nil {
return onError(err)
}
if _, err = f.Write(data); err != nil {
return onError(err)
}
fmt.Printf("Bumped %s\n", name)
}
return 0
}
|
[
"func",
"Command",
"(",
"argv",
"[",
"]",
"string",
")",
"(",
"returnCode",
"int",
")",
"{",
"usage",
":=",
"`\nUpdates the current semantic version number to a new one in the specified\nsource and doc files.\n\nUsage:\n bumpver [-f <current>] <version> <files>...\n\nOptions:\n -f --from=<current> An explicit version string to replace. Otherwise, use\n the first semantic version found in the first file.\n `",
"\n",
"argv",
"=",
"parseArgs",
"(",
"argv",
")",
"\n",
"// parse command-line arguments",
"args",
",",
"err",
":=",
"docopt",
".",
"Parse",
"(",
"usage",
",",
"argv",
",",
"true",
",",
"\"",
"\"",
",",
"true",
",",
"false",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"1",
"\n",
"}",
"\n",
"if",
"len",
"(",
"args",
")",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n",
"re",
":=",
"regexp",
".",
"MustCompile",
"(",
"`(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})`",
")",
"\n",
"// validate that <version> is a proper semver string",
"version",
":=",
"(",
"args",
"[",
"\"",
"\"",
"]",
".",
"(",
"string",
")",
")",
"\n",
"if",
"version",
"!=",
"re",
".",
"FindString",
"(",
"version",
")",
"{",
"return",
"onError",
"(",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"version",
")",
")",
"\n",
"}",
"\n",
"files",
":=",
"args",
"[",
"\"",
"\"",
"]",
".",
"(",
"[",
"]",
"string",
")",
"\n",
"var",
"from",
"[",
"]",
"byte",
"\n",
"var",
"data",
"[",
"]",
"byte",
"\n",
"if",
"args",
"[",
"\"",
"\"",
"]",
"!=",
"nil",
"{",
"from",
"=",
"[",
"]",
"byte",
"(",
"args",
"[",
"\"",
"\"",
"]",
".",
"(",
"string",
")",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"name",
":=",
"range",
"files",
"{",
"src",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"onError",
"(",
"err",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"from",
")",
"==",
"0",
"{",
"// find the first semver match in the file, if any",
"from",
"=",
"re",
".",
"Find",
"(",
"src",
")",
"\n",
"if",
"from",
"=",
"re",
".",
"Find",
"(",
"src",
")",
";",
"len",
"(",
"from",
")",
"==",
"0",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"name",
")",
"\n",
"continue",
"\n",
"}",
"\n",
"}",
"\n",
"// replace all occurrences in source and doc files",
"data",
"=",
"bytes",
".",
"Replace",
"(",
"src",
",",
"from",
",",
"[",
"]",
"byte",
"(",
"version",
")",
",",
"-",
"1",
")",
"\n",
"f",
",",
"err",
":=",
"os",
".",
"Create",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"onError",
"(",
"err",
")",
"\n",
"}",
"\n",
"if",
"_",
",",
"err",
"=",
"f",
".",
"Write",
"(",
"data",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"onError",
"(",
"err",
")",
"\n",
"}",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"name",
")",
"\n",
"}",
"\n",
"return",
"0",
"\n",
"}"
] |
// Command processes command-line arguments according to a usage string specification.
|
[
"Command",
"processes",
"command",
"-",
"line",
"arguments",
"according",
"to",
"a",
"usage",
"string",
"specification",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/contrib/bumpver/bump.go#L14-L72
|
142,870 |
deis/deis
|
client/parser/users.go
|
Users
|
func Users(argv []string) error {
usage := `
Valid commands for users:
users:list list all registered users
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "users:list":
return usersList(argv)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "users" {
argv[0] = "users:list"
return usersList(argv)
}
PrintUsage()
return nil
}
}
|
go
|
func Users(argv []string) error {
usage := `
Valid commands for users:
users:list list all registered users
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "users:list":
return usersList(argv)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "users" {
argv[0] = "users:list"
return usersList(argv)
}
PrintUsage()
return nil
}
}
|
[
"func",
"Users",
"(",
"argv",
"[",
"]",
"string",
")",
"error",
"{",
"usage",
":=",
"`\nValid commands for users:\n\nusers:list list all registered users\n\nUse 'deis help [command]' to learn more.\n`",
"\n\n",
"switch",
"argv",
"[",
"0",
"]",
"{",
"case",
"\"",
"\"",
":",
"return",
"usersList",
"(",
"argv",
")",
"\n",
"default",
":",
"if",
"printHelp",
"(",
"argv",
",",
"usage",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"argv",
"[",
"0",
"]",
"==",
"\"",
"\"",
"{",
"argv",
"[",
"0",
"]",
"=",
"\"",
"\"",
"\n",
"return",
"usersList",
"(",
"argv",
")",
"\n",
"}",
"\n\n",
"PrintUsage",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] |
// Users routes user commands to the specific function.
|
[
"Users",
"routes",
"user",
"commands",
"to",
"the",
"specific",
"function",
"."
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/parser/users.go#L9-L34
|
142,871 |
deis/deis
|
deisctl/cmd/upgrade.go
|
UpgradePrep
|
func UpgradePrep(stateless bool, b backend.Backend) error {
var wg sync.WaitGroup
b.Stop([]string{"database", "registry@*", "controller", "builder", "logger", "logspout"}, &wg, Stdout, Stderr)
wg.Wait()
b.Destroy([]string{"database", "registry@*", "controller", "builder", "logger", "logspout"}, &wg, Stdout, Stderr)
wg.Wait()
if !stateless {
b.Stop([]string{"store-volume", "store-gateway@*"}, &wg, Stdout, Stderr)
wg.Wait()
b.Destroy([]string{"store-volume", "store-gateway@*"}, &wg, Stdout, Stderr)
wg.Wait()
b.Stop([]string{"store-metadata"}, &wg, Stdout, Stderr)
wg.Wait()
b.Destroy([]string{"store-metadata"}, &wg, Stdout, Stderr)
wg.Wait()
b.Stop([]string{"store-daemon"}, &wg, Stdout, Stderr)
wg.Wait()
b.Destroy([]string{"store-daemon"}, &wg, Stdout, Stderr)
wg.Wait()
b.Stop([]string{"store-monitor"}, &wg, Stdout, Stderr)
wg.Wait()
b.Destroy([]string{"store-monitor"}, &wg, Stdout, Stderr)
wg.Wait()
}
fmt.Fprintln(Stdout, "The platform has been stopped, but applications are still serving traffic as normal.")
fmt.Fprintln(Stdout, "Your cluster is now ready for upgrade. Install a new deisctl version and run `deisctl upgrade-takeover`.")
fmt.Fprintln(Stdout, "For more details, see: http://docs.deis.io/en/latest/managing_deis/upgrading-deis/#graceful-upgrade")
return nil
}
|
go
|
func UpgradePrep(stateless bool, b backend.Backend) error {
var wg sync.WaitGroup
b.Stop([]string{"database", "registry@*", "controller", "builder", "logger", "logspout"}, &wg, Stdout, Stderr)
wg.Wait()
b.Destroy([]string{"database", "registry@*", "controller", "builder", "logger", "logspout"}, &wg, Stdout, Stderr)
wg.Wait()
if !stateless {
b.Stop([]string{"store-volume", "store-gateway@*"}, &wg, Stdout, Stderr)
wg.Wait()
b.Destroy([]string{"store-volume", "store-gateway@*"}, &wg, Stdout, Stderr)
wg.Wait()
b.Stop([]string{"store-metadata"}, &wg, Stdout, Stderr)
wg.Wait()
b.Destroy([]string{"store-metadata"}, &wg, Stdout, Stderr)
wg.Wait()
b.Stop([]string{"store-daemon"}, &wg, Stdout, Stderr)
wg.Wait()
b.Destroy([]string{"store-daemon"}, &wg, Stdout, Stderr)
wg.Wait()
b.Stop([]string{"store-monitor"}, &wg, Stdout, Stderr)
wg.Wait()
b.Destroy([]string{"store-monitor"}, &wg, Stdout, Stderr)
wg.Wait()
}
fmt.Fprintln(Stdout, "The platform has been stopped, but applications are still serving traffic as normal.")
fmt.Fprintln(Stdout, "Your cluster is now ready for upgrade. Install a new deisctl version and run `deisctl upgrade-takeover`.")
fmt.Fprintln(Stdout, "For more details, see: http://docs.deis.io/en/latest/managing_deis/upgrading-deis/#graceful-upgrade")
return nil
}
|
[
"func",
"UpgradePrep",
"(",
"stateless",
"bool",
",",
"b",
"backend",
".",
"Backend",
")",
"error",
"{",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n\n",
"b",
".",
"Stop",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"}",
",",
"&",
"wg",
",",
"Stdout",
",",
"Stderr",
")",
"\n",
"wg",
".",
"Wait",
"(",
")",
"\n",
"b",
".",
"Destroy",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"}",
",",
"&",
"wg",
",",
"Stdout",
",",
"Stderr",
")",
"\n",
"wg",
".",
"Wait",
"(",
")",
"\n\n",
"if",
"!",
"stateless",
"{",
"b",
".",
"Stop",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
"}",
",",
"&",
"wg",
",",
"Stdout",
",",
"Stderr",
")",
"\n",
"wg",
".",
"Wait",
"(",
")",
"\n",
"b",
".",
"Destroy",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
"}",
",",
"&",
"wg",
",",
"Stdout",
",",
"Stderr",
")",
"\n",
"wg",
".",
"Wait",
"(",
")",
"\n\n",
"b",
".",
"Stop",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
",",
"&",
"wg",
",",
"Stdout",
",",
"Stderr",
")",
"\n",
"wg",
".",
"Wait",
"(",
")",
"\n",
"b",
".",
"Destroy",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
",",
"&",
"wg",
",",
"Stdout",
",",
"Stderr",
")",
"\n",
"wg",
".",
"Wait",
"(",
")",
"\n\n",
"b",
".",
"Stop",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
",",
"&",
"wg",
",",
"Stdout",
",",
"Stderr",
")",
"\n",
"wg",
".",
"Wait",
"(",
")",
"\n",
"b",
".",
"Destroy",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
",",
"&",
"wg",
",",
"Stdout",
",",
"Stderr",
")",
"\n",
"wg",
".",
"Wait",
"(",
")",
"\n\n",
"b",
".",
"Stop",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
",",
"&",
"wg",
",",
"Stdout",
",",
"Stderr",
")",
"\n",
"wg",
".",
"Wait",
"(",
")",
"\n",
"b",
".",
"Destroy",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
",",
"&",
"wg",
",",
"Stdout",
",",
"Stderr",
")",
"\n",
"wg",
".",
"Wait",
"(",
")",
"\n",
"}",
"\n\n",
"fmt",
".",
"Fprintln",
"(",
"Stdout",
",",
"\"",
"\"",
")",
"\n",
"fmt",
".",
"Fprintln",
"(",
"Stdout",
",",
"\"",
"\"",
")",
"\n",
"fmt",
".",
"Fprintln",
"(",
"Stdout",
",",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
// UpgradePrep stops and uninstalls all components except router and publisher
|
[
"UpgradePrep",
"stops",
"and",
"uninstalls",
"all",
"components",
"except",
"router",
"and",
"publisher"
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/cmd/upgrade.go#L15-L49
|
142,872 |
deis/deis
|
deisctl/cmd/upgrade.go
|
UpgradeTakeover
|
func UpgradeTakeover(stateless bool, b backend.Backend, cb config.Backend) error {
if err := doUpgradeTakeOver(stateless, b, cb); err != nil {
return err
}
return nil
}
|
go
|
func UpgradeTakeover(stateless bool, b backend.Backend, cb config.Backend) error {
if err := doUpgradeTakeOver(stateless, b, cb); err != nil {
return err
}
return nil
}
|
[
"func",
"UpgradeTakeover",
"(",
"stateless",
"bool",
",",
"b",
"backend",
".",
"Backend",
",",
"cb",
"config",
".",
"Backend",
")",
"error",
"{",
"if",
"err",
":=",
"doUpgradeTakeOver",
"(",
"stateless",
",",
"b",
",",
"cb",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
// UpgradeTakeover gracefully starts a platform stopped with UpgradePrep
|
[
"UpgradeTakeover",
"gracefully",
"starts",
"a",
"platform",
"stopped",
"with",
"UpgradePrep"
] |
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
|
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/cmd/upgrade.go#L72-L78
|
142,873 |
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
|
142,874 |
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
|
142,875 |
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
|
142,876 |
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
|
142,877 |
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
|
142,878 |
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
|
142,879 |
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
|
142,880 |
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
|
142,881 |
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
|
142,882 |
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
|
142,883 |
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
|
142,884 |
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
|
142,885 |
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
|
142,886 |
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
|
142,887 |
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
|
142,888 |
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
|
142,889 |
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
|
142,890 |
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
|
142,891 |
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
|
142,892 |
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
|
142,893 |
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
|
142,894 |
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
|
142,895 |
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
|
142,896 |
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
|
142,897 |
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
|
142,898 |
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
|
142,899 |
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
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.