本文整理汇总了Golang中github.com/appc/spec/schema.Mount类的典型用法代码示例。如果您正苦于以下问题:Golang Mount类的具体用法?Golang Mount怎么用?Golang Mount使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mount类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Set
func (am *appMountVolume) Set(s string) error {
pairs, err := url.ParseQuery(strings.Replace(s, ",", "&", -1))
if err != nil {
return err
}
mount := schema.Mount{}
target, ok := pairs["target"]
if !ok {
return fmt.Errorf("missing target= parameter")
}
if len(target) != 1 {
return fmt.Errorf("label %s with multiple values %q", "target", target)
}
mount.Path = target[0]
delete(pairs, "target")
vol, err := types.VolumeFromParams(pairs)
if err != nil {
return errwrap.Wrap(fmt.Errorf("error parsing volume component of MountVolume"), err)
}
mount.AppVolume = vol
mount.Volume = vol.Name
as := (*apps.Apps)(am)
if as.Count() == 0 {
return fmt.Errorf("an image is required before any MountVolumes")
}
app := as.Last()
app.Mounts = append(app.Mounts, mount)
return nil
}
开发者ID:intelsdi-x,项目名称:rkt,代码行数:35,代码来源:cli_apps.go
示例2: Set
func (mf *MountsFlag) Set(val string) error {
mnt := schema.Mount{}
pieces := strings.SplitN(val, ":", 2)
if name, err := types.NewACName(pieces[0]); err != nil {
return err
} else {
mnt.Volume = *name
}
if len(pieces) == 1 {
mnt.Path = mnt.Volume.String()
} else {
mnt.Path = pieces[1]
}
*mf = append(*mf, mnt)
return nil
}
开发者ID:JayBusch,项目名称:jetpack,代码行数:16,代码来源:flags.go
示例3: Set
func (al *appMount) Set(s string) error {
mount := schema.Mount{}
// this is intentionally made similar to types.VolumeFromString()
// TODO(iaguis) use MakeQueryString() when appc/spec#520 is merged
m, err := url.ParseQuery(strings.Replace(s, ",", "&", -1))
if err != nil {
return err
}
for key, val := range m {
if len(val) > 1 {
return fmt.Errorf("label %s with multiple values %q", key, val)
}
switch key {
case "volume":
mv, err := types.NewACName(val[0])
if err != nil {
return errwrap.Wrap(fmt.Errorf("invalid volume name %q in --mount flag %q", val[0], s), err)
}
mount.Volume = *mv
case "target":
mount.Path = val[0]
default:
return fmt.Errorf("unknown mount parameter %q", key)
}
}
as := (*apps.Apps)(al)
if as.Count() == 0 {
as.Mounts = append(as.Mounts, mount)
} else {
app := as.Last()
app.Mounts = append(app.Mounts, mount)
}
return nil
}
开发者ID:coderhaoxin,项目名称:rkt,代码行数:38,代码来源:cli_apps.go
注:本文中的github.com/appc/spec/schema.Mount类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论