Documentation
¶
Overview ¶
Copyright (c) 2016-2019 Uber Technologies, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Package configutil provides an interface for loading and validating configuration data from YAML files.
Other YAML files could be included via the following directive:
production.yaml: extends: base.yaml
There is no multiple inheritance supported. Dependency tree suppossed to form a directed acyclic graph(DAG).
Values from multiple configurations within the same hierarchy are deep merged ¶
Package support multiple configuraton directories potentially having multiple files with the the same name. In this the we just follow the path in extends and load all the file accroding to the relative directory, i.e configA: base.yaml production.yaml(extends base.yaml), configB: base.yaml the load sequance will be the following: configA(base.yaml), configA(production.yaml)
Note regarding configuration merging:
Array defined in YAML will be overriden based on load sequence. e.g. in the base.yaml: sports: - football in the development.yaml: extends: base.yaml sports: - basketball after the merge: sports: - basketball // only keep the latest one Map defined in YAML will be merged together based on load sequence. e.g. in the base.yaml: sports: football: true in the development.yaml: extends: base.yaml sports: basketball: true after the merge: sports: // combine all the map fields football: true basketball: true
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCycleRef = errors.New("cyclic reference in configuration extends detected")
ErrCycleRef is returned when there are circular dependencies detected in configuraiton files extending each other.
var ErrNoFilesToLoad = errors.New("attempt to load configuration with no files")
ErrNoFilesToLoad is returned when you attemp to call LoadFiles without valid file paths.
Functions ¶
func FilterCandidates ¶
FilterCandidates filters candidate config files into only the ones that exist.
Types ¶
type Extends ¶
type Extends struct {
Extends string `yaml:"extends"`
}
Extends define a keywoword in config for extending a base configuration file.
type ValidationError ¶
type ValidationError struct {
// contains filtered or unexported fields
}
ValidationError is the returned when a configuration fails to pass validation.
func (ValidationError) ErrForField ¶
func (e ValidationError) ErrForField(name string) error
ErrForField returns the validation error for the given field.
func (ValidationError) Error ¶
func (e ValidationError) Error() string