aboutsummaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_api.go3
-rw-r--r--libpod/container_inspect.go10
-rw-r--r--libpod/driver/driver.go15
-rw-r--r--libpod/image_inspect.go8
-rw-r--r--libpod/inspect_data.go104
-rw-r--r--libpod/runtime_img.go7
6 files changed, 21 insertions, 126 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go
index c0ccdc212..05b3e89e6 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -17,6 +17,7 @@ import (
"github.com/projectatomic/libpod/libpod/driver"
crioAnnotations "github.com/projectatomic/libpod/pkg/annotations"
"github.com/projectatomic/libpod/pkg/chrootuser"
+ "github.com/projectatomic/libpod/pkg/inspect"
"github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/tools/remotecommand"
@@ -600,7 +601,7 @@ func (c *Container) RemoveArtifact(name string) error {
}
// Inspect a container for low-level information
-func (c *Container) Inspect(size bool) (*ContainerInspectData, error) {
+func (c *Container) Inspect(size bool) (*inspect.ContainerInspectData, error) {
if !c.locked {
c.lock.Lock()
defer c.lock.Unlock()
diff --git a/libpod/container_inspect.go b/libpod/container_inspect.go
index 78dd00c16..b07dafa00 100644
--- a/libpod/container_inspect.go
+++ b/libpod/container_inspect.go
@@ -2,11 +2,11 @@ package libpod
import (
"github.com/cri-o/ocicni/pkg/ocicni"
- "github.com/projectatomic/libpod/libpod/driver"
+ "github.com/projectatomic/libpod/pkg/inspect"
"github.com/sirupsen/logrus"
)
-func (c *Container) getContainerInspectData(size bool, driverData *driver.Data) (*ContainerInspectData, error) {
+func (c *Container) getContainerInspectData(size bool, driverData *inspect.Data) (*inspect.ContainerInspectData, error) {
config := c.config
runtimeInfo := c.state
spec := c.config.Spec
@@ -20,12 +20,12 @@ func (c *Container) getContainerInspectData(size bool, driverData *driver.Data)
args = args[1:]
}
- data := &ContainerInspectData{
+ data := &inspect.ContainerInspectData{
ID: config.ID,
Created: config.CreatedTime,
Path: path,
Args: args,
- State: &ContainerInspectState{
+ State: &inspect.ContainerInspectState{
OciVersion: spec.Version,
Status: runtimeInfo.State.String(),
Running: runtimeInfo.State == ContainerStateRunning,
@@ -53,7 +53,7 @@ func (c *Container) getContainerInspectData(size bool, driverData *driver.Data)
ExecIDs: []string{}, //TODO
GraphDriver: driverData,
Mounts: spec.Mounts,
- NetworkSettings: &NetworkSettings{
+ NetworkSettings: &inspect.NetworkSettings{
Bridge: "", // TODO
SandboxID: "", // TODO - is this even relevant?
HairpinMode: false, // TODO
diff --git a/libpod/driver/driver.go b/libpod/driver/driver.go
index 8475810a8..d84ce8d3c 100644
--- a/libpod/driver/driver.go
+++ b/libpod/driver/driver.go
@@ -1,12 +1,9 @@
package driver
-import cstorage "github.com/containers/storage"
-
-// Data handles the data for a storage driver
-type Data struct {
- Name string `json:"Name"`
- Data map[string]string `json:"Data"`
-}
+import (
+ cstorage "github.com/containers/storage"
+ "github.com/projectatomic/libpod/pkg/inspect"
+)
// GetDriverName returns the name of the driver for the given store
func GetDriverName(store cstorage.Store) (string, error) {
@@ -27,7 +24,7 @@ func GetDriverMetadata(store cstorage.Store, layerID string) (map[string]string,
}
// GetDriverData returns the Data struct with information of the driver used by the store
-func GetDriverData(store cstorage.Store, layerID string) (*Data, error) {
+func GetDriverData(store cstorage.Store, layerID string) (*inspect.Data, error) {
name, err := GetDriverName(store)
if err != nil {
return nil, err
@@ -36,7 +33,7 @@ func GetDriverData(store cstorage.Store, layerID string) (*Data, error) {
if err != nil {
return nil, err
}
- return &Data{
+ return &inspect.Data{
Name: name,
Data: metaData,
}, nil
diff --git a/libpod/image_inspect.go b/libpod/image_inspect.go
index 3d904e64b..cc4b8307a 100644
--- a/libpod/image_inspect.go
+++ b/libpod/image_inspect.go
@@ -9,10 +9,10 @@ import (
digest "github.com/opencontainers/go-digest"
ociv1 "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
- "github.com/projectatomic/libpod/libpod/driver"
+ "github.com/projectatomic/libpod/pkg/inspect"
)
-func getImageData(img storage.Image, imgRef types.Image, size int64, driver *driver.Data) (*ImageData, error) {
+func getImageData(img storage.Image, imgRef types.Image, size int64, driver *inspect.Data) (*inspect.ImageData, error) {
imgSize, err := imgRef.Size()
if err != nil {
return nil, errors.Wrapf(err, "error reading size of image %q", img.ID)
@@ -41,7 +41,7 @@ func getImageData(img storage.Image, imgRef types.Image, size int64, driver *dri
repoDigests = append(repoDigests, strings.SplitN(name, ":", 2)[0]+"@"+imgDigest.String())
}
- data := &ImageData{
+ data := &inspect.ImageData{
ID: img.ID,
RepoTags: img.Names,
RepoDigests: repoDigests,
@@ -57,7 +57,7 @@ func getImageData(img storage.Image, imgRef types.Image, size int64, driver *dri
Annotations: annotations,
Digest: imgDigest,
Labels: info.Labels,
- RootFS: &RootFS{
+ RootFS: &inspect.RootFS{
Type: ociv1Img.RootFS.Type,
Layers: ociv1Img.RootFS.DiffIDs,
},
diff --git a/libpod/inspect_data.go b/libpod/inspect_data.go
deleted file mode 100644
index 5f9e3166d..000000000
--- a/libpod/inspect_data.go
+++ /dev/null
@@ -1,104 +0,0 @@
-package libpod
-
-import (
- "time"
-
- "github.com/cri-o/ocicni/pkg/ocicni"
- digest "github.com/opencontainers/go-digest"
- "github.com/opencontainers/image-spec/specs-go/v1"
- specs "github.com/opencontainers/runtime-spec/specs-go"
- "github.com/projectatomic/libpod/libpod/driver"
-)
-
-// ContainerInspectData handles the data used when inspecting a container
-type ContainerInspectData struct {
- ID string `json:"ID"`
- Created time.Time `json:"Created"`
- Path string `json:"Path"`
- Args []string `json:"Args"`
- State *ContainerInspectState `json:"State"`
- ImageID string `json:"Image"`
- ImageName string `json:"ImageName"`
- ResolvConfPath string `json:"ResolvConfPath"`
- HostnamePath string `json:"HostnamePath"` //TODO
- HostsPath string `json:"HostsPath"` //TODO
- StaticDir string `json:"StaticDir"`
- LogPath string `json:"LogPath"`
- Name string `json:"Name"`
- RestartCount int32 `json:"RestartCount"` //TODO
- Driver string `json:"Driver"`
- MountLabel string `json:"MountLabel"`
- ProcessLabel string `json:"ProcessLabel"`
- AppArmorProfile string `json:"AppArmorProfile"`
- ExecIDs []string `json:"ExecIDs"` //TODO
- GraphDriver *driver.Data `json:"GraphDriver"`
- SizeRw int64 `json:"SizeRw,omitempty"`
- SizeRootFs int64 `json:"SizeRootFs,omitempty"`
- Mounts []specs.Mount `json:"Mounts"`
- NetworkSettings *NetworkSettings `json:"NetworkSettings"` //TODO
-}
-
-// ContainerInspectState represents the state of a container.
-type ContainerInspectState struct {
- OciVersion string `json:"OciVersion"`
- Status string `json:"Status"`
- Running bool `json:"Running"`
- Paused bool `json:"Paused"`
- Restarting bool `json:"Restarting"` // TODO
- OOMKilled bool `json:"OOMKilled"`
- Dead bool `json:"Dead"`
- Pid int `json:"Pid"`
- ExitCode int32 `json:"ExitCode"`
- Error string `json:"Error"` // TODO
- StartedAt time.Time `json:"StartedAt"`
- FinishedAt time.Time `json:"FinishedAt"`
-}
-
-// NetworkSettings holds information about the newtwork settings of the container
-type NetworkSettings struct {
- Bridge string `json:"Bridge"`
- SandboxID string `json:"SandboxID"`
- HairpinMode bool `json:"HairpinMode"`
- LinkLocalIPv6Address string `json:"LinkLocalIPv6Address"`
- LinkLocalIPv6PrefixLen int `json:"LinkLocalIPv6PrefixLen"`
- Ports []ocicni.PortMapping `json:"Ports"`
- SandboxKey string `json:"SandboxKey"`
- SecondaryIPAddresses []string `json:"SecondaryIPAddresses"`
- SecondaryIPv6Addresses []string `json:"SecondaryIPv6Addresses"`
- EndpointID string `json:"EndpointID"`
- Gateway string `json:"Gateway"`
- GlobalIPv6Addresses []string `json:"GlobalIPv6Addresses"`
- GlobalIPv6PrefixLen int `json:"GlobalIPv6PrefixLen"`
- IPAddress string `json:"IPAddress"`
- IPPrefixLen int `json:"IPPrefixLen"`
- IPv6Gateway string `json:"IPv6Gateway"`
- MacAddress string `json:"MacAddress"`
-}
-
-// ImageData holds the inspect information of an image
-type ImageData struct {
- ID string `json:"ID"`
- Digest digest.Digest `json:"Digest"`
- RepoTags []string `json:"RepoTags"`
- RepoDigests []string `json:"RepoDigests"`
- Parent string `json:"Parent"`
- Comment string `json:"Comment"`
- Created *time.Time `json:"Created"`
- Config *v1.ImageConfig `json:"Config"`
- Version string `json:"Version"`
- Author string `json:"Author"`
- Architecture string `json:"Architecture"`
- Os string `json:"Os"`
- Size int64 `json:"Size"`
- VirtualSize int64 `json:"VirtualSize"`
- GraphDriver *driver.Data `json:"GraphDriver"`
- RootFS *RootFS `json:"RootFS"`
- Labels map[string]string `json:"Labels"`
- Annotations map[string]string `json:"Annotations"`
-}
-
-// RootFS holds the root fs information of an image
-type RootFS struct {
- Type string `json:"Type"`
- Layers []digest.Digest `json:"Layers"`
-}
diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go
index a572afcbb..76687351d 100644
--- a/libpod/runtime_img.go
+++ b/libpod/runtime_img.go
@@ -28,6 +28,7 @@ import (
"github.com/pkg/errors"
"github.com/projectatomic/libpod/libpod/common"
"github.com/projectatomic/libpod/libpod/driver"
+ "github.com/projectatomic/libpod/pkg/inspect"
)
// Runtime API
@@ -492,7 +493,7 @@ func getRegistries() ([]string, error) {
// ImageFilter is a function to determine whether an image is included in
// command output. Images to be outputted are tested using the function. A true
// return will include the image, a false return will exclude it.
-type ImageFilter func(*storage.Image, *ImageData) bool
+type ImageFilter func(*storage.Image, *inspect.ImageData) bool
func (ips imageDecomposeStruct) returnFQName() string {
return fmt.Sprintf("%s%s/%s:%s", ips.transport, ips.registry, ips.imageName, ips.tag)
@@ -1072,7 +1073,7 @@ func (r *Runtime) ImportImage(path string, options CopyOptions) error {
}
// GetImageInspectInfo returns the inspect information of an image
-func (r *Runtime) GetImageInspectInfo(image storage.Image) (*ImageData, error) {
+func (r *Runtime) GetImageInspectInfo(image storage.Image) (*inspect.ImageData, error) {
r.lock.RLock()
defer r.lock.RUnlock()
@@ -1082,7 +1083,7 @@ func (r *Runtime) GetImageInspectInfo(image storage.Image) (*ImageData, error) {
return r.getImageInspectInfo(image)
}
-func (r *Runtime) getImageInspectInfo(image storage.Image) (*ImageData, error) {
+func (r *Runtime) getImageInspectInfo(image storage.Image) (*inspect.ImageData, error) {
imgRef, err := r.getImageRef("@" + image.ID)
if err != nil {
return nil, errors.Wrapf(err, "error reading image %q", image.ID)