本文整理汇总了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;未经允许,请勿转载。 |
请发表评论