-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow Resources to be Optional in Task, ClusterTask, and Condition #1601
Conversation
/wip |
The following is the coverage report on pkg/.
|
Hey Priti, thanks for this change! Is there an issue or design doc to describe the motivations for this change? It seems useful but I want to make sure we've thought through some of the use cases and new error scenariros before we add this to the API There's also a bit of work going on in the PipelineResources space at the moment, so this change might be easier to land after that dust has settled. Is there a particular use case you're trying to support, and how soon do you need it? |
hey @imjasonh, sorry forgot to link the GitHub issue #812 and Design Doc, yup the motivation is included in there ... |
7d0df85
to
256c8f6
Compare
The following is the coverage report on pkg/.
|
256c8f6
to
f18866e
Compare
The following is the coverage report on pkg/.
|
f18866e
to
338e68e
Compare
The following is the coverage report on pkg/.
|
338e68e
to
0980ceb
Compare
The following is the coverage report on pkg/.
|
0980ceb
to
93a00f6
Compare
93a00f6
to
6c6cbce
Compare
The following is the coverage report on pkg/.
|
The following is the coverage report on pkg/.
|
6c6cbce
to
fd53501
Compare
The following is the coverage report on pkg/.
|
its ready for review now ... Please let me know if there are any changes needed 😄 |
examples/pipelineruns/conditional-pipelinerun-with-optional-resources.yaml
Outdated
Show resolved
Hide resolved
It would be great to add some doc updates here as well - in particular I'm a bit unclear on the expected behaviour of variable substitutions when a resource is optional. |
The following is the coverage report on pkg/.
|
failed again 😢
https://godoc.org/github.com/jenkins-x/go-scm/scm#State is accessible from the browser when I try. |
/test pull-tekton-pipeline-build-tests 👼 🙏 |
/retest |
i've made a pr against plumbing to try disabling the md link checker: tektoncd/plumbing#154 not sure at the moment what else to do beyond removing the links. |
was hoping (PR #1737 but now realizing its for nightly builds)to see coverage build fixed but doesnt look like 😞, still produces failure https://tekton-releases.appspot.com/build/tekton-prow/pr-logs/pull/tektoncd_pipeline/1601/pull-tekton-pipeline-go-coverage/1204807757975261187/?log#log
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this @pritidesai
I was a bit concerned about potential edge cases when the resource is missing but from looking at the code, it seems like that it would be up to the task author to ensure that their tasks behave correctly when a resource is missing!
@@ -94,6 +94,11 @@ type ResourceDeclaration struct { | |||
// will be copied. | |||
// +optional | |||
TargetPath string `json:"targetPath,omitempty"` | |||
// Optional declares the resource as optional. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a tiny nitpick but I think the last two lines comment lines are not required as the first two are descriptive enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would like to keep them in as those two lines show the usage and its behavior vs first two lines explains the key itself.
@@ -239,20 +239,30 @@ func InputsResource(name string, resourceType v1alpha1.PipelineResourceType, ops | |||
} | |||
} | |||
|
|||
func ResourceOptional(optional bool) TaskResourceOp { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is totally fine but is there a easier/simpler for doing test builders for boolean values? @vdemeester
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think so, its more about following our convention of building a resource, for example,
Required Resource:
tb.InputsResource("resource-to-build", v1alpha1.PipelineResourceTypeGit),
Optional Resource:
tb.InputsResource("optional-resource-to-build", v1alpha1.PipelineResourceTypeGit, tb.ResourceOptional(true)),
But would be ideal to refactor the way we initialize a resource in future, as we add more keys/fields, we end up adding setters for each.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dibyom The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/test pull-tekton-pipeline-build-tests |
1 similar comment
/test pull-tekton-pipeline-build-tests |
/retest |
💃 the build succeeds 😄 thanks everyone for fixing it 👍 |
Thanks @dibyom |
/lgtm |
Pipeline inputs and outputs are considered required, there is no way today to mark them optional. This change introduces a new field called optional as part of the PipelineDeclaredResource similar to previous PR tektoncd#1601, by default optional is set to false and a resource is required. To mark any resource optional, set optional to true: apiVersion: tekton.dev/v1alpha1 kind: Pipeline metadata: name: pipeline-build-image spec: resources: - name: workspace type: git optional: true tasks: - name: check-workspace Closes tektoncd#1710
Pipeline inputs and outputs are considered required, there is no way today to mark them optional. This change introduces a new field called optional as part of the PipelineDeclaredResource similar to previous PR tektoncd#1601, by default optional is set to false and a resource is required. To mark any resource optional, set optional to true: apiVersion: tekton.dev/v1alpha1 kind: Pipeline metadata: name: pipeline-build-image spec: resources: - name: workspace type: git optional: true tasks: - name: check-workspace Closes tektoncd#1710
Pipeline inputs and outputs are considered required, there is no way today to mark them optional. This change introduces a new field called optional as part of the PipelineDeclaredResource similar to previous PR tektoncd#1601, by default optional is set to false and a resource is required. To mark any resource optional, set optional to true: apiVersion: tekton.dev/v1alpha1 kind: Pipeline metadata: name: pipeline-build-image spec: resources: - name: workspace type: git optional: true tasks: - name: check-workspace Closes tektoncd#1710
Pipeline inputs and outputs are considered required, there is no way today to mark them optional. This change introduces a new field called optional as part of the PipelineDeclaredResource similar to previous PR tektoncd#1601, by default optional is set to false and a resource is required. To mark any resource optional, set optional to true: apiVersion: tekton.dev/v1alpha1 kind: Pipeline metadata: name: pipeline-build-image spec: resources: - name: workspace type: git optional: true tasks: - name: check-workspace Closes tektoncd#1710
Pipeline inputs and outputs are considered required, there is no way today to mark them optional. This change introduces a new field called optional as part of the PipelineDeclaredResource similar to previous PR tektoncd#1601, by default optional is set to false and a resource is required. To mark any resource optional, set optional to true: apiVersion: tekton.dev/v1alpha1 kind: Pipeline metadata: name: pipeline-build-image spec: resources: - name: workspace type: git optional: true tasks: - name: check-workspace Closes tektoncd#1710
Pipeline inputs and outputs are considered required, there is no way today to mark them optional. This change introduces a new field called optional as part of the PipelineDeclaredResource similar to previous PR tektoncd#1601, by default optional is set to false and a resource is required. To mark any resource optional, set optional to true: apiVersion: tekton.dev/v1alpha1 kind: Pipeline metadata: name: pipeline-build-image spec: resources: - name: workspace type: git optional: true tasks: - name: check-workspace Closes tektoncd#1710
Pipeline inputs and outputs are considered required, there is no way today to mark them optional. This change introduces a new field called optional as part of the PipelineDeclaredResource similar to previous PR tektoncd#1601, by default optional is set to false and a resource is required. To mark any resource optional, set optional to true: apiVersion: tekton.dev/v1alpha1 kind: Pipeline metadata: name: pipeline-build-image spec: resources: - name: workspace type: git optional: true tasks: - name: check-workspace Closes tektoncd#1710
Pipeline inputs and outputs are considered required, there is no way today to mark them optional. This change introduces a new field called optional as part of the PipelineDeclaredResource similar to previous PR #1601, by default optional is set to false and a resource is required. To mark any resource optional, set optional to true: apiVersion: tekton.dev/v1alpha1 kind: Pipeline metadata: name: pipeline-build-image spec: resources: - name: workspace type: git optional: true tasks: - name: check-workspace Closes #1710
Changes
Task inputs and outputs are considered required, there is no way
today to mark them optional. This change introduced a new field called
optional
as part of thePipelineResourceDeclaration
by default a resourceis required. To mark any resource optional, set
optional
totrue
:These changes apply to
Task
,ClusterTask
andCondition
resources.Closes #812
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide for more details.
Double check this list of stuff that's easy to miss:
cmd
dir, please updatethe release Task to build and release this image.
Reviewer Notes
If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.
Release Notes
Introducing a new key called
optional
as part of thePipelineResourceDeclaration
by default a resource is required (as is - no change in behavior). To mark any resource optional, setoptional
totrue
: