Skip to content

feat(backend): add skip support to pull/fetch layer hooks#536

Merged
gaius-qi merged 1 commit intomainfrom
feat/hook-enhancement
May 9, 2026
Merged

feat(backend): add skip support to pull/fetch layer hooks#536
gaius-qi merged 1 commit intomainfrom
feat/hook-enhancement

Conversation

@chlins
Copy link
Copy Markdown
Member

@chlins chlins commented May 9, 2026

This pull request introduces a more flexible and robust hook system for layer fetching and pulling operations, allowing hooks to skip specific layers and improving error handling and test coverage. The changes ensure that hooks are never nil, allow hooks to short-circuit layer downloads, and update the hook interface to provide more context. Comprehensive tests are added to validate the new behavior.

Hook system enhancements:

  • The PullHooks interface now allows the BeforePullLayer hook to return a boolean indicating whether a layer should be skipped; AfterPullLayer now receives a skipped flag and error value for more detailed reporting. The default (empty) hook implementation is updated accordingly.
  • Fetch and pull operations (backend.Fetch and backend.Pull) now check the result of BeforePullLayer, skip downloading the layer if requested, and always call AfterPullLayer with the correct flags. This logic is consistently applied in both regular and Dragonfly code paths. [1] [2] [3] [4] [5] [6]

Default hook safety:

  • Default hooks are automatically set if the caller leaves them unset, preventing nil dereference errors in both fetch and pull operations. [1] [2]

Testing improvements:

  • New tests are added for the hook system, including unit tests for the interface contract and a comprehensive integration test that verifies skipping logic and hook invocation order. [1] [2]

Signed-off-by: chlins <chlins.zhang@gmail.com>
@chlins chlins added the enhancement New feature or request label May 9, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the PullHooks interface to allow skipping layers during pull and fetch operations, with corresponding logic implemented in the backend and verified by new tests. BeforePullLayer now returns a boolean to signal skipping, and AfterPullLayer includes a flag for skip status. Review feedback focuses on thread safety, suggesting that configuration objects be copied before mutation and that the PullHooks interface documentation explicitly require thread-safe implementations.

Comment thread pkg/backend/fetch.go
Comment thread pkg/backend/pull.go
Comment thread pkg/config/pull.go
Copy link
Copy Markdown
Member

@gaius-qi gaius-qi left a comment

Choose a reason for hiding this comment

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

LGTM

@gaius-qi gaius-qi merged commit 17c7a96 into main May 9, 2026
5 checks passed
@gaius-qi gaius-qi deleted the feat/hook-enhancement branch May 9, 2026 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants