Skip to content

Conversation

@jumboduck
Copy link
Contributor

@jumboduck jumboduck commented Feb 9, 2026

This change adds the --repo flag to the log environment command, and filter the query by repo.
The flag can be repeated, which will result in a repeated query parameter in the requested url.

@jumboduck jumboduck enabled auto-merge (squash) February 9, 2026 14:18
@jumboduck jumboduck requested a review from Copilot February 9, 2026 14:22
Copy link
Contributor

Copilot AI left a 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 --repo flag to log environment and append repo_name query 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.

jumboduck and others added 3 commits February 9, 2026 15:25
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)
Copy link
Contributor

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)
	}

@jumboduck jumboduck merged commit 89934a1 into main Feb 9, 2026
9 checks passed
@jumboduck jumboduck deleted the env-log-repo-filter branch February 9, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants