Documentation
¶
Index ¶
- func PreprocessContent(content []byte, vars map[string]any) ([]byte, error)
- func PreprocessContentIntoWriter(content []byte, vars map[string]any, writer io.Writer) error
- func PreprocessFile(templateFilePath string, vars map[string]any) ([]byte, error)
- func ValidateConfigMetaSchema(config map[string]any) error
- type ConfigProvider
- type ConfigReplacements
- type ConfigResolver
- type Configuration
- type Provenance
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PreprocessContent ¶
PreprocessContent processes a gotemplate from memory
func PreprocessFile ¶
PreprocessFile reads and processes a gotemplate The path will be read as is. It parses the file as a template, and executes it with the pro
Types ¶
type ConfigProvider ¶
type ConfigProvider interface { // AllContexts determines all the clouds, environments, and regions that this provider has explicit records for. AllContexts() map[string]map[string][]string // GetResolver consumes the configuration replacements to create a configuration resolver. // The cloud and environment provided in the replacements must be literal values, used to // constrain the resolver further and ensure that configurations it resolves are correct. GetResolver(configReplacements *ConfigReplacements) (ConfigResolver, error) }
ConfigProvider provides service configuration using a base configuration file.
func NewConfigProvider ¶
func NewConfigProvider(config string) (ConfigProvider, error)
NewConfigProvider creates a configuration provider by knowing the path to the configuration file. Configuration files are not valid YAML - they are text templates that, when provided with the correct set of inputs and run through the Go template engine, become valid YAML. We want to be able to load the whole config file before the user knows what cloud/env/region they want, since we have a lot of cases where we want to operate over all the cloud/env/regions in the config. Previously, we had said that the whole config file needs to parse as valid YAML before templating, but this unfortunately means you cannot use templates for non-string values, which is a non-starter.
We instead run the file through a dummy template step that replaces values with some cloud/env/region and - since this ConfigProvider can't do anything except for divulge the contexts - we can just do the correct templating later.
type ConfigReplacements ¶
type ConfigReplacements struct { RegionReplacement string RegionShortReplacement string StampReplacement string CloudReplacement string EnvironmentReplacement string Ev2Config map[string]interface{} }
ConfigReplacements holds replacement values
func (ConfigReplacements) AsMap ¶
func (c ConfigReplacements) AsMap() map[string]interface{}
AsMap returns a map[string]interface{} representation of this ConfigReplacement instance
type ConfigResolver ¶
type ConfigResolver interface { // ValidateSchema validates a fully resolved configuration created by this provider. ValidateSchema(config types.Configuration) error // SchemaPath returns the absolute path to the JSONSchema file that this config is registered as using. SchemaPath() (string, error) // GetConfiguration resolves the configuration for the cloud and environment. GetConfiguration() (types.Configuration, error) // GetRegions divulges the regions for which overrides are registered. GetRegions() ([]string, error) // GetRegionConfiguration resolves the configuration for a region in the cloud and environment. GetRegionConfiguration(region string) (types.Configuration, error) // GetRegionOverrides fetches the overrides specific to a region, if any exist. GetRegionOverrides(region string) (types.Configuration, error) // ValueProvenance divulges how the value at 'path' is overridden to arrive at the result. ValueProvenance(region, path string) (*Provenance, error) }
ConfigResolver resolves service configuration for a specific environment and cloud using a processed configuration file.
type Configuration ¶
type Configuration = types.Configuration
DEPRECATED: use the exported type from types package instead
func MergeConfiguration ¶
func MergeConfiguration(base, override Configuration) Configuration
Merges Configuration, returns merged Configuration DEPRECATED: use the exported function from types package instead