-
Notifications
You must be signed in to change notification settings - Fork 6
env log repo filter #653
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
env log repo filter #653
Conversation
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.
Pull request overview
Adds support for filtering kosli log environment events by one or more repositories via a new --repo flag, producing repeated query parameters in the request URL.
Changes:
- Add
--repoflag tolog environmentand appendrepo_namequery parameters to the events API request. - Extend command help/usage examples to document repo-filtered event listing.
- Expand the test suite setup and add new test cases covering repo filtering.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| cmd/kosli/logEnvironment.go | Adds --repo flag plumbing and appends repo_name query parameters when fetching environment events. |
| cmd/kosli/logEnvironment_test.go | Enhances test setup with repo-related context and adds test cases for --repo filtering behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
cmd/kosli/logEnvironment.go
Outdated
| func (o *logEnvironmentOptions) getEnvironmentEvents(out io.Writer, envName, interval string) error { | ||
| eventsURL := fmt.Sprintf("%s/api/v2/environments/%s/%s/events?page=%d&per_page=%d&interval=%s&reverse=%t", | ||
| global.Host, global.Org, envName, o.pageNumber, o.pageLimit, url.QueryEscape(interval), o.reverse) | ||
| baseURL := fmt.Sprintf("%s/api/v2/environments/%s/%s/events", global.Host, global.Org, envName) |
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.
We're still doing some unsafe string manipulation here.
Something like this would be safe, I think?
u, err := url.Parse(global.Host)
if err != nil {
return fmt.Errorf("failed to parse host URL: %w", err)
}
u.Path, err = url.JoinPath(u.Path, "/api/v2/environments", global.Org, envName, "events")
if err != nil {
return fmt.Errorf("failed to join URL path: %w", err)
}
This change adds the
--repoflag to thelog environmentcommand, and filter the query by repo.The flag can be repeated, which will result in a repeated query parameter in the requested url.