本文整理匯總了Golang中github.com/lotreal/docker-pods/src/sh.Command.Ok方法的典型用法代碼示例。如果您正苦於以下問題:Golang Command.Ok方法的具體用法?Golang Command.Ok怎麽用?Golang Command.Ok使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/lotreal/docker-pods/src/sh.Command
的用法示例。
在下文中一共展示了Command.Ok方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: RunPods
func RunPods(file string) (RunOutput, error) {
var out RunOutput
p, err := config.Pods(file)
if err != nil {
return out, err
}
script, err := MakeCmd(p)
if err != nil {
return out, err
}
cmd := sh.Command{script}
fmt.Println(file)
fmt.Println(script)
fmt.Println("=============================")
out = RunOutput{
Pid: p.Id,
Pods: file,
ContainerId: cmd.Ok(),
// ContainerId: cmd.Mock()[0],
}
return out, nil
}
示例2: InspectRunning
func InspectRunning(cid string) string {
script := fmt.Sprintf("docker inspect --format='{{.State.Running}}' %s", cid)
cmd := sh.Command{script}
ret := cmd.Ok()
if ret == "true" {
return "YES"
}
return "NO"
}
示例3: InspectPid
func InspectPid(cid string) string {
script := fmt.Sprintf("docker inspect --format='{{.Config.Labels.name}}' %s", cid)
cmd := sh.Command{script}
ret := cmd.Ok()
if ret == "<no value>" {
return ""
}
return ret
}
示例4: TestRm
func TestRm(t *testing.T) {
script := fmt.Sprintf("docker rm -f %s", busybox)
cmd := sh.Command{script}
t.Log(cmd.Ok())
}
示例5: TestInit
package docker_test
import (
"fmt"
"testing"
"github.com/lotreal/docker-pods/src/docker"
"github.com/lotreal/docker-pods/src/sh"
)
var busybox = (func() string {
cmd := sh.Command{"docker run -d -it busybox sh"}
return cmd.Ok()[0:12]
})()
func TestInit(t *testing.T) {
t.Logf("%s", docker.Ps())
t.Logf("%s", busybox)
}
func TestIp(t *testing.T) {
t.Log(docker.InspectIp(busybox))
}
func TestPort(t *testing.T) {
t.Log(docker.InspectPorts(busybox))
}
func TestState(t *testing.T) {
t.Log(docker.InspectPorts(busybox))
}
示例6: InspectIp
func InspectIp(cid string) string {
script := fmt.Sprintf("docker inspect --format='{{.NetworkSettings.IPAddress}}' %s", cid)
cmd := sh.Command{script}
return cmd.Ok()
}
示例7: InspectPorts
func InspectPorts(cid string) string {
script := fmt.Sprintf("docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' %s", cid)
cmd := sh.Command{script}
ret := cmd.Ok()
return ret
}