/
daemonset.go
213 lines (180 loc) · 8.45 KB
/
daemonset.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
//go:build !ignore_autogenerated
// +build !ignore_autogenerated
/*
Copyright The KCP Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by kcp code-generator. DO NOT EDIT.
package fake
import (
"context"
"encoding/json"
"fmt"
"github.com/kcp-dev/logicalcluster/v3"
appsv1beta2 "k8s.io/api/apps/v1beta2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
applyconfigurationsappsv1beta2 "k8s.io/client-go/applyconfigurations/apps/v1beta2"
appsv1beta2client "k8s.io/client-go/kubernetes/typed/apps/v1beta2"
"k8s.io/client-go/testing"
kcpappsv1beta2 "github.com/kcp-dev/client-go/kubernetes/typed/apps/v1beta2"
kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing"
)
var daemonSetsResource = schema.GroupVersionResource{Group: "apps", Version: "v1beta2", Resource: "daemonsets"}
var daemonSetsKind = schema.GroupVersionKind{Group: "apps", Version: "v1beta2", Kind: "DaemonSet"}
type daemonSetsClusterClient struct {
*kcptesting.Fake
}
// Cluster scopes the client down to a particular cluster.
func (c *daemonSetsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpappsv1beta2.DaemonSetsNamespacer {
if clusterPath == logicalcluster.Wildcard {
panic("A specific cluster must be provided when scoping, not the wildcard.")
}
return &daemonSetsNamespacer{Fake: c.Fake, ClusterPath: clusterPath}
}
// List takes label and field selectors, and returns the list of DaemonSets that match those selectors across all clusters.
func (c *daemonSetsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta2.DaemonSetList, error) {
obj, err := c.Fake.Invokes(kcptesting.NewListAction(daemonSetsResource, daemonSetsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &appsv1beta2.DaemonSetList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &appsv1beta2.DaemonSetList{ListMeta: obj.(*appsv1beta2.DaemonSetList).ListMeta}
for _, item := range obj.(*appsv1beta2.DaemonSetList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested DaemonSets across all clusters.
func (c *daemonSetsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
return c.Fake.InvokesWatch(kcptesting.NewWatchAction(daemonSetsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts))
}
type daemonSetsNamespacer struct {
*kcptesting.Fake
ClusterPath logicalcluster.Path
}
func (n *daemonSetsNamespacer) Namespace(namespace string) appsv1beta2client.DaemonSetInterface {
return &daemonSetsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace}
}
type daemonSetsClient struct {
*kcptesting.Fake
ClusterPath logicalcluster.Path
Namespace string
}
func (c *daemonSetsClient) Create(ctx context.Context, daemonSet *appsv1beta2.DaemonSet, opts metav1.CreateOptions) (*appsv1beta2.DaemonSet, error) {
obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(daemonSetsResource, c.ClusterPath, c.Namespace, daemonSet), &appsv1beta2.DaemonSet{})
if obj == nil {
return nil, err
}
return obj.(*appsv1beta2.DaemonSet), err
}
func (c *daemonSetsClient) Update(ctx context.Context, daemonSet *appsv1beta2.DaemonSet, opts metav1.UpdateOptions) (*appsv1beta2.DaemonSet, error) {
obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(daemonSetsResource, c.ClusterPath, c.Namespace, daemonSet), &appsv1beta2.DaemonSet{})
if obj == nil {
return nil, err
}
return obj.(*appsv1beta2.DaemonSet), err
}
func (c *daemonSetsClient) UpdateStatus(ctx context.Context, daemonSet *appsv1beta2.DaemonSet, opts metav1.UpdateOptions) (*appsv1beta2.DaemonSet, error) {
obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(daemonSetsResource, c.ClusterPath, "status", c.Namespace, daemonSet), &appsv1beta2.DaemonSet{})
if obj == nil {
return nil, err
}
return obj.(*appsv1beta2.DaemonSet), err
}
func (c *daemonSetsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
_, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(daemonSetsResource, c.ClusterPath, c.Namespace, name, opts), &appsv1beta2.DaemonSet{})
return err
}
func (c *daemonSetsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error {
action := kcptesting.NewDeleteCollectionAction(daemonSetsResource, c.ClusterPath, c.Namespace, listOpts)
_, err := c.Fake.Invokes(action, &appsv1beta2.DaemonSetList{})
return err
}
func (c *daemonSetsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*appsv1beta2.DaemonSet, error) {
obj, err := c.Fake.Invokes(kcptesting.NewGetAction(daemonSetsResource, c.ClusterPath, c.Namespace, name), &appsv1beta2.DaemonSet{})
if obj == nil {
return nil, err
}
return obj.(*appsv1beta2.DaemonSet), err
}
// List takes label and field selectors, and returns the list of DaemonSets that match those selectors.
func (c *daemonSetsClient) List(ctx context.Context, opts metav1.ListOptions) (*appsv1beta2.DaemonSetList, error) {
obj, err := c.Fake.Invokes(kcptesting.NewListAction(daemonSetsResource, daemonSetsKind, c.ClusterPath, c.Namespace, opts), &appsv1beta2.DaemonSetList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &appsv1beta2.DaemonSetList{ListMeta: obj.(*appsv1beta2.DaemonSetList).ListMeta}
for _, item := range obj.(*appsv1beta2.DaemonSetList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
func (c *daemonSetsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
return c.Fake.InvokesWatch(kcptesting.NewWatchAction(daemonSetsResource, c.ClusterPath, c.Namespace, opts))
}
func (c *daemonSetsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*appsv1beta2.DaemonSet, error) {
obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(daemonSetsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &appsv1beta2.DaemonSet{})
if obj == nil {
return nil, err
}
return obj.(*appsv1beta2.DaemonSet), err
}
func (c *daemonSetsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationsappsv1beta2.DaemonSetApplyConfiguration, opts metav1.ApplyOptions) (*appsv1beta2.DaemonSet, error) {
if applyConfiguration == nil {
return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil")
}
data, err := json.Marshal(applyConfiguration)
if err != nil {
return nil, err
}
name := applyConfiguration.Name
if name == nil {
return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply")
}
obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(daemonSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &appsv1beta2.DaemonSet{})
if obj == nil {
return nil, err
}
return obj.(*appsv1beta2.DaemonSet), err
}
func (c *daemonSetsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationsappsv1beta2.DaemonSetApplyConfiguration, opts metav1.ApplyOptions) (*appsv1beta2.DaemonSet, error) {
if applyConfiguration == nil {
return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil")
}
data, err := json.Marshal(applyConfiguration)
if err != nil {
return nil, err
}
name := applyConfiguration.Name
if name == nil {
return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply")
}
obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(daemonSetsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &appsv1beta2.DaemonSet{})
if obj == nil {
return nil, err
}
return obj.(*appsv1beta2.DaemonSet), err
}