Merge pull request #56 from rhatdan/LayerID
Add new function to return ContainerLayerID
This commit is contained in:
commit
29f53da34e
45
store.go
45
store.go
|
|
@ -1475,9 +1475,8 @@ func (s *store) Version() ([][2]string, error) {
|
|||
}
|
||||
|
||||
func (s *store) Mount(id, mountLabel string) (string, error) {
|
||||
rcstore, err := s.ContainerStore()
|
||||
if err != nil {
|
||||
return "", err
|
||||
if layerID, err := s.ContainerLayerID(id); err == nil {
|
||||
id = layerID
|
||||
}
|
||||
rlstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
|
|
@ -1489,22 +1488,12 @@ func (s *store) Mount(id, mountLabel string) (string, error) {
|
|||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
}
|
||||
rcstore.Lock()
|
||||
defer rcstore.Unlock()
|
||||
if modified, err := rcstore.Modified(); modified || err != nil {
|
||||
rcstore.Load()
|
||||
}
|
||||
|
||||
if c, err := rcstore.Get(id); c != nil && err == nil {
|
||||
id = c.LayerID
|
||||
}
|
||||
return rlstore.Mount(id, mountLabel)
|
||||
}
|
||||
|
||||
func (s *store) Unmount(id string) error {
|
||||
rcstore, err := s.ContainerStore()
|
||||
if err != nil {
|
||||
return err
|
||||
if layerID, err := s.ContainerLayerID(id); err == nil {
|
||||
id = layerID
|
||||
}
|
||||
rlstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
|
|
@ -1516,15 +1505,6 @@ func (s *store) Unmount(id string) error {
|
|||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
}
|
||||
rcstore.Lock()
|
||||
defer rcstore.Unlock()
|
||||
if modified, err := rcstore.Modified(); modified || err != nil {
|
||||
rcstore.Load()
|
||||
}
|
||||
|
||||
if c, err := rcstore.Get(id); c != nil && err == nil {
|
||||
id = c.LayerID
|
||||
}
|
||||
return rlstore.Unmount(id)
|
||||
}
|
||||
|
||||
|
|
@ -1714,6 +1694,23 @@ func (s *store) Container(id string) (*Container, error) {
|
|||
return rcstore.Get(id)
|
||||
}
|
||||
|
||||
func (s *store) ContainerLayerID(id string) (string, error) {
|
||||
rcstore, err := s.ContainerStore()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
rcstore.Lock()
|
||||
defer rcstore.Unlock()
|
||||
if modified, err := rcstore.Modified(); modified || err != nil {
|
||||
rcstore.Load()
|
||||
}
|
||||
container, err := rcstore.Get(id)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return container.LayerID, nil
|
||||
}
|
||||
|
||||
func (s *store) ContainerByLayer(id string) (*Container, error) {
|
||||
rlstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue