Documentation
¶
Overview ¶
Package configs provides configuration structures and utilities for the application. note that only configurations that can be reused by addons will be included here
Index ¶
Constants ¶
const DefaultIAMRuntimeTimeoutSeconds = 15
DefaultIAMRuntimeTimeoutSeconds is the default timeout for the IAM runtime
Variables ¶
var ( // ErrInvalidNATSAuthMode is returned when an invalid NATS authentication mode is provided ErrInvalidNATSAuthMode = errors.New("invalid NATS authentication mode") // ErrMissingNATSCreds is returned when nats creds are not provided ErrMissingNATSCreds = errors.New("nats creds are required") )
Functions ¶
func AddIAMRuntimeFlags ¶
AddIAMRuntimeFlags adds iam-runtime flags to the given FlagSet
func AddNATSFlags ¶
AddNATSFlags adds NATS flags to the given FlagSet
func AddWorkloadIdentityFlags ¶
AddWorkloadIdentityFlags adds workload identity federation flags to the given FlagSet.
Types ¶
type Configs ¶
type Configs struct {
WorkloadIdentity WorkloadIdentityConfig `mapstructure:"workload-identity"`
IAMRuntime IAMRuntimeConfig `mapstructure:"iam-runtime"`
NATS NATSConfig `mapstructure:"nats"`
}
Configs holds the configuration for the application.
type IAMRuntimeConfig ¶
type IAMRuntimeConfig struct {
Socket string `mapstructure:"socket"`
Timeout time.Duration `mapstructure:"timeout"`
}
IAMRuntimeConfig holds the configuration for the IAM runtime.
func (*IAMRuntimeConfig) ToTokenSource ¶
func (c *IAMRuntimeConfig) ToTokenSource(ctx context.Context, dialOpts ...grpc.DialOption) (oauth2.TokenSource, error)
ToTokenSource creates a new oauth2.TokenSource from the IAM runtime config.
func (*IAMRuntimeConfig) Validate ¶
func (c *IAMRuntimeConfig) Validate() error
Validate validates the IAM runtime configuration.
type NATSAuthMode ¶
type NATSAuthMode string
NATSAuthMode represents the authentication modes for NATS
const ( // AuthModeCredsFileOnly is the auth mode for using a credentials file only AuthModeCredsFileOnly NATSAuthMode = "creds-file-only" // AuthModeWorkloadIdentity is the auth mode for using workload identity AuthModeWorkloadIdentity NATSAuthMode = "workload-identity" // AuthModeIAMRuntime is the auth mode for using IAM runtime AuthModeIAMRuntime NATSAuthMode = "iam-runtime" )
type NATSConfig ¶
type NATSConfig struct {
URL string `mapstructure:"url"`
CredsFile string `mapstructure:"creds-file"`
SubjectPrefix string `mapstructure:"subject-prefix"`
AuthMode NATSAuthMode `mapstructure:"auth-mode"`
}
NATSConfig holds the configuration for NATS
func (*NATSConfig) ToNATSConnection ¶
ToNATSConnection creates a NATS connection based on a config
func (*NATSConfig) Validate ¶
func (c *NATSConfig) Validate() error
Validate validates the NATS configuration.
type Opt ¶
type Opt func(*optionals)
Opt is a functional option type for configuring optional parameters.
func WithTokenSource ¶
func WithTokenSource(ts oauth2.TokenSource) Opt
WithTokenSource sets the token source in the options.
type WorkloadIdentityConfig ¶
type WorkloadIdentityConfig struct {
TokenURL string `mapstructure:"token-url"`
KubeServiceAccount string `mapstructure:"kube-service-account"`
Scopes []string `mapstructure:"scopes"`
Audience string `mapstructure:"audience"`
SubjectTokenType string `mapstructure:"subject-token-type"`
}
WorkloadIdentityConfig holds the configuration for workload identity federation.
func (*WorkloadIdentityConfig) ToTokenSource ¶
func (c *WorkloadIdentityConfig) ToTokenSource(ctx context.Context) (oauth2.TokenSource, error)
ToTokenSource creates a token source from a config
func (*WorkloadIdentityConfig) Validate ¶
func (c *WorkloadIdentityConfig) Validate() error
Validate validates the workload identity configuration.