本文整理汇总了Golang中github.com/jeffail/gabs.Container.Object方法的典型用法代码示例。如果您正苦于以下问题:Golang Container.Object方法的具体用法?Golang Container.Object怎么用?Golang Container.Object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jeffail/gabs.Container
的用法示例。
在下文中一共展示了Container.Object方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: mergeVolumeConfig
// Merge guest volume/block device configuration with any volumes found in
// host container.
func mergeVolumeConfig(volumeconfig []volumeConfig, guest *gabs.Container) (err error) {
var mounts *gabs.Container
if guest.ExistsP("mount") {
mounts = guest.S("mount")
} else {
mounts, _ = guest.ObjectP("mount")
}
mmap, _ := mounts.ChildrenMap()
for _, mount := range mmap {
var source string
var path string
var ok bool
if source, ok = mount.Path("source").Data().(string); !ok {
continue
}
if path, ok = mount.Path("path").Data().(string); !ok {
continue
}
if source == "blk" && strings.HasPrefix(path, "/dev/ld") {
return fmt.Errorf("Guest configuration defines " +
"/dev/ld* block devices, cannot merge with " +
"host volumes")
}
}
blkIndex := 0
for _, v := range volumeconfig {
mp := "/" + v.name
obj, _ := guest.Object("mount", mp)
obj.Set("blk", "source")
obj.Set(fmt.Sprintf("/dev/ld%va", blkIndex), "path")
blkIndex += 1
}
return
}