Documentation
¶
Index ¶
- Constants
- func ApplyConstraints(sol solution.Solution) error
- func GraphToDOT(kb knowledgebase.TemplateKB, g construct.Graph, out io.Writer) error
- func GraphToSVG(kb knowledgebase.TemplateKB, g construct.Graph, prefix string) error
- func NewSolution(ctx context.Context, kb knowledgebase.TemplateKB, globalTag string, ...) *engineSolution
- type Engine
- func (e *Engine) EdgeCanBeExpanded(sol *engineSolution, source construct.ResourceId, target construct.ResourceId) (result bool, cacheable bool, err error)
- func (e *Engine) GetValidEdgeTargets(req *GetPossibleEdgesContext) (map[string][]string, error)
- func (e *Engine) GetViewsDag(view View, sol solution.Solution) (visualizer.VisGraph, error)
- func (e *Engine) ListAttributes() []string
- func (e *Engine) ListFunctionalities() []knowledgebase.Functionality
- func (e *Engine) ListProviders() []string
- func (e *Engine) ListResources() []construct.ResourceId
- func (e *Engine) Run(ctx context.Context, req *SolveRequest) (solution.Solution, error)
- func (e *Engine) VisualizeViews(ctx solution.Solution) ([]klotho_io.File, error)
- type EngineMain
- func (em *EngineMain) AddEngine() error
- func (em *EngineMain) AddEngineCli(root *cobra.Command)
- func (em *EngineMain) GetValidEdgeTargets(cmd *cobra.Command, args []string) error
- func (em *EngineMain) ListAttributes(cmd *cobra.Command, args []string) error
- func (em *EngineMain) ListResourceTypes(cmd *cobra.Command, args []string) error
- func (em *EngineMain) Run(ctx context.Context, req *SolveRequest) (int, solution.Solution, []engine_errs.EngineError)
- func (em *EngineMain) RunEngine(cmd *cobra.Command, args []string) (exitCode int)
- type FileFormat
- type GetPossibleEdgesContext
- type GetValidEdgeTargetsConfig
- type MakeOperationalView
- func (view *MakeOperationalView) AddEdge(source, target construct.ResourceId, options ...func(*graph.EdgeProperties)) (err error)
- func (view *MakeOperationalView) AddEdgesFrom(g construct.Graph) error
- func (view *MakeOperationalView) AddVertex(value *construct.Resource, options ...func(*graph.VertexProperties)) error
- func (view *MakeOperationalView) AddVerticesFrom(g construct.Graph) error
- func (view *MakeOperationalView) AdjacencyMap() (map[construct.ResourceId]map[construct.ResourceId]construct.Edge, error)
- func (view *MakeOperationalView) Clone() (construct.Graph, error)
- func (view *MakeOperationalView) Edge(source, target construct.ResourceId) (construct.ResourceEdge, error)
- func (view *MakeOperationalView) Edges() ([]construct.Edge, error)
- func (view *MakeOperationalView) MakeEdgesOperational(edges []construct.Edge) error
- func (view *MakeOperationalView) MakeResourcesOperational(resources []*construct.Resource) error
- func (view *MakeOperationalView) Order() (int, error)
- func (view *MakeOperationalView) PredecessorMap() (map[construct.ResourceId]map[construct.ResourceId]construct.Edge, error)
- func (view *MakeOperationalView) RemoveEdge(source, target construct.ResourceId) error
- func (view *MakeOperationalView) RemoveVertex(hash construct.ResourceId) error
- func (view *MakeOperationalView) Size() (int, error)
- func (view *MakeOperationalView) Traits() *graph.Traits
- func (view *MakeOperationalView) UpdateEdge(source, target construct.ResourceId, ...) error
- func (view *MakeOperationalView) UpdateResourceID(oldId, newId construct.ResourceId) error
- func (view *MakeOperationalView) Vertex(hash construct.ResourceId) (*construct.Resource, error)
- func (view *MakeOperationalView) VertexWithProperties(hash construct.ResourceId) (*construct.Resource, graph.VertexProperties, error)
- type SolveRequest
- type Tag
- type View
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func ApplyConstraints ¶
func GraphToDOT ¶
func GraphToDOT(kb knowledgebase.TemplateKB, g construct.Graph, out io.Writer) error
func GraphToSVG ¶
func GraphToSVG(kb knowledgebase.TemplateKB, g construct.Graph, prefix string) error
func NewSolution ¶
func NewSolution(ctx context.Context, kb knowledgebase.TemplateKB, globalTag string, constraints *constraints.Constraints) *engineSolution
Types ¶
type Engine ¶
type Engine struct {
Kb knowledgebase.TemplateKB
}
Engine is a struct that represents the object which processes the resource graph and applies constraints
func NewEngine ¶
func NewEngine(kb knowledgebase.TemplateKB) *Engine
func (*Engine) EdgeCanBeExpanded ¶
func (e *Engine) EdgeCanBeExpanded(sol *engineSolution, source construct.ResourceId, target construct.ResourceId) (result bool, cacheable bool, err error)
EdgeCanBeExpanded returns true if there is a set of kb paths between the source and target that satisfies path satisfaction classifications for both the source and target.
This is used to determine (on a best-effort basis) if an edge can be expanded without fully solving the graph (which is expensive).
func (*Engine) GetValidEdgeTargets ¶
func (e *Engine) GetValidEdgeTargets(req *GetPossibleEdgesContext) (map[string][]string, error)
GetValidEdgeTargets returns a map of valid edge targets for each source resource in the supplied graph. The returned map is keyed by the source resource's string representation. The value for each source resource is a list of valid target resources.
Targets are considered valid if there is a set of kb paths between the source and target that satisfies both source and target path satisfaction classifications.
A partial set of valid targets can be generated using the filter criteria in the context's config.
func (*Engine) GetViewsDag ¶
func (*Engine) ListAttributes ¶
func (*Engine) ListFunctionalities ¶
func (e *Engine) ListFunctionalities() []knowledgebase.Functionality
func (*Engine) ListProviders ¶
func (*Engine) ListResources ¶
func (e *Engine) ListResources() []construct.ResourceId
type EngineMain ¶
type EngineMain struct {
Engine *Engine
// contains filtered or unexported fields
}
func (*EngineMain) AddEngine ¶
func (em *EngineMain) AddEngine() error
func (*EngineMain) AddEngineCli ¶
func (em *EngineMain) AddEngineCli(root *cobra.Command)
func (*EngineMain) GetValidEdgeTargets ¶
func (em *EngineMain) GetValidEdgeTargets(cmd *cobra.Command, args []string) error
func (*EngineMain) ListAttributes ¶
func (em *EngineMain) ListAttributes(cmd *cobra.Command, args []string) error
func (*EngineMain) ListResourceTypes ¶
func (em *EngineMain) ListResourceTypes(cmd *cobra.Command, args []string) error
func (*EngineMain) Run ¶
func (em *EngineMain) Run(ctx context.Context, req *SolveRequest) (int, solution.Solution, []engine_errs.EngineError)
type FileFormat ¶
type FileFormat struct {
Constraints constraints.Constraints
Graph construct.Graph
}
FileFormat is used for engine input/output to render or read a YAML file An example yaml file is:
constraints:
- scope: application
operator: add
node: p:t:a
resources:
p:t:a:
p:t:b:
edges:
p:t:a -> p:t:b:
func (FileFormat) MarshalYAML ¶
func (ff FileFormat) MarshalYAML() (interface{}, error)
func (*FileFormat) UnmarshalYAML ¶
func (ff *FileFormat) UnmarshalYAML(node *yaml.Node) error
type GetPossibleEdgesContext ¶
type GetPossibleEdgesContext struct {
InputGraph []byte
GetValidEdgeTargetsConfig
}
type GetValidEdgeTargetsConfig ¶
type GetValidEdgeTargetsConfig struct {
Resources struct {
Sources []construct.ResourceId
Targets []construct.ResourceId
}
ResourceTypes struct {
Sources []construct.ResourceId
Targets []construct.ResourceId
}
Tags []Tag
}
func ReadGetValidEdgeTargetsConfig ¶
func ReadGetValidEdgeTargetsConfig(path string) (GetValidEdgeTargetsConfig, error)
type MakeOperationalView ¶
type MakeOperationalView engineSolution
func (*MakeOperationalView) AddEdge ¶
func (view *MakeOperationalView) AddEdge(source, target construct.ResourceId, options ...func(*graph.EdgeProperties)) (err error)
func (*MakeOperationalView) AddEdgesFrom ¶
func (view *MakeOperationalView) AddEdgesFrom(g construct.Graph) error
func (*MakeOperationalView) AddVertex ¶
func (view *MakeOperationalView) AddVertex(value *construct.Resource, options ...func(*graph.VertexProperties)) error
func (*MakeOperationalView) AddVerticesFrom ¶
func (view *MakeOperationalView) AddVerticesFrom(g construct.Graph) error
func (*MakeOperationalView) AdjacencyMap ¶
func (view *MakeOperationalView) AdjacencyMap() (map[construct.ResourceId]map[construct.ResourceId]construct.Edge, error)
func (*MakeOperationalView) Clone ¶
func (view *MakeOperationalView) Clone() (construct.Graph, error)
func (*MakeOperationalView) Edge ¶
func (view *MakeOperationalView) Edge(source, target construct.ResourceId) (construct.ResourceEdge, error)
func (*MakeOperationalView) Edges ¶
func (view *MakeOperationalView) Edges() ([]construct.Edge, error)
func (*MakeOperationalView) MakeEdgesOperational ¶
func (view *MakeOperationalView) MakeEdgesOperational(edges []construct.Edge) error
func (*MakeOperationalView) MakeResourcesOperational ¶
func (view *MakeOperationalView) MakeResourcesOperational(resources []*construct.Resource) error
func (*MakeOperationalView) Order ¶
func (view *MakeOperationalView) Order() (int, error)
func (*MakeOperationalView) PredecessorMap ¶
func (view *MakeOperationalView) PredecessorMap() (map[construct.ResourceId]map[construct.ResourceId]construct.Edge, error)
func (*MakeOperationalView) RemoveEdge ¶
func (view *MakeOperationalView) RemoveEdge(source, target construct.ResourceId) error
func (*MakeOperationalView) RemoveVertex ¶
func (view *MakeOperationalView) RemoveVertex(hash construct.ResourceId) error
func (*MakeOperationalView) Size ¶
func (view *MakeOperationalView) Size() (int, error)
func (*MakeOperationalView) Traits ¶
func (view *MakeOperationalView) Traits() *graph.Traits
func (*MakeOperationalView) UpdateEdge ¶
func (view *MakeOperationalView) UpdateEdge(source, target construct.ResourceId, options ...func(properties *graph.EdgeProperties)) error
func (*MakeOperationalView) UpdateResourceID ¶
func (view *MakeOperationalView) UpdateResourceID(oldId, newId construct.ResourceId) error
func (*MakeOperationalView) Vertex ¶
func (view *MakeOperationalView) Vertex(hash construct.ResourceId) (*construct.Resource, error)
func (*MakeOperationalView) VertexWithProperties ¶
func (view *MakeOperationalView) VertexWithProperties(hash construct.ResourceId) (*construct.Resource, graph.VertexProperties, error)
type SolveRequest ¶
type SolveRequest struct {
Constraints constraints.Constraints
InitialState construct.Graph
GlobalTag string
}
SolveRequest is a struct that represents the context of the engine The context is used to store the state of the engine
func (SolveRequest) MarshalYAML ¶
func (req SolveRequest) MarshalYAML() (interface{}, error)
type Tag ¶
type Tag string
func GetResourceVizTag ¶
func GetResourceVizTag(kb knowledgebase.TemplateKB, view View, resource construct.ResourceId) Tag