graph

package
v0.0.0-...-13c9884 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateIdentifier

func CreateIdentifier(elem ...string) string

func CreateProjectIdentifier

func CreateProjectIdentifier(filename string) string

func HashSiteComponent

func HashSiteComponent(sc *SiteComponent) (string, error)

func SortSiteComponentNodes

func SortSiteComponentNodes(nodes []*SiteComponent)

Types

type EdgeMock

type EdgeMock struct {
	Source string
	Target string
}

type Graph

type Graph struct {
	graph.Graph[string, Node]
	StartNode Node
}

func CreateGraphMock

func CreateGraphMock(
	vertices map[string]Node,
	startNode Node,
	edges ...EdgeMock,
) *Graph

func ToDependencyGraph

func ToDependencyGraph(cfg *config.MachConfig, outPath string) (*Graph, error)

ToDependencyGraph will transform a MachConfig into a graph of dependencies connected by different relations

func ToDeploymentGraph

func ToDeploymentGraph(cfg *config.MachConfig, outPath string) (*Graph, error)

ToDeploymentGraph converts a MachConfig to a Graph ready for deployment. This means that all nodes that are not independently deployable are pruned from the graph.

func (*Graph) Routes

func (g *Graph) Routes(source, target string) ([]Path, error)

Routes determines all the possible paths between two nodes

func (*Graph) Vertices

func (g *Graph) Vertices() Vertices

Vertices returns all the vertex that are contained in the graph

type Node

type Node interface {
	//Path returns the directory path of the node, relative to the global output directory
	Path() string

	//Identifier returns the identifier of the node as set in the configurations
	Identifier() string

	//Type returns the type of the node
	Type() Type

	//Ancestor returns the ancestor of the node. The ancestor is specific to the type of the node. For example,
	//a site will have the project as ancestor, a site component will have the site as ancestor,
	//and project will have no ancestor
	Ancestor() Node

	//Parents returns the direct parents of the node
	Parents() ([]Node, error)

	//Independent returns true if the node can be deployed independently, false otherwise
	Independent() bool

	//Tainted indicates if.
	Tainted() bool

	//Hash returns the hash of the node. The hash is based on the node's configuration as well as the configuration of any
	//related components. This can be compared to other hashes to determine whether a node has changed
	Hash() (string, error)

	//SetTainted sets the tainted status of the node
	SetTainted(tainted bool)

	//SetOldHash sets the old hash of the node. This is used to determine if the node has changed
	SetOldHash(hash string)

	//GetOldHash returns the old hash of the node
	GetOldHash() string
	// contains filtered or unexported methods
}

type NodeMock

type NodeMock struct {
	mock.Mock
	// contains filtered or unexported fields
}

func (*NodeMock) Ancestor

func (n *NodeMock) Ancestor() Node

func (*NodeMock) GetOldHash

func (n *NodeMock) GetOldHash() string

func (*NodeMock) HasChanges

func (n *NodeMock) HasChanges() (bool, error)

func (*NodeMock) Hash

func (n *NodeMock) Hash() (string, error)

func (*NodeMock) Identifier

func (n *NodeMock) Identifier() string

func (*NodeMock) Independent

func (n *NodeMock) Independent() bool

func (*NodeMock) Parents

func (n *NodeMock) Parents() ([]Node, error)

func (*NodeMock) Path

func (n *NodeMock) Path() string

func (*NodeMock) SetOldHash

func (n *NodeMock) SetOldHash(hash string)

func (*NodeMock) SetTainted

func (n *NodeMock) SetTainted(tainted bool)

func (*NodeMock) Tainted

func (n *NodeMock) Tainted() bool

func (*NodeMock) Type

func (n *NodeMock) Type() Type

type Path

type Path []string

type Project

type Project struct {
	ProjectConfig config.MachConfig
	// contains filtered or unexported fields
}

func NewProject

func NewProject(g graph.Graph[string, Node], path, identifier string, deploymentType config.DeploymentType,
	projectConfig config.MachConfig) *Project

func (*Project) Ancestor

func (n *Project) Ancestor() Node

func (*Project) GetOldHash

func (n *Project) GetOldHash() string

func (*Project) Hash

func (p *Project) Hash() (string, error)

func (*Project) Identifier

func (n *Project) Identifier() string

func (*Project) Independent

func (n *Project) Independent() bool

func (*Project) Parents

func (n *Project) Parents() ([]Node, error)

func (*Project) Path

func (n *Project) Path() string

func (*Project) SetOldHash

func (n *Project) SetOldHash(hash string)

func (*Project) SetTainted

func (n *Project) SetTainted(tainted bool)

func (*Project) Tainted

func (n *Project) Tainted() bool

func (*Project) Type

func (n *Project) Type() Type

type Site

type Site struct {
	NestedNodes   []*SiteComponent
	ProjectConfig config.MachConfig
	SiteConfig    config.SiteConfig
	// contains filtered or unexported fields
}

func NewSite

func NewSite(g graph.Graph[string, Node], path, identifier string,
	deploymentType config.DeploymentType, ancestor Node,
	projectConfig config.MachConfig, siteConfig config.SiteConfig) *Site

func (*Site) Ancestor

func (n *Site) Ancestor() Node

func (*Site) GetOldHash

func (n *Site) GetOldHash() string

func (*Site) Hash

func (s *Site) Hash() (string, error)

func (*Site) Identifier

func (n *Site) Identifier() string

func (*Site) Independent

func (n *Site) Independent() bool

func (*Site) Parents

func (n *Site) Parents() ([]Node, error)

func (*Site) Path

func (n *Site) Path() string

func (*Site) SetOldHash

func (n *Site) SetOldHash(hash string)

func (*Site) SetTainted

func (n *Site) SetTainted(tainted bool)

func (*Site) Tainted

func (n *Site) Tainted() bool

func (*Site) Type

func (n *Site) Type() Type

type SiteComponent

type SiteComponent struct {
	ProjectConfig       config.MachConfig
	SiteConfig          config.SiteConfig
	SiteComponentConfig config.SiteComponentConfig
	// contains filtered or unexported fields
}

func NewSiteComponent

func NewSiteComponent(
	g graph.Graph[string, Node], path, identifier string, deploymentType config.DeploymentType,
	ancestor Node, projectConfig config.MachConfig, siteConfig config.SiteConfig, siteComponentConfig config.SiteComponentConfig,
) *SiteComponent

func (*SiteComponent) Ancestor

func (n *SiteComponent) Ancestor() Node

func (*SiteComponent) GetOldHash

func (n *SiteComponent) GetOldHash() string

func (*SiteComponent) Hash

func (sc *SiteComponent) Hash() (string, error)

func (*SiteComponent) Identifier

func (n *SiteComponent) Identifier() string

func (*SiteComponent) Independent

func (n *SiteComponent) Independent() bool

func (*SiteComponent) Parents

func (n *SiteComponent) Parents() ([]Node, error)

func (*SiteComponent) Path

func (n *SiteComponent) Path() string

func (*SiteComponent) SetOldHash

func (n *SiteComponent) SetOldHash(hash string)

func (*SiteComponent) SetTainted

func (n *SiteComponent) SetTainted(tainted bool)

func (*SiteComponent) Tainted

func (n *SiteComponent) Tainted() bool

func (*SiteComponent) Type

func (n *SiteComponent) Type() Type

type Type

type Type string
const (
	ProjectType       Type = "project"
	SiteType          Type = "site"
	SiteComponentType Type = "site-component"
)

type ValidationError

type ValidationError struct {
	Msg    string
	Errors []error
}

func (*ValidationError) Error

func (v *ValidationError) Error() string

type Vertices

type Vertices []Node

Jump to

Keyboard shortcuts

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