This repository has been archived by the owner on Feb 19, 2024. It is now read-only.
/
zz_generated.api.register.go
362 lines (306 loc) · 10.7 KB
/
zz_generated.api.register.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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
/*
Copyright 2020 The Bulward 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 apiregister-gen. DO NOT EDIT.
package apiserver
import (
"context"
"fmt"
"k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apiserver/pkg/registry/rest"
"sigs.k8s.io/apiserver-builder-alpha/pkg/builders"
storagev1alpha1 "k8c.io/bulward/pkg/apis/storage/v1alpha1"
)
var (
ApiserverOrganizationStorage = builders.NewApiResourceWithStorage( // Resource status endpoint
InternalOrganization,
func() runtime.Object { return &Organization{} }, // Register versioned resource
func() runtime.Object { return &OrganizationList{} }, // Register versioned resource list
NewOrganizationREST,
)
ApiserverProjectStorage = builders.NewApiResourceWithStorage( // Resource status endpoint
InternalProject,
func() runtime.Object { return &Project{} }, // Register versioned resource
func() runtime.Object { return &ProjectList{} }, // Register versioned resource list
NewProjectREST,
)
InternalOrganization = builders.NewInternalResource(
"organizations",
"Organization",
func() runtime.Object { return &Organization{} },
func() runtime.Object { return &OrganizationList{} },
)
InternalOrganizationStatus = builders.NewInternalResourceStatus(
"organizations",
"OrganizationStatus",
func() runtime.Object { return &Organization{} },
func() runtime.Object { return &OrganizationList{} },
)
InternalProject = builders.NewInternalResource(
"projects",
"Project",
func() runtime.Object { return &Project{} },
func() runtime.Object { return &ProjectList{} },
)
InternalProjectStatus = builders.NewInternalResourceStatus(
"projects",
"ProjectStatus",
func() runtime.Object { return &Project{} },
func() runtime.Object { return &ProjectList{} },
)
// Registered resources and subresources
ApiVersion = builders.NewApiGroup("apiserver.bulward.io").WithKinds(
InternalOrganization,
InternalOrganizationStatus,
InternalProject,
InternalProjectStatus,
)
// Required by code generated by go2idl
AddToScheme = (&runtime.SchemeBuilder{
ApiVersion.SchemeBuilder.AddToScheme,
RegisterDefaults,
}).AddToScheme
SchemeBuilder = ApiVersion.SchemeBuilder
localSchemeBuilder = &SchemeBuilder
SchemeGroupVersion = ApiVersion.GroupVersion
)
// Required by code generated by go2idl
// Kind takes an unqualified kind and returns a Group qualified GroupKind
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}
// Required by code generated by go2idl
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
// +genclient
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type Organization struct {
metav1.TypeMeta
metav1.ObjectMeta
Spec storagev1alpha1.OrganizationSpec
Status storagev1alpha1.OrganizationStatus
}
// +genclient
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type Project struct {
metav1.TypeMeta
metav1.ObjectMeta
Spec storagev1alpha1.ProjectSpec
Status storagev1alpha1.ProjectStatus
}
//
// Organization Functions and Structs
//
// +k8s:deepcopy-gen=false
type OrganizationStrategy struct {
builders.DefaultStorageStrategy
}
// +k8s:deepcopy-gen=false
type OrganizationStatusStrategy struct {
builders.DefaultStatusStorageStrategy
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type OrganizationList struct {
metav1.TypeMeta
metav1.ListMeta
Items []Organization
}
func (Organization) NewStatus() interface{} {
return storagev1alpha1.OrganizationStatus{}
}
func (pc *Organization) GetStatus() interface{} {
return pc.Status
}
func (pc *Organization) SetStatus(s interface{}) {
pc.Status = s.(storagev1alpha1.OrganizationStatus)
}
func (pc *Organization) GetSpec() interface{} {
return pc.Spec
}
func (pc *Organization) SetSpec(s interface{}) {
pc.Spec = s.(storagev1alpha1.OrganizationSpec)
}
func (pc *Organization) GetObjectMeta() *metav1.ObjectMeta {
return &pc.ObjectMeta
}
func (pc *Organization) SetGeneration(generation int64) {
pc.ObjectMeta.Generation = generation
}
func (pc Organization) GetGeneration() int64 {
return pc.ObjectMeta.Generation
}
// Registry is an interface for things that know how to store Organization.
// +k8s:deepcopy-gen=false
type OrganizationRegistry interface {
ListOrganizations(ctx context.Context, options *internalversion.ListOptions) (*OrganizationList, error)
GetOrganization(ctx context.Context, id string, options *metav1.GetOptions) (*Organization, error)
CreateOrganization(ctx context.Context, id *Organization) (*Organization, error)
UpdateOrganization(ctx context.Context, id *Organization) (*Organization, error)
DeleteOrganization(ctx context.Context, id string) (bool, error)
}
// NewRegistry returns a new Registry interface for the given Storage. Any mismatched types will panic.
func NewOrganizationRegistry(sp builders.StandardStorageProvider) OrganizationRegistry {
return &storageOrganization{sp}
}
// Implement Registry
// storage puts strong typing around storage calls
// +k8s:deepcopy-gen=false
type storageOrganization struct {
builders.StandardStorageProvider
}
func (s *storageOrganization) ListOrganizations(ctx context.Context, options *internalversion.ListOptions) (*OrganizationList, error) {
if options != nil && options.FieldSelector != nil && !options.FieldSelector.Empty() {
return nil, fmt.Errorf("field selector not supported yet")
}
st := s.GetStandardStorage()
obj, err := st.List(ctx, options)
if err != nil {
return nil, err
}
return obj.(*OrganizationList), err
}
func (s *storageOrganization) GetOrganization(ctx context.Context, id string, options *metav1.GetOptions) (*Organization, error) {
st := s.GetStandardStorage()
obj, err := st.Get(ctx, id, options)
if err != nil {
return nil, err
}
return obj.(*Organization), nil
}
func (s *storageOrganization) CreateOrganization(ctx context.Context, object *Organization) (*Organization, error) {
st := s.GetStandardStorage()
obj, err := st.Create(ctx, object, nil, &metav1.CreateOptions{})
if err != nil {
return nil, err
}
return obj.(*Organization), nil
}
func (s *storageOrganization) UpdateOrganization(ctx context.Context, object *Organization) (*Organization, error) {
st := s.GetStandardStorage()
obj, _, err := st.Update(ctx, object.Name, rest.DefaultUpdatedObjectInfo(object), nil, nil, false, &metav1.UpdateOptions{})
if err != nil {
return nil, err
}
return obj.(*Organization), nil
}
func (s *storageOrganization) DeleteOrganization(ctx context.Context, id string) (bool, error) {
st := s.GetStandardStorage()
_, sync, err := st.Delete(ctx, id, nil, &metav1.DeleteOptions{})
return sync, err
}
//
// Project Functions and Structs
//
// +k8s:deepcopy-gen=false
type ProjectStrategy struct {
builders.DefaultStorageStrategy
}
// +k8s:deepcopy-gen=false
type ProjectStatusStrategy struct {
builders.DefaultStatusStorageStrategy
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type ProjectList struct {
metav1.TypeMeta
metav1.ListMeta
Items []Project
}
func (Project) NewStatus() interface{} {
return storagev1alpha1.ProjectStatus{}
}
func (pc *Project) GetStatus() interface{} {
return pc.Status
}
func (pc *Project) SetStatus(s interface{}) {
pc.Status = s.(storagev1alpha1.ProjectStatus)
}
func (pc *Project) GetSpec() interface{} {
return pc.Spec
}
func (pc *Project) SetSpec(s interface{}) {
pc.Spec = s.(storagev1alpha1.ProjectSpec)
}
func (pc *Project) GetObjectMeta() *metav1.ObjectMeta {
return &pc.ObjectMeta
}
func (pc *Project) SetGeneration(generation int64) {
pc.ObjectMeta.Generation = generation
}
func (pc Project) GetGeneration() int64 {
return pc.ObjectMeta.Generation
}
// Registry is an interface for things that know how to store Project.
// +k8s:deepcopy-gen=false
type ProjectRegistry interface {
ListProjects(ctx context.Context, options *internalversion.ListOptions) (*ProjectList, error)
GetProject(ctx context.Context, id string, options *metav1.GetOptions) (*Project, error)
CreateProject(ctx context.Context, id *Project) (*Project, error)
UpdateProject(ctx context.Context, id *Project) (*Project, error)
DeleteProject(ctx context.Context, id string) (bool, error)
}
// NewRegistry returns a new Registry interface for the given Storage. Any mismatched types will panic.
func NewProjectRegistry(sp builders.StandardStorageProvider) ProjectRegistry {
return &storageProject{sp}
}
// Implement Registry
// storage puts strong typing around storage calls
// +k8s:deepcopy-gen=false
type storageProject struct {
builders.StandardStorageProvider
}
func (s *storageProject) ListProjects(ctx context.Context, options *internalversion.ListOptions) (*ProjectList, error) {
if options != nil && options.FieldSelector != nil && !options.FieldSelector.Empty() {
return nil, fmt.Errorf("field selector not supported yet")
}
st := s.GetStandardStorage()
obj, err := st.List(ctx, options)
if err != nil {
return nil, err
}
return obj.(*ProjectList), err
}
func (s *storageProject) GetProject(ctx context.Context, id string, options *metav1.GetOptions) (*Project, error) {
st := s.GetStandardStorage()
obj, err := st.Get(ctx, id, options)
if err != nil {
return nil, err
}
return obj.(*Project), nil
}
func (s *storageProject) CreateProject(ctx context.Context, object *Project) (*Project, error) {
st := s.GetStandardStorage()
obj, err := st.Create(ctx, object, nil, &metav1.CreateOptions{})
if err != nil {
return nil, err
}
return obj.(*Project), nil
}
func (s *storageProject) UpdateProject(ctx context.Context, object *Project) (*Project, error) {
st := s.GetStandardStorage()
obj, _, err := st.Update(ctx, object.Name, rest.DefaultUpdatedObjectInfo(object), nil, nil, false, &metav1.UpdateOptions{})
if err != nil {
return nil, err
}
return obj.(*Project), nil
}
func (s *storageProject) DeleteProject(ctx context.Context, id string) (bool, error) {
st := s.GetStandardStorage()
_, sync, err := st.Delete(ctx, id, nil, &metav1.DeleteOptions{})
return sync, err
}