Documentation
¶
Index ¶
- Variables
- func GrpcSimpleRetrieve(ctx context.Context, ServerAddress string, AuthenticationPassword string, ...) (val string, err error)
- func GrpcSimpleRetrieveWithPrebuiltTLS(ctx context.Context, ServerAddress string, AuthenticationPassword string, ...) (val string, err error)
- func GrpcSimpleRetrieveWithTLS(ctx context.Context, ServerAddress string, AuthenticationPassword string, ...) (val string, err error)
- func GrpcSimpleStore(ctx context.Context, ServerAddress string, AuthenticationPassword string, ...) (err error)
- func GrpcSimpleStoreWithPrebuiltTLS(ctx context.Context, ServerAddress string, AuthenticationPassword string, ...) (err error)
- func GrpcSimpleStoreWithTLS(ctx context.Context, ServerAddress string, AuthenticationPassword string, ...) (err error)
- type CertificateSource
- type Client
- type ClientOption
- type PasswordCallback
- type TLSConfig
- func NewTLSConfigFromP12Bytes(p12Data []byte, passwordFn PasswordCallback) *TLSConfig
- func NewTLSConfigFromP12File(p12File string, passwordFn PasswordCallback) *TLSConfig
- func NewTLSConfigFromSeparateCertBytes(clientCertData, clientKeyData, caCertData []byte) *TLSConfig
- func NewTLSConfigFromSeparateCerts(clientCertFile, clientKeyFile, caCertFile string) *TLSConfig
Constants ¶
This section is empty.
Variables ¶
var DefaultPasswordCallbacks = struct { // TerminalPrompt prompts the user for a password via terminal input. TerminalPrompt PasswordCallback // EnvVar returns a callback that reads the password from an environment variable. EnvVar func(envVarName string) PasswordCallback // Static returns a callback that returns a static password (not recommended for production). Static func(password string) PasswordCallback }{ TerminalPrompt: func() (string, error) { fmt.Print("Enter P12 password: ") passwordBytes, err := term.ReadPassword(int(syscall.Stdin)) fmt.Println() if err != nil { return "", fmt.Errorf("failed to read password: %w", err) } return string(passwordBytes), nil }, EnvVar: func(envVarName string) PasswordCallback { return func() (string, error) { password := os.Getenv(envVarName) if password == "" { return "", fmt.Errorf("environment variable %s not set or empty", envVarName) } return password, nil } }, Static: func(password string) PasswordCallback { return func() (string, error) { return password, nil } }, }
DefaultPasswordCallbacks provides common password input methods.
var GRPCDialContextFunc = grpc.NewClient
GRPCDialContextFunc is a function variable that can be replaced for testing. It defaults to the standard grpc.NewClient function.
Functions ¶
func GrpcSimpleRetrieve ¶ added in v1.0.9
func GrpcSimpleRetrieve(ctx context.Context, ServerAddress string, AuthenticationPassword string, key string, opts ...grpc.DialOption) (val string, err error)
GrpcSimpleRetrieve retrieves a value from the parameter store using gRPC. It accepts a context for timeout/cancellation control and optional grpc.DialOptions.
func GrpcSimpleRetrieveWithPrebuiltTLS ¶ added in v1.2.2
func GrpcSimpleRetrieveWithPrebuiltTLS(ctx context.Context, ServerAddress string, AuthenticationPassword string, key string, tlsConf *tls.Config, opts ...grpc.DialOption) (val string, err error)
GrpcSimpleRetrieveWithPrebuiltTLS retrieves a value from the parameter store using gRPC with pre-built TLS config. This version accepts a pre-built *tls.Config to avoid password prompts within timeout context.
func GrpcSimpleRetrieveWithTLS ¶ added in v1.2.0
func GrpcSimpleRetrieveWithTLS(ctx context.Context, ServerAddress string, AuthenticationPassword string, key string, tlsConfig *TLSConfig, opts ...grpc.DialOption) (val string, err error)
GrpcSimpleRetrieveWithTLS retrieves a value from the parameter store using gRPC with TLS. It accepts a context, server details, credentials, a key, and TLS configuration.
func GrpcSimpleStore ¶
func GrpcSimpleStore(ctx context.Context, ServerAddress string, AuthenticationPassword string, key string, value string, opts ...grpc.DialOption) (err error)
GrpcSimpleStore stores a key-value pair using gRPC. Accepts a context for timeout/cancellation and optional grpc.DialOptions.
func GrpcSimpleStoreWithPrebuiltTLS ¶ added in v1.2.2
func GrpcSimpleStoreWithPrebuiltTLS(ctx context.Context, ServerAddress string, AuthenticationPassword string, key string, value string, tlsConf *tls.Config, opts ...grpc.DialOption) (err error)
GrpcSimpleStoreWithPrebuiltTLS stores a key-value pair using gRPC with pre-built TLS config. This version accepts a pre-built *tls.Config to avoid password prompts within timeout context.
func GrpcSimpleStoreWithTLS ¶ added in v1.2.0
func GrpcSimpleStoreWithTLS(ctx context.Context, ServerAddress string, AuthenticationPassword string, key string, value string, tlsConfig *TLSConfig, opts ...grpc.DialOption) (err error)
GrpcSimpleStoreWithTLS stores a key-value pair using gRPC with TLS. It accepts a context, server details, credentials, key-value pair, and TLS configuration.
Types ¶
type CertificateSource ¶ added in v1.1.0
CertificateSource holds either a file path to a certificate/key or its raw byte content.
func (*CertificateSource) GetData ¶ added in v1.1.0
func (cs *CertificateSource) GetData() ([]byte, error)
GetData returns the certificate/key data. It prioritizes Bytes if available, otherwise reads from FilePath.
func (*CertificateSource) IsProvided ¶ added in v1.1.0
func (cs *CertificateSource) IsProvided() bool
IsProvided checks if either a file path or byte content has been supplied.
type Client ¶ added in v1.1.0
Client is the main parameter store client
func NewClient ¶ added in v1.1.0
func NewClient(host string, port int, opts ...ClientOption) (*Client, error)
NewClient creates a new parameter store client with sensible defaults
type ClientOption ¶ added in v1.1.0
type ClientOption func(*Client)
ClientOption is a function that configures a Client
func WithTLS ¶ added in v1.2.0
func WithTLS(tlsConfig *TLSConfig) ClientOption
WithTLS configures the client with TLS settings.
func WithTimeout ¶ added in v1.1.0
func WithTimeout(timeout time.Duration) ClientOption
WithTimeout sets a custom timeout for the client
type PasswordCallback ¶ added in v1.2.0
PasswordCallback is a function type for securely obtaining passwords. It should return the password and any error that occurred during retrieval.
type TLSConfig ¶ added in v1.2.0
type TLSConfig struct {
// Separate certificate and key (PEM format)
ClientCert CertificateSource
ClientKey CertificateSource
CACert CertificateSource
// PKCS#12 (.p12/.pfx) support
P12File string
P12Bytes []byte
P12PasswordFn PasswordCallback
// ServerName for TLS verification (optional)
ServerName string
// InsecureSkipVerify disables certificate verification (for testing only)
InsecureSkipVerify bool
}
TLSConfig holds TLS configuration for the client, supporting multiple certificate formats.
func NewTLSConfigFromP12Bytes ¶ added in v1.2.0
func NewTLSConfigFromP12Bytes(p12Data []byte, passwordFn PasswordCallback) *TLSConfig
NewTLSConfigFromP12Bytes creates a TLS config using PKCS#12 data.
func NewTLSConfigFromP12File ¶ added in v1.2.0
func NewTLSConfigFromP12File(p12File string, passwordFn PasswordCallback) *TLSConfig
NewTLSConfigFromP12File creates a TLS config using a PKCS#12 file.
func NewTLSConfigFromSeparateCertBytes ¶ added in v1.2.0
NewTLSConfigFromSeparateCertBytes creates a TLS config using separate cert/key data.
func NewTLSConfigFromSeparateCerts ¶ added in v1.2.0
NewTLSConfigFromSeparateCerts creates a TLS config using separate cert/key files.
func (*TLSConfig) GetTLSConfig ¶ added in v1.2.0
GetTLSConfig builds and returns a *tls.Config based on the configuration.
func (*TLSConfig) IsConfigured ¶ added in v1.2.0
IsConfigured returns true if any TLS configuration is provided.