• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang cmd.RunCmd函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/docker/docker/pkg/integration/cmd.RunCmd函数的典型用法代码示例。如果您正苦于以下问题:Golang RunCmd函数的具体用法?Golang RunCmd怎么用?Golang RunCmd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了RunCmd函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: dockerCmdInDir

// execute a docker command in a directory
func dockerCmdInDir(c *check.C, path string, args ...string) (string, int, error) {
	if err := validateArgs(args...); err != nil {
		c.Fatalf(err.Error())
	}
	result := icmd.RunCmd(icmd.Cmd{Command: binaryWithArgs(args...), Dir: path})
	return result.Combined(), result.ExitCode, result.Error
}
开发者ID:Mic92,项目名称:docker,代码行数:8,代码来源:docker_utils.go


示例2: waitForContainer

func waitForContainer(contID string, args ...string) error {
	args = append([]string{dockerBinary, "run", "--name", contID}, args...)
	result := icmd.RunCmd(icmd.Cmd{Command: args})
	if result.Error != nil {
		return result.Error
	}
	return waitRun(contID)
}
开发者ID:Mic92,项目名称:docker,代码行数:8,代码来源:docker_utils.go


示例3: dockerCmdInDirWithTimeout

// execute a docker command in a directory with a timeout
func dockerCmdInDirWithTimeout(timeout time.Duration, path string, args ...string) *icmd.Result {
	if err := validateArgs(args...); err != nil {
		return &icmd.Result{Error: err}
	}
	return icmd.RunCmd(icmd.Cmd{
		Command: binaryWithArgs(args...),
		Timeout: timeout,
		Dir:     path,
	})
}
开发者ID:Mic92,项目名称:docker,代码行数:11,代码来源:docker_utils.go


示例4: BuildImageWithOut

// BuildImageWithOut builds an image with the specified dockerfile and options and returns the output
func (d *Daemon) BuildImageWithOut(name, dockerfile string, useCache bool, buildFlags ...string) (string, int, error) {
	buildCmd := BuildImageCmdWithHost(d.dockerBinary, name, dockerfile, d.Sock(), useCache, buildFlags...)
	result := icmd.RunCmd(icmd.Cmd{
		Command: buildCmd.Args,
		Env:     buildCmd.Env,
		Dir:     buildCmd.Dir,
		Stdin:   buildCmd.Stdin,
		Stdout:  buildCmd.Stdout,
	})
	return result.Combined(), result.ExitCode, result.Error
}
开发者ID:mYmNeo,项目名称:docker,代码行数:12,代码来源:daemon.go


示例5: TestAPIDockerAPIVersion

func (s *DockerSuite) TestAPIDockerAPIVersion(c *check.C) {
	var svrVersion string

	server := httptest.NewServer(http.HandlerFunc(
		func(w http.ResponseWriter, r *http.Request) {
			url := r.URL.Path
			svrVersion = url
		}))
	defer server.Close()

	// Test using the env var first
	result := icmd.RunCmd(icmd.Cmd{
		Command: binaryWithArgs("-H="+server.URL[7:], "version"),
		Env:     appendBaseEnv(false, "DOCKER_API_VERSION=xxx"),
	})
	c.Assert(result, icmd.Matches, icmd.Expected{Out: "API version:  xxx", ExitCode: 1})
	c.Assert(svrVersion, check.Equals, "/vxxx/version", check.Commentf("%s", result.Compare(icmd.Success)))
}
开发者ID:SUSE,项目名称:docker.mirror,代码行数:18,代码来源:docker_api_test.go


示例6: TestImportWithQuotedChanges

func (s *DockerSuite) TestImportWithQuotedChanges(c *check.C) {
	testRequires(c, DaemonIsLinux)
	dockerCmd(c, "run", "--name", "test-import", "busybox", "true")

	temporaryFile, err := ioutil.TempFile("", "exportImportTest")
	c.Assert(err, checker.IsNil, check.Commentf("failed to create temporary file"))
	defer os.Remove(temporaryFile.Name())

	result := icmd.RunCmd(icmd.Cmd{
		Command: binaryWithArgs("export", "test-import"),
		Stdout:  bufio.NewWriter(temporaryFile),
	})
	c.Assert(result, icmd.Matches, icmd.Success)

	result = dockerCmdWithResult("import", "-c", `ENTRYPOINT ["/bin/sh", "-c"]`, temporaryFile.Name())
	c.Assert(result, icmd.Matches, icmd.Success)
	image := strings.TrimSpace(result.Stdout())

	result = dockerCmdWithResult("run", "--rm", image, "true")
	c.Assert(result, icmd.Matches, icmd.Expected{Out: icmd.None})
}
开发者ID:SUSE,项目名称:docker.mirror,代码行数:21,代码来源:docker_cli_import_test.go


示例7: TestEventsUntag

func (s *DockerSuite) TestEventsUntag(c *check.C) {
	image := "busybox"
	dockerCmd(c, "tag", image, "utest:tag1")
	dockerCmd(c, "tag", image, "utest:tag2")
	dockerCmd(c, "rmi", "utest:tag1")
	dockerCmd(c, "rmi", "utest:tag2")

	result := icmd.RunCmd(icmd.Cmd{
		Command: []string{dockerBinary, "events", "--since=1"},
		Timeout: time.Millisecond * 2500,
	})
	c.Assert(result, icmd.Matches, icmd.Expected{Timeout: true})

	events := strings.Split(result.Stdout(), "\n")
	nEvents := len(events)
	// The last element after the split above will be an empty string, so we
	// get the two elements before the last, which are the untags we're
	// looking for.
	for _, v := range events[nEvents-3 : nEvents-1] {
		c.Assert(v, checker.Contains, "untag", check.Commentf("event should be untag"))
	}
}
开发者ID:Mic92,项目名称:docker,代码行数:22,代码来源:docker_cli_events_test.go


示例8: runCommand

// TODO: update code to call cmd.RunCmd directly, and remove this function
func runCommand(execCmd *exec.Cmd) (exitCode int, err error) {
	result := cmd.RunCmd(transformCmd(execCmd))
	return result.ExitCode, result.Error
}
开发者ID:SUSE,项目名称:docker.mirror,代码行数:5,代码来源:utils.go


示例9: runCommandWithStdoutStderr

// TODO: update code to call cmd.RunCmd directly, and remove this function
func runCommandWithStdoutStderr(execCmd *exec.Cmd) (string, string, int, error) {
	result := cmd.RunCmd(transformCmd(execCmd))
	return result.Stdout(), result.Stderr(), result.ExitCode, result.Error
}
开发者ID:SUSE,项目名称:docker.mirror,代码行数:5,代码来源:utils.go


示例10: runCommandWithOutput

// TODO: update code to call cmd.RunCmd directly, and remove this function
func runCommandWithOutput(execCmd *exec.Cmd) (string, int, error) {
	result := cmd.RunCmd(transformCmd(execCmd))
	return result.Combined(), result.ExitCode, result.Error
}
开发者ID:SUSE,项目名称:docker.mirror,代码行数:5,代码来源:utils.go


示例11: deleteImages

func deleteImages(images ...string) error {
	args := []string{dockerBinary, "rmi", "-f"}
	return icmd.RunCmd(icmd.Cmd{Command: append(args, images...)}).Error
}
开发者ID:Mic92,项目名称:docker,代码行数:4,代码来源:docker_utils.go



注:本文中的github.com/docker/docker/pkg/integration/cmd.RunCmd函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang cmd.RunCommand函数代码示例发布时间:2022-05-23
下一篇:
Golang checker.Not函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap