forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
imagestreams.go
102 lines (88 loc) · 3.79 KB
/
imagestreams.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package client
import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
imageapi "github.com/openshift/origin/pkg/image/api"
)
// ImageStreamsNamespacer has methods to work with ImageStream resources in a namespace
type ImageStreamsNamespacer interface {
ImageStreams(namespace string) ImageStreamInterface
}
// ImageStreamInterface exposes methods on ImageStream resources.
type ImageStreamInterface interface {
List(label labels.Selector, field fields.Selector) (*imageapi.ImageStreamList, error)
Get(name string) (*imageapi.ImageStream, error)
Create(stream *imageapi.ImageStream) (*imageapi.ImageStream, error)
Update(stream *imageapi.ImageStream) (*imageapi.ImageStream, error)
Delete(name string) error
Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
}
// ImageStreamNamespaceGetter exposes methods to get ImageStreams by Namespace
type ImageStreamNamespaceGetter interface {
GetByNamespace(namespace, name string) (*imageapi.ImageStream, error)
}
// imageStreams implements ImageStreamsNamespacer interface
type imageStreams struct {
r *Client
ns string
}
// newImageStreams returns an imageStreams
func newImageStreams(c *Client, namespace string) *imageStreams {
return &imageStreams{
r: c,
ns: namespace,
}
}
// List returns a list of image streams that match the label and field selectors.
func (c *imageStreams) List(label labels.Selector, field fields.Selector) (result *imageapi.ImageStreamList, err error) {
result = &imageapi.ImageStreamList{}
err = c.r.Get().
Namespace(c.ns).
Resource("imageStreams").
LabelsSelectorParam("labels", label).
FieldsSelectorParam("fields", field).
Do().
Into(result)
return
}
// Get returns information about a particular image stream and error if one occurs.
func (c *imageStreams) Get(name string) (result *imageapi.ImageStream, err error) {
result = &imageapi.ImageStream{}
err = c.r.Get().Namespace(c.ns).Resource("imageStreams").Name(name).Do().Into(result)
return
}
// GetByNamespace returns information about a particular image stream in a particular namespace and error if one occurs.
func (c *imageStreams) GetByNamespace(namespace, name string) (result *imageapi.ImageStream, err error) {
result = &imageapi.ImageStream{}
c.r.Get().Namespace(namespace).Resource("imageStreams").Name(name).Do().Into(result)
return
}
// Create create a new image stream. Returns the server's representation of the image stream and error if one occurs.
func (c *imageStreams) Create(stream *imageapi.ImageStream) (result *imageapi.ImageStream, err error) {
result = &imageapi.ImageStream{}
err = c.r.Post().Namespace(c.ns).Resource("imageStreams").Body(stream).Do().Into(result)
return
}
// Update updates the image stream on the server. Returns the server's representation of the image stream and error if one occurs.
func (c *imageStreams) Update(stream *imageapi.ImageStream) (result *imageapi.ImageStream, err error) {
result = &imageapi.ImageStream{}
err = c.r.Put().Namespace(c.ns).Resource("imageStreams").Name(stream.Name).Body(stream).Do().Into(result)
return
}
// Delete deletes an image stream, returns error if one occurs.
func (c *imageStreams) Delete(name string) (err error) {
err = c.r.Delete().Namespace(c.ns).Resource("imageStreams").Name(name).Do().Error()
return
}
// Watch returns a watch.Interface that watches the requested image streams.
func (c *imageStreams) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
return c.r.Get().
Prefix("watch").
Namespace(c.ns).
Resource("imageStreams").
Param("resourceVersion", resourceVersion).
LabelsSelectorParam("labels", label).
FieldsSelectorParam("fields", field).
Watch()
}