Documentation
¶
Index ¶
- Variables
- func UnmarshalFile(path string, unmarshalFunc unmarshalFunction, output interface{}) (err error)
- func WalkComponentTree(startingPath string, environments []string, iterator componentIteration, ...) <-chan WalkResult
- type Component
- func (c *Component) AddSubcomponent(subcomponents ...Component) (err error)
- func (c *Component) ExecuteHook(hook string) (err error)
- func (c *Component) Generate(generator Generator) (err error)
- func (c *Component) GetAccessTokens() (tokens map[string]string, err error)
- func (c *Component) Install(componentPath string, generator Generator) (err error)
- func (c *Component) InstallComponent(componentPath string) (err error)
- func (c Component) InstallRoot(startingPath string, environments []string) (root Component, err error)
- func (c *Component) InstallSingleComponent(componentPath string, generator Generator) (err error)
- func (c *Component) LoadComponent() (loadedComponent Component, err error)
- func (c *Component) LoadConfig(environments []string) (err error)
- func (c *Component) RelativePathTo() string
- func (c *Component) RemoveSubcomponent(subcomponents ...Component) (err error)
- func (c *Component) UnmarshalComponent(serializationType string, unmarshalFunc unmarshalFunction, ...) error
- func (c Component) UpdateComponentPath(startingPath string, environments []string) (root Component, err error)
- func (c *Component) Write() (err error)
- type ComponentConfig
- func (cc *ComponentConfig) GetPath(environment string) string
- func (cc *ComponentConfig) GetSubcomponentConfig(subcomponentPath []string) (subcomponentConfig ComponentConfig)
- func (cc *ComponentConfig) HasComponentConfig(path []string) bool
- func (cc *ComponentConfig) HasSubcomponentConfig(subcomponentPath []string) bool
- func (cc *ComponentConfig) Load(environment string) (err error)
- func (cc *ComponentConfig) Merge(newConfig ComponentConfig) (err error)
- func (cc *ComponentConfig) MergeConfigFile(path string, environment string) (err error)
- func (cc *ComponentConfig) MergeNamespaces(newConfig ComponentConfig) ComponentConfig
- func (cc *ComponentConfig) SetComponentConfig(path []string, value string)
- func (cc *ComponentConfig) SetConfig(subcomponentPath []string, path []string, value string)
- func (cc *ComponentConfig) UnmarshalJSONConfig(environment string) (err error)
- func (cc *ComponentConfig) UnmarshalYAMLConfig(environment string) (err error)
- func (cc *ComponentConfig) Write(environment string) (err error)
- type Generator
- type PathValuePair
- type WalkResult
Constants ¶
This section is empty.
Variables ¶
var Git = git{}
Git is function wrapper to expose host git functionality
var GitAccessTokens = gitAccessTokenMap{ // contains filtered or unexported fields }
GitAccessTokens is a thread-safe global store of Personal Access Tokens which is used to store PATs as they are discovered throughout the Install lifecycle
Functions ¶
func UnmarshalFile ¶
UnmarshalFile is an unmarshal wrapper which reads in any file from `path` and attempts to unmarshal to `output` using the `unmarshalFunc`.
func WalkComponentTree ¶
func WalkComponentTree(startingPath string, environments []string, iterator componentIteration, rootInit rootComponentInit) <-chan WalkResult
WalkComponentTree asynchronously walks a component tree starting at `startingPath` and calls `iterator` on every node in the tree in Breadth First Order.
Returns a channel of WalkResult which can either have a Component or an Error (Error is nillable)
Same level ordering is not ensured; any nodes on the same tree level can be visited in any order. Parent->Child ordering is ensured; A parent is always visited via `iterator` before the children are visited.
Types ¶
type Component ¶
type Component struct { Name string `yaml:"name" json:"name"` Config ComponentConfig `yaml:"-" json:"-"` ComponentType string `yaml:"type,omitempty" json:"type,omitempty"` Generator string `yaml:"generator,omitempty" json:"generator,omitempty"` Hooks map[string][]string `yaml:"hooks,omitempty" json:"hooks,omitempty"` Serialization string `yaml:"-" json:"-"` Source string `yaml:"source,omitempty" json:"source,omitempty"` Method string `yaml:"method,omitempty" json:"method,omitempty"` Path string `yaml:"path,omitempty" json:"path,omitempty"` Version string `yaml:"version,omitempty" json:"version,omitempty"` Branch string `yaml:"branch,omitempty" json:"branch,omitempty"` Repositories map[string]string `yaml:"repositories,omitempty" json:"repositories,omitempty"` Subcomponents []Component `yaml:"subcomponents,omitempty" json:"subcomponents,omitempty"` PhysicalPath string `yaml:"-" json:"-"` LogicalPath string `yaml:"-" json:"-"` Manifest string `yaml:"-" json:"-"` }
Component documentation: https://github.com/evanlouie/fabrikate/blob/master/docs/component.md
func SynchronizeWalkResult ¶
func SynchronizeWalkResult(results <-chan WalkResult) (components []Component, err error)
SynchronizeWalkResult will synchronize a channel of WalkResult to a list of visited Components. It will return on the first Error encountered; returning the visited Components up until then and the error
func (*Component) AddSubcomponent ¶
AddSubcomponent adds the provided subcomponents to a component. If the subcomponents Name matches an existing entry, the existing entry is overwritten. If the subcomponents Name does not match, a new subcomponent entry is created.
func (*Component) ExecuteHook ¶
ExecuteHook executes the passed hook
func (*Component) Generate ¶
Generate encapsulates the generate lifecycle of a component including before-generate, generation, and after-generate hooks.
func (*Component) GetAccessTokens ¶
GetAccessTokens attempts to find an access.yaml file in the same physical directory of the component. Un-marshalling if found,
func (*Component) Install ¶
Install encapsulates the install lifecycle of a component including before-install, installation, and after-install hooks.
func (*Component) InstallComponent ¶
InstallComponent installs the component (if needed) utilizing its Method. This is only used to install 'components', Generators handle the installation of 'non-components' (eg; helm/static). Therefore the only installation needed for any component is when ComponentType == "component"|"" and Method == "git"
func (Component) InstallRoot ¶
func (c Component) InstallRoot(startingPath string, environments []string) (root Component, err error)
InstallRoot installs the root component
func (*Component) InstallSingleComponent ¶
InstallSingleComponent installs the given component
func (*Component) LoadComponent ¶
LoadComponent loads a component definition in either YAML or JSON formats.
func (*Component) LoadConfig ¶
LoadConfig loads and merges the config specified by the passed set of environments.
func (*Component) RelativePathTo ¶
RelativePathTo returns the relative filesystem path where this component should be. If the method the component is retrieved is `git`: the convention "components/<component.Name>" is used If the method not git but the component has a `source`, that value is used
func (*Component) RemoveSubcomponent ¶
RemoveSubcomponent takes in a variadic amount of subcomponents and attempts to remove them from the component. If a subcomponent is found with the same name, it is removed. If not, it is a noop.
func (*Component) UnmarshalComponent ¶
func (c *Component) UnmarshalComponent(serializationType string, unmarshalFunc unmarshalFunction, component *Component) error
UnmarshalComponent finds and unmarshal the component.<format> of a component using the provided `unmarshalFunc` function.
type ComponentConfig ¶
type ComponentConfig struct { Path string `yaml:"-" json:"-"` Serialization string `yaml:"-" json:"-"` Namespace string `yaml:"namespace,omitempty" json:"namespace,omitempty"` InjectNamespace bool `yaml:"injectNamespace,omitempty" json:"injectNamespace,omitempty"` Config map[string]interface{} `yaml:"config,omitempty" json:"config,omitempty"` Subcomponents map[string]ComponentConfig `yaml:"subcomponents,omitempty" json:"subcomponents,omitempty"` }
ComponentConfig documentation: https://github.com/evanlouie/fabrikate/blob/master/docs/config.md
func NewComponentConfig ¶
func NewComponentConfig(path string) ComponentConfig
NewComponentConfig creates a ComponentConfig at the passed path.
func (*ComponentConfig) GetPath ¶
func (cc *ComponentConfig) GetPath(environment string) string
GetPath returns the path to the config file for the specified environment.
func (*ComponentConfig) GetSubcomponentConfig ¶
func (cc *ComponentConfig) GetSubcomponentConfig(subcomponentPath []string) (subcomponentConfig ComponentConfig)
GetSubcomponentConfig returns the subcomponent config of the given component. If the subcomponent does not exist, it creates it
Returns the subcomponent config
func (*ComponentConfig) HasComponentConfig ¶
func (cc *ComponentConfig) HasComponentConfig(path []string) bool
HasComponentConfig checks if the component contains the given component configuration. The given component is specified via a configuration `path`. Returns true if it contains it, otherwise it returns false.
func (*ComponentConfig) HasSubcomponentConfig ¶
func (cc *ComponentConfig) HasSubcomponentConfig(subcomponentPath []string) bool
HasSubcomponentConfig checks if a component contains the given subcomponents of the `subcomponentPath`
Returns true if it contains the subcomponent, otherwise it returns false
func (*ComponentConfig) Load ¶
func (cc *ComponentConfig) Load(environment string) (err error)
Load loads the config for the specified environment.
func (*ComponentConfig) Merge ¶
func (cc *ComponentConfig) Merge(newConfig ComponentConfig) (err error)
Merge merges the config (and the namespace spec) between the passed componentConfig and this componentConfig. In the case of conflicts, this componentConfig wins.
func (*ComponentConfig) MergeConfigFile ¶
func (cc *ComponentConfig) MergeConfigFile(path string, environment string) (err error)
MergeConfigFile loads the config for the specified environment and path and merges it with the current set of config.
func (*ComponentConfig) MergeNamespaces ¶
func (cc *ComponentConfig) MergeNamespaces(newConfig ComponentConfig) ComponentConfig
MergeNamespaces merges the namespaces between the componentConfig passed and this ComponentConfig.
func (*ComponentConfig) SetComponentConfig ¶
func (cc *ComponentConfig) SetComponentConfig(path []string, value string)
SetComponentConfig sets the `value` of the given configuration setting. The configuration setting is indicated via a configuration `path`.
func (*ComponentConfig) SetConfig ¶
func (cc *ComponentConfig) SetConfig(subcomponentPath []string, path []string, value string)
SetConfig sets or creates the configuration `value` for the given `subcomponentPath`.
func (*ComponentConfig) UnmarshalJSONConfig ¶
func (cc *ComponentConfig) UnmarshalJSONConfig(environment string) (err error)
UnmarshalJSONConfig unmarshals the JSON config file for the specified environment.
func (*ComponentConfig) UnmarshalYAMLConfig ¶
func (cc *ComponentConfig) UnmarshalYAMLConfig(environment string) (err error)
UnmarshalYAMLConfig unmarshals the YAML config file for the specified environment.
func (*ComponentConfig) Write ¶
func (cc *ComponentConfig) Write(environment string) (err error)
Write writes this componentConfig to a file using the serialization specified in cc.Serialization.
type Generator ¶
type Generator interface { Generate(component *Component) (manifest string, err error) Install(component *Component) (err error) }
The Generator interface defines the interface for generator tools (like Helm or Static) to install and generate resource manifests.
type PathValuePair ¶
PathValuePair encapsulates a config path (eg. data.storageClass) and the value that it has. Used during the 'set' command to store parsed config paths and values.
type WalkResult ¶
WalkResult is what WalkComponentTree returns. Will contain either a Component OR an Error (Error is nillable; meaning both fields can be nil)