graph

package
v3.10.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GraphFlags

type GraphFlags struct {
	Filter  string
	Exclude string

	Openshift bool

	RepoImportPath string
	Entrypoints    []string
	BuildTags      []string
}

func (*GraphFlags) AddFlags

func (o *GraphFlags) AddFlags(cmd *cobra.Command)

func (*GraphFlags) ToOptions

func (o *GraphFlags) ToOptions(out, errout io.Writer) (*GraphOptions, error)

type GraphOptions

type GraphOptions struct {
	// Packages is the caculated list of traversed go packages to use to create the graph
	Packages *PackageList

	// Roots is a list of go-import paths containing the total set of traversed
	// packages, from the given set of Entrypoints.
	Roots []string
	// Excludes are package go-import paths to ignore while traversing a directory structure
	Excludes []string
	// Filters are package go-import paths. Any package paths nested under these are truncated.
	Filters []string
	// BuildTags match files containing conditional compilation flags to be included during package traversal
	BuildTags []string
}

GraphOptions contains values necessary to create a dependency graph.

func (*GraphOptions) BuildGraph

func (o *GraphOptions) BuildGraph() (*MutableDirectedGraph, error)

BuildGraph receives a list of Go packages and constructs a dependency graph from it.\ Each package's ImportPath and non-transitive (immediate) imports are filtered and aggregated. A package is filtered based on whether its ImportPath matches an accepted pattern defined in the set of validPackages. Any core library dependencies (fmt, strings, etc.) are not added to the graph. Any packages whose import path is contained within a list of "excludes" are not added to the graph. Returns a directed graph and a map of package import paths to node ids, or an error.

func (*GraphOptions) Complete

func (o *GraphOptions) Complete() error

func (*GraphOptions) Validate

func (o *GraphOptions) Validate() error

type MutableDirectedGraph

type MutableDirectedGraph struct {
	*concrete.DirectedGraph
	// contains filtered or unexported fields
}

func FilterPackages

func FilterPackages(g *MutableDirectedGraph, packagePrefixes []string) (*MutableDirectedGraph, error)

FilterPackages receives a graph and a set of packagePrefixes contained within the graph. Returns a new graph with the sub-tree for each node matching the packagePrefix collapsed into just that node. Relationships among packagePrefixes are kept: edges originating from packagePrefix subpackages are re-written to originate from the packagePrefix, and edges terminating at packagePrefix subpackages are re-written to terminate at the packagePrefix.

func NewMutableDirectedGraph

func NewMutableDirectedGraph(roots []string) *MutableDirectedGraph

func (*MutableDirectedGraph) AddNode

func (g *MutableDirectedGraph) AddNode(n *Node) error

func (*MutableDirectedGraph) Copy

Copy creates a new graph instance, preserving all of the nodes and edges from the original graph. The nodes themselves are shallow copies from the original graph.

func (*MutableDirectedGraph) NodeByName

func (g *MutableDirectedGraph) NodeByName(name string) (graph.Node, bool)

func (*MutableDirectedGraph) PruneOrphans

func (g *MutableDirectedGraph) PruneOrphans() []*Node

PruneOrphans recursively removes nodes with no inbound edges. Nodes marked as root nodes are ignored. Returns a list of recursively pruned nodes.

func (*MutableDirectedGraph) RemoveNode

func (g *MutableDirectedGraph) RemoveNode(n *Node)

RemoveNode deletes the given node from the graph, removing all of its outbound and inbound edges as well.

type Node

type Node struct {
	Id         int
	UniqueName string
	Color      string
}

func (Node) DOTAttributes

func (n Node) DOTAttributes() []dot.Attribute

DOTAttributes implements an attribute getter for the DOT encoding

func (Node) ID

func (n Node) ID() int

func (Node) String

func (n Node) String() string

type Package

type Package struct {
	Dir         string
	ImportPath  string
	Imports     []string
	TestImports []string
	Error       *PackageError
}

type PackageError

type PackageError struct {
	ImportStack []string
	Pos         string
	Err         string
}

func (*PackageError) Error

func (e *PackageError) Error() string

type PackageList

type PackageList struct {
	Packages []Package
}

func (*PackageList) Add

func (p *PackageList) Add(pkg Package)

Jump to

Keyboard shortcuts

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