Documentation ¶
Index ¶
- func SortProjects(projects []project.Project, environments []string) (map[string][]config.Config, []error)
- type ConfigGraph
- type ConfigGraphPerEnvironment
- func (graphs ConfigGraphPerEnvironment) EncodeToDOT(environment string) ([]byte, error)
- func (graphs ConfigGraphPerEnvironment) GetIndependentlySortedConfigs(environment string) ([]SortedComponent, error)
- func (graphs ConfigGraphPerEnvironment) SortConfigs(environment string) ([]config.Config, error)
- type ConfigNode
- type CyclicDependencyError
- type DependencyLocation
- type SortedComponent
- type SortingErrors
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SortProjects ¶
func SortProjects(projects []project.Project, environments []string) (map[string][]config.Config, []error)
SortProjects is a convenience method to make Graph based sorting an easy plugin for the old toposort variant. Internally it builds dependency graphs and uses these to sort and return the basic sorted configs per environment map.
Types ¶
type ConfigGraph ¶
ConfigGraph is a directed graph containing ConfigNode s
type ConfigGraphPerEnvironment ¶
type ConfigGraphPerEnvironment map[string]*simple.DirectedGraph
ConfigGraphPerEnvironment is a map of directed dependency graphs per environment name.
func New ¶
func New(projects []project.Project, environments []string) ConfigGraphPerEnvironment
New creates a new ConfigGraphPerEnvironment based on the given projects and environments.
func (ConfigGraphPerEnvironment) EncodeToDOT ¶
func (graphs ConfigGraphPerEnvironment) EncodeToDOT(environment string) ([]byte, error)
EncodeToDOT returns a DOT string represenation of the dependency graph for the given environment.
func (ConfigGraphPerEnvironment) GetIndependentlySortedConfigs ¶
func (graphs ConfigGraphPerEnvironment) GetIndependentlySortedConfigs(environment string) ([]SortedComponent, error)
GetIndependentlySortedConfigs returns sorted slices of SortedComponent. Dependent configurations are returned as a sub-graph as well as a slice, sorted in the correct order to deploy them sequentially.
func (ConfigGraphPerEnvironment) SortConfigs ¶
func (graphs ConfigGraphPerEnvironment) SortConfigs(environment string) ([]config.Config, error)
SortConfigs returns a slice of config.Config for the given environment sorted according to their dependencies.
type ConfigNode ¶
ConfigNode implements the gonum graph.Node interface and contains a pointer to its respective config.Config in addition to the unique ID required.
func (ConfigNode) DOTID ¶
func (n ConfigNode) DOTID() string
DOTID returns the node's identifier when printed to a DOT file. For readability of files this is the coordinate.Coordinate of the Config, instead of the node's ID integer.
func (ConfigNode) ID ¶
func (n ConfigNode) ID() int64
ID returns the node's integer ID by which it is referenced in the graph.
func (ConfigNode) String ¶
func (n ConfigNode) String() string
type CyclicDependencyError ¶
type CyclicDependencyError struct { //The Environment for which the error occurred. Environment string `json:"environment"` //A slice of all dependency cycles between configurations as slices of DependencyLocation. Each cycle slice is returned in order of dependencies. ConfigsInDependencyCycle [][]DependencyLocation `json:"configsInDependencyCycle"` }
CyclicDependencyError is returned if sorting a graph failed due to cyclic dependencies between configurations.
func (CyclicDependencyError) Error ¶
func (e CyclicDependencyError) Error() string
type DependencyLocation ¶
type DependencyLocation struct { // The coordinate.Coordinate of the configuration that is part of a Dependency Cycle Coordinate coordinate.Coordinate `json:"coordinate"` // The filepath this configuration was loaded from. May be empty. Filepath string `json:"filepath,omitempty"` }
DependencyLocation is a short from location pointing to the coordinate and (if available) file of the configuration.
type SortedComponent ¶
type SortedComponent struct { // Graph is a directed graph representation of the weakly connected component/sub-graph found in another graph. Graph graph.Directed // SortedNodes are a topologically sorted slice of graph.Node s, which can be deployed in order. // This exists for convenience, so callers of GetIndependentlySortedConfigs can work with the component without implementing graph algorithms. SortedNodes []graph.Node }
SortedComponent represents a weakly connected component found in a graph.
type SortingErrors ¶
type SortingErrors []error
SortingErrors is a slice of errors that implements the error interface. It may contain general errors as well as CyclicDependencyError.
func (SortingErrors) Error ¶
func (errs SortingErrors) Error() string