本文整理汇总了Golang中github.com/docker/docker/pkg/graphdb.Database.Children方法的典型用法代码示例。如果您正苦于以下问题:Golang Database.Children方法的具体用法?Golang Database.Children怎么用?Golang Database.Children使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/docker/docker/pkg/graphdb.Database
的用法示例。
在下文中一共展示了Database.Children方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: migrateLegacySqliteLinks
// migrateLegacySqliteLinks migrates sqlite links to use links from HostConfig
// when sqlite links were used, hostConfig.Links was set to nil
func (daemon *Daemon) migrateLegacySqliteLinks(db *graphdb.Database, container *container.Container) error {
// if links is populated (or an empty slice), then this isn't using sqlite links and can be skipped
if container.HostConfig == nil || container.HostConfig.Links != nil {
return nil
}
logrus.Debugf("migrating legacy sqlite link info for container: %s", container.ID)
fullName := container.Name
if fullName[0] != '/' {
fullName = "/" + fullName
}
// don't use a nil slice, this ensures that the check above will skip once the migration has completed
links := []string{}
children, err := db.Children(fullName, 0)
if err != nil {
if !strings.Contains(err.Error(), "Cannot find child for") {
return err
}
// else continue... it's ok if we didn't find any children, it'll just be nil and we can continue the migration
}
for _, child := range children {
c, err := daemon.GetContainer(child.Entity.ID())
if err != nil {
return err
}
links = append(links, c.Name+":"+child.Edge.Name)
}
container.HostConfig.Links = links
return container.WriteHostConfig()
}