Skip to content

feat: factory function provides more context#437

Merged
Benehiko merged 1 commit intomainfrom
store/factory
Jan 27, 2026
Merged

feat: factory function provides more context#437
Benehiko merged 1 commit intomainfrom
store/factory

Conversation

@Benehiko
Copy link
Copy Markdown
Member

This change provides more context to the factory function. A more informed factory, could even add additional data based on data only it knows about (e.g. via context or the id).

Another use case is returning different store.Secret types based on what is being read from the store.

store, err := store.New(
    func(ctx context.Context, id store.ID) store.Secret {
        if id.String() == "bob" {
            return &oauth.BobCredential{}
        }
        return &oauth.OAuthCredential{}
	}, 
    func(id store.ID) string { return "" },
)

@Benehiko Benehiko requested review from Copilot and joe0BAB and removed request for Copilot January 27, 2026 13:42
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 updates the Factory type signature to accept context.Context and store.ID parameters, enabling factory functions to make context-aware decisions and return different secret types based on the identifier being accessed.

Changes:

  • Updated Factory function signature from func() T to func(context.Context, ID) T
  • Updated all factory function invocations across stores to pass context and ID parameters
  • Updated test mocks and helper functions to match the new signature

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
store/store.go Updated Factory type signature to include context and ID parameters
store/posixage/store.go Updated factory invocations in Filter, Get, and GetAllMetadata methods
store/posixage/store_test.go Updated test factory functions to accept new parameters
store/keychain/keychain_darwin.go Updated factory field type and method signatures to use context parameter
store/keychain/keychain_darwin_test.go Added context import and updated factory function signature
store/keychain/keychain_test.go Updated setupKeychain helper and test factories to match new signature
store/keychain/cmd/main.go Updated factory function in command setup
plugins/pass/store/store.go Added context import and updated PassStore factory function

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

Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
@Benehiko Benehiko merged commit 9f59896 into main Jan 27, 2026
18 checks passed
@Benehiko Benehiko deleted the store/factory branch January 27, 2026 14:04
joe0BAB pushed a commit that referenced this pull request Feb 16, 2026
feat: factory function provides more context
joe0BAB pushed a commit that referenced this pull request Feb 16, 2026
feat: factory function provides more context
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