forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
images.go
67 lines (57 loc) · 1.9 KB
/
images.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package client
import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
imageapi "github.com/openshift/origin/pkg/image/api"
)
// ImagesNamespacer has methods to work with Image resources in a namespace
type ImagesNamespacer interface {
Images(namespace string) ImageInterface
}
// ImageInterface exposes methods on Image resources.
type ImageInterface interface {
List(label, field labels.Selector) (*imageapi.ImageList, error)
Get(name string) (*imageapi.Image, error)
Create(image *imageapi.Image) (*imageapi.Image, error)
Delete(name string) error
}
// images implements ImagesNamespacer interface
type images struct {
r *Client
ns string
}
// newImages returns an images
func newImages(c *Client, namespace string) ImageInterface {
return &images{
r: c,
ns: namespace,
}
}
// List returns a list of images that match the label and field selectors.
func (c *images) List(label, field labels.Selector) (result *imageapi.ImageList, err error) {
result = &imageapi.ImageList{}
err = c.r.Get().
Namespace(c.ns).
Resource("images").
SelectorParam("labels", label).
SelectorParam("fields", field).
Do().
Into(result)
return
}
// Get returns information about a particular image and error if one occurs.
func (c *images) Get(name string) (result *imageapi.Image, err error) {
result = &imageapi.Image{}
err = c.r.Get().Namespace(c.ns).Resource("images").Name(name).Do().Into(result)
return
}
// Create creates a new image. Returns the server's representation of the image and error if one occurs.
func (c *images) Create(image *imageapi.Image) (result *imageapi.Image, err error) {
result = &imageapi.Image{}
err = c.r.Post().Namespace(c.ns).Resource("images").Body(image).Do().Into(result)
return
}
// Delete deletes an image, returns error if one occurs.
func (c *images) Delete(name string) (err error) {
err = c.r.Delete().Namespace(c.ns).Resource("images").Name(name).Do().Error()
return
}