本文整理汇总了Golang中github.com/coreos/rkt/common/apps.Apps类的典型用法代码示例。如果您正苦于以下问题:Golang Apps类的具体用法?Golang Apps怎么用?Golang Apps使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Apps类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: findImages
// findImages uses findImage to attain a list of image hashes using discovery if necessary
func (f *finder) findImages(al *apps.Apps) error {
return al.Walk(func(app *apps.App) error {
h, err := f.findImage(app.Image, app.Asc, true)
if err != nil {
return err
}
app.ImageID = *h
return nil
})
}
开发者ID:ChengTiesheng,项目名称:rkt,代码行数:11,代码来源:images.go
示例2: FetchImages
// FetchImages uses FetchImage to attain a list of image hashes
func (f *Fetcher) FetchImages(al *apps.Apps) error {
return al.Walk(func(app *apps.App) error {
d, err := DistFromImageString(app.Image)
if err != nil {
return err
}
h, err := f.FetchImage(d, app.Image, app.Asc)
if err != nil {
return err
}
app.ImageID = *h
return nil
})
}
开发者ID:intelsdi-x,项目名称:rkt,代码行数:15,代码来源:fetcher.go
示例3: parseApps
// parseApps looks through the args for support of per-app argument lists delimited with "--" and "---".
// Between per-app argument lists flags.Parse() is called using the supplied FlagSet.
// Anything not consumed by flags.Parse() and not found to be a per-app argument list is treated as an image.
// allowAppArgs controls whether "--" prefixed per-app arguments will be accepted or not.
func parseApps(al *apps.Apps, args []string, flags *pflag.FlagSet, allowAppArgs bool) error {
nAppsLastAppArgs := al.Count()
// valid args here may either be:
// not-"--"; flags handled by *flags or an image specifier
// "--"; app arguments begin
// "---"; conclude app arguments
// between "--" and "---" pairs anything is permitted.
inAppArgs := false
for i := 0; i < len(args); i++ {
a := args[i]
if inAppArgs {
switch a {
case "---":
// conclude this app's args
inAppArgs = false
default:
// keep appending to this app's args
app := al.Last()
app.Args = append(app.Args, a)
}
} else {
switch a {
case "--":
if !allowAppArgs {
return fmt.Errorf("app arguments unsupported")
}
// begin app's args
inAppArgs = true
// catch some likely mistakes
if nAppsLastAppArgs == al.Count() {
if al.Count() == 0 {
return fmt.Errorf("an image is required before any app arguments")
}
return fmt.Errorf("only one set of app arguments allowed per image")
}
nAppsLastAppArgs = al.Count()
case "---":
// ignore triple dashes since they aren't images
// TODO(vc): I don't think ignoring this is appropriate, probably should error; it implies malformed argv.
// "---" is not an image separator, it's an optional argument list terminator.
// encountering it outside of inAppArgs is likely to be "--" typoed
default:
// consume any potential inter-app flags
if err := flags.Parse(args[i:]); err != nil {
return err
}
nInterFlags := (len(args[i:]) - flags.NArg())
if nInterFlags > 0 {
// XXX(vc): flag.Parse() annoyingly consumes the "--", reclaim it here if necessary
if args[i+nInterFlags-1] == "--" {
nInterFlags--
}
// advance past what flags.Parse() consumed
i += nInterFlags - 1 // - 1 because of i++
} else {
// flags.Parse() didn't want this arg, treat as image
al.Create(a)
}
}
}
}
return al.Validate()
}
开发者ID:coderhaoxin,项目名称:rkt,代码行数:72,代码来源:cli_apps.go
注:本文中的github.com/coreos/rkt/common/apps.Apps类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论