當前位置: 首頁>>代碼示例>>Golang>>正文


Golang command_runner.CommandRunner類代碼示例

本文整理匯總了Golang中github.com/cloudfoundry/gunk/command_runner.CommandRunner的典型用法代碼示例。如果您正苦於以下問題:Golang CommandRunner類的具體用法?Golang CommandRunner怎麽用?Golang CommandRunner使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了CommandRunner類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: New

func New(containerDepotPath, binPath string, runner command_runner.CommandRunner) (*LinuxQuotaManager, error) {
	dfOut := new(bytes.Buffer)

	df := &exec.Cmd{
		Path:   "df",
		Args:   []string{"-P", containerDepotPath},
		Stdout: dfOut,
	}

	err := runner.Run(df)
	if err != nil {
		return nil, err
	}

	dfOutputWords := strings.Split(string(dfOut.Bytes()), " ")
	mountPoint := strings.Trim(dfOutputWords[len(dfOutputWords)-1], "\n")

	return &LinuxQuotaManager{
		enabled: true,

		binPath: binPath,
		runner:  runner,

		mountPoint: mountPoint,
	}, nil
}
開發者ID:vito,項目名稱:warden-docker,代碼行數:26,代碼來源:quota_manager.go

示例2: NewBigApp

func NewBigApp(runner command_runner.CommandRunner, appPath string, sizeInMegabytes int) (*BigApp, error) {
	tempDirName, err := ioutil.TempDir("", "big-app")
	if err != nil {
		return nil, err
	}

	cmd := &exec.Cmd{Path: "cp", Args: []string{"-r", appPath + "/", tempDirName}}

	err = runner.Run(cmd)
	if err != nil {
		return nil, err
	}

	ddOutputArg := "of=" + tempDirName + "/payload"
	ddCountArg := fmt.Sprintf("count=%d", sizeInMegabytes)

	cmd = &exec.Cmd{Path: "dd", Args: []string{"if=/dev/urandom", ddOutputArg, ddCountArg, "bs=1048576"}}

	err = runner.Run(cmd)
	if err != nil {
		return nil, err
	}

	return &BigApp{
		Location: tempDirName,
		runner:   runner,
		Name:     "big-app-" + generator.RandomName(),
	}, nil
}
開發者ID:pivotal-cf-experimental,項目名稱:cf-probe,代碼行數:29,代碼來源:app.go

示例3: run

func (c *BtrfsCleaningCake) run(runner command_runner.CommandRunner, cmd *exec.Cmd) (string, error) {
	var buffer bytes.Buffer
	cmd.Stdout = &buffer
	if err := runner.Run(cmd); err != nil {
		return "", err
	}
	return buffer.String(), nil
}
開發者ID:guanglinlv,項目名稱:garden-linux,代碼行數:8,代碼來源:btrfs.go

示例4: destroy

func (n *rule) destroy(chain string, runner command_runner.CommandRunner) error {
	return runner.Run(exec.Command("/sbin/iptables", flags("-D", chain, n)...))
}
開發者ID:nagyistoce,項目名稱:garden-linux,代碼行數:3,代碼來源:iptables.go


注:本文中的github.com/cloudfoundry/gunk/command_runner.CommandRunner類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。