mirror of
https://github.com/rancher/types.git
synced 2025-06-27 22:16:48 +00:00
generated files
This commit is contained in:
parent
c4d44c02bd
commit
e4aa8d8e7d
60
apis/networking.k8s.io/v1/zz_generated_deepcopy.go
Normal file
60
apis/networking.k8s.io/v1/zz_generated_deepcopy.go
Normal file
@ -0,0 +1,60 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
reflect "reflect"
|
||||
|
||||
networking_v1 "k8s.io/api/networking/v1"
|
||||
conversion "k8s.io/apimachinery/pkg/conversion"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(RegisterDeepCopies)
|
||||
}
|
||||
|
||||
// RegisterDeepCopies adds deep-copy functions to the given scheme. Public
|
||||
// to allow building arbitrary schemes.
|
||||
//
|
||||
// Deprecated: deepcopy registration will go away when static deepcopy is fully implemented.
|
||||
func RegisterDeepCopies(scheme *runtime.Scheme) error {
|
||||
return scheme.AddGeneratedDeepCopyFuncs(
|
||||
conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||
in.(*NetworkPolicyList).DeepCopyInto(out.(*NetworkPolicyList))
|
||||
return nil
|
||||
}, InType: reflect.TypeOf(&NetworkPolicyList{})},
|
||||
)
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NetworkPolicyList) DeepCopyInto(out *NetworkPolicyList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ListMeta = in.ListMeta
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]networking_v1.NetworkPolicy, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkPolicyList.
|
||||
func (in *NetworkPolicyList) DeepCopy() *NetworkPolicyList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(NetworkPolicyList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *NetworkPolicyList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
69
apis/networking.k8s.io/v1/zz_generated_k8s_client.go
Normal file
69
apis/networking.k8s.io/v1/zz_generated_k8s_client.go
Normal file
@ -0,0 +1,69 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/rancher/norman/clientbase"
|
||||
"github.com/rancher/norman/controller"
|
||||
"k8s.io/client-go/dynamic"
|
||||
"k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
type Interface interface {
|
||||
RESTClient() rest.Interface
|
||||
controller.Starter
|
||||
|
||||
NetworkPoliciesGetter
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
sync.Mutex
|
||||
restClient rest.Interface
|
||||
starters []controller.Starter
|
||||
|
||||
networkPolicyControllers map[string]NetworkPolicyController
|
||||
}
|
||||
|
||||
func NewForConfig(config rest.Config) (Interface, error) {
|
||||
if config.NegotiatedSerializer == nil {
|
||||
configConfig := dynamic.ContentConfig()
|
||||
config.NegotiatedSerializer = configConfig.NegotiatedSerializer
|
||||
}
|
||||
|
||||
restClient, err := rest.UnversionedRESTClientFor(&config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Client{
|
||||
restClient: restClient,
|
||||
|
||||
networkPolicyControllers: map[string]NetworkPolicyController{},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Client) RESTClient() rest.Interface {
|
||||
return c.restClient
|
||||
}
|
||||
|
||||
func (c *Client) Sync(ctx context.Context) error {
|
||||
return controller.Sync(ctx, c.starters...)
|
||||
}
|
||||
|
||||
func (c *Client) Start(ctx context.Context, threadiness int) error {
|
||||
return controller.Start(ctx, threadiness, c.starters...)
|
||||
}
|
||||
|
||||
type NetworkPoliciesGetter interface {
|
||||
NetworkPolicies(namespace string) NetworkPolicyInterface
|
||||
}
|
||||
|
||||
func (c *Client) NetworkPolicies(namespace string) NetworkPolicyInterface {
|
||||
objectClient := clientbase.NewObjectClient(namespace, c.restClient, &NetworkPolicyResource, NetworkPolicyGroupVersionKind, networkPolicyFactory{})
|
||||
return &networkPolicyClient{
|
||||
ns: namespace,
|
||||
client: c,
|
||||
objectClient: objectClient,
|
||||
}
|
||||
}
|
@ -0,0 +1,253 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/rancher/norman/clientbase"
|
||||
"github.com/rancher/norman/controller"
|
||||
"k8s.io/api/networking/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
var (
|
||||
NetworkPolicyGroupVersionKind = schema.GroupVersionKind{
|
||||
Version: Version,
|
||||
Group: GroupName,
|
||||
Kind: "NetworkPolicy",
|
||||
}
|
||||
NetworkPolicyResource = metav1.APIResource{
|
||||
Name: "networkpolicies",
|
||||
SingularName: "networkpolicy",
|
||||
Namespaced: true,
|
||||
|
||||
Kind: NetworkPolicyGroupVersionKind.Kind,
|
||||
}
|
||||
)
|
||||
|
||||
type NetworkPolicyList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []v1.NetworkPolicy
|
||||
}
|
||||
|
||||
type NetworkPolicyHandlerFunc func(key string, obj *v1.NetworkPolicy) error
|
||||
|
||||
type NetworkPolicyLister interface {
|
||||
List(namespace string, selector labels.Selector) (ret []*v1.NetworkPolicy, err error)
|
||||
Get(namespace, name string) (*v1.NetworkPolicy, error)
|
||||
}
|
||||
|
||||
type NetworkPolicyController interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() NetworkPolicyLister
|
||||
AddHandler(name string, handler NetworkPolicyHandlerFunc)
|
||||
AddClusterScopedHandler(name, clusterName string, handler NetworkPolicyHandlerFunc)
|
||||
Enqueue(namespace, name string)
|
||||
Sync(ctx context.Context) error
|
||||
Start(ctx context.Context, threadiness int) error
|
||||
}
|
||||
|
||||
type NetworkPolicyInterface interface {
|
||||
ObjectClient() *clientbase.ObjectClient
|
||||
Create(*v1.NetworkPolicy) (*v1.NetworkPolicy, error)
|
||||
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.NetworkPolicy, error)
|
||||
Get(name string, opts metav1.GetOptions) (*v1.NetworkPolicy, error)
|
||||
Update(*v1.NetworkPolicy) (*v1.NetworkPolicy, error)
|
||||
Delete(name string, options *metav1.DeleteOptions) error
|
||||
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
|
||||
List(opts metav1.ListOptions) (*NetworkPolicyList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
|
||||
Controller() NetworkPolicyController
|
||||
AddHandler(name string, sync NetworkPolicyHandlerFunc)
|
||||
AddLifecycle(name string, lifecycle NetworkPolicyLifecycle)
|
||||
AddClusterScopedHandler(name, clusterName string, sync NetworkPolicyHandlerFunc)
|
||||
AddClusterScopedLifecycle(name, clusterName string, lifecycle NetworkPolicyLifecycle)
|
||||
}
|
||||
|
||||
type networkPolicyLister struct {
|
||||
controller *networkPolicyController
|
||||
}
|
||||
|
||||
func (l *networkPolicyLister) List(namespace string, selector labels.Selector) (ret []*v1.NetworkPolicy, err error) {
|
||||
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
|
||||
ret = append(ret, obj.(*v1.NetworkPolicy))
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (l *networkPolicyLister) Get(namespace, name string) (*v1.NetworkPolicy, error) {
|
||||
var key string
|
||||
if namespace != "" {
|
||||
key = namespace + "/" + name
|
||||
} else {
|
||||
key = name
|
||||
}
|
||||
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !exists {
|
||||
return nil, errors.NewNotFound(schema.GroupResource{
|
||||
Group: NetworkPolicyGroupVersionKind.Group,
|
||||
Resource: "networkPolicy",
|
||||
}, name)
|
||||
}
|
||||
return obj.(*v1.NetworkPolicy), nil
|
||||
}
|
||||
|
||||
type networkPolicyController struct {
|
||||
controller.GenericController
|
||||
}
|
||||
|
||||
func (c *networkPolicyController) Lister() NetworkPolicyLister {
|
||||
return &networkPolicyLister{
|
||||
controller: c,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *networkPolicyController) AddHandler(name string, handler NetworkPolicyHandlerFunc) {
|
||||
c.GenericController.AddHandler(name, func(key string) error {
|
||||
obj, exists, err := c.Informer().GetStore().GetByKey(key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !exists {
|
||||
return handler(key, nil)
|
||||
}
|
||||
return handler(key, obj.(*v1.NetworkPolicy))
|
||||
})
|
||||
}
|
||||
|
||||
func (c *networkPolicyController) AddClusterScopedHandler(name, cluster string, handler NetworkPolicyHandlerFunc) {
|
||||
c.GenericController.AddHandler(name, func(key string) error {
|
||||
obj, exists, err := c.Informer().GetStore().GetByKey(key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !exists {
|
||||
return handler(key, nil)
|
||||
}
|
||||
|
||||
if !controller.ObjectInCluster(cluster, obj) {
|
||||
return nil
|
||||
}
|
||||
|
||||
return handler(key, obj.(*v1.NetworkPolicy))
|
||||
})
|
||||
}
|
||||
|
||||
type networkPolicyFactory struct {
|
||||
}
|
||||
|
||||
func (c networkPolicyFactory) Object() runtime.Object {
|
||||
return &v1.NetworkPolicy{}
|
||||
}
|
||||
|
||||
func (c networkPolicyFactory) List() runtime.Object {
|
||||
return &NetworkPolicyList{}
|
||||
}
|
||||
|
||||
func (s *networkPolicyClient) Controller() NetworkPolicyController {
|
||||
s.client.Lock()
|
||||
defer s.client.Unlock()
|
||||
|
||||
c, ok := s.client.networkPolicyControllers[s.ns]
|
||||
if ok {
|
||||
return c
|
||||
}
|
||||
|
||||
genericController := controller.NewGenericController(NetworkPolicyGroupVersionKind.Kind+"Controller",
|
||||
s.objectClient)
|
||||
|
||||
c = &networkPolicyController{
|
||||
GenericController: genericController,
|
||||
}
|
||||
|
||||
s.client.networkPolicyControllers[s.ns] = c
|
||||
s.client.starters = append(s.client.starters, c)
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
type networkPolicyClient struct {
|
||||
client *Client
|
||||
ns string
|
||||
objectClient *clientbase.ObjectClient
|
||||
controller NetworkPolicyController
|
||||
}
|
||||
|
||||
func (s *networkPolicyClient) ObjectClient() *clientbase.ObjectClient {
|
||||
return s.objectClient
|
||||
}
|
||||
|
||||
func (s *networkPolicyClient) Create(o *v1.NetworkPolicy) (*v1.NetworkPolicy, error) {
|
||||
obj, err := s.objectClient.Create(o)
|
||||
return obj.(*v1.NetworkPolicy), err
|
||||
}
|
||||
|
||||
func (s *networkPolicyClient) Get(name string, opts metav1.GetOptions) (*v1.NetworkPolicy, error) {
|
||||
obj, err := s.objectClient.Get(name, opts)
|
||||
return obj.(*v1.NetworkPolicy), err
|
||||
}
|
||||
|
||||
func (s *networkPolicyClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.NetworkPolicy, error) {
|
||||
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
|
||||
return obj.(*v1.NetworkPolicy), err
|
||||
}
|
||||
|
||||
func (s *networkPolicyClient) Update(o *v1.NetworkPolicy) (*v1.NetworkPolicy, error) {
|
||||
obj, err := s.objectClient.Update(o.Name, o)
|
||||
return obj.(*v1.NetworkPolicy), err
|
||||
}
|
||||
|
||||
func (s *networkPolicyClient) Delete(name string, options *metav1.DeleteOptions) error {
|
||||
return s.objectClient.Delete(name, options)
|
||||
}
|
||||
|
||||
func (s *networkPolicyClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
|
||||
return s.objectClient.DeleteNamespaced(namespace, name, options)
|
||||
}
|
||||
|
||||
func (s *networkPolicyClient) List(opts metav1.ListOptions) (*NetworkPolicyList, error) {
|
||||
obj, err := s.objectClient.List(opts)
|
||||
return obj.(*NetworkPolicyList), err
|
||||
}
|
||||
|
||||
func (s *networkPolicyClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||
return s.objectClient.Watch(opts)
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched deployment.
|
||||
func (s *networkPolicyClient) Patch(o *v1.NetworkPolicy, data []byte, subresources ...string) (*v1.NetworkPolicy, error) {
|
||||
obj, err := s.objectClient.Patch(o.Name, o, data, subresources...)
|
||||
return obj.(*v1.NetworkPolicy), err
|
||||
}
|
||||
|
||||
func (s *networkPolicyClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
|
||||
}
|
||||
|
||||
func (s *networkPolicyClient) AddHandler(name string, sync NetworkPolicyHandlerFunc) {
|
||||
s.Controller().AddHandler(name, sync)
|
||||
}
|
||||
|
||||
func (s *networkPolicyClient) AddLifecycle(name string, lifecycle NetworkPolicyLifecycle) {
|
||||
sync := NewNetworkPolicyLifecycleAdapter(name, false, s, lifecycle)
|
||||
s.AddHandler(name, sync)
|
||||
}
|
||||
|
||||
func (s *networkPolicyClient) AddClusterScopedHandler(name, clusterName string, sync NetworkPolicyHandlerFunc) {
|
||||
s.Controller().AddClusterScopedHandler(name, clusterName, sync)
|
||||
}
|
||||
|
||||
func (s *networkPolicyClient) AddClusterScopedLifecycle(name, clusterName string, lifecycle NetworkPolicyLifecycle) {
|
||||
sync := NewNetworkPolicyLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
|
||||
s.AddClusterScopedHandler(name, clusterName, sync)
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"github.com/rancher/norman/lifecycle"
|
||||
"k8s.io/api/networking/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
type NetworkPolicyLifecycle interface {
|
||||
Create(obj *v1.NetworkPolicy) (*v1.NetworkPolicy, error)
|
||||
Remove(obj *v1.NetworkPolicy) (*v1.NetworkPolicy, error)
|
||||
Updated(obj *v1.NetworkPolicy) (*v1.NetworkPolicy, error)
|
||||
}
|
||||
|
||||
type networkPolicyLifecycleAdapter struct {
|
||||
lifecycle NetworkPolicyLifecycle
|
||||
}
|
||||
|
||||
func (w *networkPolicyLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
|
||||
o, err := w.lifecycle.Create(obj.(*v1.NetworkPolicy))
|
||||
if o == nil {
|
||||
return nil, err
|
||||
}
|
||||
return o, err
|
||||
}
|
||||
|
||||
func (w *networkPolicyLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
|
||||
o, err := w.lifecycle.Remove(obj.(*v1.NetworkPolicy))
|
||||
if o == nil {
|
||||
return nil, err
|
||||
}
|
||||
return o, err
|
||||
}
|
||||
|
||||
func (w *networkPolicyLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
|
||||
o, err := w.lifecycle.Updated(obj.(*v1.NetworkPolicy))
|
||||
if o == nil {
|
||||
return nil, err
|
||||
}
|
||||
return o, err
|
||||
}
|
||||
|
||||
func NewNetworkPolicyLifecycleAdapter(name string, clusterScoped bool, client NetworkPolicyInterface, l NetworkPolicyLifecycle) NetworkPolicyHandlerFunc {
|
||||
adapter := &networkPolicyLifecycleAdapter{lifecycle: l}
|
||||
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
|
||||
return func(key string, obj *v1.NetworkPolicy) error {
|
||||
if obj == nil {
|
||||
return syncFn(key, nil)
|
||||
}
|
||||
return syncFn(key, obj)
|
||||
}
|
||||
}
|
39
apis/networking.k8s.io/v1/zz_generated_scheme.go
Normal file
39
apis/networking.k8s.io/v1/zz_generated_scheme.go
Normal file
@ -0,0 +1,39 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
const (
|
||||
GroupName = "networking.k8s.io"
|
||||
Version = "v1"
|
||||
)
|
||||
|
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: Version}
|
||||
|
||||
// Kind takes an unqualified kind and returns a Group qualified GroupKind
|
||||
func Kind(kind string) schema.GroupKind {
|
||||
return SchemeGroupVersion.WithKind(kind).GroupKind()
|
||||
}
|
||||
|
||||
// Resource takes an unqualified resource and returns a Group qualified GroupResource
|
||||
func Resource(resource string) schema.GroupResource {
|
||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
||||
}
|
||||
|
||||
var (
|
||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
// Adds the list of known types to api.Scheme.
|
||||
func addKnownTypes(scheme *runtime.Scheme) error {
|
||||
// TODO this gets cleaned up when the types are fixed
|
||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||
|
||||
&NetworkPolicyList{},
|
||||
)
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user