generated from knative-extensions/sample-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
239 lines (208 loc) · 7.38 KB
/
client.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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/*
Copyright 2020 The Knative 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 injection-gen. DO NOT EDIT.
package client
import (
context "context"
json "encoding/json"
errors "errors"
fmt "fmt"
versioned "github.com/imjasonh/seccomp-profile/pkg/apis/clientset/versioned"
typedseccompv1alpha1 "github.com/imjasonh/seccomp-profile/pkg/apis/clientset/versioned/typed/seccomp/v1alpha1"
v1alpha1 "github.com/imjasonh/seccomp-profile/pkg/apis/seccomp/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
unstructured "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
discovery "k8s.io/client-go/discovery"
dynamic "k8s.io/client-go/dynamic"
rest "k8s.io/client-go/rest"
injection "knative.dev/pkg/injection"
dynamicclient "knative.dev/pkg/injection/clients/dynamicclient"
logging "knative.dev/pkg/logging"
)
func init() {
injection.Default.RegisterClient(withClientFromConfig)
injection.Default.RegisterClientFetcher(func(ctx context.Context) interface{} {
return Get(ctx)
})
injection.Dynamic.RegisterDynamicClient(withClientFromDynamic)
}
// Key is used as the key for associating information with a context.Context.
type Key struct{}
func withClientFromConfig(ctx context.Context, cfg *rest.Config) context.Context {
return context.WithValue(ctx, Key{}, versioned.NewForConfigOrDie(cfg))
}
func withClientFromDynamic(ctx context.Context) context.Context {
return context.WithValue(ctx, Key{}, &wrapClient{dyn: dynamicclient.Get(ctx)})
}
// Get extracts the versioned.Interface client from the context.
func Get(ctx context.Context) versioned.Interface {
untyped := ctx.Value(Key{})
if untyped == nil {
if injection.GetConfig(ctx) == nil {
logging.FromContext(ctx).Panic(
"Unable to fetch github.com/imjasonh/seccomp-profile/pkg/apis/clientset/versioned.Interface from context. This context is not the application context (which is typically given to constructors via sharedmain).")
} else {
logging.FromContext(ctx).Panic(
"Unable to fetch github.com/imjasonh/seccomp-profile/pkg/apis/clientset/versioned.Interface from context.")
}
}
return untyped.(versioned.Interface)
}
type wrapClient struct {
dyn dynamic.Interface
}
var _ versioned.Interface = (*wrapClient)(nil)
func (w *wrapClient) Discovery() discovery.DiscoveryInterface {
panic("Discovery called on dynamic client!")
}
func convert(from interface{}, to runtime.Object) error {
bs, err := json.Marshal(from)
if err != nil {
return fmt.Errorf("Marshal() = %w", err)
}
if err := json.Unmarshal(bs, to); err != nil {
return fmt.Errorf("Unmarshal() = %w", err)
}
return nil
}
// SeccompV1alpha1 retrieves the SeccompV1alpha1Client
func (w *wrapClient) SeccompV1alpha1() typedseccompv1alpha1.SeccompV1alpha1Interface {
return &wrapSeccompV1alpha1{
dyn: w.dyn,
}
}
type wrapSeccompV1alpha1 struct {
dyn dynamic.Interface
}
func (w *wrapSeccompV1alpha1) RESTClient() rest.Interface {
panic("RESTClient called on dynamic client!")
}
func (w *wrapSeccompV1alpha1) SeccompProfiles() typedseccompv1alpha1.SeccompProfileInterface {
return &wrapSeccompV1alpha1SeccompProfileImpl{
dyn: w.dyn.Resource(schema.GroupVersionResource{
Group: "seccomp.imjasonh.dev",
Version: "v1alpha1",
Resource: "seccompprofiles",
}),
}
}
type wrapSeccompV1alpha1SeccompProfileImpl struct {
dyn dynamic.NamespaceableResourceInterface
}
var _ typedseccompv1alpha1.SeccompProfileInterface = (*wrapSeccompV1alpha1SeccompProfileImpl)(nil)
func (w *wrapSeccompV1alpha1SeccompProfileImpl) Create(ctx context.Context, in *v1alpha1.SeccompProfile, opts v1.CreateOptions) (*v1alpha1.SeccompProfile, error) {
in.SetGroupVersionKind(schema.GroupVersionKind{
Group: "seccomp.imjasonh.dev",
Version: "v1alpha1",
Kind: "SeccompProfile",
})
uo := &unstructured.Unstructured{}
if err := convert(in, uo); err != nil {
return nil, err
}
uo, err := w.dyn.Create(ctx, uo, opts)
if err != nil {
return nil, err
}
out := &v1alpha1.SeccompProfile{}
if err := convert(uo, out); err != nil {
return nil, err
}
return out, nil
}
func (w *wrapSeccompV1alpha1SeccompProfileImpl) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
return w.dyn.Delete(ctx, name, opts)
}
func (w *wrapSeccompV1alpha1SeccompProfileImpl) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
return w.dyn.DeleteCollection(ctx, opts, listOpts)
}
func (w *wrapSeccompV1alpha1SeccompProfileImpl) Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.SeccompProfile, error) {
uo, err := w.dyn.Get(ctx, name, opts)
if err != nil {
return nil, err
}
out := &v1alpha1.SeccompProfile{}
if err := convert(uo, out); err != nil {
return nil, err
}
return out, nil
}
func (w *wrapSeccompV1alpha1SeccompProfileImpl) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.SeccompProfileList, error) {
uo, err := w.dyn.List(ctx, opts)
if err != nil {
return nil, err
}
out := &v1alpha1.SeccompProfileList{}
if err := convert(uo, out); err != nil {
return nil, err
}
return out, nil
}
func (w *wrapSeccompV1alpha1SeccompProfileImpl) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.SeccompProfile, err error) {
uo, err := w.dyn.Patch(ctx, name, pt, data, opts)
if err != nil {
return nil, err
}
out := &v1alpha1.SeccompProfile{}
if err := convert(uo, out); err != nil {
return nil, err
}
return out, nil
}
func (w *wrapSeccompV1alpha1SeccompProfileImpl) Update(ctx context.Context, in *v1alpha1.SeccompProfile, opts v1.UpdateOptions) (*v1alpha1.SeccompProfile, error) {
in.SetGroupVersionKind(schema.GroupVersionKind{
Group: "seccomp.imjasonh.dev",
Version: "v1alpha1",
Kind: "SeccompProfile",
})
uo := &unstructured.Unstructured{}
if err := convert(in, uo); err != nil {
return nil, err
}
uo, err := w.dyn.Update(ctx, uo, opts)
if err != nil {
return nil, err
}
out := &v1alpha1.SeccompProfile{}
if err := convert(uo, out); err != nil {
return nil, err
}
return out, nil
}
func (w *wrapSeccompV1alpha1SeccompProfileImpl) UpdateStatus(ctx context.Context, in *v1alpha1.SeccompProfile, opts v1.UpdateOptions) (*v1alpha1.SeccompProfile, error) {
in.SetGroupVersionKind(schema.GroupVersionKind{
Group: "seccomp.imjasonh.dev",
Version: "v1alpha1",
Kind: "SeccompProfile",
})
uo := &unstructured.Unstructured{}
if err := convert(in, uo); err != nil {
return nil, err
}
uo, err := w.dyn.UpdateStatus(ctx, uo, opts)
if err != nil {
return nil, err
}
out := &v1alpha1.SeccompProfile{}
if err := convert(uo, out); err != nil {
return nil, err
}
return out, nil
}
func (w *wrapSeccompV1alpha1SeccompProfileImpl) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
return nil, errors.New("NYI: Watch")
}