forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
images.go
65 lines (55 loc) · 1.83 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
package client
import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
imageapi "github.com/openshift/origin/pkg/image/api"
)
// ImagesInterfacer has methods to work with Image resources
type ImagesInterfacer interface {
Images() ImageInterface
}
// ImageInterface exposes methods on Image resources.
type ImageInterface interface {
List(label labels.Selector, field fields.Selector) (*imageapi.ImageList, error)
Get(name string) (*imageapi.Image, error)
Create(image *imageapi.Image) (*imageapi.Image, error)
Delete(name string) error
}
// images implements ImagesInterface.
type images struct {
r *Client
}
// newImages returns an images
func newImages(c *Client) ImageInterface {
return &images{
r: c,
}
}
// List returns a list of images that match the label and field selectors.
func (c *images) List(label labels.Selector, field fields.Selector) (result *imageapi.ImageList, err error) {
result = &imageapi.ImageList{}
err = c.r.Get().
Resource("images").
LabelsSelectorParam(label).
FieldsSelectorParam(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().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().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().Resource("images").Name(name).Do().Error()
return
}