Skip to content

refactor: split controller.go#79

Open
ajbeattie wants to merge 3 commits intomainfrom
refactor/split-controller
Open

refactor: split controller.go#79
ajbeattie wants to merge 3 commits intomainfrom
refactor/split-controller

Conversation

@ajbeattie
Copy link
Copy Markdown
Contributor

What this does

This PR splits up some of the functionality in controller.go, both to simplify the Controller struct and to reduce the amount of code in controller.go:

  • Adds reporting.go file to controller package containing logic related to reporting deployments to the Artifact Metadata API
  • Adds a new workload package with encapsulated logic for getting pod workload info (resolving parent workload, deployment name, etc).

- Split various functionality out of controller.go
- Add reporting.go file to controller package containing logic related to reporting deployments to the Artifact Metadata API
- Add workload package with encapsulated logic for resolving workload identity for pods.
Copilot AI review requested due to automatic review settings April 15, 2026 05:38
@ajbeattie ajbeattie requested a review from a team as a code owner April 15, 2026 05:38
Copy link
Copy Markdown
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

This PR refactors the controller by extracting reporting logic into a dedicated file and introducing a new internal/workload package to encapsulate pod-to-workload resolution and workload liveness checks, reducing the size and responsibility of controller.go.

Changes:

  • Split deployment record reporting logic out of controller.go into internal/controller/reporting.go (+ new unit tests).
  • Added internal/workload package (with tests) to centralize supported owner detection, workload identity resolution, and “is workload still active” checks.
  • Updated controller startup/sync flow to use SharedInformerFactory.Start() and WaitForCacheSync().
Show a summary per file
File Description
internal/controller/controller.go Simplifies Controller by storing the informer factory + delegating workload logic to internal/workload; starts/syncs informers via the factory.
internal/controller/reporting.go New home for pod event processing + posting deployment records to the Artifact Metadata API.
internal/controller/reporting_test.go New unit tests for unknown-artifact caching behavior.
internal/controller/controller_test.go Updates test controller setup to satisfy new workloadResolver dependency and informer-factory sync behavior.
internal/controller/controller_integration_test.go Updates cache-sync waiting to use the controller’s informer factory.
internal/workload/workload.go New package for resolving workload identity and checking workload existence via informer listers.
internal/workload/workload_test.go New tests for supported-owner checks, name extraction helpers, and workload resolution.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 7/7 changed files
  • Comments generated: 3

Comment thread internal/workload/workload.go
Comment thread internal/workload/workload_test.go Outdated
Comment thread internal/controller/reporting_test.go
bdehamer
bdehamer previously approved these changes Apr 15, 2026
Copy link
Copy Markdown
Contributor

@bdehamer bdehamer left a comment

Choose a reason for hiding this comment

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

👍

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.

3 participants