11package libpod
22
33import (
4+ "github.com/containers/storage"
45 "github.com/kubernetes-incubator/cri-o/libpod/ctr"
56 "github.com/kubernetes-incubator/cri-o/libpod/pod"
67 spec "github.com/opencontainers/runtime-spec/specs-go"
78)
89
9- // ContainerFilter is a function to determine whether a container is included
10- // in command output. Containers to be outputted are tested using the function.
11- // A true return will include the container, a false return will exclude it.
12- type ContainerFilter func (* ctr.Container ) bool
13-
14- // PodFilter is a function to determine whether a pod is included in command
15- // output. Pods to be outputted are tested using the function. A true return
16- // will include the pod, a false return will exclude it.
17- type PodFilter func (* pod.Pod ) bool
10+ // Runtime API
1811
1912// A RuntimeOption is a functional option which alters the Runtime created by
2013// NewRuntime
2114type RuntimeOption func (* Runtime ) error
2215
23- // A CtrCreateOption is a functional option which alters the Container created
24- // by NewContainer
25- type CtrCreateOption func (* ctr.Container ) error
26-
2716// Runtime is the core libpod runtime
2817type Runtime struct {
2918 // TODO populate
@@ -34,6 +23,17 @@ func NewRuntime(options ...RuntimeOption) (*Runtime, error) {
3423 return nil , ctr .ErrNotImplemented
3524}
3625
26+ // Container API
27+
28+ // A CtrCreateOption is a functional option which alters the Container created
29+ // by NewContainer
30+ type CtrCreateOption func (* ctr.Container ) error
31+
32+ // ContainerFilter is a function to determine whether a container is included
33+ // in command output. Containers to be outputted are tested using the function.
34+ // A true return will include the container, a false return will exclude it.
35+ type ContainerFilter func (* ctr.Container ) bool
36+
3737// NewContainer creates a new container from a given OCI config
3838func (r * Runtime ) NewContainer (spec * spec.Spec , options ... CtrCreateOption ) (* ctr.Container , error ) {
3939 return nil , ctr .ErrNotImplemented
@@ -65,6 +65,13 @@ func (r *Runtime) GetContainers(filters ...ContainerFilter) ([]*ctr.Container, e
6565 return nil , ctr .ErrNotImplemented
6666}
6767
68+ // Pod API
69+
70+ // PodFilter is a function to determine whether a pod is included in command
71+ // output. Pods to be outputted are tested using the function. A true return
72+ // will include the pod, a false return will exclude it.
73+ type PodFilter func (* pod.Pod ) bool
74+
6875// NewPod makes a new, empty pod
6976func (r * Runtime ) NewPod () (* pod.Pod , error ) {
7077 return nil , ctr .ErrNotImplemented
@@ -97,4 +104,64 @@ func (r *Runtime) GetPods(filters ...PodFilter) ([]*pod.Pod, error) {
97104 return nil , ctr .ErrNotImplemented
98105}
99106
100- // TODO Add image API
107+ // Image API
108+
109+ // ImageFilter is a function to determine whether an image is included in
110+ // command output. Images to be outputted are tested using the function. A true
111+ // return will include the image, a false return will exclude it.
112+ type ImageFilter func (* storage.Image ) bool
113+
114+ // PullImage pulls an image from configured registries
115+ // By default, only the latest tag (or a specific tag if requested) will be
116+ // pulled. If allTags is true, all tags for the requested image will be pulled.
117+ // Signature validation will be performed if the Runtime has been appropriately
118+ // configured
119+ func (r * Runtime ) PullImage (image string , allTags bool ) (* storage.Image , error ) {
120+ return nil , ctr .ErrNotImplemented
121+ }
122+
123+ // PushImage pushes the given image to a location described by the given path
124+ func (r * Runtime ) PushImage (image * storage.Image , destination string ) error {
125+ return ctr .ErrNotImplemented
126+ }
127+
128+ // TagImage adds a tag to the given image
129+ func (r * Runtime ) TagImage (image * storage.Image , tag string ) error {
130+ return ctr .ErrNotImplemented
131+ }
132+
133+ // UntagImage removes a tag from the given image
134+ func (r * Runtime ) UntagImage (image * storage.Image , tag string ) error {
135+ return ctr .ErrNotImplemented
136+ }
137+
138+ // RemoveImage deletes an image from local storage
139+ // Images being used by running containers cannot be removed
140+ func (r * Runtime ) RemoveImage (image * storage.Image ) error {
141+ return ctr .ErrNotImplemented
142+ }
143+
144+ // GetImage retrieves an image matching the given name or hash from system
145+ // storage
146+ // If no matching image can be found, an error is returned
147+ func (r * Runtime ) GetImage (image string ) (* storage.Image , error ) {
148+ return nil , ctr .ErrNotImplemented
149+ }
150+
151+ // GetImages retrieves all images present in storage
152+ // Filters can be provided which will determine which images are included in the
153+ // output. Multiple filters are handled by ANDing their output, so only images
154+ // matching all filters are included
155+ func (r * Runtime ) GetImages (filter ... ImageFilter ) ([]* storage.Image , error ) {
156+ return nil , ctr .ErrNotImplemented
157+ }
158+
159+ // CommitContainer commits the changes between a container and its image,
160+ // creating a new image
161+ // If the container was not created from an image (for example,
162+ // WithRootFSFromPath will create a container from a directory on the system),
163+ // a new base image will be created from the contents of the container's
164+ // filesystem
165+ func (r * Runtime ) CommitContainer (c * ctr.Container ) (* storage.Image , error ) {
166+ return nil , ctr .ErrNotImplemented
167+ }
0 commit comments