diff --git a/config/crd/bases/node.katalyst.kubewharf.io_customnoderesources.yaml b/config/crd/bases/node.katalyst.kubewharf.io_customnoderesources.yaml index 6b950f5f..d1d92602 100644 --- a/config/crd/bases/node.katalyst.kubewharf.io_customnoderesources.yaml +++ b/config/crd/bases/node.katalyst.kubewharf.io_customnoderesources.yaml @@ -21,7 +21,8 @@ spec: schema: openAPIV3Schema: description: CustomNodeResource captures information about a custom defined - node resource CustomNodeResource objects are non-namespaced. + node resource, mainly focus on static attributes and resources CustomNodeResource + objects are non-namespaced. properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation diff --git a/config/crd/bases/node.katalyst.kubewharf.io_nodeprofiledescriptors.yaml b/config/crd/bases/node.katalyst.kubewharf.io_nodeprofiledescriptors.yaml new file mode 100644 index 00000000..17ae887f --- /dev/null +++ b/config/crd/bases/node.katalyst.kubewharf.io_nodeprofiledescriptors.yaml @@ -0,0 +1,146 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.9.0 + creationTimestamp: null + name: nodeprofiledescriptors.node.katalyst.kubewharf.io +spec: + group: node.katalyst.kubewharf.io + names: + kind: NodeProfileDescriptor + listKind: NodeProfileDescriptorList + plural: nodeprofiledescriptors + shortNames: + - npd + singular: nodeprofiledescriptor + scope: Cluster + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: NodeProfileDescriptor captures information about node, such as + node-related metrics NodeProfileDescriptor objects are non-namespaced. + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: Spec defines the behavior of a NodeProfileDescriptor. + type: object + status: + description: Status represents the current information about a NodeProfileDescriptor. + This data may not be up-to-date. + properties: + nodeMetrics: + description: NodeMetrics contains the node-related metrics + items: + properties: + metrics: + items: + properties: + aggregator: + description: the aggregator of the metric + type: string + metricLabels: + additionalProperties: + type: string + description: a set of labels that identify a single time + series for the metric + type: object + metricName: + description: the name of the metric + type: string + timestamp: + description: indicates the time at which the metrics were + produced + format: date-time + type: string + value: + anyOf: + - type: integer + - type: string + description: the value of the metric + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + window: + description: indicates the window ([Timestamp-Window, + Timestamp]) from which these metrics were calculated, + when returning rate metrics calculated from cumulative + metrics (or zero for non-calculated instantaneous metrics). + type: string + type: object + type: array + scope: + type: string + type: object + type: array + podMetrics: + description: PodMetrics contains the pod-related metrics + items: + properties: + podMetrics: + items: + properties: + metrics: + items: + properties: + aggregator: + description: the aggregator of the metric + type: string + metricLabels: + additionalProperties: + type: string + description: a set of labels that identify a single + time series for the metric + type: object + metricName: + description: the name of the metric + type: string + timestamp: + description: indicates the time at which the metrics + were produced + format: date-time + type: string + value: + anyOf: + - type: integer + - type: string + description: the value of the metric + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + window: + description: indicates the window ([Timestamp-Window, + Timestamp]) from which these metrics were calculated, + when returning rate metrics calculated from cumulative + metrics (or zero for non-calculated instantaneous + metrics). + type: string + type: object + type: array + name: + type: string + namespace: + type: string + type: object + type: array + scope: + type: string + type: object + type: array + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/pkg/apis/node/v1alpha1/register.go b/pkg/apis/node/v1alpha1/register.go index 79c79975..7b36fb8c 100644 --- a/pkg/apis/node/v1alpha1/register.go +++ b/pkg/apis/node/v1alpha1/register.go @@ -33,6 +33,7 @@ var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha // ResourceNameKatalystCNR is used to construct standard gvr const ( ResourceNameKatalystCNR = "customnoderesources" + ResourceNameKatalystNPD = "nodeprofiledescriptor" ) // Resource takes an unqualified resource and returns a Group qualified GroupResource @@ -52,6 +53,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, &CustomNodeResource{}, &CustomNodeResourceList{}, + &NodeProfileDescriptor{}, + &NodeProfileDescriptorList{}, ) v1.AddToGroupVersion(scheme, SchemeGroupVersion) diff --git a/pkg/apis/node/v1alpha1/types.go b/pkg/apis/node/v1alpha1/types.go index 3d767f1c..6090b2bb 100644 --- a/pkg/apis/node/v1alpha1/types.go +++ b/pkg/apis/node/v1alpha1/types.go @@ -28,7 +28,7 @@ import ( // +kubebuilder:resource:scope=Cluster,shortName=kcnr // +kubebuilder:subresource:status -// CustomNodeResource captures information about a custom defined node resource +// CustomNodeResource captures information about a custom defined node resource, mainly focus on static attributes and resources // CustomNodeResource objects are non-namespaced. type CustomNodeResource struct { metav1.TypeMeta `json:",inline"` @@ -326,3 +326,122 @@ type NUMAMetricInfo struct { // Usage contains the real-time resource usage for this NUMA node Usage *ResourceMetric `json:"usage"` } + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:scope=Cluster,shortName=npd +// +kubebuilder:subresource:status + +// NodeProfileDescriptor captures information about node, such as node-related metrics +// NodeProfileDescriptor objects are non-namespaced. +type NodeProfileDescriptor struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec defines the behavior of a NodeProfileDescriptor. + // +optional + Spec NodeProfileDescriptorSpec `json:"spec,omitempty"` + + // Status represents the current information about a NodeProfileDescriptor. + // This data may not be up-to-date. + // +optional + Status NodeProfileDescriptorStatus `json:"status,omitempty"` +} + +type NodeProfileDescriptorSpec struct { +} + +type NodeProfileDescriptorStatus struct { + // NodeMetrics contains the node-related metrics + // +optional + NodeMetrics []ScopedNodeMetrics `json:"nodeMetrics,omitempty"` + + // PodMetrics contains the pod-related metrics + // +optional + PodMetrics []ScopedPodMetrics `json:"podMetrics,omitempty"` +} + +type ScopedNodeMetrics struct { + // +optional + Scope string `json:"scope,omitempty"` + + // +optional + Metrics []MetricValue `json:"metrics,omitempty"` +} + +type ScopedPodMetrics struct { + // +optional + Scope string `json:"scope,omitempty"` + + // +optional + PodMetrics []PodMetric `json:"podMetrics,omitempty"` +} + +type PodMetric struct { + // +optional + Namespace string `json:"namespace,omitempty"` + + // +optional + Name string `json:"name,omitempty"` + + // +optional + Metrics []MetricValue `json:"metrics,omitempty"` +} + +type Aggregator string + +const ( + AggregatorAvg Aggregator = "avg" + AggregatorMax Aggregator = "max" + AggregatorMin Aggregator = "min" + AggregatorCount Aggregator = "count" + AggregatorP99 Aggregator = "p99" + AggregatorP95 Aggregator = "p95" + AggregatorP90 Aggregator = "p90" +) + +type MetricValue struct { + // the name of the metric + // +optional + MetricName string `json:"metricName,omitempty"` + + // a set of labels that identify a single time series for the metric + // +optional + MetricLabels map[string]string `json:"metricLabels,omitempty"` + + // indicates the time at which the metrics were produced + // +optional + Timestamp metav1.Time `json:"timestamp,omitempty"` + + // the aggregator of the metric + // +optional + Aggregator *Aggregator `json:"aggregator,omitempty"` + + // indicates the window ([Timestamp-Window, Timestamp]) from + // which these metrics were calculated, when returning rate + // metrics calculated from cumulative metrics (or zero for + // non-calculated instantaneous metrics). + // +optional + Window *metav1.Duration `json:"window,omitempty"` + + // the value of the metric + // +optional + Value resource.Quantity `json:"value,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// NodeProfileDescriptorList is a collection of NodeProfileDescriptor objects. +type NodeProfileDescriptorList struct { + metav1.TypeMeta `json:",inline"` + + // Standard list metadata + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + + // items is the list of CNRs + Items []NodeProfileDescriptor `json:"items"` +} diff --git a/pkg/apis/node/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/node/v1alpha1/zz_generated.deepcopy.go index 7003430a..942e4527 100644 --- a/pkg/apis/node/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/node/v1alpha1/zz_generated.deepcopy.go @@ -24,6 +24,7 @@ package v1alpha1 import ( v1 "k8s.io/api/core/v1" resource "k8s.io/apimachinery/pkg/api/resource" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -248,6 +249,41 @@ func (in *GroupMetricInfo) DeepCopy() *GroupMetricInfo { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetricValue) DeepCopyInto(out *MetricValue) { + *out = *in + if in.MetricLabels != nil { + in, out := &in.MetricLabels, &out.MetricLabels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + in.Timestamp.DeepCopyInto(&out.Timestamp) + if in.Aggregator != nil { + in, out := &in.Aggregator, &out.Aggregator + *out = new(Aggregator) + **out = **in + } + if in.Window != nil { + in, out := &in.Window, &out.Window + *out = new(metav1.Duration) + **out = **in + } + out.Value = in.Value.DeepCopy() + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricValue. +func (in *MetricValue) DeepCopy() *MetricValue { + if in == nil { + return nil + } + out := new(MetricValue) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NUMAMetricInfo) DeepCopyInto(out *NUMAMetricInfo) { *out = *in @@ -315,6 +351,136 @@ func (in *NodeMetricStatus) DeepCopy() *NodeMetricStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeProfileDescriptor) DeepCopyInto(out *NodeProfileDescriptor) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeProfileDescriptor. +func (in *NodeProfileDescriptor) DeepCopy() *NodeProfileDescriptor { + if in == nil { + return nil + } + out := new(NodeProfileDescriptor) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NodeProfileDescriptor) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeProfileDescriptorList) DeepCopyInto(out *NodeProfileDescriptorList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]NodeProfileDescriptor, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeProfileDescriptorList. +func (in *NodeProfileDescriptorList) DeepCopy() *NodeProfileDescriptorList { + if in == nil { + return nil + } + out := new(NodeProfileDescriptorList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NodeProfileDescriptorList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeProfileDescriptorSpec) DeepCopyInto(out *NodeProfileDescriptorSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeProfileDescriptorSpec. +func (in *NodeProfileDescriptorSpec) DeepCopy() *NodeProfileDescriptorSpec { + if in == nil { + return nil + } + out := new(NodeProfileDescriptorSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeProfileDescriptorStatus) DeepCopyInto(out *NodeProfileDescriptorStatus) { + *out = *in + if in.NodeMetrics != nil { + in, out := &in.NodeMetrics, &out.NodeMetrics + *out = make([]ScopedNodeMetrics, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.PodMetrics != nil { + in, out := &in.PodMetrics, &out.PodMetrics + *out = make([]ScopedPodMetrics, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeProfileDescriptorStatus. +func (in *NodeProfileDescriptorStatus) DeepCopy() *NodeProfileDescriptorStatus { + if in == nil { + return nil + } + out := new(NodeProfileDescriptorStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodMetric) DeepCopyInto(out *PodMetric) { + *out = *in + if in.Metrics != nil { + in, out := &in.Metrics, &out.Metrics + *out = make([]MetricValue, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodMetric. +func (in *PodMetric) DeepCopy() *PodMetric { + if in == nil { + return nil + } + out := new(PodMetric) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Property) DeepCopyInto(out *Property) { *out = *in @@ -433,6 +599,52 @@ func (in *Resources) DeepCopy() *Resources { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ScopedNodeMetrics) DeepCopyInto(out *ScopedNodeMetrics) { + *out = *in + if in.Metrics != nil { + in, out := &in.Metrics, &out.Metrics + *out = make([]MetricValue, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ScopedNodeMetrics. +func (in *ScopedNodeMetrics) DeepCopy() *ScopedNodeMetrics { + if in == nil { + return nil + } + out := new(ScopedNodeMetrics) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ScopedPodMetrics) DeepCopyInto(out *ScopedPodMetrics) { + *out = *in + if in.PodMetrics != nil { + in, out := &in.PodMetrics, &out.PodMetrics + *out = make([]PodMetric, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ScopedPodMetrics. +func (in *ScopedPodMetrics) DeepCopy() *ScopedPodMetrics { + if in == nil { + return nil + } + out := new(ScopedPodMetrics) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Sibling) DeepCopyInto(out *Sibling) { *out = *in diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index 9aaf89ef..0f7d3116 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -51,14 +51,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index ffa9cdb4..17ad6fb2 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -51,14 +51,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/pkg/client/clientset/versioned/typed/node/v1alpha1/fake/fake_node_client.go b/pkg/client/clientset/versioned/typed/node/v1alpha1/fake/fake_node_client.go index 3c5f4479..d4ec6b81 100644 --- a/pkg/client/clientset/versioned/typed/node/v1alpha1/fake/fake_node_client.go +++ b/pkg/client/clientset/versioned/typed/node/v1alpha1/fake/fake_node_client.go @@ -32,6 +32,10 @@ func (c *FakeNodeV1alpha1) CustomNodeResources() v1alpha1.CustomNodeResourceInte return &FakeCustomNodeResources{c} } +func (c *FakeNodeV1alpha1) NodeProfileDescriptors() v1alpha1.NodeProfileDescriptorInterface { + return &FakeNodeProfileDescriptors{c} +} + // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. func (c *FakeNodeV1alpha1) RESTClient() rest.Interface { diff --git a/pkg/client/clientset/versioned/typed/node/v1alpha1/fake/fake_nodeprofiledescriptor.go b/pkg/client/clientset/versioned/typed/node/v1alpha1/fake/fake_nodeprofiledescriptor.go new file mode 100644 index 00000000..c5ff15db --- /dev/null +++ b/pkg/client/clientset/versioned/typed/node/v1alpha1/fake/fake_nodeprofiledescriptor.go @@ -0,0 +1,133 @@ +/* +Copyright 2022 The Katalyst 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 client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/node/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeNodeProfileDescriptors implements NodeProfileDescriptorInterface +type FakeNodeProfileDescriptors struct { + Fake *FakeNodeV1alpha1 +} + +var nodeprofiledescriptorsResource = schema.GroupVersionResource{Group: "node.katalyst.kubewharf.io", Version: "v1alpha1", Resource: "nodeprofiledescriptors"} + +var nodeprofiledescriptorsKind = schema.GroupVersionKind{Group: "node.katalyst.kubewharf.io", Version: "v1alpha1", Kind: "NodeProfileDescriptor"} + +// Get takes name of the nodeProfileDescriptor, and returns the corresponding nodeProfileDescriptor object, and an error if there is any. +func (c *FakeNodeProfileDescriptors) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.NodeProfileDescriptor, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(nodeprofiledescriptorsResource, name), &v1alpha1.NodeProfileDescriptor{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NodeProfileDescriptor), err +} + +// List takes label and field selectors, and returns the list of NodeProfileDescriptors that match those selectors. +func (c *FakeNodeProfileDescriptors) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NodeProfileDescriptorList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(nodeprofiledescriptorsResource, nodeprofiledescriptorsKind, opts), &v1alpha1.NodeProfileDescriptorList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.NodeProfileDescriptorList{ListMeta: obj.(*v1alpha1.NodeProfileDescriptorList).ListMeta} + for _, item := range obj.(*v1alpha1.NodeProfileDescriptorList).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 nodeProfileDescriptors. +func (c *FakeNodeProfileDescriptors) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(nodeprofiledescriptorsResource, opts)) +} + +// Create takes the representation of a nodeProfileDescriptor and creates it. Returns the server's representation of the nodeProfileDescriptor, and an error, if there is any. +func (c *FakeNodeProfileDescriptors) Create(ctx context.Context, nodeProfileDescriptor *v1alpha1.NodeProfileDescriptor, opts v1.CreateOptions) (result *v1alpha1.NodeProfileDescriptor, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(nodeprofiledescriptorsResource, nodeProfileDescriptor), &v1alpha1.NodeProfileDescriptor{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NodeProfileDescriptor), err +} + +// Update takes the representation of a nodeProfileDescriptor and updates it. Returns the server's representation of the nodeProfileDescriptor, and an error, if there is any. +func (c *FakeNodeProfileDescriptors) Update(ctx context.Context, nodeProfileDescriptor *v1alpha1.NodeProfileDescriptor, opts v1.UpdateOptions) (result *v1alpha1.NodeProfileDescriptor, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(nodeprofiledescriptorsResource, nodeProfileDescriptor), &v1alpha1.NodeProfileDescriptor{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NodeProfileDescriptor), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeNodeProfileDescriptors) UpdateStatus(ctx context.Context, nodeProfileDescriptor *v1alpha1.NodeProfileDescriptor, opts v1.UpdateOptions) (*v1alpha1.NodeProfileDescriptor, error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceAction(nodeprofiledescriptorsResource, "status", nodeProfileDescriptor), &v1alpha1.NodeProfileDescriptor{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NodeProfileDescriptor), err +} + +// Delete takes name of the nodeProfileDescriptor and deletes it. Returns an error if one occurs. +func (c *FakeNodeProfileDescriptors) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteActionWithOptions(nodeprofiledescriptorsResource, name, opts), &v1alpha1.NodeProfileDescriptor{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeNodeProfileDescriptors) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(nodeprofiledescriptorsResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.NodeProfileDescriptorList{}) + return err +} + +// Patch applies the patch and returns the patched nodeProfileDescriptor. +func (c *FakeNodeProfileDescriptors) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NodeProfileDescriptor, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(nodeprofiledescriptorsResource, name, pt, data, subresources...), &v1alpha1.NodeProfileDescriptor{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NodeProfileDescriptor), err +} diff --git a/pkg/client/clientset/versioned/typed/node/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/node/v1alpha1/generated_expansion.go index 5c58ae6f..6d789e51 100644 --- a/pkg/client/clientset/versioned/typed/node/v1alpha1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/node/v1alpha1/generated_expansion.go @@ -19,3 +19,5 @@ limitations under the License. package v1alpha1 type CustomNodeResourceExpansion interface{} + +type NodeProfileDescriptorExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/node/v1alpha1/node_client.go b/pkg/client/clientset/versioned/typed/node/v1alpha1/node_client.go index 25e2198f..c8c006b6 100644 --- a/pkg/client/clientset/versioned/typed/node/v1alpha1/node_client.go +++ b/pkg/client/clientset/versioned/typed/node/v1alpha1/node_client.go @@ -29,6 +29,7 @@ import ( type NodeV1alpha1Interface interface { RESTClient() rest.Interface CustomNodeResourcesGetter + NodeProfileDescriptorsGetter } // NodeV1alpha1Client is used to interact with features provided by the node.katalyst.kubewharf.io group. @@ -40,6 +41,10 @@ func (c *NodeV1alpha1Client) CustomNodeResources() CustomNodeResourceInterface { return newCustomNodeResources(c) } +func (c *NodeV1alpha1Client) NodeProfileDescriptors() NodeProfileDescriptorInterface { + return newNodeProfileDescriptors(c) +} + // NewForConfig creates a new NodeV1alpha1Client for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). diff --git a/pkg/client/clientset/versioned/typed/node/v1alpha1/nodeprofiledescriptor.go b/pkg/client/clientset/versioned/typed/node/v1alpha1/nodeprofiledescriptor.go new file mode 100644 index 00000000..fc1bb6d8 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/node/v1alpha1/nodeprofiledescriptor.go @@ -0,0 +1,184 @@ +/* +Copyright 2022 The Katalyst 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 client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/node/v1alpha1" + scheme "github.com/kubewharf/katalyst-api/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// NodeProfileDescriptorsGetter has a method to return a NodeProfileDescriptorInterface. +// A group's client should implement this interface. +type NodeProfileDescriptorsGetter interface { + NodeProfileDescriptors() NodeProfileDescriptorInterface +} + +// NodeProfileDescriptorInterface has methods to work with NodeProfileDescriptor resources. +type NodeProfileDescriptorInterface interface { + Create(ctx context.Context, nodeProfileDescriptor *v1alpha1.NodeProfileDescriptor, opts v1.CreateOptions) (*v1alpha1.NodeProfileDescriptor, error) + Update(ctx context.Context, nodeProfileDescriptor *v1alpha1.NodeProfileDescriptor, opts v1.UpdateOptions) (*v1alpha1.NodeProfileDescriptor, error) + UpdateStatus(ctx context.Context, nodeProfileDescriptor *v1alpha1.NodeProfileDescriptor, opts v1.UpdateOptions) (*v1alpha1.NodeProfileDescriptor, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.NodeProfileDescriptor, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.NodeProfileDescriptorList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NodeProfileDescriptor, err error) + NodeProfileDescriptorExpansion +} + +// nodeProfileDescriptors implements NodeProfileDescriptorInterface +type nodeProfileDescriptors struct { + client rest.Interface +} + +// newNodeProfileDescriptors returns a NodeProfileDescriptors +func newNodeProfileDescriptors(c *NodeV1alpha1Client) *nodeProfileDescriptors { + return &nodeProfileDescriptors{ + client: c.RESTClient(), + } +} + +// Get takes name of the nodeProfileDescriptor, and returns the corresponding nodeProfileDescriptor object, and an error if there is any. +func (c *nodeProfileDescriptors) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.NodeProfileDescriptor, err error) { + result = &v1alpha1.NodeProfileDescriptor{} + err = c.client.Get(). + Resource("nodeprofiledescriptors"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of NodeProfileDescriptors that match those selectors. +func (c *nodeProfileDescriptors) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NodeProfileDescriptorList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.NodeProfileDescriptorList{} + err = c.client.Get(). + Resource("nodeprofiledescriptors"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested nodeProfileDescriptors. +func (c *nodeProfileDescriptors) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Resource("nodeprofiledescriptors"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a nodeProfileDescriptor and creates it. Returns the server's representation of the nodeProfileDescriptor, and an error, if there is any. +func (c *nodeProfileDescriptors) Create(ctx context.Context, nodeProfileDescriptor *v1alpha1.NodeProfileDescriptor, opts v1.CreateOptions) (result *v1alpha1.NodeProfileDescriptor, err error) { + result = &v1alpha1.NodeProfileDescriptor{} + err = c.client.Post(). + Resource("nodeprofiledescriptors"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(nodeProfileDescriptor). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a nodeProfileDescriptor and updates it. Returns the server's representation of the nodeProfileDescriptor, and an error, if there is any. +func (c *nodeProfileDescriptors) Update(ctx context.Context, nodeProfileDescriptor *v1alpha1.NodeProfileDescriptor, opts v1.UpdateOptions) (result *v1alpha1.NodeProfileDescriptor, err error) { + result = &v1alpha1.NodeProfileDescriptor{} + err = c.client.Put(). + Resource("nodeprofiledescriptors"). + Name(nodeProfileDescriptor.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(nodeProfileDescriptor). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *nodeProfileDescriptors) UpdateStatus(ctx context.Context, nodeProfileDescriptor *v1alpha1.NodeProfileDescriptor, opts v1.UpdateOptions) (result *v1alpha1.NodeProfileDescriptor, err error) { + result = &v1alpha1.NodeProfileDescriptor{} + err = c.client.Put(). + Resource("nodeprofiledescriptors"). + Name(nodeProfileDescriptor.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(nodeProfileDescriptor). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the nodeProfileDescriptor and deletes it. Returns an error if one occurs. +func (c *nodeProfileDescriptors) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("nodeprofiledescriptors"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *nodeProfileDescriptors) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("nodeprofiledescriptors"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched nodeProfileDescriptor. +func (c *nodeProfileDescriptors) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NodeProfileDescriptor, err error) { + result = &v1alpha1.NodeProfileDescriptor{} + err = c.client.Patch(pt). + Resource("nodeprofiledescriptors"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index 969bb674..43aea83e 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -78,6 +78,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource // Group=node.katalyst.kubewharf.io, Version=v1alpha1 case nodev1alpha1.SchemeGroupVersion.WithResource("customnoderesources"): return &genericInformer{resource: resource.GroupResource(), informer: f.Node().V1alpha1().CustomNodeResources().Informer()}, nil + case nodev1alpha1.SchemeGroupVersion.WithResource("nodeprofiledescriptors"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Node().V1alpha1().NodeProfileDescriptors().Informer()}, nil // Group=overcommit.katalyst.kubewharf.io, Version=v1alpha1 case overcommitv1alpha1.SchemeGroupVersion.WithResource("nodeovercommitconfigs"): diff --git a/pkg/client/informers/externalversions/node/v1alpha1/interface.go b/pkg/client/informers/externalversions/node/v1alpha1/interface.go index d246af9f..d3133125 100644 --- a/pkg/client/informers/externalversions/node/v1alpha1/interface.go +++ b/pkg/client/informers/externalversions/node/v1alpha1/interface.go @@ -26,6 +26,8 @@ import ( type Interface interface { // CustomNodeResources returns a CustomNodeResourceInformer. CustomNodeResources() CustomNodeResourceInformer + // NodeProfileDescriptors returns a NodeProfileDescriptorInformer. + NodeProfileDescriptors() NodeProfileDescriptorInformer } type version struct { @@ -43,3 +45,8 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList func (v *version) CustomNodeResources() CustomNodeResourceInformer { return &customNodeResourceInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } + +// NodeProfileDescriptors returns a NodeProfileDescriptorInformer. +func (v *version) NodeProfileDescriptors() NodeProfileDescriptorInformer { + return &nodeProfileDescriptorInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/informers/externalversions/node/v1alpha1/nodeprofiledescriptor.go b/pkg/client/informers/externalversions/node/v1alpha1/nodeprofiledescriptor.go new file mode 100644 index 00000000..2916773f --- /dev/null +++ b/pkg/client/informers/externalversions/node/v1alpha1/nodeprofiledescriptor.go @@ -0,0 +1,89 @@ +/* +Copyright 2022 The Katalyst 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + nodev1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/node/v1alpha1" + versioned "github.com/kubewharf/katalyst-api/pkg/client/clientset/versioned" + internalinterfaces "github.com/kubewharf/katalyst-api/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/kubewharf/katalyst-api/pkg/client/listers/node/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// NodeProfileDescriptorInformer provides access to a shared informer and lister for +// NodeProfileDescriptors. +type NodeProfileDescriptorInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.NodeProfileDescriptorLister +} + +type nodeProfileDescriptorInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewNodeProfileDescriptorInformer constructs a new informer for NodeProfileDescriptor type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewNodeProfileDescriptorInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredNodeProfileDescriptorInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredNodeProfileDescriptorInformer constructs a new informer for NodeProfileDescriptor type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredNodeProfileDescriptorInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NodeV1alpha1().NodeProfileDescriptors().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NodeV1alpha1().NodeProfileDescriptors().Watch(context.TODO(), options) + }, + }, + &nodev1alpha1.NodeProfileDescriptor{}, + resyncPeriod, + indexers, + ) +} + +func (f *nodeProfileDescriptorInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredNodeProfileDescriptorInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *nodeProfileDescriptorInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&nodev1alpha1.NodeProfileDescriptor{}, f.defaultInformer) +} + +func (f *nodeProfileDescriptorInformer) Lister() v1alpha1.NodeProfileDescriptorLister { + return v1alpha1.NewNodeProfileDescriptorLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/listers/node/v1alpha1/expansion_generated.go b/pkg/client/listers/node/v1alpha1/expansion_generated.go index 2c2d1f38..d0cba963 100644 --- a/pkg/client/listers/node/v1alpha1/expansion_generated.go +++ b/pkg/client/listers/node/v1alpha1/expansion_generated.go @@ -21,3 +21,7 @@ package v1alpha1 // CustomNodeResourceListerExpansion allows custom methods to be added to // CustomNodeResourceLister. type CustomNodeResourceListerExpansion interface{} + +// NodeProfileDescriptorListerExpansion allows custom methods to be added to +// NodeProfileDescriptorLister. +type NodeProfileDescriptorListerExpansion interface{} diff --git a/pkg/client/listers/node/v1alpha1/nodeprofiledescriptor.go b/pkg/client/listers/node/v1alpha1/nodeprofiledescriptor.go new file mode 100644 index 00000000..23df8a63 --- /dev/null +++ b/pkg/client/listers/node/v1alpha1/nodeprofiledescriptor.go @@ -0,0 +1,68 @@ +/* +Copyright 2022 The Katalyst 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/node/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// NodeProfileDescriptorLister helps list NodeProfileDescriptors. +// All objects returned here must be treated as read-only. +type NodeProfileDescriptorLister interface { + // List lists all NodeProfileDescriptors in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.NodeProfileDescriptor, err error) + // Get retrieves the NodeProfileDescriptor from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.NodeProfileDescriptor, error) + NodeProfileDescriptorListerExpansion +} + +// nodeProfileDescriptorLister implements the NodeProfileDescriptorLister interface. +type nodeProfileDescriptorLister struct { + indexer cache.Indexer +} + +// NewNodeProfileDescriptorLister returns a new NodeProfileDescriptorLister. +func NewNodeProfileDescriptorLister(indexer cache.Indexer) NodeProfileDescriptorLister { + return &nodeProfileDescriptorLister{indexer: indexer} +} + +// List lists all NodeProfileDescriptors in the indexer. +func (s *nodeProfileDescriptorLister) List(selector labels.Selector) (ret []*v1alpha1.NodeProfileDescriptor, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.NodeProfileDescriptor)) + }) + return ret, err +} + +// Get retrieves the NodeProfileDescriptor from the index for a given name. +func (s *nodeProfileDescriptorLister) Get(name string) (*v1alpha1.NodeProfileDescriptor, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("nodeprofiledescriptor"), name) + } + return obj.(*v1alpha1.NodeProfileDescriptor), nil +}