feat: expose bitwarden cache in generated helpers
This commit is contained in:
parent
fd08615950
commit
5552e63974
2 changed files with 38 additions and 8 deletions
|
|
@ -342,14 +342,15 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type SecretStoreOptions struct {
|
type SecretStoreOptions struct {
|
||||||
ServiceName string
|
ServiceName string
|
||||||
LookupEnv func(string) (string, bool)
|
LookupEnv func(string) (string, bool)
|
||||||
KWalletAppID string
|
KWalletAppID string
|
||||||
KWalletFolder string
|
KWalletFolder string
|
||||||
BitwardenCommand string
|
BitwardenCommand string
|
||||||
BitwardenDebug bool
|
BitwardenDebug bool
|
||||||
Shell string
|
DisableBitwardenCache bool
|
||||||
ExecutableResolver fwsecretstore.ExecutableResolver
|
Shell string
|
||||||
|
ExecutableResolver fwsecretstore.ExecutableResolver
|
||||||
}
|
}
|
||||||
|
|
||||||
func OpenSecretStore(options SecretStoreOptions) (fwsecretstore.Store, error) {
|
func OpenSecretStore(options SecretStoreOptions) (fwsecretstore.Store, error) {
|
||||||
|
|
@ -372,6 +373,7 @@ func secretStoreOpenOptions(options SecretStoreOptions) fwsecretstore.OpenFromMa
|
||||||
KWalletFolder: options.KWalletFolder,
|
KWalletFolder: options.KWalletFolder,
|
||||||
BitwardenCommand: options.BitwardenCommand,
|
BitwardenCommand: options.BitwardenCommand,
|
||||||
BitwardenDebug: options.BitwardenDebug,
|
BitwardenDebug: options.BitwardenDebug,
|
||||||
|
DisableBitwardenCache: options.DisableBitwardenCache,
|
||||||
Shell: options.Shell,
|
Shell: options.Shell,
|
||||||
ManifestLoader: LoadManifest,
|
ManifestLoader: LoadManifest,
|
||||||
ExecutableResolver: options.ExecutableResolver,
|
ExecutableResolver: options.ExecutableResolver,
|
||||||
|
|
@ -386,6 +388,7 @@ func secretStoreDescribeOptions(options SecretStoreOptions) fwsecretstore.Descri
|
||||||
KWalletFolder: options.KWalletFolder,
|
KWalletFolder: options.KWalletFolder,
|
||||||
BitwardenCommand: options.BitwardenCommand,
|
BitwardenCommand: options.BitwardenCommand,
|
||||||
BitwardenDebug: options.BitwardenDebug,
|
BitwardenDebug: options.BitwardenDebug,
|
||||||
|
DisableBitwardenCache: options.DisableBitwardenCache,
|
||||||
Shell: options.Shell,
|
Shell: options.Shell,
|
||||||
ManifestLoader: LoadManifest,
|
ManifestLoader: LoadManifest,
|
||||||
ExecutableResolver: options.ExecutableResolver,
|
ExecutableResolver: options.ExecutableResolver,
|
||||||
|
|
|
||||||
|
|
@ -322,6 +322,33 @@ sources = ["flag", "env", "secret"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGenerateSecretStoreIncludesBitwardenCacheOption(t *testing.T) {
|
||||||
|
projectDir := newProject(t, `
|
||||||
|
binary_name = "demo-mcp"
|
||||||
|
|
||||||
|
[secret_store]
|
||||||
|
backend_policy = "bitwarden-cli"
|
||||||
|
`)
|
||||||
|
|
||||||
|
if _, err := Generate(Options{ProjectDir: projectDir}); err != nil {
|
||||||
|
t.Fatalf("Generate returned error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
content, err := os.ReadFile(filepath.Join(projectDir, "mcpgen", "secretstore.go"))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("ReadFile generated secretstore: %v", err)
|
||||||
|
}
|
||||||
|
text := string(content)
|
||||||
|
for _, snippet := range []string{
|
||||||
|
"DisableBitwardenCache bool",
|
||||||
|
"DisableBitwardenCache: options.DisableBitwardenCache,",
|
||||||
|
} {
|
||||||
|
if !strings.Contains(text, snippet) {
|
||||||
|
t.Fatalf("generated secretstore.go missing %q:\n%s", snippet, text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func newProject(t *testing.T, manifest string) string {
|
func newProject(t *testing.T, manifest string) string {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue