Add support for GCP Secret Manager

This commit is contained in:
2025-09-08 10:40:25 +02:00
parent 8e2706784b
commit e4e4bf9be4
6 changed files with 281 additions and 14 deletions

View File

@@ -5,6 +5,7 @@ import (
"encoding/hex"
"fmt"
"strings"
"time"
)
// Provider for secrets.
@@ -55,3 +56,59 @@ func ToBinary(s string) (bytes []byte) {
}
return
}
type providerOptions struct {
timeout time.Duration
apiKey string
credentials string
clientID string
secretID string
region string
}
// Option for providers.
type Option func(*providerOptions)
func newProviderOptions(opts ...Option) *providerOptions {
options := new(providerOptions)
for _, opt := range opts {
opt(options)
}
return options
}
// WithAPIKey sets the provider API key.
func WithAPIKey(key string) Option {
return func(p *providerOptions) {
p.apiKey = key
}
}
// WithCredentials specifies the API credentials.
func WithCredentials(credentials string) Option {
return func(p *providerOptions) {
p.credentials = credentials
}
}
// WithOAuth sets the provider client ID & secret options.
func WithOAuth(clientID, secret string) Option {
return func(p *providerOptions) {
p.clientID = clientID
p.secretID = secret
}
}
// WithTimeout sets the provider timeout option.
func WithTimeout(timeout time.Duration) Option {
return func(p *providerOptions) {
p.timeout = timeout
}
}
// WithRegion sets the provider (cloud) region.
func WithRegion(region string) Option {
return func(p *providerOptions) {
p.region = region
}
}