github.com/mheon/docker@v0.11.2-0.20150922122814-44f47903a831/daemon/inspect_unix.go (about)

     1  // +build !windows
     2  
     3  package daemon
     4  
     5  import "github.com/docker/docker/api/types"
     6  
     7  // This sets platform-specific fields
     8  func setPlatformSpecificContainerFields(container *Container, contJSONBase *types.ContainerJSONBase) *types.ContainerJSONBase {
     9  	contJSONBase.AppArmorProfile = container.AppArmorProfile
    10  	contJSONBase.ResolvConfPath = container.ResolvConfPath
    11  	contJSONBase.HostnamePath = container.HostnamePath
    12  	contJSONBase.HostsPath = container.HostsPath
    13  
    14  	return contJSONBase
    15  }
    16  
    17  // ContainerInspectPre120 gets containers for pre 1.20 APIs.
    18  func (daemon *Daemon) ContainerInspectPre120(name string) (*types.ContainerJSONPre120, error) {
    19  	container, err := daemon.Get(name)
    20  	if err != nil {
    21  		return nil, err
    22  	}
    23  
    24  	container.Lock()
    25  	defer container.Unlock()
    26  
    27  	base, err := daemon.getInspectData(container)
    28  	if err != nil {
    29  		return nil, err
    30  	}
    31  
    32  	volumes := make(map[string]string)
    33  	volumesRW := make(map[string]bool)
    34  	for _, m := range container.MountPoints {
    35  		volumes[m.Destination] = m.Path()
    36  		volumesRW[m.Destination] = m.RW
    37  	}
    38  
    39  	config := &types.ContainerConfigPre120{
    40  		container.Config,
    41  		container.hostConfig.VolumeDriver,
    42  		container.hostConfig.Memory,
    43  		container.hostConfig.MemorySwap,
    44  		container.hostConfig.CPUShares,
    45  		container.hostConfig.CpusetCpus,
    46  	}
    47  
    48  	return &types.ContainerJSONPre120{base, volumes, volumesRW, config}, nil
    49  }
    50  
    51  func addMountPoints(container *Container) []types.MountPoint {
    52  	mountPoints := make([]types.MountPoint, 0, len(container.MountPoints))
    53  	for _, m := range container.MountPoints {
    54  		mountPoints = append(mountPoints, types.MountPoint{
    55  			Name:        m.Name,
    56  			Source:      m.Path(),
    57  			Destination: m.Destination,
    58  			Driver:      m.Driver,
    59  			Mode:        m.Mode,
    60  			RW:          m.RW,
    61  		})
    62  	}
    63  	return mountPoints
    64  }