From 744e4f3ae013fc33b05f7f277578f095d35a9bd8 Mon Sep 17 00:00:00 2001 From: Andrew Bayer Date: Wed, 24 Aug 2022 20:09:36 -0400 Subject: [PATCH] Add types and client for Resolution Part of #4710 In order to get remote resolution functionality to beta, we're moving it from a separate repository/release to be part of Pipeline. This is the first PR in a sequence moving the code from the Resolution repository into Pipeline. This also changes the `.resolver.resource` field's name to `.resolver.params` for consistency across our syntax. Signed-off-by: Andrew Bayer --- config/300-resolutionrequest.yaml | 67 +- docs/pipeline-api.md | 1569 ++++++++++++++--- docs/pipelineruns.md | 2 +- docs/taskruns.md | 2 +- hack/ignored-openapi-violations.list | 3 +- hack/spec-gen/main.go | 2 +- hack/update-codegen.sh | 11 + hack/update-openapigen.sh | 2 +- pkg/apis/pipeline/v1/openapi_generated.go | 39 +- pkg/apis/pipeline/v1/pipeline_types.go | 4 +- pkg/apis/pipeline/v1/pipeline_types_test.go | 10 +- pkg/apis/pipeline/v1/resolver_types.go | 14 +- pkg/apis/pipeline/v1/swagger.json | 34 +- pkg/apis/pipeline/v1/taskref_validation.go | 30 +- .../pipeline/v1/taskref_validation_test.go | 22 +- pkg/apis/pipeline/v1/zz_generated.deepcopy.go | 26 +- .../pipeline/v1beta1/openapi_generated.go | 422 +++-- pkg/apis/pipeline/v1beta1/pipeline_types.go | 2 +- .../pipeline/v1beta1/pipeline_types_test.go | 15 +- .../v1beta1/pipelineref_validation.go | 50 +- .../v1beta1/pipelineref_validation_test.go | 71 +- .../pipeline/v1beta1/resolver_conversion.go | 26 +- pkg/apis/pipeline/v1beta1/resolver_types.go | 14 +- pkg/apis/pipeline/v1beta1/swagger.json | 155 +- .../pipeline/v1beta1/taskref_validation.go | 50 +- .../v1beta1/taskref_validation_test.go | 71 +- .../pipeline/v1beta1/zz_generated.deepcopy.go | 26 +- pkg/apis/resolution/register.go | 22 + pkg/apis/resolution/v1alpha1/doc.go | 21 + pkg/apis/resolution/v1alpha1/register.go | 54 + .../v1alpha1/resolution_request_defaults.go | 33 + .../v1alpha1/resolution_request_lifecycle.go | 71 + .../v1alpha1/resolution_request_types.go | 86 + .../v1alpha1/resolution_request_validation.go | 51 + .../v1alpha1/zz_generated.deepcopy.go | 144 ++ .../clientset/versioned/clientset.go | 121 ++ .../resolution/clientset/versioned/doc.go | 20 + .../versioned/fake/clientset_generated.go | 85 + .../clientset/versioned/fake/doc.go | 20 + .../clientset/versioned/fake/register.go | 56 + .../clientset/versioned/scheme/doc.go | 20 + .../clientset/versioned/scheme/register.go | 56 + .../typed/resolution/v1alpha1/doc.go | 20 + .../typed/resolution/v1alpha1/fake/doc.go | 20 + .../v1alpha1/fake/fake_resolution_client.go | 40 + .../v1alpha1/fake/fake_resolutionrequest.go | 142 ++ .../v1alpha1/generated_expansion.go | 21 + .../resolution/v1alpha1/resolution_client.go | 107 ++ .../resolution/v1alpha1/resolutionrequest.go | 195 ++ .../informers/externalversions/factory.go | 180 ++ .../informers/externalversions/generic.go | 62 + .../internalinterfaces/factory_interfaces.go | 40 + .../externalversions/resolution/interface.go | 46 + .../resolution/v1alpha1/interface.go | 45 + .../resolution/v1alpha1/resolutionrequest.go | 90 + .../resolution/injection/client/client.go | 243 +++ .../resolution/injection/client/fake/fake.go | 57 + .../injection/informers/factory/factory.go | 56 + .../injection/informers/factory/fake/fake.go | 45 + .../filtered/fake/fake_filtered_factory.go | 59 + .../factory/filtered/filtered_factory.go | 77 + .../v1alpha1/resolutionrequest/fake/fake.go | 40 + .../resolutionrequest/filtered/fake/fake.go | 52 + .../filtered/resolutionrequest.go | 136 ++ .../resolutionrequest/resolutionrequest.go | 116 ++ .../v1alpha1/resolutionrequest/controller.go | 162 ++ .../v1alpha1/resolutionrequest/reconciler.go | 450 +++++ .../v1alpha1/resolutionrequest/state.go | 97 + .../v1alpha1/expansion_generated.go | 27 + .../resolution/v1alpha1/resolutionrequest.go | 99 ++ .../pipelinerun/pipelinerun_test.go | 6 + .../pipelinespec/pipelinespec_test.go | 9 +- .../pipelinerun/resources/pipelineref.go | 5 +- pkg/reconciler/taskrun/resources/taskref.go | 6 +- .../taskrun/resources/taskspec_test.go | 9 +- 75 files changed, 5627 insertions(+), 731 deletions(-) create mode 100644 pkg/apis/resolution/register.go create mode 100644 pkg/apis/resolution/v1alpha1/doc.go create mode 100644 pkg/apis/resolution/v1alpha1/register.go create mode 100644 pkg/apis/resolution/v1alpha1/resolution_request_defaults.go create mode 100644 pkg/apis/resolution/v1alpha1/resolution_request_lifecycle.go create mode 100644 pkg/apis/resolution/v1alpha1/resolution_request_types.go create mode 100644 pkg/apis/resolution/v1alpha1/resolution_request_validation.go create mode 100644 pkg/apis/resolution/v1alpha1/zz_generated.deepcopy.go create mode 100644 pkg/client/resolution/clientset/versioned/clientset.go create mode 100644 pkg/client/resolution/clientset/versioned/doc.go create mode 100644 pkg/client/resolution/clientset/versioned/fake/clientset_generated.go create mode 100644 pkg/client/resolution/clientset/versioned/fake/doc.go create mode 100644 pkg/client/resolution/clientset/versioned/fake/register.go create mode 100644 pkg/client/resolution/clientset/versioned/scheme/doc.go create mode 100644 pkg/client/resolution/clientset/versioned/scheme/register.go create mode 100644 pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/doc.go create mode 100644 pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/fake/doc.go create mode 100644 pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/fake/fake_resolution_client.go create mode 100644 pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/fake/fake_resolutionrequest.go create mode 100644 pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/generated_expansion.go create mode 100644 pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/resolution_client.go create mode 100644 pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/resolutionrequest.go create mode 100644 pkg/client/resolution/informers/externalversions/factory.go create mode 100644 pkg/client/resolution/informers/externalversions/generic.go create mode 100644 pkg/client/resolution/informers/externalversions/internalinterfaces/factory_interfaces.go create mode 100644 pkg/client/resolution/informers/externalversions/resolution/interface.go create mode 100644 pkg/client/resolution/informers/externalversions/resolution/v1alpha1/interface.go create mode 100644 pkg/client/resolution/informers/externalversions/resolution/v1alpha1/resolutionrequest.go create mode 100644 pkg/client/resolution/injection/client/client.go create mode 100644 pkg/client/resolution/injection/client/fake/fake.go create mode 100644 pkg/client/resolution/injection/informers/factory/factory.go create mode 100644 pkg/client/resolution/injection/informers/factory/fake/fake.go create mode 100644 pkg/client/resolution/injection/informers/factory/filtered/fake/fake_filtered_factory.go create mode 100644 pkg/client/resolution/injection/informers/factory/filtered/filtered_factory.go create mode 100644 pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest/fake/fake.go create mode 100644 pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest/filtered/fake/fake.go create mode 100644 pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest/filtered/resolutionrequest.go create mode 100644 pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest/resolutionrequest.go create mode 100644 pkg/client/resolution/injection/reconciler/resolution/v1alpha1/resolutionrequest/controller.go create mode 100644 pkg/client/resolution/injection/reconciler/resolution/v1alpha1/resolutionrequest/reconciler.go create mode 100644 pkg/client/resolution/injection/reconciler/resolution/v1alpha1/resolutionrequest/state.go create mode 100644 pkg/client/resolution/listers/resolution/v1alpha1/expansion_generated.go create mode 100644 pkg/client/resolution/listers/resolution/v1alpha1/resolutionrequest.go diff --git a/config/300-resolutionrequest.yaml b/config/300-resolutionrequest.yaml index 02d74fb8f9b..3d58caac07a 100644 --- a/config/300-resolutionrequest.yaml +++ b/config/300-resolutionrequest.yaml @@ -26,8 +26,11 @@ spec: plural: resolutionrequests singular: resolutionrequest categories: - - all - - tekton + - tekton + - tekton-pipelines + shortNames: + - resolutionrequest + - resolutionrequests versions: - name: v1alpha1 served: true @@ -37,58 +40,14 @@ spec: schema: openAPIV3Schema: type: object - properties: - spec: - description: Spec holds the parameters for the request. - type: object - properties: - params: - type: object - x-kubernetes-preserve-unknown-fields: true - status: - description: Status receives the data of a completed request. - type: object - properties: - data: - description: The resolved contents of the requested resource in-lined as a string. - type: string - annotations: - description: Annotations is additional Status fields for the Resource to save some additional State as well as convey more information to the user. This is roughly akin to Annotations on any k8s resource, just the reconciler conveying richer information outwards. - type: object - x-kubernetes-preserve-unknown-fields: true - conditions: - description: Conditions the latest available observations of a resource's current state. - type: array - items: - description: Conditions describe the success and completion state of the resource request. - type: object - required: - - status - - type - properties: - lastTransitionTime: - description: LastTransitionTime is the last time the condition transitioned from one status to another. We use VolatileTime in place of metav1.Time to exclude this from creating equality.Semantic differences (all other things held constant). - type: string - format: date-time - message: - description: A human readable message indicating details about the transition. - type: string - reason: - description: The reason for the condition's last transition. - type: string - severity: - description: Severity with which to treat failures of this type of condition. When this is not specified, it defaults to Error. - type: string - status: - description: Status of the condition, one of True, False, Unknown. - type: string - type: - description: Type of condition. - type: string - observedGeneration: - description: ObservedGeneration is the 'Generation' of the Service that was last processed by the controller. - type: integer - format: int64 + # One can use x-kubernetes-preserve-unknown-fields: true + # at the root of the schema (and inside any properties, additionalProperties) + # to get the traditional CRD behaviour that nothing is pruned, despite + # setting spec.preserveUnknownProperties: false. + # + # See https://kubernetes.io/blog/2019/06/20/crd-structural-schema/ + # See issue: https://github.com/knative/serving/issues/912 + x-kubernetes-preserve-unknown-fields: true additionalPrinterColumns: - name: Succeeded type: string diff --git a/docs/pipeline-api.md b/docs/pipeline-api.md index 8e8e62ee84f..902db8a5c38 100644 --- a/docs/pipeline-api.md +++ b/docs/pipeline-api.md @@ -9,6 +9,9 @@ weight: 1000

Packages:

+

resolution.tekton.dev/v1alpha1

+
+
+Resource Types: + +

ResolutionRequest +

+
+

ResolutionRequest is an object for requesting the content of +a Tekton resource like a pipeline.yaml.

+
+ + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+metadata
+ + +Kubernetes meta/v1.ObjectMeta + + +
+(Optional) +Refer to the Kubernetes API documentation for the fields of the +metadata field. +
+spec
+ + +ResolutionRequestSpec + + +
+(Optional) +

Spec holds the information for the request part of the resource request.

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

Parameters are the runtime attributes passed to +the resolver to help it figure out how to resolve the +resource being requested. For example: repo URL, commit SHA, +path to file, the kind of authentication to leverage, etc.

+
+
+status
+ + +ResolutionRequestStatus + + +
+(Optional) +

Status communicates the state of the request and, ultimately, +the content of the resolved resource.

+
+

ResolutionRequestSpec +

+

+(Appears on:ResolutionRequest) +

+
+

ResolutionRequestSpec are all the fields in the spec of the +ResolutionRequest CRD.

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

Parameters are the runtime attributes passed to +the resolver to help it figure out how to resolve the +resource being requested. For example: repo URL, commit SHA, +path to file, the kind of authentication to leverage, etc.

+
+

ResolutionRequestStatus +

+

+(Appears on:ResolutionRequest) +

+
+

ResolutionRequestStatus are all the fields in a ResolutionRequest’s +status subresource.

+
+ + + + + + + + + + + + + + + + + +
FieldDescription
+Status
+ + +knative.dev/pkg/apis/duck/v1.Status + + +
+

+(Members of Status are embedded into this type.) +

+
+ResolutionRequestStatusFields
+ + +ResolutionRequestStatusFields + + +
+

+(Members of ResolutionRequestStatusFields are embedded into this type.) +

+
+

ResolutionRequestStatusFields +

+

+(Appears on:ResolutionRequestStatus) +

+
+

ResolutionRequestStatusFields are the ResolutionRequest-specific fields +for the status subresource.

+
+ + + + + + + + + + + + + +
FieldDescription
+data
+ +string + +
+

Data is a string representation of the resolved content +of the requested resource in-lined into the ResolutionRequest +object.

+
+

tekton.dev/v1

Package v1 contains API Schema definitions for the pipeline v1 API group

@@ -27,6 +230,8 @@ Resource Types: Pipeline
  • Task +
  • +TaskRun
  • Pipeline

    @@ -357,13 +562,12 @@ the steps start and end after the steps complete.

    -

    EmbeddedTask +

    TaskRun

    -

    -(Appears on:PipelineTask) -

    -

    EmbeddedTask is used to define a Task inline within a Pipeline’s PipelineTasks.

    +

    TaskRun represents a single execution of a Task. TaskRuns are how the steps +specified in a Task are executed; they specify the parameters and resources +used to run the steps in a Task.

    @@ -375,60 +579,104 @@ the steps start and end after the steps complete.

    + + + + + + + + + + + + + + - -
    +apiVersion
    +string
    + +tekton.dev/v1 + +
    +kind
    +string +
    TaskRun
    +metadata
    + + +Kubernetes meta/v1.ObjectMeta + + +
    +(Optional) +Refer to the Kubernetes API documentation for the fields of the +metadata field. +
    spec
    -k8s.io/apimachinery/pkg/runtime.RawExtension + +TaskRunSpec +
    (Optional) -

    Spec is a specification of a custom task



    -
    --
    +debug
    -[]byte + +TaskRunDebug +
    -

    Raw is the underlying serialization of this object.

    -

    TODO: Determine how to detect ContentType and ContentEncoding of ‘Raw’ data.

    +(Optional)
    --
    +params
    -k8s.io/apimachinery/pkg/runtime.Object + +[]Param +
    -

    Object can hold a representation of this extension - useful for working with versioned -structs.

    +(Optional)
    +
    +serviceAccountName
    + +string + +
    +(Optional)
    -metadata
    +taskRef
    - -PipelineTaskMetadata + +TaskRef
    (Optional) +

    no more than one of the TaskRef and TaskSpec may be specified.

    -TaskSpec
    +taskSpec
    TaskSpec @@ -436,22 +684,152 @@ TaskSpec
    -

    -(Members of TaskSpec are embedded into this type.) -

    (Optional) -

    TaskSpec is a specification of a task

    -

    EmbeddedTask -

    -

    -(Appears on:PipelineTask) -

    -
    -

    EmbeddedTask is used to define a Task inline within a Pipeline’s PipelineTasks.

    + + +status
    + + +TaskRunSpecStatus + + + + +(Optional) +

    Used for cancelling a taskrun (and maybe more later on)

    + + + + +statusMessage
    + + +TaskRunSpecStatusMessage + + + + +(Optional) +

    Status message for cancellation.

    + + + + +timeout
    + + +Kubernetes meta/v1.Duration + + + + +(Optional) +

    Time after which the build times out. Defaults to 1 hour. +Specified build timeout should be less than 24h. +Refer Go’s ParseDuration documentation for expected format: https://golang.org/pkg/time/#ParseDuration

    + + + + +podTemplate
    + + +Template + + + + +

    PodTemplate holds pod specific configuration

    + + + + +workspaces
    + + +[]WorkspaceBinding + + + + +(Optional) +

    Workspaces is a list of WorkspaceBindings from volumes to workspaces.

    + + + + +stepOverrides
    + + +[]TaskRunStepOverride + + + + +(Optional) +

    Overrides to apply to Steps in this TaskRun. +If a field is specified in both a Step and a StepOverride, +the value from the StepOverride will be used. +This field is only supported when the alpha feature gate is enabled.

    + + + + +sidecarOverrides
    + + +[]TaskRunSidecarOverride + + + + +(Optional) +

    Overrides to apply to Sidecars in this TaskRun. +If a field is specified in both a Sidecar and a SidecarOverride, +the value from the SidecarOverride will be used. +This field is only supported when the alpha feature gate is enabled.

    + + + + +computeResources
    + + +Kubernetes core/v1.ResourceRequirements + + + + +

    Compute resources to use for this TaskRun

    + + + + + + + +status
    + + +TaskRunStatus + + + + +(Optional) + + + + +

    EmbeddedTask +

    +

    +(Appears on:PipelineTask) +

    +
    +

    EmbeddedTask is used to define a Task inline within a Pipeline’s PipelineTasks.

    @@ -559,7 +937,7 @@ TaskSpec

    Param

    -(Appears on:PipelineTask) +(Appears on:PipelineTask, ResolverRef, TaskRunInputs, TaskRunSpec)

    Param declares an ParamValues to use for the parameter called name.

    @@ -1270,48 +1648,6 @@ ParamType

    ResolverName is the name of a resolver from which a resource can be requested.

    -

    ResolverParam -

    -

    -(Appears on:ResolverRef) -

    -
    -

    ResolverParam is a single parameter passed to a resolver.

    -
    -
    - - - - - - - - - - - - - - - - -
    FieldDescription
    -name
    - -string - -
    -

    Name is the name of the parameter that will be passed to the -resolver.

    -
    -value
    - -string - -
    -

    Value is the string value of the parameter that will be -passed to the resolver.

    -

    ResolverRef

    @@ -1347,16 +1683,16 @@ resolution of the referenced Tekton resource, such as “git”.

    -resource
    +params
    - -[]ResolverParam + +[]Param (Optional) -

    Resource contains the parameters used to identify the +

    Params contains the parameters used to identify the referenced Tekton resource. Example entries might include “repo” or “path” but the set of params ultimately depends on the chosen resolver.

    @@ -1862,6 +2198,69 @@ not have access to it.

    +

    SidecarState +

    +

    +(Appears on:TaskRunStatusFields) +

    +
    +

    SidecarState reports the results of running a sidecar in a Task.

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    FieldDescription
    +ContainerState
    + + +Kubernetes core/v1.ContainerState + + +
    +

    +(Members of ContainerState are embedded into this type.) +

    +
    +name
    + +string + +
    +
    +container
    + +string + +
    +
    +imageID
    + +string + +
    +

    Step

    @@ -2190,13 +2589,13 @@ string -

    StepTemplate +

    StepState

    -(Appears on:TaskSpec) +(Appears on:TaskRunStatusFields)

    -

    StepTemplate is a template for a Step

    +

    StepState reports the results of running a step in a Task.

    @@ -2208,19 +2607,82 @@ string - +

    +(Members of ContainerState are embedded into this type.) +

    + + + + + + + + + + + + + + + +
    -image
    +ContainerState
    -string + +Kubernetes core/v1.ContainerState +
    -(Optional) -

    Image reference name. -More info: https://kubernetes.io/docs/concepts/containers/images -This field is optional to allow higher level config management to default or override -container images in workload controllers like Deployments and StatefulSets.

    -
    +name
    + +string + +
    +
    +container
    + +string + +
    +
    +imageID
    + +string + +
    +
    +

    StepTemplate +

    +

    +(Appears on:TaskSpec) +

    +
    +

    StepTemplate is a template for a Step

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

    Image reference name. +More info: https://kubernetes.io/docs/concepts/containers/images +This field is optional to allow higher level config management to default or override +container images in workload controllers like Deployments and StatefulSets.

    +
    command
    @@ -2355,67 +2817,680 @@ Cannot be updated.

    -imagePullPolicy
    +imagePullPolicy
    + + +Kubernetes core/v1.PullPolicy + + +
    +(Optional) +

    Image pull policy. +One of Always, Never, IfNotPresent. +Defaults to Always if :latest tag is specified, or IfNotPresent otherwise. +Cannot be updated. +More info: https://kubernetes.io/docs/concepts/containers/images#updating-images

    +
    +securityContext
    + + +Kubernetes core/v1.SecurityContext + + +
    +(Optional) +

    SecurityContext defines the security options the Step should be run with. +If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext. +More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/

    +
    +

    TaskKind +(string alias)

    +

    +(Appears on:TaskRef) +

    +
    +

    TaskKind defines the type of Task used by the pipeline.

    +
    + + + + + + + + + + +
    ValueDescription

    "Task"

    NamespacedTaskKind indicates that the task type has a namespaced scope.

    +
    +

    TaskRef +

    +

    +(Appears on:PipelineTask, TaskRunSpec) +

    +
    +

    TaskRef can be used to refer to a specific instance of a task.

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

    Name of the referent; More info: http://kubernetes.io/docs/user-guide/identifiers#names

    +
    +kind
    + + +TaskKind + + +
    +

    TaskKind indicates the kind of the task, namespaced or cluster scoped.

    +
    +apiVersion
    + +string + +
    +(Optional) +

    API version of the referent

    +
    +ResolverRef
    + + +ResolverRef + + +
    +(Optional) +

    ResolverRef allows referencing a Task in a remote location +like a git repo. This field is only supported when the alpha +feature gate is enabled.

    +
    +

    TaskResult +

    +

    +(Appears on:TaskSpec) +

    +
    +

    TaskResult used to describe the results of a task

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

    Name the given name

    +
    +type
    + + +ResultsType + + +
    +(Optional) +

    Type is the user-specified type of the result. The possible type +is currently “string” and will support “array” in following work.

    +
    +properties
    + + +map[string]github.com/tektoncd/pipeline/pkg/apis/pipeline/v1.PropertySpec + + +
    +(Optional) +

    Properties is the JSON Schema properties to support key-value pairs results.

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

    Description is a human-readable description of the result

    +
    +

    TaskRunDebug +

    +

    +(Appears on:TaskRunSpec) +

    +
    +

    TaskRunDebug defines the breakpoint config for a particular TaskRun

    +
    + + + + + + + + + + + + + +
    FieldDescription
    +breakpoint
    + +[]string + +
    +(Optional) +
    +

    TaskRunInputs +

    +
    +

    TaskRunInputs holds the input values that this task was invoked with.

    +
    + + + + + + + + + + + + + +
    FieldDescription
    +params
    + + +[]Param + + +
    +(Optional) +
    +

    TaskRunReason +(string alias)

    +
    +

    TaskRunReason is an enum used to store all TaskRun reason for +the Succeeded condition that are controlled by the TaskRun itself. Failure +reasons that emerge from underlying resources are not included here

    +
    + + + + + + + + + + + + + + + + + + + + + + +
    ValueDescription

    "TaskRunCancelled"

    TaskRunReasonCancelled is the reason set when the Taskrun is cancelled by the user

    +

    "Failed"

    TaskRunReasonFailed is the reason set when the TaskRun completed with a failure

    +

    "TaskRunImagePullFailed"

    TaskRunReasonImagePullFailed is the reason set when the step of a task fails due to image not being pulled

    +

    "Running"

    TaskRunReasonRunning is the reason set when the TaskRun is running

    +

    "Started"

    TaskRunReasonStarted is the reason set when the TaskRun has just started

    +

    "Succeeded"

    TaskRunReasonSuccessful is the reason set when the TaskRun completed successfully

    +

    "TaskRunTimeout"

    TaskRunReasonTimedOut is the reason set when the Taskrun has timed out

    +
    +

    TaskRunResult +

    +

    +(Appears on:TaskRunStatusFields) +

    +
    +

    TaskRunResult used to describe the results of a task

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

    Name the given name

    +
    +type
    + + +ResultsType + + +
    +(Optional) +

    Type is the user-specified type of the result. The possible type +is currently “string” and will support “array” in following work.

    +
    +value
    + + +ParamValue + + +
    +

    Value the given value of the result

    +
    +

    TaskRunSidecarOverride +

    +

    +(Appears on:TaskRunSpec) +

    +
    +

    TaskRunSidecarOverride is used to override the values of a Sidecar in the corresponding Task.

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

    The name of the Sidecar to override.

    +
    +resources
    + + +Kubernetes core/v1.ResourceRequirements + + +
    +

    The resource requirements to apply to the Sidecar.

    +
    +

    TaskRunSpec +

    +

    +(Appears on:TaskRun) +

    +
    +

    TaskRunSpec defines the desired state of TaskRun

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FieldDescription
    +debug
    + + +TaskRunDebug + + +
    +(Optional) +
    +params
    + + +[]Param + + +
    +(Optional) +
    +serviceAccountName
    + +string + +
    +(Optional) +
    +taskRef
    + + +TaskRef + + +
    +(Optional) +

    no more than one of the TaskRef and TaskSpec may be specified.

    +
    +taskSpec
    + + +TaskSpec + + +
    +(Optional) +
    +status
    + + +TaskRunSpecStatus + + +
    +(Optional) +

    Used for cancelling a taskrun (and maybe more later on)

    +
    +statusMessage
    + + +TaskRunSpecStatusMessage + + +
    +(Optional) +

    Status message for cancellation.

    +
    +timeout
    + + +Kubernetes meta/v1.Duration + + +
    +(Optional) +

    Time after which the build times out. Defaults to 1 hour. +Specified build timeout should be less than 24h. +Refer Go’s ParseDuration documentation for expected format: https://golang.org/pkg/time/#ParseDuration

    +
    +podTemplate
    + + +Template + + +
    +

    PodTemplate holds pod specific configuration

    +
    +workspaces
    + + +[]WorkspaceBinding + + +
    +(Optional) +

    Workspaces is a list of WorkspaceBindings from volumes to workspaces.

    +
    +stepOverrides
    + + +[]TaskRunStepOverride + + +
    +(Optional) +

    Overrides to apply to Steps in this TaskRun. +If a field is specified in both a Step and a StepOverride, +the value from the StepOverride will be used. +This field is only supported when the alpha feature gate is enabled.

    +
    +sidecarOverrides
    + + +[]TaskRunSidecarOverride + + +
    +(Optional) +

    Overrides to apply to Sidecars in this TaskRun. +If a field is specified in both a Sidecar and a SidecarOverride, +the value from the SidecarOverride will be used. +This field is only supported when the alpha feature gate is enabled.

    +
    +computeResources
    + + +Kubernetes core/v1.ResourceRequirements + + +
    +

    Compute resources to use for this TaskRun

    +
    +

    TaskRunSpecStatus +(string alias)

    +

    +(Appears on:TaskRunSpec) +

    +
    +

    TaskRunSpecStatus defines the taskrun spec status the user can provide

    +
    +

    TaskRunSpecStatusMessage +(string alias)

    +

    +(Appears on:TaskRunSpec) +

    +
    +

    TaskRunSpecStatusMessage defines human readable status messages for the TaskRun.

    +
    + + + + + + + + + + +
    ValueDescription

    "TaskRun cancelled as the PipelineRun it belongs to has been cancelled."

    TaskRunCancelledByPipelineMsg indicates that the PipelineRun of which this +TaskRun was a part of has been cancelled.

    +
    +

    TaskRunStatus +

    +

    +(Appears on:TaskRun, TaskRunStatusFields) +

    +
    +

    TaskRunStatus defines the observed state of TaskRun

    +
    + + + + + + + + + + - - -
    FieldDescription
    +Status
    - -Kubernetes core/v1.PullPolicy + +knative.dev/pkg/apis/duck/v1.Status
    -(Optional) -

    Image pull policy. -One of Always, Never, IfNotPresent. -Defaults to Always if :latest tag is specified, or IfNotPresent otherwise. -Cannot be updated. -More info: https://kubernetes.io/docs/concepts/containers/images#updating-images

    +

    +(Members of Status are embedded into this type.) +

    -securityContext
    +TaskRunStatusFields
    - -Kubernetes core/v1.SecurityContext + +TaskRunStatusFields
    -(Optional) -

    SecurityContext defines the security options the Step should be run with. -If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext. -More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/

    -
    -

    TaskKind -(string alias)

    -(Appears on:TaskRef) +(Members of TaskRunStatusFields are embedded into this type.)

    -
    -

    TaskKind defines the type of Task used by the pipeline.

    -
    - - - - - - - - - - + +
    ValueDescription

    "Task"

    NamespacedTaskKind indicates that the task type has a namespaced scope.

    +

    TaskRunStatusFields inlines the status fields.

    -

    TaskRef +

    TaskRunStatusFields

    -(Appears on:PipelineTask) +(Appears on:TaskRunStatus)

    -

    TaskRef can be used to refer to a specific instance of a task.

    +

    TaskRunStatusFields holds the fields of TaskRun’s status. This is defined +separately and inlined so that other types can readily consume these fields +via duck typing.

    @@ -2427,132 +3502,122 @@ More info: http://kubernetes.io/docs/user-guide/identifiers#names

    +

    PodName is the name of the pod responsible for executing this task’s steps.

    - -
    -kind
    +startTime
    - -TaskKind + +Kubernetes meta/v1.Time
    -

    TaskKind indicates the kind of the task, namespaced or cluster scoped.

    +(Optional) +

    StartTime is the time the build is actually started.

    -apiVersion
    +completionTime
    -string + +Kubernetes meta/v1.Time +
    (Optional) -

    API version of the referent

    +

    CompletionTime is the time the build completed.

    -ResolverRef
    +steps
    - -ResolverRef + +[]StepState
    (Optional) -

    ResolverRef allows referencing a Task in a remote location -like a git repo. This field is only supported when the alpha -feature gate is enabled.

    +

    Steps describes the state of each build step container.

    -

    TaskResult -

    -

    -(Appears on:TaskSpec) -

    -
    -

    TaskResult used to describe the results of a task

    -
    - - - - - - - -
    FieldDescription
    -name
    +retriesStatus
    -string + +[]TaskRunStatus +
    -

    Name the given name

    +(Optional) +

    RetriesStatus contains the history of TaskRunStatus in case of a retry in order to keep record of failures. +All TaskRunStatus stored in RetriesStatus will have no date within the RetriesStatus as is redundant.

    -type
    +results
    - -ResultsType + +[]TaskRunResult
    (Optional) -

    Type is the user-specified type of the result. The possible type -is currently “string” and will support “array” in following work.

    +

    Results are the list of results written out by the task’s containers

    -properties
    +sidecars
    - -map[string]github.com/tektoncd/pipeline/pkg/apis/pipeline/v1.PropertySpec + +[]SidecarState
    -(Optional) -

    Properties is the JSON Schema properties to support key-value pairs results.

    +

    The list has one entry per sidecar in the manifest. Each entry is +represents the imageid of the corresponding sidecar.

    -description
    +taskSpec
    -string + +TaskSpec +
    -(Optional) -

    Description is a human-readable description of the result

    +

    TaskSpec contains the Spec from the dereferenced Task definition used to instantiate this TaskRun.

    -

    TaskRunResult +

    TaskRunStepOverride

    +

    +(Appears on:TaskRunSpec) +

    -

    TaskRunResult used to describe the results of a task

    +

    TaskRunStepOverride is used to override the values of a Step in the corresponding Task.

    @@ -2570,35 +3635,20 @@ string - - - - @@ -2606,7 +3656,7 @@ ParamValue

    TaskSpec

    -(Appears on:Task, EmbeddedTask) +(Appears on:Task, EmbeddedTask, TaskRunSpec, TaskRunStatusFields)

    TaskSpec defines the desired state of Task.

    @@ -2793,6 +3843,9 @@ All of them need to evaluate to True for a guarded Task to be executed.

    WorkspaceBinding

    +

    +(Appears on:TaskRunSpec) +

    WorkspaceBinding maps a Task’s declared workspace to a Volume.

    @@ -2902,6 +3955,34 @@ Kubernetes core/v1.SecretVolumeSource

    Secret represents a secret that should populate this workspace.

    + + + + + + + +
    -

    Name the given name

    -
    -type
    - - -ResultsType - - -
    -(Optional) -

    Type is the user-specified type of the result. The possible type -is currently “string” and will support “array” in following work.

    +

    The name of the Step to override.

    -value
    +resources
    - -ParamValue + +Kubernetes core/v1.ResourceRequirements
    -

    Value the given value of the result

    +

    The resource requirements to apply to the Step.

    +projected
    + + +Kubernetes core/v1.ProjectedVolumeSource + + +
    +(Optional) +

    Projected represents a projected volume that should populate this workspace.

    +
    +csi
    + + +Kubernetes core/v1.CSIVolumeSource + + +
    +(Optional) +

    CSI (Container Storage Interface) represents ephemeral storage that is handled by certain external CSI drivers.

    +

    WorkspaceDeclaration @@ -5540,7 +6621,7 @@ TaskSpec

    Param

    -(Appears on:RunSpec, PipelineRunSpec, PipelineTask, TaskRunInputs, TaskRunSpec) +(Appears on:RunSpec, PipelineRunSpec, PipelineTask, ResolverRef, TaskRunInputs, TaskRunSpec)

    Param declares an ParamValues to use for the parameter called name.

    @@ -6629,6 +7710,20 @@ PipelineSpec

    list of TaskRun and Run names, PipelineTask names, and API versions/kinds for children of this PipelineRun.

    + + +finallyStartTime
    + + +Kubernetes meta/v1.Time + + + + +(Optional) +

    FinallyStartTime is when all non-finally tasks have been completed and only finally tasks are being executed.

    + +

    PipelineRunTaskRunStatus @@ -7420,48 +8515,6 @@ ParamType

    ResolverName is the name of a resolver from which a resource can be requested.

    -

    ResolverParam -

    -

    -(Appears on:ResolverRef) -

    -
    -

    ResolverParam is a single parameter passed to a resolver.

    -
    - - - - - - - - - - - - - - - - - -
    FieldDescription
    -name
    - -string - -
    -

    Name is the name of the parameter that will be passed to the -resolver.

    -
    -value
    - -string - -
    -

    Value is the string value of the parameter that will be -passed to the resolver.

    -

    ResolverRef

    @@ -7497,16 +8550,16 @@ resolution of the referenced Tekton resource, such as “git”.

    -resource
    +params
    - -[]ResolverParam + +[]Param (Optional) -

    Resource contains the parameters used to identify the +

    Params contains the parameters used to identify the referenced Tekton resource. Example entries might include “repo” or “path” but the set of params ultimately depends on the chosen resolver.

    @@ -8168,7 +9221,10 @@ SkippingReason Description -

    "PipelineRun was gracefully cancelled"

    +

    "PipelineRun Finally timeout has been reached"

    +

    FinallyTimedOutSkip means the task was skipped because the PipelineRun has passed its Timeouts.Finally.

    + +

    "PipelineRun was gracefully cancelled"

    GracefullyCancelledSkip means the task was skipped because the pipeline run has been gracefully cancelled

    "PipelineRun was gracefully stopped"

    @@ -8183,9 +9239,15 @@ SkippingReason

    "Parent Tasks were skipped"

    ParentTasksSkip means the task was skipped because its parent was skipped

    +

    "PipelineRun timeout has been reached"

    +

    PipelineTimedOutSkip means the task was skipped because the PipelineRun has passed its overall timeout.

    +

    "PipelineRun was stopping"

    StoppingSkip means the task was skipped because the pipeline run is stopping

    +

    "PipelineRun Tasks timeout has been reached"

    +

    TasksTimedOutSkip means the task was skipped because the PipelineRun has passed its Timeouts.Tasks.

    +

    "When Expressions evaluated to false"

    WhenExpressionsSkip means the task was skipped due to at least one of its when expressions evaluating to false

    @@ -9966,6 +11028,9 @@ Kubernetes core/v1.ResourceRequirements

    TaskRunCancelledByPipelineMsg indicates that the PipelineRun of which this TaskRun was a part of has been cancelled.

    +

    "TaskRun cancelled as the PipelineRun it belongs to has timed out."

    +

    TaskRunCancelledByPipelineTimeoutMsg indicates that the TaskRun was cancelled because the PipelineRun running it timed out.

    +

    TaskRunStatus diff --git a/docs/pipelineruns.md b/docs/pipelineruns.md index 85cd6bd8979..b8587a99472 100644 --- a/docs/pipelineruns.md +++ b/docs/pipelineruns.md @@ -185,7 +185,7 @@ referencing a Pipeline in git: spec: pipelineRef: resolver: git - resource: + params: - name: url value: https://github.com/tektoncd/catalog.git - name: revision diff --git a/docs/taskruns.md b/docs/taskruns.md index c5845708d49..b1807213e74 100644 --- a/docs/taskruns.md +++ b/docs/taskruns.md @@ -176,7 +176,7 @@ referencing a Task in git: spec: taskRef: resolver: git - resource: + params: - name: url value: https://github.com/tektoncd/catalog.git - name: revision diff --git a/hack/ignored-openapi-violations.list b/hack/ignored-openapi-violations.list index af28bcd6cf4..a7dc6800867 100644 --- a/hack/ignored-openapi-violations.list +++ b/hack/ignored-openapi-violations.list @@ -28,4 +28,5 @@ API rule violation: names_match,github.com/tektoncd/pipeline/pkg/apis/pipeline/v API rule violation: names_match,github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1,StepTemplate,DeprecatedStdinOnce API rule violation: names_match,github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1,StepTemplate,DeprecatedTTY API rule violation: names_match,github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1,StepTemplate,DeprecatedTerminationMessagePath -API rule violation: names_match,github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1,StepTemplate,DeprecatedTerminationMessagePolicy \ No newline at end of file +API rule violation: names_match,github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1,StepTemplate,DeprecatedTerminationMessagePolicy +API rule violation: names_match,github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1,ResolutionRequestSpec,Parameters diff --git a/hack/spec-gen/main.go b/hack/spec-gen/main.go index 9b17694a863..eee3f6506e7 100644 --- a/hack/spec-gen/main.go +++ b/hack/spec-gen/main.go @@ -24,7 +24,6 @@ import ( tektonv1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" tektonv1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - "k8s.io/klog" "k8s.io/kube-openapi/pkg/common" spec "k8s.io/kube-openapi/pkg/validation/spec" @@ -80,6 +79,7 @@ func swaggify(name string) string { name = strings.ReplaceAll(name, "./pkg/apis/pipeline/", "") name = strings.ReplaceAll(name, "./pkg/apis/resource/", "") name = strings.ReplaceAll(name, "github.com/tektoncd/pipeline/pkg/apis/pipeline/", "") + name = strings.ReplaceAll(name, "github.com/tektoncd/pipeline/pkg/apis/resolution/", "") name = strings.ReplaceAll(name, "github.com/tektoncd/pipeline/pkg/apis/resource/", "") name = strings.ReplaceAll(name, "k8s.io/api/core/", "") name = strings.ReplaceAll(name, "k8s.io/apimachinery/pkg/apis/meta/", "") diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 66a15f5a7b5..01cbe890dd8 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -45,6 +45,11 @@ bash ${REPO_ROOT_DIR}/hack/generate-groups.sh "deepcopy,client,informer,lister" github.com/tektoncd/pipeline/pkg/client github.com/tektoncd/pipeline/pkg/apis \ "pipeline:v1alpha1,v1beta1,v1" \ --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt +# This generates deepcopy,client,informer and lister for the resolution package (v1alpha1) +bash ${REPO_ROOT_DIR}/hack/generate-groups.sh "deepcopy,client,informer,lister" \ + github.com/tektoncd/pipeline/pkg/client/resolution github.com/tektoncd/pipeline/pkg/apis \ + "resolution:v1alpha1" \ + --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt # Depends on generate-groups.sh to install bin/deepcopy-gen ${PREFIX}/deepcopy-gen \ @@ -80,6 +85,12 @@ bash ${REPO_ROOT_DIR}/hack/generate-knative.sh "injection" \ "pipeline:v1alpha1,v1beta1,v1" \ --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt GOFLAGS="${OLDGOFLAGS}" +# This generates the knative inject packages for the resolution package (v1alpha1). +bash ${REPO_ROOT_DIR}/hack/generate-knative.sh "injection" \ + github.com/tektoncd/pipeline/pkg/client/resolution github.com/tektoncd/pipeline/pkg/apis \ + "resolution:v1alpha1" \ + --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt +GOFLAGS="${OLDGOFLAGS}" # Make sure our dependencies are up-to-date ${REPO_ROOT_DIR}/hack/update-deps.sh diff --git a/hack/update-openapigen.sh b/hack/update-openapigen.sh index e04da41e5d0..5b9fce309b2 100755 --- a/hack/update-openapigen.sh +++ b/hack/update-openapigen.sh @@ -39,7 +39,7 @@ do input_dirs=./pkg/apis/pipeline/${APIVERSION},./pkg/apis/pipeline/pod,knative.dev/pkg/apis,knative.dev/pkg/apis/duck/v1beta1 if [ ${APIVERSION} = "v1beta1" ] then - input_dirs=${input_dirs},./pkg/apis/resource/v1alpha1 + input_dirs=${input_dirs},./pkg/apis/resource/v1alpha1,./pkg/apis/resolution/v1alpha1 fi echo "Generating OpenAPI specification for ${APIVERSION} ..." diff --git a/pkg/apis/pipeline/v1/openapi_generated.go b/pkg/apis/pipeline/v1/openapi_generated.go index f0389784009..aeae1ee193f 100644 --- a/pkg/apis/pipeline/v1/openapi_generated.go +++ b/pkg/apis/pipeline/v1/openapi_generated.go @@ -45,7 +45,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1.PipelineTaskParam": schema_pkg_apis_pipeline_v1_PipelineTaskParam(ref), "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1.PipelineWorkspaceDeclaration": schema_pkg_apis_pipeline_v1_PipelineWorkspaceDeclaration(ref), "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1.PropertySpec": schema_pkg_apis_pipeline_v1_PropertySpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1.ResolverParam": schema_pkg_apis_pipeline_v1_ResolverParam(ref), "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1.ResolverRef": schema_pkg_apis_pipeline_v1_ResolverRef(ref), "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1.ResultRef": schema_pkg_apis_pipeline_v1_ResultRef(ref), "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1.Sidecar": schema_pkg_apis_pipeline_v1_Sidecar(ref), @@ -1177,36 +1176,6 @@ func schema_pkg_apis_pipeline_v1_PropertySpec(ref common.ReferenceCallback) comm } } -func schema_pkg_apis_pipeline_v1_ResolverParam(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "ResolverParam is a single parameter passed to a resolver.", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "name": { - SchemaProps: spec.SchemaProps{ - Description: "Name is the name of the parameter that will be passed to the resolver.", - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - "value": { - SchemaProps: spec.SchemaProps{ - Description: "Value is the string value of the parameter that will be passed to the resolver.", - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - }, - Required: []string{"name", "value"}, - }, - }, - } -} - func schema_pkg_apis_pipeline_v1_ResolverRef(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -1221,20 +1190,20 @@ func schema_pkg_apis_pipeline_v1_ResolverRef(ref common.ReferenceCallback) commo Format: "", }, }, - "resource": { + "params": { VendorExtensible: spec.VendorExtensible{ Extensions: spec.Extensions{ "x-kubernetes-list-type": "atomic", }, }, SchemaProps: spec.SchemaProps{ - Description: "Resource contains the parameters used to identify the referenced Tekton resource. Example entries might include \"repo\" or \"path\" but the set of params ultimately depends on the chosen resolver.", + Description: "Params contains the parameters used to identify the referenced Tekton resource. Example entries might include \"repo\" or \"path\" but the set of params ultimately depends on the chosen resolver.", Type: []string{"array"}, Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("github.com/tektoncd/pipeline/pkg/apis/pipeline/v1.ResolverParam"), + Ref: ref("github.com/tektoncd/pipeline/pkg/apis/pipeline/v1.Param"), }, }, }, @@ -1244,7 +1213,7 @@ func schema_pkg_apis_pipeline_v1_ResolverRef(ref common.ReferenceCallback) commo }, }, Dependencies: []string{ - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1.ResolverParam"}, + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1.Param"}, } } diff --git a/pkg/apis/pipeline/v1/pipeline_types.go b/pkg/apis/pipeline/v1/pipeline_types.go index 716d38549e3..cf5e43ab89e 100644 --- a/pkg/apis/pipeline/v1/pipeline_types.go +++ b/pkg/apis/pipeline/v1/pipeline_types.go @@ -256,8 +256,8 @@ func (pt PipelineTask) validateTask(ctx context.Context) (errs *apis.FieldError) if pt.TaskRef.Resolver != "" { errs = errs.Also(apis.ErrDisallowedFields("taskref.resolver")) } - if len(pt.TaskRef.Resource) > 0 { - errs = errs.Also(apis.ErrDisallowedFields("taskref.resource")) + if len(pt.TaskRef.Params) > 0 { + errs = errs.Also(apis.ErrDisallowedFields("taskref.params")) } } } diff --git a/pkg/apis/pipeline/v1/pipeline_types_test.go b/pkg/apis/pipeline/v1/pipeline_types_test.go index 4f2ba7e3e3f..0db875d4796 100644 --- a/pkg/apis/pipeline/v1/pipeline_types_test.go +++ b/pkg/apis/pipeline/v1/pipeline_types_test.go @@ -208,9 +208,9 @@ func TestPipelineTask_ValidateRegularTask_Success(t *testing.T) { }, enableAPIFields: true, }, { - name: "pipeline task - use of resource with the feature flag set", + name: "pipeline task - use of resolver params with the feature flag set", tasks: PipelineTask{ - TaskRef: &TaskRef{Name: "boo", ResolverRef: ResolverRef{Resource: []ResolverParam{{}}}}, + TaskRef: &TaskRef{Name: "boo", ResolverRef: ResolverRef{Params: []Param{{}}}}, }, enableAPIFields: true, }} @@ -275,11 +275,11 @@ func TestPipelineTask_ValidateRegularTask_Failure(t *testing.T) { }, expectedError: *apis.ErrDisallowedFields("taskref.resolver"), }, { - name: "pipeline task - use of resource without the feature flag set", + name: "pipeline task - use of resolver params without the feature flag set", task: PipelineTask{ - TaskRef: &TaskRef{Name: "boo", ResolverRef: ResolverRef{Resource: []ResolverParam{{}}}}, + TaskRef: &TaskRef{Name: "boo", ResolverRef: ResolverRef{Params: []Param{{}}}}, }, - expectedError: *apis.ErrDisallowedFields("taskref.resource"), + expectedError: *apis.ErrDisallowedFields("taskref.params"), }} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/apis/pipeline/v1/resolver_types.go b/pkg/apis/pipeline/v1/resolver_types.go index bb547b2a0f0..140a3ffb7a0 100644 --- a/pkg/apis/pipeline/v1/resolver_types.go +++ b/pkg/apis/pipeline/v1/resolver_types.go @@ -28,21 +28,11 @@ type ResolverRef struct { // resolution of the referenced Tekton resource, such as "git". // +optional Resolver ResolverName `json:"resolver,omitempty"` - // Resource contains the parameters used to identify the + // Params contains the parameters used to identify the // referenced Tekton resource. Example entries might include // "repo" or "path" but the set of params ultimately depends on // the chosen resolver. // +optional // +listType=atomic - Resource []ResolverParam `json:"resource,omitempty"` -} - -// ResolverParam is a single parameter passed to a resolver. -type ResolverParam struct { - // Name is the name of the parameter that will be passed to the - // resolver. - Name string `json:"name"` - // Value is the string value of the parameter that will be - // passed to the resolver. - Value string `json:"value"` + Params []Param `json:"params,omitempty"` } diff --git a/pkg/apis/pipeline/v1/swagger.json b/pkg/apis/pipeline/v1/swagger.json index e09dc8eb7b2..862912773ec 100644 --- a/pkg/apis/pipeline/v1/swagger.json +++ b/pkg/apis/pipeline/v1/swagger.json @@ -586,42 +586,22 @@ } } }, - "v1.ResolverParam": { - "description": "ResolverParam is a single parameter passed to a resolver.", - "type": "object", - "required": [ - "name", - "value" - ], - "properties": { - "name": { - "description": "Name is the name of the parameter that will be passed to the resolver.", - "type": "string", - "default": "" - }, - "value": { - "description": "Value is the string value of the parameter that will be passed to the resolver.", - "type": "string", - "default": "" - } - } - }, "v1.ResolverRef": { "description": "ResolverRef can be used to refer to a Pipeline or Task in a remote location like a git repo. This feature is in alpha and these fields are only available when the alpha feature gate is enabled.", "type": "object", "properties": { - "resolver": { - "description": "Resolver is the name of the resolver that should perform resolution of the referenced Tekton resource, such as \"git\".", - "type": "string" - }, - "resource": { - "description": "Resource contains the parameters used to identify the referenced Tekton resource. Example entries might include \"repo\" or \"path\" but the set of params ultimately depends on the chosen resolver.", + "params": { + "description": "Params contains the parameters used to identify the referenced Tekton resource. Example entries might include \"repo\" or \"path\" but the set of params ultimately depends on the chosen resolver.", "type": "array", "items": { "default": {}, - "$ref": "#/definitions/v1.ResolverParam" + "$ref": "#/definitions/v1.Param" }, "x-kubernetes-list-type": "atomic" + }, + "resolver": { + "description": "Resolver is the name of the resolver that should perform resolution of the referenced Tekton resource, such as \"git\".", + "type": "string" } } }, diff --git a/pkg/apis/pipeline/v1/taskref_validation.go b/pkg/apis/pipeline/v1/taskref_validation.go index 245d1f5eb07..b824ef3c009 100644 --- a/pkg/apis/pipeline/v1/taskref_validation.go +++ b/pkg/apis/pipeline/v1/taskref_validation.go @@ -31,21 +31,25 @@ func (ref *TaskRef) Validate(ctx context.Context) (errs *apis.FieldError) { return } - switch { - case ref.Resolver != "": - errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "resolver", config.AlphaAPIFields).ViaField("resolver")) - if ref.Name != "" { - errs = errs.Also(apis.ErrMultipleOneOf("name", "resolver")) + if ref.Resolver != "" || ref.Params != nil { + if ref.Resolver != "" { + errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "resolver", config.AlphaAPIFields).ViaField("resolver")) + if ref.Name != "" { + errs = errs.Also(apis.ErrMultipleOneOf("name", "resolver")) + } } - case ref.Resource != nil: - errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "resource", config.AlphaAPIFields).ViaField("resource")) - if ref.Name != "" { - errs = errs.Also(apis.ErrMultipleOneOf("name", "resource")) + if ref.Params != nil { + errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "params", config.AlphaAPIFields).ViaField("params")) + if ref.Name != "" { + errs = errs.Also(apis.ErrMultipleOneOf("name", "params")) + } + if ref.Resolver == "" { + errs = errs.Also(apis.ErrMissingField("resolver")) + } + // TODO(abayer): Uncomment this when taskrun_validation.go is added with the ValidateParameters function. + // errs = errs.Also(ValidateParameters(ctx, ref.Params)) } - if ref.Resolver == "" { - errs = errs.Also(apis.ErrMissingField("resolver")) - } - case ref.Name == "": + } else if ref.Name == "" { errs = errs.Also(apis.ErrMissingField("name")) } return diff --git a/pkg/apis/pipeline/v1/taskref_validation_test.go b/pkg/apis/pipeline/v1/taskref_validation_test.go index d5e153da743..96fce59d979 100644 --- a/pkg/apis/pipeline/v1/taskref_validation_test.go +++ b/pkg/apis/pipeline/v1/taskref_validation_test.go @@ -43,12 +43,12 @@ func TestTaskRef_Valid(t *testing.T) { wc: config.EnableAlphaAPIFields, }, { name: "alpha feature: valid resolver with resource parameters", - taskRef: &v1.TaskRef{ResolverRef: v1.ResolverRef{Resolver: "git", Resource: []v1.ResolverParam{{ + taskRef: &v1.TaskRef{ResolverRef: v1.ResolverRef{Resolver: "git", Params: []v1.Param{{ Name: "repo", - Value: "https://github.com/tektoncd/pipeline.git", + Value: *v1.NewStructuredValues("https://github.com/tektoncd/pipeline.git"), }, { Name: "branch", - Value: "baz", + Value: *v1.NewStructuredValues("baz"), }}}}, wc: config.EnableAlphaAPIFields, }} @@ -87,15 +87,15 @@ func TestTaskRef_Invalid(t *testing.T) { name: "taskref resource disallowed without alpha feature gate", taskRef: &v1.TaskRef{ ResolverRef: v1.ResolverRef{ - Resource: []v1.ResolverParam{}, + Params: []v1.Param{}, }, }, - wantErr: apis.ErrMissingField("resolver").Also(apis.ErrGeneric("resource requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")), + wantErr: apis.ErrMissingField("resolver").Also(apis.ErrGeneric("params requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")), }, { - name: "taskref resource disallowed without resolver", + name: "taskref resolver params disallowed without resolver", taskRef: &v1.TaskRef{ ResolverRef: v1.ResolverRef{ - Resource: []v1.ResolverParam{}, + Params: []v1.Param{}, }, }, wantErr: apis.ErrMissingField("resolver"), @@ -111,17 +111,17 @@ func TestTaskRef_Invalid(t *testing.T) { wantErr: apis.ErrMultipleOneOf("name", "resolver"), wc: config.EnableAlphaAPIFields, }, { - name: "taskref resource disallowed in conjunction with taskref name", + name: "taskref resolver params disallowed in conjunction with taskref name", taskRef: &v1.TaskRef{ Name: "bar", ResolverRef: v1.ResolverRef{ - Resource: []v1.ResolverParam{{ + Params: []v1.Param{{ Name: "foo", - Value: "bar", + Value: *v1.NewStructuredValues("bar"), }}, }, }, - wantErr: apis.ErrMultipleOneOf("name", "resource").Also(apis.ErrMissingField("resolver")), + wantErr: apis.ErrMultipleOneOf("name", "params").Also(apis.ErrMissingField("resolver")), wc: config.EnableAlphaAPIFields, }} for _, ts := range tests { diff --git a/pkg/apis/pipeline/v1/zz_generated.deepcopy.go b/pkg/apis/pipeline/v1/zz_generated.deepcopy.go index e7df0254eb8..73368c5f29c 100644 --- a/pkg/apis/pipeline/v1/zz_generated.deepcopy.go +++ b/pkg/apis/pipeline/v1/zz_generated.deepcopy.go @@ -409,29 +409,15 @@ func (in *PropertySpec) DeepCopy() *PropertySpec { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ResolverParam) DeepCopyInto(out *ResolverParam) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResolverParam. -func (in *ResolverParam) DeepCopy() *ResolverParam { - if in == nil { - return nil - } - out := new(ResolverParam) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResolverRef) DeepCopyInto(out *ResolverRef) { *out = *in - if in.Resource != nil { - in, out := &in.Resource, &out.Resource - *out = make([]ResolverParam, len(*in)) - copy(*out, *in) + if in.Params != nil { + in, out := &in.Params, &out.Params + *out = make([]Param, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } return } diff --git a/pkg/apis/pipeline/v1beta1/openapi_generated.go b/pkg/apis/pipeline/v1beta1/openapi_generated.go index 153df2450c3..0d9b519adb4 100644 --- a/pkg/apis/pipeline/v1beta1/openapi_generated.go +++ b/pkg/apis/pipeline/v1beta1/openapi_generated.go @@ -30,88 +30,92 @@ import ( func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { return map[string]common.OpenAPIDefinition{ - "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod.AffinityAssistantTemplate": schema_pkg_apis_pipeline_pod_AffinityAssistantTemplate(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod.Template": schema_pkg_apis_pipeline_pod_Template(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ChildStatusReference": schema_pkg_apis_pipeline_v1beta1_ChildStatusReference(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.CloudEventDelivery": schema_pkg_apis_pipeline_v1beta1_CloudEventDelivery(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.CloudEventDeliveryState": schema_pkg_apis_pipeline_v1beta1_CloudEventDeliveryState(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ClusterTask": schema_pkg_apis_pipeline_v1beta1_ClusterTask(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ClusterTaskList": schema_pkg_apis_pipeline_v1beta1_ClusterTaskList(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.EmbeddedTask": schema_pkg_apis_pipeline_v1beta1_EmbeddedTask(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.InternalTaskModifier": schema_pkg_apis_pipeline_v1beta1_InternalTaskModifier(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Param": schema_pkg_apis_pipeline_v1beta1_Param(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ParamSpec": schema_pkg_apis_pipeline_v1beta1_ParamSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ParamValue": schema_pkg_apis_pipeline_v1beta1_ParamValue(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Pipeline": schema_pkg_apis_pipeline_v1beta1_Pipeline(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineDeclaredResource": schema_pkg_apis_pipeline_v1beta1_PipelineDeclaredResource(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineList": schema_pkg_apis_pipeline_v1beta1_PipelineList(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRef": schema_pkg_apis_pipeline_v1beta1_PipelineRef(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResourceBinding": schema_pkg_apis_pipeline_v1beta1_PipelineResourceBinding(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResourceRef": schema_pkg_apis_pipeline_v1beta1_PipelineResourceRef(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResourceResult": schema_pkg_apis_pipeline_v1beta1_PipelineResourceResult(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResult": schema_pkg_apis_pipeline_v1beta1_PipelineResult(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRun": schema_pkg_apis_pipeline_v1beta1_PipelineRun(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunList": schema_pkg_apis_pipeline_v1beta1_PipelineRunList(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunResult": schema_pkg_apis_pipeline_v1beta1_PipelineRunResult(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunRunStatus": schema_pkg_apis_pipeline_v1beta1_PipelineRunRunStatus(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunSpec": schema_pkg_apis_pipeline_v1beta1_PipelineRunSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunStatus": schema_pkg_apis_pipeline_v1beta1_PipelineRunStatus(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunStatusFields": schema_pkg_apis_pipeline_v1beta1_PipelineRunStatusFields(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunTaskRunStatus": schema_pkg_apis_pipeline_v1beta1_PipelineRunTaskRunStatus(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineSpec": schema_pkg_apis_pipeline_v1beta1_PipelineSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTask": schema_pkg_apis_pipeline_v1beta1_PipelineTask(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskInputResource": schema_pkg_apis_pipeline_v1beta1_PipelineTaskInputResource(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskMetadata": schema_pkg_apis_pipeline_v1beta1_PipelineTaskMetadata(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskOutputResource": schema_pkg_apis_pipeline_v1beta1_PipelineTaskOutputResource(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskParam": schema_pkg_apis_pipeline_v1beta1_PipelineTaskParam(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskResources": schema_pkg_apis_pipeline_v1beta1_PipelineTaskResources(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskRun": schema_pkg_apis_pipeline_v1beta1_PipelineTaskRun(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskRunSpec": schema_pkg_apis_pipeline_v1beta1_PipelineTaskRunSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineWorkspaceDeclaration": schema_pkg_apis_pipeline_v1beta1_PipelineWorkspaceDeclaration(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PropertySpec": schema_pkg_apis_pipeline_v1beta1_PropertySpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ResolverParam": schema_pkg_apis_pipeline_v1beta1_ResolverParam(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ResolverRef": schema_pkg_apis_pipeline_v1beta1_ResolverRef(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ResultRef": schema_pkg_apis_pipeline_v1beta1_ResultRef(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Sidecar": schema_pkg_apis_pipeline_v1beta1_Sidecar(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.SidecarState": schema_pkg_apis_pipeline_v1beta1_SidecarState(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.SkippedTask": schema_pkg_apis_pipeline_v1beta1_SkippedTask(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Step": schema_pkg_apis_pipeline_v1beta1_Step(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepOutputConfig": schema_pkg_apis_pipeline_v1beta1_StepOutputConfig(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepState": schema_pkg_apis_pipeline_v1beta1_StepState(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepTemplate": schema_pkg_apis_pipeline_v1beta1_StepTemplate(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Task": schema_pkg_apis_pipeline_v1beta1_Task(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskList": schema_pkg_apis_pipeline_v1beta1_TaskList(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRef": schema_pkg_apis_pipeline_v1beta1_TaskRef(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResource": schema_pkg_apis_pipeline_v1beta1_TaskResource(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResourceBinding": schema_pkg_apis_pipeline_v1beta1_TaskResourceBinding(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResources": schema_pkg_apis_pipeline_v1beta1_TaskResources(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResult": schema_pkg_apis_pipeline_v1beta1_TaskResult(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRun": schema_pkg_apis_pipeline_v1beta1_TaskRun(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunDebug": schema_pkg_apis_pipeline_v1beta1_TaskRunDebug(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunInputs": schema_pkg_apis_pipeline_v1beta1_TaskRunInputs(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunList": schema_pkg_apis_pipeline_v1beta1_TaskRunList(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunOutputs": schema_pkg_apis_pipeline_v1beta1_TaskRunOutputs(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunResources": schema_pkg_apis_pipeline_v1beta1_TaskRunResources(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunResult": schema_pkg_apis_pipeline_v1beta1_TaskRunResult(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunSidecarOverride": schema_pkg_apis_pipeline_v1beta1_TaskRunSidecarOverride(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunSpec": schema_pkg_apis_pipeline_v1beta1_TaskRunSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunStatus": schema_pkg_apis_pipeline_v1beta1_TaskRunStatus(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunStatusFields": schema_pkg_apis_pipeline_v1beta1_TaskRunStatusFields(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunStepOverride": schema_pkg_apis_pipeline_v1beta1_TaskRunStepOverride(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskSpec": schema_pkg_apis_pipeline_v1beta1_TaskSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TimeoutFields": schema_pkg_apis_pipeline_v1beta1_TimeoutFields(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WhenExpression": schema_pkg_apis_pipeline_v1beta1_WhenExpression(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceBinding": schema_pkg_apis_pipeline_v1beta1_WorkspaceBinding(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceDeclaration": schema_pkg_apis_pipeline_v1beta1_WorkspaceDeclaration(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspacePipelineTaskBinding": schema_pkg_apis_pipeline_v1beta1_WorkspacePipelineTaskBinding(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceUsage": schema_pkg_apis_pipeline_v1beta1_WorkspaceUsage(ref), - "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResource": schema_pkg_apis_resource_v1alpha1_PipelineResource(ref), - "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResourceList": schema_pkg_apis_resource_v1alpha1_PipelineResourceList(ref), - "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResourceSpec": schema_pkg_apis_resource_v1alpha1_PipelineResourceSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResourceStatus": schema_pkg_apis_resource_v1alpha1_PipelineResourceStatus(ref), - "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.ResourceDeclaration": schema_pkg_apis_resource_v1alpha1_ResourceDeclaration(ref), - "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.ResourceParam": schema_pkg_apis_resource_v1alpha1_ResourceParam(ref), - "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.SecretParam": schema_pkg_apis_resource_v1alpha1_SecretParam(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod.AffinityAssistantTemplate": schema_pkg_apis_pipeline_pod_AffinityAssistantTemplate(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod.Template": schema_pkg_apis_pipeline_pod_Template(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ChildStatusReference": schema_pkg_apis_pipeline_v1beta1_ChildStatusReference(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.CloudEventDelivery": schema_pkg_apis_pipeline_v1beta1_CloudEventDelivery(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.CloudEventDeliveryState": schema_pkg_apis_pipeline_v1beta1_CloudEventDeliveryState(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ClusterTask": schema_pkg_apis_pipeline_v1beta1_ClusterTask(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ClusterTaskList": schema_pkg_apis_pipeline_v1beta1_ClusterTaskList(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.EmbeddedTask": schema_pkg_apis_pipeline_v1beta1_EmbeddedTask(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.InternalTaskModifier": schema_pkg_apis_pipeline_v1beta1_InternalTaskModifier(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Param": schema_pkg_apis_pipeline_v1beta1_Param(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ParamSpec": schema_pkg_apis_pipeline_v1beta1_ParamSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ParamValue": schema_pkg_apis_pipeline_v1beta1_ParamValue(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Pipeline": schema_pkg_apis_pipeline_v1beta1_Pipeline(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineDeclaredResource": schema_pkg_apis_pipeline_v1beta1_PipelineDeclaredResource(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineList": schema_pkg_apis_pipeline_v1beta1_PipelineList(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRef": schema_pkg_apis_pipeline_v1beta1_PipelineRef(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResourceBinding": schema_pkg_apis_pipeline_v1beta1_PipelineResourceBinding(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResourceRef": schema_pkg_apis_pipeline_v1beta1_PipelineResourceRef(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResourceResult": schema_pkg_apis_pipeline_v1beta1_PipelineResourceResult(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResult": schema_pkg_apis_pipeline_v1beta1_PipelineResult(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRun": schema_pkg_apis_pipeline_v1beta1_PipelineRun(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunList": schema_pkg_apis_pipeline_v1beta1_PipelineRunList(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunResult": schema_pkg_apis_pipeline_v1beta1_PipelineRunResult(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunRunStatus": schema_pkg_apis_pipeline_v1beta1_PipelineRunRunStatus(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunSpec": schema_pkg_apis_pipeline_v1beta1_PipelineRunSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunStatus": schema_pkg_apis_pipeline_v1beta1_PipelineRunStatus(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunStatusFields": schema_pkg_apis_pipeline_v1beta1_PipelineRunStatusFields(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunTaskRunStatus": schema_pkg_apis_pipeline_v1beta1_PipelineRunTaskRunStatus(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineSpec": schema_pkg_apis_pipeline_v1beta1_PipelineSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTask": schema_pkg_apis_pipeline_v1beta1_PipelineTask(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskInputResource": schema_pkg_apis_pipeline_v1beta1_PipelineTaskInputResource(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskMetadata": schema_pkg_apis_pipeline_v1beta1_PipelineTaskMetadata(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskOutputResource": schema_pkg_apis_pipeline_v1beta1_PipelineTaskOutputResource(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskParam": schema_pkg_apis_pipeline_v1beta1_PipelineTaskParam(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskResources": schema_pkg_apis_pipeline_v1beta1_PipelineTaskResources(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskRun": schema_pkg_apis_pipeline_v1beta1_PipelineTaskRun(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskRunSpec": schema_pkg_apis_pipeline_v1beta1_PipelineTaskRunSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineWorkspaceDeclaration": schema_pkg_apis_pipeline_v1beta1_PipelineWorkspaceDeclaration(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PropertySpec": schema_pkg_apis_pipeline_v1beta1_PropertySpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ResolverRef": schema_pkg_apis_pipeline_v1beta1_ResolverRef(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ResultRef": schema_pkg_apis_pipeline_v1beta1_ResultRef(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Sidecar": schema_pkg_apis_pipeline_v1beta1_Sidecar(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.SidecarState": schema_pkg_apis_pipeline_v1beta1_SidecarState(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.SkippedTask": schema_pkg_apis_pipeline_v1beta1_SkippedTask(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Step": schema_pkg_apis_pipeline_v1beta1_Step(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepOutputConfig": schema_pkg_apis_pipeline_v1beta1_StepOutputConfig(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepState": schema_pkg_apis_pipeline_v1beta1_StepState(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepTemplate": schema_pkg_apis_pipeline_v1beta1_StepTemplate(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Task": schema_pkg_apis_pipeline_v1beta1_Task(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskList": schema_pkg_apis_pipeline_v1beta1_TaskList(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRef": schema_pkg_apis_pipeline_v1beta1_TaskRef(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResource": schema_pkg_apis_pipeline_v1beta1_TaskResource(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResourceBinding": schema_pkg_apis_pipeline_v1beta1_TaskResourceBinding(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResources": schema_pkg_apis_pipeline_v1beta1_TaskResources(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResult": schema_pkg_apis_pipeline_v1beta1_TaskResult(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRun": schema_pkg_apis_pipeline_v1beta1_TaskRun(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunDebug": schema_pkg_apis_pipeline_v1beta1_TaskRunDebug(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunInputs": schema_pkg_apis_pipeline_v1beta1_TaskRunInputs(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunList": schema_pkg_apis_pipeline_v1beta1_TaskRunList(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunOutputs": schema_pkg_apis_pipeline_v1beta1_TaskRunOutputs(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunResources": schema_pkg_apis_pipeline_v1beta1_TaskRunResources(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunResult": schema_pkg_apis_pipeline_v1beta1_TaskRunResult(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunSidecarOverride": schema_pkg_apis_pipeline_v1beta1_TaskRunSidecarOverride(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunSpec": schema_pkg_apis_pipeline_v1beta1_TaskRunSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunStatus": schema_pkg_apis_pipeline_v1beta1_TaskRunStatus(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunStatusFields": schema_pkg_apis_pipeline_v1beta1_TaskRunStatusFields(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunStepOverride": schema_pkg_apis_pipeline_v1beta1_TaskRunStepOverride(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskSpec": schema_pkg_apis_pipeline_v1beta1_TaskSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TimeoutFields": schema_pkg_apis_pipeline_v1beta1_TimeoutFields(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WhenExpression": schema_pkg_apis_pipeline_v1beta1_WhenExpression(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceBinding": schema_pkg_apis_pipeline_v1beta1_WorkspaceBinding(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceDeclaration": schema_pkg_apis_pipeline_v1beta1_WorkspaceDeclaration(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspacePipelineTaskBinding": schema_pkg_apis_pipeline_v1beta1_WorkspacePipelineTaskBinding(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceUsage": schema_pkg_apis_pipeline_v1beta1_WorkspaceUsage(ref), + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ResolutionRequest": schema_pkg_apis_resolution_v1alpha1_ResolutionRequest(ref), + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ResolutionRequestList": schema_pkg_apis_resolution_v1alpha1_ResolutionRequestList(ref), + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ResolutionRequestSpec": schema_pkg_apis_resolution_v1alpha1_ResolutionRequestSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ResolutionRequestStatus": schema_pkg_apis_resolution_v1alpha1_ResolutionRequestStatus(ref), + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ResolutionRequestStatusFields": schema_pkg_apis_resolution_v1alpha1_ResolutionRequestStatusFields(ref), + "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResource": schema_pkg_apis_resource_v1alpha1_PipelineResource(ref), + "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResourceList": schema_pkg_apis_resource_v1alpha1_PipelineResourceList(ref), + "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResourceSpec": schema_pkg_apis_resource_v1alpha1_PipelineResourceSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResourceStatus": schema_pkg_apis_resource_v1alpha1_PipelineResourceStatus(ref), + "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.ResourceDeclaration": schema_pkg_apis_resource_v1alpha1_ResourceDeclaration(ref), + "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.ResourceParam": schema_pkg_apis_resource_v1alpha1_ResourceParam(ref), + "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.SecretParam": schema_pkg_apis_resource_v1alpha1_SecretParam(ref), } } @@ -2586,36 +2590,6 @@ func schema_pkg_apis_pipeline_v1beta1_PropertySpec(ref common.ReferenceCallback) } } -func schema_pkg_apis_pipeline_v1beta1_ResolverParam(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "ResolverParam is a single parameter passed to a resolver.", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "name": { - SchemaProps: spec.SchemaProps{ - Description: "Name is the name of the parameter that will be passed to the resolver.", - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - "value": { - SchemaProps: spec.SchemaProps{ - Description: "Value is the string value of the parameter that will be passed to the resolver.", - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - }, - Required: []string{"name", "value"}, - }, - }, - } -} - func schema_pkg_apis_pipeline_v1beta1_ResolverRef(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -2630,20 +2604,20 @@ func schema_pkg_apis_pipeline_v1beta1_ResolverRef(ref common.ReferenceCallback) Format: "", }, }, - "resource": { + "params": { VendorExtensible: spec.VendorExtensible{ Extensions: spec.Extensions{ "x-kubernetes-list-type": "atomic", }, }, SchemaProps: spec.SchemaProps{ - Description: "Resource contains the parameters used to identify the referenced Tekton resource. Example entries might include \"repo\" or \"path\" but the set of params ultimately depends on the chosen resolver.", + Description: "Params contains the parameters used to identify the referenced Tekton resource. Example entries might include \"repo\" or \"path\" but the set of params ultimately depends on the chosen resolver.", Type: []string{"array"}, Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ResolverParam"), + Ref: ref("github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Param"), }, }, }, @@ -2653,7 +2627,7 @@ func schema_pkg_apis_pipeline_v1beta1_ResolverRef(ref common.ReferenceCallback) }, }, Dependencies: []string{ - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ResolverParam"}, + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Param"}, } } @@ -5374,6 +5348,222 @@ func schema_pkg_apis_pipeline_v1beta1_WorkspaceUsage(ref common.ReferenceCallbac } } +func schema_pkg_apis_resolution_v1alpha1_ResolutionRequest(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ResolutionRequest is an object for requesting the content of a Tekton resource like a pipeline.yaml.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + 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{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + 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{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Description: "Spec holds the information for the request part of the resource request.", + Default: map[string]interface{}{}, + Ref: ref("github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ResolutionRequestSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "Status communicates the state of the request and, ultimately, the content of the resolved resource.", + Default: map[string]interface{}{}, + Ref: ref("github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ResolutionRequestStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ResolutionRequestSpec", "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ResolutionRequestStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_pkg_apis_resolution_v1alpha1_ResolutionRequestList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ResolutionRequestList is a list of ResolutionRequests.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + 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{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + 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{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ResolutionRequest"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ResolutionRequest", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_pkg_apis_resolution_v1alpha1_ResolutionRequestSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ResolutionRequestSpec are all the fields in the spec of the ResolutionRequest CRD.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "params": { + SchemaProps: spec.SchemaProps{ + Description: "Parameters are the runtime attributes passed to the resolver to help it figure out how to resolve the resource being requested. For example: repo URL, commit SHA, path to file, the kind of authentication to leverage, etc.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_resolution_v1alpha1_ResolutionRequestStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ResolutionRequestStatus are all the fields in a ResolutionRequest's status subresource.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "observedGeneration": { + SchemaProps: spec.SchemaProps{ + Description: "ObservedGeneration is the 'Generation' of the Service that was last processed by the controller.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "conditions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Conditions the latest available observations of a resource's current state.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("knative.dev/pkg/apis.Condition"), + }, + }, + }, + }, + }, + "annotations": { + SchemaProps: spec.SchemaProps{ + Description: "Annotations is additional Status fields for the Resource to save some additional State as well as convey more information to the user. This is roughly akin to Annotations on any k8s resource, just the reconciler conveying richer information outwards.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "data": { + SchemaProps: spec.SchemaProps{ + Description: "Data is a string representation of the resolved content of the requested resource in-lined into the ResolutionRequest object.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"data"}, + }, + }, + Dependencies: []string{ + "knative.dev/pkg/apis.Condition"}, + } +} + +func schema_pkg_apis_resolution_v1alpha1_ResolutionRequestStatusFields(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ResolutionRequestStatusFields are the ResolutionRequest-specific fields for the status subresource.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "data": { + SchemaProps: spec.SchemaProps{ + Description: "Data is a string representation of the resolved content of the requested resource in-lined into the ResolutionRequest object.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"data"}, + }, + }, + } +} + func schema_pkg_apis_resource_v1alpha1_PipelineResource(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/pkg/apis/pipeline/v1beta1/pipeline_types.go b/pkg/apis/pipeline/v1beta1/pipeline_types.go index f994fb0ad81..680e113a3c4 100644 --- a/pkg/apis/pipeline/v1beta1/pipeline_types.go +++ b/pkg/apis/pipeline/v1beta1/pipeline_types.go @@ -295,7 +295,7 @@ func (pt PipelineTask) validateTask(ctx context.Context) (errs *apis.FieldError) if pt.TaskRef.Resolver != "" { errs = errs.Also(apis.ErrDisallowedFields("taskref.resolver")) } - if len(pt.TaskRef.Resource) > 0 { + if len(pt.TaskRef.Params) > 0 { errs = errs.Also(apis.ErrDisallowedFields("taskref.resource")) } } diff --git a/pkg/apis/pipeline/v1beta1/pipeline_types_test.go b/pkg/apis/pipeline/v1beta1/pipeline_types_test.go index 07d4888a274..8651f86fa7d 100644 --- a/pkg/apis/pipeline/v1beta1/pipeline_types_test.go +++ b/pkg/apis/pipeline/v1beta1/pipeline_types_test.go @@ -253,9 +253,9 @@ func TestPipelineTask_ValidateRegularTask_Success(t *testing.T) { }, enableAPIFields: true, }, { - name: "pipeline task - use of resource with the feature flag set", + name: "pipeline task - use of params with the feature flag set", tasks: PipelineTask{ - TaskRef: &TaskRef{Name: "boo", ResolverRef: ResolverRef{Resource: []ResolverParam{{}}}}, + TaskRef: &TaskRef{Name: "boo", ResolverRef: ResolverRef{Params: []Param{}}}, }, enableAPIFields: true, }, { @@ -337,9 +337,16 @@ func TestPipelineTask_ValidateRegularTask_Failure(t *testing.T) { }, expectedError: *apis.ErrDisallowedFields("taskref.resolver"), }, { - name: "pipeline task - use of resource without the feature flag set", + name: "pipeline task - use of resolver params without the feature flag set", task: PipelineTask{ - TaskRef: &TaskRef{Name: "boo", ResolverRef: ResolverRef{Resource: []ResolverParam{{}}}}, + TaskRef: &TaskRef{Name: "boo", ResolverRef: ResolverRef{Params: []Param{{ + Name: "bar", + Value: ParamValue{ + Type: ParamTypeString, + StringVal: "baz", + }, + }}, + }}, }, expectedError: *apis.ErrDisallowedFields("taskref.resource"), }} diff --git a/pkg/apis/pipeline/v1beta1/pipelineref_validation.go b/pkg/apis/pipeline/v1beta1/pipelineref_validation.go index 45300a54801..3b4a67f1a7b 100644 --- a/pkg/apis/pipeline/v1beta1/pipelineref_validation.go +++ b/pkg/apis/pipeline/v1beta1/pipelineref_validation.go @@ -33,32 +33,38 @@ func (ref *PipelineRef) Validate(ctx context.Context) (errs *apis.FieldError) { return } - switch { - case ref.Resolver != "": - errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "resolver", config.AlphaAPIFields).ViaField("resolver")) - if ref.Name != "" { - errs = errs.Also(apis.ErrMultipleOneOf("name", "resolver")) + if ref.Resolver != "" || ref.Params != nil { + if ref.Resolver != "" { + errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "resolver", config.AlphaAPIFields).ViaField("resolver")) + if ref.Name != "" { + errs = errs.Also(apis.ErrMultipleOneOf("name", "resolver")) + } + if ref.Bundle != "" { + errs = errs.Also(apis.ErrMultipleOneOf("bundle", "resolver")) + } } - if ref.Bundle != "" { - errs = errs.Also(apis.ErrMultipleOneOf("bundle", "resolver")) + if ref.Params != nil { + errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "params", config.AlphaAPIFields).ViaField("params")) + if ref.Name != "" { + errs = errs.Also(apis.ErrMultipleOneOf("name", "params")) + } + if ref.Bundle != "" { + errs = errs.Also(apis.ErrMultipleOneOf("bundle", "params")) + } + if ref.Resolver == "" { + errs = errs.Also(apis.ErrMissingField("resolver")) + } + errs = errs.Also(ValidateParameters(ctx, ref.Params)) } - case ref.Resource != nil: - errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "resource", config.AlphaAPIFields).ViaField("resource")) - if ref.Name != "" { - errs = errs.Also(apis.ErrMultipleOneOf("name", "resource")) + } else { + if ref.Name == "" { + errs = errs.Also(apis.ErrMissingField("name")) } if ref.Bundle != "" { - errs = errs.Also(apis.ErrMultipleOneOf("bundle", "resource")) - } - if ref.Resolver == "" { - errs = errs.Also(apis.ErrMissingField("resolver")) - } - case ref.Name == "": - errs = errs.Also(apis.ErrMissingField("name")) - case ref.Bundle != "": - errs = errs.Also(validateBundleFeatureFlag(ctx, "bundle", true).ViaField("bundle")) - if _, err := name.ParseReference(ref.Bundle); err != nil { - errs = errs.Also(apis.ErrInvalidValue("invalid bundle reference", "bundle", err.Error())) + errs = errs.Also(validateBundleFeatureFlag(ctx, "bundle", true).ViaField("bundle")) + if _, err := name.ParseReference(ref.Bundle); err != nil { + errs = errs.Also(apis.ErrInvalidValue("invalid bundle reference", "bundle", err.Error())) + } } } return diff --git a/pkg/apis/pipeline/v1beta1/pipelineref_validation_test.go b/pkg/apis/pipeline/v1beta1/pipelineref_validation_test.go index f5ba9c9d8f3..e3aa16c2664 100644 --- a/pkg/apis/pipeline/v1beta1/pipelineref_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/pipelineref_validation_test.go @@ -71,18 +71,18 @@ func TestPipelineRef_Invalid(t *testing.T) { }, wantErr: apis.ErrGeneric("resolver requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\""), }, { - name: "pipelineref resource disallowed without alpha feature gate", + name: "pipelineref params disallowed without alpha feature gate", ref: &v1beta1.PipelineRef{ ResolverRef: v1beta1.ResolverRef{ - Resource: []v1beta1.ResolverParam{}, + Params: []v1beta1.Param{}, }, }, - wantErr: apis.ErrMissingField("resolver").Also(apis.ErrGeneric("resource requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")), + wantErr: apis.ErrMissingField("resolver").Also(apis.ErrGeneric("params requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")), }, { - name: "pipelineref resource disallowed without resolver", + name: "pipelineref params disallowed without resolver", ref: &v1beta1.PipelineRef{ ResolverRef: v1beta1.ResolverRef{ - Resource: []v1beta1.ResolverParam{}, + Params: []v1beta1.Param{}, }, }, wantErr: apis.ErrMissingField("resolver"), @@ -108,31 +108,54 @@ func TestPipelineRef_Invalid(t *testing.T) { wantErr: apis.ErrMultipleOneOf("bundle", "resolver"), withContext: config.EnableAlphaAPIFields, }, { - name: "pipelineref resource disallowed in conjunction with pipelineref name", + name: "pipelineref params disallowed in conjunction with pipelineref name", ref: &v1beta1.PipelineRef{ Name: "bar", ResolverRef: v1beta1.ResolverRef{ - Resource: []v1beta1.ResolverParam{{ - Name: "foo", - Value: "bar", + Params: []v1beta1.Param{{ + Name: "foo", + Value: v1beta1.ParamValue{ + Type: v1beta1.ParamTypeString, + StringVal: "bar", + }, }}, }, }, - wantErr: apis.ErrMultipleOneOf("name", "resource").Also(apis.ErrMissingField("resolver")), + wantErr: apis.ErrMultipleOneOf("name", "params").Also(apis.ErrMissingField("resolver")), withContext: config.EnableAlphaAPIFields, }, { - name: "pipelineref resource disallowed in conjunction with pipelineref bundle", + name: "pipelineref params disallowed in conjunction with pipelineref bundle", ref: &v1beta1.PipelineRef{ Bundle: "bar", ResolverRef: v1beta1.ResolverRef{ - Resource: []v1beta1.ResolverParam{{ - Name: "foo", - Value: "bar", + Params: []v1beta1.Param{{ + Name: "foo", + Value: v1beta1.ParamValue{ + Type: v1beta1.ParamTypeString, + StringVal: "bar", + }, }}, }, }, - wantErr: apis.ErrMultipleOneOf("bundle", "resource").Also(apis.ErrMissingField("resolver")), + wantErr: apis.ErrMultipleOneOf("bundle", "params").Also(apis.ErrMissingField("resolver")), withContext: config.EnableAlphaAPIFields, + }, { + name: "pipelineref param object requires alpha", + ref: &v1beta1.PipelineRef{ + ResolverRef: v1beta1.ResolverRef{ + Resolver: "some-resolver", + Params: []v1beta1.Param{{ + Name: "foo", + Value: v1beta1.ParamValue{ + Type: v1beta1.ParamTypeObject, + ObjectVal: map[string]string{"bar": "baz"}, + }, + }}, + }, + }, + wantErr: apis.ErrGeneric("object type parameter requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\""). + Also(apis.ErrGeneric("resolver requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")). + Also(apis.ErrGeneric("params requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")), }} for _, tc := range tests { @@ -162,13 +185,19 @@ func TestPipelineRef_Valid(t *testing.T) { ref: &v1beta1.PipelineRef{ResolverRef: v1beta1.ResolverRef{Resolver: "git"}}, wc: config.EnableAlphaAPIFields, }, { - name: "alpha feature: valid resolver with resource parameters", - ref: &v1beta1.PipelineRef{ResolverRef: v1beta1.ResolverRef{Resolver: "git", Resource: []v1beta1.ResolverParam{{ - Name: "repo", - Value: "https://github.com/tektoncd/pipeline.git", + name: "alpha feature: valid resolver with params", + ref: &v1beta1.PipelineRef{ResolverRef: v1beta1.ResolverRef{Resolver: "git", Params: []v1beta1.Param{{ + Name: "repo", + Value: v1beta1.ParamValue{ + Type: v1beta1.ParamTypeString, + StringVal: "https://github.com/tektoncd/pipeline.git", + }, }, { - Name: "branch", - Value: "baz", + Name: "branch", + Value: v1beta1.ParamValue{ + Type: v1beta1.ParamTypeString, + StringVal: "baz", + }, }}}}, wc: config.EnableAlphaAPIFields, }} diff --git a/pkg/apis/pipeline/v1beta1/resolver_conversion.go b/pkg/apis/pipeline/v1beta1/resolver_conversion.go index b63c978a59f..18d3c07bb64 100644 --- a/pkg/apis/pipeline/v1beta1/resolver_conversion.go +++ b/pkg/apis/pipeline/v1beta1/resolver_conversion.go @@ -8,30 +8,20 @@ import ( func (rr ResolverRef) convertTo(ctx context.Context, sink *v1.ResolverRef) { sink.Resolver = v1.ResolverName(rr.Resolver) - sink.Resource = nil - for _, r := range rr.Resource { - new := v1.ResolverParam{} + sink.Params = nil + for _, r := range rr.Params { + new := v1.Param{} r.convertTo(ctx, &new) - sink.Resource = append(sink.Resource, new) + sink.Params = append(sink.Params, new) } } func (rr *ResolverRef) convertFrom(ctx context.Context, source v1.ResolverRef) { rr.Resolver = ResolverName(source.Resolver) - rr.Resource = nil - for _, r := range source.Resource { - new := ResolverParam{} + rr.Params = nil + for _, r := range source.Params { + new := Param{} new.convertFrom(ctx, r) - rr.Resource = append(rr.Resource, new) + rr.Params = append(rr.Params, new) } } - -func (rp ResolverParam) convertTo(ctx context.Context, sink *v1.ResolverParam) { - sink.Name = rp.Name - sink.Value = rp.Value -} - -func (rp *ResolverParam) convertFrom(ctx context.Context, source v1.ResolverParam) { - rp.Name = source.Name - rp.Value = source.Value -} diff --git a/pkg/apis/pipeline/v1beta1/resolver_types.go b/pkg/apis/pipeline/v1beta1/resolver_types.go index 1f7a34df7a0..2da2fae52fa 100644 --- a/pkg/apis/pipeline/v1beta1/resolver_types.go +++ b/pkg/apis/pipeline/v1beta1/resolver_types.go @@ -28,21 +28,11 @@ type ResolverRef struct { // resolution of the referenced Tekton resource, such as "git". // +optional Resolver ResolverName `json:"resolver,omitempty"` - // Resource contains the parameters used to identify the + // Params contains the parameters used to identify the // referenced Tekton resource. Example entries might include // "repo" or "path" but the set of params ultimately depends on // the chosen resolver. // +optional // +listType=atomic - Resource []ResolverParam `json:"resource,omitempty"` -} - -// ResolverParam is a single parameter passed to a resolver. -type ResolverParam struct { - // Name is the name of the parameter that will be passed to the - // resolver. - Name string `json:"name"` - // Value is the string value of the parameter that will be - // passed to the resolver. - Value string `json:"value"` + Params []Param `json:"params,omitempty"` } diff --git a/pkg/apis/pipeline/v1beta1/swagger.json b/pkg/apis/pipeline/v1beta1/swagger.json index 6c3451d2360..dc89ab213c8 100644 --- a/pkg/apis/pipeline/v1beta1/swagger.json +++ b/pkg/apis/pipeline/v1beta1/swagger.json @@ -234,6 +234,127 @@ "description": "PipelineResourceStatus does not contain anything because PipelineResources on their own do not have a status Deprecated", "type": "object" }, + "v1alpha1.ResolutionRequest": { + "description": "ResolutionRequest is an object for requesting the content of a Tekton resource like a pipeline.yaml.", + "type": "object", + "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": { + "default": {}, + "$ref": "#/definitions/v1.ObjectMeta" + }, + "spec": { + "description": "Spec holds the information for the request part of the resource request.", + "default": {}, + "$ref": "#/definitions/v1alpha1.ResolutionRequestSpec" + }, + "status": { + "description": "Status communicates the state of the request and, ultimately, the content of the resolved resource.", + "default": {}, + "$ref": "#/definitions/v1alpha1.ResolutionRequestStatus" + } + } + }, + "v1alpha1.ResolutionRequestList": { + "description": "ResolutionRequestList is a list of ResolutionRequests.", + "type": "object", + "required": [ + "items" + ], + "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" + }, + "items": { + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1alpha1.ResolutionRequest" + } + }, + "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": { + "default": {}, + "$ref": "#/definitions/v1.ListMeta" + } + } + }, + "v1alpha1.ResolutionRequestSpec": { + "description": "ResolutionRequestSpec are all the fields in the spec of the ResolutionRequest CRD.", + "type": "object", + "properties": { + "params": { + "description": "Parameters are the runtime attributes passed to the resolver to help it figure out how to resolve the resource being requested. For example: repo URL, commit SHA, path to file, the kind of authentication to leverage, etc.", + "type": "object", + "additionalProperties": { + "type": "string", + "default": "" + } + } + } + }, + "v1alpha1.ResolutionRequestStatus": { + "description": "ResolutionRequestStatus are all the fields in a ResolutionRequest's status subresource.", + "type": "object", + "required": [ + "data" + ], + "properties": { + "annotations": { + "description": "Annotations is additional Status fields for the Resource to save some additional State as well as convey more information to the user. This is roughly akin to Annotations on any k8s resource, just the reconciler conveying richer information outwards.", + "type": "object", + "additionalProperties": { + "type": "string", + "default": "" + } + }, + "conditions": { + "description": "Conditions the latest available observations of a resource's current state.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/knative.Condition" + }, + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge" + }, + "data": { + "description": "Data is a string representation of the resolved content of the requested resource in-lined into the ResolutionRequest object.", + "type": "string", + "default": "" + }, + "observedGeneration": { + "description": "ObservedGeneration is the 'Generation' of the Service that was last processed by the controller.", + "type": "integer", + "format": "int64" + } + } + }, + "v1alpha1.ResolutionRequestStatusFields": { + "description": "ResolutionRequestStatusFields are the ResolutionRequest-specific fields for the status subresource.", + "type": "object", + "required": [ + "data" + ], + "properties": { + "data": { + "description": "Data is a string representation of the resolved content of the requested resource in-lined into the ResolutionRequest object.", + "type": "string", + "default": "" + } + } + }, "v1alpha1.ResourceDeclaration": { "description": "ResourceDeclaration defines an input or output PipelineResource declared as a requirement by another type such as a Task or Condition. The Name field will be used to refer to these PipelineResources within the type's definition, and when provided as an Input, the Name will be the path to the volume mounted containing this PipelineResource as an input (e.g. an input Resource named `workspace` will be mounted at `/workspace`).", "type": "object", @@ -1480,42 +1601,22 @@ } } }, - "v1beta1.ResolverParam": { - "description": "ResolverParam is a single parameter passed to a resolver.", - "type": "object", - "required": [ - "name", - "value" - ], - "properties": { - "name": { - "description": "Name is the name of the parameter that will be passed to the resolver.", - "type": "string", - "default": "" - }, - "value": { - "description": "Value is the string value of the parameter that will be passed to the resolver.", - "type": "string", - "default": "" - } - } - }, "v1beta1.ResolverRef": { "description": "ResolverRef can be used to refer to a Pipeline or Task in a remote location like a git repo. This feature is in alpha and these fields are only available when the alpha feature gate is enabled.", "type": "object", "properties": { - "resolver": { - "description": "Resolver is the name of the resolver that should perform resolution of the referenced Tekton resource, such as \"git\".", - "type": "string" - }, - "resource": { - "description": "Resource contains the parameters used to identify the referenced Tekton resource. Example entries might include \"repo\" or \"path\" but the set of params ultimately depends on the chosen resolver.", + "params": { + "description": "Params contains the parameters used to identify the referenced Tekton resource. Example entries might include \"repo\" or \"path\" but the set of params ultimately depends on the chosen resolver.", "type": "array", "items": { "default": {}, - "$ref": "#/definitions/v1beta1.ResolverParam" + "$ref": "#/definitions/v1beta1.Param" }, "x-kubernetes-list-type": "atomic" + }, + "resolver": { + "description": "Resolver is the name of the resolver that should perform resolution of the referenced Tekton resource, such as \"git\".", + "type": "string" } } }, diff --git a/pkg/apis/pipeline/v1beta1/taskref_validation.go b/pkg/apis/pipeline/v1beta1/taskref_validation.go index 652eed6cff8..3097ea42a4f 100644 --- a/pkg/apis/pipeline/v1beta1/taskref_validation.go +++ b/pkg/apis/pipeline/v1beta1/taskref_validation.go @@ -32,32 +32,38 @@ func (ref *TaskRef) Validate(ctx context.Context) (errs *apis.FieldError) { return } - switch { - case ref.Resolver != "": - errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "resolver", config.AlphaAPIFields).ViaField("resolver")) - if ref.Name != "" { - errs = errs.Also(apis.ErrMultipleOneOf("name", "resolver")) + if ref.Resolver != "" || ref.Params != nil { + if ref.Resolver != "" { + errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "resolver", config.AlphaAPIFields).ViaField("resolver")) + if ref.Name != "" { + errs = errs.Also(apis.ErrMultipleOneOf("name", "resolver")) + } + if ref.Bundle != "" { + errs = errs.Also(apis.ErrMultipleOneOf("bundle", "resolver")) + } } - if ref.Bundle != "" { - errs = errs.Also(apis.ErrMultipleOneOf("bundle", "resolver")) + if ref.Params != nil { + errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "params", config.AlphaAPIFields).ViaField("params")) + if ref.Name != "" { + errs = errs.Also(apis.ErrMultipleOneOf("name", "params")) + } + if ref.Bundle != "" { + errs = errs.Also(apis.ErrMultipleOneOf("bundle", "params")) + } + if ref.Resolver == "" { + errs = errs.Also(apis.ErrMissingField("resolver")) + } + errs = errs.Also(ValidateParameters(ctx, ref.Params)) } - case ref.Resource != nil: - errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "resource", config.AlphaAPIFields).ViaField("resource")) - if ref.Name != "" { - errs = errs.Also(apis.ErrMultipleOneOf("name", "resource")) + } else { + if ref.Name == "" { + errs = errs.Also(apis.ErrMissingField("name")) } if ref.Bundle != "" { - errs = errs.Also(apis.ErrMultipleOneOf("bundle", "resource")) - } - if ref.Resolver == "" { - errs = errs.Also(apis.ErrMissingField("resolver")) - } - case ref.Name == "": - errs = errs.Also(apis.ErrMissingField("name")) - case ref.Bundle != "": - errs = errs.Also(validateBundleFeatureFlag(ctx, "bundle", true).ViaField("bundle")) - if _, err := name.ParseReference(ref.Bundle); err != nil { - errs = errs.Also(apis.ErrInvalidValue("invalid bundle reference", "bundle", err.Error())) + errs = errs.Also(validateBundleFeatureFlag(ctx, "bundle", true).ViaField("bundle")) + if _, err := name.ParseReference(ref.Bundle); err != nil { + errs = errs.Also(apis.ErrInvalidValue("invalid bundle reference", "bundle", err.Error())) + } } } return diff --git a/pkg/apis/pipeline/v1beta1/taskref_validation_test.go b/pkg/apis/pipeline/v1beta1/taskref_validation_test.go index 70efba6ddfb..c46e1f7f257 100644 --- a/pkg/apis/pipeline/v1beta1/taskref_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/taskref_validation_test.go @@ -42,13 +42,19 @@ func TestTaskRef_Valid(t *testing.T) { taskRef: &v1beta1.TaskRef{ResolverRef: v1beta1.ResolverRef{Resolver: "git"}}, wc: config.EnableAlphaAPIFields, }, { - name: "alpha feature: valid resolver with resource parameters", - taskRef: &v1beta1.TaskRef{ResolverRef: v1beta1.ResolverRef{Resolver: "git", Resource: []v1beta1.ResolverParam{{ - Name: "repo", - Value: "https://github.com/tektoncd/pipeline.git", + name: "alpha feature: valid resolver with params", + taskRef: &v1beta1.TaskRef{ResolverRef: v1beta1.ResolverRef{Resolver: "git", Params: []v1beta1.Param{{ + Name: "repo", + Value: v1beta1.ParamValue{ + Type: v1beta1.ParamTypeString, + StringVal: "https://github.com/tektoncd/pipeline.git", + }, }, { - Name: "branch", - Value: "baz", + Name: "branch", + Value: v1beta1.ParamValue{ + Type: v1beta1.ParamTypeString, + StringVal: "baz", + }, }}}}, wc: config.EnableAlphaAPIFields, }, { @@ -112,18 +118,18 @@ func TestTaskRef_Invalid(t *testing.T) { }, wantErr: apis.ErrGeneric("resolver requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\""), }, { - name: "taskref resource disallowed without alpha feature gate", + name: "taskref params disallowed without alpha feature gate", taskRef: &v1beta1.TaskRef{ ResolverRef: v1beta1.ResolverRef{ - Resource: []v1beta1.ResolverParam{}, + Params: []v1beta1.Param{}, }, }, - wantErr: apis.ErrMissingField("resolver").Also(apis.ErrGeneric("resource requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")), + wantErr: apis.ErrMissingField("resolver").Also(apis.ErrGeneric("params requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")), }, { - name: "taskref resource disallowed without resolver", + name: "taskref params disallowed without resolver", taskRef: &v1beta1.TaskRef{ ResolverRef: v1beta1.ResolverRef{ - Resource: []v1beta1.ResolverParam{}, + Params: []v1beta1.Param{}, }, }, wantErr: apis.ErrMissingField("resolver"), @@ -149,31 +155,54 @@ func TestTaskRef_Invalid(t *testing.T) { wantErr: apis.ErrMultipleOneOf("bundle", "resolver"), wc: config.EnableAlphaAPIFields, }, { - name: "taskref resource disallowed in conjunction with taskref name", + name: "taskref params disallowed in conjunction with taskref name", taskRef: &v1beta1.TaskRef{ Name: "bar", ResolverRef: v1beta1.ResolverRef{ - Resource: []v1beta1.ResolverParam{{ - Name: "foo", - Value: "bar", + Params: []v1beta1.Param{{ + Name: "foo", + Value: v1beta1.ParamValue{ + Type: v1beta1.ParamTypeString, + StringVal: "bar", + }, }}, }, }, - wantErr: apis.ErrMultipleOneOf("name", "resource").Also(apis.ErrMissingField("resolver")), + wantErr: apis.ErrMultipleOneOf("name", "params").Also(apis.ErrMissingField("resolver")), wc: config.EnableAlphaAPIFields, }, { - name: "taskref resource disallowed in conjunction with taskref bundle", + name: "taskref params disallowed in conjunction with taskref bundle", taskRef: &v1beta1.TaskRef{ Bundle: "bar", ResolverRef: v1beta1.ResolverRef{ - Resource: []v1beta1.ResolverParam{{ - Name: "foo", - Value: "bar", + Params: []v1beta1.Param{{ + Name: "foo", + Value: v1beta1.ParamValue{ + Type: v1beta1.ParamTypeString, + StringVal: "bar", + }, }}, }, }, - wantErr: apis.ErrMultipleOneOf("bundle", "resource").Also(apis.ErrMissingField("resolver")), + wantErr: apis.ErrMultipleOneOf("bundle", "params").Also(apis.ErrMissingField("resolver")), wc: config.EnableAlphaAPIFields, + }, { + name: "taskref param object requires alpha", + taskRef: &v1beta1.TaskRef{ + ResolverRef: v1beta1.ResolverRef{ + Resolver: "some-resolver", + Params: []v1beta1.Param{{ + Name: "foo", + Value: v1beta1.ParamValue{ + Type: v1beta1.ParamTypeObject, + ObjectVal: map[string]string{"bar": "baz"}, + }, + }}, + }, + }, + wantErr: apis.ErrGeneric("object type parameter requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\""). + Also(apis.ErrGeneric("resolver requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")). + Also(apis.ErrGeneric("params requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")), }} for _, ts := range tests { t.Run(ts.name, func(t *testing.T) { diff --git a/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go b/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go index 5570ac2fd65..38535abe30e 100644 --- a/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go @@ -1101,29 +1101,15 @@ func (in *PropertySpec) DeepCopy() *PropertySpec { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ResolverParam) DeepCopyInto(out *ResolverParam) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResolverParam. -func (in *ResolverParam) DeepCopy() *ResolverParam { - if in == nil { - return nil - } - out := new(ResolverParam) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResolverRef) DeepCopyInto(out *ResolverRef) { *out = *in - if in.Resource != nil { - in, out := &in.Resource, &out.Resource - *out = make([]ResolverParam, len(*in)) - copy(*out, *in) + if in.Params != nil { + in, out := &in.Params, &out.Params + *out = make([]Param, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } return } diff --git a/pkg/apis/resolution/register.go b/pkg/apis/resolution/register.go new file mode 100644 index 00000000000..d83bf6eb483 --- /dev/null +++ b/pkg/apis/resolution/register.go @@ -0,0 +1,22 @@ +/* +Copyright 2022 The Tekton 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 resolution + +const ( + // GroupName is the name of the API group. + GroupName = "resolution.tekton.dev" +) diff --git a/pkg/apis/resolution/v1alpha1/doc.go b/pkg/apis/resolution/v1alpha1/doc.go new file mode 100644 index 00000000000..43214e8cc22 --- /dev/null +++ b/pkg/apis/resolution/v1alpha1/doc.go @@ -0,0 +1,21 @@ +/* +Copyright 2022 The Tekton 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. +*/ + +// +k8s:openapi-gen=true +// +k8s:deepcopy-gen=package,register +// +k8s:defaulter-gen=TypeMeta +// +groupName=resolution.tekton.dev +package v1alpha1 diff --git a/pkg/apis/resolution/v1alpha1/register.go b/pkg/apis/resolution/v1alpha1/register.go new file mode 100644 index 00000000000..4911249e4cb --- /dev/null +++ b/pkg/apis/resolution/v1alpha1/register.go @@ -0,0 +1,54 @@ +/* +Copyright 2022 The Tekton 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 ( + "github.com/tektoncd/pipeline/pkg/apis/resolution" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: resolution.GroupName, Version: "v1alpha1"} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // SchemeBuilder builds a scheme with the types known to the package. + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + // AddToScheme adds the types known to this package to an existing schema. + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &ResolutionRequest{}, + &ResolutionRequestList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/pkg/apis/resolution/v1alpha1/resolution_request_defaults.go b/pkg/apis/resolution/v1alpha1/resolution_request_defaults.go new file mode 100644 index 00000000000..1b1c9ad9eeb --- /dev/null +++ b/pkg/apis/resolution/v1alpha1/resolution_request_defaults.go @@ -0,0 +1,33 @@ +/* +Copyright 2022 The Tekton 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 "context" + +// ManagedByLabelKey is the label key used to mark what is managing this resource +const ManagedByLabelKey = "app.kubernetes.io/managed-by" + +// SetDefaults walks a ResolutionRequest object and sets any default +// values that are required to be set before a reconciler sees it. +func (rr *ResolutionRequest) SetDefaults(ctx context.Context) { + if rr.TypeMeta.Kind == "" { + rr.TypeMeta.Kind = "ResolutionRequest" + } + if rr.TypeMeta.APIVersion == "" { + rr.TypeMeta.APIVersion = "resolution.tekton.dev/v1alpha1" + } +} diff --git a/pkg/apis/resolution/v1alpha1/resolution_request_lifecycle.go b/pkg/apis/resolution/v1alpha1/resolution_request_lifecycle.go new file mode 100644 index 00000000000..279ad0ece5e --- /dev/null +++ b/pkg/apis/resolution/v1alpha1/resolution_request_lifecycle.go @@ -0,0 +1,71 @@ +/* +Copyright 2022 The Tekton 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 ( + resolutioncommon "github.com/tektoncd/resolution/pkg/common" + "k8s.io/apimachinery/pkg/runtime/schema" + "knative.dev/pkg/apis" +) + +// ResolutionRequests only have apis.ConditionSucceeded for now. +var resolutionRequestCondSet = apis.NewBatchConditionSet() + +// GetGroupVersionKind implements kmeta.OwnerRefable. +func (*ResolutionRequest) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("ResolutionRequest") +} + +// GetConditionSet implements KRShaped. +func (*ResolutionRequest) GetConditionSet() apis.ConditionSet { + return resolutionRequestCondSet +} + +// HasStarted returns whether a ResolutionRequests Status is considered to +// be in-progress. +func (rr *ResolutionRequest) HasStarted() bool { + return rr.Status.GetCondition(apis.ConditionSucceeded).IsUnknown() +} + +// IsDone returns whether a ResolutionRequests Status is considered to be +// in a completed state, independent of success/failure. +func (rr *ResolutionRequest) IsDone() bool { + finalStateIsUnknown := rr.Status.GetCondition(apis.ConditionSucceeded).IsUnknown() + return !finalStateIsUnknown +} + +// InitializeConditions set ths initial values of the conditions. +func (s *ResolutionRequestStatus) InitializeConditions() { + resolutionRequestCondSet.Manage(s).InitializeConditions() +} + +// MarkFailed sets the Succeeded condition to False with an accompanying +// error message. +func (s *ResolutionRequestStatus) MarkFailed(reason, message string) { + resolutionRequestCondSet.Manage(s).MarkFalse(apis.ConditionSucceeded, reason, message) +} + +// MarkSucceeded sets the Succeeded condition to True. +func (s *ResolutionRequestStatus) MarkSucceeded() { + resolutionRequestCondSet.Manage(s).MarkTrue(apis.ConditionSucceeded) +} + +// MarkInProgress updates the Succeeded condition to Unknown with an +// accompanying message. +func (s *ResolutionRequestStatus) MarkInProgress(message string) { + resolutionRequestCondSet.Manage(s).MarkUnknown(apis.ConditionSucceeded, resolutioncommon.ReasonResolutionInProgress, message) +} diff --git a/pkg/apis/resolution/v1alpha1/resolution_request_types.go b/pkg/apis/resolution/v1alpha1/resolution_request_types.go new file mode 100644 index 00000000000..b473e1465d1 --- /dev/null +++ b/pkg/apis/resolution/v1alpha1/resolution_request_types.go @@ -0,0 +1,86 @@ +/* +Copyright 2022 The Tekton Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + duckv1 "knative.dev/pkg/apis/duck/v1" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ResolutionRequest is an object for requesting the content of +// a Tekton resource like a pipeline.yaml. +// +// +genclient +// +genreconciler +type ResolutionRequest struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec holds the information for the request part of the resource request. + // +optional + Spec ResolutionRequestSpec `json:"spec,omitempty"` + + // Status communicates the state of the request and, ultimately, + // the content of the resolved resource. + // +optional + Status ResolutionRequestStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ResolutionRequestList is a list of ResolutionRequests. +type ResolutionRequestList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata"` + Items []ResolutionRequest `json:"items"` +} + +// ResolutionRequestSpec are all the fields in the spec of the +// ResolutionRequest CRD. +type ResolutionRequestSpec struct { + // Parameters are the runtime attributes passed to + // the resolver to help it figure out how to resolve the + // resource being requested. For example: repo URL, commit SHA, + // path to file, the kind of authentication to leverage, etc. + // +optional + Parameters map[string]string `json:"params,omitempty"` +} + +// ResolutionRequestStatus are all the fields in a ResolutionRequest's +// status subresource. +type ResolutionRequestStatus struct { + duckv1.Status `json:",inline"` + ResolutionRequestStatusFields `json:",inline"` +} + +// ResolutionRequestStatusFields are the ResolutionRequest-specific fields +// for the status subresource. +type ResolutionRequestStatusFields struct { + // Data is a string representation of the resolved content + // of the requested resource in-lined into the ResolutionRequest + // object. + Data string `json:"data"` +} + +// GetStatus implements KRShaped. +func (rr *ResolutionRequest) GetStatus() *duckv1.Status { + return &rr.Status.Status +} diff --git a/pkg/apis/resolution/v1alpha1/resolution_request_validation.go b/pkg/apis/resolution/v1alpha1/resolution_request_validation.go new file mode 100644 index 00000000000..6c3a45fc9f9 --- /dev/null +++ b/pkg/apis/resolution/v1alpha1/resolution_request_validation.go @@ -0,0 +1,51 @@ +/* +Copyright 2022 The Tekton 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 ( + "context" + + "github.com/tektoncd/resolution/pkg/common" + "knative.dev/pkg/apis" +) + +// Validate checks that a submitted ResolutionRequest is structurally +// sound before the controller receives it. +func (rr *ResolutionRequest) Validate(ctx context.Context) (errs *apis.FieldError) { + errs = errs.Also(validateTypeLabel(rr)) + return errs.Also(rr.Spec.Validate(ctx).ViaField("spec")) +} + +// Validate checks the the spec field of a ResolutionRequest is valid. +func (rs *ResolutionRequestSpec) Validate(ctx context.Context) (errs *apis.FieldError) { + return nil +} + +func validateTypeLabel(rr *ResolutionRequest) *apis.FieldError { + typeLabel := getTypeLabel(rr.ObjectMeta.Labels) + if typeLabel == "" { + return apis.ErrMissingField(common.LabelKeyResolverType).ViaField("labels").ViaField("meta") + } + return nil +} + +func getTypeLabel(labels map[string]string) string { + if labels == nil { + return "" + } + return labels[common.LabelKeyResolverType] +} diff --git a/pkg/apis/resolution/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/resolution/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..db02bbff9b8 --- /dev/null +++ b/pkg/apis/resolution/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,144 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 2020 The Tekton 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 ( + 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 *ResolutionRequest) DeepCopyInto(out *ResolutionRequest) { + *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 ResolutionRequest. +func (in *ResolutionRequest) DeepCopy() *ResolutionRequest { + if in == nil { + return nil + } + out := new(ResolutionRequest) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ResolutionRequest) 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 *ResolutionRequestList) DeepCopyInto(out *ResolutionRequestList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ResolutionRequest, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResolutionRequestList. +func (in *ResolutionRequestList) DeepCopy() *ResolutionRequestList { + if in == nil { + return nil + } + out := new(ResolutionRequestList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ResolutionRequestList) 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 *ResolutionRequestSpec) DeepCopyInto(out *ResolutionRequestSpec) { + *out = *in + if in.Parameters != nil { + in, out := &in.Parameters, &out.Parameters + *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 ResolutionRequestSpec. +func (in *ResolutionRequestSpec) DeepCopy() *ResolutionRequestSpec { + if in == nil { + return nil + } + out := new(ResolutionRequestSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ResolutionRequestStatus) DeepCopyInto(out *ResolutionRequestStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + out.ResolutionRequestStatusFields = in.ResolutionRequestStatusFields + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResolutionRequestStatus. +func (in *ResolutionRequestStatus) DeepCopy() *ResolutionRequestStatus { + if in == nil { + return nil + } + out := new(ResolutionRequestStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ResolutionRequestStatusFields) DeepCopyInto(out *ResolutionRequestStatusFields) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResolutionRequestStatusFields. +func (in *ResolutionRequestStatusFields) DeepCopy() *ResolutionRequestStatusFields { + if in == nil { + return nil + } + out := new(ResolutionRequestStatusFields) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/client/resolution/clientset/versioned/clientset.go b/pkg/client/resolution/clientset/versioned/clientset.go new file mode 100644 index 00000000000..b71b9b1e9e0 --- /dev/null +++ b/pkg/client/resolution/clientset/versioned/clientset.go @@ -0,0 +1,121 @@ +/* +Copyright 2020 The Tekton 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 versioned + +import ( + "fmt" + "net/http" + + resolutionv1alpha1 "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1" + discovery "k8s.io/client-go/discovery" + rest "k8s.io/client-go/rest" + flowcontrol "k8s.io/client-go/util/flowcontrol" +) + +type Interface interface { + Discovery() discovery.DiscoveryInterface + ResolutionV1alpha1() resolutionv1alpha1.ResolutionV1alpha1Interface +} + +// Clientset contains the clients for groups. Each group has exactly one +// version included in a Clientset. +type Clientset struct { + *discovery.DiscoveryClient + resolutionV1alpha1 *resolutionv1alpha1.ResolutionV1alpha1Client +} + +// ResolutionV1alpha1 retrieves the ResolutionV1alpha1Client +func (c *Clientset) ResolutionV1alpha1() resolutionv1alpha1.ResolutionV1alpha1Interface { + return c.resolutionV1alpha1 +} + +// Discovery retrieves the DiscoveryClient +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + if c == nil { + return nil + } + return c.DiscoveryClient +} + +// NewForConfig creates a new Clientset for the given config. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfig will generate a rate-limiter in configShallowCopy. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*Clientset, error) { + configShallowCopy := *c + + if configShallowCopy.UserAgent == "" { + configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent() + } + + // share the transport between all clients + httpClient, err := rest.HTTPClientFor(&configShallowCopy) + if err != nil { + return nil, err + } + + return NewForConfigAndClient(&configShallowCopy, httpClient) +} + +// NewForConfigAndClient creates a new Clientset for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfigAndClient will generate a rate-limiter in configShallowCopy. +func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) { + configShallowCopy := *c + if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { + if configShallowCopy.Burst <= 0 { + return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") + } + configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) + } + + var cs Clientset + var err error + cs.resolutionV1alpha1, err = resolutionv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } + + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } + return &cs, nil +} + +// NewForConfigOrDie creates a new Clientset for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *Clientset { + cs, err := NewForConfig(c) + if err != nil { + panic(err) + } + return cs +} + +// New creates a new Clientset for the given RESTClient. +func New(c rest.Interface) *Clientset { + var cs Clientset + cs.resolutionV1alpha1 = resolutionv1alpha1.New(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &cs +} diff --git a/pkg/client/resolution/clientset/versioned/doc.go b/pkg/client/resolution/clientset/versioned/doc.go new file mode 100644 index 00000000000..0d13552ae28 --- /dev/null +++ b/pkg/client/resolution/clientset/versioned/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 The Tekton 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 clientset. +package versioned diff --git a/pkg/client/resolution/clientset/versioned/fake/clientset_generated.go b/pkg/client/resolution/clientset/versioned/fake/clientset_generated.go new file mode 100644 index 00000000000..8717312d332 --- /dev/null +++ b/pkg/client/resolution/clientset/versioned/fake/clientset_generated.go @@ -0,0 +1,85 @@ +/* +Copyright 2020 The Tekton 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 ( + clientset "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned" + resolutionv1alpha1 "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1" + fakeresolutionv1alpha1 "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/fake" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/discovery" + fakediscovery "k8s.io/client-go/discovery/fake" + "k8s.io/client-go/testing" +) + +// NewSimpleClientset returns a clientset that will respond with the provided objects. +// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, +// without applying any validations and/or defaults. It shouldn't be considered a replacement +// for a real clientset and is mostly useful in simple unit tests. +func NewSimpleClientset(objects ...runtime.Object) *Clientset { + o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) + for _, obj := range objects { + if err := o.Add(obj); err != nil { + panic(err) + } + } + + cs := &Clientset{tracker: o} + cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} + cs.AddReactor("*", "*", testing.ObjectReaction(o)) + cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { + gvr := action.GetResource() + ns := action.GetNamespace() + watch, err := o.Watch(gvr, ns) + if err != nil { + return false, nil, err + } + return true, watch, nil + }) + + return cs +} + +// Clientset implements clientset.Interface. Meant to be embedded into a +// struct to get a default implementation. This makes faking out just the method +// you want to test easier. +type Clientset struct { + testing.Fake + discovery *fakediscovery.FakeDiscovery + tracker testing.ObjectTracker +} + +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + return c.discovery +} + +func (c *Clientset) Tracker() testing.ObjectTracker { + return c.tracker +} + +var ( + _ clientset.Interface = &Clientset{} + _ testing.FakeClient = &Clientset{} +) + +// ResolutionV1alpha1 retrieves the ResolutionV1alpha1Client +func (c *Clientset) ResolutionV1alpha1() resolutionv1alpha1.ResolutionV1alpha1Interface { + return &fakeresolutionv1alpha1.FakeResolutionV1alpha1{Fake: &c.Fake} +} diff --git a/pkg/client/resolution/clientset/versioned/fake/doc.go b/pkg/client/resolution/clientset/versioned/fake/doc.go new file mode 100644 index 00000000000..4e4dbb68181 --- /dev/null +++ b/pkg/client/resolution/clientset/versioned/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 The Tekton 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 fake clientset. +package fake diff --git a/pkg/client/resolution/clientset/versioned/fake/register.go b/pkg/client/resolution/clientset/versioned/fake/register.go new file mode 100644 index 00000000000..3768dbbd30a --- /dev/null +++ b/pkg/client/resolution/clientset/versioned/fake/register.go @@ -0,0 +1,56 @@ +/* +Copyright 2020 The Tekton 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 ( + resolutionv1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var scheme = runtime.NewScheme() +var codecs = serializer.NewCodecFactory(scheme) + +var localSchemeBuilder = runtime.SchemeBuilder{ + resolutionv1alpha1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(scheme)) +} diff --git a/pkg/client/resolution/clientset/versioned/scheme/doc.go b/pkg/client/resolution/clientset/versioned/scheme/doc.go new file mode 100644 index 00000000000..0fb16cc0567 --- /dev/null +++ b/pkg/client/resolution/clientset/versioned/scheme/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 The Tekton 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 contains the scheme of the automatically generated clientset. +package scheme diff --git a/pkg/client/resolution/clientset/versioned/scheme/register.go b/pkg/client/resolution/clientset/versioned/scheme/register.go new file mode 100644 index 00000000000..5f7b6278f67 --- /dev/null +++ b/pkg/client/resolution/clientset/versioned/scheme/register.go @@ -0,0 +1,56 @@ +/* +Copyright 2020 The Tekton 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 scheme + +import ( + resolutionv1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var Scheme = runtime.NewScheme() +var Codecs = serializer.NewCodecFactory(Scheme) +var ParameterCodec = runtime.NewParameterCodec(Scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + resolutionv1alpha1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(Scheme)) +} diff --git a/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/doc.go b/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/doc.go new file mode 100644 index 00000000000..69ed294b828 --- /dev/null +++ b/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 The Tekton 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/resolution/clientset/versioned/typed/resolution/v1alpha1/fake/doc.go b/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/fake/doc.go new file mode 100644 index 00000000000..1a72e0befe2 --- /dev/null +++ b/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 The Tekton 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/resolution/clientset/versioned/typed/resolution/v1alpha1/fake/fake_resolution_client.go b/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/fake/fake_resolution_client.go new file mode 100644 index 00000000000..a442a07b0eb --- /dev/null +++ b/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/fake/fake_resolution_client.go @@ -0,0 +1,40 @@ +/* +Copyright 2020 The Tekton 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 ( + v1alpha1 "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeResolutionV1alpha1 struct { + *testing.Fake +} + +func (c *FakeResolutionV1alpha1) ResolutionRequests(namespace string) v1alpha1.ResolutionRequestInterface { + return &FakeResolutionRequests{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeResolutionV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/fake/fake_resolutionrequest.go b/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/fake/fake_resolutionrequest.go new file mode 100644 index 00000000000..ce8a7d2bad7 --- /dev/null +++ b/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/fake/fake_resolutionrequest.go @@ -0,0 +1,142 @@ +/* +Copyright 2020 The Tekton Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeResolutionRequests implements ResolutionRequestInterface +type FakeResolutionRequests struct { + Fake *FakeResolutionV1alpha1 + ns string +} + +var resolutionrequestsResource = schema.GroupVersionResource{Group: "resolution.tekton.dev", Version: "v1alpha1", Resource: "resolutionrequests"} + +var resolutionrequestsKind = schema.GroupVersionKind{Group: "resolution.tekton.dev", Version: "v1alpha1", Kind: "ResolutionRequest"} + +// Get takes name of the resolutionRequest, and returns the corresponding resolutionRequest object, and an error if there is any. +func (c *FakeResolutionRequests) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ResolutionRequest, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(resolutionrequestsResource, c.ns, name), &v1alpha1.ResolutionRequest{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ResolutionRequest), err +} + +// List takes label and field selectors, and returns the list of ResolutionRequests that match those selectors. +func (c *FakeResolutionRequests) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ResolutionRequestList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(resolutionrequestsResource, resolutionrequestsKind, c.ns, opts), &v1alpha1.ResolutionRequestList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.ResolutionRequestList{ListMeta: obj.(*v1alpha1.ResolutionRequestList).ListMeta} + for _, item := range obj.(*v1alpha1.ResolutionRequestList).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 resolutionRequests. +func (c *FakeResolutionRequests) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(resolutionrequestsResource, c.ns, opts)) + +} + +// Create takes the representation of a resolutionRequest and creates it. Returns the server's representation of the resolutionRequest, and an error, if there is any. +func (c *FakeResolutionRequests) Create(ctx context.Context, resolutionRequest *v1alpha1.ResolutionRequest, opts v1.CreateOptions) (result *v1alpha1.ResolutionRequest, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(resolutionrequestsResource, c.ns, resolutionRequest), &v1alpha1.ResolutionRequest{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ResolutionRequest), err +} + +// Update takes the representation of a resolutionRequest and updates it. Returns the server's representation of the resolutionRequest, and an error, if there is any. +func (c *FakeResolutionRequests) Update(ctx context.Context, resolutionRequest *v1alpha1.ResolutionRequest, opts v1.UpdateOptions) (result *v1alpha1.ResolutionRequest, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(resolutionrequestsResource, c.ns, resolutionRequest), &v1alpha1.ResolutionRequest{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ResolutionRequest), 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 *FakeResolutionRequests) UpdateStatus(ctx context.Context, resolutionRequest *v1alpha1.ResolutionRequest, opts v1.UpdateOptions) (*v1alpha1.ResolutionRequest, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(resolutionrequestsResource, "status", c.ns, resolutionRequest), &v1alpha1.ResolutionRequest{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ResolutionRequest), err +} + +// Delete takes name of the resolutionRequest and deletes it. Returns an error if one occurs. +func (c *FakeResolutionRequests) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(resolutionrequestsResource, c.ns, name, opts), &v1alpha1.ResolutionRequest{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeResolutionRequests) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(resolutionrequestsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.ResolutionRequestList{}) + return err +} + +// Patch applies the patch and returns the patched resolutionRequest. +func (c *FakeResolutionRequests) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ResolutionRequest, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(resolutionrequestsResource, c.ns, name, pt, data, subresources...), &v1alpha1.ResolutionRequest{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ResolutionRequest), err +} diff --git a/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/generated_expansion.go b/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/generated_expansion.go new file mode 100644 index 00000000000..f11a8b5169f --- /dev/null +++ b/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2020 The Tekton 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 ResolutionRequestExpansion interface{} diff --git a/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/resolution_client.go b/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/resolution_client.go new file mode 100644 index 00000000000..bc70e73c9a6 --- /dev/null +++ b/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/resolution_client.go @@ -0,0 +1,107 @@ +/* +Copyright 2020 The Tekton 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" + + v1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type ResolutionV1alpha1Interface interface { + RESTClient() rest.Interface + ResolutionRequestsGetter +} + +// ResolutionV1alpha1Client is used to interact with features provided by the resolution.tekton.dev group. +type ResolutionV1alpha1Client struct { + restClient rest.Interface +} + +func (c *ResolutionV1alpha1Client) ResolutionRequests(namespace string) ResolutionRequestInterface { + return newResolutionRequests(c, namespace) +} + +// NewForConfig creates a new ResolutionV1alpha1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*ResolutionV1alpha1Client, 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 ResolutionV1alpha1Client 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) (*ResolutionV1alpha1Client, 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 &ResolutionV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new ResolutionV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *ResolutionV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new ResolutionV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *ResolutionV1alpha1Client { + return &ResolutionV1alpha1Client{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 *ResolutionV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/resolutionrequest.go b/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/resolutionrequest.go new file mode 100644 index 00000000000..6169f8a3ad3 --- /dev/null +++ b/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1/resolutionrequest.go @@ -0,0 +1,195 @@ +/* +Copyright 2020 The Tekton Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + scheme "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// ResolutionRequestsGetter has a method to return a ResolutionRequestInterface. +// A group's client should implement this interface. +type ResolutionRequestsGetter interface { + ResolutionRequests(namespace string) ResolutionRequestInterface +} + +// ResolutionRequestInterface has methods to work with ResolutionRequest resources. +type ResolutionRequestInterface interface { + Create(ctx context.Context, resolutionRequest *v1alpha1.ResolutionRequest, opts v1.CreateOptions) (*v1alpha1.ResolutionRequest, error) + Update(ctx context.Context, resolutionRequest *v1alpha1.ResolutionRequest, opts v1.UpdateOptions) (*v1alpha1.ResolutionRequest, error) + UpdateStatus(ctx context.Context, resolutionRequest *v1alpha1.ResolutionRequest, opts v1.UpdateOptions) (*v1alpha1.ResolutionRequest, 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.ResolutionRequest, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ResolutionRequestList, 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.ResolutionRequest, err error) + ResolutionRequestExpansion +} + +// resolutionRequests implements ResolutionRequestInterface +type resolutionRequests struct { + client rest.Interface + ns string +} + +// newResolutionRequests returns a ResolutionRequests +func newResolutionRequests(c *ResolutionV1alpha1Client, namespace string) *resolutionRequests { + return &resolutionRequests{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the resolutionRequest, and returns the corresponding resolutionRequest object, and an error if there is any. +func (c *resolutionRequests) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ResolutionRequest, err error) { + result = &v1alpha1.ResolutionRequest{} + err = c.client.Get(). + Namespace(c.ns). + Resource("resolutionrequests"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ResolutionRequests that match those selectors. +func (c *resolutionRequests) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ResolutionRequestList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.ResolutionRequestList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("resolutionrequests"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested resolutionRequests. +func (c *resolutionRequests) 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("resolutionrequests"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a resolutionRequest and creates it. Returns the server's representation of the resolutionRequest, and an error, if there is any. +func (c *resolutionRequests) Create(ctx context.Context, resolutionRequest *v1alpha1.ResolutionRequest, opts v1.CreateOptions) (result *v1alpha1.ResolutionRequest, err error) { + result = &v1alpha1.ResolutionRequest{} + err = c.client.Post(). + Namespace(c.ns). + Resource("resolutionrequests"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(resolutionRequest). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a resolutionRequest and updates it. Returns the server's representation of the resolutionRequest, and an error, if there is any. +func (c *resolutionRequests) Update(ctx context.Context, resolutionRequest *v1alpha1.ResolutionRequest, opts v1.UpdateOptions) (result *v1alpha1.ResolutionRequest, err error) { + result = &v1alpha1.ResolutionRequest{} + err = c.client.Put(). + Namespace(c.ns). + Resource("resolutionrequests"). + Name(resolutionRequest.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(resolutionRequest). + 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 *resolutionRequests) UpdateStatus(ctx context.Context, resolutionRequest *v1alpha1.ResolutionRequest, opts v1.UpdateOptions) (result *v1alpha1.ResolutionRequest, err error) { + result = &v1alpha1.ResolutionRequest{} + err = c.client.Put(). + Namespace(c.ns). + Resource("resolutionrequests"). + Name(resolutionRequest.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(resolutionRequest). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the resolutionRequest and deletes it. Returns an error if one occurs. +func (c *resolutionRequests) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("resolutionrequests"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *resolutionRequests) 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("resolutionrequests"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched resolutionRequest. +func (c *resolutionRequests) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ResolutionRequest, err error) { + result = &v1alpha1.ResolutionRequest{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("resolutionrequests"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/resolution/informers/externalversions/factory.go b/pkg/client/resolution/informers/externalversions/factory.go new file mode 100644 index 00000000000..39c9230ec84 --- /dev/null +++ b/pkg/client/resolution/informers/externalversions/factory.go @@ -0,0 +1,180 @@ +/* +Copyright 2020 The Tekton 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 externalversions + +import ( + reflect "reflect" + sync "sync" + time "time" + + versioned "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned" + internalinterfaces "github.com/tektoncd/pipeline/pkg/client/resolution/informers/externalversions/internalinterfaces" + resolution "github.com/tektoncd/pipeline/pkg/client/resolution/informers/externalversions/resolution" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// SharedInformerOption defines the functional option type for SharedInformerFactory. +type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory + +type sharedInformerFactory struct { + client versioned.Interface + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc + lock sync.Mutex + defaultResync time.Duration + customResync map[reflect.Type]time.Duration + + informers map[reflect.Type]cache.SharedIndexInformer + // startedInformers is used for tracking which informers have been started. + // This allows Start() to be called multiple times safely. + startedInformers map[reflect.Type]bool +} + +// WithCustomResyncConfig sets a custom resync period for the specified informer types. +func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + for k, v := range resyncConfig { + factory.customResync[reflect.TypeOf(k)] = v + } + return factory + } +} + +// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory. +func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.tweakListOptions = tweakListOptions + return factory + } +} + +// WithNamespace limits the SharedInformerFactory to the specified namespace. +func WithNamespace(namespace string) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.namespace = namespace + return factory + } +} + +// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. +func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync) +} + +// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. +// Listers obtained via this SharedInformerFactory will be subject to the same filters +// as specified here. +// Deprecated: Please use NewSharedInformerFactoryWithOptions instead +func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions)) +} + +// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. +func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { + factory := &sharedInformerFactory{ + client: client, + namespace: v1.NamespaceAll, + defaultResync: defaultResync, + informers: make(map[reflect.Type]cache.SharedIndexInformer), + startedInformers: make(map[reflect.Type]bool), + customResync: make(map[reflect.Type]time.Duration), + } + + // Apply all options + for _, opt := range options { + factory = opt(factory) + } + + return factory +} + +// Start initializes all requested informers. +func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { + f.lock.Lock() + defer f.lock.Unlock() + + for informerType, informer := range f.informers { + if !f.startedInformers[informerType] { + go informer.Run(stopCh) + f.startedInformers[informerType] = true + } + } +} + +// 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() + defer f.lock.Unlock() + + informers := map[reflect.Type]cache.SharedIndexInformer{} + for informerType, informer := range f.informers { + if f.startedInformers[informerType] { + informers[informerType] = informer + } + } + return informers + }() + + res := map[reflect.Type]bool{} + for informType, informer := range informers { + res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) + } + return res +} + +// 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() + defer f.lock.Unlock() + + informerType := reflect.TypeOf(obj) + informer, exists := f.informers[informerType] + if exists { + return informer + } + + resyncPeriod, exists := f.customResync[informerType] + if !exists { + resyncPeriod = f.defaultResync + } + + informer = newFunc(f.client, resyncPeriod) + f.informers[informerType] = informer + + return informer +} + +// SharedInformerFactory provides shared informers for resources in all known +// API group versions. +type SharedInformerFactory interface { + internalinterfaces.SharedInformerFactory + ForResource(resource schema.GroupVersionResource) (GenericInformer, error) + WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + + Resolution() resolution.Interface +} + +func (f *sharedInformerFactory) Resolution() resolution.Interface { + return resolution.New(f, f.namespace, f.tweakListOptions) +} diff --git a/pkg/client/resolution/informers/externalversions/generic.go b/pkg/client/resolution/informers/externalversions/generic.go new file mode 100644 index 00000000000..5868bb3df3c --- /dev/null +++ b/pkg/client/resolution/informers/externalversions/generic.go @@ -0,0 +1,62 @@ +/* +Copyright 2020 The Tekton 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 externalversions + +import ( + "fmt" + + v1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// GenericInformer is type of SharedIndexInformer which will locate and delegate to other +// sharedInformers based on type +type GenericInformer interface { + Informer() cache.SharedIndexInformer + Lister() cache.GenericLister +} + +type genericInformer struct { + informer cache.SharedIndexInformer + resource schema.GroupResource +} + +// Informer returns the SharedIndexInformer. +func (f *genericInformer) Informer() cache.SharedIndexInformer { + return f.informer +} + +// Lister returns the GenericLister. +func (f *genericInformer) Lister() cache.GenericLister { + return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) +} + +// ForResource gives generic access to a shared informer of the matching type +// TODO extend this to unknown resources with a client pool +func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { + switch resource { + // Group=resolution.tekton.dev, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("resolutionrequests"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Resolution().V1alpha1().ResolutionRequests().Informer()}, nil + + } + + return nil, fmt.Errorf("no informer found for %v", resource) +} diff --git a/pkg/client/resolution/informers/externalversions/internalinterfaces/factory_interfaces.go b/pkg/client/resolution/informers/externalversions/internalinterfaces/factory_interfaces.go new file mode 100644 index 00000000000..e5d27987c97 --- /dev/null +++ b/pkg/client/resolution/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -0,0 +1,40 @@ +/* +Copyright 2020 The Tekton 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 internalinterfaces + +import ( + time "time" + + versioned "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + cache "k8s.io/client-go/tools/cache" +) + +// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer. +type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer + +// SharedInformerFactory a small interface to allow for adding an informer without an import cycle +type SharedInformerFactory interface { + Start(stopCh <-chan struct{}) + InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer +} + +// TweakListOptionsFunc is a function that transforms a v1.ListOptions. +type TweakListOptionsFunc func(*v1.ListOptions) diff --git a/pkg/client/resolution/informers/externalversions/resolution/interface.go b/pkg/client/resolution/informers/externalversions/resolution/interface.go new file mode 100644 index 00000000000..006bf60e89e --- /dev/null +++ b/pkg/client/resolution/informers/externalversions/resolution/interface.go @@ -0,0 +1,46 @@ +/* +Copyright 2020 The Tekton 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 resolution + +import ( + internalinterfaces "github.com/tektoncd/pipeline/pkg/client/resolution/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/tektoncd/pipeline/pkg/client/resolution/informers/externalversions/resolution/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/resolution/informers/externalversions/resolution/v1alpha1/interface.go b/pkg/client/resolution/informers/externalversions/resolution/v1alpha1/interface.go new file mode 100644 index 00000000000..e5bfc1d1f1a --- /dev/null +++ b/pkg/client/resolution/informers/externalversions/resolution/v1alpha1/interface.go @@ -0,0 +1,45 @@ +/* +Copyright 2020 The Tekton 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 "github.com/tektoncd/pipeline/pkg/client/resolution/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // ResolutionRequests returns a ResolutionRequestInformer. + ResolutionRequests() ResolutionRequestInformer +} + +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} +} + +// ResolutionRequests returns a ResolutionRequestInformer. +func (v *version) ResolutionRequests() ResolutionRequestInformer { + return &resolutionRequestInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/resolution/informers/externalversions/resolution/v1alpha1/resolutionrequest.go b/pkg/client/resolution/informers/externalversions/resolution/v1alpha1/resolutionrequest.go new file mode 100644 index 00000000000..f896ee29fcf --- /dev/null +++ b/pkg/client/resolution/informers/externalversions/resolution/v1alpha1/resolutionrequest.go @@ -0,0 +1,90 @@ +/* +Copyright 2020 The Tekton 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" + + resolutionv1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + versioned "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned" + internalinterfaces "github.com/tektoncd/pipeline/pkg/client/resolution/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/tektoncd/pipeline/pkg/client/resolution/listers/resolution/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ResolutionRequestInformer provides access to a shared informer and lister for +// ResolutionRequests. +type ResolutionRequestInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.ResolutionRequestLister +} + +type resolutionRequestInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewResolutionRequestInformer constructs a new informer for ResolutionRequest 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 NewResolutionRequestInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredResolutionRequestInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredResolutionRequestInformer constructs a new informer for ResolutionRequest 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 NewFilteredResolutionRequestInformer(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.ResolutionV1alpha1().ResolutionRequests(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ResolutionV1alpha1().ResolutionRequests(namespace).Watch(context.TODO(), options) + }, + }, + &resolutionv1alpha1.ResolutionRequest{}, + resyncPeriod, + indexers, + ) +} + +func (f *resolutionRequestInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredResolutionRequestInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *resolutionRequestInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&resolutionv1alpha1.ResolutionRequest{}, f.defaultInformer) +} + +func (f *resolutionRequestInformer) Lister() v1alpha1.ResolutionRequestLister { + return v1alpha1.NewResolutionRequestLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/resolution/injection/client/client.go b/pkg/client/resolution/injection/client/client.go new file mode 100644 index 00000000000..f57bcb12713 --- /dev/null +++ b/pkg/client/resolution/injection/client/client.go @@ -0,0 +1,243 @@ +/* +Copyright 2020 The Tekton 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 injection-gen. DO NOT EDIT. + +package client + +import ( + context "context" + json "encoding/json" + errors "errors" + fmt "fmt" + + v1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + versioned "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned" + typedresolutionv1alpha1 "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned/typed/resolution/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + unstructured "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + discovery "k8s.io/client-go/discovery" + dynamic "k8s.io/client-go/dynamic" + rest "k8s.io/client-go/rest" + injection "knative.dev/pkg/injection" + dynamicclient "knative.dev/pkg/injection/clients/dynamicclient" + logging "knative.dev/pkg/logging" +) + +func init() { + injection.Default.RegisterClient(withClientFromConfig) + injection.Default.RegisterClientFetcher(func(ctx context.Context) interface{} { + return Get(ctx) + }) + injection.Dynamic.RegisterDynamicClient(withClientFromDynamic) +} + +// Key is used as the key for associating information with a context.Context. +type Key struct{} + +func withClientFromConfig(ctx context.Context, cfg *rest.Config) context.Context { + return context.WithValue(ctx, Key{}, versioned.NewForConfigOrDie(cfg)) +} + +func withClientFromDynamic(ctx context.Context) context.Context { + return context.WithValue(ctx, Key{}, &wrapClient{dyn: dynamicclient.Get(ctx)}) +} + +// Get extracts the versioned.Interface client from the context. +func Get(ctx context.Context) versioned.Interface { + untyped := ctx.Value(Key{}) + if untyped == nil { + if injection.GetConfig(ctx) == nil { + logging.FromContext(ctx).Panic( + "Unable to fetch github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned.Interface from context. This context is not the application context (which is typically given to constructors via sharedmain).") + } else { + logging.FromContext(ctx).Panic( + "Unable to fetch github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned.Interface from context.") + } + } + return untyped.(versioned.Interface) +} + +type wrapClient struct { + dyn dynamic.Interface +} + +var _ versioned.Interface = (*wrapClient)(nil) + +func (w *wrapClient) Discovery() discovery.DiscoveryInterface { + panic("Discovery called on dynamic client!") +} + +func convert(from interface{}, to runtime.Object) error { + bs, err := json.Marshal(from) + if err != nil { + return fmt.Errorf("Marshal() = %w", err) + } + if err := json.Unmarshal(bs, to); err != nil { + return fmt.Errorf("Unmarshal() = %w", err) + } + return nil +} + +// ResolutionV1alpha1 retrieves the ResolutionV1alpha1Client +func (w *wrapClient) ResolutionV1alpha1() typedresolutionv1alpha1.ResolutionV1alpha1Interface { + return &wrapResolutionV1alpha1{ + dyn: w.dyn, + } +} + +type wrapResolutionV1alpha1 struct { + dyn dynamic.Interface +} + +func (w *wrapResolutionV1alpha1) RESTClient() rest.Interface { + panic("RESTClient called on dynamic client!") +} + +func (w *wrapResolutionV1alpha1) ResolutionRequests(namespace string) typedresolutionv1alpha1.ResolutionRequestInterface { + return &wrapResolutionV1alpha1ResolutionRequestImpl{ + dyn: w.dyn.Resource(schema.GroupVersionResource{ + Group: "resolution.tekton.dev", + Version: "v1alpha1", + Resource: "resolutionrequests", + }), + + namespace: namespace, + } +} + +type wrapResolutionV1alpha1ResolutionRequestImpl struct { + dyn dynamic.NamespaceableResourceInterface + + namespace string +} + +var _ typedresolutionv1alpha1.ResolutionRequestInterface = (*wrapResolutionV1alpha1ResolutionRequestImpl)(nil) + +func (w *wrapResolutionV1alpha1ResolutionRequestImpl) Create(ctx context.Context, in *v1alpha1.ResolutionRequest, opts v1.CreateOptions) (*v1alpha1.ResolutionRequest, error) { + in.SetGroupVersionKind(schema.GroupVersionKind{ + Group: "resolution.tekton.dev", + Version: "v1alpha1", + Kind: "ResolutionRequest", + }) + uo := &unstructured.Unstructured{} + if err := convert(in, uo); err != nil { + return nil, err + } + uo, err := w.dyn.Namespace(w.namespace).Create(ctx, uo, opts) + if err != nil { + return nil, err + } + out := &v1alpha1.ResolutionRequest{} + if err := convert(uo, out); err != nil { + return nil, err + } + return out, nil +} + +func (w *wrapResolutionV1alpha1ResolutionRequestImpl) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return w.dyn.Namespace(w.namespace).Delete(ctx, name, opts) +} + +func (w *wrapResolutionV1alpha1ResolutionRequestImpl) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + return w.dyn.Namespace(w.namespace).DeleteCollection(ctx, opts, listOpts) +} + +func (w *wrapResolutionV1alpha1ResolutionRequestImpl) Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.ResolutionRequest, error) { + uo, err := w.dyn.Namespace(w.namespace).Get(ctx, name, opts) + if err != nil { + return nil, err + } + out := &v1alpha1.ResolutionRequest{} + if err := convert(uo, out); err != nil { + return nil, err + } + return out, nil +} + +func (w *wrapResolutionV1alpha1ResolutionRequestImpl) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ResolutionRequestList, error) { + uo, err := w.dyn.Namespace(w.namespace).List(ctx, opts) + if err != nil { + return nil, err + } + out := &v1alpha1.ResolutionRequestList{} + if err := convert(uo, out); err != nil { + return nil, err + } + return out, nil +} + +func (w *wrapResolutionV1alpha1ResolutionRequestImpl) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ResolutionRequest, err error) { + uo, err := w.dyn.Namespace(w.namespace).Patch(ctx, name, pt, data, opts) + if err != nil { + return nil, err + } + out := &v1alpha1.ResolutionRequest{} + if err := convert(uo, out); err != nil { + return nil, err + } + return out, nil +} + +func (w *wrapResolutionV1alpha1ResolutionRequestImpl) Update(ctx context.Context, in *v1alpha1.ResolutionRequest, opts v1.UpdateOptions) (*v1alpha1.ResolutionRequest, error) { + in.SetGroupVersionKind(schema.GroupVersionKind{ + Group: "resolution.tekton.dev", + Version: "v1alpha1", + Kind: "ResolutionRequest", + }) + uo := &unstructured.Unstructured{} + if err := convert(in, uo); err != nil { + return nil, err + } + uo, err := w.dyn.Namespace(w.namespace).Update(ctx, uo, opts) + if err != nil { + return nil, err + } + out := &v1alpha1.ResolutionRequest{} + if err := convert(uo, out); err != nil { + return nil, err + } + return out, nil +} + +func (w *wrapResolutionV1alpha1ResolutionRequestImpl) UpdateStatus(ctx context.Context, in *v1alpha1.ResolutionRequest, opts v1.UpdateOptions) (*v1alpha1.ResolutionRequest, error) { + in.SetGroupVersionKind(schema.GroupVersionKind{ + Group: "resolution.tekton.dev", + Version: "v1alpha1", + Kind: "ResolutionRequest", + }) + uo := &unstructured.Unstructured{} + if err := convert(in, uo); err != nil { + return nil, err + } + uo, err := w.dyn.Namespace(w.namespace).UpdateStatus(ctx, uo, opts) + if err != nil { + return nil, err + } + out := &v1alpha1.ResolutionRequest{} + if err := convert(uo, out); err != nil { + return nil, err + } + return out, nil +} + +func (w *wrapResolutionV1alpha1ResolutionRequestImpl) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return nil, errors.New("NYI: Watch") +} diff --git a/pkg/client/resolution/injection/client/fake/fake.go b/pkg/client/resolution/injection/client/fake/fake.go new file mode 100644 index 00000000000..0004b0aede0 --- /dev/null +++ b/pkg/client/resolution/injection/client/fake/fake.go @@ -0,0 +1,57 @@ +/* +Copyright 2020 The Tekton 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 injection-gen. DO NOT EDIT. + +package fake + +import ( + context "context" + + fake "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned/fake" + client "github.com/tektoncd/pipeline/pkg/client/resolution/injection/client" + runtime "k8s.io/apimachinery/pkg/runtime" + rest "k8s.io/client-go/rest" + injection "knative.dev/pkg/injection" + logging "knative.dev/pkg/logging" +) + +func init() { + injection.Fake.RegisterClient(withClient) + injection.Fake.RegisterClientFetcher(func(ctx context.Context) interface{} { + return Get(ctx) + }) +} + +func withClient(ctx context.Context, cfg *rest.Config) context.Context { + ctx, _ = With(ctx) + return ctx +} + +func With(ctx context.Context, objects ...runtime.Object) (context.Context, *fake.Clientset) { + cs := fake.NewSimpleClientset(objects...) + return context.WithValue(ctx, client.Key{}, cs), cs +} + +// Get extracts the Kubernetes client from the context. +func Get(ctx context.Context) *fake.Clientset { + untyped := ctx.Value(client.Key{}) + if untyped == nil { + logging.FromContext(ctx).Panic( + "Unable to fetch github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned/fake.Clientset from context.") + } + return untyped.(*fake.Clientset) +} diff --git a/pkg/client/resolution/injection/informers/factory/factory.go b/pkg/client/resolution/injection/informers/factory/factory.go new file mode 100644 index 00000000000..6d79983a441 --- /dev/null +++ b/pkg/client/resolution/injection/informers/factory/factory.go @@ -0,0 +1,56 @@ +/* +Copyright 2020 The Tekton 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 injection-gen. DO NOT EDIT. + +package factory + +import ( + context "context" + + externalversions "github.com/tektoncd/pipeline/pkg/client/resolution/informers/externalversions" + client "github.com/tektoncd/pipeline/pkg/client/resolution/injection/client" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" + logging "knative.dev/pkg/logging" +) + +func init() { + injection.Default.RegisterInformerFactory(withInformerFactory) +} + +// Key is used as the key for associating information with a context.Context. +type Key struct{} + +func withInformerFactory(ctx context.Context) context.Context { + c := client.Get(ctx) + opts := make([]externalversions.SharedInformerOption, 0, 1) + if injection.HasNamespaceScope(ctx) { + opts = append(opts, externalversions.WithNamespace(injection.GetNamespaceScope(ctx))) + } + return context.WithValue(ctx, Key{}, + externalversions.NewSharedInformerFactoryWithOptions(c, controller.GetResyncPeriod(ctx), opts...)) +} + +// Get extracts the InformerFactory from the context. +func Get(ctx context.Context) externalversions.SharedInformerFactory { + untyped := ctx.Value(Key{}) + if untyped == nil { + logging.FromContext(ctx).Panic( + "Unable to fetch github.com/tektoncd/pipeline/pkg/client/resolution/informers/externalversions.SharedInformerFactory from context.") + } + return untyped.(externalversions.SharedInformerFactory) +} diff --git a/pkg/client/resolution/injection/informers/factory/fake/fake.go b/pkg/client/resolution/injection/informers/factory/fake/fake.go new file mode 100644 index 00000000000..80d30060f9e --- /dev/null +++ b/pkg/client/resolution/injection/informers/factory/fake/fake.go @@ -0,0 +1,45 @@ +/* +Copyright 2020 The Tekton 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 injection-gen. DO NOT EDIT. + +package fake + +import ( + context "context" + + externalversions "github.com/tektoncd/pipeline/pkg/client/resolution/informers/externalversions" + fake "github.com/tektoncd/pipeline/pkg/client/resolution/injection/client/fake" + factory "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/factory" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" +) + +var Get = factory.Get + +func init() { + injection.Fake.RegisterInformerFactory(withInformerFactory) +} + +func withInformerFactory(ctx context.Context) context.Context { + c := fake.Get(ctx) + opts := make([]externalversions.SharedInformerOption, 0, 1) + if injection.HasNamespaceScope(ctx) { + opts = append(opts, externalversions.WithNamespace(injection.GetNamespaceScope(ctx))) + } + return context.WithValue(ctx, factory.Key{}, + externalversions.NewSharedInformerFactoryWithOptions(c, controller.GetResyncPeriod(ctx), opts...)) +} diff --git a/pkg/client/resolution/injection/informers/factory/filtered/fake/fake_filtered_factory.go b/pkg/client/resolution/injection/informers/factory/filtered/fake/fake_filtered_factory.go new file mode 100644 index 00000000000..4846176c6dd --- /dev/null +++ b/pkg/client/resolution/injection/informers/factory/filtered/fake/fake_filtered_factory.go @@ -0,0 +1,59 @@ +/* +Copyright 2020 The Tekton 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 injection-gen. DO NOT EDIT. + +package fakeFilteredFactory + +import ( + context "context" + + externalversions "github.com/tektoncd/pipeline/pkg/client/resolution/informers/externalversions" + fake "github.com/tektoncd/pipeline/pkg/client/resolution/injection/client/fake" + filtered "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/factory/filtered" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" + logging "knative.dev/pkg/logging" +) + +var Get = filtered.Get + +func init() { + injection.Fake.RegisterInformerFactory(withInformerFactory) +} + +func withInformerFactory(ctx context.Context) context.Context { + c := fake.Get(ctx) + untyped := ctx.Value(filtered.LabelKey{}) + if untyped == nil { + logging.FromContext(ctx).Panic( + "Unable to fetch labelkey from context.") + } + labelSelectors := untyped.([]string) + for _, selector := range labelSelectors { + opts := []externalversions.SharedInformerOption{} + if injection.HasNamespaceScope(ctx) { + opts = append(opts, externalversions.WithNamespace(injection.GetNamespaceScope(ctx))) + } + opts = append(opts, externalversions.WithTweakListOptions(func(l *v1.ListOptions) { + l.LabelSelector = selector + })) + ctx = context.WithValue(ctx, filtered.Key{Selector: selector}, + externalversions.NewSharedInformerFactoryWithOptions(c, controller.GetResyncPeriod(ctx), opts...)) + } + return ctx +} diff --git a/pkg/client/resolution/injection/informers/factory/filtered/filtered_factory.go b/pkg/client/resolution/injection/informers/factory/filtered/filtered_factory.go new file mode 100644 index 00000000000..312ed3adaf2 --- /dev/null +++ b/pkg/client/resolution/injection/informers/factory/filtered/filtered_factory.go @@ -0,0 +1,77 @@ +/* +Copyright 2020 The Tekton 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 injection-gen. DO NOT EDIT. + +package filteredFactory + +import ( + context "context" + + externalversions "github.com/tektoncd/pipeline/pkg/client/resolution/informers/externalversions" + client "github.com/tektoncd/pipeline/pkg/client/resolution/injection/client" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" + logging "knative.dev/pkg/logging" +) + +func init() { + injection.Default.RegisterInformerFactory(withInformerFactory) +} + +// Key is used as the key for associating information with a context.Context. +type Key struct { + Selector string +} + +type LabelKey struct{} + +func WithSelectors(ctx context.Context, selector ...string) context.Context { + return context.WithValue(ctx, LabelKey{}, selector) +} + +func withInformerFactory(ctx context.Context) context.Context { + c := client.Get(ctx) + untyped := ctx.Value(LabelKey{}) + if untyped == nil { + logging.FromContext(ctx).Panic( + "Unable to fetch labelkey from context.") + } + labelSelectors := untyped.([]string) + for _, selector := range labelSelectors { + opts := []externalversions.SharedInformerOption{} + if injection.HasNamespaceScope(ctx) { + opts = append(opts, externalversions.WithNamespace(injection.GetNamespaceScope(ctx))) + } + opts = append(opts, externalversions.WithTweakListOptions(func(l *v1.ListOptions) { + l.LabelSelector = selector + })) + ctx = context.WithValue(ctx, Key{Selector: selector}, + externalversions.NewSharedInformerFactoryWithOptions(c, controller.GetResyncPeriod(ctx), opts...)) + } + return ctx +} + +// Get extracts the InformerFactory from the context. +func Get(ctx context.Context, selector string) externalversions.SharedInformerFactory { + untyped := ctx.Value(Key{Selector: selector}) + if untyped == nil { + logging.FromContext(ctx).Panicf( + "Unable to fetch github.com/tektoncd/pipeline/pkg/client/resolution/informers/externalversions.SharedInformerFactory with selector %s from context.", selector) + } + return untyped.(externalversions.SharedInformerFactory) +} diff --git a/pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest/fake/fake.go b/pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest/fake/fake.go new file mode 100644 index 00000000000..8ebd3d0751b --- /dev/null +++ b/pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest/fake/fake.go @@ -0,0 +1,40 @@ +/* +Copyright 2020 The Tekton 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 injection-gen. DO NOT EDIT. + +package fake + +import ( + context "context" + + fake "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/factory/fake" + resolutionrequest "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" +) + +var Get = resolutionrequest.Get + +func init() { + injection.Fake.RegisterInformer(withInformer) +} + +func withInformer(ctx context.Context) (context.Context, controller.Informer) { + f := fake.Get(ctx) + inf := f.Resolution().V1alpha1().ResolutionRequests() + return context.WithValue(ctx, resolutionrequest.Key{}, inf), inf.Informer() +} diff --git a/pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest/filtered/fake/fake.go b/pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest/filtered/fake/fake.go new file mode 100644 index 00000000000..bfddcf35da4 --- /dev/null +++ b/pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest/filtered/fake/fake.go @@ -0,0 +1,52 @@ +/* +Copyright 2020 The Tekton 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 injection-gen. DO NOT EDIT. + +package fake + +import ( + context "context" + + factoryfiltered "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/factory/filtered" + filtered "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest/filtered" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" + logging "knative.dev/pkg/logging" +) + +var Get = filtered.Get + +func init() { + injection.Fake.RegisterFilteredInformers(withInformer) +} + +func withInformer(ctx context.Context) (context.Context, []controller.Informer) { + untyped := ctx.Value(factoryfiltered.LabelKey{}) + if untyped == nil { + logging.FromContext(ctx).Panic( + "Unable to fetch labelkey from context.") + } + labelSelectors := untyped.([]string) + infs := []controller.Informer{} + for _, selector := range labelSelectors { + f := factoryfiltered.Get(ctx, selector) + inf := f.Resolution().V1alpha1().ResolutionRequests() + ctx = context.WithValue(ctx, filtered.Key{Selector: selector}, inf) + infs = append(infs, inf.Informer()) + } + return ctx, infs +} diff --git a/pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest/filtered/resolutionrequest.go b/pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest/filtered/resolutionrequest.go new file mode 100644 index 00000000000..f4c067f1e07 --- /dev/null +++ b/pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest/filtered/resolutionrequest.go @@ -0,0 +1,136 @@ +/* +Copyright 2020 The Tekton 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 injection-gen. DO NOT EDIT. + +package filtered + +import ( + context "context" + + apisresolutionv1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + versioned "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned" + v1alpha1 "github.com/tektoncd/pipeline/pkg/client/resolution/informers/externalversions/resolution/v1alpha1" + client "github.com/tektoncd/pipeline/pkg/client/resolution/injection/client" + filtered "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/factory/filtered" + resolutionv1alpha1 "github.com/tektoncd/pipeline/pkg/client/resolution/listers/resolution/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + cache "k8s.io/client-go/tools/cache" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" + logging "knative.dev/pkg/logging" +) + +func init() { + injection.Default.RegisterFilteredInformers(withInformer) + injection.Dynamic.RegisterDynamicInformer(withDynamicInformer) +} + +// Key is used for associating the Informer inside the context.Context. +type Key struct { + Selector string +} + +func withInformer(ctx context.Context) (context.Context, []controller.Informer) { + untyped := ctx.Value(filtered.LabelKey{}) + if untyped == nil { + logging.FromContext(ctx).Panic( + "Unable to fetch labelkey from context.") + } + labelSelectors := untyped.([]string) + infs := []controller.Informer{} + for _, selector := range labelSelectors { + f := filtered.Get(ctx, selector) + inf := f.Resolution().V1alpha1().ResolutionRequests() + ctx = context.WithValue(ctx, Key{Selector: selector}, inf) + infs = append(infs, inf.Informer()) + } + return ctx, infs +} + +func withDynamicInformer(ctx context.Context) context.Context { + untyped := ctx.Value(filtered.LabelKey{}) + if untyped == nil { + logging.FromContext(ctx).Panic( + "Unable to fetch labelkey from context.") + } + labelSelectors := untyped.([]string) + for _, selector := range labelSelectors { + inf := &wrapper{client: client.Get(ctx), selector: selector} + ctx = context.WithValue(ctx, Key{Selector: selector}, inf) + } + return ctx +} + +// Get extracts the typed informer from the context. +func Get(ctx context.Context, selector string) v1alpha1.ResolutionRequestInformer { + untyped := ctx.Value(Key{Selector: selector}) + if untyped == nil { + logging.FromContext(ctx).Panicf( + "Unable to fetch github.com/tektoncd/pipeline/pkg/client/resolution/informers/externalversions/resolution/v1alpha1.ResolutionRequestInformer with selector %s from context.", selector) + } + return untyped.(v1alpha1.ResolutionRequestInformer) +} + +type wrapper struct { + client versioned.Interface + + namespace string + + selector string +} + +var _ v1alpha1.ResolutionRequestInformer = (*wrapper)(nil) +var _ resolutionv1alpha1.ResolutionRequestLister = (*wrapper)(nil) + +func (w *wrapper) Informer() cache.SharedIndexInformer { + return cache.NewSharedIndexInformer(nil, &apisresolutionv1alpha1.ResolutionRequest{}, 0, nil) +} + +func (w *wrapper) Lister() resolutionv1alpha1.ResolutionRequestLister { + return w +} + +func (w *wrapper) ResolutionRequests(namespace string) resolutionv1alpha1.ResolutionRequestNamespaceLister { + return &wrapper{client: w.client, namespace: namespace, selector: w.selector} +} + +func (w *wrapper) List(selector labels.Selector) (ret []*apisresolutionv1alpha1.ResolutionRequest, err error) { + reqs, err := labels.ParseToRequirements(w.selector) + if err != nil { + return nil, err + } + selector = selector.Add(reqs...) + lo, err := w.client.ResolutionV1alpha1().ResolutionRequests(w.namespace).List(context.TODO(), v1.ListOptions{ + LabelSelector: selector.String(), + // TODO(mattmoor): Incorporate resourceVersion bounds based on staleness criteria. + }) + if err != nil { + return nil, err + } + for idx := range lo.Items { + ret = append(ret, &lo.Items[idx]) + } + return ret, nil +} + +func (w *wrapper) Get(name string) (*apisresolutionv1alpha1.ResolutionRequest, error) { + // TODO(mattmoor): Check that the fetched object matches the selector. + return w.client.ResolutionV1alpha1().ResolutionRequests(w.namespace).Get(context.TODO(), name, v1.GetOptions{ + // TODO(mattmoor): Incorporate resourceVersion bounds based on staleness criteria. + }) +} diff --git a/pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest/resolutionrequest.go b/pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest/resolutionrequest.go new file mode 100644 index 00000000000..80c875420fc --- /dev/null +++ b/pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest/resolutionrequest.go @@ -0,0 +1,116 @@ +/* +Copyright 2020 The Tekton 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 injection-gen. DO NOT EDIT. + +package resolutionrequest + +import ( + context "context" + + apisresolutionv1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + versioned "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned" + v1alpha1 "github.com/tektoncd/pipeline/pkg/client/resolution/informers/externalversions/resolution/v1alpha1" + client "github.com/tektoncd/pipeline/pkg/client/resolution/injection/client" + factory "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/factory" + resolutionv1alpha1 "github.com/tektoncd/pipeline/pkg/client/resolution/listers/resolution/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + cache "k8s.io/client-go/tools/cache" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" + logging "knative.dev/pkg/logging" +) + +func init() { + injection.Default.RegisterInformer(withInformer) + injection.Dynamic.RegisterDynamicInformer(withDynamicInformer) +} + +// Key is used for associating the Informer inside the context.Context. +type Key struct{} + +func withInformer(ctx context.Context) (context.Context, controller.Informer) { + f := factory.Get(ctx) + inf := f.Resolution().V1alpha1().ResolutionRequests() + return context.WithValue(ctx, Key{}, inf), inf.Informer() +} + +func withDynamicInformer(ctx context.Context) context.Context { + inf := &wrapper{client: client.Get(ctx), resourceVersion: injection.GetResourceVersion(ctx)} + return context.WithValue(ctx, Key{}, inf) +} + +// Get extracts the typed informer from the context. +func Get(ctx context.Context) v1alpha1.ResolutionRequestInformer { + untyped := ctx.Value(Key{}) + if untyped == nil { + logging.FromContext(ctx).Panic( + "Unable to fetch github.com/tektoncd/pipeline/pkg/client/resolution/informers/externalversions/resolution/v1alpha1.ResolutionRequestInformer from context.") + } + return untyped.(v1alpha1.ResolutionRequestInformer) +} + +type wrapper struct { + client versioned.Interface + + namespace string + + resourceVersion string +} + +var _ v1alpha1.ResolutionRequestInformer = (*wrapper)(nil) +var _ resolutionv1alpha1.ResolutionRequestLister = (*wrapper)(nil) + +func (w *wrapper) Informer() cache.SharedIndexInformer { + return cache.NewSharedIndexInformer(nil, &apisresolutionv1alpha1.ResolutionRequest{}, 0, nil) +} + +func (w *wrapper) Lister() resolutionv1alpha1.ResolutionRequestLister { + return w +} + +func (w *wrapper) ResolutionRequests(namespace string) resolutionv1alpha1.ResolutionRequestNamespaceLister { + return &wrapper{client: w.client, namespace: namespace, resourceVersion: w.resourceVersion} +} + +// SetResourceVersion allows consumers to adjust the minimum resourceVersion +// used by the underlying client. It is not accessible via the standard +// lister interface, but can be accessed through a user-defined interface and +// an implementation check e.g. rvs, ok := foo.(ResourceVersionSetter) +func (w *wrapper) SetResourceVersion(resourceVersion string) { + w.resourceVersion = resourceVersion +} + +func (w *wrapper) List(selector labels.Selector) (ret []*apisresolutionv1alpha1.ResolutionRequest, err error) { + lo, err := w.client.ResolutionV1alpha1().ResolutionRequests(w.namespace).List(context.TODO(), v1.ListOptions{ + LabelSelector: selector.String(), + ResourceVersion: w.resourceVersion, + }) + if err != nil { + return nil, err + } + for idx := range lo.Items { + ret = append(ret, &lo.Items[idx]) + } + return ret, nil +} + +func (w *wrapper) Get(name string) (*apisresolutionv1alpha1.ResolutionRequest, error) { + return w.client.ResolutionV1alpha1().ResolutionRequests(w.namespace).Get(context.TODO(), name, v1.GetOptions{ + ResourceVersion: w.resourceVersion, + }) +} diff --git a/pkg/client/resolution/injection/reconciler/resolution/v1alpha1/resolutionrequest/controller.go b/pkg/client/resolution/injection/reconciler/resolution/v1alpha1/resolutionrequest/controller.go new file mode 100644 index 00000000000..ccd1eac169d --- /dev/null +++ b/pkg/client/resolution/injection/reconciler/resolution/v1alpha1/resolutionrequest/controller.go @@ -0,0 +1,162 @@ +/* +Copyright 2020 The Tekton 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 injection-gen. DO NOT EDIT. + +package resolutionrequest + +import ( + context "context" + fmt "fmt" + reflect "reflect" + strings "strings" + + versionedscheme "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned/scheme" + client "github.com/tektoncd/pipeline/pkg/client/resolution/injection/client" + resolutionrequest "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest" + zap "go.uber.org/zap" + corev1 "k8s.io/api/core/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + scheme "k8s.io/client-go/kubernetes/scheme" + v1 "k8s.io/client-go/kubernetes/typed/core/v1" + record "k8s.io/client-go/tools/record" + kubeclient "knative.dev/pkg/client/injection/kube/client" + controller "knative.dev/pkg/controller" + logging "knative.dev/pkg/logging" + logkey "knative.dev/pkg/logging/logkey" + reconciler "knative.dev/pkg/reconciler" +) + +const ( + defaultControllerAgentName = "resolutionrequest-controller" + defaultFinalizerName = "resolutionrequests.resolution.tekton.dev" +) + +// NewImpl returns a controller.Impl that handles queuing and feeding work from +// the queue through an implementation of controller.Reconciler, delegating to +// the provided Interface and optional Finalizer methods. OptionsFn is used to return +// controller.ControllerOptions to be used by the internal reconciler. +func NewImpl(ctx context.Context, r Interface, optionsFns ...controller.OptionsFn) *controller.Impl { + logger := logging.FromContext(ctx) + + // Check the options function input. It should be 0 or 1. + if len(optionsFns) > 1 { + logger.Fatal("Up to one options function is supported, found: ", len(optionsFns)) + } + + resolutionrequestInformer := resolutionrequest.Get(ctx) + + lister := resolutionrequestInformer.Lister() + + var promoteFilterFunc func(obj interface{}) bool + + rec := &reconcilerImpl{ + LeaderAwareFuncs: reconciler.LeaderAwareFuncs{ + PromoteFunc: func(bkt reconciler.Bucket, enq func(reconciler.Bucket, types.NamespacedName)) error { + all, err := lister.List(labels.Everything()) + if err != nil { + return err + } + for _, elt := range all { + if promoteFilterFunc != nil { + if ok := promoteFilterFunc(elt); !ok { + continue + } + } + enq(bkt, types.NamespacedName{ + Namespace: elt.GetNamespace(), + Name: elt.GetName(), + }) + } + return nil + }, + }, + Client: client.Get(ctx), + Lister: lister, + reconciler: r, + finalizerName: defaultFinalizerName, + } + + ctrType := reflect.TypeOf(r).Elem() + ctrTypeName := fmt.Sprintf("%s.%s", ctrType.PkgPath(), ctrType.Name()) + ctrTypeName = strings.ReplaceAll(ctrTypeName, "/", ".") + + logger = logger.With( + zap.String(logkey.ControllerType, ctrTypeName), + zap.String(logkey.Kind, "resolution.tekton.dev.ResolutionRequest"), + ) + + impl := controller.NewContext(ctx, rec, controller.ControllerOptions{WorkQueueName: ctrTypeName, Logger: logger}) + agentName := defaultControllerAgentName + + // Pass impl to the options. Save any optional results. + for _, fn := range optionsFns { + opts := fn(impl) + if opts.ConfigStore != nil { + rec.configStore = opts.ConfigStore + } + if opts.FinalizerName != "" { + rec.finalizerName = opts.FinalizerName + } + if opts.AgentName != "" { + agentName = opts.AgentName + } + if opts.SkipStatusUpdates { + rec.skipStatusUpdates = true + } + if opts.DemoteFunc != nil { + rec.DemoteFunc = opts.DemoteFunc + } + if opts.PromoteFilterFunc != nil { + promoteFilterFunc = opts.PromoteFilterFunc + } + } + + rec.Recorder = createRecorder(ctx, agentName) + + return impl +} + +func createRecorder(ctx context.Context, agentName string) record.EventRecorder { + logger := logging.FromContext(ctx) + + recorder := controller.GetEventRecorder(ctx) + if recorder == nil { + // Create event broadcaster + logger.Debug("Creating event broadcaster") + eventBroadcaster := record.NewBroadcaster() + watches := []watch.Interface{ + eventBroadcaster.StartLogging(logger.Named("event-broadcaster").Infof), + eventBroadcaster.StartRecordingToSink( + &v1.EventSinkImpl{Interface: kubeclient.Get(ctx).CoreV1().Events("")}), + } + recorder = eventBroadcaster.NewRecorder(scheme.Scheme, corev1.EventSource{Component: agentName}) + go func() { + <-ctx.Done() + for _, w := range watches { + w.Stop() + } + }() + } + + return recorder +} + +func init() { + versionedscheme.AddToScheme(scheme.Scheme) +} diff --git a/pkg/client/resolution/injection/reconciler/resolution/v1alpha1/resolutionrequest/reconciler.go b/pkg/client/resolution/injection/reconciler/resolution/v1alpha1/resolutionrequest/reconciler.go new file mode 100644 index 00000000000..87610ebeac7 --- /dev/null +++ b/pkg/client/resolution/injection/reconciler/resolution/v1alpha1/resolutionrequest/reconciler.go @@ -0,0 +1,450 @@ +/* +Copyright 2020 The Tekton 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 injection-gen. DO NOT EDIT. + +package resolutionrequest + +import ( + context "context" + json "encoding/json" + fmt "fmt" + + v1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + versioned "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned" + resolutionv1alpha1 "github.com/tektoncd/pipeline/pkg/client/resolution/listers/resolution/v1alpha1" + zap "go.uber.org/zap" + v1 "k8s.io/api/core/v1" + equality "k8s.io/apimachinery/pkg/api/equality" + errors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + sets "k8s.io/apimachinery/pkg/util/sets" + record "k8s.io/client-go/tools/record" + controller "knative.dev/pkg/controller" + kmp "knative.dev/pkg/kmp" + logging "knative.dev/pkg/logging" + reconciler "knative.dev/pkg/reconciler" +) + +// Interface defines the strongly typed interfaces to be implemented by a +// controller reconciling v1alpha1.ResolutionRequest. +type Interface interface { + // ReconcileKind implements custom logic to reconcile v1alpha1.ResolutionRequest. Any changes + // to the objects .Status or .Finalizers will be propagated to the stored + // object. It is recommended that implementors do not call any update calls + // for the Kind inside of ReconcileKind, it is the responsibility of the calling + // controller to propagate those properties. The resource passed to ReconcileKind + // will always have an empty deletion timestamp. + ReconcileKind(ctx context.Context, o *v1alpha1.ResolutionRequest) reconciler.Event +} + +// Finalizer defines the strongly typed interfaces to be implemented by a +// controller finalizing v1alpha1.ResolutionRequest. +type Finalizer interface { + // FinalizeKind implements custom logic to finalize v1alpha1.ResolutionRequest. Any changes + // to the objects .Status or .Finalizers will be ignored. Returning a nil or + // Normal type reconciler.Event will allow the finalizer to be deleted on + // the resource. The resource passed to FinalizeKind will always have a set + // deletion timestamp. + FinalizeKind(ctx context.Context, o *v1alpha1.ResolutionRequest) reconciler.Event +} + +// ReadOnlyInterface defines the strongly typed interfaces to be implemented by a +// controller reconciling v1alpha1.ResolutionRequest if they want to process resources for which +// they are not the leader. +type ReadOnlyInterface interface { + // ObserveKind implements logic to observe v1alpha1.ResolutionRequest. + // This method should not write to the API. + ObserveKind(ctx context.Context, o *v1alpha1.ResolutionRequest) reconciler.Event +} + +type doReconcile func(ctx context.Context, o *v1alpha1.ResolutionRequest) reconciler.Event + +// reconcilerImpl implements controller.Reconciler for v1alpha1.ResolutionRequest resources. +type reconcilerImpl struct { + // LeaderAwareFuncs is inlined to help us implement reconciler.LeaderAware. + reconciler.LeaderAwareFuncs + + // Client is used to write back status updates. + Client versioned.Interface + + // Listers index properties about resources. + Lister resolutionv1alpha1.ResolutionRequestLister + + // Recorder is an event recorder for recording Event resources to the + // Kubernetes API. + Recorder record.EventRecorder + + // configStore allows for decorating a context with config maps. + // +optional + configStore reconciler.ConfigStore + + // reconciler is the implementation of the business logic of the resource. + reconciler Interface + + // finalizerName is the name of the finalizer to reconcile. + finalizerName string + + // skipStatusUpdates configures whether or not this reconciler automatically updates + // the status of the reconciled resource. + skipStatusUpdates bool +} + +// Check that our Reconciler implements controller.Reconciler. +var _ controller.Reconciler = (*reconcilerImpl)(nil) + +// Check that our generated Reconciler is always LeaderAware. +var _ reconciler.LeaderAware = (*reconcilerImpl)(nil) + +func NewReconciler(ctx context.Context, logger *zap.SugaredLogger, client versioned.Interface, lister resolutionv1alpha1.ResolutionRequestLister, recorder record.EventRecorder, r Interface, options ...controller.Options) controller.Reconciler { + // Check the options function input. It should be 0 or 1. + if len(options) > 1 { + logger.Fatal("Up to one options struct is supported, found: ", len(options)) + } + + // Fail fast when users inadvertently implement the other LeaderAware interface. + // For the typed reconcilers, Promote shouldn't take any arguments. + if _, ok := r.(reconciler.LeaderAware); ok { + logger.Fatalf("%T implements the incorrect LeaderAware interface. Promote() should not take an argument as genreconciler handles the enqueuing automatically.", r) + } + + rec := &reconcilerImpl{ + LeaderAwareFuncs: reconciler.LeaderAwareFuncs{ + PromoteFunc: func(bkt reconciler.Bucket, enq func(reconciler.Bucket, types.NamespacedName)) error { + all, err := lister.List(labels.Everything()) + if err != nil { + return err + } + for _, elt := range all { + // TODO: Consider letting users specify a filter in options. + enq(bkt, types.NamespacedName{ + Namespace: elt.GetNamespace(), + Name: elt.GetName(), + }) + } + return nil + }, + }, + Client: client, + Lister: lister, + Recorder: recorder, + reconciler: r, + finalizerName: defaultFinalizerName, + } + + for _, opts := range options { + if opts.ConfigStore != nil { + rec.configStore = opts.ConfigStore + } + if opts.FinalizerName != "" { + rec.finalizerName = opts.FinalizerName + } + if opts.SkipStatusUpdates { + rec.skipStatusUpdates = true + } + if opts.DemoteFunc != nil { + rec.DemoteFunc = opts.DemoteFunc + } + } + + return rec +} + +// Reconcile implements controller.Reconciler +func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { + logger := logging.FromContext(ctx) + + // Initialize the reconciler state. This will convert the namespace/name + // string into a distinct namespace and name, determine if this instance of + // the reconciler is the leader, and any additional interfaces implemented + // by the reconciler. Returns an error is the resource key is invalid. + s, err := newState(key, r) + if err != nil { + logger.Error("Invalid resource key: ", key) + return nil + } + + // If we are not the leader, and we don't implement either ReadOnly + // observer interfaces, then take a fast-path out. + if s.isNotLeaderNorObserver() { + return controller.NewSkipKey(key) + } + + // If configStore is set, attach the frozen configuration to the context. + if r.configStore != nil { + ctx = r.configStore.ToContext(ctx) + } + + // Add the recorder to context. + ctx = controller.WithEventRecorder(ctx, r.Recorder) + + // Get the resource with this namespace/name. + + getter := r.Lister.ResolutionRequests(s.namespace) + + original, err := getter.Get(s.name) + + if errors.IsNotFound(err) { + // The resource may no longer exist, in which case we stop processing and call + // the ObserveDeletion handler if appropriate. + logger.Debugf("Resource %q no longer exists", key) + if del, ok := r.reconciler.(reconciler.OnDeletionInterface); ok { + return del.ObserveDeletion(ctx, types.NamespacedName{ + Namespace: s.namespace, + Name: s.name, + }) + } + return nil + } else if err != nil { + return err + } + + // Don't modify the informers copy. + resource := original.DeepCopy() + + var reconcileEvent reconciler.Event + + name, do := s.reconcileMethodFor(resource) + // Append the target method to the logger. + logger = logger.With(zap.String("targetMethod", name)) + switch name { + case reconciler.DoReconcileKind: + // Set and update the finalizer on resource if r.reconciler + // implements Finalizer. + if resource, err = r.setFinalizerIfFinalizer(ctx, resource); err != nil { + return fmt.Errorf("failed to set finalizers: %w", err) + } + + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } + + // Reconcile this copy of the resource and then write back any status + // updates regardless of whether the reconciliation errored out. + reconcileEvent = do(ctx, resource) + + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } + + case reconciler.DoFinalizeKind: + // For finalizing reconcilers, if this resource being marked for deletion + // and reconciled cleanly (nil or normal event), remove the finalizer. + reconcileEvent = do(ctx, resource) + + if resource, err = r.clearFinalizer(ctx, resource, reconcileEvent); err != nil { + return fmt.Errorf("failed to clear finalizers: %w", err) + } + + case reconciler.DoObserveKind: + // Observe any changes to this resource, since we are not the leader. + reconcileEvent = do(ctx, resource) + + } + + // Synchronize the status. + switch { + case r.skipStatusUpdates: + // This reconciler implementation is configured to skip resource updates. + // This may mean this reconciler does not observe spec, but reconciles external changes. + case equality.Semantic.DeepEqual(original.Status, resource.Status): + // If we didn't change anything then don't call updateStatus. + // This is important because the copy we loaded from the injectionInformer's + // cache may be stale and we don't want to overwrite a prior update + // to status with this stale state. + case !s.isLeader: + // High-availability reconcilers may have many replicas watching the resource, but only + // the elected leader is expected to write modifications. + logger.Warn("Saw status changes when we aren't the leader!") + default: + if err = r.updateStatus(ctx, original, resource); err != nil { + logger.Warnw("Failed to update resource status", zap.Error(err)) + r.Recorder.Eventf(resource, v1.EventTypeWarning, "UpdateFailed", + "Failed to update status for %q: %v", resource.Name, err) + return err + } + } + + // Report the reconciler event, if any. + if reconcileEvent != nil { + var event *reconciler.ReconcilerEvent + if reconciler.EventAs(reconcileEvent, &event) { + logger.Infow("Returned an event", zap.Any("event", reconcileEvent)) + r.Recorder.Event(resource, event.EventType, event.Reason, event.Error()) + + // the event was wrapped inside an error, consider the reconciliation as failed + if _, isEvent := reconcileEvent.(*reconciler.ReconcilerEvent); !isEvent { + return reconcileEvent + } + return nil + } + + if controller.IsSkipKey(reconcileEvent) { + // This is a wrapped error, don't emit an event. + } else if ok, _ := controller.IsRequeueKey(reconcileEvent); ok { + // This is a wrapped error, don't emit an event. + } else { + logger.Errorw("Returned an error", zap.Error(reconcileEvent)) + r.Recorder.Event(resource, v1.EventTypeWarning, "InternalError", reconcileEvent.Error()) + } + return reconcileEvent + } + + return nil +} + +func (r *reconcilerImpl) updateStatus(ctx context.Context, existing *v1alpha1.ResolutionRequest, desired *v1alpha1.ResolutionRequest) error { + existing = existing.DeepCopy() + return reconciler.RetryUpdateConflicts(func(attempts int) (err error) { + // The first iteration tries to use the injectionInformer's state, subsequent attempts fetch the latest state via API. + if attempts > 0 { + + getter := r.Client.ResolutionV1alpha1().ResolutionRequests(desired.Namespace) + + existing, err = getter.Get(ctx, desired.Name, metav1.GetOptions{}) + if err != nil { + return err + } + } + + // If there's nothing to update, just return. + if equality.Semantic.DeepEqual(existing.Status, desired.Status) { + return nil + } + + if diff, err := kmp.SafeDiff(existing.Status, desired.Status); err == nil && diff != "" { + logging.FromContext(ctx).Debug("Updating status with: ", diff) + } + + existing.Status = desired.Status + + updater := r.Client.ResolutionV1alpha1().ResolutionRequests(existing.Namespace) + + _, err = updater.UpdateStatus(ctx, existing, metav1.UpdateOptions{}) + return err + }) +} + +// updateFinalizersFiltered will update the Finalizers of the resource. +// TODO: this method could be generic and sync all finalizers. For now it only +// updates defaultFinalizerName or its override. +func (r *reconcilerImpl) updateFinalizersFiltered(ctx context.Context, resource *v1alpha1.ResolutionRequest) (*v1alpha1.ResolutionRequest, error) { + + getter := r.Lister.ResolutionRequests(resource.Namespace) + + actual, err := getter.Get(resource.Name) + if err != nil { + return resource, err + } + + // Don't modify the informers copy. + existing := actual.DeepCopy() + + var finalizers []string + + // If there's nothing to update, just return. + existingFinalizers := sets.NewString(existing.Finalizers...) + desiredFinalizers := sets.NewString(resource.Finalizers...) + + if desiredFinalizers.Has(r.finalizerName) { + if existingFinalizers.Has(r.finalizerName) { + // Nothing to do. + return resource, nil + } + // Add the finalizer. + finalizers = append(existing.Finalizers, r.finalizerName) + } else { + if !existingFinalizers.Has(r.finalizerName) { + // Nothing to do. + return resource, nil + } + // Remove the finalizer. + existingFinalizers.Delete(r.finalizerName) + finalizers = existingFinalizers.List() + } + + mergePatch := map[string]interface{}{ + "metadata": map[string]interface{}{ + "finalizers": finalizers, + "resourceVersion": existing.ResourceVersion, + }, + } + + patch, err := json.Marshal(mergePatch) + if err != nil { + return resource, err + } + + patcher := r.Client.ResolutionV1alpha1().ResolutionRequests(resource.Namespace) + + resourceName := resource.Name + updated, err := patcher.Patch(ctx, resourceName, types.MergePatchType, patch, metav1.PatchOptions{}) + if err != nil { + r.Recorder.Eventf(existing, v1.EventTypeWarning, "FinalizerUpdateFailed", + "Failed to update finalizers for %q: %v", resourceName, err) + } else { + r.Recorder.Eventf(updated, v1.EventTypeNormal, "FinalizerUpdate", + "Updated %q finalizers", resource.GetName()) + } + return updated, err +} + +func (r *reconcilerImpl) setFinalizerIfFinalizer(ctx context.Context, resource *v1alpha1.ResolutionRequest) (*v1alpha1.ResolutionRequest, error) { + if _, ok := r.reconciler.(Finalizer); !ok { + return resource, nil + } + + finalizers := sets.NewString(resource.Finalizers...) + + // If this resource is not being deleted, mark the finalizer. + if resource.GetDeletionTimestamp().IsZero() { + finalizers.Insert(r.finalizerName) + } + + resource.Finalizers = finalizers.List() + + // Synchronize the finalizers filtered by r.finalizerName. + return r.updateFinalizersFiltered(ctx, resource) +} + +func (r *reconcilerImpl) clearFinalizer(ctx context.Context, resource *v1alpha1.ResolutionRequest, reconcileEvent reconciler.Event) (*v1alpha1.ResolutionRequest, error) { + if _, ok := r.reconciler.(Finalizer); !ok { + return resource, nil + } + if resource.GetDeletionTimestamp().IsZero() { + return resource, nil + } + + finalizers := sets.NewString(resource.Finalizers...) + + if reconcileEvent != nil { + var event *reconciler.ReconcilerEvent + if reconciler.EventAs(reconcileEvent, &event) { + if event.EventType == v1.EventTypeNormal { + finalizers.Delete(r.finalizerName) + } + } + } else { + finalizers.Delete(r.finalizerName) + } + + resource.Finalizers = finalizers.List() + + // Synchronize the finalizers filtered by r.finalizerName. + return r.updateFinalizersFiltered(ctx, resource) +} diff --git a/pkg/client/resolution/injection/reconciler/resolution/v1alpha1/resolutionrequest/state.go b/pkg/client/resolution/injection/reconciler/resolution/v1alpha1/resolutionrequest/state.go new file mode 100644 index 00000000000..40beea23828 --- /dev/null +++ b/pkg/client/resolution/injection/reconciler/resolution/v1alpha1/resolutionrequest/state.go @@ -0,0 +1,97 @@ +/* +Copyright 2020 The Tekton 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 injection-gen. DO NOT EDIT. + +package resolutionrequest + +import ( + fmt "fmt" + + v1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + types "k8s.io/apimachinery/pkg/types" + cache "k8s.io/client-go/tools/cache" + reconciler "knative.dev/pkg/reconciler" +) + +// state is used to track the state of a reconciler in a single run. +type state struct { + // key is the original reconciliation key from the queue. + key string + // namespace is the namespace split from the reconciliation key. + namespace string + // name is the name split from the reconciliation key. + name string + // reconciler is the reconciler. + reconciler Interface + // roi is the read only interface cast of the reconciler. + roi ReadOnlyInterface + // isROI (Read Only Interface) the reconciler only observes reconciliation. + isROI bool + // isLeader the instance of the reconciler is the elected leader. + isLeader bool +} + +func newState(key string, r *reconcilerImpl) (*state, error) { + // Convert the namespace/name string into a distinct namespace and name. + namespace, name, err := cache.SplitMetaNamespaceKey(key) + if err != nil { + return nil, fmt.Errorf("invalid resource key: %s", key) + } + + roi, isROI := r.reconciler.(ReadOnlyInterface) + + isLeader := r.IsLeaderFor(types.NamespacedName{ + Namespace: namespace, + Name: name, + }) + + return &state{ + key: key, + namespace: namespace, + name: name, + reconciler: r.reconciler, + roi: roi, + isROI: isROI, + isLeader: isLeader, + }, nil +} + +// isNotLeaderNorObserver checks to see if this reconciler with the current +// state is enabled to do any work or not. +// isNotLeaderNorObserver returns true when there is no work possible for the +// reconciler. +func (s *state) isNotLeaderNorObserver() bool { + if !s.isLeader && !s.isROI { + // If we are not the leader, and we don't implement the ReadOnly + // interface, then take a fast-path out. + return true + } + return false +} + +func (s *state) reconcileMethodFor(o *v1alpha1.ResolutionRequest) (string, doReconcile) { + if o.GetDeletionTimestamp().IsZero() { + if s.isLeader { + return reconciler.DoReconcileKind, s.reconciler.ReconcileKind + } else if s.isROI { + return reconciler.DoObserveKind, s.roi.ObserveKind + } + } else if fin, ok := s.reconciler.(Finalizer); s.isLeader && ok { + return reconciler.DoFinalizeKind, fin.FinalizeKind + } + return "unknown", nil +} diff --git a/pkg/client/resolution/listers/resolution/v1alpha1/expansion_generated.go b/pkg/client/resolution/listers/resolution/v1alpha1/expansion_generated.go new file mode 100644 index 00000000000..23cfdaadc84 --- /dev/null +++ b/pkg/client/resolution/listers/resolution/v1alpha1/expansion_generated.go @@ -0,0 +1,27 @@ +/* +Copyright 2020 The Tekton 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 + +// ResolutionRequestListerExpansion allows custom methods to be added to +// ResolutionRequestLister. +type ResolutionRequestListerExpansion interface{} + +// ResolutionRequestNamespaceListerExpansion allows custom methods to be added to +// ResolutionRequestNamespaceLister. +type ResolutionRequestNamespaceListerExpansion interface{} diff --git a/pkg/client/resolution/listers/resolution/v1alpha1/resolutionrequest.go b/pkg/client/resolution/listers/resolution/v1alpha1/resolutionrequest.go new file mode 100644 index 00000000000..648ce7c6dc8 --- /dev/null +++ b/pkg/client/resolution/listers/resolution/v1alpha1/resolutionrequest.go @@ -0,0 +1,99 @@ +/* +Copyright 2020 The Tekton Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ResolutionRequestLister helps list ResolutionRequests. +// All objects returned here must be treated as read-only. +type ResolutionRequestLister interface { + // List lists all ResolutionRequests in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.ResolutionRequest, err error) + // ResolutionRequests returns an object that can list and get ResolutionRequests. + ResolutionRequests(namespace string) ResolutionRequestNamespaceLister + ResolutionRequestListerExpansion +} + +// resolutionRequestLister implements the ResolutionRequestLister interface. +type resolutionRequestLister struct { + indexer cache.Indexer +} + +// NewResolutionRequestLister returns a new ResolutionRequestLister. +func NewResolutionRequestLister(indexer cache.Indexer) ResolutionRequestLister { + return &resolutionRequestLister{indexer: indexer} +} + +// List lists all ResolutionRequests in the indexer. +func (s *resolutionRequestLister) List(selector labels.Selector) (ret []*v1alpha1.ResolutionRequest, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.ResolutionRequest)) + }) + return ret, err +} + +// ResolutionRequests returns an object that can list and get ResolutionRequests. +func (s *resolutionRequestLister) ResolutionRequests(namespace string) ResolutionRequestNamespaceLister { + return resolutionRequestNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ResolutionRequestNamespaceLister helps list and get ResolutionRequests. +// All objects returned here must be treated as read-only. +type ResolutionRequestNamespaceLister interface { + // List lists all ResolutionRequests in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.ResolutionRequest, err error) + // Get retrieves the ResolutionRequest from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.ResolutionRequest, error) + ResolutionRequestNamespaceListerExpansion +} + +// resolutionRequestNamespaceLister implements the ResolutionRequestNamespaceLister +// interface. +type resolutionRequestNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all ResolutionRequests in the indexer for a given namespace. +func (s resolutionRequestNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.ResolutionRequest, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.ResolutionRequest)) + }) + return ret, err +} + +// Get retrieves the ResolutionRequest from the indexer for a given namespace and name. +func (s resolutionRequestNamespaceLister) Get(name string) (*v1alpha1.ResolutionRequest, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("resolutionrequest"), name) + } + return obj.(*v1alpha1.ResolutionRequest), nil +} diff --git a/pkg/reconciler/pipelinerun/pipelinerun_test.go b/pkg/reconciler/pipelinerun/pipelinerun_test.go index b02a0ec8bad..ac3350b4ed4 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun_test.go +++ b/pkg/reconciler/pipelinerun/pipelinerun_test.go @@ -7650,6 +7650,9 @@ spec: - name: some-task taskRef: resolver: foobar + params: + - name: foo + value: bar serviceAccountName: default `) @@ -7685,6 +7688,9 @@ spec: if resolutionRequestType != resolverName { t.Fatalf("expected resource request type %q but saw %q", resolutionRequestType, resolverName) } + if resreq.Spec.Parameters["foo"] != "bar" { + t.Fatalf("expected resource request parameter 'bar', but got '%s'", resreq.Spec.Parameters["foo"]) + } taskBytes := []byte(` kind: Task diff --git a/pkg/reconciler/pipelinerun/pipelinespec/pipelinespec_test.go b/pkg/reconciler/pipelinerun/pipelinespec/pipelinespec_test.go index 57e37e0caed..289f3ef0a80 100644 --- a/pkg/reconciler/pipelinerun/pipelinespec/pipelinespec_test.go +++ b/pkg/reconciler/pipelinerun/pipelinespec/pipelinespec_test.go @@ -126,9 +126,12 @@ func TestGetPipelineData_ResolutionSuccess(t *testing.T) { PipelineRef: &v1beta1.PipelineRef{ ResolverRef: v1beta1.ResolverRef{ Resolver: "foo", - Resource: []v1beta1.ResolverParam{{ - Name: "bar", - Value: "baz", + Params: []v1beta1.Param{{ + Name: "bar", + Value: v1beta1.ParamValue{ + Type: v1beta1.ParamTypeString, + StringVal: "baz", + }, }}, }, }, diff --git a/pkg/reconciler/pipelinerun/resources/pipelineref.go b/pkg/reconciler/pipelinerun/resources/pipelineref.go index 8ebb89f9f2e..70405eb2983 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelineref.go +++ b/pkg/reconciler/pipelinerun/resources/pipelineref.go @@ -73,8 +73,9 @@ func GetPipelineFunc(ctx context.Context, k8s kubernetes.Interface, tekton clien case cfg.FeatureFlags.EnableAPIFields == config.AlphaAPIFields && pr != nil && pr.Resolver != "" && requester != nil: return func(ctx context.Context, name string) (v1beta1.PipelineObject, error) { params := map[string]string{} - for _, p := range pr.Resource { - params[p.Name] = p.Value + for _, p := range pr.Params { + // TODO(abayer): This will be changed to pass p.Value directly once we switch the reconciler over to the new resolution code + params[p.Name] = p.Value.StringVal } resolver := resolution.NewResolver(requester, pipelineRun, string(pr.Resolver), "", "", params) return resolvePipeline(ctx, resolver, name) diff --git a/pkg/reconciler/taskrun/resources/taskref.go b/pkg/reconciler/taskrun/resources/taskref.go index 35c1f6612d6..8f38daa11d0 100644 --- a/pkg/reconciler/taskrun/resources/taskref.go +++ b/pkg/reconciler/taskrun/resources/taskref.go @@ -105,11 +105,11 @@ func GetTaskFunc(ctx context.Context, k8s kubernetes.Interface, tekton clientset // casting it to a TaskObject. return func(ctx context.Context, name string) (v1beta1.TaskObject, error) { params := map[string]string{} - for _, p := range tr.Resource { - params[p.Name] = p.Value + for _, p := range tr.Params { + // TODO(abayer): This will be changed to pass p.Value directly once we switch the reconciler over to the new resolution code + params[p.Name] = p.Value.StringVal } resolver := resolution.NewResolver(requester, owner, string(tr.Resolver), trName, namespace, params) - return resolveTask(ctx, resolver, name, kind) }, nil diff --git a/pkg/reconciler/taskrun/resources/taskspec_test.go b/pkg/reconciler/taskrun/resources/taskspec_test.go index 6c64b6d8078..deb68382d64 100644 --- a/pkg/reconciler/taskrun/resources/taskspec_test.go +++ b/pkg/reconciler/taskrun/resources/taskspec_test.go @@ -140,9 +140,12 @@ func TestGetTaskData_ResolutionSuccess(t *testing.T) { TaskRef: &v1beta1.TaskRef{ ResolverRef: v1beta1.ResolverRef{ Resolver: "foo", - Resource: []v1beta1.ResolverParam{{ - Name: "bar", - Value: "baz", + Params: []v1beta1.Param{{ + Name: "bar", + Value: v1beta1.ParamValue{ + Type: v1beta1.ParamTypeString, + StringVal: "baz", + }, }}, }, },