Skip to content

Restructure (6): Store interface for local truststore access#590

Merged
roosterfish merged 11 commits intocanonical:v3from
roosterfish:restructure_rm_remotes
Jan 20, 2026
Merged

Restructure (6): Store interface for local truststore access#590
roosterfish merged 11 commits intocanonical:v3from
roosterfish:restructure_rm_remotes

Conversation

@roosterfish
Copy link
Contributor

@roosterfish roosterfish commented Jan 20, 2026

This is the sixth 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 Remotes func from the State interface is replaced with an interface to not anymore return an implementation of the truststore with types located inside the internal/ package.
Furthermore the naming is made a bit more consistent:

  • Store represents a truststore
  • Remote represents an entry in the truststore

The initial idea was to just hide the truststore access. However it's a very inexpensive way of querying for the existence and details of cluster members as the truststore is already located in memory.

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 refactors the truststore interface to expose it properly through public types rather than internal implementation types. The changes align with a broader effort to restructure microcluster packages and enable better testing through mockable interfaces.

Changes:

  • Introduced a new Store interface in microcluster/types/truststore.go to represent a local truststore
  • Moved Remote and Location types from internal/trust to microcluster/types package
  • Renamed the Remotes() method to Truststore() in the State interface and updated all method names for consistency (e.g., Addresses()RemoteAddresses(), Cluster()RemoteClients())

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
microcluster/types/truststore.go New file defining the Store interface and Remote/Location types for public API
internal/trust/truststore.go Updated to use types.Remote instead of internal Remote type
internal/trust/remotes.go Removed duplicate type definitions; updated to use types.Remote and types.Location; renamed methods for consistency
internal/state/state.go Changed Remotes() to Truststore() returning types.Store interface; updated SetConfig signature
internal/rest/rest.go Updated to call Truststore().RemoteCertificatesNative()
internal/rest/resources/truststore.go Updated to use types.Remote/types.Location and Truststore() method
internal/rest/resources/tokens.go Updated to call Truststore().RemoteAddresses()
internal/rest/resources/heartbeat.go Updated to call Truststore().Replace()
internal/rest/resources/daemon.go Updated to use Truststore() method
internal/rest/resources/control.go Updated to use types.Remote/types.Location and Truststore() method
internal/rest/resources/cluster.go Updated to use types.Remote/types.Location and Truststore() method
internal/recover/recover.go Updated to call RemoteClients() instead of Cluster()
internal/daemon/daemon.go Updated to use types.Remote/types.Location and updated method references

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

The Store interface allows masking the internal truststore implementation and offers helpful utilities to query
truststore information purely in memory (except the add/replace operations).

By having the interface in a the public types package we can replace the Remotes func in the public State interface.

Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
…tore entries

Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Also change the wording a little bit to represent the actual truststore. Entries in the truststore are called
remotes therefore those are returned/used by the various funcs of the Store interface.

Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
…tore

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>
@roosterfish roosterfish force-pushed the restructure_rm_remotes branch from 1efd93f to 9d988f4 Compare January 20, 2026 11:01
@roosterfish roosterfish marked this pull request as ready for review January 20, 2026 11:02
Copy link
Contributor

@tugbataluy tugbataluy left a comment

Choose a reason for hiding this comment

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

I think your implementation is solid, looks great as-is, ready to ship!

Copy link
Contributor

@markylaing markylaing left a comment

Choose a reason for hiding this comment

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

Great work 🚀

@roosterfish roosterfish merged commit 3391e35 into canonical:v3 Jan 20, 2026
5 checks passed
@roosterfish roosterfish deleted the restructure_rm_remotes branch January 20, 2026 16:29
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