Skip to content

Conversation

@nghialv
Copy link
Member

@nghialv nghialv commented Jan 8, 2021

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

NONE

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 33.81%. This pull request increases coverage by 0.00%.

File Function Base Head Diff
pkg/app/api/grpcapi/api.go API.RegisterEvent -- 0.00% +0.00%
pkg/datastore/event.go NewEventStore -- 100.00% +100.00%
pkg/datastore/event.go eventStore.AddEvent -- 100.00% +100.00%
pkg/app/api/grpcapi/api.go API.PushImageReference 0.00% -- +-0.00%
pkg/datastore/imagereference.go NewImageReferenceStore 100.00% -- -100.00%
pkg/datastore/imagereference.go imageReferenceStore.AddImageReference 100.00% -- -100.00%

@khanhtc1202
Copy link
Member

/lgtm

// The data of event.
string data = 3 [(validate.rules).string.min_len = 3];
// The ID of the project this event belongs to.
string project_id = 4 [(validate.rules).string.min_len = 1];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we really don't have to let Event have repo_id. Currently within a project, all events can be affected all repositories. So it can happen something like below:

Suppose this EventWatcher file is placed at repo1 as well as repo2:

apiVersion: pipecd.dev/v1beta1
kind: EventWatcher
spec:
  events:
    - name: app1-image-push
    ...

Then you register a new event with the name app1-image-push.

pipectl event register \
    --address=host.xz:443 \
    --api-key=xxxx
    --event-name=app1-image-push \
    --data=foo/bar:v0.2.0

No matter what you intend to update which repository, both repo1 and repo2 will be updated. I figured out we have to prevent it in some way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One way we can solve this with the current design is, we denote users to name the event with the repo prefix like: repo1/app1-image-push. We can leave the responsibility to distinguish them to users by doing this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One way to make the event become more usable is that we can add tags/labels field to it.
EventWatcher or anything else can rely on that value.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By that way, the event's generality is not reduced. And in the future, we can add another tag/label not even repo id.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally agree with it. Thanks for the great suggestion, and yeah, we must not forget keeping up EventWatcher versatile, general and flexible definitely!

@nakabonne
Copy link
Member

Thank you. Looks great!
/lgtm

@pipecd-bot pipecd-bot removed the lgtm label Jan 12, 2021
@pipecd-bot
Copy link
Collaborator

TODO

The following ISSUES will be created once got merged. If you want me to skip creating the issue, you can use /todo skip command.

Details

1. Allow specifying event labels.

https://github.com/pipe-cd/pipe/blob/323705651196e61c099dc2d15aa094fedca0f096/pkg/app/pipectl/cmd/event/register.go#L46-L49

This was created by todo plugin since "TODO:" was found in 3237056 when #1385 was merged. cc: @nghialv.

@nghialv
Copy link
Member Author

nghialv commented Jan 12, 2021

I have just added the labels field into the model.
Updating the pipectl will be done by another PR.

@nakabonne
Copy link
Member

👍
/lgtm

@khanhtc1202
Copy link
Member

🚀
/approve

@pipecd-bot
Copy link
Collaborator

APPROVE

This pull request is APPROVED by khanhtc1202.

Approvers can cancel the approval by writing /approve cancel in a comment. Any additional commits also will change this pull request to be not-approved.

@pipecd-bot pipecd-bot merged commit 26e97d6 into master Jan 12, 2021
@pipecd-bot pipecd-bot deleted the event branch January 12, 2021 03:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants