move container-related functions out of kpod and into libkpod

Signed-off-by: Ryan Cole <rcyoalne@gmail.com>
This commit is contained in:
Ryan Cole 2017-07-21 22:07:40 -04:00
parent a68a981d0b
commit 2c1fd1ad3f
8 changed files with 65 additions and 54 deletions

View file

@ -84,22 +84,6 @@ func getCopyOptions(reportWriter io.Writer, signaturePolicyPath string, srcDocke
}
}
func findContainer(store storage.Store, container string) (*storage.Container, error) {
ctrStore, err := store.ContainerStore()
if err != nil {
return nil, err
}
return ctrStore.Get(container)
}
func getContainerTopLayerID(store storage.Store, containerID string) (string, error) {
ctr, err := findContainer(store, containerID)
if err != nil {
return "", err
}
return ctr.LayerID, nil
}
func getSystemContext(signaturePolicyPath string) *types.SystemContext {
sc := &types.SystemContext{}
if signaturePolicyPath != "" {
@ -163,30 +147,6 @@ func getRootFsSize(store storage.Store, containerID string) (int64, error) {
return size + layerSize, err
}
func getContainerRwSize(store storage.Store, containerID string) (int64, error) {
ctrStore, err := store.ContainerStore()
if err != nil {
return 0, err
}
container, err := ctrStore.Get(containerID)
if err != nil {
return 0, err
}
lstore, err := store.LayerStore()
if err != nil {
return 0, err
}
// Get the size of the top layer by calculating the size of the diff
// between the layer and its parent. The top layer of a container is
// the only RW layer, all others are immutable
layer, err := lstore.Get(container.LayerID)
if err != nil {
return 0, err
}
return lstore.DiffSize(layer.Parent, layer.ID)
}
func isTrue(str string) bool {
return str == "true"
}