graph

package
v0.0.0-...-da51959 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareDependencies

func CompareDependencies(a, b Identifier) int

func CompareStepDependencies

func CompareStepDependencies(a, b types.StepDependency) int

func MarshalDOT

func MarshalDOT(g *Graph) ([]byte, error)

MarshalDOT marshals the graph into the DOT notation used by the graphviz library. See documentation here: https://graphviz.gitlab.io/doc/info/lang.html

Types

type Graph

type Graph struct {
	// Services is a lookup table of services by name (the service group).
	Services map[string]*topology.Service

	// ResourceGroups is a lookup table of resource groups keyed by stamp and logical name.
	// Unstamped resource groups use Unstamped.
	ResourceGroups map[ResourceGroupKey]*types.ResourceGroupMeta

	// Subscription is an optional set of metadata required for subscription provisioning.
	Subscription *Subscription

	// Steps is a lookup table keyed by Identifier.
	Steps map[Identifier]types.Step

	// Nodes records every step, and the parent/child relationships between them.
	Nodes []Node

	// ServiceValidationSteps record the service validation steps
	ServiceValidationSteps map[Identifier]types.ValidationStep
	// contains filtered or unexported fields
}

Graph holds a set of nodes, recording parent/child relationships for each, along with a set of lookup tables for the services, resource groups, steps, etc. that the nodes represent.

func ForEntrypoint

func ForEntrypoint(topo *topology.Topology, entrypoint *topology.Entrypoint, pipelines map[string]*types.Pipeline) (*Graph, error)

ForEntrypoint generates a graph for all pipelines in the sub-tree of the topology identified by the entrypoint. Convenience wrapper around ForEntrypoints for a single entrypoint.

func ForEntrypoints

func ForEntrypoints(topo *topology.Topology, entrypoints []*topology.Entrypoint, pipelines map[string]*types.Pipeline) (*Graph, error)

ForEntrypoints generates a graph for all pipelines in the sub-trees of the topology identified by the entrypoints. Stamped services in the topology are not expanded — each appears exactly once with Unstamped on its nodes. The resulting graph has one set of nodes per service, making it suitable for contexts where stamp expansion is handled by the runtime (e.g. EV2 rollout specs) rather than the graph itself.

func ForPipeline

func ForPipeline(service *topology.Service, pipeline *types.Pipeline) (*Graph, error)

ForPipeline generates a graph for one pipeline, processing all steps therein to determine dependencies between them.

func ForStampedEntrypoints

func ForStampedEntrypoints(topo *topology.Topology, entrypoints []*topology.Entrypoint, stampPipelines map[Stamp]map[string]*types.Pipeline) (*Graph, error)

ForStampedEntrypoints generates a graph for all pipelines in the sub-trees of the topology identified by the entrypoints, expanding stamped services once per stamp. Each stamped service produces N copies of its nodes — one per stamp with IsSet() == true in stampPipelines — with each copy carrying a distinct Stamp on its identifiers. Unstamped services appear once with Unstamped. The resulting graph is suitable for contexts where the graph itself drives per-stamp execution (e.g. templatize concurrent stamp rollouts).

func ForStampedPipeline

func ForStampedPipeline(service *topology.Service, stampPipelines map[Stamp]map[string]*types.Pipeline) (*Graph, error)

ForStampedPipeline generates a graph for a single service group, expanding stamped services once per stamp. Like ForPipeline it strips children so the graph covers exactly one pipeline, but unlike ForPipeline it preserves the service's Stamped flag and accepts per-stamp pipelines. Unstamped services produce a single set of nodes with Unstamped; stamped services produce N copies — one per stamp with IsSet() == true.

func (*Graph) GetStep

func (c *Graph) GetStep(node Identifier) (types.Step, bool)

GetStep returns the step for a node, using the node's Stamp field to select per-stamp steps.

type Identifier

type Identifier struct {
	Stamp        Stamp
	ServiceGroup string
	types.StepDependency
}

Identifier records a dependency on a step in a particular service group and resource group. This is the minimum amount of precision required to identify a step in a multi-pipeline execution environment. Stamp is set by callers that expand stamped services into multiple graph copies — it distinguishes nodes that share the same ServiceGroup/ResourceGroup/Step but belong to different stamps.

func (Identifier) ResourceGroupKey

func (i Identifier) ResourceGroupKey() ResourceGroupKey

func (Identifier) String

func (i Identifier) String() string

type Node

type Node struct {
	// This embedded Identifier defines the identifier for this node.
	Identifier

	// Children contains the direct children (not further descendants) of this node.
	Children []Identifier
	// Parents contains the direct parents (not further ancestors) of this node.
	Parents []Identifier
}

Node records a step along with references to all parents and children. This structure is intentionally devoid of complex data, pointers to the underlying structures needed to execute the steps, etc. Such a structure helps to make operations that produce or operate over these nodes easy to test and verify.

type ResourceGroupKey

type ResourceGroupKey struct {
	Stamp Stamp
	Name  string
}

ResourceGroupKey identifies a resource group within a graph. Stamp is Unstamped for unstamped resource groups. Callers that expand stamped services set Stamp to distinguish per-stamp resource group metadata that shares the same logical Name.

type Stamp

type Stamp struct {
	// contains filtered or unexported fields
}

Stamp identifies a stamp within a multi-stamp execution graph. Use NewStamp to create a set stamp value and Unstamped for unstamped contexts. Callers should use IsSet rather than comparing against the zero value directly.

func NewStamp

func NewStamp(v string) (Stamp, error)

NewStamp creates a Stamp from a non-empty string. It returns an error if the value is empty.

func Unstamped

func Unstamped() Stamp

Unstamped returns the zero value representing an unstamped context.

func (Stamp) If

func (s Stamp) If(stamped bool) Stamp

If returns this stamp when stamped is true, otherwise Unstamped().

func (Stamp) IsSet

func (s Stamp) IsSet() bool

IsSet reports whether the stamp represents a real stamp value rather than the unstamped zero value.

func (Stamp) String

func (s Stamp) String() string

type Subscription

type Subscription struct {
	// ServiceGroup records the service which requested the subscription provisioning. In a multi-service execution graph, there may
	// be many services at play; subscription provisioning requires relative path resolution for role assignment ARM templates, so
	// the path to the service's directory must be known.
	ServiceGroup string

	// ResourceGroup records the semantic identifier for the resource group that requested subscription provisioning. The scope tags
	// used to parameterize the subscription provisioning must be tied to a specific resource group.
	ResourceGroup string

	Config types.SubscriptionProvisioning
}

Subscription holds the metadata required to handle subscription provisioning for an execution graph.

Jump to

Keyboard shortcuts

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