Add support for GCP Secret Manager
This commit is contained in:
57
provider.go
57
provider.go
@@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user