Skip to content

Add factory helpers for user and scoped secret providers#4242

Open
amirejaz wants to merge 2 commits intoscoped-secret-providersfrom
phase2-factory-helpers
Open

Add factory helpers for user and scoped secret providers#4242
amirejaz wants to merge 2 commits intoscoped-secret-providersfrom
phase2-factory-helpers

Conversation

@amirejaz
Copy link
Contributor

Summary

  • Callers currently have to manually wrap the result of CreateSecretProvider in UserProvider or ScopedProvider; this PR adds dedicated constructors so the wrapping is consistent and boilerplate-free.
  • Adds CreateUserSecretProvider(providerType) — creates the base provider and wraps it in UserProvider, blocking all __thv_* keys. Intended for user-facing callers (CLI, API, MCP tool server).
  • Adds CreateScopedSecretProvider(providerType, scope) — creates the base provider and wraps it in ScopedProvider, namespacing all key operations under __thv_<scope>_. Intended for internal callers such as the registry or workloads subsystem.

This is Phase 2 of the scoped secret store implementation (part of #4188). Phase 1 (#4229) introduced ScopedProvider and UserProvider; this PR exposes them through the factory layer.

Type of change

  • New feature (non-breaking change which adds functionality)

Test plan

  • Unit tests added to pkg/secrets/factory_test.go covering both helpers for the environment provider type (the only provider that works without external dependencies in CI), system-key blocking, and the unknown-provider error path.
  • go test ./pkg/secrets/... — all tests pass.
  • golangci-lint run ./pkg/secrets/... — 0 issues.

Special notes for reviewers

This PR is stacked on top of scoped-secret-providers (Phase 1 #4229). The diff against that branch is a single commit touching only factory.go and factory_test.go.

Generated with Claude Code

…elpers

Expose convenience constructors that wrap the base secret provider in either
a UserProvider (blocks system-reserved __thv_ keys for user-facing callers)
or a ScopedProvider (namespaces all operations under a given scope for
internal callers such as the registry or workloads subsystems).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added the size/XS Extra small PR: < 100 lines changed label Mar 19, 2026
@codecov
Copy link

codecov bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.26%. Comparing base (e52d21b) to head (c6f42f7).

Additional details and impacted files
@@                     Coverage Diff                     @@
##           scoped-secret-providers    #4242      +/-   ##
===========================================================
+ Coverage                    68.82%   69.26%   +0.43%     
===========================================================
  Files                          469      469              
  Lines                        47189    47137      -52     
===========================================================
+ Hits                         32480    32651     +171     
+ Misses                       12007    11975      -32     
+ Partials                      2702     2511     -191     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

}

func TestCreateUserSecretProvider(t *testing.T) { //nolint:paralleltest
ctx := context.Background()
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not use t.Context()?

}

func TestCreateScopedSecretProvider(t *testing.T) { //nolint:paralleltest
ctx := context.Background()
Copy link
Collaborator

Choose a reason for hiding this comment

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

t.Context() would be better.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added size/XS Extra small PR: < 100 lines changed and removed size/XS Extra small PR: < 100 lines changed labels Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Extra small PR: < 100 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants