-
Notifications
You must be signed in to change notification settings - Fork 113
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
Shipwright Triggers API #1008
Shipwright Triggers API #1008
Conversation
bab9210
to
ebf188d
Compare
Hi @otaviof , thanks for your works, any update on this PR? |
17c8188
to
15304e2
Compare
/retitle Shipwright Triggers API |
/assign @SaschaSchwarze0 @adambkaplan /cc @coreydaley |
@otaviof I don't see the use of the |
Hello! Sorry for the delay, we are moving forward with this feature again 👍 And thanks for the heads up too. |
I'm implementing the changes we've discussed during the EP review without changes, so that's why we have the nested attribute approach. Personally, the |
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 suggest to add validation to https://github.com/shipwright-io/build/blob/v0.10.0/pkg/validate/validate.go#L83-L119. Basically a BuildRun with an inline spec must not have triggers set.
docs/build.md
Outdated
|
||
The GitHub type is meant to react on events coming from GitHub WebHook, the events are compared against the existing `Build` resources and therefore it can find `Build` based on `.spec.source.url` combined with the attributes on `.spec.trigger.when[].github`. | ||
|
||
When `.spec.trigger.when[].github.branches` is empty, the `.spec.source.revision` is employed, the default "branch" name employed is based on the regular source repository configuration. |
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 suggest to have a full defined list of all possible combinations to leave no room for speculation:
- If the source contains a revision that is a branch name, and the trigger branches are empty, then BuildRuns get submitted for this single branch only.
- If the source contains no revision and the trigger branches are empty, then ... TBD (how do we behave here, is that valid at all ?)
- If the source contains a revision, and the trigger branches are not empty, then BuildRuns get submitted for the branches defined in the trigger.
- If the source contains no revision, and the trigger branches are not empty, then BuildRuns get submitted for the branches defined in the trigger.
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.
Let me start with an example, please. Let's imagine a pull-request is open at the repository X against the main
branch, it will dispatch a GitHub Event which contains detailed
Okay, so let me start with a use-case example, please. Let's imagine the user is receiving WebHook events from GitHub, a event comes along with the type PullRequest
listing the target branch as main
and as well the repository URL. Based on those, it must then trigger a single BuildRun
per Build
object that matches both repository URL and revision, so in other words, there's a direct relationship between one GitHub event and one (or more) Build
instance.
Given a single GitHub Event must trigger a single BuildRun
per Build
instance responsible for that repository, the business rule is basically a fallback approach: probe if the event branch name is listed on .spec.trigger.when[].github.branches
slice, or, uses the .spec.source.revision
(by default is assumed "main" when empty).
type: Image | ||
image: | ||
names: | ||
- ghcr.io/some/base-image:latest |
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.
Should not here be the name of the Image resource that must be in the same namespace ? Especially if the image is not at all in an external registry, it would be complicated to provide such an image name.
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.
Here we are looking for a fully qualified image name and to later on rely on the image controller to handle this business logic. However, the image name is a free form string initially.
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.
status: | ||
- Succeeded |
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 may need to check the ship again, why do we filter on the status here? Should not it be always on successful completion?
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.
In order to have a flexible workflow we should allow any state to be filled in, and it's expected that "Succeeded" is the most common.
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.
Flexibility is fine, but out of interest, what would be the use case to trigger a BuildRun on a Pipeline status change other than to Succeeded?
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.
The "status" is reported as a string, and the .objectRef
can match more than one type of Kubernetes CRD.
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.
Just for my understanding, does Pipeline CRD has a state, or is more about PipelineRun states?
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.
Sorry, I haven't been clear before. The object that carries the state is the PipelineRun
.
- Succeeded | ||
name: tekton-pipeline-name | ||
``` | ||
|
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.
What about the BuildRun trigger? In my own subjective opinion, that is more important than pipelines.
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.
The triggers is a mechanism to instantiate BuildRun
objects based on a Build
, so BuildRun
would not be able to trigger itself.
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.
Yep, I meant Build trigger. But I just notice it is not part of the SHIP, then it is fine for now. It is being discussed here: shipwright-io/community#75 (comment).
// SpecTriggersNameCanNotBeBlank indicates the when condition does not have a name | ||
SpecTriggersNameCanNotBeBlank BuildReason = "SpecTriggersWhenNameCanNotBeBlank" | ||
// SpecTriggersInvalidType indicates the when type is invalid | ||
SpecTriggersInvalidType BuildReason = "SpecTriggersWhenInvalidType" | ||
// SpecTriggersInvalidGitHub indicates the when type GitHub is invalid | ||
SpecTriggersInvalidGitHub BuildReason = "SpecTriggersWhenInvalidGitHub" | ||
// SpecTriggersInvalidImage indicates the when type Image is invalid | ||
SpecTriggersInvalidImage BuildReason = "SpecTriggersWhenInvalidImage" | ||
// SpecTriggersInvalidPipeline indicates the when type Pipeline is invalid | ||
SpecTriggersInvalidPipeline BuildReason = "SpecTriggersWhenInvalidPipeline" |
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.
For consistency, I suggest to remove the Spec
prefix everywhere. Those error codes are also documented on https://github.com/shipwright-io/build/blob/main/docs/build.md#build-validations. And I just notice that we forgot to add the Volume-related reasons.
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.
Sure!
Name string `json:"name"` | ||
|
||
// Type the event type, the name of the webhook event. | ||
Type WhenTypeName `json:"type,omitempty"` |
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.
If this is required, should we remove omitempty ?
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, indeed the omitempty
must not be there.
I have a question, If we watch github event, how to apply carried information to Build result? |
Hi @lookis, qq, are you:
|
@SaschaSchwarze0 Thanks, looking forward to it. |
54d4af1
to
7082c9e
Compare
@otaviof: GitHub didn't allow me to request PR reviews from the following users: ricardomaraschini. Note that only shipwright-io members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this: Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Thanks for the review, please consider the latest changes. |
Most definitely an interesting use-case, @lookis! I think we've spoken about having automation to tag the image accordingly with the context, like in this case the repository metadata. I think we should keep this in the radar. Lets bring this on the next community meeting? |
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.
/approve
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.
@otaviof thank you, neat neat work!
Some minor comments, pls take a look
status: | ||
- Succeeded |
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.
Just for my understanding, does Pipeline CRD has a state, or is more about PipelineRun states?
eccb60a
to
cdaf481
Compare
Co-authored-by: Enrique Encalada <encaladaenrique@gmail.com>
Co-authored-by: Sascha Schwarze <schwarzs@de.ibm.com>
cdaf481
to
3f6ef66
Compare
@otaviof ty, approving. /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: qu1queee, SaschaSchwarze0 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 |
/lgtm |
Changes
Adding the API for Shipwright Triggers (EP) with validation and initial documentation.
Submitter Checklist
Release Notes