forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
images.go
72 lines (61 loc) · 2.1 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
68
69
70
71
72
package client
import (
kapi "k8s.io/kubernetes/pkg/api"
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(opts kapi.ListOptions) (*imageapi.ImageList, error)
Get(name string) (*imageapi.Image, error)
Create(image *imageapi.Image) (*imageapi.Image, error)
Update(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(opts kapi.ListOptions) (result *imageapi.ImageList, err error) {
result = &imageapi.ImageList{}
err = c.r.Get().
Resource("images").
VersionedParams(&opts, kapi.ParameterCodec).
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
}
// Update allows to modify existing image. Since most of image's attributes are immutable, this call allows
// mainly for updating image signatures.
func (c *images) Update(image *imageapi.Image) (result *imageapi.Image, err error) {
result = &imageapi.Image{}
err = c.r.Put().Resource("images").Name(image.Name).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
}