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,900
deis/deis
deisctl/backend/fleet/unit.go
readTemplate
func readTemplate(component string, templatePaths []string) (out []byte, err error) { templateName := "deis-" + component + ".service" var templateFile string // look in $DEISCTL_UNITS env var, then the local and global root paths for _, p := range templatePaths { if p == "" { continue } filename := path.Join(p, templateName) if _, err := os.Stat(filename); err == nil { templateFile = filename break } } if templateFile == "" { return nil, fmt.Errorf("Could not find unit template for %v", component) } out, err = ioutil.ReadFile(templateFile) if err != nil { return } return }
go
func readTemplate(component string, templatePaths []string) (out []byte, err error) { templateName := "deis-" + component + ".service" var templateFile string // look in $DEISCTL_UNITS env var, then the local and global root paths for _, p := range templatePaths { if p == "" { continue } filename := path.Join(p, templateName) if _, err := os.Stat(filename); err == nil { templateFile = filename break } } if templateFile == "" { return nil, fmt.Errorf("Could not find unit template for %v", component) } out, err = ioutil.ReadFile(templateFile) if err != nil { return } return }
[ "func", "readTemplate", "(", "component", "string", ",", "templatePaths", "[", "]", "string", ")", "(", "out", "[", "]", "byte", ",", "err", "error", ")", "{", "templateName", ":=", "\"", "\"", "+", "component", "+", "\"", "\"", "\n", "var", "templateFile", "string", "\n\n", "// look in $DEISCTL_UNITS env var, then the local and global root paths", "for", "_", ",", "p", ":=", "range", "templatePaths", "{", "if", "p", "==", "\"", "\"", "{", "continue", "\n", "}", "\n", "filename", ":=", "path", ".", "Join", "(", "p", ",", "templateName", ")", "\n", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "filename", ")", ";", "err", "==", "nil", "{", "templateFile", "=", "filename", "\n", "break", "\n", "}", "\n", "}", "\n\n", "if", "templateFile", "==", "\"", "\"", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "component", ")", "\n", "}", "\n", "out", ",", "err", "=", "ioutil", ".", "ReadFile", "(", "templateFile", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "return", "\n", "}" ]
// readTemplate returns the contents of a systemd template for the given component
[ "readTemplate", "returns", "the", "contents", "of", "a", "systemd", "template", "for", "the", "given", "component" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/unit.go#L122-L146
142,901
deis/deis
deisctl/backend/fleet/unit.go
readDecorator
func readDecorator(component string) (out []byte, err error) { decoratorName := "deis-" + component + ".service.decorator" var decoratorFile string // look in $DEISCTL_UNITS env var, then the local and global root paths for _, p := range decoratorPaths { filename := path.Join(p, decoratorName) if _, err := os.Stat(filename); err == nil { decoratorFile = filename break } } if decoratorFile == "" { return } out, err = ioutil.ReadFile(decoratorFile) return }
go
func readDecorator(component string) (out []byte, err error) { decoratorName := "deis-" + component + ".service.decorator" var decoratorFile string // look in $DEISCTL_UNITS env var, then the local and global root paths for _, p := range decoratorPaths { filename := path.Join(p, decoratorName) if _, err := os.Stat(filename); err == nil { decoratorFile = filename break } } if decoratorFile == "" { return } out, err = ioutil.ReadFile(decoratorFile) return }
[ "func", "readDecorator", "(", "component", "string", ")", "(", "out", "[", "]", "byte", ",", "err", "error", ")", "{", "decoratorName", ":=", "\"", "\"", "+", "component", "+", "\"", "\"", "\n", "var", "decoratorFile", "string", "\n\n", "// look in $DEISCTL_UNITS env var, then the local and global root paths", "for", "_", ",", "p", ":=", "range", "decoratorPaths", "{", "filename", ":=", "path", ".", "Join", "(", "p", ",", "decoratorName", ")", "\n", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "filename", ")", ";", "err", "==", "nil", "{", "decoratorFile", "=", "filename", "\n", "break", "\n", "}", "\n", "}", "\n\n", "if", "decoratorFile", "==", "\"", "\"", "{", "return", "\n", "}", "\n", "out", ",", "err", "=", "ioutil", ".", "ReadFile", "(", "decoratorFile", ")", "\n", "return", "\n", "}" ]
// readDecorator returns the contents of a file containing a snippet that can // optionally be grafted on to the end of a corresponding systemd unit to // achieve isolation of the control plane, data plane, and router mesh
[ "readDecorator", "returns", "the", "contents", "of", "a", "file", "containing", "a", "snippet", "that", "can", "optionally", "be", "grafted", "on", "to", "the", "end", "of", "a", "corresponding", "systemd", "unit", "to", "achieve", "isolation", "of", "the", "control", "plane", "data", "plane", "and", "router", "mesh" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/unit.go#L151-L169
142,902
deis/deis
logger/storage/ringbuffer/adapter.go
NewStorageAdapter
func NewStorageAdapter(bufferSize int) (*adapter, error) { if bufferSize <= 0 { return nil, fmt.Errorf("Invalid ringBuffer size: %d", bufferSize) } return &adapter{bufferSize: bufferSize, ringBuffers: make(map[string]*ringBuffer)}, nil }
go
func NewStorageAdapter(bufferSize int) (*adapter, error) { if bufferSize <= 0 { return nil, fmt.Errorf("Invalid ringBuffer size: %d", bufferSize) } return &adapter{bufferSize: bufferSize, ringBuffers: make(map[string]*ringBuffer)}, nil }
[ "func", "NewStorageAdapter", "(", "bufferSize", "int", ")", "(", "*", "adapter", ",", "error", ")", "{", "if", "bufferSize", "<=", "0", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "bufferSize", ")", "\n", "}", "\n", "return", "&", "adapter", "{", "bufferSize", ":", "bufferSize", ",", "ringBuffers", ":", "make", "(", "map", "[", "string", "]", "*", "ringBuffer", ")", "}", ",", "nil", "\n", "}" ]
// NewStorageAdapter returns a pointer to a new instance of an in-memory storage.Adapter.
[ "NewStorageAdapter", "returns", "a", "pointer", "to", "a", "new", "instance", "of", "an", "in", "-", "memory", "storage", ".", "Adapter", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/storage/ringbuffer/adapter.go#L58-L63
142,903
deis/deis
logger/storage/ringbuffer/adapter.go
Write
func (a *adapter) Write(app string, message string) error { // Check first if we might actually have to add to the map of ringBuffer pointers so we can avoid // waiting for / obtaining a lock unnecessarily rb, ok := a.ringBuffers[app] if !ok { // Ensure only one goroutine at a time can be adding a ringBuffer to the map of ringBuffers // pointers a.mutex.Lock() defer a.mutex.Unlock() rb, ok = a.ringBuffers[app] if !ok { rb = newRingBuffer(a.bufferSize) a.ringBuffers[app] = rb } } rb.write(message) return nil }
go
func (a *adapter) Write(app string, message string) error { // Check first if we might actually have to add to the map of ringBuffer pointers so we can avoid // waiting for / obtaining a lock unnecessarily rb, ok := a.ringBuffers[app] if !ok { // Ensure only one goroutine at a time can be adding a ringBuffer to the map of ringBuffers // pointers a.mutex.Lock() defer a.mutex.Unlock() rb, ok = a.ringBuffers[app] if !ok { rb = newRingBuffer(a.bufferSize) a.ringBuffers[app] = rb } } rb.write(message) return nil }
[ "func", "(", "a", "*", "adapter", ")", "Write", "(", "app", "string", ",", "message", "string", ")", "error", "{", "// Check first if we might actually have to add to the map of ringBuffer pointers so we can avoid", "// waiting for / obtaining a lock unnecessarily", "rb", ",", "ok", ":=", "a", ".", "ringBuffers", "[", "app", "]", "\n", "if", "!", "ok", "{", "// Ensure only one goroutine at a time can be adding a ringBuffer to the map of ringBuffers", "// pointers", "a", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "mutex", ".", "Unlock", "(", ")", "\n", "rb", ",", "ok", "=", "a", ".", "ringBuffers", "[", "app", "]", "\n", "if", "!", "ok", "{", "rb", "=", "newRingBuffer", "(", "a", ".", "bufferSize", ")", "\n", "a", ".", "ringBuffers", "[", "app", "]", "=", "rb", "\n", "}", "\n", "}", "\n", "rb", ".", "write", "(", "message", ")", "\n", "return", "nil", "\n", "}" ]
// Write adds a log message to to an app-specific ringBuffer
[ "Write", "adds", "a", "log", "message", "to", "to", "an", "app", "-", "specific", "ringBuffer" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/storage/ringbuffer/adapter.go#L66-L83
142,904
deis/deis
logger/storage/ringbuffer/adapter.go
Read
func (a *adapter) Read(app string, lines int) ([]string, error) { rb, ok := a.ringBuffers[app] if ok { return rb.read(lines), nil } return nil, fmt.Errorf("Could not find logs for '%s'", app) }
go
func (a *adapter) Read(app string, lines int) ([]string, error) { rb, ok := a.ringBuffers[app] if ok { return rb.read(lines), nil } return nil, fmt.Errorf("Could not find logs for '%s'", app) }
[ "func", "(", "a", "*", "adapter", ")", "Read", "(", "app", "string", ",", "lines", "int", ")", "(", "[", "]", "string", ",", "error", ")", "{", "rb", ",", "ok", ":=", "a", ".", "ringBuffers", "[", "app", "]", "\n", "if", "ok", "{", "return", "rb", ".", "read", "(", "lines", ")", ",", "nil", "\n", "}", "\n", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "app", ")", "\n", "}" ]
// Read retrieves a specified number of log lines from an app-specific ringBuffer
[ "Read", "retrieves", "a", "specified", "number", "of", "log", "lines", "from", "an", "app", "-", "specific", "ringBuffer" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/storage/ringbuffer/adapter.go#L86-L92
142,905
deis/deis
client/parser/config.go
Config
func Config(argv []string) error { usage := ` Valid commands for config: config:list list environment variables for an app config:set set environment variables for an app config:unset unset environment variables for an app config:pull extract environment variables to .env config:push set environment variables from .env Use 'deis help [command]' to learn more. ` switch argv[0] { case "config:list": return configList(argv) case "config:set": return configSet(argv) case "config:unset": return configUnset(argv) case "config:pull": return configPull(argv) case "config:push": return configPush(argv) default: if printHelp(argv, usage) { return nil } if argv[0] == "config" { argv[0] = "config:list" return configList(argv) } PrintUsage() return nil } }
go
func Config(argv []string) error { usage := ` Valid commands for config: config:list list environment variables for an app config:set set environment variables for an app config:unset unset environment variables for an app config:pull extract environment variables to .env config:push set environment variables from .env Use 'deis help [command]' to learn more. ` switch argv[0] { case "config:list": return configList(argv) case "config:set": return configSet(argv) case "config:unset": return configUnset(argv) case "config:pull": return configPull(argv) case "config:push": return configPush(argv) default: if printHelp(argv, usage) { return nil } if argv[0] == "config" { argv[0] = "config:list" return configList(argv) } PrintUsage() return nil } }
[ "func", "Config", "(", "argv", "[", "]", "string", ")", "error", "{", "usage", ":=", "`\nValid commands for config:\n\nconfig:list list environment variables for an app\nconfig:set set environment variables for an app\nconfig:unset unset environment variables for an app\nconfig:pull extract environment variables to .env\nconfig:push set environment variables from .env\n\nUse 'deis help [command]' to learn more.\n`", "\n\n", "switch", "argv", "[", "0", "]", "{", "case", "\"", "\"", ":", "return", "configList", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "return", "configSet", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "return", "configUnset", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "return", "configPull", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "return", "configPush", "(", "argv", ")", "\n", "default", ":", "if", "printHelp", "(", "argv", ",", "usage", ")", "{", "return", "nil", "\n", "}", "\n\n", "if", "argv", "[", "0", "]", "==", "\"", "\"", "{", "argv", "[", "0", "]", "=", "\"", "\"", "\n", "return", "configList", "(", "argv", ")", "\n", "}", "\n\n", "PrintUsage", "(", ")", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// Config routes config commands to their specific function.
[ "Config", "routes", "config", "commands", "to", "their", "specific", "function", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/parser/config.go#L9-L46
142,906
deis/deis
Godeps/_workspace/src/gopkg.in/tomb.v1/tomb.go
Wait
func (t *Tomb) Wait() error { t.init() <-t.dead t.m.Lock() reason := t.reason t.m.Unlock() return reason }
go
func (t *Tomb) Wait() error { t.init() <-t.dead t.m.Lock() reason := t.reason t.m.Unlock() return reason }
[ "func", "(", "t", "*", "Tomb", ")", "Wait", "(", ")", "error", "{", "t", ".", "init", "(", ")", "\n", "<-", "t", ".", "dead", "\n", "t", ".", "m", ".", "Lock", "(", ")", "\n", "reason", ":=", "t", ".", "reason", "\n", "t", ".", "m", ".", "Unlock", "(", ")", "\n", "return", "reason", "\n", "}" ]
// Wait blocks until the goroutine is in a dead state and returns the // reason for its death.
[ "Wait", "blocks", "until", "the", "goroutine", "is", "in", "a", "dead", "state", "and", "returns", "the", "reason", "for", "its", "death", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/Godeps/_workspace/src/gopkg.in/tomb.v1/tomb.go#L111-L118
142,907
deis/deis
Godeps/_workspace/src/gopkg.in/tomb.v1/tomb.go
Kill
func (t *Tomb) Kill(reason error) { t.init() t.m.Lock() defer t.m.Unlock() if reason == ErrDying { if t.reason == ErrStillAlive { panic("tomb: Kill with ErrDying while still alive") } return } if t.reason == nil || t.reason == ErrStillAlive { t.reason = reason } // If the receive on t.dying succeeds, then // it can only be because we have already closed it. // If it blocks, then we know that it needs to be closed. select { case <-t.dying: default: close(t.dying) } }
go
func (t *Tomb) Kill(reason error) { t.init() t.m.Lock() defer t.m.Unlock() if reason == ErrDying { if t.reason == ErrStillAlive { panic("tomb: Kill with ErrDying while still alive") } return } if t.reason == nil || t.reason == ErrStillAlive { t.reason = reason } // If the receive on t.dying succeeds, then // it can only be because we have already closed it. // If it blocks, then we know that it needs to be closed. select { case <-t.dying: default: close(t.dying) } }
[ "func", "(", "t", "*", "Tomb", ")", "Kill", "(", "reason", "error", ")", "{", "t", ".", "init", "(", ")", "\n", "t", ".", "m", ".", "Lock", "(", ")", "\n", "defer", "t", ".", "m", ".", "Unlock", "(", ")", "\n", "if", "reason", "==", "ErrDying", "{", "if", "t", ".", "reason", "==", "ErrStillAlive", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "\n", "}", "\n", "if", "t", ".", "reason", "==", "nil", "||", "t", ".", "reason", "==", "ErrStillAlive", "{", "t", ".", "reason", "=", "reason", "\n", "}", "\n", "// If the receive on t.dying succeeds, then", "// it can only be because we have already closed it.", "// If it blocks, then we know that it needs to be closed.", "select", "{", "case", "<-", "t", ".", "dying", ":", "default", ":", "close", "(", "t", ".", "dying", ")", "\n", "}", "\n", "}" ]
// Kill flags the goroutine as dying for the given reason. // Kill may be called multiple times, but only the first // non-nil error is recorded as the reason for termination. // // If reason is ErrDying, the previous reason isn't replaced // even if it is nil. It's a runtime error to call Kill with // ErrDying if t is not in a dying state.
[ "Kill", "flags", "the", "goroutine", "as", "dying", "for", "the", "given", "reason", ".", "Kill", "may", "be", "called", "multiple", "times", "but", "only", "the", "first", "non", "-", "nil", "error", "is", "recorded", "as", "the", "reason", "for", "termination", ".", "If", "reason", "is", "ErrDying", "the", "previous", "reason", "isn", "t", "replaced", "even", "if", "it", "is", "nil", ".", "It", "s", "a", "runtime", "error", "to", "call", "Kill", "with", "ErrDying", "if", "t", "is", "not", "in", "a", "dying", "state", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/Godeps/_workspace/src/gopkg.in/tomb.v1/tomb.go#L137-L158
142,908
deis/deis
Godeps/_workspace/src/gopkg.in/tomb.v1/tomb.go
Killf
func (t *Tomb) Killf(f string, a ...interface{}) error { err := fmt.Errorf(f, a...) t.Kill(err) return err }
go
func (t *Tomb) Killf(f string, a ...interface{}) error { err := fmt.Errorf(f, a...) t.Kill(err) return err }
[ "func", "(", "t", "*", "Tomb", ")", "Killf", "(", "f", "string", ",", "a", "...", "interface", "{", "}", ")", "error", "{", "err", ":=", "fmt", ".", "Errorf", "(", "f", ",", "a", "...", ")", "\n", "t", ".", "Kill", "(", "err", ")", "\n", "return", "err", "\n", "}" ]
// Killf works like Kill, but builds the reason providing the received // arguments to fmt.Errorf. The generated error is also returned.
[ "Killf", "works", "like", "Kill", "but", "builds", "the", "reason", "providing", "the", "received", "arguments", "to", "fmt", ".", "Errorf", ".", "The", "generated", "error", "is", "also", "returned", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/Godeps/_workspace/src/gopkg.in/tomb.v1/tomb.go#L162-L166
142,909
deis/deis
Godeps/_workspace/src/gopkg.in/tomb.v1/tomb.go
Err
func (t *Tomb) Err() (reason error) { t.init() t.m.Lock() reason = t.reason t.m.Unlock() return }
go
func (t *Tomb) Err() (reason error) { t.init() t.m.Lock() reason = t.reason t.m.Unlock() return }
[ "func", "(", "t", "*", "Tomb", ")", "Err", "(", ")", "(", "reason", "error", ")", "{", "t", ".", "init", "(", ")", "\n", "t", ".", "m", ".", "Lock", "(", ")", "\n", "reason", "=", "t", ".", "reason", "\n", "t", ".", "m", ".", "Unlock", "(", ")", "\n", "return", "\n", "}" ]
// Err returns the reason for the goroutine death provided via Kill // or Killf, or ErrStillAlive when the goroutine is still alive.
[ "Err", "returns", "the", "reason", "for", "the", "goroutine", "death", "provided", "via", "Kill", "or", "Killf", "or", "ErrStillAlive", "when", "the", "goroutine", "is", "still", "alive", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/Godeps/_workspace/src/gopkg.in/tomb.v1/tomb.go#L170-L176
142,910
deis/deis
client/cmd/builds.go
BuildsList
func BuildsList(appID string, results int) error { c, appID, err := load(appID) if err != nil { return err } if results == defaultLimit { results = c.ResponseLimit } builds, count, err := builds.List(c, appID, results) if err != nil { return err } fmt.Printf("=== %s Builds%s", appID, limitCount(len(builds), count)) for _, build := range builds { fmt.Println(build.UUID, build.Created) } return nil }
go
func BuildsList(appID string, results int) error { c, appID, err := load(appID) if err != nil { return err } if results == defaultLimit { results = c.ResponseLimit } builds, count, err := builds.List(c, appID, results) if err != nil { return err } fmt.Printf("=== %s Builds%s", appID, limitCount(len(builds), count)) for _, build := range builds { fmt.Println(build.UUID, build.Created) } return nil }
[ "func", "BuildsList", "(", "appID", "string", ",", "results", "int", ")", "error", "{", "c", ",", "appID", ",", "err", ":=", "load", "(", "appID", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "results", "==", "defaultLimit", "{", "results", "=", "c", ".", "ResponseLimit", "\n", "}", "\n\n", "builds", ",", "count", ",", "err", ":=", "builds", ".", "List", "(", "c", ",", "appID", ",", "results", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Printf", "(", "\"", "\"", ",", "appID", ",", "limitCount", "(", "len", "(", "builds", ")", ",", "count", ")", ")", "\n\n", "for", "_", ",", "build", ":=", "range", "builds", "{", "fmt", ".", "Println", "(", "build", ".", "UUID", ",", "build", ".", "Created", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// BuildsList lists an app's builds.
[ "BuildsList", "lists", "an", "app", "s", "builds", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/builds.go#L14-L37
142,911
deis/deis
client/cmd/builds.go
BuildsCreate
func BuildsCreate(appID, image, procfile string) error { c, appID, err := load(appID) if err != nil { return err } procfileMap := make(map[string]string) if procfile != "" { if procfileMap, err = parseProcfile([]byte(procfile)); err != nil { return err } } else if _, err := os.Stat("Procfile"); err == nil { contents, err := ioutil.ReadFile("Procfile") if err != nil { return err } if procfileMap, err = parseProcfile(contents); err != nil { return err } } fmt.Print("Creating build... ") quit := progress() _, err = builds.New(c, appID, image, procfileMap) quit <- true <-quit if err != nil { return err } fmt.Println("done") return nil }
go
func BuildsCreate(appID, image, procfile string) error { c, appID, err := load(appID) if err != nil { return err } procfileMap := make(map[string]string) if procfile != "" { if procfileMap, err = parseProcfile([]byte(procfile)); err != nil { return err } } else if _, err := os.Stat("Procfile"); err == nil { contents, err := ioutil.ReadFile("Procfile") if err != nil { return err } if procfileMap, err = parseProcfile(contents); err != nil { return err } } fmt.Print("Creating build... ") quit := progress() _, err = builds.New(c, appID, image, procfileMap) quit <- true <-quit if err != nil { return err } fmt.Println("done") return nil }
[ "func", "BuildsCreate", "(", "appID", ",", "image", ",", "procfile", "string", ")", "error", "{", "c", ",", "appID", ",", "err", ":=", "load", "(", "appID", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "procfileMap", ":=", "make", "(", "map", "[", "string", "]", "string", ")", "\n\n", "if", "procfile", "!=", "\"", "\"", "{", "if", "procfileMap", ",", "err", "=", "parseProcfile", "(", "[", "]", "byte", "(", "procfile", ")", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "else", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "\"", "\"", ")", ";", "err", "==", "nil", "{", "contents", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "procfileMap", ",", "err", "=", "parseProcfile", "(", "contents", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "fmt", ".", "Print", "(", "\"", "\"", ")", "\n", "quit", ":=", "progress", "(", ")", "\n", "_", ",", "err", "=", "builds", ".", "New", "(", "c", ",", "appID", ",", "image", ",", "procfileMap", ")", "\n", "quit", "<-", "true", "\n", "<-", "quit", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n\n", "return", "nil", "\n", "}" ]
// BuildsCreate creates a build for an app.
[ "BuildsCreate", "creates", "a", "build", "for", "an", "app", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/builds.go#L40-L77
142,912
deis/deis
client/cmd/apps.go
AppCreate
func AppCreate(id string, buildpack string, remote string, noRemote bool) error { c, err := client.New() if err != nil { return err } fmt.Print("Creating Application... ") quit := progress() app, err := apps.New(c, id) quit <- true <-quit if err != nil { return err } fmt.Printf("done, created %s\n", app.ID) if buildpack != "" { configValues := api.Config{ Values: map[string]interface{}{ "BUILDPACK_URL": buildpack, }, } if _, err = config.Set(c, app.ID, configValues); err != nil { return err } } if !noRemote { if err = git.CreateRemote(c.ControllerURL.Host, remote, app.ID); err != nil { if err.Error() == "exit status 128" { fmt.Println("To replace the existing git remote entry, run:") fmt.Printf(" git remote rename deis deis.old && deis git:remote -a %s\n", app.ID) } return err } } fmt.Println("remote available at", git.RemoteURL(c.ControllerURL.Host, app.ID)) return nil }
go
func AppCreate(id string, buildpack string, remote string, noRemote bool) error { c, err := client.New() if err != nil { return err } fmt.Print("Creating Application... ") quit := progress() app, err := apps.New(c, id) quit <- true <-quit if err != nil { return err } fmt.Printf("done, created %s\n", app.ID) if buildpack != "" { configValues := api.Config{ Values: map[string]interface{}{ "BUILDPACK_URL": buildpack, }, } if _, err = config.Set(c, app.ID, configValues); err != nil { return err } } if !noRemote { if err = git.CreateRemote(c.ControllerURL.Host, remote, app.ID); err != nil { if err.Error() == "exit status 128" { fmt.Println("To replace the existing git remote entry, run:") fmt.Printf(" git remote rename deis deis.old && deis git:remote -a %s\n", app.ID) } return err } } fmt.Println("remote available at", git.RemoteURL(c.ControllerURL.Host, app.ID)) return nil }
[ "func", "AppCreate", "(", "id", "string", ",", "buildpack", "string", ",", "remote", "string", ",", "noRemote", "bool", ")", "error", "{", "c", ",", "err", ":=", "client", ".", "New", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Print", "(", "\"", "\"", ")", "\n", "quit", ":=", "progress", "(", ")", "\n", "app", ",", "err", ":=", "apps", ".", "New", "(", "c", ",", "id", ")", "\n\n", "quit", "<-", "true", "\n", "<-", "quit", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "app", ".", "ID", ")", "\n\n", "if", "buildpack", "!=", "\"", "\"", "{", "configValues", ":=", "api", ".", "Config", "{", "Values", ":", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "buildpack", ",", "}", ",", "}", "\n", "if", "_", ",", "err", "=", "config", ".", "Set", "(", "c", ",", "app", ".", "ID", ",", "configValues", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "if", "!", "noRemote", "{", "if", "err", "=", "git", ".", "CreateRemote", "(", "c", ".", "ControllerURL", ".", "Host", ",", "remote", ",", "app", ".", "ID", ")", ";", "err", "!=", "nil", "{", "if", "err", ".", "Error", "(", ")", "==", "\"", "\"", "{", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "app", ".", "ID", ")", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "}", "\n\n", "fmt", ".", "Println", "(", "\"", "\"", ",", "git", ".", "RemoteURL", "(", "c", ".", "ControllerURL", ".", "Host", ",", "app", ".", "ID", ")", ")", "\n\n", "return", "nil", "\n", "}" ]
// AppCreate creates an app.
[ "AppCreate", "creates", "an", "app", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/apps.go#L21-L64
142,913
deis/deis
client/cmd/apps.go
AppsList
func AppsList(results int) error { c, err := client.New() if err != nil { return err } if results == defaultLimit { results = c.ResponseLimit } apps, count, err := apps.List(c, results) if err != nil { return err } fmt.Printf("=== Apps%s", limitCount(len(apps), count)) sort.Sort(apps) for _, app := range apps { fmt.Println(app.ID) } return nil }
go
func AppsList(results int) error { c, err := client.New() if err != nil { return err } if results == defaultLimit { results = c.ResponseLimit } apps, count, err := apps.List(c, results) if err != nil { return err } fmt.Printf("=== Apps%s", limitCount(len(apps), count)) sort.Sort(apps) for _, app := range apps { fmt.Println(app.ID) } return nil }
[ "func", "AppsList", "(", "results", "int", ")", "error", "{", "c", ",", "err", ":=", "client", ".", "New", "(", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "results", "==", "defaultLimit", "{", "results", "=", "c", ".", "ResponseLimit", "\n", "}", "\n\n", "apps", ",", "count", ",", "err", ":=", "apps", ".", "List", "(", "c", ",", "results", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Printf", "(", "\"", "\"", ",", "limitCount", "(", "len", "(", "apps", ")", ",", "count", ")", ")", "\n\n", "sort", ".", "Sort", "(", "apps", ")", "\n", "for", "_", ",", "app", ":=", "range", "apps", "{", "fmt", ".", "Println", "(", "app", ".", "ID", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// AppsList lists apps on the Deis controller.
[ "AppsList", "lists", "apps", "on", "the", "Deis", "controller", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/apps.go#L67-L91
142,914
deis/deis
client/cmd/apps.go
AppInfo
func AppInfo(appID string) error { c, appID, err := load(appID) if err != nil { return err } app, err := apps.Get(c, appID) if err != nil { return err } fmt.Printf("=== %s Application\n", app.ID) fmt.Println("updated: ", app.Updated) fmt.Println("uuid: ", app.UUID) fmt.Println("created: ", app.Created) fmt.Println("url: ", app.URL) fmt.Println("owner: ", app.Owner) fmt.Println("id: ", app.ID) fmt.Println() // print the app processes if err = PsList(app.ID, defaultLimit); err != nil { return err } fmt.Println() // print the app domains if err = DomainsList(app.ID, defaultLimit); err != nil { return err } fmt.Println() return nil }
go
func AppInfo(appID string) error { c, appID, err := load(appID) if err != nil { return err } app, err := apps.Get(c, appID) if err != nil { return err } fmt.Printf("=== %s Application\n", app.ID) fmt.Println("updated: ", app.Updated) fmt.Println("uuid: ", app.UUID) fmt.Println("created: ", app.Created) fmt.Println("url: ", app.URL) fmt.Println("owner: ", app.Owner) fmt.Println("id: ", app.ID) fmt.Println() // print the app processes if err = PsList(app.ID, defaultLimit); err != nil { return err } fmt.Println() // print the app domains if err = DomainsList(app.ID, defaultLimit); err != nil { return err } fmt.Println() return nil }
[ "func", "AppInfo", "(", "appID", "string", ")", "error", "{", "c", ",", "appID", ",", "err", ":=", "load", "(", "appID", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "app", ",", "err", ":=", "apps", ".", "Get", "(", "c", ",", "appID", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "app", ".", "ID", ")", "\n", "fmt", ".", "Println", "(", "\"", "\"", ",", "app", ".", "Updated", ")", "\n", "fmt", ".", "Println", "(", "\"", "\"", ",", "app", ".", "UUID", ")", "\n", "fmt", ".", "Println", "(", "\"", "\"", ",", "app", ".", "Created", ")", "\n", "fmt", ".", "Println", "(", "\"", "\"", ",", "app", ".", "URL", ")", "\n", "fmt", ".", "Println", "(", "\"", "\"", ",", "app", ".", "Owner", ")", "\n", "fmt", ".", "Println", "(", "\"", "\"", ",", "app", ".", "ID", ")", "\n\n", "fmt", ".", "Println", "(", ")", "\n", "// print the app processes", "if", "err", "=", "PsList", "(", "app", ".", "ID", ",", "defaultLimit", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Println", "(", ")", "\n", "// print the app domains", "if", "err", "=", "DomainsList", "(", "app", ".", "ID", ",", "defaultLimit", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Println", "(", ")", "\n\n", "return", "nil", "\n", "}" ]
// AppInfo prints info about app.
[ "AppInfo", "prints", "info", "about", "app", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/apps.go#L94-L130
142,915
deis/deis
client/cmd/apps.go
AppOpen
func AppOpen(appID string) error { c, appID, err := load(appID) if err != nil { return err } app, err := apps.Get(c, appID) if err != nil { return err } u := app.URL if !(strings.HasPrefix(u, "http://") || strings.HasPrefix(u, "https://")) { u = "http://" + u } return webbrowser.Webbrowser(u) }
go
func AppOpen(appID string) error { c, appID, err := load(appID) if err != nil { return err } app, err := apps.Get(c, appID) if err != nil { return err } u := app.URL if !(strings.HasPrefix(u, "http://") || strings.HasPrefix(u, "https://")) { u = "http://" + u } return webbrowser.Webbrowser(u) }
[ "func", "AppOpen", "(", "appID", "string", ")", "error", "{", "c", ",", "appID", ",", "err", ":=", "load", "(", "appID", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "app", ",", "err", ":=", "apps", ".", "Get", "(", "c", ",", "appID", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "u", ":=", "app", ".", "URL", "\n", "if", "!", "(", "strings", ".", "HasPrefix", "(", "u", ",", "\"", "\"", ")", "||", "strings", ".", "HasPrefix", "(", "u", ",", "\"", "\"", ")", ")", "{", "u", "=", "\"", "\"", "+", "u", "\n", "}", "\n\n", "return", "webbrowser", ".", "Webbrowser", "(", "u", ")", "\n", "}" ]
// AppOpen opens an app in the default webbrowser.
[ "AppOpen", "opens", "an", "app", "in", "the", "default", "webbrowser", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/apps.go#L133-L152
142,916
deis/deis
client/cmd/apps.go
AppLogs
func AppLogs(appID string, lines int) error { c, appID, err := load(appID) if err != nil { return err } logs, err := apps.Logs(c, appID, lines) if err != nil { return err } return printLogs(logs) }
go
func AppLogs(appID string, lines int) error { c, appID, err := load(appID) if err != nil { return err } logs, err := apps.Logs(c, appID, lines) if err != nil { return err } return printLogs(logs) }
[ "func", "AppLogs", "(", "appID", "string", ",", "lines", "int", ")", "error", "{", "c", ",", "appID", ",", "err", ":=", "load", "(", "appID", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "logs", ",", "err", ":=", "apps", ".", "Logs", "(", "c", ",", "appID", ",", "lines", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "printLogs", "(", "logs", ")", "\n", "}" ]
// AppLogs returns the logs from an app.
[ "AppLogs", "returns", "the", "logs", "from", "an", "app", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/apps.go#L155-L169
142,917
deis/deis
client/cmd/apps.go
printLogs
func printLogs(logs string) error { for _, log := range strings.Split(logs, "\n") { category := "unknown" parts := strings.Split(strings.Split(log, ": ")[0], " ") if len(parts) >= 2 { category = parts[1] } colorVars := map[string]string{ "Color": chooseColor(category), "Log": log, } fmt.Println(prettyprint.ColorizeVars("{{.V.Color}}{{.V.Log}}{{.C.Default}}", colorVars)) } return nil }
go
func printLogs(logs string) error { for _, log := range strings.Split(logs, "\n") { category := "unknown" parts := strings.Split(strings.Split(log, ": ")[0], " ") if len(parts) >= 2 { category = parts[1] } colorVars := map[string]string{ "Color": chooseColor(category), "Log": log, } fmt.Println(prettyprint.ColorizeVars("{{.V.Color}}{{.V.Log}}{{.C.Default}}", colorVars)) } return nil }
[ "func", "printLogs", "(", "logs", "string", ")", "error", "{", "for", "_", ",", "log", ":=", "range", "strings", ".", "Split", "(", "logs", ",", "\"", "\\n", "\"", ")", "{", "category", ":=", "\"", "\"", "\n", "parts", ":=", "strings", ".", "Split", "(", "strings", ".", "Split", "(", "log", ",", "\"", "\"", ")", "[", "0", "]", ",", "\"", "\"", ")", "\n", "if", "len", "(", "parts", ")", ">=", "2", "{", "category", "=", "parts", "[", "1", "]", "\n", "}", "\n", "colorVars", ":=", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "chooseColor", "(", "category", ")", ",", "\"", "\"", ":", "log", ",", "}", "\n", "fmt", ".", "Println", "(", "prettyprint", ".", "ColorizeVars", "(", "\"", "\"", ",", "colorVars", ")", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// printLogs prints each log line with a color matched to its category.
[ "printLogs", "prints", "each", "log", "line", "with", "a", "color", "matched", "to", "its", "category", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/apps.go#L172-L187
142,918
deis/deis
client/cmd/apps.go
AppRun
func AppRun(appID, command string) error { c, appID, err := load(appID) if err != nil { return err } fmt.Printf("Running '%s'...\n", command) out, err := apps.Run(c, appID, command) if err != nil { return err } fmt.Print(out.Output) os.Exit(out.ReturnCode) return nil }
go
func AppRun(appID, command string) error { c, appID, err := load(appID) if err != nil { return err } fmt.Printf("Running '%s'...\n", command) out, err := apps.Run(c, appID, command) if err != nil { return err } fmt.Print(out.Output) os.Exit(out.ReturnCode) return nil }
[ "func", "AppRun", "(", "appID", ",", "command", "string", ")", "error", "{", "c", ",", "appID", ",", "err", ":=", "load", "(", "appID", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "command", ")", "\n\n", "out", ",", "err", ":=", "apps", ".", "Run", "(", "c", ",", "appID", ",", "command", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Print", "(", "out", ".", "Output", ")", "\n", "os", ".", "Exit", "(", "out", ".", "ReturnCode", ")", "\n", "return", "nil", "\n", "}" ]
// AppRun runs a one time command in the app.
[ "AppRun", "runs", "a", "one", "time", "command", "in", "the", "app", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/apps.go#L190-L208
142,919
deis/deis
client/cmd/apps.go
AppDestroy
func AppDestroy(appID, confirm string) error { gitSession := false c, err := client.New() if err != nil { return err } if appID == "" { appID, err = git.DetectAppName(c.ControllerURL.Host) if err != nil { return err } gitSession = true } if confirm == "" { fmt.Printf(` ! WARNING: Potentially Destructive Action ! This command will destroy the application: %s ! To proceed, type "%s" or re-run this command with --confirm=%s > `, appID, appID, appID) fmt.Scanln(&confirm) } if confirm != appID { return fmt.Errorf("App %s does not match confirm %s, aborting.", appID, confirm) } startTime := time.Now() fmt.Printf("Destroying %s...\n", appID) if err = apps.Delete(c, appID); err != nil { return err } fmt.Printf("done in %ds\n", int(time.Since(startTime).Seconds())) if gitSession { return git.DeleteRemote(appID) } return nil }
go
func AppDestroy(appID, confirm string) error { gitSession := false c, err := client.New() if err != nil { return err } if appID == "" { appID, err = git.DetectAppName(c.ControllerURL.Host) if err != nil { return err } gitSession = true } if confirm == "" { fmt.Printf(` ! WARNING: Potentially Destructive Action ! This command will destroy the application: %s ! To proceed, type "%s" or re-run this command with --confirm=%s > `, appID, appID, appID) fmt.Scanln(&confirm) } if confirm != appID { return fmt.Errorf("App %s does not match confirm %s, aborting.", appID, confirm) } startTime := time.Now() fmt.Printf("Destroying %s...\n", appID) if err = apps.Delete(c, appID); err != nil { return err } fmt.Printf("done in %ds\n", int(time.Since(startTime).Seconds())) if gitSession { return git.DeleteRemote(appID) } return nil }
[ "func", "AppDestroy", "(", "appID", ",", "confirm", "string", ")", "error", "{", "gitSession", ":=", "false", "\n\n", "c", ",", "err", ":=", "client", ".", "New", "(", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "appID", "==", "\"", "\"", "{", "appID", ",", "err", "=", "git", ".", "DetectAppName", "(", "c", ".", "ControllerURL", ".", "Host", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "gitSession", "=", "true", "\n", "}", "\n\n", "if", "confirm", "==", "\"", "\"", "{", "fmt", ".", "Printf", "(", "` ! WARNING: Potentially Destructive Action\n ! This command will destroy the application: %s\n ! To proceed, type \"%s\" or re-run this command with --confirm=%s\n\n> `", ",", "appID", ",", "appID", ",", "appID", ")", "\n\n", "fmt", ".", "Scanln", "(", "&", "confirm", ")", "\n", "}", "\n\n", "if", "confirm", "!=", "appID", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "appID", ",", "confirm", ")", "\n", "}", "\n\n", "startTime", ":=", "time", ".", "Now", "(", ")", "\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "appID", ")", "\n\n", "if", "err", "=", "apps", ".", "Delete", "(", "c", ",", "appID", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "int", "(", "time", ".", "Since", "(", "startTime", ")", ".", "Seconds", "(", ")", ")", ")", "\n\n", "if", "gitSession", "{", "return", "git", ".", "DeleteRemote", "(", "appID", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// AppDestroy destroys an app.
[ "AppDestroy", "destroys", "an", "app", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/apps.go#L211-L258
142,920
deis/deis
client/cmd/apps.go
AppTransfer
func AppTransfer(appID, username string) error { c, appID, err := load(appID) if err != nil { return err } fmt.Printf("Transferring %s to %s... ", appID, username) err = apps.Transfer(c, appID, username) if err != nil { return err } fmt.Println("done") return nil }
go
func AppTransfer(appID, username string) error { c, appID, err := load(appID) if err != nil { return err } fmt.Printf("Transferring %s to %s... ", appID, username) err = apps.Transfer(c, appID, username) if err != nil { return err } fmt.Println("done") return nil }
[ "func", "AppTransfer", "(", "appID", ",", "username", "string", ")", "error", "{", "c", ",", "appID", ",", "err", ":=", "load", "(", "appID", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Printf", "(", "\"", "\"", ",", "appID", ",", "username", ")", "\n\n", "err", "=", "apps", ".", "Transfer", "(", "c", ",", "appID", ",", "username", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n\n", "return", "nil", "\n", "}" ]
// AppTransfer transfers app ownership to another user.
[ "AppTransfer", "transfers", "app", "ownership", "to", "another", "user", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/apps.go#L261-L279
142,921
deis/deis
client/controller/models/users/users.go
List
func List(c *client.Client, results int) (api.Users, int, error) { body, count, err := c.LimitedRequest("/v1/users/", results) if err != nil { return []api.User{}, -1, err } var users []api.User if err = json.Unmarshal([]byte(body), &users); err != nil { return []api.User{}, -1, err } return users, count, nil }
go
func List(c *client.Client, results int) (api.Users, int, error) { body, count, err := c.LimitedRequest("/v1/users/", results) if err != nil { return []api.User{}, -1, err } var users []api.User if err = json.Unmarshal([]byte(body), &users); err != nil { return []api.User{}, -1, err } return users, count, nil }
[ "func", "List", "(", "c", "*", "client", ".", "Client", ",", "results", "int", ")", "(", "api", ".", "Users", ",", "int", ",", "error", ")", "{", "body", ",", "count", ",", "err", ":=", "c", ".", "LimitedRequest", "(", "\"", "\"", ",", "results", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "[", "]", "api", ".", "User", "{", "}", ",", "-", "1", ",", "err", "\n", "}", "\n\n", "var", "users", "[", "]", "api", ".", "User", "\n", "if", "err", "=", "json", ".", "Unmarshal", "(", "[", "]", "byte", "(", "body", ")", ",", "&", "users", ")", ";", "err", "!=", "nil", "{", "return", "[", "]", "api", ".", "User", "{", "}", ",", "-", "1", ",", "err", "\n", "}", "\n\n", "return", "users", ",", "count", ",", "nil", "\n", "}" ]
// List users registered with the controller.
[ "List", "users", "registered", "with", "the", "controller", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/users/users.go#L11-L24
142,922
deis/deis
client/parser/apps.go
Apps
func Apps(argv []string) error { usage := ` Valid commands for apps: apps:create create a new application apps:list list accessible applications apps:info view info about an application apps:open open the application in a browser apps:logs view aggregated application logs apps:run run a command in an ephemeral app container apps:destroy destroy an application apps:transfer transfer app ownership to another user Use 'deis help [command]' to learn more. ` switch argv[0] { case "apps:create": return appCreate(argv) case "apps:list": return appsList(argv) case "apps:info": return appInfo(argv) case "apps:open": return appOpen(argv) case "apps:logs": return appLogs(argv) case "apps:run": return appRun(argv) case "apps:destroy": return appDestroy(argv) case "apps:transfer": return appTransfer(argv) default: if printHelp(argv, usage) { return nil } if argv[0] == "apps" { argv[0] = "apps:list" return appsList(argv) } PrintUsage() return nil } }
go
func Apps(argv []string) error { usage := ` Valid commands for apps: apps:create create a new application apps:list list accessible applications apps:info view info about an application apps:open open the application in a browser apps:logs view aggregated application logs apps:run run a command in an ephemeral app container apps:destroy destroy an application apps:transfer transfer app ownership to another user Use 'deis help [command]' to learn more. ` switch argv[0] { case "apps:create": return appCreate(argv) case "apps:list": return appsList(argv) case "apps:info": return appInfo(argv) case "apps:open": return appOpen(argv) case "apps:logs": return appLogs(argv) case "apps:run": return appRun(argv) case "apps:destroy": return appDestroy(argv) case "apps:transfer": return appTransfer(argv) default: if printHelp(argv, usage) { return nil } if argv[0] == "apps" { argv[0] = "apps:list" return appsList(argv) } PrintUsage() return nil } }
[ "func", "Apps", "(", "argv", "[", "]", "string", ")", "error", "{", "usage", ":=", "`\nValid commands for apps:\n\napps:create create a new application\napps:list list accessible applications\napps:info view info about an application\napps:open open the application in a browser\napps:logs view aggregated application logs\napps:run run a command in an ephemeral app container\napps:destroy destroy an application\napps:transfer transfer app ownership to another user\n\nUse 'deis help [command]' to learn more.\n`", "\n\n", "switch", "argv", "[", "0", "]", "{", "case", "\"", "\"", ":", "return", "appCreate", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "return", "appsList", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "return", "appInfo", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "return", "appOpen", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "return", "appLogs", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "return", "appRun", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "return", "appDestroy", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "return", "appTransfer", "(", "argv", ")", "\n", "default", ":", "if", "printHelp", "(", "argv", ",", "usage", ")", "{", "return", "nil", "\n", "}", "\n\n", "if", "argv", "[", "0", "]", "==", "\"", "\"", "{", "argv", "[", "0", "]", "=", "\"", "\"", "\n", "return", "appsList", "(", "argv", ")", "\n", "}", "\n\n", "PrintUsage", "(", ")", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// Apps routes app commands to their specific function.
[ "Apps", "routes", "app", "commands", "to", "their", "specific", "function", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/parser/apps.go#L12-L58
142,923
deis/deis
client/controller/client/http.go
CreateHTTPClient
func CreateHTTPClient(sslVerify bool) *http.Client { tr := &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: !sslVerify}, DisableKeepAlives: true, } return &http.Client{Transport: tr} }
go
func CreateHTTPClient(sslVerify bool) *http.Client { tr := &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: !sslVerify}, DisableKeepAlives: true, } return &http.Client{Transport: tr} }
[ "func", "CreateHTTPClient", "(", "sslVerify", "bool", ")", "*", "http", ".", "Client", "{", "tr", ":=", "&", "http", ".", "Transport", "{", "TLSClientConfig", ":", "&", "tls", ".", "Config", "{", "InsecureSkipVerify", ":", "!", "sslVerify", "}", ",", "DisableKeepAlives", ":", "true", ",", "}", "\n", "return", "&", "http", ".", "Client", "{", "Transport", ":", "tr", "}", "\n", "}" ]
// CreateHTTPClient creates a HTTP Client with proper SSL options.
[ "CreateHTTPClient", "creates", "a", "HTTP", "Client", "with", "proper", "SSL", "options", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/client/http.go#L20-L26
142,924
deis/deis
client/controller/client/http.go
Request
func (c Client) Request(method string, path string, body []byte) (*http.Response, error) { url := c.ControllerURL if strings.Contains(path, "?") { parts := strings.Split(path, "?") url.Path = parts[0] url.RawQuery = parts[1] } else { url.Path = path } req, err := http.NewRequest(method, url.String(), bytes.NewBuffer(body)) if err != nil { return nil, err } req.Header.Add("Content-Type", "application/json") if c.Token != "" { req.Header.Add("Authorization", "token "+c.Token) } addUserAgent(&req.Header) res, err := c.HTTPClient.Do(req) if err != nil { return nil, err } if err = checkForErrors(res, ""); err != nil { return nil, err } checkAPICompatibility(res.Header.Get("DEIS_API_VERSION")) return res, nil }
go
func (c Client) Request(method string, path string, body []byte) (*http.Response, error) { url := c.ControllerURL if strings.Contains(path, "?") { parts := strings.Split(path, "?") url.Path = parts[0] url.RawQuery = parts[1] } else { url.Path = path } req, err := http.NewRequest(method, url.String(), bytes.NewBuffer(body)) if err != nil { return nil, err } req.Header.Add("Content-Type", "application/json") if c.Token != "" { req.Header.Add("Authorization", "token "+c.Token) } addUserAgent(&req.Header) res, err := c.HTTPClient.Do(req) if err != nil { return nil, err } if err = checkForErrors(res, ""); err != nil { return nil, err } checkAPICompatibility(res.Header.Get("DEIS_API_VERSION")) return res, nil }
[ "func", "(", "c", "Client", ")", "Request", "(", "method", "string", ",", "path", "string", ",", "body", "[", "]", "byte", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "url", ":=", "c", ".", "ControllerURL", "\n\n", "if", "strings", ".", "Contains", "(", "path", ",", "\"", "\"", ")", "{", "parts", ":=", "strings", ".", "Split", "(", "path", ",", "\"", "\"", ")", "\n", "url", ".", "Path", "=", "parts", "[", "0", "]", "\n", "url", ".", "RawQuery", "=", "parts", "[", "1", "]", "\n", "}", "else", "{", "url", ".", "Path", "=", "path", "\n", "}", "\n\n", "req", ",", "err", ":=", "http", ".", "NewRequest", "(", "method", ",", "url", ".", "String", "(", ")", ",", "bytes", ".", "NewBuffer", "(", "body", ")", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "req", ".", "Header", ".", "Add", "(", "\"", "\"", ",", "\"", "\"", ")", "\n\n", "if", "c", ".", "Token", "!=", "\"", "\"", "{", "req", ".", "Header", ".", "Add", "(", "\"", "\"", ",", "\"", "\"", "+", "c", ".", "Token", ")", "\n", "}", "\n\n", "addUserAgent", "(", "&", "req", ".", "Header", ")", "\n\n", "res", ",", "err", ":=", "c", ".", "HTTPClient", ".", "Do", "(", "req", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "err", "=", "checkForErrors", "(", "res", ",", "\"", "\"", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "checkAPICompatibility", "(", "res", ".", "Header", ".", "Get", "(", "\"", "\"", ")", ")", "\n\n", "return", "res", ",", "nil", "\n", "}" ]
// Request makes a HTTP request on the controller.
[ "Request", "makes", "a", "HTTP", "request", "on", "the", "controller", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/client/http.go#L29-L67
142,925
deis/deis
client/controller/client/http.go
BasicRequest
func (c Client) BasicRequest(method string, path string, body []byte) (string, error) { res, err := c.Request(method, path, body) if err != nil { return "", err } defer res.Body.Close() resBody, err := ioutil.ReadAll(res.Body) if err != nil { return "", err } return string(resBody), checkForErrors(res, string(resBody)) }
go
func (c Client) BasicRequest(method string, path string, body []byte) (string, error) { res, err := c.Request(method, path, body) if err != nil { return "", err } defer res.Body.Close() resBody, err := ioutil.ReadAll(res.Body) if err != nil { return "", err } return string(resBody), checkForErrors(res, string(resBody)) }
[ "func", "(", "c", "Client", ")", "BasicRequest", "(", "method", "string", ",", "path", "string", ",", "body", "[", "]", "byte", ")", "(", "string", ",", "error", ")", "{", "res", ",", "err", ":=", "c", ".", "Request", "(", "method", ",", "path", ",", "body", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "defer", "res", ".", "Body", ".", "Close", "(", ")", "\n\n", "resBody", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "res", ".", "Body", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "return", "string", "(", "resBody", ")", ",", "checkForErrors", "(", "res", ",", "string", "(", "resBody", ")", ")", "\n", "}" ]
// BasicRequest makes a simple http request on the controller.
[ "BasicRequest", "makes", "a", "simple", "http", "request", "on", "the", "controller", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/client/http.go#L92-L106
142,926
deis/deis
logger/drain/factory.go
NewDrain
func NewDrain(drainURL string) (LogDrain, error) { if drainURL == "" { // nil means no drain-- which is valid return nil, nil } // Any of these three can use the same drain implementation if strings.HasPrefix(drainURL, "udp://") || strings.HasPrefix(drainURL, "syslog://") || strings.HasPrefix(drainURL, "tcp://") { drain, err := simple.NewDrain(drainURL) if err != nil { return nil, err } return drain, nil } // TODO: Add more drain implementations-- TLS over TCP and HTTP/S return nil, fmt.Errorf("Cannot construct a drain for URL: '%s'", drainURL) }
go
func NewDrain(drainURL string) (LogDrain, error) { if drainURL == "" { // nil means no drain-- which is valid return nil, nil } // Any of these three can use the same drain implementation if strings.HasPrefix(drainURL, "udp://") || strings.HasPrefix(drainURL, "syslog://") || strings.HasPrefix(drainURL, "tcp://") { drain, err := simple.NewDrain(drainURL) if err != nil { return nil, err } return drain, nil } // TODO: Add more drain implementations-- TLS over TCP and HTTP/S return nil, fmt.Errorf("Cannot construct a drain for URL: '%s'", drainURL) }
[ "func", "NewDrain", "(", "drainURL", "string", ")", "(", "LogDrain", ",", "error", ")", "{", "if", "drainURL", "==", "\"", "\"", "{", "// nil means no drain-- which is valid", "return", "nil", ",", "nil", "\n", "}", "\n", "// Any of these three can use the same drain implementation", "if", "strings", ".", "HasPrefix", "(", "drainURL", ",", "\"", "\"", ")", "||", "strings", ".", "HasPrefix", "(", "drainURL", ",", "\"", "\"", ")", "||", "strings", ".", "HasPrefix", "(", "drainURL", ",", "\"", "\"", ")", "{", "drain", ",", "err", ":=", "simple", ".", "NewDrain", "(", "drainURL", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "drain", ",", "nil", "\n", "}", "\n", "// TODO: Add more drain implementations-- TLS over TCP and HTTP/S", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "drainURL", ")", "\n", "}" ]
// NewDrain returns a pointer to an appropriate implementation of the LogDrain interface, as // determined by the drainURL it is passed.
[ "NewDrain", "returns", "a", "pointer", "to", "an", "appropriate", "implementation", "of", "the", "LogDrain", "interface", "as", "determined", "by", "the", "drainURL", "it", "is", "passed", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/drain/factory.go#L12-L27
142,927
deis/deis
logger/configurer/configurer.go
NewConfigurer
func NewConfigurer(etcdHost string, etcdPort int, etcdPath string, configInterval int, syslogishServer *syslogish.Server) (*Configurer, error) { etcdClient := etcd.NewClient([]string{fmt.Sprintf("http://%s:%d", etcdHost, etcdPort)}) ticker := time.NewTicker(time.Duration(configInterval) * time.Second) configurer := &Configurer{ etcdClient: etcdClient, etcdPath: etcdPath, syslogishServer: syslogishServer, ticker: ticker, } // Support legacy behavior that allows default drain uri to be specified using a drain-uri flag if _, err := etcdClient.Get(etcdPath+"/drain", false, false); err != nil { etcdErr, ok := err.(*etcd.EtcdError) // Error code 100 is key not found if ok && etcdErr.ErrorCode == 100 { configurer.setEtcd("/drain", DefaultDrainURI) } else { log.Println(err) } } return configurer, nil }
go
func NewConfigurer(etcdHost string, etcdPort int, etcdPath string, configInterval int, syslogishServer *syslogish.Server) (*Configurer, error) { etcdClient := etcd.NewClient([]string{fmt.Sprintf("http://%s:%d", etcdHost, etcdPort)}) ticker := time.NewTicker(time.Duration(configInterval) * time.Second) configurer := &Configurer{ etcdClient: etcdClient, etcdPath: etcdPath, syslogishServer: syslogishServer, ticker: ticker, } // Support legacy behavior that allows default drain uri to be specified using a drain-uri flag if _, err := etcdClient.Get(etcdPath+"/drain", false, false); err != nil { etcdErr, ok := err.(*etcd.EtcdError) // Error code 100 is key not found if ok && etcdErr.ErrorCode == 100 { configurer.setEtcd("/drain", DefaultDrainURI) } else { log.Println(err) } } return configurer, nil }
[ "func", "NewConfigurer", "(", "etcdHost", "string", ",", "etcdPort", "int", ",", "etcdPath", "string", ",", "configInterval", "int", ",", "syslogishServer", "*", "syslogish", ".", "Server", ")", "(", "*", "Configurer", ",", "error", ")", "{", "etcdClient", ":=", "etcd", ".", "NewClient", "(", "[", "]", "string", "{", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "etcdHost", ",", "etcdPort", ")", "}", ")", "\n", "ticker", ":=", "time", ".", "NewTicker", "(", "time", ".", "Duration", "(", "configInterval", ")", "*", "time", ".", "Second", ")", "\n", "configurer", ":=", "&", "Configurer", "{", "etcdClient", ":", "etcdClient", ",", "etcdPath", ":", "etcdPath", ",", "syslogishServer", ":", "syslogishServer", ",", "ticker", ":", "ticker", ",", "}", "\n\n", "// Support legacy behavior that allows default drain uri to be specified using a drain-uri flag", "if", "_", ",", "err", ":=", "etcdClient", ".", "Get", "(", "etcdPath", "+", "\"", "\"", ",", "false", ",", "false", ")", ";", "err", "!=", "nil", "{", "etcdErr", ",", "ok", ":=", "err", ".", "(", "*", "etcd", ".", "EtcdError", ")", "\n", "// Error code 100 is key not found", "if", "ok", "&&", "etcdErr", ".", "ErrorCode", "==", "100", "{", "configurer", ".", "setEtcd", "(", "\"", "\"", ",", "DefaultDrainURI", ")", "\n", "}", "else", "{", "log", ".", "Println", "(", "err", ")", "\n", "}", "\n", "}", "\n\n", "return", "configurer", ",", "nil", "\n", "}" ]
// NewConfigurer returns a pointer to a new Configurer instance.
[ "NewConfigurer", "returns", "a", "pointer", "to", "a", "new", "Configurer", "instance", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/configurer/configurer.go#L30-L53
142,928
deis/deis
logger/configurer/configurer.go
Start
func (c *Configurer) Start() { // Should only ever be called once if !c.running { c.running = true go c.configure() log.Println("configurer running") } }
go
func (c *Configurer) Start() { // Should only ever be called once if !c.running { c.running = true go c.configure() log.Println("configurer running") } }
[ "func", "(", "c", "*", "Configurer", ")", "Start", "(", ")", "{", "// Should only ever be called once", "if", "!", "c", ".", "running", "{", "c", ".", "running", "=", "true", "\n", "go", "c", ".", "configure", "(", ")", "\n", "log", ".", "Println", "(", "\"", "\"", ")", "\n", "}", "\n", "}" ]
// Start begins the configurer's main loop.
[ "Start", "begins", "the", "configurer", "s", "main", "loop", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/configurer/configurer.go#L56-L63
142,929
deis/deis
client/parser/domains.go
Domains
func Domains(argv []string) error { usage := ` Valid commands for domains: domains:add bind a domain to an application domains:list list domains bound to an application domains:remove unbind a domain from an application Use 'deis help [command]' to learn more. ` switch argv[0] { case "domains:add": return domainsAdd(argv) case "domains:list": return domainsList(argv) case "domains:remove": return domainsRemove(argv) default: if printHelp(argv, usage) { return nil } if argv[0] == "domains" { argv[0] = "domains:list" return domainsList(argv) } PrintUsage() return nil } }
go
func Domains(argv []string) error { usage := ` Valid commands for domains: domains:add bind a domain to an application domains:list list domains bound to an application domains:remove unbind a domain from an application Use 'deis help [command]' to learn more. ` switch argv[0] { case "domains:add": return domainsAdd(argv) case "domains:list": return domainsList(argv) case "domains:remove": return domainsRemove(argv) default: if printHelp(argv, usage) { return nil } if argv[0] == "domains" { argv[0] = "domains:list" return domainsList(argv) } PrintUsage() return nil } }
[ "func", "Domains", "(", "argv", "[", "]", "string", ")", "error", "{", "usage", ":=", "`\nValid commands for domains:\n\ndomains:add bind a domain to an application\ndomains:list list domains bound to an application\ndomains:remove unbind a domain from an application\n\nUse 'deis help [command]' to learn more.\n`", "\n", "switch", "argv", "[", "0", "]", "{", "case", "\"", "\"", ":", "return", "domainsAdd", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "return", "domainsList", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "return", "domainsRemove", "(", "argv", ")", "\n", "default", ":", "if", "printHelp", "(", "argv", ",", "usage", ")", "{", "return", "nil", "\n", "}", "\n\n", "if", "argv", "[", "0", "]", "==", "\"", "\"", "{", "argv", "[", "0", "]", "=", "\"", "\"", "\n", "return", "domainsList", "(", "argv", ")", "\n", "}", "\n\n", "PrintUsage", "(", ")", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// Domains routes domain commands to their specific function.
[ "Domains", "routes", "domain", "commands", "to", "their", "specific", "function", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/parser/domains.go#L9-L39
142,930
deis/deis
client/controller/client/client.go
New
func New() (*Client, error) { filename := locateSettingsFile() if _, err := os.Stat(filename); err != nil { if os.IsNotExist(err) { return nil, errors.New("Not logged in. Use 'deis login' or 'deis register' to get started.") } return nil, err } contents, err := ioutil.ReadFile(filename) if err != nil { return nil, err } settings := settingsFile{} if err = json.Unmarshal(contents, &settings); err != nil { return nil, err } u, err := url.Parse(settings.Controller) if err != nil { return nil, err } if settings.Limit <= 0 { settings.Limit = DefaultResponseLimit } return &Client{HTTPClient: CreateHTTPClient(settings.SslVerify), SSLVerify: settings.SslVerify, ControllerURL: *u, Token: settings.Token, Username: settings.Username, ResponseLimit: settings.Limit}, nil }
go
func New() (*Client, error) { filename := locateSettingsFile() if _, err := os.Stat(filename); err != nil { if os.IsNotExist(err) { return nil, errors.New("Not logged in. Use 'deis login' or 'deis register' to get started.") } return nil, err } contents, err := ioutil.ReadFile(filename) if err != nil { return nil, err } settings := settingsFile{} if err = json.Unmarshal(contents, &settings); err != nil { return nil, err } u, err := url.Parse(settings.Controller) if err != nil { return nil, err } if settings.Limit <= 0 { settings.Limit = DefaultResponseLimit } return &Client{HTTPClient: CreateHTTPClient(settings.SslVerify), SSLVerify: settings.SslVerify, ControllerURL: *u, Token: settings.Token, Username: settings.Username, ResponseLimit: settings.Limit}, nil }
[ "func", "New", "(", ")", "(", "*", "Client", ",", "error", ")", "{", "filename", ":=", "locateSettingsFile", "(", ")", "\n\n", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "filename", ")", ";", "err", "!=", "nil", "{", "if", "os", ".", "IsNotExist", "(", "err", ")", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "nil", ",", "err", "\n", "}", "\n\n", "contents", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "settings", ":=", "settingsFile", "{", "}", "\n", "if", "err", "=", "json", ".", "Unmarshal", "(", "contents", ",", "&", "settings", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "u", ",", "err", ":=", "url", ".", "Parse", "(", "settings", ".", "Controller", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "settings", ".", "Limit", "<=", "0", "{", "settings", ".", "Limit", "=", "DefaultResponseLimit", "\n", "}", "\n\n", "return", "&", "Client", "{", "HTTPClient", ":", "CreateHTTPClient", "(", "settings", ".", "SslVerify", ")", ",", "SSLVerify", ":", "settings", ".", "SslVerify", ",", "ControllerURL", ":", "*", "u", ",", "Token", ":", "settings", ".", "Token", ",", "Username", ":", "settings", ".", "Username", ",", "ResponseLimit", ":", "settings", ".", "Limit", "}", ",", "nil", "\n", "}" ]
// New creates a new client from a settings file.
[ "New", "creates", "a", "new", "client", "from", "a", "settings", "file", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/client/client.go#L47-L80
142,931
deis/deis
client/controller/client/client.go
Save
func (c Client) Save() error { settings := settingsFile{Username: c.Username, SslVerify: c.SSLVerify, Controller: c.ControllerURL.String(), Token: c.Token, Limit: c.ResponseLimit} if settings.Limit <= 0 { settings.Limit = DefaultResponseLimit } settingsContents, err := json.Marshal(settings) if err != nil { return err } if err = os.MkdirAll(path.Join(FindHome(), "/.deis/"), 0700); err != nil { return err } return ioutil.WriteFile(locateSettingsFile(), settingsContents, 0600) }
go
func (c Client) Save() error { settings := settingsFile{Username: c.Username, SslVerify: c.SSLVerify, Controller: c.ControllerURL.String(), Token: c.Token, Limit: c.ResponseLimit} if settings.Limit <= 0 { settings.Limit = DefaultResponseLimit } settingsContents, err := json.Marshal(settings) if err != nil { return err } if err = os.MkdirAll(path.Join(FindHome(), "/.deis/"), 0700); err != nil { return err } return ioutil.WriteFile(locateSettingsFile(), settingsContents, 0600) }
[ "func", "(", "c", "Client", ")", "Save", "(", ")", "error", "{", "settings", ":=", "settingsFile", "{", "Username", ":", "c", ".", "Username", ",", "SslVerify", ":", "c", ".", "SSLVerify", ",", "Controller", ":", "c", ".", "ControllerURL", ".", "String", "(", ")", ",", "Token", ":", "c", ".", "Token", ",", "Limit", ":", "c", ".", "ResponseLimit", "}", "\n\n", "if", "settings", ".", "Limit", "<=", "0", "{", "settings", ".", "Limit", "=", "DefaultResponseLimit", "\n", "}", "\n\n", "settingsContents", ",", "err", ":=", "json", ".", "Marshal", "(", "settings", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "err", "=", "os", ".", "MkdirAll", "(", "path", ".", "Join", "(", "FindHome", "(", ")", ",", "\"", "\"", ")", ",", "0700", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "ioutil", ".", "WriteFile", "(", "locateSettingsFile", "(", ")", ",", "settingsContents", ",", "0600", ")", "\n", "}" ]
// Save settings to a file
[ "Save", "settings", "to", "a", "file" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/client/client.go#L83-L102
142,932
deis/deis
client/controller/client/client.go
Delete
func Delete() error { filename := locateSettingsFile() if _, err := os.Stat(filename); err != nil { if os.IsNotExist(err) { return nil } return err } if err := os.Remove(filename); err != nil { return err } return nil }
go
func Delete() error { filename := locateSettingsFile() if _, err := os.Stat(filename); err != nil { if os.IsNotExist(err) { return nil } return err } if err := os.Remove(filename); err != nil { return err } return nil }
[ "func", "Delete", "(", ")", "error", "{", "filename", ":=", "locateSettingsFile", "(", ")", "\n\n", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "filename", ")", ";", "err", "!=", "nil", "{", "if", "os", ".", "IsNotExist", "(", "err", ")", "{", "return", "nil", "\n", "}", "\n\n", "return", "err", "\n", "}", "\n\n", "if", "err", ":=", "os", ".", "Remove", "(", "filename", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Delete user's settings file.
[ "Delete", "user", "s", "settings", "file", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/client/client.go#L105-L121
142,933
deis/deis
client/controller/models/certs/certs.go
New
func New(c *client.Client, cert string, key string, commonName string) (api.Cert, error) { req := api.CertCreateRequest{Certificate: cert, Key: key, Name: commonName} reqBody, err := json.Marshal(req) if err != nil { return api.Cert{}, err } resBody, err := c.BasicRequest("POST", "/v1/certs/", reqBody) if err != nil { return api.Cert{}, err } resCert := api.Cert{} if err = json.Unmarshal([]byte(resBody), &resCert); err != nil { return api.Cert{}, err } return resCert, nil }
go
func New(c *client.Client, cert string, key string, commonName string) (api.Cert, error) { req := api.CertCreateRequest{Certificate: cert, Key: key, Name: commonName} reqBody, err := json.Marshal(req) if err != nil { return api.Cert{}, err } resBody, err := c.BasicRequest("POST", "/v1/certs/", reqBody) if err != nil { return api.Cert{}, err } resCert := api.Cert{} if err = json.Unmarshal([]byte(resBody), &resCert); err != nil { return api.Cert{}, err } return resCert, nil }
[ "func", "New", "(", "c", "*", "client", ".", "Client", ",", "cert", "string", ",", "key", "string", ",", "commonName", "string", ")", "(", "api", ".", "Cert", ",", "error", ")", "{", "req", ":=", "api", ".", "CertCreateRequest", "{", "Certificate", ":", "cert", ",", "Key", ":", "key", ",", "Name", ":", "commonName", "}", "\n", "reqBody", ",", "err", ":=", "json", ".", "Marshal", "(", "req", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "api", ".", "Cert", "{", "}", ",", "err", "\n", "}", "\n\n", "resBody", ",", "err", ":=", "c", ".", "BasicRequest", "(", "\"", "\"", ",", "\"", "\"", ",", "reqBody", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "api", ".", "Cert", "{", "}", ",", "err", "\n", "}", "\n\n", "resCert", ":=", "api", ".", "Cert", "{", "}", "\n", "if", "err", "=", "json", ".", "Unmarshal", "(", "[", "]", "byte", "(", "resBody", ")", ",", "&", "resCert", ")", ";", "err", "!=", "nil", "{", "return", "api", ".", "Cert", "{", "}", ",", "err", "\n", "}", "\n\n", "return", "resCert", ",", "nil", "\n", "}" ]
// New creates a new cert.
[ "New", "creates", "a", "new", "cert", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/certs/certs.go#L28-L48
142,934
deis/deis
client/controller/models/certs/certs.go
Delete
func Delete(c *client.Client, commonName string) error { u := fmt.Sprintf("/v1/certs/%s", commonName) _, err := c.BasicRequest("DELETE", u, nil) return err }
go
func Delete(c *client.Client, commonName string) error { u := fmt.Sprintf("/v1/certs/%s", commonName) _, err := c.BasicRequest("DELETE", u, nil) return err }
[ "func", "Delete", "(", "c", "*", "client", ".", "Client", ",", "commonName", "string", ")", "error", "{", "u", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "commonName", ")", "\n\n", "_", ",", "err", ":=", "c", ".", "BasicRequest", "(", "\"", "\"", ",", "u", ",", "nil", ")", "\n", "return", "err", "\n", "}" ]
// Delete removes a cert.
[ "Delete", "removes", "a", "cert", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/certs/certs.go#L51-L56
142,935
deis/deis
client/cmd/domains.go
DomainsList
func DomainsList(appID string, results int) error { c, appID, err := load(appID) if err != nil { return err } if results == defaultLimit { results = c.ResponseLimit } domains, count, err := domains.List(c, appID, results) if err != nil { return err } fmt.Printf("=== %s Domains%s", appID, limitCount(len(domains), count)) sort.Sort(domains) for _, domain := range domains { fmt.Println(domain.Domain) } return nil }
go
func DomainsList(appID string, results int) error { c, appID, err := load(appID) if err != nil { return err } if results == defaultLimit { results = c.ResponseLimit } domains, count, err := domains.List(c, appID, results) if err != nil { return err } fmt.Printf("=== %s Domains%s", appID, limitCount(len(domains), count)) sort.Sort(domains) for _, domain := range domains { fmt.Println(domain.Domain) } return nil }
[ "func", "DomainsList", "(", "appID", "string", ",", "results", "int", ")", "error", "{", "c", ",", "appID", ",", "err", ":=", "load", "(", "appID", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "results", "==", "defaultLimit", "{", "results", "=", "c", ".", "ResponseLimit", "\n", "}", "\n\n", "domains", ",", "count", ",", "err", ":=", "domains", ".", "List", "(", "c", ",", "appID", ",", "results", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Printf", "(", "\"", "\"", ",", "appID", ",", "limitCount", "(", "len", "(", "domains", ")", ",", "count", ")", ")", "\n\n", "sort", ".", "Sort", "(", "domains", ")", "\n\n", "for", "_", ",", "domain", ":=", "range", "domains", "{", "fmt", ".", "Println", "(", "domain", ".", "Domain", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// DomainsList lists domains registered with an app.
[ "DomainsList", "lists", "domains", "registered", "with", "an", "app", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/domains.go#L11-L36
142,936
deis/deis
client/cmd/domains.go
DomainsAdd
func DomainsAdd(appID, domain string) error { c, appID, err := load(appID) if err != nil { return err } fmt.Printf("Adding %s to %s... ", domain, appID) quit := progress() _, err = domains.New(c, appID, domain) quit <- true <-quit if err != nil { return err } fmt.Println("done") return nil }
go
func DomainsAdd(appID, domain string) error { c, appID, err := load(appID) if err != nil { return err } fmt.Printf("Adding %s to %s... ", domain, appID) quit := progress() _, err = domains.New(c, appID, domain) quit <- true <-quit if err != nil { return err } fmt.Println("done") return nil }
[ "func", "DomainsAdd", "(", "appID", ",", "domain", "string", ")", "error", "{", "c", ",", "appID", ",", "err", ":=", "load", "(", "appID", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Printf", "(", "\"", "\"", ",", "domain", ",", "appID", ")", "\n\n", "quit", ":=", "progress", "(", ")", "\n", "_", ",", "err", "=", "domains", ".", "New", "(", "c", ",", "appID", ",", "domain", ")", "\n", "quit", "<-", "true", "\n", "<-", "quit", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n", "return", "nil", "\n", "}" ]
// DomainsAdd adds a domain to an app.
[ "DomainsAdd", "adds", "a", "domain", "to", "an", "app", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/domains.go#L39-L59
142,937
deis/deis
client/cmd/domains.go
DomainsRemove
func DomainsRemove(appID, domain string) error { c, appID, err := load(appID) if err != nil { return err } fmt.Printf("Removing %s from %s... ", domain, appID) quit := progress() err = domains.Delete(c, appID, domain) quit <- true <-quit if err != nil { return err } fmt.Println("done") return nil }
go
func DomainsRemove(appID, domain string) error { c, appID, err := load(appID) if err != nil { return err } fmt.Printf("Removing %s from %s... ", domain, appID) quit := progress() err = domains.Delete(c, appID, domain) quit <- true <-quit if err != nil { return err } fmt.Println("done") return nil }
[ "func", "DomainsRemove", "(", "appID", ",", "domain", "string", ")", "error", "{", "c", ",", "appID", ",", "err", ":=", "load", "(", "appID", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Printf", "(", "\"", "\"", ",", "domain", ",", "appID", ")", "\n\n", "quit", ":=", "progress", "(", ")", "\n", "err", "=", "domains", ".", "Delete", "(", "c", ",", "appID", ",", "domain", ")", "\n", "quit", "<-", "true", "\n", "<-", "quit", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n", "return", "nil", "\n", "}" ]
// DomainsRemove removes a domain registered with an app.
[ "DomainsRemove", "removes", "a", "domain", "registered", "with", "an", "app", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/domains.go#L62-L82
142,938
deis/deis
client/parser/auth.go
Auth
func Auth(argv []string) error { usage := ` Valid commands for auth: auth:register register a new user auth:login authenticate against a controller auth:logout clear the current user session auth:passwd change the password for the current user auth:whoami display the current user auth:cancel remove the current user account auth:regenerate regenerate user tokens Use 'deis help [command]' to learn more. ` switch argv[0] { case "auth:register": return authRegister(argv) case "auth:login": return authLogin(argv) case "auth:logout": return authLogout(argv) case "auth:passwd": return authPasswd(argv) case "auth:whoami": return authWhoami(argv) case "auth:cancel": return authCancel(argv) case "auth:regenerate": return authRegenerate(argv) case "auth": fmt.Print(usage) return nil default: PrintUsage() return nil } }
go
func Auth(argv []string) error { usage := ` Valid commands for auth: auth:register register a new user auth:login authenticate against a controller auth:logout clear the current user session auth:passwd change the password for the current user auth:whoami display the current user auth:cancel remove the current user account auth:regenerate regenerate user tokens Use 'deis help [command]' to learn more. ` switch argv[0] { case "auth:register": return authRegister(argv) case "auth:login": return authLogin(argv) case "auth:logout": return authLogout(argv) case "auth:passwd": return authPasswd(argv) case "auth:whoami": return authWhoami(argv) case "auth:cancel": return authCancel(argv) case "auth:regenerate": return authRegenerate(argv) case "auth": fmt.Print(usage) return nil default: PrintUsage() return nil } }
[ "func", "Auth", "(", "argv", "[", "]", "string", ")", "error", "{", "usage", ":=", "`\nValid commands for auth:\n\nauth:register register a new user\nauth:login authenticate against a controller\nauth:logout clear the current user session\nauth:passwd change the password for the current user\nauth:whoami display the current user\nauth:cancel remove the current user account\nauth:regenerate regenerate user tokens\n\nUse 'deis help [command]' to learn more.\n`", "\n\n", "switch", "argv", "[", "0", "]", "{", "case", "\"", "\"", ":", "return", "authRegister", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "return", "authLogin", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "return", "authLogout", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "return", "authPasswd", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "return", "authWhoami", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "return", "authCancel", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "return", "authRegenerate", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "fmt", ".", "Print", "(", "usage", ")", "\n", "return", "nil", "\n", "default", ":", "PrintUsage", "(", ")", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// Auth routes auth commands to the specific function.
[ "Auth", "routes", "auth", "commands", "to", "the", "specific", "function", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/parser/auth.go#L11-L48
142,939
deis/deis
client/controller/models/builds/builds.go
New
func New(c *client.Client, appID string, image string, procfile map[string]string) (api.Build, error) { u := fmt.Sprintf("/v1/apps/%s/builds/", appID) req := api.CreateBuildRequest{Image: image, Procfile: procfile} body, err := json.Marshal(req) if err != nil { return api.Build{}, err } resBody, err := c.BasicRequest("POST", u, body) if err != nil { return api.Build{}, err } build := api.Build{} if err = json.Unmarshal([]byte(resBody), &build); err != nil { return api.Build{}, err } return build, nil }
go
func New(c *client.Client, appID string, image string, procfile map[string]string) (api.Build, error) { u := fmt.Sprintf("/v1/apps/%s/builds/", appID) req := api.CreateBuildRequest{Image: image, Procfile: procfile} body, err := json.Marshal(req) if err != nil { return api.Build{}, err } resBody, err := c.BasicRequest("POST", u, body) if err != nil { return api.Build{}, err } build := api.Build{} if err = json.Unmarshal([]byte(resBody), &build); err != nil { return api.Build{}, err } return build, nil }
[ "func", "New", "(", "c", "*", "client", ".", "Client", ",", "appID", "string", ",", "image", "string", ",", "procfile", "map", "[", "string", "]", "string", ")", "(", "api", ".", "Build", ",", "error", ")", "{", "u", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "appID", ")", "\n\n", "req", ":=", "api", ".", "CreateBuildRequest", "{", "Image", ":", "image", ",", "Procfile", ":", "procfile", "}", "\n\n", "body", ",", "err", ":=", "json", ".", "Marshal", "(", "req", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "api", ".", "Build", "{", "}", ",", "err", "\n", "}", "\n\n", "resBody", ",", "err", ":=", "c", ".", "BasicRequest", "(", "\"", "\"", ",", "u", ",", "body", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "api", ".", "Build", "{", "}", ",", "err", "\n", "}", "\n\n", "build", ":=", "api", ".", "Build", "{", "}", "\n", "if", "err", "=", "json", ".", "Unmarshal", "(", "[", "]", "byte", "(", "resBody", ")", ",", "&", "build", ")", ";", "err", "!=", "nil", "{", "return", "api", ".", "Build", "{", "}", ",", "err", "\n", "}", "\n\n", "return", "build", ",", "nil", "\n", "}" ]
// New creates a build for an app.
[ "New", "creates", "a", "build", "for", "an", "app", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/builds/builds.go#L29-L54
142,940
deis/deis
builder/utils.go
YamlToJSON
func YamlToJSON(bytes []byte) (string, error) { var anomaly map[string]string if err := yaml.Unmarshal(bytes, &anomaly); err != nil { return "", err } retVal, err := json.Marshal(&anomaly) if err != nil { return "", err } return string(retVal), nil }
go
func YamlToJSON(bytes []byte) (string, error) { var anomaly map[string]string if err := yaml.Unmarshal(bytes, &anomaly); err != nil { return "", err } retVal, err := json.Marshal(&anomaly) if err != nil { return "", err } return string(retVal), nil }
[ "func", "YamlToJSON", "(", "bytes", "[", "]", "byte", ")", "(", "string", ",", "error", ")", "{", "var", "anomaly", "map", "[", "string", "]", "string", "\n\n", "if", "err", ":=", "yaml", ".", "Unmarshal", "(", "bytes", ",", "&", "anomaly", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "retVal", ",", "err", ":=", "json", ".", "Marshal", "(", "&", "anomaly", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "return", "string", "(", "retVal", ")", ",", "nil", "\n", "}" ]
// YamlToJSON takes an input yaml string, parses it and returns a string formatted as json.
[ "YamlToJSON", "takes", "an", "input", "yaml", "string", "parses", "it", "and", "returns", "a", "string", "formatted", "as", "json", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/utils.go#L11-L25
142,941
deis/deis
builder/utils.go
ParseConfig
func ParseConfig(body []byte) (*Config, error) { var config Config err := json.Unmarshal(body, &config) return &config, err }
go
func ParseConfig(body []byte) (*Config, error) { var config Config err := json.Unmarshal(body, &config) return &config, err }
[ "func", "ParseConfig", "(", "body", "[", "]", "byte", ")", "(", "*", "Config", ",", "error", ")", "{", "var", "config", "Config", "\n", "err", ":=", "json", ".", "Unmarshal", "(", "body", ",", "&", "config", ")", "\n", "return", "&", "config", ",", "err", "\n", "}" ]
// ParseConfig takes a response body from the controller and returns a Config object.
[ "ParseConfig", "takes", "a", "response", "body", "from", "the", "controller", "and", "returns", "a", "Config", "object", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/utils.go#L28-L32
142,942
deis/deis
builder/utils.go
ParseDomain
func ParseDomain(bytes []byte) (string, error) { var hook BuildHookResponse if err := json.Unmarshal(bytes, &hook); err != nil { return "", err } if hook.Domains == nil { return "", fmt.Errorf("invalid application domain") } if len(hook.Domains) < 1 { return "", fmt.Errorf("invalid application domain") } return hook.Domains[0], nil }
go
func ParseDomain(bytes []byte) (string, error) { var hook BuildHookResponse if err := json.Unmarshal(bytes, &hook); err != nil { return "", err } if hook.Domains == nil { return "", fmt.Errorf("invalid application domain") } if len(hook.Domains) < 1 { return "", fmt.Errorf("invalid application domain") } return hook.Domains[0], nil }
[ "func", "ParseDomain", "(", "bytes", "[", "]", "byte", ")", "(", "string", ",", "error", ")", "{", "var", "hook", "BuildHookResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "bytes", ",", "&", "hook", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "if", "hook", ".", "Domains", "==", "nil", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "len", "(", "hook", ".", "Domains", ")", "<", "1", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "hook", ".", "Domains", "[", "0", "]", ",", "nil", "\n", "}" ]
// ParseDomain returns the domain field from the bytes of a build hook response.
[ "ParseDomain", "returns", "the", "domain", "field", "from", "the", "bytes", "of", "a", "build", "hook", "response", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/utils.go#L35-L50
142,943
deis/deis
builder/utils.go
ParseReleaseVersion
func ParseReleaseVersion(bytes []byte) (int, error) { var hook BuildHookResponse if err := json.Unmarshal(bytes, &hook); err != nil { return 0, fmt.Errorf("invalid application json configuration") } if hook.Release == nil { return 0, fmt.Errorf("invalid application version") } return hook.Release["version"], nil }
go
func ParseReleaseVersion(bytes []byte) (int, error) { var hook BuildHookResponse if err := json.Unmarshal(bytes, &hook); err != nil { return 0, fmt.Errorf("invalid application json configuration") } if hook.Release == nil { return 0, fmt.Errorf("invalid application version") } return hook.Release["version"], nil }
[ "func", "ParseReleaseVersion", "(", "bytes", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "var", "hook", "BuildHookResponse", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "bytes", ",", "&", "hook", ")", ";", "err", "!=", "nil", "{", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "hook", ".", "Release", "==", "nil", "{", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "hook", ".", "Release", "[", "\"", "\"", "]", ",", "nil", "\n", "}" ]
// ParseReleaseVersion returns the version field from the bytes of a build hook response.
[ "ParseReleaseVersion", "returns", "the", "version", "field", "from", "the", "bytes", "of", "a", "build", "hook", "response", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/utils.go#L53-L64
142,944
deis/deis
builder/utils.go
GetDefaultType
func GetDefaultType(bytes []byte) (string, error) { type YamlTypeMap struct { DefaultProcessTypes ProcessType `yaml:"default_process_types"` } var p YamlTypeMap if err := yaml.Unmarshal(bytes, &p); err != nil { return "", err } retVal, err := json.Marshal(&p.DefaultProcessTypes) if err != nil { return "", err } if len(p.DefaultProcessTypes) == 0 { return "{}", nil } return string(retVal), nil }
go
func GetDefaultType(bytes []byte) (string, error) { type YamlTypeMap struct { DefaultProcessTypes ProcessType `yaml:"default_process_types"` } var p YamlTypeMap if err := yaml.Unmarshal(bytes, &p); err != nil { return "", err } retVal, err := json.Marshal(&p.DefaultProcessTypes) if err != nil { return "", err } if len(p.DefaultProcessTypes) == 0 { return "{}", nil } return string(retVal), nil }
[ "func", "GetDefaultType", "(", "bytes", "[", "]", "byte", ")", "(", "string", ",", "error", ")", "{", "type", "YamlTypeMap", "struct", "{", "DefaultProcessTypes", "ProcessType", "`yaml:\"default_process_types\"`", "\n", "}", "\n\n", "var", "p", "YamlTypeMap", "\n\n", "if", "err", ":=", "yaml", ".", "Unmarshal", "(", "bytes", ",", "&", "p", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "retVal", ",", "err", ":=", "json", ".", "Marshal", "(", "&", "p", ".", "DefaultProcessTypes", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "if", "len", "(", "p", ".", "DefaultProcessTypes", ")", "==", "0", "{", "return", "\"", "\"", ",", "nil", "\n", "}", "\n\n", "return", "string", "(", "retVal", ")", ",", "nil", "\n", "}" ]
// GetDefaultType returns the default process types given a YAML byte array.
[ "GetDefaultType", "returns", "the", "default", "process", "types", "given", "a", "YAML", "byte", "array", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/utils.go#L67-L89
142,945
deis/deis
client/parser/git.go
Git
func Git(argv []string) error { usage := ` Valid commands for git: git:remote Adds git remote of application to repository Use 'deis help [command]' to learn more. ` switch argv[0] { case "git:remote": return gitRemote(argv) case "git": fmt.Print(usage) return nil default: PrintUsage() return nil } }
go
func Git(argv []string) error { usage := ` Valid commands for git: git:remote Adds git remote of application to repository Use 'deis help [command]' to learn more. ` switch argv[0] { case "git:remote": return gitRemote(argv) case "git": fmt.Print(usage) return nil default: PrintUsage() return nil } }
[ "func", "Git", "(", "argv", "[", "]", "string", ")", "error", "{", "usage", ":=", "`\nValid commands for git:\n\ngit:remote Adds git remote of application to repository\n\nUse 'deis help [command]' to learn more.\n`", "\n\n", "switch", "argv", "[", "0", "]", "{", "case", "\"", "\"", ":", "return", "gitRemote", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "fmt", ".", "Print", "(", "usage", ")", "\n", "return", "nil", "\n", "default", ":", "PrintUsage", "(", ")", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// Git routes git commands to their specific function.
[ "Git", "routes", "git", "commands", "to", "their", "specific", "function", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/parser/git.go#L11-L30
142,946
deis/deis
builder/sshd/sshd.go
compareKeys
func compareKeys(a, b ssh.PublicKey) bool { if a.Type() != b.Type() { return false } // The best way to compare just the key seems to be to marshal both and // then compare the output byte sequence. return subtle.ConstantTimeCompare(a.Marshal(), b.Marshal()) == 1 }
go
func compareKeys(a, b ssh.PublicKey) bool { if a.Type() != b.Type() { return false } // The best way to compare just the key seems to be to marshal both and // then compare the output byte sequence. return subtle.ConstantTimeCompare(a.Marshal(), b.Marshal()) == 1 }
[ "func", "compareKeys", "(", "a", ",", "b", "ssh", ".", "PublicKey", ")", "bool", "{", "if", "a", ".", "Type", "(", ")", "!=", "b", ".", "Type", "(", ")", "{", "return", "false", "\n", "}", "\n", "// The best way to compare just the key seems to be to marshal both and", "// then compare the output byte sequence.", "return", "subtle", ".", "ConstantTimeCompare", "(", "a", ".", "Marshal", "(", ")", ",", "b", ".", "Marshal", "(", ")", ")", "==", "1", "\n", "}" ]
// compareKeys compares to key files and returns true of they match.
[ "compareKeys", "compares", "to", "key", "files", "and", "returns", "true", "of", "they", "match", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/sshd/sshd.go#L145-L152
142,947
deis/deis
builder/sshd/sshd.go
Fingerprint
func Fingerprint(key ssh.PublicKey) string { hash := md5.Sum(key.Marshal()) buf := make([]byte, hex.EncodedLen(len(hash))) hex.Encode(buf, hash[:]) // We need this in colon notation: fp := make([]byte, len(buf)+15) i, j := 0, 0 for ; i < len(buf); i++ { if i > 0 && i%2 == 0 { fp[j] = ':' j++ } fp[j] = buf[i] j++ } return string(fp) }
go
func Fingerprint(key ssh.PublicKey) string { hash := md5.Sum(key.Marshal()) buf := make([]byte, hex.EncodedLen(len(hash))) hex.Encode(buf, hash[:]) // We need this in colon notation: fp := make([]byte, len(buf)+15) i, j := 0, 0 for ; i < len(buf); i++ { if i > 0 && i%2 == 0 { fp[j] = ':' j++ } fp[j] = buf[i] j++ } return string(fp) }
[ "func", "Fingerprint", "(", "key", "ssh", ".", "PublicKey", ")", "string", "{", "hash", ":=", "md5", ".", "Sum", "(", "key", ".", "Marshal", "(", ")", ")", "\n", "buf", ":=", "make", "(", "[", "]", "byte", ",", "hex", ".", "EncodedLen", "(", "len", "(", "hash", ")", ")", ")", "\n", "hex", ".", "Encode", "(", "buf", ",", "hash", "[", ":", "]", ")", "\n", "// We need this in colon notation:", "fp", ":=", "make", "(", "[", "]", "byte", ",", "len", "(", "buf", ")", "+", "15", ")", "\n\n", "i", ",", "j", ":=", "0", ",", "0", "\n", "for", ";", "i", "<", "len", "(", "buf", ")", ";", "i", "++", "{", "if", "i", ">", "0", "&&", "i", "%", "2", "==", "0", "{", "fp", "[", "j", "]", "=", "':'", "\n", "j", "++", "\n", "}", "\n", "fp", "[", "j", "]", "=", "buf", "[", "i", "]", "\n", "j", "++", "\n", "}", "\n\n", "return", "string", "(", "fp", ")", "\n", "}" ]
// Fingerprint generates a colon-separated fingerprint string from a public key.
[ "Fingerprint", "generates", "a", "colon", "-", "separated", "fingerprint", "string", "from", "a", "public", "key", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/sshd/sshd.go#L210-L228
142,948
deis/deis
client/cmd/config.go
ConfigList
func ConfigList(appID string, oneLine bool) error { c, appID, err := load(appID) if err != nil { return err } config, err := config.List(c, appID) if err != nil { return err } var keys []string for k := range config.Values { keys = append(keys, k) } sort.Strings(keys) if oneLine { for _, key := range keys { fmt.Printf("%s=%s ", key, config.Values[key]) } fmt.Println() } else { fmt.Printf("=== %s Config\n", appID) configMap := make(map[string]string) // config.Values is type interface, so it needs to be converted to a string for _, key := range keys { configMap[key] = fmt.Sprintf("%v", config.Values[key]) } fmt.Print(prettyprint.PrettyTabs(configMap, 6)) } return nil }
go
func ConfigList(appID string, oneLine bool) error { c, appID, err := load(appID) if err != nil { return err } config, err := config.List(c, appID) if err != nil { return err } var keys []string for k := range config.Values { keys = append(keys, k) } sort.Strings(keys) if oneLine { for _, key := range keys { fmt.Printf("%s=%s ", key, config.Values[key]) } fmt.Println() } else { fmt.Printf("=== %s Config\n", appID) configMap := make(map[string]string) // config.Values is type interface, so it needs to be converted to a string for _, key := range keys { configMap[key] = fmt.Sprintf("%v", config.Values[key]) } fmt.Print(prettyprint.PrettyTabs(configMap, 6)) } return nil }
[ "func", "ConfigList", "(", "appID", "string", ",", "oneLine", "bool", ")", "error", "{", "c", ",", "appID", ",", "err", ":=", "load", "(", "appID", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "config", ",", "err", ":=", "config", ".", "List", "(", "c", ",", "appID", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "var", "keys", "[", "]", "string", "\n", "for", "k", ":=", "range", "config", ".", "Values", "{", "keys", "=", "append", "(", "keys", ",", "k", ")", "\n", "}", "\n", "sort", ".", "Strings", "(", "keys", ")", "\n\n", "if", "oneLine", "{", "for", "_", ",", "key", ":=", "range", "keys", "{", "fmt", ".", "Printf", "(", "\"", "\"", ",", "key", ",", "config", ".", "Values", "[", "key", "]", ")", "\n", "}", "\n", "fmt", ".", "Println", "(", ")", "\n", "}", "else", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "appID", ")", "\n\n", "configMap", ":=", "make", "(", "map", "[", "string", "]", "string", ")", "\n\n", "// config.Values is type interface, so it needs to be converted to a string", "for", "_", ",", "key", ":=", "range", "keys", "{", "configMap", "[", "key", "]", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "config", ".", "Values", "[", "key", "]", ")", "\n", "}", "\n\n", "fmt", ".", "Print", "(", "prettyprint", ".", "PrettyTabs", "(", "configMap", ",", "6", ")", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// ConfigList lists an app's config.
[ "ConfigList", "lists", "an", "app", "s", "config", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/config.go#L19-L57
142,949
deis/deis
client/cmd/config.go
ConfigSet
func ConfigSet(appID string, configVars []string) error { c, appID, err := load(appID) if err != nil { return err } configMap := parseConfig(configVars) value, ok := configMap["SSH_KEY"] if ok { sshKey := value.(string) if _, err := os.Stat(value.(string)); err == nil { contents, err := ioutil.ReadFile(value.(string)) if err != nil { return err } sshKey = string(contents) } sshRegex := regexp.MustCompile("^-.+ .SA PRIVATE KEY-*") if !sshRegex.MatchString(sshKey) { return fmt.Errorf("Could not parse SSH private key:\n %s", sshKey) } configMap["SSH_KEY"] = base64.StdEncoding.EncodeToString([]byte(sshKey)) } fmt.Print("Creating config... ") quit := progress() configObj := api.Config{Values: configMap} configObj, err = config.Set(c, appID, configObj) quit <- true <-quit if err != nil { return err } if release, ok := configObj.Values["DEIS_RELEASE"]; ok { fmt.Printf("done, %s\n\n", release) } else { fmt.Print("done\n\n") } return ConfigList(appID, false) }
go
func ConfigSet(appID string, configVars []string) error { c, appID, err := load(appID) if err != nil { return err } configMap := parseConfig(configVars) value, ok := configMap["SSH_KEY"] if ok { sshKey := value.(string) if _, err := os.Stat(value.(string)); err == nil { contents, err := ioutil.ReadFile(value.(string)) if err != nil { return err } sshKey = string(contents) } sshRegex := regexp.MustCompile("^-.+ .SA PRIVATE KEY-*") if !sshRegex.MatchString(sshKey) { return fmt.Errorf("Could not parse SSH private key:\n %s", sshKey) } configMap["SSH_KEY"] = base64.StdEncoding.EncodeToString([]byte(sshKey)) } fmt.Print("Creating config... ") quit := progress() configObj := api.Config{Values: configMap} configObj, err = config.Set(c, appID, configObj) quit <- true <-quit if err != nil { return err } if release, ok := configObj.Values["DEIS_RELEASE"]; ok { fmt.Printf("done, %s\n\n", release) } else { fmt.Print("done\n\n") } return ConfigList(appID, false) }
[ "func", "ConfigSet", "(", "appID", "string", ",", "configVars", "[", "]", "string", ")", "error", "{", "c", ",", "appID", ",", "err", ":=", "load", "(", "appID", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "configMap", ":=", "parseConfig", "(", "configVars", ")", "\n\n", "value", ",", "ok", ":=", "configMap", "[", "\"", "\"", "]", "\n\n", "if", "ok", "{", "sshKey", ":=", "value", ".", "(", "string", ")", "\n\n", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "value", ".", "(", "string", ")", ")", ";", "err", "==", "nil", "{", "contents", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "value", ".", "(", "string", ")", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "sshKey", "=", "string", "(", "contents", ")", "\n", "}", "\n\n", "sshRegex", ":=", "regexp", ".", "MustCompile", "(", "\"", "\"", ")", "\n\n", "if", "!", "sshRegex", ".", "MatchString", "(", "sshKey", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\\n", "\"", ",", "sshKey", ")", "\n", "}", "\n\n", "configMap", "[", "\"", "\"", "]", "=", "base64", ".", "StdEncoding", ".", "EncodeToString", "(", "[", "]", "byte", "(", "sshKey", ")", ")", "\n", "}", "\n\n", "fmt", ".", "Print", "(", "\"", "\"", ")", "\n\n", "quit", ":=", "progress", "(", ")", "\n", "configObj", ":=", "api", ".", "Config", "{", "Values", ":", "configMap", "}", "\n", "configObj", ",", "err", "=", "config", ".", "Set", "(", "c", ",", "appID", ",", "configObj", ")", "\n\n", "quit", "<-", "true", "\n", "<-", "quit", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "release", ",", "ok", ":=", "configObj", ".", "Values", "[", "\"", "\"", "]", ";", "ok", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\\n", "\"", ",", "release", ")", "\n", "}", "else", "{", "fmt", ".", "Print", "(", "\"", "\\n", "\\n", "\"", ")", "\n", "}", "\n\n", "return", "ConfigList", "(", "appID", ",", "false", ")", "\n", "}" ]
// ConfigSet sets an app's config variables.
[ "ConfigSet", "sets", "an", "app", "s", "config", "variables", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/config.go#L60-L113
142,950
deis/deis
client/cmd/config.go
ConfigUnset
func ConfigUnset(appID string, configVars []string) error { c, appID, err := load(appID) if err != nil { return err } fmt.Print("Removing config... ") quit := progress() configObj := api.Config{} valuesMap := make(map[string]interface{}) for _, configVar := range configVars { valuesMap[configVar] = nil } configObj.Values = valuesMap _, err = config.Set(c, appID, configObj) quit <- true <-quit if err != nil { return err } fmt.Print("done\n\n") return ConfigList(appID, false) }
go
func ConfigUnset(appID string, configVars []string) error { c, appID, err := load(appID) if err != nil { return err } fmt.Print("Removing config... ") quit := progress() configObj := api.Config{} valuesMap := make(map[string]interface{}) for _, configVar := range configVars { valuesMap[configVar] = nil } configObj.Values = valuesMap _, err = config.Set(c, appID, configObj) quit <- true <-quit if err != nil { return err } fmt.Print("done\n\n") return ConfigList(appID, false) }
[ "func", "ConfigUnset", "(", "appID", "string", ",", "configVars", "[", "]", "string", ")", "error", "{", "c", ",", "appID", ",", "err", ":=", "load", "(", "appID", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Print", "(", "\"", "\"", ")", "\n\n", "quit", ":=", "progress", "(", ")", "\n\n", "configObj", ":=", "api", ".", "Config", "{", "}", "\n\n", "valuesMap", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n\n", "for", "_", ",", "configVar", ":=", "range", "configVars", "{", "valuesMap", "[", "configVar", "]", "=", "nil", "\n", "}", "\n\n", "configObj", ".", "Values", "=", "valuesMap", "\n\n", "_", ",", "err", "=", "config", ".", "Set", "(", "c", ",", "appID", ",", "configObj", ")", "\n\n", "quit", "<-", "true", "\n", "<-", "quit", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Print", "(", "\"", "\\n", "\\n", "\"", ")", "\n\n", "return", "ConfigList", "(", "appID", ",", "false", ")", "\n", "}" ]
// ConfigUnset removes a config variable from an app.
[ "ConfigUnset", "removes", "a", "config", "variable", "from", "an", "app", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/config.go#L116-L149
142,951
deis/deis
client/cmd/config.go
ConfigPull
func ConfigPull(appID string, interactive bool, overwrite bool) error { filename := ".env" if !overwrite { if _, err := os.Stat(filename); err == nil { return fmt.Errorf("%s already exists, pass -o to overwrite", filename) } } c, appID, err := load(appID) if err != nil { return err } configVars, err := config.List(c, appID) if interactive { contents, err := ioutil.ReadFile(filename) if err != nil { return err } localConfigVars := strings.Split(string(contents), "\n") configMap := parseConfig(localConfigVars[:len(localConfigVars)-1]) for key, value := range configVars.Values { localValue, ok := configMap[key] if ok { if value != localValue { var confirm string fmt.Printf("%s: overwrite %s with %s? (y/N) ", key, localValue, value) fmt.Scanln(&confirm) if strings.ToLower(confirm) == "y" { configMap[key] = value } } } else { configMap[key] = value } } return ioutil.WriteFile(filename, []byte(formatConfig(configMap)), 0755) } return ioutil.WriteFile(filename, []byte(formatConfig(configVars.Values)), 0755) }
go
func ConfigPull(appID string, interactive bool, overwrite bool) error { filename := ".env" if !overwrite { if _, err := os.Stat(filename); err == nil { return fmt.Errorf("%s already exists, pass -o to overwrite", filename) } } c, appID, err := load(appID) if err != nil { return err } configVars, err := config.List(c, appID) if interactive { contents, err := ioutil.ReadFile(filename) if err != nil { return err } localConfigVars := strings.Split(string(contents), "\n") configMap := parseConfig(localConfigVars[:len(localConfigVars)-1]) for key, value := range configVars.Values { localValue, ok := configMap[key] if ok { if value != localValue { var confirm string fmt.Printf("%s: overwrite %s with %s? (y/N) ", key, localValue, value) fmt.Scanln(&confirm) if strings.ToLower(confirm) == "y" { configMap[key] = value } } } else { configMap[key] = value } } return ioutil.WriteFile(filename, []byte(formatConfig(configMap)), 0755) } return ioutil.WriteFile(filename, []byte(formatConfig(configVars.Values)), 0755) }
[ "func", "ConfigPull", "(", "appID", "string", ",", "interactive", "bool", ",", "overwrite", "bool", ")", "error", "{", "filename", ":=", "\"", "\"", "\n\n", "if", "!", "overwrite", "{", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "filename", ")", ";", "err", "==", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "filename", ")", "\n", "}", "\n", "}", "\n\n", "c", ",", "appID", ",", "err", ":=", "load", "(", "appID", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "configVars", ",", "err", ":=", "config", ".", "List", "(", "c", ",", "appID", ")", "\n\n", "if", "interactive", "{", "contents", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "filename", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "localConfigVars", ":=", "strings", ".", "Split", "(", "string", "(", "contents", ")", ",", "\"", "\\n", "\"", ")", "\n\n", "configMap", ":=", "parseConfig", "(", "localConfigVars", "[", ":", "len", "(", "localConfigVars", ")", "-", "1", "]", ")", "\n\n", "for", "key", ",", "value", ":=", "range", "configVars", ".", "Values", "{", "localValue", ",", "ok", ":=", "configMap", "[", "key", "]", "\n\n", "if", "ok", "{", "if", "value", "!=", "localValue", "{", "var", "confirm", "string", "\n", "fmt", ".", "Printf", "(", "\"", "\"", ",", "key", ",", "localValue", ",", "value", ")", "\n\n", "fmt", ".", "Scanln", "(", "&", "confirm", ")", "\n\n", "if", "strings", ".", "ToLower", "(", "confirm", ")", "==", "\"", "\"", "{", "configMap", "[", "key", "]", "=", "value", "\n", "}", "\n", "}", "\n", "}", "else", "{", "configMap", "[", "key", "]", "=", "value", "\n", "}", "\n", "}", "\n\n", "return", "ioutil", ".", "WriteFile", "(", "filename", ",", "[", "]", "byte", "(", "formatConfig", "(", "configMap", ")", ")", ",", "0755", ")", "\n", "}", "\n\n", "return", "ioutil", ".", "WriteFile", "(", "filename", ",", "[", "]", "byte", "(", "formatConfig", "(", "configVars", ".", "Values", ")", ")", ",", "0755", ")", "\n", "}" ]
// ConfigPull pulls an app's config to a file.
[ "ConfigPull", "pulls", "an", "app", "s", "config", "to", "a", "file", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/config.go#L152-L202
142,952
deis/deis
client/cmd/config.go
ConfigPush
func ConfigPush(appID string, fileName string) error { contents, err := ioutil.ReadFile(fileName) if err != nil { return err } config := strings.Split(string(contents), "\n") return ConfigSet(appID, config[:len(config)-1]) }
go
func ConfigPush(appID string, fileName string) error { contents, err := ioutil.ReadFile(fileName) if err != nil { return err } config := strings.Split(string(contents), "\n") return ConfigSet(appID, config[:len(config)-1]) }
[ "func", "ConfigPush", "(", "appID", "string", ",", "fileName", "string", ")", "error", "{", "contents", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "fileName", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "config", ":=", "strings", ".", "Split", "(", "string", "(", "contents", ")", ",", "\"", "\\n", "\"", ")", "\n", "return", "ConfigSet", "(", "appID", ",", "config", "[", ":", "len", "(", "config", ")", "-", "1", "]", ")", "\n", "}" ]
// ConfigPush pushes an app's config from a file.
[ "ConfigPush", "pushes", "an", "app", "s", "config", "from", "a", "file", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/config.go#L205-L214
142,953
deis/deis
deisctl/backend/fleet/stop.go
Stop
func (c *FleetClient) Stop(targets []string, wg *sync.WaitGroup, out, ew io.Writer) { // expand @* targets expandedTargets, err := c.expandTargets(targets) if err != nil { fmt.Fprintln(ew, err.Error()) return } for _, target := range expandedTargets { wg.Add(1) go doStop(c, target, wg, out, ew) } return }
go
func (c *FleetClient) Stop(targets []string, wg *sync.WaitGroup, out, ew io.Writer) { // expand @* targets expandedTargets, err := c.expandTargets(targets) if err != nil { fmt.Fprintln(ew, err.Error()) return } for _, target := range expandedTargets { wg.Add(1) go doStop(c, target, wg, out, ew) } return }
[ "func", "(", "c", "*", "FleetClient", ")", "Stop", "(", "targets", "[", "]", "string", ",", "wg", "*", "sync", ".", "WaitGroup", ",", "out", ",", "ew", "io", ".", "Writer", ")", "{", "// expand @* targets", "expandedTargets", ",", "err", ":=", "c", ".", "expandTargets", "(", "targets", ")", "\n", "if", "err", "!=", "nil", "{", "fmt", ".", "Fprintln", "(", "ew", ",", "err", ".", "Error", "(", ")", ")", "\n", "return", "\n", "}", "\n\n", "for", "_", ",", "target", ":=", "range", "expandedTargets", "{", "wg", ".", "Add", "(", "1", ")", "\n", "go", "doStop", "(", "c", ",", "target", ",", "wg", ",", "out", ",", "ew", ")", "\n", "}", "\n", "return", "\n", "}" ]
// Stop units and wait for their desiredState
[ "Stop", "units", "and", "wait", "for", "their", "desiredState" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/stop.go#L16-L29
142,954
deis/deis
builder/etcd/etcd.go
genSSHKeys
func genSSHKeys(c cookoo.Context) error { // Generate a new key out, err := exec.Command("ssh-keygen", "-A").CombinedOutput() if err != nil { log.Infof(c, "ssh-keygen: %s", out) log.Errf(c, "Failed to generate SSH keys: %s", err) return err } return nil }
go
func genSSHKeys(c cookoo.Context) error { // Generate a new key out, err := exec.Command("ssh-keygen", "-A").CombinedOutput() if err != nil { log.Infof(c, "ssh-keygen: %s", out) log.Errf(c, "Failed to generate SSH keys: %s", err) return err } return nil }
[ "func", "genSSHKeys", "(", "c", "cookoo", ".", "Context", ")", "error", "{", "// Generate a new key", "out", ",", "err", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "\"", "\"", ")", ".", "CombinedOutput", "(", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Infof", "(", "c", ",", "\"", "\"", ",", "out", ")", "\n", "log", ".", "Errf", "(", "c", ",", "\"", "\"", ",", "err", ")", "\n", "return", "err", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// genSshKeys generates the default set of SSH host keys.
[ "genSshKeys", "generates", "the", "default", "set", "of", "SSH", "host", "keys", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/etcd/etcd.go#L314-L323
142,955
deis/deis
builder/etcd/etcd.go
checkRetry
func checkRetry(c *etcd.Cluster, numReqs int, last http.Response, err error) error { if numReqs > retryCycles*len(c.Machines) { return fmt.Errorf("Tried and failed %d cluster connections: %s", retryCycles, err) } switch last.StatusCode { case 0: return nil case 500: time.Sleep(retrySleep) return nil case 200: return nil default: return fmt.Errorf("Unhandled HTTP Error: %s %d", last.Status, last.StatusCode) } }
go
func checkRetry(c *etcd.Cluster, numReqs int, last http.Response, err error) error { if numReqs > retryCycles*len(c.Machines) { return fmt.Errorf("Tried and failed %d cluster connections: %s", retryCycles, err) } switch last.StatusCode { case 0: return nil case 500: time.Sleep(retrySleep) return nil case 200: return nil default: return fmt.Errorf("Unhandled HTTP Error: %s %d", last.Status, last.StatusCode) } }
[ "func", "checkRetry", "(", "c", "*", "etcd", ".", "Cluster", ",", "numReqs", "int", ",", "last", "http", ".", "Response", ",", "err", "error", ")", "error", "{", "if", "numReqs", ">", "retryCycles", "*", "len", "(", "c", ".", "Machines", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "retryCycles", ",", "err", ")", "\n", "}", "\n\n", "switch", "last", ".", "StatusCode", "{", "case", "0", ":", "return", "nil", "\n", "case", "500", ":", "time", ".", "Sleep", "(", "retrySleep", ")", "\n", "return", "nil", "\n", "case", "200", ":", "return", "nil", "\n", "default", ":", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "last", ".", "Status", ",", "last", ".", "StatusCode", ")", "\n", "}", "\n", "}" ]
// checkRetry overrides etcd.DefaultCheckRetry. // // It adds configurable number of retries and configurable timesouts.
[ "checkRetry", "overrides", "etcd", ".", "DefaultCheckRetry", ".", "It", "adds", "configurable", "number", "of", "retries", "and", "configurable", "timesouts", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/etcd/etcd.go#L519-L535
142,956
deis/deis
deisctl/backend/fleet/start.go
Start
func (c *FleetClient) Start(targets []string, wg *sync.WaitGroup, out, ew io.Writer) { // expand @* targets expandedTargets, err := c.expandTargets(targets) if err != nil { io.WriteString(ew, err.Error()) return } for _, target := range expandedTargets { wg.Add(1) go doStart(c, target, wg, out, ew) } return }
go
func (c *FleetClient) Start(targets []string, wg *sync.WaitGroup, out, ew io.Writer) { // expand @* targets expandedTargets, err := c.expandTargets(targets) if err != nil { io.WriteString(ew, err.Error()) return } for _, target := range expandedTargets { wg.Add(1) go doStart(c, target, wg, out, ew) } return }
[ "func", "(", "c", "*", "FleetClient", ")", "Start", "(", "targets", "[", "]", "string", ",", "wg", "*", "sync", ".", "WaitGroup", ",", "out", ",", "ew", "io", ".", "Writer", ")", "{", "// expand @* targets", "expandedTargets", ",", "err", ":=", "c", ".", "expandTargets", "(", "targets", ")", "\n", "if", "err", "!=", "nil", "{", "io", ".", "WriteString", "(", "ew", ",", "err", ".", "Error", "(", ")", ")", "\n", "return", "\n", "}", "\n\n", "for", "_", ",", "target", ":=", "range", "expandedTargets", "{", "wg", ".", "Add", "(", "1", ")", "\n", "go", "doStart", "(", "c", ",", "target", ",", "wg", ",", "out", ",", "ew", ")", "\n", "}", "\n", "return", "\n", "}" ]
// Start units and wait for their desiredState
[ "Start", "units", "and", "wait", "for", "their", "desiredState" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/backend/fleet/start.go#L14-L27
142,957
deis/deis
deisctl/cmd/cmd.go
Scale
func Scale(targets []string, b backend.Backend) error { var wg sync.WaitGroup for _, target := range targets { component, num, err := splitScaleTarget(target) if err != nil { return err } // the router, registry, and store-gateway are the only component that can scale at the moment if !strings.Contains(component, "router") && !strings.Contains(component, "registry") && !strings.Contains(component, "store-gateway") { return fmt.Errorf("cannot scale %s component", component) } b.Scale(component, num, &wg, Stdout, Stderr) wg.Wait() } return nil }
go
func Scale(targets []string, b backend.Backend) error { var wg sync.WaitGroup for _, target := range targets { component, num, err := splitScaleTarget(target) if err != nil { return err } // the router, registry, and store-gateway are the only component that can scale at the moment if !strings.Contains(component, "router") && !strings.Contains(component, "registry") && !strings.Contains(component, "store-gateway") { return fmt.Errorf("cannot scale %s component", component) } b.Scale(component, num, &wg, Stdout, Stderr) wg.Wait() } return nil }
[ "func", "Scale", "(", "targets", "[", "]", "string", ",", "b", "backend", ".", "Backend", ")", "error", "{", "var", "wg", "sync", ".", "WaitGroup", "\n\n", "for", "_", ",", "target", ":=", "range", "targets", "{", "component", ",", "num", ",", "err", ":=", "splitScaleTarget", "(", "target", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "// the router, registry, and store-gateway are the only component that can scale at the moment", "if", "!", "strings", ".", "Contains", "(", "component", ",", "\"", "\"", ")", "&&", "!", "strings", ".", "Contains", "(", "component", ",", "\"", "\"", ")", "&&", "!", "strings", ".", "Contains", "(", "component", ",", "\"", "\"", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "component", ")", "\n", "}", "\n", "b", ".", "Scale", "(", "component", ",", "num", ",", "&", "wg", ",", "Stdout", ",", "Stderr", ")", "\n", "wg", ".", "Wait", "(", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Scale grows or shrinks the number of running components. // Currently "router", "registry" and "store-gateway" are the only types that can be scaled.
[ "Scale", "grows", "or", "shrinks", "the", "number", "of", "running", "components", ".", "Currently", "router", "registry", "and", "store", "-", "gateway", "are", "the", "only", "types", "that", "can", "be", "scaled", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/cmd/cmd.go#L56-L72
142,958
deis/deis
deisctl/cmd/cmd.go
Start
func Start(targets []string, b backend.Backend) error { // if target is platform, install all services if len(targets) == 1 { switch targets[0] { case PlatformCommand: return StartPlatform(b, false) case StatelessPlatformCommand: return StartPlatform(b, true) } } var wg sync.WaitGroup b.Start(targets, &wg, Stdout, Stderr) wg.Wait() return nil }
go
func Start(targets []string, b backend.Backend) error { // if target is platform, install all services if len(targets) == 1 { switch targets[0] { case PlatformCommand: return StartPlatform(b, false) case StatelessPlatformCommand: return StartPlatform(b, true) } } var wg sync.WaitGroup b.Start(targets, &wg, Stdout, Stderr) wg.Wait() return nil }
[ "func", "Start", "(", "targets", "[", "]", "string", ",", "b", "backend", ".", "Backend", ")", "error", "{", "// if target is platform, install all services", "if", "len", "(", "targets", ")", "==", "1", "{", "switch", "targets", "[", "0", "]", "{", "case", "PlatformCommand", ":", "return", "StartPlatform", "(", "b", ",", "false", ")", "\n", "case", "StatelessPlatformCommand", ":", "return", "StartPlatform", "(", "b", ",", "true", ")", "\n", "}", "\n", "}", "\n", "var", "wg", "sync", ".", "WaitGroup", "\n\n", "b", ".", "Start", "(", "targets", ",", "&", "wg", ",", "Stdout", ",", "Stderr", ")", "\n", "wg", ".", "Wait", "(", ")", "\n\n", "return", "nil", "\n", "}" ]
// Start activates the specified components.
[ "Start", "activates", "the", "specified", "components", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/cmd/cmd.go#L75-L92
142,959
deis/deis
deisctl/cmd/cmd.go
RollingRestart
func RollingRestart(target string, b backend.Backend) error { var wg sync.WaitGroup b.RollingRestart(target, &wg, Stdout, Stderr) wg.Wait() return nil }
go
func RollingRestart(target string, b backend.Backend) error { var wg sync.WaitGroup b.RollingRestart(target, &wg, Stdout, Stderr) wg.Wait() return nil }
[ "func", "RollingRestart", "(", "target", "string", ",", "b", "backend", ".", "Backend", ")", "error", "{", "var", "wg", "sync", ".", "WaitGroup", "\n\n", "b", ".", "RollingRestart", "(", "target", ",", "&", "wg", ",", "Stdout", ",", "Stderr", ")", "\n", "wg", ".", "Wait", "(", ")", "\n\n", "return", "nil", "\n", "}" ]
// RollingRestart restart instance unit in a rolling manner
[ "RollingRestart", "restart", "instance", "unit", "in", "a", "rolling", "manner" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/cmd/cmd.go#L95-L102
142,960
deis/deis
deisctl/cmd/cmd.go
CheckRequiredKeys
func CheckRequiredKeys(cb config.Backend) error { if err := config.CheckConfig("/deis/platform/", "domain", cb); err != nil { return fmt.Errorf(`Missing platform domain, use: deisctl config platform set domain=<your-domain>`) } if err := config.CheckConfig("/deis/platform/", "sshPrivateKey", cb); err != nil { fmt.Printf(`Warning: Missing sshPrivateKey, "deis run" will be unavailable. Use: deisctl config platform set sshPrivateKey=<path-to-key> `) } return nil }
go
func CheckRequiredKeys(cb config.Backend) error { if err := config.CheckConfig("/deis/platform/", "domain", cb); err != nil { return fmt.Errorf(`Missing platform domain, use: deisctl config platform set domain=<your-domain>`) } if err := config.CheckConfig("/deis/platform/", "sshPrivateKey", cb); err != nil { fmt.Printf(`Warning: Missing sshPrivateKey, "deis run" will be unavailable. Use: deisctl config platform set sshPrivateKey=<path-to-key> `) } return nil }
[ "func", "CheckRequiredKeys", "(", "cb", "config", ".", "Backend", ")", "error", "{", "if", "err", ":=", "config", ".", "CheckConfig", "(", "\"", "\"", ",", "\"", "\"", ",", "cb", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "`Missing platform domain, use:\ndeisctl config platform set domain=<your-domain>`", ")", "\n", "}", "\n\n", "if", "err", ":=", "config", ".", "CheckConfig", "(", "\"", "\"", ",", "\"", "\"", ",", "cb", ")", ";", "err", "!=", "nil", "{", "fmt", ".", "Printf", "(", "`Warning: Missing sshPrivateKey, \"deis run\" will be unavailable. Use:\ndeisctl config platform set sshPrivateKey=<path-to-key>\n`", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// CheckRequiredKeys exist in config backend
[ "CheckRequiredKeys", "exist", "in", "config", "backend" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/cmd/cmd.go#L105-L117
142,961
deis/deis
deisctl/cmd/cmd.go
Restart
func Restart(targets []string, b backend.Backend) error { // act as if the user called "stop" and then "start" if err := Stop(targets, b); err != nil { return err } return Start(targets, b) }
go
func Restart(targets []string, b backend.Backend) error { // act as if the user called "stop" and then "start" if err := Stop(targets, b); err != nil { return err } return Start(targets, b) }
[ "func", "Restart", "(", "targets", "[", "]", "string", ",", "b", "backend", ".", "Backend", ")", "error", "{", "// act as if the user called \"stop\" and then \"start\"", "if", "err", ":=", "Stop", "(", "targets", ",", "b", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "Start", "(", "targets", ",", "b", ")", "\n", "}" ]
// Restart stops and then starts the specified components.
[ "Restart", "stops", "and", "then", "starts", "the", "specified", "components", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/cmd/cmd.go#L241-L249
142,962
deis/deis
deisctl/cmd/cmd.go
Journal
func Journal(targets []string, b backend.Backend) error { for _, target := range targets { if err := b.Journal(target); err != nil { return err } } return nil }
go
func Journal(targets []string, b backend.Backend) error { for _, target := range targets { if err := b.Journal(target); err != nil { return err } } return nil }
[ "func", "Journal", "(", "targets", "[", "]", "string", ",", "b", "backend", ".", "Backend", ")", "error", "{", "for", "_", ",", "target", ":=", "range", "targets", "{", "if", "err", ":=", "b", ".", "Journal", "(", "target", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Journal prints log output for the specified components.
[ "Journal", "prints", "log", "output", "for", "the", "specified", "components", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/cmd/cmd.go#L263-L271
142,963
deis/deis
deisctl/cmd/cmd.go
Uninstall
func Uninstall(targets []string, b backend.Backend) error { if len(targets) == 1 { switch targets[0] { case PlatformCommand: return UninstallPlatform(b, false) case StatelessPlatformCommand: return UninstallPlatform(b, true) } } var wg sync.WaitGroup // uninstall the specific target b.Destroy(targets, &wg, Stdout, Stderr) wg.Wait() return nil }
go
func Uninstall(targets []string, b backend.Backend) error { if len(targets) == 1 { switch targets[0] { case PlatformCommand: return UninstallPlatform(b, false) case StatelessPlatformCommand: return UninstallPlatform(b, true) } } var wg sync.WaitGroup // uninstall the specific target b.Destroy(targets, &wg, Stdout, Stderr) wg.Wait() return nil }
[ "func", "Uninstall", "(", "targets", "[", "]", "string", ",", "b", "backend", ".", "Backend", ")", "error", "{", "if", "len", "(", "targets", ")", "==", "1", "{", "switch", "targets", "[", "0", "]", "{", "case", "PlatformCommand", ":", "return", "UninstallPlatform", "(", "b", ",", "false", ")", "\n", "case", "StatelessPlatformCommand", ":", "return", "UninstallPlatform", "(", "b", ",", "true", ")", "\n", "}", "\n", "}", "\n\n", "var", "wg", "sync", ".", "WaitGroup", "\n\n", "// uninstall the specific target", "b", ".", "Destroy", "(", "targets", ",", "&", "wg", ",", "Stdout", ",", "Stderr", ")", "\n", "wg", ".", "Wait", "(", ")", "\n\n", "return", "nil", "\n", "}" ]
// Uninstall unloads the definitions of the specified components. // After Uninstall, the components will be unavailable until Install is called.
[ "Uninstall", "unloads", "the", "definitions", "of", "the", "specified", "components", ".", "After", "Uninstall", "the", "components", "will", "be", "unavailable", "until", "Install", "is", "called", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/cmd/cmd.go#L335-L352
142,964
deis/deis
deisctl/cmd/cmd.go
RefreshUnits
func RefreshUnits(unitDir, tag, rootURL string) error { unitDir = utils.ResolvePath(unitDir) decoratorDir := filepath.Join(unitDir, "decorators") // create the target dir if necessary if err := os.MkdirAll(decoratorDir, 0755); err != nil { return err } // download and save the unit files to the specified path for _, unit := range units.Names { unitSrc := rootURL + tag + "/deisctl/units/" + unit + ".service" unitDest := filepath.Join(unitDir, unit+".service") if err := net.Download(unitSrc, unitDest); err != nil { return err } fmt.Printf("Refreshed %s unit from %s\n", unit, tag) decoratorSrc := rootURL + tag + "/deisctl/units/decorators/" + unit + ".service.decorator" decoratorDest := filepath.Join(decoratorDir, unit+".service.decorator") if err := net.Download(decoratorSrc, decoratorDest); err != nil { if err.Error() == "404 Not Found" { fmt.Printf("Decorator for %s not found in %s\n", unit, tag) } else { return err } } else { fmt.Printf("Refreshed %s decorator from %s\n", unit, tag) } } return nil }
go
func RefreshUnits(unitDir, tag, rootURL string) error { unitDir = utils.ResolvePath(unitDir) decoratorDir := filepath.Join(unitDir, "decorators") // create the target dir if necessary if err := os.MkdirAll(decoratorDir, 0755); err != nil { return err } // download and save the unit files to the specified path for _, unit := range units.Names { unitSrc := rootURL + tag + "/deisctl/units/" + unit + ".service" unitDest := filepath.Join(unitDir, unit+".service") if err := net.Download(unitSrc, unitDest); err != nil { return err } fmt.Printf("Refreshed %s unit from %s\n", unit, tag) decoratorSrc := rootURL + tag + "/deisctl/units/decorators/" + unit + ".service.decorator" decoratorDest := filepath.Join(decoratorDir, unit+".service.decorator") if err := net.Download(decoratorSrc, decoratorDest); err != nil { if err.Error() == "404 Not Found" { fmt.Printf("Decorator for %s not found in %s\n", unit, tag) } else { return err } } else { fmt.Printf("Refreshed %s decorator from %s\n", unit, tag) } } return nil }
[ "func", "RefreshUnits", "(", "unitDir", ",", "tag", ",", "rootURL", "string", ")", "error", "{", "unitDir", "=", "utils", ".", "ResolvePath", "(", "unitDir", ")", "\n", "decoratorDir", ":=", "filepath", ".", "Join", "(", "unitDir", ",", "\"", "\"", ")", "\n", "// create the target dir if necessary", "if", "err", ":=", "os", ".", "MkdirAll", "(", "decoratorDir", ",", "0755", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "// download and save the unit files to the specified path", "for", "_", ",", "unit", ":=", "range", "units", ".", "Names", "{", "unitSrc", ":=", "rootURL", "+", "tag", "+", "\"", "\"", "+", "unit", "+", "\"", "\"", "\n", "unitDest", ":=", "filepath", ".", "Join", "(", "unitDir", ",", "unit", "+", "\"", "\"", ")", "\n", "if", "err", ":=", "net", ".", "Download", "(", "unitSrc", ",", "unitDest", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "unit", ",", "tag", ")", "\n", "decoratorSrc", ":=", "rootURL", "+", "tag", "+", "\"", "\"", "+", "unit", "+", "\"", "\"", "\n", "decoratorDest", ":=", "filepath", ".", "Join", "(", "decoratorDir", ",", "unit", "+", "\"", "\"", ")", "\n", "if", "err", ":=", "net", ".", "Download", "(", "decoratorSrc", ",", "decoratorDest", ")", ";", "err", "!=", "nil", "{", "if", "err", ".", "Error", "(", ")", "==", "\"", "\"", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "unit", ",", "tag", ")", "\n", "}", "else", "{", "return", "err", "\n", "}", "\n", "}", "else", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "unit", ",", "tag", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// RefreshUnits overwrites local unit files with those requested. // Downloading from the Deis project GitHub URL by tag or SHA is the only mechanism // currently supported.
[ "RefreshUnits", "overwrites", "local", "unit", "files", "with", "those", "requested", ".", "Downloading", "from", "the", "Deis", "project", "GitHub", "URL", "by", "tag", "or", "SHA", "is", "the", "only", "mechanism", "currently", "supported", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/cmd/cmd.go#L425-L453
142,965
deis/deis
deisctl/cmd/cmd.go
SSH
func SSH(target string, cmd []string, b backend.Backend) error { if len(cmd) > 0 { return b.SSHExec(target, strings.Join(cmd, " ")) } return b.SSH(target) }
go
func SSH(target string, cmd []string, b backend.Backend) error { if len(cmd) > 0 { return b.SSHExec(target, strings.Join(cmd, " ")) } return b.SSH(target) }
[ "func", "SSH", "(", "target", "string", ",", "cmd", "[", "]", "string", ",", "b", "backend", ".", "Backend", ")", "error", "{", "if", "len", "(", "cmd", ")", ">", "0", "{", "return", "b", ".", "SSHExec", "(", "target", ",", "strings", ".", "Join", "(", "cmd", ",", "\"", "\"", ")", ")", "\n", "}", "\n\n", "return", "b", ".", "SSH", "(", "target", ")", "\n", "}" ]
// SSH opens an interactive shell on a machine in the cluster
[ "SSH", "opens", "an", "interactive", "shell", "on", "a", "machine", "in", "the", "cluster" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/deisctl/cmd/cmd.go#L456-L463
142,966
deis/deis
client/parser/tags.go
Tags
func Tags(argv []string) error { usage := ` Valid commands for tags: tags:list list tags for an app tags:set set tags for an app tags:unset unset tags for an app Use 'deis help [command]' to learn more. ` switch argv[0] { case "tags:list": return tagsList(argv) case "tags:set": return tagsSet(argv) case "tags:unset": return tagsUnset(argv) default: if printHelp(argv, usage) { return nil } if argv[0] == "tags" { argv[0] = "tags:list" return tagsList(argv) } PrintUsage() return nil } }
go
func Tags(argv []string) error { usage := ` Valid commands for tags: tags:list list tags for an app tags:set set tags for an app tags:unset unset tags for an app Use 'deis help [command]' to learn more. ` switch argv[0] { case "tags:list": return tagsList(argv) case "tags:set": return tagsSet(argv) case "tags:unset": return tagsUnset(argv) default: if printHelp(argv, usage) { return nil } if argv[0] == "tags" { argv[0] = "tags:list" return tagsList(argv) } PrintUsage() return nil } }
[ "func", "Tags", "(", "argv", "[", "]", "string", ")", "error", "{", "usage", ":=", "`\nValid commands for tags:\n\ntags:list list tags for an app\ntags:set set tags for an app\ntags:unset unset tags for an app\n\nUse 'deis help [command]' to learn more.\n`", "\n\n", "switch", "argv", "[", "0", "]", "{", "case", "\"", "\"", ":", "return", "tagsList", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "return", "tagsSet", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "return", "tagsUnset", "(", "argv", ")", "\n", "default", ":", "if", "printHelp", "(", "argv", ",", "usage", ")", "{", "return", "nil", "\n", "}", "\n\n", "if", "argv", "[", "0", "]", "==", "\"", "\"", "{", "argv", "[", "0", "]", "=", "\"", "\"", "\n", "return", "tagsList", "(", "argv", ")", "\n", "}", "\n\n", "PrintUsage", "(", ")", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// Tags routes tags commands to their specific function
[ "Tags", "routes", "tags", "commands", "to", "their", "specific", "function" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/parser/tags.go#L9-L40
142,967
deis/deis
logger/storage/factory.go
NewAdapter
func NewAdapter(storeageAdapterType string) (Adapter, error) { if storeageAdapterType == "" || storeageAdapterType == "file" { adapter, err := file.NewStorageAdapter(LogRoot) if err != nil { return nil, err } return adapter, nil } match := memoryAdapterRegex.FindStringSubmatch(storeageAdapterType) if match == nil { return nil, fmt.Errorf("Unrecognized storage adapter type: '%s'", storeageAdapterType) } sizeStr := match[1] if sizeStr == "" { sizeStr = "1000" } size, err := strconv.Atoi(sizeStr) if err != nil { return nil, err } adapter, err := ringbuffer.NewStorageAdapter(size) if err != nil { return nil, err } return adapter, nil }
go
func NewAdapter(storeageAdapterType string) (Adapter, error) { if storeageAdapterType == "" || storeageAdapterType == "file" { adapter, err := file.NewStorageAdapter(LogRoot) if err != nil { return nil, err } return adapter, nil } match := memoryAdapterRegex.FindStringSubmatch(storeageAdapterType) if match == nil { return nil, fmt.Errorf("Unrecognized storage adapter type: '%s'", storeageAdapterType) } sizeStr := match[1] if sizeStr == "" { sizeStr = "1000" } size, err := strconv.Atoi(sizeStr) if err != nil { return nil, err } adapter, err := ringbuffer.NewStorageAdapter(size) if err != nil { return nil, err } return adapter, nil }
[ "func", "NewAdapter", "(", "storeageAdapterType", "string", ")", "(", "Adapter", ",", "error", ")", "{", "if", "storeageAdapterType", "==", "\"", "\"", "||", "storeageAdapterType", "==", "\"", "\"", "{", "adapter", ",", "err", ":=", "file", ".", "NewStorageAdapter", "(", "LogRoot", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "adapter", ",", "nil", "\n", "}", "\n", "match", ":=", "memoryAdapterRegex", ".", "FindStringSubmatch", "(", "storeageAdapterType", ")", "\n", "if", "match", "==", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "storeageAdapterType", ")", "\n", "}", "\n", "sizeStr", ":=", "match", "[", "1", "]", "\n", "if", "sizeStr", "==", "\"", "\"", "{", "sizeStr", "=", "\"", "\"", "\n", "}", "\n", "size", ",", "err", ":=", "strconv", ".", "Atoi", "(", "sizeStr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "adapter", ",", "err", ":=", "ringbuffer", ".", "NewStorageAdapter", "(", "size", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "adapter", ",", "nil", "\n", "}" ]
// NewAdapter returns a pointer to an appropriate implementation of the Adapter interface, as // determined by the storeageAdapterType string it is passed.
[ "NewAdapter", "returns", "a", "pointer", "to", "an", "appropriate", "implementation", "of", "the", "Adapter", "interface", "as", "determined", "by", "the", "storeageAdapterType", "string", "it", "is", "passed", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/logger/storage/factory.go#L23-L48
142,968
deis/deis
builder/docker/docker.go
Start
func Start(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt) { // Allow insecure Docker registries on all private network ranges in RFC 1918 and RFC 6598. dargs := []string{ "-d", "--bip=172.19.42.1/16", "--insecure-registry", "10.0.0.0/8", "--insecure-registry", "172.16.0.0/12", "--insecure-registry", "192.168.0.0/16", "--insecure-registry", "100.64.0.0/10", "--exec-opt", "native.cgroupdriver=cgroupfs", } // For overlay-ish filesystems, force the overlay to kick in if it exists. // Then we can check the fstype. if err := os.MkdirAll("/", 0700); err == nil { cmd := exec.Command("findmnt", "--noheadings", "--output", "FSTYPE", "--target", "/") if out, err := cmd.Output(); err == nil && strings.TrimSpace(string(out)) == "overlay" { dargs = append(dargs, "--storage-driver=overlay") } else { log.Infof(c, "File system type: '%s' (%v)", out, err) } } log.Infof(c, "Starting docker with %s", strings.Join(dargs, " ")) cmd := exec.Command("docker", dargs...) if err := cmd.Start(); err != nil { log.Errf(c, "Failed to start Docker. %s", err) return -1, err } // Get the PID and return it. return cmd.Process.Pid, nil }
go
func Start(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt) { // Allow insecure Docker registries on all private network ranges in RFC 1918 and RFC 6598. dargs := []string{ "-d", "--bip=172.19.42.1/16", "--insecure-registry", "10.0.0.0/8", "--insecure-registry", "172.16.0.0/12", "--insecure-registry", "192.168.0.0/16", "--insecure-registry", "100.64.0.0/10", "--exec-opt", "native.cgroupdriver=cgroupfs", } // For overlay-ish filesystems, force the overlay to kick in if it exists. // Then we can check the fstype. if err := os.MkdirAll("/", 0700); err == nil { cmd := exec.Command("findmnt", "--noheadings", "--output", "FSTYPE", "--target", "/") if out, err := cmd.Output(); err == nil && strings.TrimSpace(string(out)) == "overlay" { dargs = append(dargs, "--storage-driver=overlay") } else { log.Infof(c, "File system type: '%s' (%v)", out, err) } } log.Infof(c, "Starting docker with %s", strings.Join(dargs, " ")) cmd := exec.Command("docker", dargs...) if err := cmd.Start(); err != nil { log.Errf(c, "Failed to start Docker. %s", err) return -1, err } // Get the PID and return it. return cmd.Process.Pid, nil }
[ "func", "Start", "(", "c", "cookoo", ".", "Context", ",", "p", "*", "cookoo", ".", "Params", ")", "(", "interface", "{", "}", ",", "cookoo", ".", "Interrupt", ")", "{", "// Allow insecure Docker registries on all private network ranges in RFC 1918 and RFC 6598.", "dargs", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "}", "\n\n", "// For overlay-ish filesystems, force the overlay to kick in if it exists.", "// Then we can check the fstype.", "if", "err", ":=", "os", ".", "MkdirAll", "(", "\"", "\"", ",", "0700", ")", ";", "err", "==", "nil", "{", "cmd", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", "\n\n", "if", "out", ",", "err", ":=", "cmd", ".", "Output", "(", ")", ";", "err", "==", "nil", "&&", "strings", ".", "TrimSpace", "(", "string", "(", "out", ")", ")", "==", "\"", "\"", "{", "dargs", "=", "append", "(", "dargs", ",", "\"", "\"", ")", "\n", "}", "else", "{", "log", ".", "Infof", "(", "c", ",", "\"", "\"", ",", "out", ",", "err", ")", "\n", "}", "\n", "}", "\n\n", "log", ".", "Infof", "(", "c", ",", "\"", "\"", ",", "strings", ".", "Join", "(", "dargs", ",", "\"", "\"", ")", ")", "\n", "cmd", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "dargs", "...", ")", "\n", "if", "err", ":=", "cmd", ".", "Start", "(", ")", ";", "err", "!=", "nil", "{", "log", ".", "Errf", "(", "c", ",", "\"", "\"", ",", "err", ")", "\n", "return", "-", "1", ",", "err", "\n", "}", "\n", "// Get the PID and return it.", "return", "cmd", ".", "Process", ".", "Pid", ",", "nil", "\n", "}" ]
// Start starts a Docker daemon. // // This assumes the presence of the docker client on the host. It does not use // the API.
[ "Start", "starts", "a", "Docker", "daemon", ".", "This", "assumes", "the", "presence", "of", "the", "docker", "client", "on", "the", "host", ".", "It", "does", "not", "use", "the", "API", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/builder/docker/docker.go#L62-L100
142,969
deis/deis
client/parser/releases.go
Releases
func Releases(argv []string) error { usage := ` Valid commands for releases: releases:list list an application's release history releases:info print information about a specific release releases:rollback return to a previous release Use 'deis help [command]' to learn more. ` switch argv[0] { case "releases:list": return releasesList(argv) case "releases:info": return releasesInfo(argv) case "releases:rollback": return releasesRollback(argv) default: if printHelp(argv, usage) { return nil } if argv[0] == "releases" { argv[0] = "releases:list" return releasesList(argv) } PrintUsage() return nil } }
go
func Releases(argv []string) error { usage := ` Valid commands for releases: releases:list list an application's release history releases:info print information about a specific release releases:rollback return to a previous release Use 'deis help [command]' to learn more. ` switch argv[0] { case "releases:list": return releasesList(argv) case "releases:info": return releasesInfo(argv) case "releases:rollback": return releasesRollback(argv) default: if printHelp(argv, usage) { return nil } if argv[0] == "releases" { argv[0] = "releases:list" return releasesList(argv) } PrintUsage() return nil } }
[ "func", "Releases", "(", "argv", "[", "]", "string", ")", "error", "{", "usage", ":=", "`\nValid commands for releases:\n\nreleases:list list an application's release history\nreleases:info print information about a specific release\nreleases:rollback return to a previous release\n\nUse 'deis help [command]' to learn more.\n`", "\n\n", "switch", "argv", "[", "0", "]", "{", "case", "\"", "\"", ":", "return", "releasesList", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "return", "releasesInfo", "(", "argv", ")", "\n", "case", "\"", "\"", ":", "return", "releasesRollback", "(", "argv", ")", "\n", "default", ":", "if", "printHelp", "(", "argv", ",", "usage", ")", "{", "return", "nil", "\n", "}", "\n\n", "if", "argv", "[", "0", "]", "==", "\"", "\"", "{", "argv", "[", "0", "]", "=", "\"", "\"", "\n", "return", "releasesList", "(", "argv", ")", "\n", "}", "\n\n", "PrintUsage", "(", ")", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// Releases routes releases commands to their specific function.
[ "Releases", "routes", "releases", "commands", "to", "their", "specific", "function", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/parser/releases.go#L12-L43
142,970
deis/deis
client/pkg/git/git.go
CreateRemote
func CreateRemote(host, remote, appID string) error { cmd := exec.Command("git", "remote", "add", remote, RemoteURL(host, appID)) stderr, err := cmd.StderrPipe() if err != nil { return err } if err = cmd.Start(); err != nil { return err } output, _ := ioutil.ReadAll(stderr) fmt.Print(string(output)) if err := cmd.Wait(); err != nil { return err } fmt.Printf("Git remote %s added\n", remote) return nil }
go
func CreateRemote(host, remote, appID string) error { cmd := exec.Command("git", "remote", "add", remote, RemoteURL(host, appID)) stderr, err := cmd.StderrPipe() if err != nil { return err } if err = cmd.Start(); err != nil { return err } output, _ := ioutil.ReadAll(stderr) fmt.Print(string(output)) if err := cmd.Wait(); err != nil { return err } fmt.Printf("Git remote %s added\n", remote) return nil }
[ "func", "CreateRemote", "(", "host", ",", "remote", ",", "appID", "string", ")", "error", "{", "cmd", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "remote", ",", "RemoteURL", "(", "host", ",", "appID", ")", ")", "\n", "stderr", ",", "err", ":=", "cmd", ".", "StderrPipe", "(", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "err", "=", "cmd", ".", "Start", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "output", ",", "_", ":=", "ioutil", ".", "ReadAll", "(", "stderr", ")", "\n", "fmt", ".", "Print", "(", "string", "(", "output", ")", ")", "\n\n", "if", "err", ":=", "cmd", ".", "Wait", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "remote", ")", "\n\n", "return", "nil", "\n", "}" ]
// CreateRemote adds a git remote in the current directory.
[ "CreateRemote", "adds", "a", "git", "remote", "in", "the", "current", "directory", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/pkg/git/git.go#L14-L36
142,971
deis/deis
client/pkg/git/git.go
DeleteRemote
func DeleteRemote(appID string) error { name, err := remoteNameFromAppID(appID) if err != nil { return err } if _, err = exec.Command("git", "remote", "remove", name).Output(); err != nil { return err } fmt.Printf("Git remote %s removed\n", name) return nil }
go
func DeleteRemote(appID string) error { name, err := remoteNameFromAppID(appID) if err != nil { return err } if _, err = exec.Command("git", "remote", "remove", name).Output(); err != nil { return err } fmt.Printf("Git remote %s removed\n", name) return nil }
[ "func", "DeleteRemote", "(", "appID", "string", ")", "error", "{", "name", ",", "err", ":=", "remoteNameFromAppID", "(", "appID", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "_", ",", "err", "=", "exec", ".", "Command", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "name", ")", ".", "Output", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "name", ")", "\n\n", "return", "nil", "\n", "}" ]
// DeleteRemote removes a git remote in the current directory.
[ "DeleteRemote", "removes", "a", "git", "remote", "in", "the", "current", "directory", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/pkg/git/git.go#L39-L53
142,972
deis/deis
client/pkg/git/git.go
DetectAppName
func DetectAppName(host string) (string, error) { remote, err := findRemote(host) // Don't return an error if remote can't be found, return directory name instead. if err != nil { dir, err := os.Getwd() return strings.ToLower(path.Base(dir)), err } ss := strings.Split(remote, "/") return strings.Split(ss[len(ss)-1], ".")[0], nil }
go
func DetectAppName(host string) (string, error) { remote, err := findRemote(host) // Don't return an error if remote can't be found, return directory name instead. if err != nil { dir, err := os.Getwd() return strings.ToLower(path.Base(dir)), err } ss := strings.Split(remote, "/") return strings.Split(ss[len(ss)-1], ".")[0], nil }
[ "func", "DetectAppName", "(", "host", "string", ")", "(", "string", ",", "error", ")", "{", "remote", ",", "err", ":=", "findRemote", "(", "host", ")", "\n\n", "// Don't return an error if remote can't be found, return directory name instead.", "if", "err", "!=", "nil", "{", "dir", ",", "err", ":=", "os", ".", "Getwd", "(", ")", "\n", "return", "strings", ".", "ToLower", "(", "path", ".", "Base", "(", "dir", ")", ")", ",", "err", "\n", "}", "\n\n", "ss", ":=", "strings", ".", "Split", "(", "remote", ",", "\"", "\"", ")", "\n", "return", "strings", ".", "Split", "(", "ss", "[", "len", "(", "ss", ")", "-", "1", "]", ",", "\"", "\"", ")", "[", "0", "]", ",", "nil", "\n", "}" ]
// DetectAppName detects if there is deis remote in git.
[ "DetectAppName", "detects", "if", "there", "is", "deis", "remote", "in", "git", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/pkg/git/git.go#L74-L85
142,973
deis/deis
client/pkg/git/git.go
RemoteURL
func RemoteURL(host, appID string) string { // Strip off any trailing :port number after the host name. host = strings.Split(host, ":")[0] return fmt.Sprintf("ssh://git@%s:2222/%s.git", host, appID) }
go
func RemoteURL(host, appID string) string { // Strip off any trailing :port number after the host name. host = strings.Split(host, ":")[0] return fmt.Sprintf("ssh://git@%s:2222/%s.git", host, appID) }
[ "func", "RemoteURL", "(", "host", ",", "appID", "string", ")", "string", "{", "// Strip off any trailing :port number after the host name.", "host", "=", "strings", ".", "Split", "(", "host", ",", "\"", "\"", ")", "[", "0", "]", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "host", ",", "appID", ")", "\n", "}" ]
// RemoteURL returns the git URL of app.
[ "RemoteURL", "returns", "the", "git", "URL", "of", "app", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/pkg/git/git.go#L111-L115
142,974
deis/deis
client/cmd/keys.go
KeysList
func KeysList(results int) error { c, err := client.New() if err != nil { return err } if results == defaultLimit { results = c.ResponseLimit } keys, count, err := keys.List(c, results) if err != nil { return err } fmt.Printf("=== %s Keys%s", c.Username, limitCount(len(keys), count)) sort.Sort(keys) for _, key := range keys { fmt.Printf("%s %s...%s\n", key.ID, key.Public[:16], key.Public[len(key.Public)-10:]) } return nil }
go
func KeysList(results int) error { c, err := client.New() if err != nil { return err } if results == defaultLimit { results = c.ResponseLimit } keys, count, err := keys.List(c, results) if err != nil { return err } fmt.Printf("=== %s Keys%s", c.Username, limitCount(len(keys), count)) sort.Sort(keys) for _, key := range keys { fmt.Printf("%s %s...%s\n", key.ID, key.Public[:16], key.Public[len(key.Public)-10:]) } return nil }
[ "func", "KeysList", "(", "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", "keys", ",", "count", ",", "err", ":=", "keys", ".", "List", "(", "c", ",", "results", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Printf", "(", "\"", "\"", ",", "c", ".", "Username", ",", "limitCount", "(", "len", "(", "keys", ")", ",", "count", ")", ")", "\n\n", "sort", ".", "Sort", "(", "keys", ")", "\n\n", "for", "_", ",", "key", ":=", "range", "keys", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "key", ".", "ID", ",", "key", ".", "Public", "[", ":", "16", "]", ",", "key", ".", "Public", "[", "len", "(", "key", ".", "Public", ")", "-", "10", ":", "]", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// KeysList lists a user's keys.
[ "KeysList", "lists", "a", "user", "s", "keys", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/keys.go#L18-L43
142,975
deis/deis
client/cmd/keys.go
KeyRemove
func KeyRemove(keyID string) error { c, err := client.New() if err != nil { return err } fmt.Printf("Removing %s SSH Key...", keyID) if err = keys.Delete(c, keyID); err != nil { fmt.Println() return err } fmt.Println(" done") return nil }
go
func KeyRemove(keyID string) error { c, err := client.New() if err != nil { return err } fmt.Printf("Removing %s SSH Key...", keyID) if err = keys.Delete(c, keyID); err != nil { fmt.Println() return err } fmt.Println(" done") return nil }
[ "func", "KeyRemove", "(", "keyID", "string", ")", "error", "{", "c", ",", "err", ":=", "client", ".", "New", "(", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Printf", "(", "\"", "\"", ",", "keyID", ")", "\n\n", "if", "err", "=", "keys", ".", "Delete", "(", "c", ",", "keyID", ")", ";", "err", "!=", "nil", "{", "fmt", ".", "Println", "(", ")", "\n", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n", "return", "nil", "\n", "}" ]
// KeyRemove removes keys.
[ "KeyRemove", "removes", "keys", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/keys.go#L46-L62
142,976
deis/deis
client/cmd/keys.go
KeyAdd
func KeyAdd(keyLocation string) error { c, err := client.New() if err != nil { return err } var key api.KeyCreateRequest if keyLocation == "" { key, err = chooseKey() } else { key, err = getKey(keyLocation) } if err != nil { return err } fmt.Printf("Uploading %s to deis...", path.Base(key.Name)) if _, err = keys.New(c, key.ID, key.Public); err != nil { fmt.Println() return err } fmt.Println(" done") return nil }
go
func KeyAdd(keyLocation string) error { c, err := client.New() if err != nil { return err } var key api.KeyCreateRequest if keyLocation == "" { key, err = chooseKey() } else { key, err = getKey(keyLocation) } if err != nil { return err } fmt.Printf("Uploading %s to deis...", path.Base(key.Name)) if _, err = keys.New(c, key.ID, key.Public); err != nil { fmt.Println() return err } fmt.Println(" done") return nil }
[ "func", "KeyAdd", "(", "keyLocation", "string", ")", "error", "{", "c", ",", "err", ":=", "client", ".", "New", "(", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "var", "key", "api", ".", "KeyCreateRequest", "\n\n", "if", "keyLocation", "==", "\"", "\"", "{", "key", ",", "err", "=", "chooseKey", "(", ")", "\n", "}", "else", "{", "key", ",", "err", "=", "getKey", "(", "keyLocation", ")", "\n", "}", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Printf", "(", "\"", "\"", ",", "path", ".", "Base", "(", "key", ".", "Name", ")", ")", "\n\n", "if", "_", ",", "err", "=", "keys", ".", "New", "(", "c", ",", "key", ".", "ID", ",", "key", ".", "Public", ")", ";", "err", "!=", "nil", "{", "fmt", ".", "Println", "(", ")", "\n", "return", "err", "\n", "}", "\n\n", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n", "return", "nil", "\n", "}" ]
// KeyAdd adds keys.
[ "KeyAdd", "adds", "keys", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/cmd/keys.go#L65-L93
142,977
deis/deis
client/controller/models/keys/keys.go
New
func New(c *client.Client, id string, pubKey string) (api.Key, error) { req := api.KeyCreateRequest{ID: id, Public: pubKey} body, err := json.Marshal(req) resBody, err := c.BasicRequest("POST", "/v1/keys/", body) if err != nil { return api.Key{}, err } key := api.Key{} if err = json.Unmarshal([]byte(resBody), &key); err != nil { return api.Key{}, err } return key, nil }
go
func New(c *client.Client, id string, pubKey string) (api.Key, error) { req := api.KeyCreateRequest{ID: id, Public: pubKey} body, err := json.Marshal(req) resBody, err := c.BasicRequest("POST", "/v1/keys/", body) if err != nil { return api.Key{}, err } key := api.Key{} if err = json.Unmarshal([]byte(resBody), &key); err != nil { return api.Key{}, err } return key, nil }
[ "func", "New", "(", "c", "*", "client", ".", "Client", ",", "id", "string", ",", "pubKey", "string", ")", "(", "api", ".", "Key", ",", "error", ")", "{", "req", ":=", "api", ".", "KeyCreateRequest", "{", "ID", ":", "id", ",", "Public", ":", "pubKey", "}", "\n", "body", ",", "err", ":=", "json", ".", "Marshal", "(", "req", ")", "\n\n", "resBody", ",", "err", ":=", "c", ".", "BasicRequest", "(", "\"", "\"", ",", "\"", "\"", ",", "body", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "api", ".", "Key", "{", "}", ",", "err", "\n", "}", "\n\n", "key", ":=", "api", ".", "Key", "{", "}", "\n", "if", "err", "=", "json", ".", "Unmarshal", "(", "[", "]", "byte", "(", "resBody", ")", ",", "&", "key", ")", ";", "err", "!=", "nil", "{", "return", "api", ".", "Key", "{", "}", ",", "err", "\n", "}", "\n\n", "return", "key", ",", "nil", "\n", "}" ]
// New creates a new key.
[ "New", "creates", "a", "new", "key", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/client/controller/models/keys/keys.go#L28-L44
142,978
deis/deis
pkg/time/time.go
MarshalJSON
func (t *Time) MarshalJSON() ([]byte, error) { return []byte(t.Time.Format(`"` + DeisDatetimeFormat + `"`)), nil }
go
func (t *Time) MarshalJSON() ([]byte, error) { return []byte(t.Time.Format(`"` + DeisDatetimeFormat + `"`)), nil }
[ "func", "(", "t", "*", "Time", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "return", "[", "]", "byte", "(", "t", ".", "Time", ".", "Format", "(", "`\"`", "+", "DeisDatetimeFormat", "+", "`\"`", ")", ")", ",", "nil", "\n", "}" ]
// MarshalJSON implements the json.Marshaler interface. // The time is a quoted string in Deis' datetime format.
[ "MarshalJSON", "implements", "the", "json", ".", "Marshaler", "interface", ".", "The", "time", "is", "a", "quoted", "string", "in", "Deis", "datetime", "format", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/pkg/time/time.go#L19-L21
142,979
deis/deis
pkg/prettyprint/colorizer.go
DeisIfy
func DeisIfy(msg string) string { var t = struct { Msg string C map[string]string }{ Msg: msg, C: Colors, } tpl := "{{.C.Deis1}}\n{{.C.Deis2}} {{.Msg}}\n{{.C.Deis3}}\n" var buf bytes.Buffer template.Must(template.New("deis").Parse(tpl)).Execute(&buf, t) return buf.String() }
go
func DeisIfy(msg string) string { var t = struct { Msg string C map[string]string }{ Msg: msg, C: Colors, } tpl := "{{.C.Deis1}}\n{{.C.Deis2}} {{.Msg}}\n{{.C.Deis3}}\n" var buf bytes.Buffer template.Must(template.New("deis").Parse(tpl)).Execute(&buf, t) return buf.String() }
[ "func", "DeisIfy", "(", "msg", "string", ")", "string", "{", "var", "t", "=", "struct", "{", "Msg", "string", "\n", "C", "map", "[", "string", "]", "string", "\n", "}", "{", "Msg", ":", "msg", ",", "C", ":", "Colors", ",", "}", "\n", "tpl", ":=", "\"", "\\n", "\\n", "\\n", "\"", "\n", "var", "buf", "bytes", ".", "Buffer", "\n", "template", ".", "Must", "(", "template", ".", "New", "(", "\"", "\"", ")", ".", "Parse", "(", "tpl", ")", ")", ".", "Execute", "(", "&", "buf", ",", "t", ")", "\n", "return", "buf", ".", "String", "(", ")", "\n", "}" ]
// DeisIfy returns a pretty-printed deis logo along with the corresponding message
[ "DeisIfy", "returns", "a", "pretty", "-", "printed", "deis", "logo", "along", "with", "the", "corresponding", "message" ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/pkg/prettyprint/colorizer.go#L63-L75
142,980
deis/deis
pkg/prettyprint/colorizer.go
NoColor
func NoColor(msg string) string { empties := make(map[string]string, len(Colors)) for k := range Colors { empties[k] = "" } return colorize(msg, empties) }
go
func NoColor(msg string) string { empties := make(map[string]string, len(Colors)) for k := range Colors { empties[k] = "" } return colorize(msg, empties) }
[ "func", "NoColor", "(", "msg", "string", ")", "string", "{", "empties", ":=", "make", "(", "map", "[", "string", "]", "string", ",", "len", "(", "Colors", ")", ")", "\n", "for", "k", ":=", "range", "Colors", "{", "empties", "[", "k", "]", "=", "\"", "\"", "\n", "}", "\n", "return", "colorize", "(", "msg", ",", "empties", ")", "\n", "}" ]
// NoColor strips colors from the template. // // NoColor provides support for non-color ANSI terminals. It can be used // as an alternative to Colorize when it is detected that the terminal does // not support colors.
[ "NoColor", "strips", "colors", "from", "the", "template", ".", "NoColor", "provides", "support", "for", "non", "-", "color", "ANSI", "terminals", ".", "It", "can", "be", "used", "as", "an", "alternative", "to", "Colorize", "when", "it", "is", "detected", "that", "the", "terminal", "does", "not", "support", "colors", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/pkg/prettyprint/colorizer.go#L87-L93
142,981
deis/deis
pkg/prettyprint/colorizer.go
Overwritef
func Overwritef(msg string, args ...interface{}) string { return Overwrite(fmt.Sprintf(msg, args...)) }
go
func Overwritef(msg string, args ...interface{}) string { return Overwrite(fmt.Sprintf(msg, args...)) }
[ "func", "Overwritef", "(", "msg", "string", ",", "args", "...", "interface", "{", "}", ")", "string", "{", "return", "Overwrite", "(", "fmt", ".", "Sprintf", "(", "msg", ",", "args", "...", ")", ")", "\n", "}" ]
// Overwritef formats a string and then returns an overwrite line. // // See `Overwrite` for details.
[ "Overwritef", "formats", "a", "string", "and", "then", "returns", "an", "overwrite", "line", ".", "See", "Overwrite", "for", "details", "." ]
1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410
https://github.com/deis/deis/blob/1d9e59fbdbfc9d7767f77c2e0097e335b0fcd410/pkg/prettyprint/colorizer.go#L162-L164
142,982
hashicorp/go-getter
get.go
Get
func Get(dst, src string, opts ...ClientOption) error { return (&Client{ Src: src, Dst: dst, Dir: true, Options: opts, }).Get() }
go
func Get(dst, src string, opts ...ClientOption) error { return (&Client{ Src: src, Dst: dst, Dir: true, Options: opts, }).Get() }
[ "func", "Get", "(", "dst", ",", "src", "string", ",", "opts", "...", "ClientOption", ")", "error", "{", "return", "(", "&", "Client", "{", "Src", ":", "src", ",", "Dst", ":", "dst", ",", "Dir", ":", "true", ",", "Options", ":", "opts", ",", "}", ")", ".", "Get", "(", ")", "\n", "}" ]
// Get downloads the directory specified by src into the folder specified by // dst. If dst already exists, Get will attempt to update it. // // src is a URL, whereas dst is always just a file path to a folder. This // folder doesn't need to exist. It will be created if it doesn't exist.
[ "Get", "downloads", "the", "directory", "specified", "by", "src", "into", "the", "folder", "specified", "by", "dst", ".", "If", "dst", "already", "exists", "Get", "will", "attempt", "to", "update", "it", ".", "src", "is", "a", "URL", "whereas", "dst", "is", "always", "just", "a", "file", "path", "to", "a", "folder", ".", "This", "folder", "doesn", "t", "need", "to", "exist", ".", "It", "will", "be", "created", "if", "it", "doesn", "t", "exist", "." ]
69dec094fde6ac8d2659bff743fc0b2096ccb54f
https://github.com/hashicorp/go-getter/blob/69dec094fde6ac8d2659bff743fc0b2096ccb54f/get.go#L83-L90
142,983
hashicorp/go-getter
get.go
GetAny
func GetAny(dst, src string, opts ...ClientOption) error { return (&Client{ Src: src, Dst: dst, Mode: ClientModeAny, Options: opts, }).Get() }
go
func GetAny(dst, src string, opts ...ClientOption) error { return (&Client{ Src: src, Dst: dst, Mode: ClientModeAny, Options: opts, }).Get() }
[ "func", "GetAny", "(", "dst", ",", "src", "string", ",", "opts", "...", "ClientOption", ")", "error", "{", "return", "(", "&", "Client", "{", "Src", ":", "src", ",", "Dst", ":", "dst", ",", "Mode", ":", "ClientModeAny", ",", "Options", ":", "opts", ",", "}", ")", ".", "Get", "(", ")", "\n", "}" ]
// GetAny downloads a URL into the given destination. Unlike Get or // GetFile, both directories and files are supported. // // dst must be a directory. If src is a file, it will be downloaded // into dst with the basename of the URL. If src is a directory or // archive, it will be unpacked directly into dst.
[ "GetAny", "downloads", "a", "URL", "into", "the", "given", "destination", ".", "Unlike", "Get", "or", "GetFile", "both", "directories", "and", "files", "are", "supported", ".", "dst", "must", "be", "a", "directory", ".", "If", "src", "is", "a", "file", "it", "will", "be", "downloaded", "into", "dst", "with", "the", "basename", "of", "the", "URL", ".", "If", "src", "is", "a", "directory", "or", "archive", "it", "will", "be", "unpacked", "directly", "into", "dst", "." ]
69dec094fde6ac8d2659bff743fc0b2096ccb54f
https://github.com/hashicorp/go-getter/blob/69dec094fde6ac8d2659bff743fc0b2096ccb54f/get.go#L98-L105
142,984
hashicorp/go-getter
get.go
getRunCommand
func getRunCommand(cmd *exec.Cmd) error { var buf bytes.Buffer cmd.Stdout = &buf cmd.Stderr = &buf err := cmd.Run() if err == nil { return nil } if exiterr, ok := err.(*exec.ExitError); ok { // The program has exited with an exit code != 0 if status, ok := exiterr.Sys().(syscall.WaitStatus); ok { return fmt.Errorf( "%s exited with %d: %s", cmd.Path, status.ExitStatus(), buf.String()) } } return fmt.Errorf("error running %s: %s", cmd.Path, buf.String()) }
go
func getRunCommand(cmd *exec.Cmd) error { var buf bytes.Buffer cmd.Stdout = &buf cmd.Stderr = &buf err := cmd.Run() if err == nil { return nil } if exiterr, ok := err.(*exec.ExitError); ok { // The program has exited with an exit code != 0 if status, ok := exiterr.Sys().(syscall.WaitStatus); ok { return fmt.Errorf( "%s exited with %d: %s", cmd.Path, status.ExitStatus(), buf.String()) } } return fmt.Errorf("error running %s: %s", cmd.Path, buf.String()) }
[ "func", "getRunCommand", "(", "cmd", "*", "exec", ".", "Cmd", ")", "error", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "cmd", ".", "Stdout", "=", "&", "buf", "\n", "cmd", ".", "Stderr", "=", "&", "buf", "\n", "err", ":=", "cmd", ".", "Run", "(", ")", "\n", "if", "err", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "if", "exiterr", ",", "ok", ":=", "err", ".", "(", "*", "exec", ".", "ExitError", ")", ";", "ok", "{", "// The program has exited with an exit code != 0", "if", "status", ",", "ok", ":=", "exiterr", ".", "Sys", "(", ")", ".", "(", "syscall", ".", "WaitStatus", ")", ";", "ok", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "cmd", ".", "Path", ",", "status", ".", "ExitStatus", "(", ")", ",", "buf", ".", "String", "(", ")", ")", "\n", "}", "\n", "}", "\n\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "cmd", ".", "Path", ",", "buf", ".", "String", "(", ")", ")", "\n", "}" ]
// getRunCommand is a helper that will run a command and capture the output // in the case an error happens.
[ "getRunCommand", "is", "a", "helper", "that", "will", "run", "a", "command", "and", "capture", "the", "output", "in", "the", "case", "an", "error", "happens", "." ]
69dec094fde6ac8d2659bff743fc0b2096ccb54f
https://github.com/hashicorp/go-getter/blob/69dec094fde6ac8d2659bff743fc0b2096ccb54f/get.go#L120-L140
142,985
hashicorp/go-getter
client_option_progress.go
WithProgress
func WithProgress(pl ProgressTracker) func(*Client) error { return func(c *Client) error { c.ProgressListener = pl return nil } }
go
func WithProgress(pl ProgressTracker) func(*Client) error { return func(c *Client) error { c.ProgressListener = pl return nil } }
[ "func", "WithProgress", "(", "pl", "ProgressTracker", ")", "func", "(", "*", "Client", ")", "error", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "c", ".", "ProgressListener", "=", "pl", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// WithProgress allows for a user to track // the progress of a download. // For example by displaying a progress bar with // current download. // Not all getters have progress support yet.
[ "WithProgress", "allows", "for", "a", "user", "to", "track", "the", "progress", "of", "a", "download", ".", "For", "example", "by", "displaying", "a", "progress", "bar", "with", "current", "download", ".", "Not", "all", "getters", "have", "progress", "support", "yet", "." ]
69dec094fde6ac8d2659bff743fc0b2096ccb54f
https://github.com/hashicorp/go-getter/blob/69dec094fde6ac8d2659bff743fc0b2096ccb54f/client_option_progress.go#L12-L17
142,986
hashicorp/go-getter
get_git.go
fetchSubmodules
func (g *GitGetter) fetchSubmodules(ctx context.Context, dst, sshKeyFile string, depth int) error { args := []string{"submodule", "update", "--init", "--recursive"} if depth > 0 { args = append(args, "--depth", strconv.Itoa(depth)) } cmd := exec.CommandContext(ctx, "git", args...) cmd.Dir = dst setupGitEnv(cmd, sshKeyFile) return getRunCommand(cmd) }
go
func (g *GitGetter) fetchSubmodules(ctx context.Context, dst, sshKeyFile string, depth int) error { args := []string{"submodule", "update", "--init", "--recursive"} if depth > 0 { args = append(args, "--depth", strconv.Itoa(depth)) } cmd := exec.CommandContext(ctx, "git", args...) cmd.Dir = dst setupGitEnv(cmd, sshKeyFile) return getRunCommand(cmd) }
[ "func", "(", "g", "*", "GitGetter", ")", "fetchSubmodules", "(", "ctx", "context", ".", "Context", ",", "dst", ",", "sshKeyFile", "string", ",", "depth", "int", ")", "error", "{", "args", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", "\n", "if", "depth", ">", "0", "{", "args", "=", "append", "(", "args", ",", "\"", "\"", ",", "strconv", ".", "Itoa", "(", "depth", ")", ")", "\n", "}", "\n", "cmd", ":=", "exec", ".", "CommandContext", "(", "ctx", ",", "\"", "\"", ",", "args", "...", ")", "\n", "cmd", ".", "Dir", "=", "dst", "\n", "setupGitEnv", "(", "cmd", ",", "sshKeyFile", ")", "\n", "return", "getRunCommand", "(", "cmd", ")", "\n", "}" ]
// fetchSubmodules downloads any configured submodules recursively.
[ "fetchSubmodules", "downloads", "any", "configured", "submodules", "recursively", "." ]
69dec094fde6ac8d2659bff743fc0b2096ccb54f
https://github.com/hashicorp/go-getter/blob/69dec094fde6ac8d2659bff743fc0b2096ccb54f/get_git.go#L216-L225
142,987
hashicorp/go-getter
get_git.go
setupGitEnv
func setupGitEnv(cmd *exec.Cmd, sshKeyFile string) { const gitSSHCommand = "GIT_SSH_COMMAND=" var sshCmd []string // If we have an existing GIT_SSH_COMMAND, we need to append our options. // We will also remove our old entry to make sure the behavior is the same // with versions of Go < 1.9. env := os.Environ() for i, v := range env { if strings.HasPrefix(v, gitSSHCommand) && len(v) > len(gitSSHCommand) { sshCmd = []string{v} env[i], env[len(env)-1] = env[len(env)-1], env[i] env = env[:len(env)-1] break } } if len(sshCmd) == 0 { sshCmd = []string{gitSSHCommand + "ssh"} } if sshKeyFile != "" { // We have an SSH key temp file configured, tell ssh about this. if runtime.GOOS == "windows" { sshKeyFile = strings.Replace(sshKeyFile, `\`, `/`, -1) } sshCmd = append(sshCmd, "-i", sshKeyFile) } env = append(env, strings.Join(sshCmd, " ")) cmd.Env = env }
go
func setupGitEnv(cmd *exec.Cmd, sshKeyFile string) { const gitSSHCommand = "GIT_SSH_COMMAND=" var sshCmd []string // If we have an existing GIT_SSH_COMMAND, we need to append our options. // We will also remove our old entry to make sure the behavior is the same // with versions of Go < 1.9. env := os.Environ() for i, v := range env { if strings.HasPrefix(v, gitSSHCommand) && len(v) > len(gitSSHCommand) { sshCmd = []string{v} env[i], env[len(env)-1] = env[len(env)-1], env[i] env = env[:len(env)-1] break } } if len(sshCmd) == 0 { sshCmd = []string{gitSSHCommand + "ssh"} } if sshKeyFile != "" { // We have an SSH key temp file configured, tell ssh about this. if runtime.GOOS == "windows" { sshKeyFile = strings.Replace(sshKeyFile, `\`, `/`, -1) } sshCmd = append(sshCmd, "-i", sshKeyFile) } env = append(env, strings.Join(sshCmd, " ")) cmd.Env = env }
[ "func", "setupGitEnv", "(", "cmd", "*", "exec", ".", "Cmd", ",", "sshKeyFile", "string", ")", "{", "const", "gitSSHCommand", "=", "\"", "\"", "\n", "var", "sshCmd", "[", "]", "string", "\n\n", "// If we have an existing GIT_SSH_COMMAND, we need to append our options.", "// We will also remove our old entry to make sure the behavior is the same", "// with versions of Go < 1.9.", "env", ":=", "os", ".", "Environ", "(", ")", "\n", "for", "i", ",", "v", ":=", "range", "env", "{", "if", "strings", ".", "HasPrefix", "(", "v", ",", "gitSSHCommand", ")", "&&", "len", "(", "v", ")", ">", "len", "(", "gitSSHCommand", ")", "{", "sshCmd", "=", "[", "]", "string", "{", "v", "}", "\n\n", "env", "[", "i", "]", ",", "env", "[", "len", "(", "env", ")", "-", "1", "]", "=", "env", "[", "len", "(", "env", ")", "-", "1", "]", ",", "env", "[", "i", "]", "\n", "env", "=", "env", "[", ":", "len", "(", "env", ")", "-", "1", "]", "\n", "break", "\n", "}", "\n", "}", "\n\n", "if", "len", "(", "sshCmd", ")", "==", "0", "{", "sshCmd", "=", "[", "]", "string", "{", "gitSSHCommand", "+", "\"", "\"", "}", "\n", "}", "\n\n", "if", "sshKeyFile", "!=", "\"", "\"", "{", "// We have an SSH key temp file configured, tell ssh about this.", "if", "runtime", ".", "GOOS", "==", "\"", "\"", "{", "sshKeyFile", "=", "strings", ".", "Replace", "(", "sshKeyFile", ",", "`\\`", ",", "`/`", ",", "-", "1", ")", "\n", "}", "\n", "sshCmd", "=", "append", "(", "sshCmd", ",", "\"", "\"", ",", "sshKeyFile", ")", "\n", "}", "\n\n", "env", "=", "append", "(", "env", ",", "strings", ".", "Join", "(", "sshCmd", ",", "\"", "\"", ")", ")", "\n", "cmd", ".", "Env", "=", "env", "\n", "}" ]
// setupGitEnv sets up the environment for the given command. This is used to // pass configuration data to git and ssh and enables advanced cloning methods.
[ "setupGitEnv", "sets", "up", "the", "environment", "for", "the", "given", "command", ".", "This", "is", "used", "to", "pass", "configuration", "data", "to", "git", "and", "ssh", "and", "enables", "advanced", "cloning", "methods", "." ]
69dec094fde6ac8d2659bff743fc0b2096ccb54f
https://github.com/hashicorp/go-getter/blob/69dec094fde6ac8d2659bff743fc0b2096ccb54f/get_git.go#L229-L261
142,988
hashicorp/go-getter
get_git.go
checkGitVersion
func checkGitVersion(min string) error { want, err := version.NewVersion(min) if err != nil { return err } out, err := exec.Command("git", "version").Output() if err != nil { return err } fields := strings.Fields(string(out)) if len(fields) < 3 { return fmt.Errorf("Unexpected 'git version' output: %q", string(out)) } v := fields[2] if runtime.GOOS == "windows" && strings.Contains(v, ".windows.") { // on windows, git version will return for example: // git version 2.20.1.windows.1 // Which does not follow the semantic versionning specs // https://semver.org. We remove that part in order for // go-version to not error. v = v[:strings.Index(v, ".windows.")] } have, err := version.NewVersion(v) if err != nil { return err } if have.LessThan(want) { return fmt.Errorf("Required git version = %s, have %s", want, have) } return nil }
go
func checkGitVersion(min string) error { want, err := version.NewVersion(min) if err != nil { return err } out, err := exec.Command("git", "version").Output() if err != nil { return err } fields := strings.Fields(string(out)) if len(fields) < 3 { return fmt.Errorf("Unexpected 'git version' output: %q", string(out)) } v := fields[2] if runtime.GOOS == "windows" && strings.Contains(v, ".windows.") { // on windows, git version will return for example: // git version 2.20.1.windows.1 // Which does not follow the semantic versionning specs // https://semver.org. We remove that part in order for // go-version to not error. v = v[:strings.Index(v, ".windows.")] } have, err := version.NewVersion(v) if err != nil { return err } if have.LessThan(want) { return fmt.Errorf("Required git version = %s, have %s", want, have) } return nil }
[ "func", "checkGitVersion", "(", "min", "string", ")", "error", "{", "want", ",", "err", ":=", "version", ".", "NewVersion", "(", "min", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "out", ",", "err", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "\"", "\"", ")", ".", "Output", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fields", ":=", "strings", ".", "Fields", "(", "string", "(", "out", ")", ")", "\n", "if", "len", "(", "fields", ")", "<", "3", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "string", "(", "out", ")", ")", "\n", "}", "\n", "v", ":=", "fields", "[", "2", "]", "\n", "if", "runtime", ".", "GOOS", "==", "\"", "\"", "&&", "strings", ".", "Contains", "(", "v", ",", "\"", "\"", ")", "{", "// on windows, git version will return for example:", "// git version 2.20.1.windows.1", "// Which does not follow the semantic versionning specs", "// https://semver.org. We remove that part in order for", "// go-version to not error.", "v", "=", "v", "[", ":", "strings", ".", "Index", "(", "v", ",", "\"", "\"", ")", "]", "\n", "}", "\n\n", "have", ",", "err", ":=", "version", ".", "NewVersion", "(", "v", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "have", ".", "LessThan", "(", "want", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "want", ",", "have", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// checkGitVersion is used to check the version of git installed on the system // against a known minimum version. Returns an error if the installed version // is older than the given minimum.
[ "checkGitVersion", "is", "used", "to", "check", "the", "version", "of", "git", "installed", "on", "the", "system", "against", "a", "known", "minimum", "version", ".", "Returns", "an", "error", "if", "the", "installed", "version", "is", "older", "than", "the", "given", "minimum", "." ]
69dec094fde6ac8d2659bff743fc0b2096ccb54f
https://github.com/hashicorp/go-getter/blob/69dec094fde6ac8d2659bff743fc0b2096ccb54f/get_git.go#L266-L301
142,989
hashicorp/go-getter
get_http.go
getSubdir
func (g *HttpGetter) getSubdir(ctx context.Context, dst, source, subDir string) error { // Create a temporary directory to store the full source. This has to be // a non-existent directory. td, tdcloser, err := safetemp.Dir("", "getter") if err != nil { return err } defer tdcloser.Close() var opts []ClientOption if g.client != nil { opts = g.client.Options } // Download that into the given directory if err := Get(td, source, opts...); err != nil { return err } // Process any globbing sourcePath, err := SubdirGlob(td, subDir) if err != nil { return err } // Make sure the subdir path actually exists if _, err := os.Stat(sourcePath); err != nil { return fmt.Errorf( "Error downloading %s: %s", source, err) } // Copy the subdirectory into our actual destination. if err := os.RemoveAll(dst); err != nil { return err } // Make the final destination if err := os.MkdirAll(dst, 0755); err != nil { return err } return copyDir(ctx, dst, sourcePath, false) }
go
func (g *HttpGetter) getSubdir(ctx context.Context, dst, source, subDir string) error { // Create a temporary directory to store the full source. This has to be // a non-existent directory. td, tdcloser, err := safetemp.Dir("", "getter") if err != nil { return err } defer tdcloser.Close() var opts []ClientOption if g.client != nil { opts = g.client.Options } // Download that into the given directory if err := Get(td, source, opts...); err != nil { return err } // Process any globbing sourcePath, err := SubdirGlob(td, subDir) if err != nil { return err } // Make sure the subdir path actually exists if _, err := os.Stat(sourcePath); err != nil { return fmt.Errorf( "Error downloading %s: %s", source, err) } // Copy the subdirectory into our actual destination. if err := os.RemoveAll(dst); err != nil { return err } // Make the final destination if err := os.MkdirAll(dst, 0755); err != nil { return err } return copyDir(ctx, dst, sourcePath, false) }
[ "func", "(", "g", "*", "HttpGetter", ")", "getSubdir", "(", "ctx", "context", ".", "Context", ",", "dst", ",", "source", ",", "subDir", "string", ")", "error", "{", "// Create a temporary directory to store the full source. This has to be", "// a non-existent directory.", "td", ",", "tdcloser", ",", "err", ":=", "safetemp", ".", "Dir", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "tdcloser", ".", "Close", "(", ")", "\n\n", "var", "opts", "[", "]", "ClientOption", "\n", "if", "g", ".", "client", "!=", "nil", "{", "opts", "=", "g", ".", "client", ".", "Options", "\n", "}", "\n", "// Download that into the given directory", "if", "err", ":=", "Get", "(", "td", ",", "source", ",", "opts", "...", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Process any globbing", "sourcePath", ",", "err", ":=", "SubdirGlob", "(", "td", ",", "subDir", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Make sure the subdir path actually exists", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "sourcePath", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "source", ",", "err", ")", "\n", "}", "\n\n", "// Copy the subdirectory into our actual destination.", "if", "err", ":=", "os", ".", "RemoveAll", "(", "dst", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Make the final destination", "if", "err", ":=", "os", ".", "MkdirAll", "(", "dst", ",", "0755", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "copyDir", "(", "ctx", ",", "dst", ",", "sourcePath", ",", "false", ")", "\n", "}" ]
// getSubdir downloads the source into the destination, but with // the proper subdir.
[ "getSubdir", "downloads", "the", "source", "into", "the", "destination", "but", "with", "the", "proper", "subdir", "." ]
69dec094fde6ac8d2659bff743fc0b2096ccb54f
https://github.com/hashicorp/go-getter/blob/69dec094fde6ac8d2659bff743fc0b2096ccb54f/get_http.go#L220-L261
142,990
hashicorp/go-getter
get_http.go
parseMeta
func (g *HttpGetter) parseMeta(r io.Reader) (string, error) { d := xml.NewDecoder(r) d.CharsetReader = charsetReader d.Strict = false var err error var t xml.Token for { t, err = d.Token() if err != nil { if err == io.EOF { err = nil } return "", err } if e, ok := t.(xml.StartElement); ok && strings.EqualFold(e.Name.Local, "body") { return "", nil } if e, ok := t.(xml.EndElement); ok && strings.EqualFold(e.Name.Local, "head") { return "", nil } e, ok := t.(xml.StartElement) if !ok || !strings.EqualFold(e.Name.Local, "meta") { continue } if attrValue(e.Attr, "name") != "terraform-get" { continue } if f := attrValue(e.Attr, "content"); f != "" { return f, nil } } }
go
func (g *HttpGetter) parseMeta(r io.Reader) (string, error) { d := xml.NewDecoder(r) d.CharsetReader = charsetReader d.Strict = false var err error var t xml.Token for { t, err = d.Token() if err != nil { if err == io.EOF { err = nil } return "", err } if e, ok := t.(xml.StartElement); ok && strings.EqualFold(e.Name.Local, "body") { return "", nil } if e, ok := t.(xml.EndElement); ok && strings.EqualFold(e.Name.Local, "head") { return "", nil } e, ok := t.(xml.StartElement) if !ok || !strings.EqualFold(e.Name.Local, "meta") { continue } if attrValue(e.Attr, "name") != "terraform-get" { continue } if f := attrValue(e.Attr, "content"); f != "" { return f, nil } } }
[ "func", "(", "g", "*", "HttpGetter", ")", "parseMeta", "(", "r", "io", ".", "Reader", ")", "(", "string", ",", "error", ")", "{", "d", ":=", "xml", ".", "NewDecoder", "(", "r", ")", "\n", "d", ".", "CharsetReader", "=", "charsetReader", "\n", "d", ".", "Strict", "=", "false", "\n", "var", "err", "error", "\n", "var", "t", "xml", ".", "Token", "\n", "for", "{", "t", ",", "err", "=", "d", ".", "Token", "(", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "io", ".", "EOF", "{", "err", "=", "nil", "\n", "}", "\n", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "if", "e", ",", "ok", ":=", "t", ".", "(", "xml", ".", "StartElement", ")", ";", "ok", "&&", "strings", ".", "EqualFold", "(", "e", ".", "Name", ".", "Local", ",", "\"", "\"", ")", "{", "return", "\"", "\"", ",", "nil", "\n", "}", "\n", "if", "e", ",", "ok", ":=", "t", ".", "(", "xml", ".", "EndElement", ")", ";", "ok", "&&", "strings", ".", "EqualFold", "(", "e", ".", "Name", ".", "Local", ",", "\"", "\"", ")", "{", "return", "\"", "\"", ",", "nil", "\n", "}", "\n", "e", ",", "ok", ":=", "t", ".", "(", "xml", ".", "StartElement", ")", "\n", "if", "!", "ok", "||", "!", "strings", ".", "EqualFold", "(", "e", ".", "Name", ".", "Local", ",", "\"", "\"", ")", "{", "continue", "\n", "}", "\n", "if", "attrValue", "(", "e", ".", "Attr", ",", "\"", "\"", ")", "!=", "\"", "\"", "{", "continue", "\n", "}", "\n", "if", "f", ":=", "attrValue", "(", "e", ".", "Attr", ",", "\"", "\"", ")", ";", "f", "!=", "\"", "\"", "{", "return", "f", ",", "nil", "\n", "}", "\n", "}", "\n", "}" ]
// parseMeta looks for the first meta tag in the given reader that // will give us the source URL.
[ "parseMeta", "looks", "for", "the", "first", "meta", "tag", "in", "the", "given", "reader", "that", "will", "give", "us", "the", "source", "URL", "." ]
69dec094fde6ac8d2659bff743fc0b2096ccb54f
https://github.com/hashicorp/go-getter/blob/69dec094fde6ac8d2659bff743fc0b2096ccb54f/get_http.go#L265-L296
142,991
hashicorp/go-getter
cmd/go-getter/progress_tracking.go
TrackProgress
func (cpb *ProgressBar) TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) io.ReadCloser { cpb.lock.Lock() defer cpb.lock.Unlock() newPb := pb.New64(totalSize) newPb.Set64(currentSize) ProgressBarConfig(newPb, filepath.Base(src)) if cpb.pool == nil { cpb.pool = pb.NewPool() cpb.pool.Start() } cpb.pool.Add(newPb) reader := newPb.NewProxyReader(stream) cpb.pbs++ return &readCloser{ Reader: reader, close: func() error { cpb.lock.Lock() defer cpb.lock.Unlock() newPb.Finish() cpb.pbs-- if cpb.pbs <= 0 { cpb.pool.Stop() cpb.pool = nil } return nil }, } }
go
func (cpb *ProgressBar) TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) io.ReadCloser { cpb.lock.Lock() defer cpb.lock.Unlock() newPb := pb.New64(totalSize) newPb.Set64(currentSize) ProgressBarConfig(newPb, filepath.Base(src)) if cpb.pool == nil { cpb.pool = pb.NewPool() cpb.pool.Start() } cpb.pool.Add(newPb) reader := newPb.NewProxyReader(stream) cpb.pbs++ return &readCloser{ Reader: reader, close: func() error { cpb.lock.Lock() defer cpb.lock.Unlock() newPb.Finish() cpb.pbs-- if cpb.pbs <= 0 { cpb.pool.Stop() cpb.pool = nil } return nil }, } }
[ "func", "(", "cpb", "*", "ProgressBar", ")", "TrackProgress", "(", "src", "string", ",", "currentSize", ",", "totalSize", "int64", ",", "stream", "io", ".", "ReadCloser", ")", "io", ".", "ReadCloser", "{", "cpb", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "cpb", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "newPb", ":=", "pb", ".", "New64", "(", "totalSize", ")", "\n", "newPb", ".", "Set64", "(", "currentSize", ")", "\n", "ProgressBarConfig", "(", "newPb", ",", "filepath", ".", "Base", "(", "src", ")", ")", "\n", "if", "cpb", ".", "pool", "==", "nil", "{", "cpb", ".", "pool", "=", "pb", ".", "NewPool", "(", ")", "\n", "cpb", ".", "pool", ".", "Start", "(", ")", "\n", "}", "\n", "cpb", ".", "pool", ".", "Add", "(", "newPb", ")", "\n", "reader", ":=", "newPb", ".", "NewProxyReader", "(", "stream", ")", "\n\n", "cpb", ".", "pbs", "++", "\n", "return", "&", "readCloser", "{", "Reader", ":", "reader", ",", "close", ":", "func", "(", ")", "error", "{", "cpb", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "cpb", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "newPb", ".", "Finish", "(", ")", "\n", "cpb", ".", "pbs", "--", "\n", "if", "cpb", ".", "pbs", "<=", "0", "{", "cpb", ".", "pool", ".", "Stop", "(", ")", "\n", "cpb", ".", "pool", "=", "nil", "\n", "}", "\n", "return", "nil", "\n", "}", ",", "}", "\n", "}" ]
// TrackProgress instantiates a new progress bar that will // display the progress of stream until closed. // total can be 0.
[ "TrackProgress", "instantiates", "a", "new", "progress", "bar", "that", "will", "display", "the", "progress", "of", "stream", "until", "closed", ".", "total", "can", "be", "0", "." ]
69dec094fde6ac8d2659bff743fc0b2096ccb54f
https://github.com/hashicorp/go-getter/blob/69dec094fde6ac8d2659bff743fc0b2096ccb54f/cmd/go-getter/progress_tracking.go#L40-L70
142,992
hashicorp/go-getter
detect_ssh.go
detectSSH
func detectSSH(src string) (*url.URL, error) { matched := sshPattern.FindStringSubmatch(src) if matched == nil { return nil, nil } user := matched[1] host := matched[2] path := matched[3] qidx := strings.Index(path, "?") if qidx == -1 { qidx = len(path) } var u url.URL u.Scheme = "ssh" u.User = url.User(user) u.Host = host u.Path = path[0:qidx] if qidx < len(path) { q, err := url.ParseQuery(path[qidx+1:]) if err != nil { return nil, fmt.Errorf("error parsing GitHub SSH URL: %s", err) } u.RawQuery = q.Encode() } return &u, nil }
go
func detectSSH(src string) (*url.URL, error) { matched := sshPattern.FindStringSubmatch(src) if matched == nil { return nil, nil } user := matched[1] host := matched[2] path := matched[3] qidx := strings.Index(path, "?") if qidx == -1 { qidx = len(path) } var u url.URL u.Scheme = "ssh" u.User = url.User(user) u.Host = host u.Path = path[0:qidx] if qidx < len(path) { q, err := url.ParseQuery(path[qidx+1:]) if err != nil { return nil, fmt.Errorf("error parsing GitHub SSH URL: %s", err) } u.RawQuery = q.Encode() } return &u, nil }
[ "func", "detectSSH", "(", "src", "string", ")", "(", "*", "url", ".", "URL", ",", "error", ")", "{", "matched", ":=", "sshPattern", ".", "FindStringSubmatch", "(", "src", ")", "\n", "if", "matched", "==", "nil", "{", "return", "nil", ",", "nil", "\n", "}", "\n\n", "user", ":=", "matched", "[", "1", "]", "\n", "host", ":=", "matched", "[", "2", "]", "\n", "path", ":=", "matched", "[", "3", "]", "\n", "qidx", ":=", "strings", ".", "Index", "(", "path", ",", "\"", "\"", ")", "\n", "if", "qidx", "==", "-", "1", "{", "qidx", "=", "len", "(", "path", ")", "\n", "}", "\n\n", "var", "u", "url", ".", "URL", "\n", "u", ".", "Scheme", "=", "\"", "\"", "\n", "u", ".", "User", "=", "url", ".", "User", "(", "user", ")", "\n", "u", ".", "Host", "=", "host", "\n", "u", ".", "Path", "=", "path", "[", "0", ":", "qidx", "]", "\n", "if", "qidx", "<", "len", "(", "path", ")", "{", "q", ",", "err", ":=", "url", ".", "ParseQuery", "(", "path", "[", "qidx", "+", "1", ":", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "u", ".", "RawQuery", "=", "q", ".", "Encode", "(", ")", "\n", "}", "\n\n", "return", "&", "u", ",", "nil", "\n", "}" ]
// detectSSH determines if the src string matches an SSH-like URL and // converts it into a net.URL compatible string. This returns nil if the // string doesn't match the SSH pattern. // // This function is tested indirectly via detect_git_test.go
[ "detectSSH", "determines", "if", "the", "src", "string", "matches", "an", "SSH", "-", "like", "URL", "and", "converts", "it", "into", "a", "net", ".", "URL", "compatible", "string", ".", "This", "returns", "nil", "if", "the", "string", "doesn", "t", "match", "the", "SSH", "pattern", ".", "This", "function", "is", "tested", "indirectly", "via", "detect_git_test", ".", "go" ]
69dec094fde6ac8d2659bff743fc0b2096ccb54f
https://github.com/hashicorp/go-getter/blob/69dec094fde6ac8d2659bff743fc0b2096ccb54f/detect_ssh.go#L21-L49
142,993
hashicorp/go-getter
get_hg.go
GetFile
func (g *HgGetter) GetFile(dst string, u *url.URL) error { // Create a temporary directory to store the full source. This has to be // a non-existent directory. td, tdcloser, err := safetemp.Dir("", "getter") if err != nil { return err } defer tdcloser.Close() // Get the filename, and strip the filename from the URL so we can // just get the repository directly. filename := filepath.Base(u.Path) u.Path = filepath.ToSlash(filepath.Dir(u.Path)) // If we're on Windows, we need to set the host to "localhost" for hg if runtime.GOOS == "windows" { u.Host = "localhost" } // Get the full repository if err := g.Get(td, u); err != nil { return err } // Copy the single file u, err = urlhelper.Parse(fmtFileURL(filepath.Join(td, filename))) if err != nil { return err } fg := &FileGetter{Copy: true, getter: g.getter} return fg.GetFile(dst, u) }
go
func (g *HgGetter) GetFile(dst string, u *url.URL) error { // Create a temporary directory to store the full source. This has to be // a non-existent directory. td, tdcloser, err := safetemp.Dir("", "getter") if err != nil { return err } defer tdcloser.Close() // Get the filename, and strip the filename from the URL so we can // just get the repository directly. filename := filepath.Base(u.Path) u.Path = filepath.ToSlash(filepath.Dir(u.Path)) // If we're on Windows, we need to set the host to "localhost" for hg if runtime.GOOS == "windows" { u.Host = "localhost" } // Get the full repository if err := g.Get(td, u); err != nil { return err } // Copy the single file u, err = urlhelper.Parse(fmtFileURL(filepath.Join(td, filename))) if err != nil { return err } fg := &FileGetter{Copy: true, getter: g.getter} return fg.GetFile(dst, u) }
[ "func", "(", "g", "*", "HgGetter", ")", "GetFile", "(", "dst", "string", ",", "u", "*", "url", ".", "URL", ")", "error", "{", "// Create a temporary directory to store the full source. This has to be", "// a non-existent directory.", "td", ",", "tdcloser", ",", "err", ":=", "safetemp", ".", "Dir", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "tdcloser", ".", "Close", "(", ")", "\n\n", "// Get the filename, and strip the filename from the URL so we can", "// just get the repository directly.", "filename", ":=", "filepath", ".", "Base", "(", "u", ".", "Path", ")", "\n", "u", ".", "Path", "=", "filepath", ".", "ToSlash", "(", "filepath", ".", "Dir", "(", "u", ".", "Path", ")", ")", "\n\n", "// If we're on Windows, we need to set the host to \"localhost\" for hg", "if", "runtime", ".", "GOOS", "==", "\"", "\"", "{", "u", ".", "Host", "=", "\"", "\"", "\n", "}", "\n\n", "// Get the full repository", "if", "err", ":=", "g", ".", "Get", "(", "td", ",", "u", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Copy the single file", "u", ",", "err", "=", "urlhelper", ".", "Parse", "(", "fmtFileURL", "(", "filepath", ".", "Join", "(", "td", ",", "filename", ")", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "fg", ":=", "&", "FileGetter", "{", "Copy", ":", "true", ",", "getter", ":", "g", ".", "getter", "}", "\n", "return", "fg", ".", "GetFile", "(", "dst", ",", "u", ")", "\n", "}" ]
// GetFile for Hg doesn't support updating at this time. It will download // the file every time.
[ "GetFile", "for", "Hg", "doesn", "t", "support", "updating", "at", "this", "time", ".", "It", "will", "download", "the", "file", "every", "time", "." ]
69dec094fde6ac8d2659bff743fc0b2096ccb54f
https://github.com/hashicorp/go-getter/blob/69dec094fde6ac8d2659bff743fc0b2096ccb54f/get_hg.go#L70-L102
142,994
hashicorp/go-getter
folder_storage.go
Dir
func (s *FolderStorage) Dir(key string) (d string, e bool, err error) { d = s.dir(key) _, err = os.Stat(d) if err == nil { // Directory exists e = true return } if os.IsNotExist(err) { // Directory doesn't exist d = "" e = false err = nil return } // An error d = "" e = false return }
go
func (s *FolderStorage) Dir(key string) (d string, e bool, err error) { d = s.dir(key) _, err = os.Stat(d) if err == nil { // Directory exists e = true return } if os.IsNotExist(err) { // Directory doesn't exist d = "" e = false err = nil return } // An error d = "" e = false return }
[ "func", "(", "s", "*", "FolderStorage", ")", "Dir", "(", "key", "string", ")", "(", "d", "string", ",", "e", "bool", ",", "err", "error", ")", "{", "d", "=", "s", ".", "dir", "(", "key", ")", "\n", "_", ",", "err", "=", "os", ".", "Stat", "(", "d", ")", "\n", "if", "err", "==", "nil", "{", "// Directory exists", "e", "=", "true", "\n", "return", "\n", "}", "\n", "if", "os", ".", "IsNotExist", "(", "err", ")", "{", "// Directory doesn't exist", "d", "=", "\"", "\"", "\n", "e", "=", "false", "\n", "err", "=", "nil", "\n", "return", "\n", "}", "\n\n", "// An error", "d", "=", "\"", "\"", "\n", "e", "=", "false", "\n", "return", "\n", "}" ]
// Dir implements Storage.Dir
[ "Dir", "implements", "Storage", ".", "Dir" ]
69dec094fde6ac8d2659bff743fc0b2096ccb54f
https://github.com/hashicorp/go-getter/blob/69dec094fde6ac8d2659bff743fc0b2096ccb54f/folder_storage.go#L19-L39
142,995
hashicorp/go-getter
folder_storage.go
dir
func (s *FolderStorage) dir(key string) string { sum := md5.Sum([]byte(key)) return filepath.Join(s.StorageDir, hex.EncodeToString(sum[:])) }
go
func (s *FolderStorage) dir(key string) string { sum := md5.Sum([]byte(key)) return filepath.Join(s.StorageDir, hex.EncodeToString(sum[:])) }
[ "func", "(", "s", "*", "FolderStorage", ")", "dir", "(", "key", "string", ")", "string", "{", "sum", ":=", "md5", ".", "Sum", "(", "[", "]", "byte", "(", "key", ")", ")", "\n", "return", "filepath", ".", "Join", "(", "s", ".", "StorageDir", ",", "hex", ".", "EncodeToString", "(", "sum", "[", ":", "]", ")", ")", "\n", "}" ]
// dir returns the directory name internally that we'll use to map to // internally.
[ "dir", "returns", "the", "directory", "name", "internally", "that", "we", "ll", "use", "to", "map", "to", "internally", "." ]
69dec094fde6ac8d2659bff743fc0b2096ccb54f
https://github.com/hashicorp/go-getter/blob/69dec094fde6ac8d2659bff743fc0b2096ccb54f/folder_storage.go#L62-L65
142,996
hashicorp/go-getter
get_file_copy.go
Copy
func Copy(ctx context.Context, dst io.Writer, src io.Reader) (int64, error) { // Copy will call the Reader and Writer interface multiple time, in order // to copy by chunk (avoiding loading the whole file in memory). return io.Copy(dst, readerFunc(func(p []byte) (int, error) { select { case <-ctx.Done(): // context has been canceled // stop process and propagate "context canceled" error return 0, ctx.Err() default: // otherwise just run default io.Reader implementation return src.Read(p) } })) }
go
func Copy(ctx context.Context, dst io.Writer, src io.Reader) (int64, error) { // Copy will call the Reader and Writer interface multiple time, in order // to copy by chunk (avoiding loading the whole file in memory). return io.Copy(dst, readerFunc(func(p []byte) (int, error) { select { case <-ctx.Done(): // context has been canceled // stop process and propagate "context canceled" error return 0, ctx.Err() default: // otherwise just run default io.Reader implementation return src.Read(p) } })) }
[ "func", "Copy", "(", "ctx", "context", ".", "Context", ",", "dst", "io", ".", "Writer", ",", "src", "io", ".", "Reader", ")", "(", "int64", ",", "error", ")", "{", "// Copy will call the Reader and Writer interface multiple time, in order", "// to copy by chunk (avoiding loading the whole file in memory).", "return", "io", ".", "Copy", "(", "dst", ",", "readerFunc", "(", "func", "(", "p", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "select", "{", "case", "<-", "ctx", ".", "Done", "(", ")", ":", "// context has been canceled", "// stop process and propagate \"context canceled\" error", "return", "0", ",", "ctx", ".", "Err", "(", ")", "\n", "default", ":", "// otherwise just run default io.Reader implementation", "return", "src", ".", "Read", "(", "p", ")", "\n", "}", "\n", "}", ")", ")", "\n", "}" ]
// Copy is a io.Copy cancellable by context
[ "Copy", "is", "a", "io", ".", "Copy", "cancellable", "by", "context" ]
69dec094fde6ac8d2659bff743fc0b2096ccb54f
https://github.com/hashicorp/go-getter/blob/69dec094fde6ac8d2659bff743fc0b2096ccb54f/get_file_copy.go#L14-L29
142,997
hashicorp/go-getter
netrc.go
addAuthFromNetrc
func addAuthFromNetrc(u *url.URL) error { // If the URL already has auth information, do nothing if u.User != nil && u.User.Username() != "" { return nil } // Get the netrc file path path := os.Getenv("NETRC") if path == "" { filename := ".netrc" if runtime.GOOS == "windows" { filename = "_netrc" } var err error path, err = homedir.Expand("~/" + filename) if err != nil { return err } } // If the file is not a file, then do nothing if fi, err := os.Stat(path); err != nil { // File doesn't exist, do nothing if os.IsNotExist(err) { return nil } // Some other error! return err } else if fi.IsDir() { // File is directory, ignore return nil } // Load up the netrc file net, err := netrc.ParseFile(path) if err != nil { return fmt.Errorf("Error parsing netrc file at %q: %s", path, err) } machine := net.FindMachine(u.Host) if machine == nil { // Machine not found, no problem return nil } // Set the user info u.User = url.UserPassword(machine.Login, machine.Password) return nil }
go
func addAuthFromNetrc(u *url.URL) error { // If the URL already has auth information, do nothing if u.User != nil && u.User.Username() != "" { return nil } // Get the netrc file path path := os.Getenv("NETRC") if path == "" { filename := ".netrc" if runtime.GOOS == "windows" { filename = "_netrc" } var err error path, err = homedir.Expand("~/" + filename) if err != nil { return err } } // If the file is not a file, then do nothing if fi, err := os.Stat(path); err != nil { // File doesn't exist, do nothing if os.IsNotExist(err) { return nil } // Some other error! return err } else if fi.IsDir() { // File is directory, ignore return nil } // Load up the netrc file net, err := netrc.ParseFile(path) if err != nil { return fmt.Errorf("Error parsing netrc file at %q: %s", path, err) } machine := net.FindMachine(u.Host) if machine == nil { // Machine not found, no problem return nil } // Set the user info u.User = url.UserPassword(machine.Login, machine.Password) return nil }
[ "func", "addAuthFromNetrc", "(", "u", "*", "url", ".", "URL", ")", "error", "{", "// If the URL already has auth information, do nothing", "if", "u", ".", "User", "!=", "nil", "&&", "u", ".", "User", ".", "Username", "(", ")", "!=", "\"", "\"", "{", "return", "nil", "\n", "}", "\n\n", "// Get the netrc file path", "path", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "path", "==", "\"", "\"", "{", "filename", ":=", "\"", "\"", "\n", "if", "runtime", ".", "GOOS", "==", "\"", "\"", "{", "filename", "=", "\"", "\"", "\n", "}", "\n\n", "var", "err", "error", "\n", "path", ",", "err", "=", "homedir", ".", "Expand", "(", "\"", "\"", "+", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "// If the file is not a file, then do nothing", "if", "fi", ",", "err", ":=", "os", ".", "Stat", "(", "path", ")", ";", "err", "!=", "nil", "{", "// File doesn't exist, do nothing", "if", "os", ".", "IsNotExist", "(", "err", ")", "{", "return", "nil", "\n", "}", "\n\n", "// Some other error!", "return", "err", "\n", "}", "else", "if", "fi", ".", "IsDir", "(", ")", "{", "// File is directory, ignore", "return", "nil", "\n", "}", "\n\n", "// Load up the netrc file", "net", ",", "err", ":=", "netrc", ".", "ParseFile", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "path", ",", "err", ")", "\n", "}", "\n\n", "machine", ":=", "net", ".", "FindMachine", "(", "u", ".", "Host", ")", "\n", "if", "machine", "==", "nil", "{", "// Machine not found, no problem", "return", "nil", "\n", "}", "\n\n", "// Set the user info", "u", ".", "User", "=", "url", ".", "UserPassword", "(", "machine", ".", "Login", ",", "machine", ".", "Password", ")", "\n", "return", "nil", "\n", "}" ]
// addAuthFromNetrc adds auth information to the URL from the user's // netrc file if it can be found. This will only add the auth info // if the URL doesn't already have auth info specified and the // the username is blank.
[ "addAuthFromNetrc", "adds", "auth", "information", "to", "the", "URL", "from", "the", "user", "s", "netrc", "file", "if", "it", "can", "be", "found", ".", "This", "will", "only", "add", "the", "auth", "info", "if", "the", "URL", "doesn", "t", "already", "have", "auth", "info", "specified", "and", "the", "the", "username", "is", "blank", "." ]
69dec094fde6ac8d2659bff743fc0b2096ccb54f
https://github.com/hashicorp/go-getter/blob/69dec094fde6ac8d2659bff743fc0b2096ccb54f/netrc.go#L17-L67
142,998
hashicorp/go-getter
client_option.go
Configure
func (c *Client) Configure(opts ...ClientOption) error { if c.Ctx == nil { c.Ctx = context.Background() } c.Options = opts for _, opt := range opts { err := opt(c) if err != nil { return err } } // Default decompressor values if c.Decompressors == nil { c.Decompressors = Decompressors } // Default detector values if c.Detectors == nil { c.Detectors = Detectors } // Default getter values if c.Getters == nil { c.Getters = Getters } for _, getter := range c.Getters { getter.SetClient(c) } return nil }
go
func (c *Client) Configure(opts ...ClientOption) error { if c.Ctx == nil { c.Ctx = context.Background() } c.Options = opts for _, opt := range opts { err := opt(c) if err != nil { return err } } // Default decompressor values if c.Decompressors == nil { c.Decompressors = Decompressors } // Default detector values if c.Detectors == nil { c.Detectors = Detectors } // Default getter values if c.Getters == nil { c.Getters = Getters } for _, getter := range c.Getters { getter.SetClient(c) } return nil }
[ "func", "(", "c", "*", "Client", ")", "Configure", "(", "opts", "...", "ClientOption", ")", "error", "{", "if", "c", ".", "Ctx", "==", "nil", "{", "c", ".", "Ctx", "=", "context", ".", "Background", "(", ")", "\n", "}", "\n", "c", ".", "Options", "=", "opts", "\n", "for", "_", ",", "opt", ":=", "range", "opts", "{", "err", ":=", "opt", "(", "c", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "// Default decompressor values", "if", "c", ".", "Decompressors", "==", "nil", "{", "c", ".", "Decompressors", "=", "Decompressors", "\n", "}", "\n", "// Default detector values", "if", "c", ".", "Detectors", "==", "nil", "{", "c", ".", "Detectors", "=", "Detectors", "\n", "}", "\n", "// Default getter values", "if", "c", ".", "Getters", "==", "nil", "{", "c", ".", "Getters", "=", "Getters", "\n", "}", "\n\n", "for", "_", ",", "getter", ":=", "range", "c", ".", "Getters", "{", "getter", ".", "SetClient", "(", "c", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Configure configures a client with options.
[ "Configure", "configures", "a", "client", "with", "options", "." ]
69dec094fde6ac8d2659bff743fc0b2096ccb54f
https://github.com/hashicorp/go-getter/blob/69dec094fde6ac8d2659bff743fc0b2096ccb54f/client_option.go#L9-L37
142,999
hashicorp/go-getter
client_option.go
WithContext
func WithContext(ctx context.Context) func(*Client) error { return func(c *Client) error { c.Ctx = ctx return nil } }
go
func WithContext(ctx context.Context) func(*Client) error { return func(c *Client) error { c.Ctx = ctx return nil } }
[ "func", "WithContext", "(", "ctx", "context", ".", "Context", ")", "func", "(", "*", "Client", ")", "error", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "c", ".", "Ctx", "=", "ctx", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// WithContext allows to pass a context to operation // in order to be able to cancel a download in progress.
[ "WithContext", "allows", "to", "pass", "a", "context", "to", "operation", "in", "order", "to", "be", "able", "to", "cancel", "a", "download", "in", "progress", "." ]
69dec094fde6ac8d2659bff743fc0b2096ccb54f
https://github.com/hashicorp/go-getter/blob/69dec094fde6ac8d2659bff743fc0b2096ccb54f/client_option.go#L41-L46