forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploymentconfigs.go
109 lines (95 loc) · 4 KB
/
deploymentconfigs.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
103
104
105
106
107
108
109
package client
import (
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
deployapi "github.com/openshift/origin/pkg/deploy/api"
)
// DeploymentConfigsNamespacer has methods to work with DeploymentConfig resources in a namespace
type DeploymentConfigsNamespacer interface {
DeploymentConfigs(namespace string) DeploymentConfigInterface
}
// DeploymentConfigInterface contains methods for working with DeploymentConfigs
type DeploymentConfigInterface interface {
List(label labels.Selector, field fields.Selector) (*deployapi.DeploymentConfigList, error)
Get(name string) (*deployapi.DeploymentConfig, error)
Create(config *deployapi.DeploymentConfig) (*deployapi.DeploymentConfig, error)
Update(config *deployapi.DeploymentConfig) (*deployapi.DeploymentConfig, error)
Delete(name string) error
Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
Generate(name string) (*deployapi.DeploymentConfig, error)
Rollback(config *deployapi.DeploymentConfigRollback) (*deployapi.DeploymentConfig, error)
}
// deploymentConfigs implements DeploymentConfigsNamespacer interface
type deploymentConfigs struct {
r *Client
ns string
}
// newDeploymentConfigs returns a deploymentConfigs
func newDeploymentConfigs(c *Client, namespace string) *deploymentConfigs {
return &deploymentConfigs{
r: c,
ns: namespace,
}
}
// List takes a label and field selectors, and returns the list of deploymentConfigs that match that selectors
func (c *deploymentConfigs) List(label labels.Selector, field fields.Selector) (result *deployapi.DeploymentConfigList, err error) {
result = &deployapi.DeploymentConfigList{}
err = c.r.Get().
Namespace(c.ns).
Resource("deploymentConfigs").
LabelsSelectorParam(label).
FieldsSelectorParam(field).
Do().
Into(result)
return
}
// Get returns information about a particular deploymentConfig
func (c *deploymentConfigs) Get(name string) (result *deployapi.DeploymentConfig, err error) {
result = &deployapi.DeploymentConfig{}
err = c.r.Get().Namespace(c.ns).Resource("deploymentConfigs").Name(name).Do().Into(result)
return
}
// Create creates a new deploymentConfig
func (c *deploymentConfigs) Create(deploymentConfig *deployapi.DeploymentConfig) (result *deployapi.DeploymentConfig, err error) {
result = &deployapi.DeploymentConfig{}
err = c.r.Post().Namespace(c.ns).Resource("deploymentConfigs").Body(deploymentConfig).Do().Into(result)
return
}
// Update updates an existing deploymentConfig
func (c *deploymentConfigs) Update(deploymentConfig *deployapi.DeploymentConfig) (result *deployapi.DeploymentConfig, err error) {
result = &deployapi.DeploymentConfig{}
err = c.r.Put().Namespace(c.ns).Resource("deploymentConfigs").Name(deploymentConfig.Name).Body(deploymentConfig).Do().Into(result)
return
}
// Delete deletes an existing deploymentConfig.
func (c *deploymentConfigs) Delete(name string) error {
return c.r.Delete().Namespace(c.ns).Resource("deploymentConfigs").Name(name).Do().Error()
}
// Watch returns a watch.Interface that watches the requested deploymentConfigs.
func (c *deploymentConfigs) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
return c.r.Get().
Prefix("watch").
Namespace(c.ns).
Resource("deploymentConfigs").
Param("resourceVersion", resourceVersion).
LabelsSelectorParam(label).
FieldsSelectorParam(field).
Watch()
}
// Generate generates a new deploymentConfig for the given name.
func (c *deploymentConfigs) Generate(name string) (result *deployapi.DeploymentConfig, err error) {
result = &deployapi.DeploymentConfig{}
err = c.r.Get().Namespace(c.ns).Resource("generateDeploymentConfigs").Name(name).Do().Into(result)
return
}
func (c *deploymentConfigs) Rollback(config *deployapi.DeploymentConfigRollback) (result *deployapi.DeploymentConfig, err error) {
result = &deployapi.DeploymentConfig{}
err = c.r.Post().
Namespace(c.ns).
Resource("deploymentConfigRollbacks").
Body(config).
Do().
Into(result)
return
}