diff options
| author | Shelley-BaoYue <baoyue2@huawei.com> | 2024-01-03 10:43:50 +0800 |
|---|---|---|
| committer | Shelley-BaoYue <baoyue2@huawei.com> | 2024-01-03 10:49:45 +0800 |
| commit | bb82335741d90047fafe23a3aecb9e09729ac035 (patch) | |
| tree | 1e035de9404c6445a561b916894679beaeba5f16 | |
| parent | Merge pull request #5326 from wbc6080/upgrade-mapper (diff) | |
| download | kubeedge-bb82335741d90047fafe23a3aecb9e09729ac035.tar.gz | |
add image prepull api
Signed-off-by: Shelley-BaoYue <baoyue2@huawei.com>
22 files changed, 1264 insertions, 4 deletions
diff --git a/build/admission/clusterrole.yaml b/build/admission/clusterrole.yaml index 0f3519949..92d13bf9e 100644 --- a/build/admission/clusterrole.yaml +++ b/build/admission/clusterrole.yaml @@ -26,5 +26,5 @@ rules: resources: ["rules", "ruleendpoints"] verbs: ["get", "list"] - apiGroups: ["operations.kubeedge.io"] - resources: ["nodeupgradejobs"] + resources: ["nodeupgradejobs", "imageprepulljobs"] verbs: ["get", "list"] diff --git a/build/cloud/03-clusterrole.yaml b/build/cloud/03-clusterrole.yaml index 2bb3ac7df..19978bcdb 100644 --- a/build/cloud/03-clusterrole.yaml +++ b/build/cloud/03-clusterrole.yaml @@ -37,5 +37,5 @@ rules: resources: ["*"] verbs: ["get", "list", "watch"] - apiGroups: ["operations.kubeedge.io"] - resources: ["nodeupgradejobs", "nodeupgradejobs/status"] + resources: ["nodeupgradejobs", "nodeupgradejobs/status", "imageprepulljobs", "imageprepulljobs/status"] verbs: ["get", "list", "watch", "update", "patch"] diff --git a/build/crd-samples/operations/imageprepulljob.yaml b/build/crd-samples/operations/imageprepulljob.yaml new file mode 100644 index 000000000..cebfbe27f --- /dev/null +++ b/build/crd-samples/operations/imageprepulljob.yaml @@ -0,0 +1,14 @@ +apiVersion: operations.kubeedge.io/v1alpha1 +kind: ImagePrePullJob +metadata: + name: imageprepull-example + labels: + description: ImagePrePullLabel +spec: + imagePrePullTemplate: + images: + - busybox:latest + nodes: + - edgenode1 # Need to replaced with your own node name + timeoutSecondsOnEachNode: 300 + retryTimesOnEachNode: 1
\ No newline at end of file diff --git a/build/crd-samples/nodeupgradejob.yaml b/build/crd-samples/operations/nodeupgradejob.yaml index 5b97287d7..5b97287d7 100644 --- a/build/crd-samples/nodeupgradejob.yaml +++ b/build/crd-samples/operations/nodeupgradejob.yaml diff --git a/build/crds/operations/operations_v1alpha1_imageprepulljob.yaml b/build/crds/operations/operations_v1alpha1_imageprepulljob.yaml new file mode 100644 index 000000000..cdc4ac603 --- /dev/null +++ b/build/crds/operations/operations_v1alpha1_imageprepulljob.yaml @@ -0,0 +1,204 @@ + +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.6.2 + creationTimestamp: null + name: imageprepulljobs.operations.kubeedge.io +spec: + group: operations.kubeedge.io + names: + kind: ImagePrePullJob + listKind: ImagePrePullJobList + plural: imageprepulljobs + singular: imageprepulljob + scope: Cluster + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: ImagePrePullJob is used to prepull images on edge node. + 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 represents the specification of the desired behavior + of ImagePrePullJob. + properties: + imagePrePullTemplate: + description: ImagePrepullTemplate represents original templates of + imagePrePull + properties: + checkItems: + description: CheckItems specifies the items need to be checked + before the task is executed. The default CheckItems value is + disk. + items: + type: string + type: array + imageSecrets: + description: ImageSecret specifies the secret for image pull if + private registry used. Use {namespace}/{secretName} in format. + type: string + images: + description: Images is the image list to be prepull + items: + type: string + type: array + labelSelector: + description: LabelSelector is a filter to select member clusters + by labels. It must match a node's labels for the NodeUpgradeJob + to be operated on that node. Please note that sets of NodeNames + and LabelSelector are ORed. Users must set one and can only + set one. + properties: + matchExpressions: + description: matchExpressions is a list of label selector + requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector + that contains values, a key, and an operator that relates + the key and values. + properties: + key: + description: key is the label key that the selector + applies to. + type: string + operator: + description: operator represents a key's relationship + to a set of values. Valid operators are In, NotIn, + Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If + the operator is In or NotIn, the values array must + be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced + during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A + single {key,value} in the matchLabels map is equivalent + to an element of matchExpressions, whose key field is "key", + the operator is "In", and the values array contains only + "value". The requirements are ANDed. + type: object + type: object + nodeNames: + description: NodeNames is a request to select some specific nodes. + If it is non-empty, the upgrade job simply select these edge + nodes to do upgrade operation. Please note that sets of NodeNames + and LabelSelector are ORed. Users must set one and can only + set one. + items: + type: string + type: array + retryTimesOnEachNode: + description: RetryTimesOnEachNode specifies the retry times if + image pull failed on each edgenode. Default to 0 + format: int32 + type: integer + timeoutSecondsOnEachNode: + description: TimeoutSecondsOnEachNode limits the duration of the + image prepull job on each edgenode. Default to 360. If set to + 0, we'll use the default value 300. + format: int32 + type: integer + type: object + type: object + status: + description: Status represents the status of ImagePrePullJob. + properties: + state: + description: 'State represents for the state phase of the ImagePrePullJob. + There are four possible state values: "", prechecking, prepulling, + successful, failed.' + enum: + - prepulling + - successful + - failed + type: string + status: + description: Status contains image prepull status for each edge node. + items: + description: ImagePrePullStatus stores image prepull status for + each edge node. + properties: + imageStatus: + description: ImageStatus represents the prepull status for each + image + items: + description: ImageStatus stores the prepull status for each + image. + properties: + image: + description: Image is the name of the image + type: string + reason: + description: Reason represents the fail reason if image + pull failed + type: string + state: + description: 'State represents for the state phase of + this image pull on the edge node There are two possible + state values: successful, failed.' + enum: + - prepulling + - successful + - failed + type: string + type: object + type: array + nodeName: + description: NodeName is the name of edge node. + type: string + reason: + description: Message represents the fail reason if images prepull + failed on the edge node + type: string + state: + description: 'State represents for the state phase of the ImagePrepullJob + on the edge node. There are five possible state values: "", + prepulling, successful, failed.' + enum: + - prepulling + - successful + - failed + type: string + type: object + type: array + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/hack/generate-crds.sh b/hack/generate-crds.sh index 295afa102..bc29ee1f4 100755 --- a/hack/generate-crds.sh +++ b/hack/generate-crds.sh @@ -86,6 +86,7 @@ function :copy:to:destination { mkdir -p ${CRD_OUTPUTS}/reliablesyncs mkdir -p ${CRD_OUTPUTS}/apps mkdir -p ${CRD_OUTPUTS}/policy + mkdir -p ${CRD_OUTPUTS}/operations for entry in `ls /tmp/crds/*.yaml`; do CRD_NAME=$(echo ${entry} | cut -d'.' -f3 | cut -d'_' -f2) @@ -108,7 +109,7 @@ function :copy:to:destination { elif [ "$CRD_NAME" == "objectsyncs" ]; then cp -v ${entry} ${CRD_OUTPUTS}/reliablesyncs/objectsync_${RELIABLESYNCS_VERSION}.yaml cp -v ${entry} ${HELM_CRDS_DIR}/objectsync_${RELIABLESYNCS_VERSION}.yaml - elif [ "$CRD_NAME" == "nodeupgradejobs" ]; then + elif [ "$CRD_NAME" == "nodeupgradejobs" ] || [ "$CRD_NAME" == "imageprepulljobs" ]; then CRD_NAME=$(remove_suffix_s "$CRD_NAME") cp -v ${entry} ${CRD_OUTPUTS}/operations/operations_${OPERATIONS_VERSION}_${CRD_NAME}.yaml cp -v ${entry} ${HELM_CRDS_DIR}/operations_${OPERATIONS_VERSION}_${CRD_NAME}.yaml diff --git a/hack/local-up-kubeedge.sh b/hack/local-up-kubeedge.sh index 750cf13bc..d008a082c 100755 --- a/hack/local-up-kubeedge.sh +++ b/hack/local-up-kubeedge.sh @@ -102,6 +102,7 @@ function create_rule_crd { function create_operation_crd { echo "creating the operation crd..." kubectl apply -f ${KUBEEDGE_ROOT}/build/crds/operations/operations_v1alpha1_nodeupgradejob.yaml + kubectl apply -f ${KUBEEDGE_ROOT}/build/crds/operations/operations_v1alpha1_imageprepulljob.yaml } function create_serviceaccountaccess_crd { diff --git a/manifests/charts/cloudcore/crds/operations_v1alpha1_imageprepulljob.yaml b/manifests/charts/cloudcore/crds/operations_v1alpha1_imageprepulljob.yaml new file mode 100644 index 000000000..cdc4ac603 --- /dev/null +++ b/manifests/charts/cloudcore/crds/operations_v1alpha1_imageprepulljob.yaml @@ -0,0 +1,204 @@ + +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.6.2 + creationTimestamp: null + name: imageprepulljobs.operations.kubeedge.io +spec: + group: operations.kubeedge.io + names: + kind: ImagePrePullJob + listKind: ImagePrePullJobList + plural: imageprepulljobs + singular: imageprepulljob + scope: Cluster + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: ImagePrePullJob is used to prepull images on edge node. + 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 represents the specification of the desired behavior + of ImagePrePullJob. + properties: + imagePrePullTemplate: + description: ImagePrepullTemplate represents original templates of + imagePrePull + properties: + checkItems: + description: CheckItems specifies the items need to be checked + before the task is executed. The default CheckItems value is + disk. + items: + type: string + type: array + imageSecrets: + description: ImageSecret specifies the secret for image pull if + private registry used. Use {namespace}/{secretName} in format. + type: string + images: + description: Images is the image list to be prepull + items: + type: string + type: array + labelSelector: + description: LabelSelector is a filter to select member clusters + by labels. It must match a node's labels for the NodeUpgradeJob + to be operated on that node. Please note that sets of NodeNames + and LabelSelector are ORed. Users must set one and can only + set one. + properties: + matchExpressions: + description: matchExpressions is a list of label selector + requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector + that contains values, a key, and an operator that relates + the key and values. + properties: + key: + description: key is the label key that the selector + applies to. + type: string + operator: + description: operator represents a key's relationship + to a set of values. Valid operators are In, NotIn, + Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If + the operator is In or NotIn, the values array must + be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced + during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A + single {key,value} in the matchLabels map is equivalent + to an element of matchExpressions, whose key field is "key", + the operator is "In", and the values array contains only + "value". The requirements are ANDed. + type: object + type: object + nodeNames: + description: NodeNames is a request to select some specific nodes. + If it is non-empty, the upgrade job simply select these edge + nodes to do upgrade operation. Please note that sets of NodeNames + and LabelSelector are ORed. Users must set one and can only + set one. + items: + type: string + type: array + retryTimesOnEachNode: + description: RetryTimesOnEachNode specifies the retry times if + image pull failed on each edgenode. Default to 0 + format: int32 + type: integer + timeoutSecondsOnEachNode: + description: TimeoutSecondsOnEachNode limits the duration of the + image prepull job on each edgenode. Default to 360. If set to + 0, we'll use the default value 300. + format: int32 + type: integer + type: object + type: object + status: + description: Status represents the status of ImagePrePullJob. + properties: + state: + description: 'State represents for the state phase of the ImagePrePullJob. + There are four possible state values: "", prechecking, prepulling, + successful, failed.' + enum: + - prepulling + - successful + - failed + type: string + status: + description: Status contains image prepull status for each edge node. + items: + description: ImagePrePullStatus stores image prepull status for + each edge node. + properties: + imageStatus: + description: ImageStatus represents the prepull status for each + image + items: + description: ImageStatus stores the prepull status for each + image. + properties: + image: + description: Image is the name of the image + type: string + reason: + description: Reason represents the fail reason if image + pull failed + type: string + state: + description: 'State represents for the state phase of + this image pull on the edge node There are two possible + state values: successful, failed.' + enum: + - prepulling + - successful + - failed + type: string + type: object + type: array + nodeName: + description: NodeName is the name of edge node. + type: string + reason: + description: Message represents the fail reason if images prepull + failed on the edge node + type: string + state: + description: 'State represents for the state phase of the ImagePrepullJob + on the edge node. There are five possible state values: "", + prepulling, successful, failed.' + enum: + - prepulling + - successful + - failed + type: string + type: object + type: array + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/manifests/charts/cloudcore/templates/rbac_cloudcore.yaml b/manifests/charts/cloudcore/templates/rbac_cloudcore.yaml index 7d4c26fa6..eba4ee29d 100644 --- a/manifests/charts/cloudcore/templates/rbac_cloudcore.yaml +++ b/manifests/charts/cloudcore/templates/rbac_cloudcore.yaml @@ -38,7 +38,7 @@ rules: resources: ["*"] verbs: ["get", "list", "watch"] - apiGroups: ["operations.kubeedge.io"] - resources: ["nodeupgradejobs", "nodeupgradejobs/status"] + resources: ["nodeupgradejobs", "nodeupgradejobs/status", "imageprepulljobs", "imageprepulljobs/status"] verbs: ["get", "list", "watch", "update", "patch"] --- diff --git a/pkg/apis/operations/v1alpha1/imageprepull_types.go b/pkg/apis/operations/v1alpha1/imageprepull_types.go new file mode 100644 index 000000000..54f2fc0ae --- /dev/null +++ b/pkg/apis/operations/v1alpha1/imageprepull_types.go @@ -0,0 +1,158 @@ +/* +Copyright 2023 The KubeEdge 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. +*/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ImagePrePullJob is used to prepull images on edge node. +// +k8s:openapi-gen=true +// +kubebuilder:subresource:status +// +kubebuilder:resource:scope=Cluster +type ImagePrePullJob struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec represents the specification of the desired behavior of ImagePrePullJob. + // +required + Spec ImagePrePullJobSpec `json:"spec"` + + // Status represents the status of ImagePrePullJob. + // +optional + Status ImagePrePullJobStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ImagePrePullJobList is a list of ImagePrePullJob. +type ImagePrePullJobList struct { + // Standard type metadata. + metav1.TypeMeta `json:",inline"` + + // Standard list metadata. + metav1.ListMeta `json:"metadata,omitempty"` + + // List of ImagePrePullJob. + Items []ImagePrePullJob `json:"items"` +} + +// ImagePrePullSpec represents the specification of the desired behavior of ImagePrePullJob. +type ImagePrePullJobSpec struct { + // ImagePrepullTemplate represents original templates of imagePrePull + ImagePrePullTemplate ImagePrePullTemplate `json:"imagePrePullTemplate,omitempty"` +} + +// ImagePrePullTemplate represents original templates of imagePrePull +type ImagePrePullTemplate struct { + // Images is the image list to be prepull + Images []string `json:"images,omitempty"` + + // NodeNames is a request to select some specific nodes. If it is non-empty, + // the upgrade job simply select these edge nodes to do upgrade operation. + // Please note that sets of NodeNames and LabelSelector are ORed. + // Users must set one and can only set one. + // +optional + NodeNames []string `json:"nodeNames,omitempty"` + // LabelSelector is a filter to select member clusters by labels. + // It must match a node's labels for the NodeUpgradeJob to be operated on that node. + // Please note that sets of NodeNames and LabelSelector are ORed. + // Users must set one and can only set one. + // +optional + LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"` + + // CheckItems specifies the items need to be checked before the task is executed. + // The default CheckItems value is disk. + // +optional + CheckItems []string `json:"checkItems,omitempty"` + + // ImageSecret specifies the secret for image pull if private registry used. + // Use {namespace}/{secretName} in format. + // +optional + ImageSecret string `json:"imageSecrets,omitempty"` + + // TimeoutSecondsOnEachNode limits the duration of the image prepull job on each edgenode. + // Default to 360. + // If set to 0, we'll use the default value 300. + // +optional + TimeoutSecondsOnEachNode *uint32 `json:"timeoutSecondsOnEachNode,omitempty"` + + // RetryTimesOnEachNode specifies the retry times if image pull failed on each edgenode. + // Default to 0 + // +optional + RetryTimesOnEachNode int32 `json:"retryTimesOnEachNode,omitempty"` +} + +// PrePullState describe the PrePullState of image prepull operation on edge nodes. +// +kubebuilder:validation:Enum=prepulling;successful;failed +type PrePullState string + +// Valid values of PrepullState +const ( + PrePullInitialValue PrePullState = "" + PrePulling PrePullState = "prepulling" + PrePullSuccessful PrePullState = "successful" + PrePullFailed PrePullState = "failed" +) + +// ImagePrePullJobStatus stores the status of ImagePrePullJob. +// contains images prepull status on multiple edge nodes. +// +kubebuilder:validation:Type=object +type ImagePrePullJobStatus struct { + // State represents for the state phase of the ImagePrePullJob. + // There are four possible state values: "", prechecking, prepulling, successful, failed. + State PrePullState `json:"state,omitempty"` + + // Status contains image prepull status for each edge node. + Status []ImagePrePullStatus `json:"status,omitempty"` +} + +// ImagePrePullStatus stores image prepull status for each edge node. +// +kubebuilder:validation:Type=object +type ImagePrePullStatus struct { + // NodeName is the name of edge node. + NodeName string `json:"nodeName,omitempty"` + + // State represents for the state phase of the ImagePrepullJob on the edge node. + // There are five possible state values: "", prepulling, successful, failed. + State PrePullState `json:"state,omitempty"` + + // Message represents the fail reason if images prepull failed on the edge node + Reason string `json:"reason,omitempty"` + + // ImageStatus represents the prepull status for each image + ImageStatus []ImageStatus `json:"imageStatus,omitempty"` +} + +// ImageStatus stores the prepull status for each image. +// +kubebuilder:validation:Type=object +type ImageStatus struct { + // Image is the name of the image + Image string `json:"image,omitempty"` + + // State represents for the state phase of this image pull on the edge node + // There are two possible state values: successful, failed. + State PrePullState `json:"state,omitempty"` + + // Reason represents the fail reason if image pull failed + // +optional + Reason string `json:"reason,omitempty"` +} diff --git a/pkg/apis/operations/v1alpha1/register.go b/pkg/apis/operations/v1alpha1/register.go index c6aa1325e..d78a1013d 100644 --- a/pkg/apis/operations/v1alpha1/register.go +++ b/pkg/apis/operations/v1alpha1/register.go @@ -65,6 +65,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, &NodeUpgradeJob{}, &NodeUpgradeJobList{}, + &ImagePrePullJob{}, + &ImagePrePullJobList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) return nil diff --git a/pkg/apis/operations/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/operations/v1alpha1/zz_generated.deepcopy.go index fb9863292..8b38fd4ec 100644 --- a/pkg/apis/operations/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/operations/v1alpha1/zz_generated.deepcopy.go @@ -43,6 +43,185 @@ func (in *History) DeepCopy() *History { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImagePrePullJob) DeepCopyInto(out *ImagePrePullJob) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImagePrePullJob. +func (in *ImagePrePullJob) DeepCopy() *ImagePrePullJob { + if in == nil { + return nil + } + out := new(ImagePrePullJob) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ImagePrePullJob) 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 *ImagePrePullJobList) DeepCopyInto(out *ImagePrePullJobList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ImagePrePullJob, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImagePrePullJobList. +func (in *ImagePrePullJobList) DeepCopy() *ImagePrePullJobList { + if in == nil { + return nil + } + out := new(ImagePrePullJobList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ImagePrePullJobList) 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 *ImagePrePullJobSpec) DeepCopyInto(out *ImagePrePullJobSpec) { + *out = *in + in.ImagePrePullTemplate.DeepCopyInto(&out.ImagePrePullTemplate) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImagePrePullJobSpec. +func (in *ImagePrePullJobSpec) DeepCopy() *ImagePrePullJobSpec { + if in == nil { + return nil + } + out := new(ImagePrePullJobSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImagePrePullJobStatus) DeepCopyInto(out *ImagePrePullJobStatus) { + *out = *in + if in.Status != nil { + in, out := &in.Status, &out.Status + *out = make([]ImagePrePullStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImagePrePullJobStatus. +func (in *ImagePrePullJobStatus) DeepCopy() *ImagePrePullJobStatus { + if in == nil { + return nil + } + out := new(ImagePrePullJobStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImagePrePullStatus) DeepCopyInto(out *ImagePrePullStatus) { + *out = *in + if in.ImageStatus != nil { + in, out := &in.ImageStatus, &out.ImageStatus + *out = make([]ImageStatus, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImagePrePullStatus. +func (in *ImagePrePullStatus) DeepCopy() *ImagePrePullStatus { + if in == nil { + return nil + } + out := new(ImagePrePullStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImagePrePullTemplate) DeepCopyInto(out *ImagePrePullTemplate) { + *out = *in + if in.Images != nil { + in, out := &in.Images, &out.Images + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.NodeNames != nil { + in, out := &in.NodeNames, &out.NodeNames + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.LabelSelector != nil { + in, out := &in.LabelSelector, &out.LabelSelector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.CheckItems != nil { + in, out := &in.CheckItems, &out.CheckItems + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.TimeoutSecondsOnEachNode != nil { + in, out := &in.TimeoutSecondsOnEachNode, &out.TimeoutSecondsOnEachNode + *out = new(uint32) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImagePrePullTemplate. +func (in *ImagePrePullTemplate) DeepCopy() *ImagePrePullTemplate { + if in == nil { + return nil + } + out := new(ImagePrePullTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImageStatus) DeepCopyInto(out *ImageStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageStatus. +func (in *ImageStatus) DeepCopy() *ImageStatus { + if in == nil { + return nil + } + out := new(ImageStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NodeUpgradeJob) DeepCopyInto(out *NodeUpgradeJob) { *out = *in out.TypeMeta = in.TypeMeta diff --git a/pkg/client/clientset/versioned/typed/operations/v1alpha1/fake/fake_imageprepulljob.go b/pkg/client/clientset/versioned/typed/operations/v1alpha1/fake/fake_imageprepulljob.go new file mode 100644 index 000000000..cb7a54910 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/operations/v1alpha1/fake/fake_imageprepulljob.go @@ -0,0 +1,132 @@ +/* +Copyright The KubeEdge 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/kubeedge/kubeedge/pkg/apis/operations/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeImagePrePullJobs implements ImagePrePullJobInterface +type FakeImagePrePullJobs struct { + Fake *FakeOperationsV1alpha1 +} + +var imageprepulljobsResource = v1alpha1.SchemeGroupVersion.WithResource("imageprepulljobs") + +var imageprepulljobsKind = v1alpha1.SchemeGroupVersion.WithKind("ImagePrePullJob") + +// Get takes name of the imagePrePullJob, and returns the corresponding imagePrePullJob object, and an error if there is any. +func (c *FakeImagePrePullJobs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ImagePrePullJob, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(imageprepulljobsResource, name), &v1alpha1.ImagePrePullJob{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ImagePrePullJob), err +} + +// List takes label and field selectors, and returns the list of ImagePrePullJobs that match those selectors. +func (c *FakeImagePrePullJobs) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ImagePrePullJobList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(imageprepulljobsResource, imageprepulljobsKind, opts), &v1alpha1.ImagePrePullJobList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.ImagePrePullJobList{ListMeta: obj.(*v1alpha1.ImagePrePullJobList).ListMeta} + for _, item := range obj.(*v1alpha1.ImagePrePullJobList).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 imagePrePullJobs. +func (c *FakeImagePrePullJobs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(imageprepulljobsResource, opts)) +} + +// Create takes the representation of a imagePrePullJob and creates it. Returns the server's representation of the imagePrePullJob, and an error, if there is any. +func (c *FakeImagePrePullJobs) Create(ctx context.Context, imagePrePullJob *v1alpha1.ImagePrePullJob, opts v1.CreateOptions) (result *v1alpha1.ImagePrePullJob, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(imageprepulljobsResource, imagePrePullJob), &v1alpha1.ImagePrePullJob{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ImagePrePullJob), err +} + +// Update takes the representation of a imagePrePullJob and updates it. Returns the server's representation of the imagePrePullJob, and an error, if there is any. +func (c *FakeImagePrePullJobs) Update(ctx context.Context, imagePrePullJob *v1alpha1.ImagePrePullJob, opts v1.UpdateOptions) (result *v1alpha1.ImagePrePullJob, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(imageprepulljobsResource, imagePrePullJob), &v1alpha1.ImagePrePullJob{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ImagePrePullJob), 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 *FakeImagePrePullJobs) UpdateStatus(ctx context.Context, imagePrePullJob *v1alpha1.ImagePrePullJob, opts v1.UpdateOptions) (*v1alpha1.ImagePrePullJob, error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceAction(imageprepulljobsResource, "status", imagePrePullJob), &v1alpha1.ImagePrePullJob{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ImagePrePullJob), err +} + +// Delete takes name of the imagePrePullJob and deletes it. Returns an error if one occurs. +func (c *FakeImagePrePullJobs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteActionWithOptions(imageprepulljobsResource, name, opts), &v1alpha1.ImagePrePullJob{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeImagePrePullJobs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(imageprepulljobsResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.ImagePrePullJobList{}) + return err +} + +// Patch applies the patch and returns the patched imagePrePullJob. +func (c *FakeImagePrePullJobs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ImagePrePullJob, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(imageprepulljobsResource, name, pt, data, subresources...), &v1alpha1.ImagePrePullJob{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ImagePrePullJob), err +} diff --git a/pkg/client/clientset/versioned/typed/operations/v1alpha1/fake/fake_operations_client.go b/pkg/client/clientset/versioned/typed/operations/v1alpha1/fake/fake_operations_client.go index 7a6025ff5..4e898107d 100644 --- a/pkg/client/clientset/versioned/typed/operations/v1alpha1/fake/fake_operations_client.go +++ b/pkg/client/clientset/versioned/typed/operations/v1alpha1/fake/fake_operations_client.go @@ -28,6 +28,10 @@ type FakeOperationsV1alpha1 struct { *testing.Fake } +func (c *FakeOperationsV1alpha1) ImagePrePullJobs() v1alpha1.ImagePrePullJobInterface { + return &FakeImagePrePullJobs{c} +} + func (c *FakeOperationsV1alpha1) NodeUpgradeJobs() v1alpha1.NodeUpgradeJobInterface { return &FakeNodeUpgradeJobs{c} } diff --git a/pkg/client/clientset/versioned/typed/operations/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/operations/v1alpha1/generated_expansion.go index e664010bf..3f5448bb5 100644 --- a/pkg/client/clientset/versioned/typed/operations/v1alpha1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/operations/v1alpha1/generated_expansion.go @@ -18,4 +18,6 @@ limitations under the License. package v1alpha1 +type ImagePrePullJobExpansion interface{} + type NodeUpgradeJobExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/operations/v1alpha1/imageprepulljob.go b/pkg/client/clientset/versioned/typed/operations/v1alpha1/imageprepulljob.go new file mode 100644 index 000000000..7dd77f40b --- /dev/null +++ b/pkg/client/clientset/versioned/typed/operations/v1alpha1/imageprepulljob.go @@ -0,0 +1,184 @@ +/* +Copyright The KubeEdge 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/kubeedge/kubeedge/pkg/apis/operations/v1alpha1" + scheme "github.com/kubeedge/kubeedge/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" +) + +// ImagePrePullJobsGetter has a method to return a ImagePrePullJobInterface. +// A group's client should implement this interface. +type ImagePrePullJobsGetter interface { + ImagePrePullJobs() ImagePrePullJobInterface +} + +// ImagePrePullJobInterface has methods to work with ImagePrePullJob resources. +type ImagePrePullJobInterface interface { + Create(ctx context.Context, imagePrePullJob *v1alpha1.ImagePrePullJob, opts v1.CreateOptions) (*v1alpha1.ImagePrePullJob, error) + Update(ctx context.Context, imagePrePullJob *v1alpha1.ImagePrePullJob, opts v1.UpdateOptions) (*v1alpha1.ImagePrePullJob, error) + UpdateStatus(ctx context.Context, imagePrePullJob *v1alpha1.ImagePrePullJob, opts v1.UpdateOptions) (*v1alpha1.ImagePrePullJob, 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.ImagePrePullJob, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ImagePrePullJobList, 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.ImagePrePullJob, err error) + ImagePrePullJobExpansion +} + +// imagePrePullJobs implements ImagePrePullJobInterface +type imagePrePullJobs struct { + client rest.Interface +} + +// newImagePrePullJobs returns a ImagePrePullJobs +func newImagePrePullJobs(c *OperationsV1alpha1Client) *imagePrePullJobs { + return &imagePrePullJobs{ + client: c.RESTClient(), + } +} + +// Get takes name of the imagePrePullJob, and returns the corresponding imagePrePullJob object, and an error if there is any. +func (c *imagePrePullJobs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ImagePrePullJob, err error) { + result = &v1alpha1.ImagePrePullJob{} + err = c.client.Get(). + Resource("imageprepulljobs"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ImagePrePullJobs that match those selectors. +func (c *imagePrePullJobs) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ImagePrePullJobList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.ImagePrePullJobList{} + err = c.client.Get(). + Resource("imageprepulljobs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested imagePrePullJobs. +func (c *imagePrePullJobs) 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("imageprepulljobs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a imagePrePullJob and creates it. Returns the server's representation of the imagePrePullJob, and an error, if there is any. +func (c *imagePrePullJobs) Create(ctx context.Context, imagePrePullJob *v1alpha1.ImagePrePullJob, opts v1.CreateOptions) (result *v1alpha1.ImagePrePullJob, err error) { + result = &v1alpha1.ImagePrePullJob{} + err = c.client.Post(). + Resource("imageprepulljobs"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(imagePrePullJob). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a imagePrePullJob and updates it. Returns the server's representation of the imagePrePullJob, and an error, if there is any. +func (c *imagePrePullJobs) Update(ctx context.Context, imagePrePullJob *v1alpha1.ImagePrePullJob, opts v1.UpdateOptions) (result *v1alpha1.ImagePrePullJob, err error) { + result = &v1alpha1.ImagePrePullJob{} + err = c.client.Put(). + Resource("imageprepulljobs"). + Name(imagePrePullJob.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(imagePrePullJob). + 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 *imagePrePullJobs) UpdateStatus(ctx context.Context, imagePrePullJob *v1alpha1.ImagePrePullJob, opts v1.UpdateOptions) (result *v1alpha1.ImagePrePullJob, err error) { + result = &v1alpha1.ImagePrePullJob{} + err = c.client.Put(). + Resource("imageprepulljobs"). + Name(imagePrePullJob.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(imagePrePullJob). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the imagePrePullJob and deletes it. Returns an error if one occurs. +func (c *imagePrePullJobs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("imageprepulljobs"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *imagePrePullJobs) 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("imageprepulljobs"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched imagePrePullJob. +func (c *imagePrePullJobs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ImagePrePullJob, err error) { + result = &v1alpha1.ImagePrePullJob{} + err = c.client.Patch(pt). + Resource("imageprepulljobs"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/operations/v1alpha1/operations_client.go b/pkg/client/clientset/versioned/typed/operations/v1alpha1/operations_client.go index 8d926b3cf..74af5f488 100644 --- a/pkg/client/clientset/versioned/typed/operations/v1alpha1/operations_client.go +++ b/pkg/client/clientset/versioned/typed/operations/v1alpha1/operations_client.go @@ -28,6 +28,7 @@ import ( type OperationsV1alpha1Interface interface { RESTClient() rest.Interface + ImagePrePullJobsGetter NodeUpgradeJobsGetter } @@ -36,6 +37,10 @@ type OperationsV1alpha1Client struct { restClient rest.Interface } +func (c *OperationsV1alpha1Client) ImagePrePullJobs() ImagePrePullJobInterface { + return newImagePrePullJobs(c) +} + func (c *OperationsV1alpha1Client) NodeUpgradeJobs() NodeUpgradeJobInterface { return newNodeUpgradeJobs(c) } diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index fa149a971..f56206105 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -70,6 +70,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Devices().V1beta1().DeviceModels().Informer()}, nil // Group=operations, Version=v1alpha1 + case operationsv1alpha1.SchemeGroupVersion.WithResource("imageprepulljobs"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Operations().V1alpha1().ImagePrePullJobs().Informer()}, nil case operationsv1alpha1.SchemeGroupVersion.WithResource("nodeupgradejobs"): return &genericInformer{resource: resource.GroupResource(), informer: f.Operations().V1alpha1().NodeUpgradeJobs().Informer()}, nil diff --git a/pkg/client/informers/externalversions/operations/v1alpha1/imageprepulljob.go b/pkg/client/informers/externalversions/operations/v1alpha1/imageprepulljob.go new file mode 100644 index 000000000..511d627a6 --- /dev/null +++ b/pkg/client/informers/externalversions/operations/v1alpha1/imageprepulljob.go @@ -0,0 +1,89 @@ +/* +Copyright The KubeEdge 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" + + operationsv1alpha1 "github.com/kubeedge/kubeedge/pkg/apis/operations/v1alpha1" + versioned "github.com/kubeedge/kubeedge/pkg/client/clientset/versioned" + internalinterfaces "github.com/kubeedge/kubeedge/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/kubeedge/kubeedge/pkg/client/listers/operations/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" +) + +// ImagePrePullJobInformer provides access to a shared informer and lister for +// ImagePrePullJobs. +type ImagePrePullJobInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.ImagePrePullJobLister +} + +type imagePrePullJobInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewImagePrePullJobInformer constructs a new informer for ImagePrePullJob 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 NewImagePrePullJobInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredImagePrePullJobInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredImagePrePullJobInformer constructs a new informer for ImagePrePullJob 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 NewFilteredImagePrePullJobInformer(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.OperationsV1alpha1().ImagePrePullJobs().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.OperationsV1alpha1().ImagePrePullJobs().Watch(context.TODO(), options) + }, + }, + &operationsv1alpha1.ImagePrePullJob{}, + resyncPeriod, + indexers, + ) +} + +func (f *imagePrePullJobInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredImagePrePullJobInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *imagePrePullJobInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&operationsv1alpha1.ImagePrePullJob{}, f.defaultInformer) +} + +func (f *imagePrePullJobInformer) Lister() v1alpha1.ImagePrePullJobLister { + return v1alpha1.NewImagePrePullJobLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/operations/v1alpha1/interface.go b/pkg/client/informers/externalversions/operations/v1alpha1/interface.go index 10a3892ab..650ab553e 100644 --- a/pkg/client/informers/externalversions/operations/v1alpha1/interface.go +++ b/pkg/client/informers/externalversions/operations/v1alpha1/interface.go @@ -24,6 +24,8 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { + // ImagePrePullJobs returns a ImagePrePullJobInformer. + ImagePrePullJobs() ImagePrePullJobInformer // NodeUpgradeJobs returns a NodeUpgradeJobInformer. NodeUpgradeJobs() NodeUpgradeJobInformer } @@ -39,6 +41,11 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } +// ImagePrePullJobs returns a ImagePrePullJobInformer. +func (v *version) ImagePrePullJobs() ImagePrePullJobInformer { + return &imagePrePullJobInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + // NodeUpgradeJobs returns a NodeUpgradeJobInformer. func (v *version) NodeUpgradeJobs() NodeUpgradeJobInformer { return &nodeUpgradeJobInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} diff --git a/pkg/client/listers/operations/v1alpha1/expansion_generated.go b/pkg/client/listers/operations/v1alpha1/expansion_generated.go index 7e83d432d..7ff435cd6 100644 --- a/pkg/client/listers/operations/v1alpha1/expansion_generated.go +++ b/pkg/client/listers/operations/v1alpha1/expansion_generated.go @@ -18,6 +18,10 @@ limitations under the License. package v1alpha1 +// ImagePrePullJobListerExpansion allows custom methods to be added to +// ImagePrePullJobLister. +type ImagePrePullJobListerExpansion interface{} + // NodeUpgradeJobListerExpansion allows custom methods to be added to // NodeUpgradeJobLister. type NodeUpgradeJobListerExpansion interface{} diff --git a/pkg/client/listers/operations/v1alpha1/imageprepulljob.go b/pkg/client/listers/operations/v1alpha1/imageprepulljob.go new file mode 100644 index 000000000..bb20ac4ac --- /dev/null +++ b/pkg/client/listers/operations/v1alpha1/imageprepulljob.go @@ -0,0 +1,68 @@ +/* +Copyright The KubeEdge 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/kubeedge/kubeedge/pkg/apis/operations/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ImagePrePullJobLister helps list ImagePrePullJobs. +// All objects returned here must be treated as read-only. +type ImagePrePullJobLister interface { + // List lists all ImagePrePullJobs in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.ImagePrePullJob, err error) + // Get retrieves the ImagePrePullJob from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.ImagePrePullJob, error) + ImagePrePullJobListerExpansion +} + +// imagePrePullJobLister implements the ImagePrePullJobLister interface. +type imagePrePullJobLister struct { + indexer cache.Indexer +} + +// NewImagePrePullJobLister returns a new ImagePrePullJobLister. +func NewImagePrePullJobLister(indexer cache.Indexer) ImagePrePullJobLister { + return &imagePrePullJobLister{indexer: indexer} +} + +// List lists all ImagePrePullJobs in the indexer. +func (s *imagePrePullJobLister) List(selector labels.Selector) (ret []*v1alpha1.ImagePrePullJob, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.ImagePrePullJob)) + }) + return ret, err +} + +// Get retrieves the ImagePrePullJob from the index for a given name. +func (s *imagePrePullJobLister) Get(name string) (*v1alpha1.ImagePrePullJob, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("imageprepulljob"), name) + } + return obj.(*v1alpha1.ImagePrePullJob), nil +} |
