core

package
v0.17.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Git = git{}

Git is function wrapper to expose host git functionality

View Source
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

func UnmarshalFile(path string, unmarshalFunc unmarshalFunction, output interface{}) (err error)

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

func (c *Component) AddSubcomponent(subcomponents ...Component) (err error)

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

func (c *Component) ExecuteHook(hook string) (err error)

ExecuteHook executes the passed hook

func (*Component) Generate

func (c *Component) Generate(generator Generator) (err error)

Generate encapsulates the generate lifecycle of a component including before-generate, generation, and after-generate hooks.

func (*Component) GetAccessTokens

func (c *Component) GetAccessTokens() (tokens map[string]string, err error)

GetAccessTokens attempts to find an access.yaml file in the same physical directory of the component. Un-marshalling if found,

func (*Component) Install

func (c *Component) Install(componentPath string, generator Generator) (err error)

Install encapsulates the install lifecycle of a component including before-install, installation, and after-install hooks.

func (*Component) InstallComponent

func (c *Component) InstallComponent(componentPath string) (err error)

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

func (c *Component) InstallSingleComponent(componentPath string, generator Generator) (err error)

InstallSingleComponent installs the given component

func (*Component) LoadComponent

func (c *Component) LoadComponent() (loadedComponent Component, err error)

LoadComponent loads a component definition in either YAML or JSON formats.

func (*Component) LoadConfig

func (c *Component) LoadConfig(environments []string) (err error)

LoadConfig loads and merges the config specified by the passed set of environments.

func (*Component) RelativePathTo

func (c *Component) RelativePathTo() string

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

func (c *Component) RemoveSubcomponent(subcomponents ...Component) (err error)

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.

func (Component) UpdateComponentPath

func (c Component) UpdateComponentPath(startingPath string, environments []string) (root Component, err error)

UpdateComponentPath updates the component path if it required installing another component

func (*Component) Write

func (c *Component) Write() (err error)

Write serializes a component to YAML (default) or JSON (chosen via c.Serialization) at c.PhysicalPath

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

type PathValuePair struct {
	Path  []string
	Value string
}

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

type WalkResult struct {
	Component *Component
	Error     error
}

WalkResult is what WalkComponentTree returns. Will contain either a Component OR an Error (Error is nillable; meaning both fields can be nil)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL