Skip to content

Restructure (9): Make State interface and Hooks public#610

Open
roosterfish wants to merge 10 commits intocanonical:v3from
roosterfish:restructure_hooks_state
Open

Restructure (9): Make State interface and Hooks public#610
roosterfish wants to merge 10 commits intocanonical:v3from
roosterfish:restructure_hooks_state

Conversation

@roosterfish
Copy link
Contributor

@roosterfish roosterfish commented Feb 5, 2026

This is the ninth PR taken from a single commit in #534 (even though in this case the actual changes are very different from the original commit).
The final package layout will be different but to allow reviewing the changes in smaller chunks I will split this PR by its commits.

In this PR the State interface can finally be moved to a public package together with the Hooks struct which allows removing the import indirection which was previously necessary to be able to access both the State and Hooks.

Copy link

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 restructures the codebase by moving the State interface and Hooks struct from internal packages to the public microcluster/types package, eliminating the previous import indirection through type aliases.

Changes:

  • Moved State interface from internal/state/state.go to microcluster/types/state.go as a public interface
  • Moved Hooks struct from internal/state/hooks.go to microcluster/types/hooks.go as a public struct
  • Removed the state/state.go package that previously provided type aliases for these types
  • Updated all import statements and function signatures across the codebase to use types.State and types.Hooks instead of state.State and state.Hooks

Reviewed changes

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

Show a summary per file
File Description
state/state.go Removed type alias package that provided public access to internal types
microcluster/types/state.go Added public State interface definition with all required methods
microcluster/types/hooks.go Added public Hooks struct definition with all hook function fields
microcluster/rest/rest.go Updated EndpointAction to use types.State in function signatures
internal/state/state.go Removed State interface definition and updated Hooks field type, updated ToInternal signature
internal/state/hooks.go Removed Hooks struct (moved to public package)
internal/rest/rest.go Updated function signatures to use types.State
internal/rest/resources/*.go Updated all resource handler function signatures to use types.State
internal/rest/access/authentication.go Updated authentication functions to use types.State
internal/daemon/daemon.go Updated daemon to use types.Hooks and types.State throughout
example/cmd/microd/main.go Updated example hooks to use types.Hooks and types.State
example/api/extended.go Updated extended API handlers to use types.State

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

This is now possible based on the previous package restructurings.

Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
The internal State and Hooks where only available to Microcluster users due to this indirection.
The entire package can now be dropped.

Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
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.

1 participant