本文整理汇总了Golang中github.com/cloudfoundry/gunk/command_runner.CommandRunner.Run方法的典型用法代码示例。如果您正苦于以下问题:Golang CommandRunner.Run方法的具体用法?Golang CommandRunner.Run怎么用?Golang CommandRunner.Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/gunk/command_runner.CommandRunner
的用法示例。
在下文中一共展示了CommandRunner.Run方法的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
}
示例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
}
示例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
}
示例4: destroy
func (n *rule) destroy(chain string, runner command_runner.CommandRunner) error {
return runner.Run(exec.Command("/sbin/iptables", flags("-D", chain, n)...))
}