mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
daemon: remove Daemon.children(), Daemon.parents() wrappers
Remove the wrappers to make it more explicit that these are related to the legacy links feature. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -36,7 +36,7 @@ func (daemon *Daemon) setupLinkedContainers(ctr *container.Container) ([]string,
|
||||
}
|
||||
|
||||
var env []string
|
||||
for linkAlias, child := range daemon.children(ctr) {
|
||||
for linkAlias, child := range daemon.linkIndex.children(ctr) {
|
||||
if !child.IsRunning() {
|
||||
return nil, fmt.Errorf("Cannot link to a non running container: %s AS %s", child.Name, linkAlias)
|
||||
}
|
||||
@@ -74,10 +74,10 @@ func (daemon *Daemon) addLegacyLinks(
|
||||
return nil
|
||||
}
|
||||
|
||||
children := daemon.children(ctr)
|
||||
children := daemon.linkIndex.children(ctr)
|
||||
var parents map[string]*container.Container
|
||||
if !cfg.DisableBridge && ctr.HostConfig.NetworkMode.IsPrivate() {
|
||||
parents = daemon.parents(ctr)
|
||||
parents = daemon.linkIndex.parents(ctr)
|
||||
}
|
||||
if len(children) == 0 && len(parents) == 0 {
|
||||
return nil
|
||||
|
||||
@@ -570,7 +570,7 @@ func (daemon *Daemon) restore(cfg *configStore) error {
|
||||
|
||||
// ignore errors here as this is a best effort to wait for children to be
|
||||
// running before we try to start the container
|
||||
children := daemon.children(c)
|
||||
children := daemon.linkIndex.children(c)
|
||||
timeout := time.NewTimer(5 * time.Second)
|
||||
defer timeout.Stop()
|
||||
|
||||
@@ -692,16 +692,6 @@ func (daemon *Daemon) restartSwarmContainers(ctx context.Context, cfg *configSto
|
||||
group.Wait()
|
||||
}
|
||||
|
||||
func (daemon *Daemon) children(c *container.Container) map[string]*container.Container {
|
||||
return daemon.linkIndex.children(c)
|
||||
}
|
||||
|
||||
// parents returns the names of the parent containers of the container
|
||||
// with the given name.
|
||||
func (daemon *Daemon) parents(c *container.Container) map[string]*container.Container {
|
||||
return daemon.linkIndex.parents(c)
|
||||
}
|
||||
|
||||
func (daemon *Daemon) registerLink(parent, child *container.Container, alias string) error {
|
||||
fullName := path.Join(parent.Name, alias)
|
||||
if err := daemon.containersReplica.ReserveName(fullName, child.ID); err != nil {
|
||||
|
||||
@@ -99,7 +99,8 @@ func (daemon *Daemon) getInspectData(daemonCfg *config.Config, container *contai
|
||||
// make a copy to play with
|
||||
hostConfig := *container.HostConfig
|
||||
|
||||
children := daemon.children(container)
|
||||
// Add information for legacy links
|
||||
children := daemon.linkIndex.children(container)
|
||||
hostConfig.Links = nil // do not expose the internal structure
|
||||
for linkAlias, child := range children {
|
||||
hostConfig.Links = append(hostConfig.Links, fmt.Sprintf("%s:%s", child.Name, linkAlias))
|
||||
|
||||
Reference in New Issue
Block a user