Documentation
¶
Index ¶
- func LockFilePath(dir string) string
- func ParseDocumentType(docType string) (baseType, variant string)
- type AttachmentConfig
- type CacheEntry
- type ChangeOp
- type Clients
- type Config
- type ConfigurationChange
- func GetChanges(ctx context.Context, clients Clients, conf *Config, schemas []LoadedSchema, ...) ([]ConfigurationChange, error)
- func GetGenerationChanges(ctx context.Context, clients Clients, conf *Config, schemas []LoadedSchema, ...) ([]ConfigurationChange, error)
- func GetMetaTypeChanges(ctx context.Context, clients Clients, conf *Config) ([]ConfigurationChange, error)
- func GetMetricsChanges(ctx context.Context, clients Clients, conf *Config) ([]ConfigurationChange, error)
- func GetSchemaChanges(ctx context.Context, clients Clients, conf *Config, loaded []LoadedSchema, ...) ([]ConfigurationChange, error)
- func GetStatusChanges(ctx context.Context, clients Clients, conf *Config) ([]ConfigurationChange, error)
- func GetTypeConfigurationChanges(ctx context.Context, clients Clients, conf *Config) ([]ConfigurationChange, error)
- func GetWorkflowChanges(ctx context.Context, clients Clients, conf *Config) ([]ConfigurationChange, error)
- type DocWorkflowUpdate
- type DocumentConfig
- type DocumentWorkflow
- type ExemplarLock
- type GitSchemaSource
- type HttpSchemaSource
- type LabelExpression
- type LoadedExemplar
- type LoadedSchema
- type MetricAggregation
- type MetricKind
- type MetricUpdate
- type SchemaCache
- type SchemaLock
- type SchemaLockfile
- type SchemaSet
- type SchemaSource
- type StaticClients
- type TimeExpression
- type TypeConfigSpec
- type TypeConfigurationChange
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LockFilePath ¶
func ParseDocumentType ¶ added in v1.1.0
ParseDocumentType splits a document type string into its base type and optional variant. For "core/article#timeless" it returns ("core/article", "timeless"). For "core/article" it returns ("core/article", "").
Types ¶
type AttachmentConfig ¶
type CacheEntry ¶
type Clients ¶
type Clients interface {
GetWorkflows() repository.Workflows
GetSchemas() repository.Schemas
GetMetrics() repository.Metrics
}
Clients provides access to the elephant repository API services.
type Config ¶
type Config struct {
Documents []DocumentConfig `hcl:"document,block"`
SchemaSets []SchemaSet `hcl:"schema_set,block"`
Metric []MetricKind `hcl:"metric,block"`
}
func ReadConfigFromDirectory ¶
type ConfigurationChange ¶
type ConfigurationChange interface {
Describe() (ChangeOp, string)
Execute(ctx context.Context, c Clients) error
}
func GetChanges ¶
func GetChanges( ctx context.Context, clients Clients, conf *Config, schemas []LoadedSchema, exemplars []LoadedExemplar, activation repository.SchemaActivation, ) ([]ConfigurationChange, error)
GetChanges computes all configuration changes needed to bring the remote state in line with the desired configuration. Schema changes use RegisterGeneration with the given activation status.
func GetGenerationChanges ¶ added in v1.0.0
func GetGenerationChanges( ctx context.Context, clients Clients, conf *Config, schemas []LoadedSchema, exemplars []LoadedExemplar, activation repository.SchemaActivation, ) ([]ConfigurationChange, error)
GetGenerationChanges computes only the schema generation change, skipping all other configuration domains. Used by the "generation pending" command.
func GetMetaTypeChanges ¶
func GetMetricsChanges ¶
func GetSchemaChanges ¶
func GetSchemaChanges( ctx context.Context, clients Clients, conf *Config, loaded []LoadedSchema, exemplars []LoadedExemplar, activation repository.SchemaActivation, ) ([]ConfigurationChange, error)
GetSchemaChanges computes the schema changes needed to bring the remote state in line with the desired configuration. With schema generations, this produces at most one change: a generationChange that registers all schemas as a generation.
func GetStatusChanges ¶
func GetWorkflowChanges ¶
type DocWorkflowUpdate ¶
type DocWorkflowUpdate struct {
Operation ChangeOp
Type string
Current *DocumentWorkflow
Wanted *DocumentWorkflow
// contains filtered or unexported fields
}
func (*DocWorkflowUpdate) Describe ¶
func (d *DocWorkflowUpdate) Describe() (ChangeOp, string)
Describe implements ConfigurationChange.
type DocumentConfig ¶
type DocumentConfig struct {
Type string `hcl:"type,label"`
MetaDocType string `hcl:"meta_doc,optional"`
Statuses []string `hcl:"statuses,optional"`
Workflow *DocumentWorkflow `hcl:"workflow,optional"`
Attachments []AttachmentConfig `hcl:"attachment,block"`
BoundedCollection bool `hcl:"bounded_collection,optional"`
TimeExpressions []TimeExpression `hcl:"time_expression,block"`
LabelExpressions []LabelExpression `hcl:"label_expression,block"`
Variants []string `hcl:"variants,optional"`
}
type DocumentWorkflow ¶
type ExemplarLock ¶ added in v1.0.0
type ExemplarLock struct {
DocType string `json:"doc_type"`
Name string `json:"name"`
Hash string `json:"hash"`
}
ExemplarLock is a locked exemplar entry in the lockfile.
func ExemplarLocks ¶ added in v1.0.0
func ExemplarLocks(exemplars []LoadedExemplar) []ExemplarLock
ExemplarLocks extracts the lock entries from loaded exemplars.
type GitSchemaSource ¶
type GitSchemaSource struct {
// contains filtered or unexported fields
}
func NewGitSchemaSource ¶
func (*GitSchemaSource) LoadSchema ¶
func (g *GitSchemaSource) LoadSchema(ctx context.Context, name string) (LoadedSchema, error)
LoadSchema implements SchemaSource.
type HttpSchemaSource ¶
type HttpSchemaSource struct {
// contains filtered or unexported fields
}
func NewHttpSchemaSource ¶
func (*HttpSchemaSource) LoadSchema ¶
func (h *HttpSchemaSource) LoadSchema( ctx context.Context, name string, ) (_ LoadedSchema, outErr error)
LoadSchema implements SchemaSource.
type LabelExpression ¶
type LoadedExemplar ¶ added in v1.0.0
type LoadedExemplar struct {
Lock ExemplarLock
Document newsdoc.Document
Canonical []byte
}
LoadedExemplar is an exemplar document loaded from disk with its canonical form and hash.
func LoadExemplars ¶ added in v1.0.0
func LoadExemplars(dir string) ([]LoadedExemplar, error)
LoadExemplars recursively loads all .json files from the exemplars directory. The document type is determined from the "type" field in each document, not from the directory structure.
type LoadedSchema ¶
type LoadedSchema struct {
Lock SchemaLock
Data []byte
}
func LoadSchemaSet ¶
func LoadSchemaSet( ctx context.Context, set SchemaSet, lockfile *SchemaLockfile, init bool, ) (_ []LoadedSchema, outErr error)
type MetricAggregation ¶
type MetricAggregation string
const ( MetricAggregationReplace MetricAggregation = "replace" MetricAggregationIncrement MetricAggregation = "increment" )
type MetricKind ¶
type MetricKind struct {
Kind string `hcl:"kind,label"`
Aggregation MetricAggregation `hcl:"aggregation,optional"`
}
type MetricUpdate ¶
type MetricUpdate struct {
Operation ChangeOp
Kind string
OldAggregation MetricAggregation
Aggregation MetricAggregation
}
func (*MetricUpdate) Describe ¶
func (m *MetricUpdate) Describe() (ChangeOp, string)
Describe implements ConfigurationChange.
type SchemaCache ¶
type SchemaCache struct {
// contains filtered or unexported fields
}
func NewSchemaCache ¶
func NewSchemaCache() (*SchemaCache, error)
type SchemaLock ¶
type SchemaLockfile ¶
type SchemaLockfile struct {
Updated time.Time `json:"updated"`
Schemas map[string]SchemaLock `json:"schemas"`
Exemplars []ExemplarLock `json:"exemplars,omitempty"`
}
SchemaLockfile tracks the locked versions and hashes of schemas and exemplars.
func LoadLockFile ¶
func LoadLockFile(fileName string) (*SchemaLockfile, error)
LoadLockFile reads and parses a lockfile from disk.
func NewSchemaLockFile ¶
func NewSchemaLockFile( schemas []LoadedSchema, exemplars []ExemplarLock, ) *SchemaLockfile
NewSchemaLockFile creates a lockfile from loaded schemas and exemplars.
func (*SchemaLockfile) Check ¶
func (lf *SchemaLockfile) Check( name string, loaded LoadedSchema, init bool, ) error
Check validates that a loaded schema matches the lockfile entry.
func (*SchemaLockfile) CheckExemplars ¶ added in v1.0.0
func (lf *SchemaLockfile) CheckExemplars(exemplars []LoadedExemplar) error
CheckExemplars validates that loaded exemplars match the lockfile entries.
func (*SchemaLockfile) Save ¶
func (lf *SchemaLockfile) Save(fileName string) error
Save writes the lockfile to disk.
type SchemaSource ¶
type SchemaSource interface {
LoadSchema(ctx context.Context, name string) (LoadedSchema, error)
}
type StaticClients ¶
type StaticClients struct {
Workflows repository.Workflows
Schemas repository.Schemas
Metrics repository.Metrics
}
StaticClients is a simple Clients implementation with fixed service clients.
func (*StaticClients) GetMetrics ¶
func (c *StaticClients) GetMetrics() repository.Metrics
GetMetrics implements Clients.
func (*StaticClients) GetSchemas ¶
func (c *StaticClients) GetSchemas() repository.Schemas
GetSchemas implements Clients.
func (*StaticClients) GetWorkflows ¶
func (c *StaticClients) GetWorkflows() repository.Workflows
GetWorkflows implements Clients.
type TimeExpression ¶
type TimeExpression struct {
// Expression is a newsdoc value extraction expression.
Expression string `hcl:"expression"`
// Layout is the time/date format to use when parsing. Optional,
// defaults to RFC3339 or ISO 8601 for values annotated as dates.
Layout string `hcl:"layout,optional"`
// Timezone is the timezone the time should be parsed in. Optional, most
// timestamps should include timezone information, if they don't,
// parsing will fall back to the default timezone that the repository
// has been configured with.
Timezone string `hcl:"timezone,optional"`
}
type TypeConfigSpec ¶
type TypeConfigSpec struct {
Bounded bool
TimeExpressions []TimeExpression
LabelExpressions []LabelExpression
Variants []string
}
type TypeConfigurationChange ¶
type TypeConfigurationChange struct {
Operation ChangeOp
Type string
Current TypeConfigSpec
Wanted TypeConfigSpec
// contains filtered or unexported fields
}
func (*TypeConfigurationChange) Describe ¶
func (t *TypeConfigurationChange) Describe() (ChangeOp, string)
Describe implements ConfigurationChange.