github.com/rancher/types@v0.0.0-20220328215343-4370ff10ecd5/apis/management.cattle.io/v3/zz_generated_cluster_template_revision_controller.go (about) 1 package v3 2 3 import ( 4 "context" 5 "time" 6 7 "github.com/rancher/norman/controller" 8 "github.com/rancher/norman/objectclient" 9 "github.com/rancher/norman/resource" 10 "k8s.io/apimachinery/pkg/api/errors" 11 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 12 "k8s.io/apimachinery/pkg/labels" 13 "k8s.io/apimachinery/pkg/runtime" 14 "k8s.io/apimachinery/pkg/runtime/schema" 15 "k8s.io/apimachinery/pkg/types" 16 "k8s.io/apimachinery/pkg/watch" 17 "k8s.io/client-go/tools/cache" 18 ) 19 20 var ( 21 ClusterTemplateRevisionGroupVersionKind = schema.GroupVersionKind{ 22 Version: Version, 23 Group: GroupName, 24 Kind: "ClusterTemplateRevision", 25 } 26 ClusterTemplateRevisionResource = metav1.APIResource{ 27 Name: "clustertemplaterevisions", 28 SingularName: "clustertemplaterevision", 29 Namespaced: true, 30 31 Kind: ClusterTemplateRevisionGroupVersionKind.Kind, 32 } 33 34 ClusterTemplateRevisionGroupVersionResource = schema.GroupVersionResource{ 35 Group: GroupName, 36 Version: Version, 37 Resource: "clustertemplaterevisions", 38 } 39 ) 40 41 func init() { 42 resource.Put(ClusterTemplateRevisionGroupVersionResource) 43 } 44 45 func NewClusterTemplateRevision(namespace, name string, obj ClusterTemplateRevision) *ClusterTemplateRevision { 46 obj.APIVersion, obj.Kind = ClusterTemplateRevisionGroupVersionKind.ToAPIVersionAndKind() 47 obj.Name = name 48 obj.Namespace = namespace 49 return &obj 50 } 51 52 type ClusterTemplateRevisionList struct { 53 metav1.TypeMeta `json:",inline"` 54 metav1.ListMeta `json:"metadata,omitempty"` 55 Items []ClusterTemplateRevision `json:"items"` 56 } 57 58 type ClusterTemplateRevisionHandlerFunc func(key string, obj *ClusterTemplateRevision) (runtime.Object, error) 59 60 type ClusterTemplateRevisionChangeHandlerFunc func(obj *ClusterTemplateRevision) (runtime.Object, error) 61 62 type ClusterTemplateRevisionLister interface { 63 List(namespace string, selector labels.Selector) (ret []*ClusterTemplateRevision, err error) 64 Get(namespace, name string) (*ClusterTemplateRevision, error) 65 } 66 67 type ClusterTemplateRevisionController interface { 68 Generic() controller.GenericController 69 Informer() cache.SharedIndexInformer 70 Lister() ClusterTemplateRevisionLister 71 AddHandler(ctx context.Context, name string, handler ClusterTemplateRevisionHandlerFunc) 72 AddFeatureHandler(ctx context.Context, enabled func() bool, name string, sync ClusterTemplateRevisionHandlerFunc) 73 AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler ClusterTemplateRevisionHandlerFunc) 74 AddClusterScopedFeatureHandler(ctx context.Context, enabled func() bool, name, clusterName string, handler ClusterTemplateRevisionHandlerFunc) 75 Enqueue(namespace, name string) 76 EnqueueAfter(namespace, name string, after time.Duration) 77 Sync(ctx context.Context) error 78 Start(ctx context.Context, threadiness int) error 79 } 80 81 type ClusterTemplateRevisionInterface interface { 82 ObjectClient() *objectclient.ObjectClient 83 Create(*ClusterTemplateRevision) (*ClusterTemplateRevision, error) 84 GetNamespaced(namespace, name string, opts metav1.GetOptions) (*ClusterTemplateRevision, error) 85 Get(name string, opts metav1.GetOptions) (*ClusterTemplateRevision, error) 86 Update(*ClusterTemplateRevision) (*ClusterTemplateRevision, error) 87 Delete(name string, options *metav1.DeleteOptions) error 88 DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error 89 List(opts metav1.ListOptions) (*ClusterTemplateRevisionList, error) 90 ListNamespaced(namespace string, opts metav1.ListOptions) (*ClusterTemplateRevisionList, error) 91 Watch(opts metav1.ListOptions) (watch.Interface, error) 92 DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error 93 Controller() ClusterTemplateRevisionController 94 AddHandler(ctx context.Context, name string, sync ClusterTemplateRevisionHandlerFunc) 95 AddFeatureHandler(ctx context.Context, enabled func() bool, name string, sync ClusterTemplateRevisionHandlerFunc) 96 AddLifecycle(ctx context.Context, name string, lifecycle ClusterTemplateRevisionLifecycle) 97 AddFeatureLifecycle(ctx context.Context, enabled func() bool, name string, lifecycle ClusterTemplateRevisionLifecycle) 98 AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync ClusterTemplateRevisionHandlerFunc) 99 AddClusterScopedFeatureHandler(ctx context.Context, enabled func() bool, name, clusterName string, sync ClusterTemplateRevisionHandlerFunc) 100 AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle ClusterTemplateRevisionLifecycle) 101 AddClusterScopedFeatureLifecycle(ctx context.Context, enabled func() bool, name, clusterName string, lifecycle ClusterTemplateRevisionLifecycle) 102 } 103 104 type clusterTemplateRevisionLister struct { 105 controller *clusterTemplateRevisionController 106 } 107 108 func (l *clusterTemplateRevisionLister) List(namespace string, selector labels.Selector) (ret []*ClusterTemplateRevision, err error) { 109 err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) { 110 ret = append(ret, obj.(*ClusterTemplateRevision)) 111 }) 112 return 113 } 114 115 func (l *clusterTemplateRevisionLister) Get(namespace, name string) (*ClusterTemplateRevision, error) { 116 var key string 117 if namespace != "" { 118 key = namespace + "/" + name 119 } else { 120 key = name 121 } 122 obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(key) 123 if err != nil { 124 return nil, err 125 } 126 if !exists { 127 return nil, errors.NewNotFound(schema.GroupResource{ 128 Group: ClusterTemplateRevisionGroupVersionKind.Group, 129 Resource: "clusterTemplateRevision", 130 }, key) 131 } 132 return obj.(*ClusterTemplateRevision), nil 133 } 134 135 type clusterTemplateRevisionController struct { 136 controller.GenericController 137 } 138 139 func (c *clusterTemplateRevisionController) Generic() controller.GenericController { 140 return c.GenericController 141 } 142 143 func (c *clusterTemplateRevisionController) Lister() ClusterTemplateRevisionLister { 144 return &clusterTemplateRevisionLister{ 145 controller: c, 146 } 147 } 148 149 func (c *clusterTemplateRevisionController) AddHandler(ctx context.Context, name string, handler ClusterTemplateRevisionHandlerFunc) { 150 c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) { 151 if obj == nil { 152 return handler(key, nil) 153 } else if v, ok := obj.(*ClusterTemplateRevision); ok { 154 return handler(key, v) 155 } else { 156 return nil, nil 157 } 158 }) 159 } 160 161 func (c *clusterTemplateRevisionController) AddFeatureHandler(ctx context.Context, enabled func() bool, name string, handler ClusterTemplateRevisionHandlerFunc) { 162 c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) { 163 if !enabled() { 164 return nil, nil 165 } else if obj == nil { 166 return handler(key, nil) 167 } else if v, ok := obj.(*ClusterTemplateRevision); ok { 168 return handler(key, v) 169 } else { 170 return nil, nil 171 } 172 }) 173 } 174 175 func (c *clusterTemplateRevisionController) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler ClusterTemplateRevisionHandlerFunc) { 176 c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) { 177 if obj == nil { 178 return handler(key, nil) 179 } else if v, ok := obj.(*ClusterTemplateRevision); ok && controller.ObjectInCluster(cluster, obj) { 180 return handler(key, v) 181 } else { 182 return nil, nil 183 } 184 }) 185 } 186 187 func (c *clusterTemplateRevisionController) AddClusterScopedFeatureHandler(ctx context.Context, enabled func() bool, name, cluster string, handler ClusterTemplateRevisionHandlerFunc) { 188 c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) { 189 if !enabled() { 190 return nil, nil 191 } else if obj == nil { 192 return handler(key, nil) 193 } else if v, ok := obj.(*ClusterTemplateRevision); ok && controller.ObjectInCluster(cluster, obj) { 194 return handler(key, v) 195 } else { 196 return nil, nil 197 } 198 }) 199 } 200 201 type clusterTemplateRevisionFactory struct { 202 } 203 204 func (c clusterTemplateRevisionFactory) Object() runtime.Object { 205 return &ClusterTemplateRevision{} 206 } 207 208 func (c clusterTemplateRevisionFactory) List() runtime.Object { 209 return &ClusterTemplateRevisionList{} 210 } 211 212 func (s *clusterTemplateRevisionClient) Controller() ClusterTemplateRevisionController { 213 s.client.Lock() 214 defer s.client.Unlock() 215 216 c, ok := s.client.clusterTemplateRevisionControllers[s.ns] 217 if ok { 218 return c 219 } 220 221 genericController := controller.NewGenericController(ClusterTemplateRevisionGroupVersionKind.Kind+"Controller", 222 s.objectClient) 223 224 c = &clusterTemplateRevisionController{ 225 GenericController: genericController, 226 } 227 228 s.client.clusterTemplateRevisionControllers[s.ns] = c 229 s.client.starters = append(s.client.starters, c) 230 231 return c 232 } 233 234 type clusterTemplateRevisionClient struct { 235 client *Client 236 ns string 237 objectClient *objectclient.ObjectClient 238 controller ClusterTemplateRevisionController 239 } 240 241 func (s *clusterTemplateRevisionClient) ObjectClient() *objectclient.ObjectClient { 242 return s.objectClient 243 } 244 245 func (s *clusterTemplateRevisionClient) Create(o *ClusterTemplateRevision) (*ClusterTemplateRevision, error) { 246 obj, err := s.objectClient.Create(o) 247 return obj.(*ClusterTemplateRevision), err 248 } 249 250 func (s *clusterTemplateRevisionClient) Get(name string, opts metav1.GetOptions) (*ClusterTemplateRevision, error) { 251 obj, err := s.objectClient.Get(name, opts) 252 return obj.(*ClusterTemplateRevision), err 253 } 254 255 func (s *clusterTemplateRevisionClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*ClusterTemplateRevision, error) { 256 obj, err := s.objectClient.GetNamespaced(namespace, name, opts) 257 return obj.(*ClusterTemplateRevision), err 258 } 259 260 func (s *clusterTemplateRevisionClient) Update(o *ClusterTemplateRevision) (*ClusterTemplateRevision, error) { 261 obj, err := s.objectClient.Update(o.Name, o) 262 return obj.(*ClusterTemplateRevision), err 263 } 264 265 func (s *clusterTemplateRevisionClient) Delete(name string, options *metav1.DeleteOptions) error { 266 return s.objectClient.Delete(name, options) 267 } 268 269 func (s *clusterTemplateRevisionClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error { 270 return s.objectClient.DeleteNamespaced(namespace, name, options) 271 } 272 273 func (s *clusterTemplateRevisionClient) List(opts metav1.ListOptions) (*ClusterTemplateRevisionList, error) { 274 obj, err := s.objectClient.List(opts) 275 return obj.(*ClusterTemplateRevisionList), err 276 } 277 278 func (s *clusterTemplateRevisionClient) ListNamespaced(namespace string, opts metav1.ListOptions) (*ClusterTemplateRevisionList, error) { 279 obj, err := s.objectClient.ListNamespaced(namespace, opts) 280 return obj.(*ClusterTemplateRevisionList), err 281 } 282 283 func (s *clusterTemplateRevisionClient) Watch(opts metav1.ListOptions) (watch.Interface, error) { 284 return s.objectClient.Watch(opts) 285 } 286 287 // Patch applies the patch and returns the patched deployment. 288 func (s *clusterTemplateRevisionClient) Patch(o *ClusterTemplateRevision, patchType types.PatchType, data []byte, subresources ...string) (*ClusterTemplateRevision, error) { 289 obj, err := s.objectClient.Patch(o.Name, o, patchType, data, subresources...) 290 return obj.(*ClusterTemplateRevision), err 291 } 292 293 func (s *clusterTemplateRevisionClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error { 294 return s.objectClient.DeleteCollection(deleteOpts, listOpts) 295 } 296 297 func (s *clusterTemplateRevisionClient) AddHandler(ctx context.Context, name string, sync ClusterTemplateRevisionHandlerFunc) { 298 s.Controller().AddHandler(ctx, name, sync) 299 } 300 301 func (s *clusterTemplateRevisionClient) AddFeatureHandler(ctx context.Context, enabled func() bool, name string, sync ClusterTemplateRevisionHandlerFunc) { 302 s.Controller().AddFeatureHandler(ctx, enabled, name, sync) 303 } 304 305 func (s *clusterTemplateRevisionClient) AddLifecycle(ctx context.Context, name string, lifecycle ClusterTemplateRevisionLifecycle) { 306 sync := NewClusterTemplateRevisionLifecycleAdapter(name, false, s, lifecycle) 307 s.Controller().AddHandler(ctx, name, sync) 308 } 309 310 func (s *clusterTemplateRevisionClient) AddFeatureLifecycle(ctx context.Context, enabled func() bool, name string, lifecycle ClusterTemplateRevisionLifecycle) { 311 sync := NewClusterTemplateRevisionLifecycleAdapter(name, false, s, lifecycle) 312 s.Controller().AddFeatureHandler(ctx, enabled, name, sync) 313 } 314 315 func (s *clusterTemplateRevisionClient) AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync ClusterTemplateRevisionHandlerFunc) { 316 s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync) 317 } 318 319 func (s *clusterTemplateRevisionClient) AddClusterScopedFeatureHandler(ctx context.Context, enabled func() bool, name, clusterName string, sync ClusterTemplateRevisionHandlerFunc) { 320 s.Controller().AddClusterScopedFeatureHandler(ctx, enabled, name, clusterName, sync) 321 } 322 323 func (s *clusterTemplateRevisionClient) AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle ClusterTemplateRevisionLifecycle) { 324 sync := NewClusterTemplateRevisionLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle) 325 s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync) 326 } 327 328 func (s *clusterTemplateRevisionClient) AddClusterScopedFeatureLifecycle(ctx context.Context, enabled func() bool, name, clusterName string, lifecycle ClusterTemplateRevisionLifecycle) { 329 sync := NewClusterTemplateRevisionLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle) 330 s.Controller().AddClusterScopedFeatureHandler(ctx, enabled, name, clusterName, sync) 331 }