1
16
17
18
19 package v1
20
21 import (
22 "context"
23 json "encoding/json"
24 "fmt"
25 "time"
26
27 v1 "k8s.io/api/apps/v1"
28 autoscalingv1 "k8s.io/api/autoscaling/v1"
29 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
30 types "k8s.io/apimachinery/pkg/types"
31 watch "k8s.io/apimachinery/pkg/watch"
32 appsv1 "k8s.io/client-go/applyconfigurations/apps/v1"
33 applyconfigurationsautoscalingv1 "k8s.io/client-go/applyconfigurations/autoscaling/v1"
34 scheme "k8s.io/client-go/kubernetes/scheme"
35 rest "k8s.io/client-go/rest"
36 )
37
38
39
40 type ReplicaSetsGetter interface {
41 ReplicaSets(namespace string) ReplicaSetInterface
42 }
43
44
45 type ReplicaSetInterface interface {
46 Create(ctx context.Context, replicaSet *v1.ReplicaSet, opts metav1.CreateOptions) (*v1.ReplicaSet, error)
47 Update(ctx context.Context, replicaSet *v1.ReplicaSet, opts metav1.UpdateOptions) (*v1.ReplicaSet, error)
48 UpdateStatus(ctx context.Context, replicaSet *v1.ReplicaSet, opts metav1.UpdateOptions) (*v1.ReplicaSet, error)
49 Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
50 DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error
51 Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.ReplicaSet, error)
52 List(ctx context.Context, opts metav1.ListOptions) (*v1.ReplicaSetList, error)
53 Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error)
54 Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.ReplicaSet, err error)
55 Apply(ctx context.Context, replicaSet *appsv1.ReplicaSetApplyConfiguration, opts metav1.ApplyOptions) (result *v1.ReplicaSet, err error)
56 ApplyStatus(ctx context.Context, replicaSet *appsv1.ReplicaSetApplyConfiguration, opts metav1.ApplyOptions) (result *v1.ReplicaSet, err error)
57 GetScale(ctx context.Context, replicaSetName string, options metav1.GetOptions) (*autoscalingv1.Scale, error)
58 UpdateScale(ctx context.Context, replicaSetName string, scale *autoscalingv1.Scale, opts metav1.UpdateOptions) (*autoscalingv1.Scale, error)
59 ApplyScale(ctx context.Context, replicaSetName string, scale *applyconfigurationsautoscalingv1.ScaleApplyConfiguration, opts metav1.ApplyOptions) (*autoscalingv1.Scale, error)
60
61 ReplicaSetExpansion
62 }
63
64
65 type replicaSets struct {
66 client rest.Interface
67 ns string
68 }
69
70
71 func newReplicaSets(c *AppsV1Client, namespace string) *replicaSets {
72 return &replicaSets{
73 client: c.RESTClient(),
74 ns: namespace,
75 }
76 }
77
78
79 func (c *replicaSets) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.ReplicaSet, err error) {
80 result = &v1.ReplicaSet{}
81 err = c.client.Get().
82 Namespace(c.ns).
83 Resource("replicasets").
84 Name(name).
85 VersionedParams(&options, scheme.ParameterCodec).
86 Do(ctx).
87 Into(result)
88 return
89 }
90
91
92 func (c *replicaSets) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ReplicaSetList, err error) {
93 var timeout time.Duration
94 if opts.TimeoutSeconds != nil {
95 timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
96 }
97 result = &v1.ReplicaSetList{}
98 err = c.client.Get().
99 Namespace(c.ns).
100 Resource("replicasets").
101 VersionedParams(&opts, scheme.ParameterCodec).
102 Timeout(timeout).
103 Do(ctx).
104 Into(result)
105 return
106 }
107
108
109 func (c *replicaSets) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
110 var timeout time.Duration
111 if opts.TimeoutSeconds != nil {
112 timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
113 }
114 opts.Watch = true
115 return c.client.Get().
116 Namespace(c.ns).
117 Resource("replicasets").
118 VersionedParams(&opts, scheme.ParameterCodec).
119 Timeout(timeout).
120 Watch(ctx)
121 }
122
123
124 func (c *replicaSets) Create(ctx context.Context, replicaSet *v1.ReplicaSet, opts metav1.CreateOptions) (result *v1.ReplicaSet, err error) {
125 result = &v1.ReplicaSet{}
126 err = c.client.Post().
127 Namespace(c.ns).
128 Resource("replicasets").
129 VersionedParams(&opts, scheme.ParameterCodec).
130 Body(replicaSet).
131 Do(ctx).
132 Into(result)
133 return
134 }
135
136
137 func (c *replicaSets) Update(ctx context.Context, replicaSet *v1.ReplicaSet, opts metav1.UpdateOptions) (result *v1.ReplicaSet, err error) {
138 result = &v1.ReplicaSet{}
139 err = c.client.Put().
140 Namespace(c.ns).
141 Resource("replicasets").
142 Name(replicaSet.Name).
143 VersionedParams(&opts, scheme.ParameterCodec).
144 Body(replicaSet).
145 Do(ctx).
146 Into(result)
147 return
148 }
149
150
151
152 func (c *replicaSets) UpdateStatus(ctx context.Context, replicaSet *v1.ReplicaSet, opts metav1.UpdateOptions) (result *v1.ReplicaSet, err error) {
153 result = &v1.ReplicaSet{}
154 err = c.client.Put().
155 Namespace(c.ns).
156 Resource("replicasets").
157 Name(replicaSet.Name).
158 SubResource("status").
159 VersionedParams(&opts, scheme.ParameterCodec).
160 Body(replicaSet).
161 Do(ctx).
162 Into(result)
163 return
164 }
165
166
167 func (c *replicaSets) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
168 return c.client.Delete().
169 Namespace(c.ns).
170 Resource("replicasets").
171 Name(name).
172 Body(&opts).
173 Do(ctx).
174 Error()
175 }
176
177
178 func (c *replicaSets) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error {
179 var timeout time.Duration
180 if listOpts.TimeoutSeconds != nil {
181 timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
182 }
183 return c.client.Delete().
184 Namespace(c.ns).
185 Resource("replicasets").
186 VersionedParams(&listOpts, scheme.ParameterCodec).
187 Timeout(timeout).
188 Body(&opts).
189 Do(ctx).
190 Error()
191 }
192
193
194 func (c *replicaSets) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.ReplicaSet, err error) {
195 result = &v1.ReplicaSet{}
196 err = c.client.Patch(pt).
197 Namespace(c.ns).
198 Resource("replicasets").
199 Name(name).
200 SubResource(subresources...).
201 VersionedParams(&opts, scheme.ParameterCodec).
202 Body(data).
203 Do(ctx).
204 Into(result)
205 return
206 }
207
208
209 func (c *replicaSets) Apply(ctx context.Context, replicaSet *appsv1.ReplicaSetApplyConfiguration, opts metav1.ApplyOptions) (result *v1.ReplicaSet, err error) {
210 if replicaSet == nil {
211 return nil, fmt.Errorf("replicaSet provided to Apply must not be nil")
212 }
213 patchOpts := opts.ToPatchOptions()
214 data, err := json.Marshal(replicaSet)
215 if err != nil {
216 return nil, err
217 }
218 name := replicaSet.Name
219 if name == nil {
220 return nil, fmt.Errorf("replicaSet.Name must be provided to Apply")
221 }
222 result = &v1.ReplicaSet{}
223 err = c.client.Patch(types.ApplyPatchType).
224 Namespace(c.ns).
225 Resource("replicasets").
226 Name(*name).
227 VersionedParams(&patchOpts, scheme.ParameterCodec).
228 Body(data).
229 Do(ctx).
230 Into(result)
231 return
232 }
233
234
235
236 func (c *replicaSets) ApplyStatus(ctx context.Context, replicaSet *appsv1.ReplicaSetApplyConfiguration, opts metav1.ApplyOptions) (result *v1.ReplicaSet, err error) {
237 if replicaSet == nil {
238 return nil, fmt.Errorf("replicaSet provided to Apply must not be nil")
239 }
240 patchOpts := opts.ToPatchOptions()
241 data, err := json.Marshal(replicaSet)
242 if err != nil {
243 return nil, err
244 }
245
246 name := replicaSet.Name
247 if name == nil {
248 return nil, fmt.Errorf("replicaSet.Name must be provided to Apply")
249 }
250
251 result = &v1.ReplicaSet{}
252 err = c.client.Patch(types.ApplyPatchType).
253 Namespace(c.ns).
254 Resource("replicasets").
255 Name(*name).
256 SubResource("status").
257 VersionedParams(&patchOpts, scheme.ParameterCodec).
258 Body(data).
259 Do(ctx).
260 Into(result)
261 return
262 }
263
264
265 func (c *replicaSets) GetScale(ctx context.Context, replicaSetName string, options metav1.GetOptions) (result *autoscalingv1.Scale, err error) {
266 result = &autoscalingv1.Scale{}
267 err = c.client.Get().
268 Namespace(c.ns).
269 Resource("replicasets").
270 Name(replicaSetName).
271 SubResource("scale").
272 VersionedParams(&options, scheme.ParameterCodec).
273 Do(ctx).
274 Into(result)
275 return
276 }
277
278
279 func (c *replicaSets) UpdateScale(ctx context.Context, replicaSetName string, scale *autoscalingv1.Scale, opts metav1.UpdateOptions) (result *autoscalingv1.Scale, err error) {
280 result = &autoscalingv1.Scale{}
281 err = c.client.Put().
282 Namespace(c.ns).
283 Resource("replicasets").
284 Name(replicaSetName).
285 SubResource("scale").
286 VersionedParams(&opts, scheme.ParameterCodec).
287 Body(scale).
288 Do(ctx).
289 Into(result)
290 return
291 }
292
293
294
295 func (c *replicaSets) ApplyScale(ctx context.Context, replicaSetName string, scale *applyconfigurationsautoscalingv1.ScaleApplyConfiguration, opts metav1.ApplyOptions) (result *autoscalingv1.Scale, err error) {
296 if scale == nil {
297 return nil, fmt.Errorf("scale provided to ApplyScale must not be nil")
298 }
299 patchOpts := opts.ToPatchOptions()
300 data, err := json.Marshal(scale)
301 if err != nil {
302 return nil, err
303 }
304
305 result = &autoscalingv1.Scale{}
306 err = c.client.Patch(types.ApplyPatchType).
307 Namespace(c.ns).
308 Resource("replicasets").
309 Name(replicaSetName).
310 SubResource("scale").
311 VersionedParams(&patchOpts, scheme.ParameterCodec).
312 Body(data).
313 Do(ctx).
314 Into(result)
315 return
316 }
317
View as plain text