diff --git a/docs/content/en/references/pipeline_v1alpha1_types.html b/docs/content/en/references/pipeline_v1alpha1_types.html new file mode 100644 index 000000000..783fcd458 --- /dev/null +++ b/docs/content/en/references/pipeline_v1alpha1_types.html @@ -0,0 +1,477 @@ +

Packages:

+ +

pipeline.kurator.dev/v1alpha1

+

Package v1alpha1 contains API Schema definitions for the fleet v1alpha1 API group

+Resource Types: + +

Pipeline +

+

Pipeline is the top-level type for Kurator CI Pipeline.

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+apiVersion
+string
+pipeline.kurator.dev/v1alpha1 +
+kind
+string +
+Pipeline +
+metadata
+ + +Kubernetes meta/v1.ObjectMeta + + +
+Refer to the Kubernetes API documentation for the fields of the +metadata field. +
+spec
+ + +PipelineSpec + + +
+ + + + + + + + + + + + + +
+description
+ +string + +
+(Optional) +

Description allows an administrator to provide a description of the pipeline.

+
+tasks
+ + +[]PipelineTask + + +
+

Tasks is an ordered list of tasks in the pipeline, containing detailed information about each task. +The tasks will be executed in the order they are listed.

+
+sharedWorkspace
+ +string + +
+(Optional) +

SharedWorkspace is the name of the PVC. If not specified, a PVC with the Pipeline’s name as prefix will be created by default. +If not set, Kurator will create a PVC named Pipeline.name using default config

+
+
+status
+ + +PipelineStatus + + +
+
+
+
+

CustomTask +

+

+(Appears on: +PipelineTask) +

+

CustomTask defines the specification for a user-defined task.

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+image
+ +string + +
+(Optional) +

Image specifies the Docker image name. +More info: https://kubernetes.io/docs/concepts/containers/images

+
+command
+ +[]string + +
+(Optional) +

Command is the entrypoint array. It’s not executed in a shell. +If not provided, the image’s ENTRYPOINT is used. +Environment variables can be used in the format $(VAR_NAME). +More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell

+
+args
+ +[]string + +
+(Optional) +

Args are the arguments for the entrypoint. +If not provided, the image’s CMD is used. +Supports environment variable expansion in the format $(VAR_NAME). +More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell

+
+env
+ + +[]Kubernetes core/v1.EnvVar + + +
+(Optional) +

List of environment variables to set in the Step. +Cannot be updated.

+
+computeResources
+ + +Kubernetes core/v1.ResourceRequirements + + +
+(Optional) +

ResourceRequirements required by this Step. +Cannot be updated. +More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/

+
+script
+ +string + +
+(Optional) +

Script is the contents of an executable file to execute. +If Script is not empty, the CustomTask cannot have a Command and the Args will be passed to the Script.

+
+
+
+

PipelinePhase +(string alias)

+

+(Appears on: +PipelineStatus) +

+

PipelineSpec +

+

+(Appears on: +Pipeline) +

+

PipelineSpec defines the desired state of a Pipeline.

+
+
+ + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+description
+ +string + +
+(Optional) +

Description allows an administrator to provide a description of the pipeline.

+
+tasks
+ + +[]PipelineTask + + +
+

Tasks is an ordered list of tasks in the pipeline, containing detailed information about each task. +The tasks will be executed in the order they are listed.

+
+sharedWorkspace
+ +string + +
+(Optional) +

SharedWorkspace is the name of the PVC. If not specified, a PVC with the Pipeline’s name as prefix will be created by default. +If not set, Kurator will create a PVC named Pipeline.name using default config

+
+
+
+

PipelineStatus +

+

+(Appears on: +Pipeline) +

+
+
+ + + + + + + + + + + + + + + + + +
FieldDescription
+phase
+ + +PipelinePhase + + +
+(Optional) +

Phase describes the overall state of the Pipeline.

+
+eventListenerServiceName
+ +string + +
+(Optional) +

EventListenerServiceName specifies the name of the service created by Kurator for event listeners. +This name is useful for users when setting up a gateway service and routing to this service.

+
+
+
+

PipelineTask +

+

+(Appears on: +PipelineSpec) +

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+name
+ +string + +
+

Name is the name of the task.

+
+predefinedTask
+ + +PredefinedTask + + +
+(Optional) +

PredefinedTask allows users to select a predefined task. +Users can choose a predefined task from a set list and fill in their own parameters.

+
+customTask
+ + +CustomTask + + +
+(Optional) +

CustomTask enables defining a task directly within the CRD if TaskRef is not used. +This should only be used when TaskRef is not provided.

+
+retries
+ +int + +
+(Optional) +

Retries represents how many times this task should be retried in case of task failure. +default values is zero.

+
+
+
+

PredefinedTask +

+

+(Appears on: +PipelineTask) +

+

PredefinedTask provides a structure for defining a PredefinedTask.

+
+
+ + + + + + + + + + + + + + + + + +
FieldDescription
+name
+ + +TaskTemplate + + +
+

Name specifies the predefined task template to be used. +This field is required to select the appropriate PredefinedTask.

+
+params
+ +map[string]string + +
+(Optional) +

Params contains key-value pairs for task-specific parameters. +The required parameters vary depending on the TaskType chosen.

+
+
+
+

TaskTemplate +(string alias)

+

+(Appears on: +PredefinedTask) +

+
+

This page was automatically generated with gen-crd-api-reference-docs

+
diff --git a/hack/gen-api-doc.sh b/hack/gen-api-doc.sh index a409042ef..3a13edad9 100755 --- a/hack/gen-api-doc.sh +++ b/hack/gen-api-doc.sh @@ -19,7 +19,7 @@ if ! [ -x "$(command -v gen-crd-api-reference-docs)" ]; then util::install_tools github.com/ahmetb/gen-crd-api-reference-docs 45bac9a # 2023-03-28 fi -API_GROUPS=("cluster" "infra" "fleet" "apps" "backups") +API_GROUPS=("cluster" "infra" "fleet" "apps" "backups" "pipeline") for APIGROUP in "${API_GROUPS[@]}" do diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 8a9ffe2c8..cb81aa230 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -7,7 +7,14 @@ set -o nounset set -o pipefail PKG_PATH=kurator.dev/kurator/pkg/client-go -APIS_PATHS=(kurator.dev/kurator/pkg/apis/cluster/v1alpha1 kurator.dev/kurator/pkg/apis/infra/v1alpha1 kurator.dev/kurator/pkg/apis/fleet/v1alpha1 kurator.dev/kurator/pkg/apis/apps/v1alpha1 kurator.dev/kurator/pkg/apis/backups/v1alpha1) +APIS_PATHS=( + kurator.dev/kurator/pkg/apis/cluster/v1alpha1 + kurator.dev/kurator/pkg/apis/infra/v1alpha1 + kurator.dev/kurator/pkg/apis/fleet/v1alpha1 + kurator.dev/kurator/pkg/apis/apps/v1alpha1 + kurator.dev/kurator/pkg/apis/backups/v1alpha1 + kurator.dev/kurator/pkg/apis/pipeline/v1alpha1 +) ALL_APIS=$(IFS=, ; echo "${APIS_PATHS[*]}") # For all commands, the working directory is the parent directory(repo root). diff --git a/hack/update-crdgen.sh b/hack/update-crdgen.sh index 5897411a2..02814fb88 100755 --- a/hack/update-crdgen.sh +++ b/hack/update-crdgen.sh @@ -22,7 +22,12 @@ kubectl kustomize "${CRD_PATH}" -o "${CRD_PATH}"/infrastructure.cluster.x-k8s.io mv "${CRD_PATH}"/*.yaml "${OPERATOR_CHART_PATH}"/crds/ echo "Generating crd for fleet manager" -APIS_PATHS=( "./pkg/apis/fleet/..." "./pkg/apis/apps/..." "./pkg/apis/backups/...") +APIS_PATHS=( + "./pkg/apis/fleet/..." + "./pkg/apis/apps/..." + "./pkg/apis/backups/..." + "./pkg/apis/pipeline/..." +) FLEET_CHART_PATH=${FLEET_CHART_PATH:-"manifests/charts/fleet-manager"} for APIS_PATH in "${APIS_PATHS[@]}" do diff --git a/manifests/charts/fleet-manager/crds/pipeline.kurator.dev_pipelines.yaml b/manifests/charts/fleet-manager/crds/pipeline.kurator.dev_pipelines.yaml new file mode 100644 index 000000000..97f6a9c40 --- /dev/null +++ b/manifests/charts/fleet-manager/crds/pipeline.kurator.dev_pipelines.yaml @@ -0,0 +1,314 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.8.0 + creationTimestamp: null + name: pipelines.pipeline.kurator.dev +spec: + group: pipeline.kurator.dev + names: + categories: + - kurator-dev + kind: Pipeline + listKind: PipelineList + plural: pipelines + singular: pipeline + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: Pipeline is the top-level type for Kurator CI Pipeline. + 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: PipelineSpec defines the desired state of a Pipeline. + properties: + description: + description: Description allows an administrator to provide a description + of the pipeline. + type: string + sharedWorkspace: + description: SharedWorkspace is the name of the PVC. If not specified, + a PVC with the Pipeline's name as prefix will be created by default. + If not set, Kurator will create a PVC named Pipeline.name using + default config + type: string + tasks: + description: Tasks is an ordered list of tasks in the pipeline, containing + detailed information about each task. The tasks will be executed + in the order they are listed. + items: + properties: + customTask: + description: CustomTask enables defining a task directly within + the CRD if TaskRef is not used. This should only be used when + TaskRef is not provided. + properties: + args: + description: 'Args are the arguments for the entrypoint. + If not provided, the image''s CMD is used. Supports environment + variable expansion in the format $(VAR_NAME). More info: + https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell' + items: + type: string + type: array + x-kubernetes-list-type: atomic + command: + description: 'Command is the entrypoint array. It''s not + executed in a shell. If not provided, the image''s ENTRYPOINT + is used. Environment variables can be used in the format + $(VAR_NAME). More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell' + items: + type: string + type: array + x-kubernetes-list-type: atomic + computeResources: + description: 'ResourceRequirements required by this Step. + Cannot be updated. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + properties: + claims: + description: "Claims lists the names of resources, defined + in spec.resourceClaims, that are used by this container. + \n This is an alpha field and requires enabling the + DynamicResourceAllocation feature gate. \n This field + is immutable. It can only be set for containers." + items: + description: ResourceClaim references one entry in + PodSpec.ResourceClaims. + properties: + name: + description: Name must match the name of one entry + in pod.spec.resourceClaims of the Pod where + this field is used. It makes that resource available + inside a container. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount of + compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Requests describes the minimum amount + of compute resources required. If Requests is omitted + for a container, it defaults to Limits if that is + explicitly specified, otherwise to an implementation-defined + value. Requests cannot exceed Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + type: object + env: + description: List of environment variables to set in the + Step. Cannot be updated. + items: + description: EnvVar represents an environment variable + present in a Container. + properties: + name: + description: Name of the environment variable. Must + be a C_IDENTIFIER. + type: string + value: + description: 'Variable references $(VAR_NAME) are + expanded using the previously defined environment + variables in the container and any service environment + variables. If a variable cannot be resolved, the + reference in the input string will be unchanged. + Double $$ are reduced to a single $, which allows + for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" + will produce the string literal "$(VAR_NAME)". Escaped + references will never be expanded, regardless of + whether the variable exists or not. Defaults to + "".' + type: string + valueFrom: + description: Source for the environment variable's + value. Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: + https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, + kind, uid?' + type: string + optional: + description: Specify whether the ConfigMap + or its key must be defined + type: boolean + required: + - key + type: object + fieldRef: + description: 'Selects a field of the pod: supports + metadata.name, metadata.namespace, `metadata.labels['''']`, + `metadata.annotations['''']`, spec.nodeName, + spec.serviceAccountName, status.hostIP, status.podIP, + status.podIPs.' + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in + the specified API version. + type: string + required: + - fieldPath + type: object + resourceFieldRef: + description: 'Selects a resource of the container: + only resources limits and requests (limits.cpu, + limits.memory, limits.ephemeral-storage, requests.cpu, + requests.memory and requests.ephemeral-storage) + are currently supported.' + properties: + containerName: + description: 'Container name: required for + volumes, optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of + the exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + secretKeyRef: + description: Selects a key of a secret in the + pod's namespace + properties: + key: + description: The key of the secret to select + from. Must be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: + https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, + kind, uid?' + type: string + optional: + description: Specify whether the Secret or + its key must be defined + type: boolean + required: + - key + type: object + type: object + required: + - name + type: object + type: array + x-kubernetes-list-type: atomic + image: + description: 'Image specifies the Docker image name. More + info: https://kubernetes.io/docs/concepts/containers/images' + type: string + script: + description: Script is the contents of an executable file + to execute. If Script is not empty, the CustomTask cannot + have a Command and the Args will be passed to the Script. + type: string + type: object + name: + description: Name is the name of the task. + type: string + predefinedTask: + description: PredefinedTask allows users to select a predefined + task. Users can choose a predefined task from a set list and + fill in their own parameters. + properties: + name: + description: Name specifies the predefined task template + to be used. This field is required to select the appropriate + PredefinedTask. + type: string + params: + additionalProperties: + type: string + description: Params contains key-value pairs for task-specific + parameters. The required parameters vary depending on + the TaskType chosen. + type: object + required: + - name + type: object + retries: + description: Retries represents how many times this task should + be retried in case of task failure. default values is zero. + type: integer + required: + - name + type: object + type: array + required: + - tasks + type: object + status: + properties: + eventListenerServiceName: + description: EventListenerServiceName specifies the name of the service + created by Kurator for event listeners. This name is useful for + users when setting up a gateway service and routing to this service. + type: string + phase: + description: Phase describes the overall state of the Pipeline. + type: string + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/pkg/apis/pipeline/v1alpha1/doc.go b/pkg/apis/pipeline/v1alpha1/doc.go new file mode 100644 index 000000000..578d9b780 --- /dev/null +++ b/pkg/apis/pipeline/v1alpha1/doc.go @@ -0,0 +1,21 @@ +/* +Copyright Kurator 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 contains API Schema definitions for the fleet v1alpha1 API group +// +kubebuilder:object:generate=true +// +groupName=pipeline.kurator.dev +// +k8s:deepcopy-gen=package +package v1alpha1 diff --git a/pkg/apis/pipeline/v1alpha1/type.go b/pkg/apis/pipeline/v1alpha1/type.go new file mode 100644 index 000000000..d61853853 --- /dev/null +++ b/pkg/apis/pipeline/v1alpha1/type.go @@ -0,0 +1,196 @@ +/* +Copyright Kurator 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 ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:object:root=true +// +kubebuilder:resource:scope=Namespaced,categories=kurator-dev +// +kubebuilder:subresource:status + +// Pipeline is the top-level type for Kurator CI Pipeline. +type Pipeline struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec PipelineSpec `json:"spec"` + Status PipelineStatus `json:"status,omitempty"` +} + +// PipelineSpec defines the desired state of a Pipeline. +type PipelineSpec struct { + // Description allows an administrator to provide a description of the pipeline. + // +optional + Description string `json:"description,omitempty"` + + // Tasks is an ordered list of tasks in the pipeline, containing detailed information about each task. + // The tasks will be executed in the order they are listed. + Tasks []PipelineTask `json:"tasks"` + + // SharedWorkspace is the name of the PVC. If not specified, a PVC with the Pipeline's name as prefix will be created by default. + // If not set, Kurator will create a PVC named Pipeline.name using default config + // +optional + SharedWorkspace *string `json:"sharedWorkspace,omitempty"` +} + +type PipelineTask struct { + // Name is the name of the task. + Name string `json:"name"` + + // PredefinedTask allows users to select a predefined task. + // Users can choose a predefined task from a set list and fill in their own parameters. + // +optional + PredefinedTask *PredefinedTask `json:"predefinedTask,omitempty"` + + // CustomTask enables defining a task directly within the CRD if TaskRef is not used. + // This should only be used when TaskRef is not provided. + // +optional + CustomTask *CustomTask `json:"customTask,omitempty"` + + // Retries represents how many times this task should be retried in case of task failure. + // default values is zero. + // +optional + Retries int `json:"retries,omitempty"` +} + +type TaskTemplate string + +const ( + // GitClone is typically the first task in the entire pipeline. + // It clones the user's code repository into the workspace. This allows subsequent tasks to operate on this basis. + // Since the pipeline is linked to a specific repository's webhook, Kurator automatically retrieves the repository information when triggered by the webhook. + // Users don't need to configure additional repository information for this task, except for authentication details for private repositories. + // This Predefined Task is origin from https://github.com/tektoncd/catalog/tree/main/task/git-clone/0.9 + // Here are the params that user can config: + // - git-secret-name: The name of the secret for Git basic authentication. + // Kurator uses this Git credential to clone private repositories. + // The secret is formatted as follows, and more details can be found at: + // https://kurator.dev/docs/fleet-manager/pipeline/ + // - username: + // - password: + GitClone TaskTemplate = "git-clone" + + // GoTest runs Go tests in specified packages with configurable environment + // This Predefined Task is origin from https://github.com/tektoncd/catalog/tree/main/task/golang-test/0.2/ + // Here are the params that user can config: + // - packages: packages to test (default: ./...) + // - context: path to the directory to use as context (default: .) + // - version: golang version to use for builds (default: latest) + // - flags: flags to use for go test command (default: -race -cover -v) + // - GOOS: operating system target (default: linux) + // - GOARCH: architecture target (default: amd64) + // - GO111MODULE: value of module support (default: auto) + // - GOCACHE: value for go caching path (default: "") + // - GOMODCACHE: value for go module caching path (default: "") + GoTest TaskTemplate = "go-test" + + // TODO: add more PredefinedTask +) + +// PredefinedTask provides a structure for defining a PredefinedTask. +type PredefinedTask struct { + // Name specifies the predefined task template to be used. + // This field is required to select the appropriate PredefinedTask. + // +required + Name TaskTemplate `json:"name"` + + // Params contains key-value pairs for task-specific parameters. + // The required parameters vary depending on the TaskType chosen. + // +optional + Params map[string]string `json:"params,omitempty"` +} + +// CustomTask defines the specification for a user-defined task. +type CustomTask struct { + // Image specifies the Docker image name. + // More info: https://kubernetes.io/docs/concepts/containers/images + // +optional + Image string `json:"image,omitempty"` + + // Command is the entrypoint array. It's not executed in a shell. + // If not provided, the image's ENTRYPOINT is used. + // Environment variables can be used in the format $(VAR_NAME). + // More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell + // +optional + // +listType=atomic + Command []string `json:"command,omitempty"` + + // Args are the arguments for the entrypoint. + // If not provided, the image's CMD is used. + // Supports environment variable expansion in the format $(VAR_NAME). + // More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell + // +optional + // +listType=atomic + Args []string `json:"args,omitempty"` + + // List of environment variables to set in the Step. + // Cannot be updated. + // +optional + // +patchMergeKey=name + // +patchStrategy=merge + // +listType=atomic + Env []corev1.EnvVar `json:"env,omitempty" patchStrategy:"merge" patchMergeKey:"name"` + + // ResourceRequirements required by this Step. + // Cannot be updated. + // More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + // +optional + ResourceRequirements corev1.ResourceRequirements `json:"computeResources,omitempty"` + + // Script is the contents of an executable file to execute. + // If Script is not empty, the CustomTask cannot have a Command and the Args will be passed to the Script. + // +optional + Script string `json:"script,omitempty"` +} + +type PipelinePhase string + +const ( + // RunningPhase indicates that the associated resources are currently being created. + RunningPhase PipelinePhase = "Running" + + // FailedPhase signifies that the creation of associated resources has failed. + FailedPhase PipelinePhase = "Failed" + + // ReadyPhase represents the state where all associated resources have been successfully created. + ReadyPhase PipelinePhase = "Ready" +) + +type PipelineStatus struct { + // Phase describes the overall state of the Pipeline. + // +optional + Phase PipelinePhase `json:"phase,omitempty"` + + // EventListenerServiceName specifies the name of the service created by Kurator for event listeners. + // This name is useful for users when setting up a gateway service and routing to this service. + // +optional + EventListenerServiceName *string `json:"eventListenerServiceName,omitempty"` +} + +// PipelineList contains a list of Pipeline. +// +kubebuilder:object:root=true +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type PipelineList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Pipeline `json:"items"` +} diff --git a/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 000000000..7154abf7a --- /dev/null +++ b/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,220 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright Kurator 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 deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/api/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CustomTask) DeepCopyInto(out *CustomTask) { + *out = *in + if in.Command != nil { + in, out := &in.Command, &out.Command + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]v1.EnvVar, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + in.ResourceRequirements.DeepCopyInto(&out.ResourceRequirements) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomTask. +func (in *CustomTask) DeepCopy() *CustomTask { + if in == nil { + return nil + } + out := new(CustomTask) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Pipeline) DeepCopyInto(out *Pipeline) { + *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 Pipeline. +func (in *Pipeline) DeepCopy() *Pipeline { + if in == nil { + return nil + } + out := new(Pipeline) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Pipeline) 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 *PipelineList) DeepCopyInto(out *PipelineList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Pipeline, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PipelineList. +func (in *PipelineList) DeepCopy() *PipelineList { + if in == nil { + return nil + } + out := new(PipelineList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PipelineList) 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 *PipelineSpec) DeepCopyInto(out *PipelineSpec) { + *out = *in + if in.Tasks != nil { + in, out := &in.Tasks, &out.Tasks + *out = make([]PipelineTask, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.SharedWorkspace != nil { + in, out := &in.SharedWorkspace, &out.SharedWorkspace + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PipelineSpec. +func (in *PipelineSpec) DeepCopy() *PipelineSpec { + if in == nil { + return nil + } + out := new(PipelineSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PipelineStatus) DeepCopyInto(out *PipelineStatus) { + *out = *in + if in.EventListenerServiceName != nil { + in, out := &in.EventListenerServiceName, &out.EventListenerServiceName + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PipelineStatus. +func (in *PipelineStatus) DeepCopy() *PipelineStatus { + if in == nil { + return nil + } + out := new(PipelineStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PipelineTask) DeepCopyInto(out *PipelineTask) { + *out = *in + if in.PredefinedTask != nil { + in, out := &in.PredefinedTask, &out.PredefinedTask + *out = new(PredefinedTask) + (*in).DeepCopyInto(*out) + } + if in.CustomTask != nil { + in, out := &in.CustomTask, &out.CustomTask + *out = new(CustomTask) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PipelineTask. +func (in *PipelineTask) DeepCopy() *PipelineTask { + if in == nil { + return nil + } + out := new(PipelineTask) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PredefinedTask) DeepCopyInto(out *PredefinedTask) { + *out = *in + if in.Params != nil { + in, out := &in.Params, &out.Params + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PredefinedTask. +func (in *PredefinedTask) DeepCopy() *PredefinedTask { + if in == nil { + return nil + } + out := new(PredefinedTask) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/apis/pipeline/v1alpha1/zz_generated.register.go b/pkg/apis/pipeline/v1alpha1/zz_generated.register.go new file mode 100644 index 000000000..204da4cde --- /dev/null +++ b/pkg/apis/pipeline/v1alpha1/zz_generated.register.go @@ -0,0 +1,67 @@ +/* +Copyright Kurator 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 register-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// GroupName specifies the group name used to register the objects. +const GroupName = "pipeline.kurator.dev" + +// GroupVersion specifies the group and the version used to register the objects. +var GroupVersion = v1.GroupVersion{Group: GroupName, Version: "v1alpha1"} + +// SchemeGroupVersion is group version used to register these objects +// Deprecated: use GroupVersion instead. +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. + SchemeBuilder runtime.SchemeBuilder + localSchemeBuilder = &SchemeBuilder + // Depreciated: use Install instead + AddToScheme = localSchemeBuilder.AddToScheme + Install = localSchemeBuilder.AddToScheme +) + +func init() { + // We only register manually written functions here. The registration of the + // generated functions takes place in the generated files. The separation + // makes the code compile even when the generated files are missing. + localSchemeBuilder.Register(addKnownTypes) +} + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &Pipeline{}, + &PipelineList{}, + ) + // AddToGroupVersion allows the serialization of client types like ListOptions. + v1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/pkg/client-go/generated/clientset/versioned/clientset.go b/pkg/client-go/generated/clientset/versioned/clientset.go index eae9f08af..3b658ae8c 100644 --- a/pkg/client-go/generated/clientset/versioned/clientset.go +++ b/pkg/client-go/generated/clientset/versioned/clientset.go @@ -30,6 +30,7 @@ import ( clusterv1alpha1 "kurator.dev/kurator/pkg/client-go/generated/clientset/versioned/typed/cluster/v1alpha1" fleetv1alpha1 "kurator.dev/kurator/pkg/client-go/generated/clientset/versioned/typed/fleet/v1alpha1" infrastructurev1alpha1 "kurator.dev/kurator/pkg/client-go/generated/clientset/versioned/typed/infra/v1alpha1" + pipelinev1alpha1 "kurator.dev/kurator/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1" ) type Interface interface { @@ -39,9 +40,11 @@ type Interface interface { ClusterV1alpha1() clusterv1alpha1.ClusterV1alpha1Interface FleetV1alpha1() fleetv1alpha1.FleetV1alpha1Interface InfrastructureV1alpha1() infrastructurev1alpha1.InfrastructureV1alpha1Interface + PipelineV1alpha1() pipelinev1alpha1.PipelineV1alpha1Interface } -// Clientset contains the clients for groups. +// Clientset contains the clients for groups. Each group has exactly one +// version included in a Clientset. type Clientset struct { *discovery.DiscoveryClient appsV1alpha1 *appsv1alpha1.AppsV1alpha1Client @@ -49,6 +52,7 @@ type Clientset struct { clusterV1alpha1 *clusterv1alpha1.ClusterV1alpha1Client fleetV1alpha1 *fleetv1alpha1.FleetV1alpha1Client infrastructureV1alpha1 *infrastructurev1alpha1.InfrastructureV1alpha1Client + pipelineV1alpha1 *pipelinev1alpha1.PipelineV1alpha1Client } // AppsV1alpha1 retrieves the AppsV1alpha1Client @@ -76,6 +80,11 @@ func (c *Clientset) InfrastructureV1alpha1() infrastructurev1alpha1.Infrastructu return c.infrastructureV1alpha1 } +// PipelineV1alpha1 retrieves the PipelineV1alpha1Client +func (c *Clientset) PipelineV1alpha1() pipelinev1alpha1.PipelineV1alpha1Interface { + return c.pipelineV1alpha1 +} + // Discovery retrieves the DiscoveryClient func (c *Clientset) Discovery() discovery.DiscoveryInterface { if c == nil { @@ -140,6 +149,10 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, if err != nil { return nil, err } + cs.pipelineV1alpha1, err = pipelinev1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) if err != nil { @@ -166,6 +179,7 @@ func New(c rest.Interface) *Clientset { cs.clusterV1alpha1 = clusterv1alpha1.New(c) cs.fleetV1alpha1 = fleetv1alpha1.New(c) cs.infrastructureV1alpha1 = infrastructurev1alpha1.New(c) + cs.pipelineV1alpha1 = pipelinev1alpha1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/client-go/generated/clientset/versioned/fake/clientset_generated.go b/pkg/client-go/generated/clientset/versioned/fake/clientset_generated.go index c53caeb3e..14ba49685 100644 --- a/pkg/client-go/generated/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client-go/generated/clientset/versioned/fake/clientset_generated.go @@ -35,6 +35,8 @@ import ( fakefleetv1alpha1 "kurator.dev/kurator/pkg/client-go/generated/clientset/versioned/typed/fleet/v1alpha1/fake" infrastructurev1alpha1 "kurator.dev/kurator/pkg/client-go/generated/clientset/versioned/typed/infra/v1alpha1" fakeinfrastructurev1alpha1 "kurator.dev/kurator/pkg/client-go/generated/clientset/versioned/typed/infra/v1alpha1/fake" + pipelinev1alpha1 "kurator.dev/kurator/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1" + fakepipelinev1alpha1 "kurator.dev/kurator/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1/fake" ) // NewSimpleClientset returns a clientset that will respond with the provided objects. @@ -111,3 +113,8 @@ func (c *Clientset) FleetV1alpha1() fleetv1alpha1.FleetV1alpha1Interface { func (c *Clientset) InfrastructureV1alpha1() infrastructurev1alpha1.InfrastructureV1alpha1Interface { return &fakeinfrastructurev1alpha1.FakeInfrastructureV1alpha1{Fake: &c.Fake} } + +// PipelineV1alpha1 retrieves the PipelineV1alpha1Client +func (c *Clientset) PipelineV1alpha1() pipelinev1alpha1.PipelineV1alpha1Interface { + return &fakepipelinev1alpha1.FakePipelineV1alpha1{Fake: &c.Fake} +} diff --git a/pkg/client-go/generated/clientset/versioned/fake/register.go b/pkg/client-go/generated/clientset/versioned/fake/register.go index 4ecd6db23..e21e9adc4 100644 --- a/pkg/client-go/generated/clientset/versioned/fake/register.go +++ b/pkg/client-go/generated/clientset/versioned/fake/register.go @@ -29,6 +29,7 @@ import ( clusterv1alpha1 "kurator.dev/kurator/pkg/apis/cluster/v1alpha1" fleetv1alpha1 "kurator.dev/kurator/pkg/apis/fleet/v1alpha1" infrastructurev1alpha1 "kurator.dev/kurator/pkg/apis/infra/v1alpha1" + pipelinev1alpha1 "kurator.dev/kurator/pkg/apis/pipeline/v1alpha1" ) var scheme = runtime.NewScheme() @@ -40,6 +41,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ clusterv1alpha1.AddToScheme, fleetv1alpha1.AddToScheme, infrastructurev1alpha1.AddToScheme, + pipelinev1alpha1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client-go/generated/clientset/versioned/scheme/register.go b/pkg/client-go/generated/clientset/versioned/scheme/register.go index 2294cd85e..4c16cfc0a 100644 --- a/pkg/client-go/generated/clientset/versioned/scheme/register.go +++ b/pkg/client-go/generated/clientset/versioned/scheme/register.go @@ -29,6 +29,7 @@ import ( clusterv1alpha1 "kurator.dev/kurator/pkg/apis/cluster/v1alpha1" fleetv1alpha1 "kurator.dev/kurator/pkg/apis/fleet/v1alpha1" infrastructurev1alpha1 "kurator.dev/kurator/pkg/apis/infra/v1alpha1" + pipelinev1alpha1 "kurator.dev/kurator/pkg/apis/pipeline/v1alpha1" ) var Scheme = runtime.NewScheme() @@ -40,6 +41,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ clusterv1alpha1.AddToScheme, fleetv1alpha1.AddToScheme, infrastructurev1alpha1.AddToScheme, + pipelinev1alpha1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client-go/generated/clientset/versioned/typed/apps/v1alpha1/fake/fake_application.go b/pkg/client-go/generated/clientset/versioned/typed/apps/v1alpha1/fake/fake_application.go index c1072cde2..8cdde4acf 100644 --- a/pkg/client-go/generated/clientset/versioned/typed/apps/v1alpha1/fake/fake_application.go +++ b/pkg/client-go/generated/clientset/versioned/typed/apps/v1alpha1/fake/fake_application.go @@ -23,6 +23,7 @@ import ( 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" @@ -35,9 +36,9 @@ type FakeApplications struct { ns string } -var applicationsResource = v1alpha1.SchemeGroupVersion.WithResource("applications") +var applicationsResource = schema.GroupVersionResource{Group: "apps.kurator.dev", Version: "v1alpha1", Resource: "applications"} -var applicationsKind = v1alpha1.SchemeGroupVersion.WithKind("Application") +var applicationsKind = schema.GroupVersionKind{Group: "apps.kurator.dev", Version: "v1alpha1", Kind: "Application"} // Get takes name of the application, and returns the corresponding application object, and an error if there is any. func (c *FakeApplications) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Application, err error) { diff --git a/pkg/client-go/generated/clientset/versioned/typed/backups/v1alpha1/fake/fake_backup.go b/pkg/client-go/generated/clientset/versioned/typed/backups/v1alpha1/fake/fake_backup.go index 9c11871eb..401caad12 100644 --- a/pkg/client-go/generated/clientset/versioned/typed/backups/v1alpha1/fake/fake_backup.go +++ b/pkg/client-go/generated/clientset/versioned/typed/backups/v1alpha1/fake/fake_backup.go @@ -23,6 +23,7 @@ import ( 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" @@ -35,9 +36,9 @@ type FakeBackups struct { ns string } -var backupsResource = v1alpha1.SchemeGroupVersion.WithResource("backups") +var backupsResource = schema.GroupVersionResource{Group: "backup.kurator.dev", Version: "v1alpha1", Resource: "backups"} -var backupsKind = v1alpha1.SchemeGroupVersion.WithKind("Backup") +var backupsKind = schema.GroupVersionKind{Group: "backup.kurator.dev", Version: "v1alpha1", Kind: "Backup"} // Get takes name of the backup, and returns the corresponding backup object, and an error if there is any. func (c *FakeBackups) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Backup, err error) { diff --git a/pkg/client-go/generated/clientset/versioned/typed/cluster/v1alpha1/fake/fake_attachedcluster.go b/pkg/client-go/generated/clientset/versioned/typed/cluster/v1alpha1/fake/fake_attachedcluster.go index a0c3092f9..4d6d3b39d 100644 --- a/pkg/client-go/generated/clientset/versioned/typed/cluster/v1alpha1/fake/fake_attachedcluster.go +++ b/pkg/client-go/generated/clientset/versioned/typed/cluster/v1alpha1/fake/fake_attachedcluster.go @@ -23,6 +23,7 @@ import ( 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" @@ -35,9 +36,9 @@ type FakeAttachedClusters struct { ns string } -var attachedclustersResource = v1alpha1.SchemeGroupVersion.WithResource("attachedclusters") +var attachedclustersResource = schema.GroupVersionResource{Group: "cluster.kurator.dev", Version: "v1alpha1", Resource: "attachedclusters"} -var attachedclustersKind = v1alpha1.SchemeGroupVersion.WithKind("AttachedCluster") +var attachedclustersKind = schema.GroupVersionKind{Group: "cluster.kurator.dev", Version: "v1alpha1", Kind: "AttachedCluster"} // Get takes name of the attachedCluster, and returns the corresponding attachedCluster object, and an error if there is any. func (c *FakeAttachedClusters) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.AttachedCluster, err error) { diff --git a/pkg/client-go/generated/clientset/versioned/typed/cluster/v1alpha1/fake/fake_cluster.go b/pkg/client-go/generated/clientset/versioned/typed/cluster/v1alpha1/fake/fake_cluster.go index ee31f8d55..5715a0c42 100644 --- a/pkg/client-go/generated/clientset/versioned/typed/cluster/v1alpha1/fake/fake_cluster.go +++ b/pkg/client-go/generated/clientset/versioned/typed/cluster/v1alpha1/fake/fake_cluster.go @@ -23,6 +23,7 @@ import ( 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" @@ -35,9 +36,9 @@ type FakeClusters struct { ns string } -var clustersResource = v1alpha1.SchemeGroupVersion.WithResource("clusters") +var clustersResource = schema.GroupVersionResource{Group: "cluster.kurator.dev", Version: "v1alpha1", Resource: "clusters"} -var clustersKind = v1alpha1.SchemeGroupVersion.WithKind("Cluster") +var clustersKind = schema.GroupVersionKind{Group: "cluster.kurator.dev", Version: "v1alpha1", Kind: "Cluster"} // Get takes name of the cluster, and returns the corresponding cluster object, and an error if there is any. func (c *FakeClusters) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Cluster, err error) { diff --git a/pkg/client-go/generated/clientset/versioned/typed/fleet/v1alpha1/fake/fake_fleet.go b/pkg/client-go/generated/clientset/versioned/typed/fleet/v1alpha1/fake/fake_fleet.go index 45b7087e4..44959a50e 100644 --- a/pkg/client-go/generated/clientset/versioned/typed/fleet/v1alpha1/fake/fake_fleet.go +++ b/pkg/client-go/generated/clientset/versioned/typed/fleet/v1alpha1/fake/fake_fleet.go @@ -23,6 +23,7 @@ import ( 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" @@ -35,9 +36,9 @@ type FakeFleets struct { ns string } -var fleetsResource = v1alpha1.SchemeGroupVersion.WithResource("fleets") +var fleetsResource = schema.GroupVersionResource{Group: "fleet.kurator.dev", Version: "v1alpha1", Resource: "fleets"} -var fleetsKind = v1alpha1.SchemeGroupVersion.WithKind("Fleet") +var fleetsKind = schema.GroupVersionKind{Group: "fleet.kurator.dev", Version: "v1alpha1", Kind: "Fleet"} // Get takes name of the fleet, and returns the corresponding fleet object, and an error if there is any. func (c *FakeFleets) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Fleet, err error) { diff --git a/pkg/client-go/generated/clientset/versioned/typed/infra/v1alpha1/fake/fake_customcluster.go b/pkg/client-go/generated/clientset/versioned/typed/infra/v1alpha1/fake/fake_customcluster.go index d1758b930..d9b441fce 100644 --- a/pkg/client-go/generated/clientset/versioned/typed/infra/v1alpha1/fake/fake_customcluster.go +++ b/pkg/client-go/generated/clientset/versioned/typed/infra/v1alpha1/fake/fake_customcluster.go @@ -23,6 +23,7 @@ import ( 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" @@ -35,9 +36,9 @@ type FakeCustomClusters struct { ns string } -var customclustersResource = v1alpha1.SchemeGroupVersion.WithResource("customclusters") +var customclustersResource = schema.GroupVersionResource{Group: "infrastructure.cluster.x-k8s.io", Version: "v1alpha1", Resource: "customclusters"} -var customclustersKind = v1alpha1.SchemeGroupVersion.WithKind("CustomCluster") +var customclustersKind = schema.GroupVersionKind{Group: "infrastructure.cluster.x-k8s.io", Version: "v1alpha1", Kind: "CustomCluster"} // Get takes name of the customCluster, and returns the corresponding customCluster object, and an error if there is any. func (c *FakeCustomClusters) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.CustomCluster, err error) { diff --git a/pkg/client-go/generated/clientset/versioned/typed/infra/v1alpha1/fake/fake_custommachine.go b/pkg/client-go/generated/clientset/versioned/typed/infra/v1alpha1/fake/fake_custommachine.go index aeb567b06..8851192e6 100644 --- a/pkg/client-go/generated/clientset/versioned/typed/infra/v1alpha1/fake/fake_custommachine.go +++ b/pkg/client-go/generated/clientset/versioned/typed/infra/v1alpha1/fake/fake_custommachine.go @@ -23,6 +23,7 @@ import ( 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" @@ -35,9 +36,9 @@ type FakeCustomMachines struct { ns string } -var custommachinesResource = v1alpha1.SchemeGroupVersion.WithResource("custommachines") +var custommachinesResource = schema.GroupVersionResource{Group: "infrastructure.cluster.x-k8s.io", Version: "v1alpha1", Resource: "custommachines"} -var custommachinesKind = v1alpha1.SchemeGroupVersion.WithKind("CustomMachine") +var custommachinesKind = schema.GroupVersionKind{Group: "infrastructure.cluster.x-k8s.io", Version: "v1alpha1", Kind: "CustomMachine"} // Get takes name of the customMachine, and returns the corresponding customMachine object, and an error if there is any. func (c *FakeCustomMachines) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.CustomMachine, err error) { diff --git a/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1/doc.go b/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1/doc.go new file mode 100644 index 000000000..6886442c4 --- /dev/null +++ b/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright Kurator 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. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1/fake/doc.go b/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1/fake/doc.go new file mode 100644 index 000000000..1e0a97ca4 --- /dev/null +++ b/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright Kurator 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 has the automatically generated clients. +package fake diff --git a/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_pipeline.go b/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_pipeline.go new file mode 100644 index 000000000..0b48925bc --- /dev/null +++ b/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_pipeline.go @@ -0,0 +1,142 @@ +/* +Copyright Kurator 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" + + 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" + v1alpha1 "kurator.dev/kurator/pkg/apis/pipeline/v1alpha1" +) + +// FakePipelines implements PipelineInterface +type FakePipelines struct { + Fake *FakePipelineV1alpha1 + ns string +} + +var pipelinesResource = schema.GroupVersionResource{Group: "pipeline.kurator.dev", Version: "v1alpha1", Resource: "pipelines"} + +var pipelinesKind = schema.GroupVersionKind{Group: "pipeline.kurator.dev", Version: "v1alpha1", Kind: "Pipeline"} + +// Get takes name of the pipeline, and returns the corresponding pipeline object, and an error if there is any. +func (c *FakePipelines) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Pipeline, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(pipelinesResource, c.ns, name), &v1alpha1.Pipeline{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Pipeline), err +} + +// List takes label and field selectors, and returns the list of Pipelines that match those selectors. +func (c *FakePipelines) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.PipelineList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(pipelinesResource, pipelinesKind, c.ns, opts), &v1alpha1.PipelineList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.PipelineList{ListMeta: obj.(*v1alpha1.PipelineList).ListMeta} + for _, item := range obj.(*v1alpha1.PipelineList).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 pipelines. +func (c *FakePipelines) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(pipelinesResource, c.ns, opts)) + +} + +// Create takes the representation of a pipeline and creates it. Returns the server's representation of the pipeline, and an error, if there is any. +func (c *FakePipelines) Create(ctx context.Context, pipeline *v1alpha1.Pipeline, opts v1.CreateOptions) (result *v1alpha1.Pipeline, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(pipelinesResource, c.ns, pipeline), &v1alpha1.Pipeline{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Pipeline), err +} + +// Update takes the representation of a pipeline and updates it. Returns the server's representation of the pipeline, and an error, if there is any. +func (c *FakePipelines) Update(ctx context.Context, pipeline *v1alpha1.Pipeline, opts v1.UpdateOptions) (result *v1alpha1.Pipeline, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(pipelinesResource, c.ns, pipeline), &v1alpha1.Pipeline{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Pipeline), 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 *FakePipelines) UpdateStatus(ctx context.Context, pipeline *v1alpha1.Pipeline, opts v1.UpdateOptions) (*v1alpha1.Pipeline, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(pipelinesResource, "status", c.ns, pipeline), &v1alpha1.Pipeline{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Pipeline), err +} + +// Delete takes name of the pipeline and deletes it. Returns an error if one occurs. +func (c *FakePipelines) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(pipelinesResource, c.ns, name, opts), &v1alpha1.Pipeline{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakePipelines) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(pipelinesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.PipelineList{}) + return err +} + +// Patch applies the patch and returns the patched pipeline. +func (c *FakePipelines) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Pipeline, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(pipelinesResource, c.ns, name, pt, data, subresources...), &v1alpha1.Pipeline{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Pipeline), err +} diff --git a/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_pipeline_client.go b/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_pipeline_client.go new file mode 100644 index 000000000..2d1ad1734 --- /dev/null +++ b/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1/fake/fake_pipeline_client.go @@ -0,0 +1,40 @@ +/* +Copyright Kurator 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 ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" + v1alpha1 "kurator.dev/kurator/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1" +) + +type FakePipelineV1alpha1 struct { + *testing.Fake +} + +func (c *FakePipelineV1alpha1) Pipelines(namespace string) v1alpha1.PipelineInterface { + return &FakePipelines{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakePipelineV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1/generated_expansion.go b/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1/generated_expansion.go new file mode 100644 index 000000000..33727469d --- /dev/null +++ b/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright Kurator 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 + +type PipelineExpansion interface{} diff --git a/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1/pipeline.go b/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1/pipeline.go new file mode 100644 index 000000000..3af058393 --- /dev/null +++ b/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1/pipeline.go @@ -0,0 +1,195 @@ +/* +Copyright Kurator 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" + + 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" + v1alpha1 "kurator.dev/kurator/pkg/apis/pipeline/v1alpha1" + scheme "kurator.dev/kurator/pkg/client-go/generated/clientset/versioned/scheme" +) + +// PipelinesGetter has a method to return a PipelineInterface. +// A group's client should implement this interface. +type PipelinesGetter interface { + Pipelines(namespace string) PipelineInterface +} + +// PipelineInterface has methods to work with Pipeline resources. +type PipelineInterface interface { + Create(ctx context.Context, pipeline *v1alpha1.Pipeline, opts v1.CreateOptions) (*v1alpha1.Pipeline, error) + Update(ctx context.Context, pipeline *v1alpha1.Pipeline, opts v1.UpdateOptions) (*v1alpha1.Pipeline, error) + UpdateStatus(ctx context.Context, pipeline *v1alpha1.Pipeline, opts v1.UpdateOptions) (*v1alpha1.Pipeline, 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.Pipeline, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.PipelineList, 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.Pipeline, err error) + PipelineExpansion +} + +// pipelines implements PipelineInterface +type pipelines struct { + client rest.Interface + ns string +} + +// newPipelines returns a Pipelines +func newPipelines(c *PipelineV1alpha1Client, namespace string) *pipelines { + return &pipelines{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the pipeline, and returns the corresponding pipeline object, and an error if there is any. +func (c *pipelines) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Pipeline, err error) { + result = &v1alpha1.Pipeline{} + err = c.client.Get(). + Namespace(c.ns). + Resource("pipelines"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Pipelines that match those selectors. +func (c *pipelines) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.PipelineList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.PipelineList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("pipelines"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested pipelines. +func (c *pipelines) 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(). + Namespace(c.ns). + Resource("pipelines"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a pipeline and creates it. Returns the server's representation of the pipeline, and an error, if there is any. +func (c *pipelines) Create(ctx context.Context, pipeline *v1alpha1.Pipeline, opts v1.CreateOptions) (result *v1alpha1.Pipeline, err error) { + result = &v1alpha1.Pipeline{} + err = c.client.Post(). + Namespace(c.ns). + Resource("pipelines"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(pipeline). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a pipeline and updates it. Returns the server's representation of the pipeline, and an error, if there is any. +func (c *pipelines) Update(ctx context.Context, pipeline *v1alpha1.Pipeline, opts v1.UpdateOptions) (result *v1alpha1.Pipeline, err error) { + result = &v1alpha1.Pipeline{} + err = c.client.Put(). + Namespace(c.ns). + Resource("pipelines"). + Name(pipeline.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(pipeline). + 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 *pipelines) UpdateStatus(ctx context.Context, pipeline *v1alpha1.Pipeline, opts v1.UpdateOptions) (result *v1alpha1.Pipeline, err error) { + result = &v1alpha1.Pipeline{} + err = c.client.Put(). + Namespace(c.ns). + Resource("pipelines"). + Name(pipeline.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(pipeline). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the pipeline and deletes it. Returns an error if one occurs. +func (c *pipelines) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("pipelines"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *pipelines) 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(). + Namespace(c.ns). + Resource("pipelines"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched pipeline. +func (c *pipelines) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Pipeline, err error) { + result = &v1alpha1.Pipeline{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("pipelines"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1/pipeline_client.go b/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1/pipeline_client.go new file mode 100644 index 000000000..bc7a3ff15 --- /dev/null +++ b/pkg/client-go/generated/clientset/versioned/typed/pipeline/v1alpha1/pipeline_client.go @@ -0,0 +1,107 @@ +/* +Copyright Kurator 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 ( + "net/http" + + rest "k8s.io/client-go/rest" + v1alpha1 "kurator.dev/kurator/pkg/apis/pipeline/v1alpha1" + "kurator.dev/kurator/pkg/client-go/generated/clientset/versioned/scheme" +) + +type PipelineV1alpha1Interface interface { + RESTClient() rest.Interface + PipelinesGetter +} + +// PipelineV1alpha1Client is used to interact with features provided by the pipeline.kurator.dev group. +type PipelineV1alpha1Client struct { + restClient rest.Interface +} + +func (c *PipelineV1alpha1Client) Pipelines(namespace string) PipelineInterface { + return newPipelines(c, namespace) +} + +// NewForConfig creates a new PipelineV1alpha1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*PipelineV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new PipelineV1alpha1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*PipelineV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &PipelineV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new PipelineV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *PipelineV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new PipelineV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *PipelineV1alpha1Client { + return &PipelineV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *PipelineV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/client-go/generated/informers/externalversions/factory.go b/pkg/client-go/generated/informers/externalversions/factory.go index 32f3ec94e..171d7abf0 100644 --- a/pkg/client-go/generated/informers/externalversions/factory.go +++ b/pkg/client-go/generated/informers/externalversions/factory.go @@ -34,6 +34,7 @@ import ( fleet "kurator.dev/kurator/pkg/client-go/generated/informers/externalversions/fleet" infra "kurator.dev/kurator/pkg/client-go/generated/informers/externalversions/infra" internalinterfaces "kurator.dev/kurator/pkg/client-go/generated/informers/externalversions/internalinterfaces" + pipeline "kurator.dev/kurator/pkg/client-go/generated/informers/externalversions/pipeline" ) // SharedInformerOption defines the functional option type for SharedInformerFactory. @@ -51,11 +52,6 @@ type sharedInformerFactory struct { // startedInformers is used for tracking which informers have been started. // This allows Start() to be called multiple times safely. startedInformers map[reflect.Type]bool - // wg tracks how many goroutines were started. - wg sync.WaitGroup - // shuttingDown is true when Shutdown has been called. It may still be running - // because it needs to wait for goroutines. - shuttingDown bool } // WithCustomResyncConfig sets a custom resync period for the specified informer types. @@ -116,39 +112,20 @@ func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResy return factory } +// Start initializes all requested informers. func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { f.lock.Lock() defer f.lock.Unlock() - if f.shuttingDown { - return - } - for informerType, informer := range f.informers { if !f.startedInformers[informerType] { - f.wg.Add(1) - // We need a new variable in each loop iteration, - // otherwise the goroutine would use the loop variable - // and that keeps changing. - informer := informer - go func() { - defer f.wg.Done() - informer.Run(stopCh) - }() + go informer.Run(stopCh) f.startedInformers[informerType] = true } } } -func (f *sharedInformerFactory) Shutdown() { - f.lock.Lock() - f.shuttingDown = true - f.lock.Unlock() - - // Will return immediately if there is nothing to wait for. - f.wg.Wait() -} - +// WaitForCacheSync waits for all started informers' cache were synced. func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { informers := func() map[reflect.Type]cache.SharedIndexInformer { f.lock.Lock() @@ -170,7 +147,7 @@ func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[ref return res } -// InformerFor returns the SharedIndexInformer for obj using an internal +// InternalInformerFor returns the SharedIndexInformer for obj using an internal // client. func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { f.lock.Lock() @@ -195,63 +172,17 @@ func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internal // SharedInformerFactory provides shared informers for resources in all known // API group versions. -// -// It is typically used like this: -// -// ctx, cancel := context.Background() -// defer cancel() -// factory := NewSharedInformerFactory(client, resyncPeriod) -// defer factory.WaitForStop() // Returns immediately if nothing was started. -// genericInformer := factory.ForResource(resource) -// typedInformer := factory.SomeAPIGroup().V1().SomeType() -// factory.Start(ctx.Done()) // Start processing these informers. -// synced := factory.WaitForCacheSync(ctx.Done()) -// for v, ok := range synced { -// if !ok { -// fmt.Fprintf(os.Stderr, "caches failed to sync: %v", v) -// return -// } -// } -// -// // Creating informers can also be created after Start, but then -// // Start must be called again: -// anotherGenericInformer := factory.ForResource(resource) -// factory.Start(ctx.Done()) type SharedInformerFactory interface { internalinterfaces.SharedInformerFactory - - // Start initializes all requested informers. They are handled in goroutines - // which run until the stop channel gets closed. - Start(stopCh <-chan struct{}) - - // Shutdown marks a factory as shutting down. At that point no new - // informers can be started anymore and Start will return without - // doing anything. - // - // In addition, Shutdown blocks until all goroutines have terminated. For that - // to happen, the close channel(s) that they were started with must be closed, - // either before Shutdown gets called or while it is waiting. - // - // Shutdown may be called multiple times, even concurrently. All such calls will - // block until all goroutines have terminated. - Shutdown() - - // WaitForCacheSync blocks until all started informers' caches were synced - // or the stop channel gets closed. - WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool - - // ForResource gives generic access to a shared informer of the matching type. ForResource(resource schema.GroupVersionResource) (GenericInformer, error) - - // InformerFor returns the SharedIndexInformer for obj using an internal - // client. - InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer + WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool Apps() apps.Interface Backup() backups.Interface Cluster() cluster.Interface Fleet() fleet.Interface Infrastructure() infra.Interface + Pipeline() pipeline.Interface } func (f *sharedInformerFactory) Apps() apps.Interface { @@ -273,3 +204,7 @@ func (f *sharedInformerFactory) Fleet() fleet.Interface { func (f *sharedInformerFactory) Infrastructure() infra.Interface { return infra.New(f, f.namespace, f.tweakListOptions) } + +func (f *sharedInformerFactory) Pipeline() pipeline.Interface { + return pipeline.New(f, f.namespace, f.tweakListOptions) +} diff --git a/pkg/client-go/generated/informers/externalversions/generic.go b/pkg/client-go/generated/informers/externalversions/generic.go index 330a2875a..242265860 100644 --- a/pkg/client-go/generated/informers/externalversions/generic.go +++ b/pkg/client-go/generated/informers/externalversions/generic.go @@ -28,6 +28,7 @@ import ( clusterv1alpha1 "kurator.dev/kurator/pkg/apis/cluster/v1alpha1" fleetv1alpha1 "kurator.dev/kurator/pkg/apis/fleet/v1alpha1" infrav1alpha1 "kurator.dev/kurator/pkg/apis/infra/v1alpha1" + pipelinev1alpha1 "kurator.dev/kurator/pkg/apis/pipeline/v1alpha1" ) // GenericInformer is type of SharedIndexInformer which will locate and delegate to other @@ -80,6 +81,10 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case infrav1alpha1.SchemeGroupVersion.WithResource("custommachines"): return &genericInformer{resource: resource.GroupResource(), informer: f.Infrastructure().V1alpha1().CustomMachines().Informer()}, nil + // Group=pipeline.kurator.dev, Version=v1alpha1 + case pipelinev1alpha1.SchemeGroupVersion.WithResource("pipelines"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Pipeline().V1alpha1().Pipelines().Informer()}, nil + } return nil, fmt.Errorf("no informer found for %v", resource) diff --git a/pkg/client-go/generated/informers/externalversions/pipeline/interface.go b/pkg/client-go/generated/informers/externalversions/pipeline/interface.go new file mode 100644 index 000000000..3c8883d79 --- /dev/null +++ b/pkg/client-go/generated/informers/externalversions/pipeline/interface.go @@ -0,0 +1,46 @@ +/* +Copyright Kurator 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 pipeline + +import ( + internalinterfaces "kurator.dev/kurator/pkg/client-go/generated/informers/externalversions/internalinterfaces" + v1alpha1 "kurator.dev/kurator/pkg/client-go/generated/informers/externalversions/pipeline/v1alpha1" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/client-go/generated/informers/externalversions/pipeline/v1alpha1/interface.go b/pkg/client-go/generated/informers/externalversions/pipeline/v1alpha1/interface.go new file mode 100644 index 000000000..3e93ceac8 --- /dev/null +++ b/pkg/client-go/generated/informers/externalversions/pipeline/v1alpha1/interface.go @@ -0,0 +1,45 @@ +/* +Copyright Kurator 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 ( + internalinterfaces "kurator.dev/kurator/pkg/client-go/generated/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // Pipelines returns a PipelineInformer. + Pipelines() PipelineInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// Pipelines returns a PipelineInformer. +func (v *version) Pipelines() PipelineInformer { + return &pipelineInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client-go/generated/informers/externalversions/pipeline/v1alpha1/pipeline.go b/pkg/client-go/generated/informers/externalversions/pipeline/v1alpha1/pipeline.go new file mode 100644 index 000000000..07e831a0a --- /dev/null +++ b/pkg/client-go/generated/informers/externalversions/pipeline/v1alpha1/pipeline.go @@ -0,0 +1,90 @@ +/* +Copyright Kurator 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" + + 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" + pipelinev1alpha1 "kurator.dev/kurator/pkg/apis/pipeline/v1alpha1" + versioned "kurator.dev/kurator/pkg/client-go/generated/clientset/versioned" + internalinterfaces "kurator.dev/kurator/pkg/client-go/generated/informers/externalversions/internalinterfaces" + v1alpha1 "kurator.dev/kurator/pkg/client-go/generated/listers/pipeline/v1alpha1" +) + +// PipelineInformer provides access to a shared informer and lister for +// Pipelines. +type PipelineInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.PipelineLister +} + +type pipelineInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewPipelineInformer constructs a new informer for Pipeline 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 NewPipelineInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredPipelineInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredPipelineInformer constructs a new informer for Pipeline 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 NewFilteredPipelineInformer(client versioned.Interface, namespace string, 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.PipelineV1alpha1().Pipelines(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.PipelineV1alpha1().Pipelines(namespace).Watch(context.TODO(), options) + }, + }, + &pipelinev1alpha1.Pipeline{}, + resyncPeriod, + indexers, + ) +} + +func (f *pipelineInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredPipelineInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *pipelineInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&pipelinev1alpha1.Pipeline{}, f.defaultInformer) +} + +func (f *pipelineInformer) Lister() v1alpha1.PipelineLister { + return v1alpha1.NewPipelineLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client-go/generated/listers/pipeline/v1alpha1/expansion_generated.go b/pkg/client-go/generated/listers/pipeline/v1alpha1/expansion_generated.go new file mode 100644 index 000000000..48ab7720d --- /dev/null +++ b/pkg/client-go/generated/listers/pipeline/v1alpha1/expansion_generated.go @@ -0,0 +1,27 @@ +/* +Copyright Kurator 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 + +// PipelineListerExpansion allows custom methods to be added to +// PipelineLister. +type PipelineListerExpansion interface{} + +// PipelineNamespaceListerExpansion allows custom methods to be added to +// PipelineNamespaceLister. +type PipelineNamespaceListerExpansion interface{} diff --git a/pkg/client-go/generated/listers/pipeline/v1alpha1/pipeline.go b/pkg/client-go/generated/listers/pipeline/v1alpha1/pipeline.go new file mode 100644 index 000000000..26d3a4727 --- /dev/null +++ b/pkg/client-go/generated/listers/pipeline/v1alpha1/pipeline.go @@ -0,0 +1,99 @@ +/* +Copyright Kurator 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 ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1alpha1 "kurator.dev/kurator/pkg/apis/pipeline/v1alpha1" +) + +// PipelineLister helps list Pipelines. +// All objects returned here must be treated as read-only. +type PipelineLister interface { + // List lists all Pipelines in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.Pipeline, err error) + // Pipelines returns an object that can list and get Pipelines. + Pipelines(namespace string) PipelineNamespaceLister + PipelineListerExpansion +} + +// pipelineLister implements the PipelineLister interface. +type pipelineLister struct { + indexer cache.Indexer +} + +// NewPipelineLister returns a new PipelineLister. +func NewPipelineLister(indexer cache.Indexer) PipelineLister { + return &pipelineLister{indexer: indexer} +} + +// List lists all Pipelines in the indexer. +func (s *pipelineLister) List(selector labels.Selector) (ret []*v1alpha1.Pipeline, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Pipeline)) + }) + return ret, err +} + +// Pipelines returns an object that can list and get Pipelines. +func (s *pipelineLister) Pipelines(namespace string) PipelineNamespaceLister { + return pipelineNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// PipelineNamespaceLister helps list and get Pipelines. +// All objects returned here must be treated as read-only. +type PipelineNamespaceLister interface { + // List lists all Pipelines in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.Pipeline, err error) + // Get retrieves the Pipeline from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.Pipeline, error) + PipelineNamespaceListerExpansion +} + +// pipelineNamespaceLister implements the PipelineNamespaceLister +// interface. +type pipelineNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Pipelines in the indexer for a given namespace. +func (s pipelineNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Pipeline, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Pipeline)) + }) + return ret, err +} + +// Get retrieves the Pipeline from the indexer for a given namespace and name. +func (s pipelineNamespaceLister) Get(name string) (*v1alpha1.Pipeline, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("pipeline"), name) + } + return obj.(*v1alpha1.Pipeline), nil +}