Documentation
¶
Index ¶
- Constants
- Variables
- func WithActor(ctx context.Context, actor *Actor) context.Context
- type APIKey
- type Actor
- type AuditEntry
- type ContextField
- type ContextFieldReference
- type ContextReference
- type ContextSchema
- type ContextSchemaConflictError
- type ContextType
- type Environment
- type EvalContext
- type FlagConfig
- type FlagUsageBucket
- type FlagUsageEvent
- type FlagUsageLatencyBucket
- type FlagUsageQuery
- type FlagUsageRecorder
- type FlagUsageSource
- type FlagValue
- type Rollout
- type Rule
- type Store
- type User
- type ValidationError
- type ValidationIssue
- type ValueType
Constants ¶
View Source
const ( AuditActionCreated = "created" AuditActionUpdated = "updated" AuditActionDeleted = "deleted" )
Audit actions.
View Source
const ( ContextTypeString = evalcore.ContextTypeString ContextTypeInt = evalcore.ContextTypeInt ContextTypeDouble = evalcore.ContextTypeDouble ContextTypeBool = evalcore.ContextTypeBool ContextTypeTimestamp = evalcore.ContextTypeTimestamp ContextTypeList = evalcore.ContextTypeList ContextTypeMap = evalcore.ContextTypeMap )
View Source
const ( ValueTypeBoolean = evalcore.ValueTypeBoolean ValueTypeString = evalcore.ValueTypeString ValueTypeNumber = evalcore.ValueTypeNumber ValueTypeJSON = evalcore.ValueTypeJSON )
View Source
const ( ValidationIssueParseError = "parse_error" ValidationIssueUnknownField = "unknown_field" ValidationIssueNonBoolExpression = "non_bool_expression" ValidationIssueInvalidRollout = "invalid_rollout" ValidationIssueMissingBucket = "missing_bucket_field" ValidationIssueInvalidValueType = "invalid_value_type" ValidationIssueInvalidValue = "invalid_value" )
View Source
const DefaultEnvironmentKey = "production"
View Source
const ResourceTypeFlag = "flag"
Audit resource types. Only flags are recorded for now, but the audit_logs table is generic so other resources can be added without a migration.
Variables ¶
View Source
var ( ErrAuthNotConfigured = errors.New("auth is not configured") ErrInvalidCredentials = errors.New("invalid credentials") ErrUserNotAllowed = errors.New("user is not allowed") ErrSessionNotFound = errors.New("session not found") ErrAPIKeyNotFound = errors.New("api key not found") )
View Source
var ( ErrFlagNotFound = errors.New("flag not found") ErrRuleNotFound = errors.New("rule not found") ErrEnvironmentNotFound = errors.New("environment not found") ErrEnvironmentKeyTaken = errors.New("environment key already in use") ErrEnvironmentInUse = errors.New("environment is in use") ErrDefaultEnvironment = errors.New("default environment cannot be deleted") ErrContextNotFound = errors.New("context not found") ErrContextNameTaken = errors.New("context name already in use") ErrContextHasReferers = errors.New("context referenced by flags") )
Functions ¶
Types ¶
type Actor ¶
Actor identifies who performed a mutation. It is carried on the request context by the admin auth middleware and read by the store when writing audit metadata. When auth is disabled the actor is nil.
func ActorFromContext ¶
ActorFromContext returns the actor carried on ctx, or nil if none is set.
type AuditEntry ¶
type AuditEntry struct {
ID string
EnvironmentID string
ResourceType string
ResourceID string
Action string
Version int
Snapshot *FlagConfig
ActorID *string
ActorLabel *string
CreatedAt time.Time
}
AuditEntry is a single version in a resource's change history. Each entry stores the full snapshot of the resource as it existed after the change (nil for a delete), so consecutive entries can be diffed to show exactly what changed.
type ContextField ¶
type ContextField = evalcore.ContextField
type ContextFieldReference ¶
type ContextReference ¶
type ContextReference struct {
ContextID string
EnvironmentID string
EnvironmentKey string
FlagKey string
RuleCount int
ReferencedFields []ContextFieldReference
Flag FlagConfig
}
type ContextSchema ¶
type ContextSchema = evalcore.ContextSchema
type ContextSchemaConflictError ¶
type ContextSchemaConflictError struct {
Issues []ValidationIssue
}
func (*ContextSchemaConflictError) Error ¶
func (e *ContextSchemaConflictError) Error() string
type ContextType ¶
type ContextType = evalcore.ContextType
type Environment ¶
type EvalContext ¶
type EvalContext = evalcore.EvalContext
type FlagConfig ¶
type FlagConfig = evalcore.FlagConfig
type FlagUsageBucket ¶
type FlagUsageEvent ¶
type FlagUsageLatencyBucket ¶
type FlagUsageQuery ¶
type FlagUsageRecorder ¶
type FlagUsageRecorder interface {
RecordFlagUsage(ctx context.Context, event FlagUsageEvent) error
}
type FlagUsageSource ¶
type Store ¶
type Store interface {
ListEnvironments(ctx context.Context) ([]*Environment, error)
GetEnvironment(ctx context.Context, id string) (*Environment, error)
GetEnvironmentByKey(ctx context.Context, key string) (*Environment, error)
CreateEnvironment(ctx context.Context, env *Environment) error
UpdateEnvironment(ctx context.Context, env *Environment) error
DeleteEnvironment(ctx context.Context, id string) error
GetFlag(ctx context.Context, environmentID, key string) (*FlagConfig, error)
ListFlags(ctx context.Context, environmentID string) ([]*FlagConfig, error)
SaveFlag(ctx context.Context, environmentID string, flag *FlagConfig) error
DeleteFlag(ctx context.Context, environmentID, key string) error
ListFlagAuditLog(ctx context.Context, environmentID, flagKey string) ([]*AuditEntry, error)
GetRule(ctx context.Context, environmentID, flagKey, ruleID string) (*Rule, error)
CreateRule(ctx context.Context, environmentID, flagKey string, rule Rule) error
UpdateRule(ctx context.Context, environmentID, flagKey string, rule Rule) error
DeleteRule(ctx context.Context, environmentID, flagKey, ruleID string) error
ReorderRules(ctx context.Context, environmentID, flagKey string, ruleIDs []string) error
ListContexts(ctx context.Context) ([]*ContextSchema, error)
GetContext(ctx context.Context, id string) (*ContextSchema, error)
CreateContext(ctx context.Context, c *ContextSchema) error
UpdateContext(ctx context.Context, c *ContextSchema) error
DeleteContext(ctx context.Context, id string) error
}
type ValidationError ¶
type ValidationError struct {
Message string `json:"message"`
Issues []ValidationIssue `json:"issues"`
}
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
type ValidationIssue ¶
Click to show internal directories.
Click to hide internal directories.