tektoncd / pipeline

A cloud-native Pipeline resource.
https://tekton.dev
Apache License 2.0
8.51k stars 1.78k forks source link

Allow resourceSpec within Pipeline definitions #2284

Closed adrianriobo closed 4 years ago

adrianriobo commented 4 years ago

Expected Behavior

Allow using resourceSpec within pipeline definitions. The use case is related to runtime params, it is expected to use as a task input resource (git) with a parameter resulting from a previous task within the pipeline.

Example:

---
apiVersion: tekton.dev/v1alpha1
kind: Pipeline
metadata:
  name: pipeline-dev
spec:
  ...
  tasks:
    - name: get-servingrepository
      taskRef:
        name: get-servingrepository
      resources:
        inputs:
          - name: repository
            resource: source-repository
    - name: deploy-to-develop
      taskRef:
        name: kubectl-exec
      runAfter: ["get-servingrepository" , "build-and-push-image"]
      params:
        - name: kubectl-args
          value: ["apply", "-f", ".", "-n", "dev"]
      resources:
        inputs:
          - name: repository
            resourceSpec:
               type: git
               params:
                 - name: revision
                   value: develop
                 - name: url
                   value: $(tasks.get-servingrepository.results.serving-repository)

Actual Behavior

Get an error when creating the pipeline:

Error from server (InternalError): error when creating "pipeline/pipeline-dev_no_func.yaml": Internal error occurred: admission webhook "webhook.tekton.dev" denied the request: mutation failed: cannot decode incoming new object: json: unknown field "resourceSpec"

Additional Info

ghost commented 4 years ago

Just wanted to clarify :- you are able to use a resourceSpec directly in your PipelineRuns, and I believe you should be able to refer to task results in the param values that you feed to a Pipeline Task from the PipelineRun.

I'm not 100% clear on the use case for putting a resourceSpec directly into a Pipeline. Could you describe a bit more the problem you're trying to solve?

adrianriobo commented 4 years ago

Hi @sbwsg sorry for the late reply... just let me try to explain my use case;

First, just clarify I am using tekton triggers to integrate github + tekton, so pipelineruns are managed by triggers and I just can play with paremeters in the request. to template the pipeline...

Got 1 project with my source code for my app: https://github.com/org/app/source-code.git Got 1 project with serving file for my app: https://github.com/org/app/serving.git

I configured the webhook at source code project, so it will be executed on every push there...

My pipeline just: build code, build the image, push the image and finally deploy... to deploy it is required to clone the serving project (which contains the manifests)....

Binding parameters with triggers does not support any kind of string manipulation...so I can not get the url of the serving project.

With my previous example I can use the source code project url ... do some manipulation (one task) and then use it as input in other task, specially convenient as git resource. But to do this approach I require this resourceSpec at Pipeline definition.

Hope this helps to understand, please let me know if you have any other suggestions.

adrianriobo commented 4 years ago

Just found this and this issue regarding not promoting pipeline resources to beta so a task equivalence is released...

This will fit totally in my use case, so maybe there is no point to evolve pipeline resources

tekton-robot commented 4 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with /close.

/lifecycle stale

Send feedback to tektoncd/plumbing.

tekton-robot commented 4 years ago

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity. If this issue is safe to close now please do so with /close.

/lifecycle rotten

Send feedback to tektoncd/plumbing.

tekton-robot commented 4 years ago

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

/close

Send feedback to tektoncd/plumbing.

tekton-robot commented 4 years ago

@tekton-robot: Closing this issue.

In response to [this](https://github.com/tektoncd/pipeline/issues/2284#issuecomment-673696027): >Rotten issues close after 30d of inactivity. >Reopen the issue with `/reopen`. >Mark the issue as fresh with `/remove-lifecycle rotten`. > >/close > >Send feedback to [tektoncd/plumbing](https://github.com/tektoncd/plumbing). Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.