Documentation ¶
Overview ¶
Package config merges together multiple configurations.
Index ¶
- func Converge(shards map[string]*configpb.Configuration) (*configpb.Configuration, error)
- func Fields(cfg *configpb.Configuration) map[string]int64
- func FindDashboard(name string, cfg *configpb.Configuration) *configpb.Dashboard
- func FindTestGroup(name string, cfg *configpb.Configuration) *configpb.TestGroup
- func InitCache()
- func MarshalBytes(c *configpb.Configuration) ([]byte, error)
- func MarshalText(c *configpb.Configuration, w io.Writer) error
- func Normalize(s string) string
- func Read(ctx context.Context, path string, client *storage.Client) (*configpb.Configuration, error)
- func ReadGCS(ctx context.Context, opener gcs.Opener, path gcs.Path) (*configpb.Configuration, error)
- func ReadPath(path string) (*configpb.Configuration, error)
- func RenameDashboard(original, new string, cfg *configpb.Configuration) *configpb.Configuration
- func RenameDashboardGroup(original, new string, cfg *configpb.Configuration) *configpb.Configuration
- func RenameDashboardOrGroup(original, new string, cfg *configpb.Configuration) *configpb.Configuration
- func RenameTestGroup(original, new string, cfg *configpb.Configuration) *configpb.Configuration
- func Unmarshal(r io.Reader) (*configpb.Configuration, error)
- func Validate(c *configpb.Configuration) error
- type Config
- type DashboardQueue
- type DuplicateNameError
- type MissingEntityError
- type MissingFieldError
- type TestGroupQueue
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Converge ¶ added in v0.0.39
func Converge(shards map[string]*configpb.Configuration) (*configpb.Configuration, error)
Converge merges together the Configurations given in the map set. If there are duplicate entries, the string key may be added as a prefix to maintain uniqueness for Dashboards, DashboardGroups, and TestGroups. The config at key "" will not be modified.
The output protobuf will pass config.Validate if all its inputs pass config.Validate
func Fields ¶ added in v0.0.96
func Fields(cfg *configpb.Configuration) map[string]int64
Fields returns counts of all of the primitive fields in this configuration
Field names in the map are qualified with where they are nested; this is not the same as a message's "FullName" Ex: A dashboard tab's name is "dashboards.dashboard_tab.name"
func FindDashboard ¶
func FindDashboard(name string, cfg *configpb.Configuration) *configpb.Dashboard
FindDashboard returns the configpb.Dashboard proto for a given Dashboard name.
func FindTestGroup ¶
func FindTestGroup(name string, cfg *configpb.Configuration) *configpb.TestGroup
FindTestGroup returns the configpb.TestGroup proto for a given TestGroup name.
func InitCache ¶ added in v0.0.117
func InitCache()
InitCache clears the cache of configs, forcing the next ReadGCS call to fetch fresh from GCS.
Used primarily for testing
func MarshalBytes ¶
func MarshalBytes(c *configpb.Configuration) ([]byte, error)
MarshalBytes returns the wire-encoded protobuf data for the parsed configuration. Returns an error if config is invalid or encoding failed.
func MarshalText ¶
func MarshalText(c *configpb.Configuration, w io.Writer) error
MarshalText writes a text version of the parsed configuration to the supplied io.Writer. Returns an error if config is invalid or writing failed.
func Normalize ¶ added in v0.0.77
Normalize lowercases, and removes all non-alphanumeric characters from a string.
func Read ¶
func Read(ctx context.Context, path string, client *storage.Client) (*configpb.Configuration, error)
Read will read the Configuration proto message from a local or gs:// path.
The ctx and client are only relevant when path refers to GCS.
func ReadGCS ¶
func ReadGCS(ctx context.Context, opener gcs.Opener, path gcs.Path) (*configpb.Configuration, error)
ReadGCS opens the config at path and unmarshals it into a Configuration proto.
If it has been read recently, a cached version will be served.
func ReadPath ¶
func ReadPath(path string) (*configpb.Configuration, error)
ReadPath reads the config from the specified local file path.
func RenameDashboard ¶ added in v0.0.39
func RenameDashboard(original, new string, cfg *configpb.Configuration) *configpb.Configuration
RenameDashboard renames all references to Dashboard 'original' to 'new'. Does not verify if the new name is already taken.
func RenameDashboardGroup ¶ added in v0.0.39
func RenameDashboardGroup(original, new string, cfg *configpb.Configuration) *configpb.Configuration
RenameDashboardGroup renames all references to DashboardGroup 'original' to 'new'. Does not verify if the new name is already taken.
func RenameDashboardOrGroup ¶ added in v0.0.39
func RenameDashboardOrGroup(original, new string, cfg *configpb.Configuration) *configpb.Configuration
RenameDashboardOrGroup renames all Dashboards and DashboardGroups named 'original' to 'new'. Since Dashboards and Dashboard Groups can't share names with each other, a valid Configuration will rename at most one item.
func RenameTestGroup ¶ added in v0.0.39
func RenameTestGroup(original, new string, cfg *configpb.Configuration) *configpb.Configuration
RenameTestGroup renames all references to TestGroup 'original' to 'new'. Does not verify if the new name is already taken.
func Unmarshal ¶
func Unmarshal(r io.Reader) (*configpb.Configuration, error)
Unmarshal reads a protocol buffer into memory
func Validate ¶
func Validate(c *configpb.Configuration) error
Validate checks that a configuration is well-formed.
Types ¶
type DashboardQueue ¶ added in v0.0.108
DashboardQueue sends dashboard names at a specific frequency.
func (*DashboardQueue) FixTestGroups ¶ added in v0.0.108
FixTestGroups will fix all the dashboards associated with the groups.
func (*DashboardQueue) Init ¶ added in v0.0.108
func (q *DashboardQueue) Init(log logrus.FieldLogger, dashboards []*configpb.Dashboard, when time.Time)
Init (or reinit) the queue with the specified configuration.
type DuplicateNameError ¶ added in v0.0.3
DuplicateNameError is an error that includes the duplicate name.
func (DuplicateNameError) Error ¶ added in v0.0.3
func (e DuplicateNameError) Error() string
type MissingEntityError ¶ added in v0.0.4
MissingEntityError is an error that includes the missing entity.
func (MissingEntityError) Error ¶ added in v0.0.4
func (e MissingEntityError) Error() string
type MissingFieldError ¶
type MissingFieldError struct {
Field string
}
MissingFieldError is an error that includes the missing root field. Entities that contain no children should use a ValidationError, so they can point to the empty Entity
func (MissingFieldError) Error ¶
func (e MissingFieldError) Error() string
type TestGroupQueue ¶ added in v0.0.76
TestGroupQueue can send test groups to receivers at a specific frequency.
Also contains the ability to modify the next time to send groups. First call must be to Init(). Exported methods are safe to call concurrently.
func (*TestGroupQueue) Init ¶ added in v0.0.76
func (q *TestGroupQueue) Init(log logrus.FieldLogger, testGroups []*configpb.TestGroup, when time.Time)
Init (or reinit) the queue with the specified groups, which should be updated at frequency.
func (*TestGroupQueue) Send ¶ added in v0.0.76
func (q *TestGroupQueue) Send(ctx context.Context, receivers chan<- *configpb.TestGroup, frequency time.Duration) error
Send test groups to receivers until the context expires.
Pops items off the queue when frequency is zero. Otherwise reschedules the item after the specified frequency has elapsed.
type ValidationError ¶ added in v0.0.72
ValidationError is an error for invalid configuration that includes what entity errored.
func (ValidationError) Error ¶ added in v0.0.72
func (e ValidationError) Error() string