本文整理汇总了Golang中github.com/docker/docker/engine.Env.GetBool方法的典型用法代码示例。如果您正苦于以下问题:Golang Env.GetBool方法的具体用法?Golang Env.GetBool怎么用?Golang Env.GetBool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/docker/docker/engine.Env
的用法示例。
在下文中一共展示了Env.GetBool方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getExecExitCode
// getExecExitCode perform an inspect on the exec command. It returns
// the running state and the exit code.
func getExecExitCode(cli *DockerCli, execId string) (bool, int, error) {
stream, _, err := cli.call("GET", "/exec/"+execId+"/json", nil, false)
if err != nil {
// If we can't connect, then the daemon probably died.
if err != ErrConnectionRefused {
return false, -1, err
}
return false, -1, nil
}
var result engine.Env
if err := result.Decode(stream); err != nil {
return false, -1, err
}
return result.GetBool("Running"), result.GetInt("ExitCode"), nil
}
示例2: newInterfaceAllocation
func newInterfaceAllocation(t *testing.T, input engine.Env) (output engine.Env) {
eng := engine.New()
eng.Logging = false
done := make(chan bool)
// set IPv6 global if given
if input.Exists("globalIPv6Network") {
_, globalIPv6Network, _ = net.ParseCIDR(input.Get("globalIPv6Network"))
}
job := eng.Job("allocate_interface", "container_id")
job.Env().Init(&input)
reader, _ := job.Stdout.AddPipe()
go func() {
output.Decode(reader)
done <- true
}()
res := Allocate(job)
job.Stdout.Close()
<-done
if input.Exists("expectFail") && input.GetBool("expectFail") {
if res == engine.StatusOK {
t.Fatal("Doesn't fail to allocate network interface")
}
} else {
if res != engine.StatusOK {
t.Fatal("Failed to allocate network interface")
}
}
if input.Exists("globalIPv6Network") {
// check for bug #11427
_, subnet, _ := net.ParseCIDR(input.Get("globalIPv6Network"))
if globalIPv6Network.IP.String() != subnet.IP.String() {
t.Fatal("globalIPv6Network was modified during allocation")
}
// clean up IPv6 global
globalIPv6Network = nil
}
return
}