Skip to content

Conversation

@nakabonne
Copy link
Member

@nakabonne nakabonne commented Aug 11, 2021

What this PR does / why we need it:
This PR adds the implementation of #2346 (comment)

Which issue(s) this PR fixes:

Fixes #2346
Fixes #2212
Fixes #2341
Fixes #2345

Does this PR introduce a user-facing change?:

Add text regex support for Event watcher

@nakabonne nakabonne force-pushed the text-regex-event-watcher branch from 0f0772c to 2812689 Compare August 12, 2021 06:13
@pipecd-bot pipecd-bot added size/L and removed size/M labels Aug 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. Support the "line" field that specifies tha line number staticaly

https://github.com/pipe-cd/pipe/blob/b7becc5309f989894c6cc1962d27c1093f28496d/pkg/config/event_watcher.go#L59-L62

This was created by todo plugin since "TODO:" was found in b7becc5 when #2347 was merged. cc: @nakabonne.

@nakabonne nakabonne marked this pull request as ready for review August 12, 2021 06:17
@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 31.99%. This pull request increases coverage by 0.07%.

File Function Base Head Diff
pkg/app/piped/eventwatcher/eventwatcher.go modifyText -- 76.47% +76.47%
pkg/config/event_watcher.go EventWatcherReplacementTextField.Filled -- 100.00% +100.00%
pkg/config/event_watcher.go EventWatcherEvent.Validate 73.68% 71.43% -2.26%
pkg/app/piped/eventwatcher/eventwatcher.go watcher.commitFiles 0.00% 0.00% +0.00%

@nakabonne
Copy link
Member Author

We settled on employing #2346 (comment)
/hold

@nakabonne
Copy link
Member Author

/hold cancel

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.08%. This pull request increases coverage by 0.16%.

File Function Base Head Diff
pkg/app/piped/eventwatcher/eventwatcher.go modifyText -- 86.67% +86.67%
pkg/app/piped/eventwatcher/eventwatcher.go watcher.commitFiles 0.00% 0.00% +0.00%
pkg/cache/memorycache/lru_cache.go LRUCache.Get 66.67% 100.00% +33.33%
pkg/config/event_watcher.go EventWatcherEvent.Validate 73.68% 71.43% -2.26%
pkg/regexpool/regexpool.go Pool.Get 87.50% 93.75% +6.25%

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.08%. This pull request increases coverage by 0.16%.

File Function Base Head Diff
pkg/app/piped/eventwatcher/eventwatcher.go modifyText -- 86.67% +86.67%
pkg/app/piped/eventwatcher/eventwatcher.go watcher.commitFiles 0.00% 0.00% +0.00%
pkg/cache/memorycache/lru_cache.go LRUCache.Get 66.67% 100.00% +33.33%
pkg/config/event_watcher.go EventWatcherEvent.Validate 73.68% 71.43% -2.26%
pkg/regexpool/regexpool.go Pool.Get 87.50% 93.75% +6.25%

return
}

func modifyText(path, regexText, newValue string) ([]byte, bool, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a comment to show the meaning of each returned value?
Or using named return for better understand.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's more helpful 👍

{
name: "the file is up-to-date",
path: "testdata/invalid.yaml",
regex: "image: gcr.io/pipecd/foo:(v[0-9].[0-9].[0-9])",
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a case that captures/replaces the whole tag url?

}
return
}

Copy link
Member

Choose a reason for hiding this comment

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

nits, should we add a comment for this just as modifyYAML function has? It's a nits and it's up to you 🙆‍♀️

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.08%. This pull request increases coverage by 0.16%.

File Function Base Head Diff
pkg/app/piped/eventwatcher/eventwatcher.go modifyText -- 86.67% +86.67%
pkg/config/event_watcher.go EventWatcherEvent.Validate 73.68% 71.43% -2.26%
pkg/regexpool/regexpool.go Pool.Get 87.50% 93.75% +6.25%
pkg/app/piped/eventwatcher/eventwatcher.go watcher.commitFiles 0.00% 0.00% +0.00%
pkg/cache/memorycache/lru_cache.go LRUCache.Get 66.67% 100.00% +33.33%

@nakabonne
Copy link
Member Author

Applied, PTAL 😄

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.08%. This pull request increases coverage by 0.16%.

File Function Base Head Diff
pkg/app/piped/eventwatcher/eventwatcher.go modifyText -- 86.67% +86.67%
pkg/app/piped/eventwatcher/eventwatcher.go watcher.commitFiles 0.00% 0.00% +0.00%
pkg/cache/memorycache/lru_cache.go LRUCache.Get 66.67% 100.00% +33.33%
pkg/config/event_watcher.go EventWatcherEvent.Validate 73.68% 71.43% -2.26%
pkg/regexpool/regexpool.go Pool.Get 87.50% 93.75% +6.25%

@nakabonne
Copy link
Member Author

I'm looking to add a couple of examples after this got mereged.

@nghialv
Copy link
Member

nghialv commented Aug 17, 2021

Nice work!
/lgtm

@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 200c623 into master Aug 17, 2021
@pipecd-bot pipecd-bot deleted the text-regex-event-watcher branch August 17, 2021 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

5 participants