mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
beam/examples/beamsh: 'emit' supports key=value syntax to compose arbitrary objects
Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
This commit is contained in:
parent
2b81fb8424
commit
6d9cdbf24f
1 changed files with 1 additions and 22 deletions
|
@ -452,7 +452,7 @@ func GetHandler(name string) Handler {
|
||||||
}
|
}
|
||||||
} else if name == "emit" {
|
} else if name == "emit" {
|
||||||
return func(args []string, in *net.UnixConn, out *net.UnixConn) {
|
return func(args []string, in *net.UnixConn, out *net.UnixConn) {
|
||||||
beam.Send(out, data.Empty().Set("foo", args[1:]...).Bytes(), nil)
|
beam.Send(out, data.Parse(args[1:]).Bytes(), nil)
|
||||||
}
|
}
|
||||||
} else if name == "print" {
|
} else if name == "print" {
|
||||||
return func(args []string, in *net.UnixConn, out *net.UnixConn) {
|
return func(args []string, in *net.UnixConn, out *net.UnixConn) {
|
||||||
|
@ -631,27 +631,6 @@ func connToFile(conn net.Conn) (f *os.File, err error) {
|
||||||
return f, err
|
return f, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 'status' is a notification of a job's status.
|
|
||||||
//
|
|
||||||
func parseEnv(args []string) ([]string, map[string]string) {
|
|
||||||
var argsOut []string
|
|
||||||
env := make(map[string]string)
|
|
||||||
for _, word := range args[1:] {
|
|
||||||
if strings.Contains(word, "=") {
|
|
||||||
kv := strings.SplitN(word, "=", 2)
|
|
||||||
key := kv[0]
|
|
||||||
var val string
|
|
||||||
if len(kv) == 2 {
|
|
||||||
val = kv[1]
|
|
||||||
}
|
|
||||||
env[key] = val
|
|
||||||
} else {
|
|
||||||
argsOut = append(argsOut, word)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return argsOut, env
|
|
||||||
}
|
|
||||||
|
|
||||||
type Msg struct {
|
type Msg struct {
|
||||||
payload []byte
|
payload []byte
|
||||||
attachment *os.File
|
attachment *os.File
|
||||||
|
|
Loading…
Add table
Reference in a new issue