Documentation
¶
Index ¶
- Constants
- func ContextWithEnvironmentGetter(ctx context.Context, getter EnvironmentGetter) context.Context
- type ClientId
- type ClientSecret
- type DefaultEnvironmentGetter
- type DirectoryOverrideEnvironmentGetter
- type EnvironmentGetter
- type JWT
- type Manager
- type MapEnvironmentGetter
- type ProjectToken
- type ProjectTokens
- type SourcedConfig
- type SourcedValueT
Constants ¶
const ApiServerEnvVarKey = "CHALK_API_SERVER"
const ClientIdEnvVarKey = "CHALK_CLIENT_ID"
const ClientSecretEnvVarKey = "CHALK_CLIENT_SECRET"
const EnvironmentEnvVarKey = "CHALK_ACTIVE_ENVIRONMENT"
Variables ¶
This section is empty.
Functions ¶
func ContextWithEnvironmentGetter ¶
func ContextWithEnvironmentGetter(ctx context.Context, getter EnvironmentGetter) context.Context
Types ¶
type ClientSecret ¶
type ClientSecret string
type DefaultEnvironmentGetter ¶
type DefaultEnvironmentGetter struct {
EnvironmentGetter
}
func (DefaultEnvironmentGetter) Abs ¶
func (d DefaultEnvironmentGetter) Abs(path string) (string, error)
func (DefaultEnvironmentGetter) Getenv ¶
func (d DefaultEnvironmentGetter) Getenv(key string) string
func (DefaultEnvironmentGetter) Getwd ¶
func (d DefaultEnvironmentGetter) Getwd() (string, error)
type DirectoryOverrideEnvironmentGetter ¶
type DirectoryOverrideEnvironmentGetter struct {
EnvironmentGetter
// contains filtered or unexported fields
}
DirectoryOverrideEnvironmentGetter wraps another EnvironmentGetter but overrides the working directory
func NewDirectoryOverrideEnvironmentGetter ¶
func NewDirectoryOverrideEnvironmentGetter(base EnvironmentGetter, dir string) *DirectoryOverrideEnvironmentGetter
func (*DirectoryOverrideEnvironmentGetter) Abs ¶
func (d *DirectoryOverrideEnvironmentGetter) Abs(path string) (string, error)
func (*DirectoryOverrideEnvironmentGetter) Getenv ¶
func (d *DirectoryOverrideEnvironmentGetter) Getenv(key string) string
func (*DirectoryOverrideEnvironmentGetter) Getwd ¶
func (d *DirectoryOverrideEnvironmentGetter) Getwd() (string, error)
type EnvironmentGetter ¶
type EnvironmentGetter interface {
Getenv(key string) string
Getwd() (string, error)
Abs(path string) (string, error)
}
EnvironmentGetter is an interface for getting environment variables and the current working directory. This can help with testing by making otherwise impure functions pure.
func EnvironmentGetterFromContext ¶
func EnvironmentGetterFromContext(ctx context.Context) EnvironmentGetter
type Manager ¶
type Manager struct {
ApiServer SourcedConfig[string]
ClientId SourcedConfig[ClientId]
ClientSecret SourcedConfig[ClientSecret]
EnvironmentId SourcedConfig[string]
Scope SourcedConfig[string]
}
func NewManager ¶
func NewManager( ctx context.Context, apiServer SourcedConfig[string], clientId SourcedConfig[ClientId], clientSecret SourcedConfig[ClientSecret], environmentId SourcedConfig[string], configDir *string, ) (*Manager, error)
NewManager creates a new configuration manager with the specified parameters
type MapEnvironmentGetter ¶
type MapEnvironmentGetter struct {
EnvironmentGetter
Env map[string]string
Wd string
}
func NewMockEnvironmentGetter ¶
func NewMockEnvironmentGetter( env map[string]string, wd string, ) *MapEnvironmentGetter
func (MapEnvironmentGetter) Getenv ¶
func (m MapEnvironmentGetter) Getenv(key string) string
func (MapEnvironmentGetter) Getwd ¶
func (m MapEnvironmentGetter) Getwd() (string, error)
type ProjectToken ¶
type ProjectToken struct {
Name string `yaml:"name"`
ClientId ClientId `yaml:"clientId"`
ClientSecret ClientSecret `yaml:"clientSecret"`
ValidUntil string `yaml:"validUntil"`
ApiServer string `yaml:"apiServer"`
ActiveEnvironment string `yaml:"activeEnvironment"`
JWT JWT `yaml:"jwt,omitempty"`
}
func GetProjectAuthConfig ¶
type ProjectTokens ¶
type ProjectTokens struct {
Tokens map[string]*ProjectToken `yaml:"tokens,omitempty"`
}
type SourcedConfig ¶
type SourcedConfig[T SourcedValueT] struct { Value T Source string }
SourcedConfig represents a configuration value along with information about where it came from
func GetFirstNonEmpty ¶
func GetFirstNonEmpty[T SourcedValueT](configs ...SourcedConfig[T]) SourcedConfig[T]
GetFirstNonEmpty returns the first non-empty SourcedConfig from the provided list using the provided zero-check function
func NewFromArg ¶
func NewFromArg[T SourcedValueT](value T) SourcedConfig[T]
NewFromArg creates a SourcedConfig from a direct argument
func NewFromEnvVar ¶
func NewFromEnvVar[T ~string](ctx context.Context, key string) SourcedConfig[T]
func NewFromFile ¶
func NewFromFile[T SourcedValueT](path string, value T) SourcedConfig[T]
NewFromFile creates a SourcedConfig from a config file