Skip to content

feat: configurable event filter #610

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

Merged
merged 3 commits into from
May 25, 2025
Merged

feat: configurable event filter #610

merged 3 commits into from
May 25, 2025

Conversation

buchdag
Copy link
Member

@buchdag buchdag commented May 14, 2024

This PR make use of the new Docker API event format available on Docker API v1.22+ (the old event format is automatically translated to the new one by fsouza/go-dockerclient) and make docker-gen watch for network connect and disconnect events.

Close #190

Ping @outdooracorn

@buchdag buchdag self-assigned this May 14, 2024
@buchdag buchdag marked this pull request as ready for review May 14, 2024 08:19
@buchdag buchdag changed the title feat: watch network connect / disconnect event feat: watch network connect / disconnect events May 14, 2024
@outdooracorn
Copy link

Thanks for creating this PR 🙌
I use docker-gen as part of the nginx-proxy container. What would be the best way to test this PR? Build the binary locally and then docker cp it into the container?

@buchdag
Copy link
Member Author

buchdag commented May 16, 2024

I've pushed a custom built nginx-proxy image for you to test: docker pull nginxproxy/nginx-proxy:network-event

@buchdag
Copy link
Member Author

buchdag commented May 22, 2024

@outdooracorn any luck trying nginxproxy/nginx-proxy:network-event ? Let me know if you need any help.

@buchdag
Copy link
Member Author

buchdag commented Jul 18, 2024

Ping @outdooracorn 👋

@buchdag buchdag force-pushed the watch-network-event branch from 91ddfac to b6b6a26 Compare October 6, 2024 13:11
@buchdag buchdag force-pushed the watch-network-event branch from b6b6a26 to b4a831d Compare May 25, 2025 14:23
@buchdag buchdag requested a review from Copilot May 25, 2025 14:30
Copy link

@Copilot 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

This PR enhances docker-gen by updating the Docker event handling to support network connect and disconnect events using the new Docker API event format. Key changes include:

  • Updating test fixtures in generator_test.go to reflect the new event format.
  • Refactoring the event filtering logic in generator.go to handle both container and network events.
  • Updating the Docker API version information in the test fixture.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
internal/generator/generator_test.go Updated test events and Docker version to match the new event format.
internal/generator/generator.go Refactored event handling to include network events using slices.Contains.
Comments suppressed due to low confidence (1)

internal/generator/generator_test.go:29

  • The test cases currently validate container event handling; consider adding separate tests to validate network connect and disconnect events to ensure full coverage of the new functionality.
{"Type":"container","Action":"start","Actor": {"ID":"8dfafdbc3a40"},"Time":1374067924}

@buchdag buchdag force-pushed the watch-network-event branch from 2c5db1d to 64d297a Compare May 25, 2025 15:19
@buchdag buchdag force-pushed the watch-network-event branch from 064b242 to 654bbca Compare May 25, 2025 20:31
@buchdag
Copy link
Member Author

buchdag commented May 25, 2025

I decided to make this configurable via a new -event-filter flag rather than changing the default.

@buchdag buchdag changed the title feat: watch network connect / disconnect events feat: configurable event filter May 25, 2025
@buchdag buchdag merged commit bbb5f84 into main May 25, 2025
9 checks passed
@buchdag buchdag deleted the watch-network-event branch May 25, 2025 20:42
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.

Listen for network (dis)connect events (API v1.22+)
2 participants