depgraph

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DepGraph

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

DepGraph represents a Go module's dependency graph.

func GetDepGraph

func GetDepGraph(logger *logrus.Logger) (*DepGraph, error)

GetDepGraph should be called from within a Go module. It will return the dependency graph for this module. The 'logger' parameter can be 'nil' which will result in no output or logging information to be provided.

func NewGraph

func NewGraph(logger *logrus.Logger, main *Module) *DepGraph

NewGraph returns a new DepGraph instance which will use the specified logger for writing log output. If nil a null-logger will be used instead.

func (*DepGraph) AddNode

func (g *DepGraph) AddNode(module *Module) (*Node, bool)

func (*DepGraph) DeepCopy

func (g *DepGraph) DeepCopy() *DepGraph

DeepCopy returns a separate copy of the current dependency graph that can be safely modified without affecting the original graph. The logger argument can be nil in which case nothing will be logged.

func (*DepGraph) Depth

func (g *DepGraph) Depth() int

func (*DepGraph) Main

func (g *DepGraph) Main() *Node

func (*DepGraph) Node

func (g *DepGraph) Node(name string) (*Node, bool)

func (*DepGraph) Nodes

func (g *DepGraph) Nodes() *NodeMap

func (*DepGraph) PruneUnsharedDeps

func (g *DepGraph) PruneUnsharedDeps() *DepGraph

PruneUnsharedDeps returns a copy of the dependency graph with all nodes removed that are not part of a chain leading to a node with more than two predecessors.

func (*DepGraph) SubGraph

func (g *DepGraph) SubGraph(filters []*DependencyFilter) *DepGraph

SubGraph returns a copy of the dependency graph with all nodes that are part of dependency chains that need to be modified for the specified dependency to be set to a given target version annotated as such.

type DependencyFilter

type DependencyFilter struct {
	Dependency string
	Version    string
}

DependencyFilter allows to specify a dependency graph filter that removes any edges that are not part of a chain leading to this dependency. If a version is given then we only keep edges that prevent the use of the dependency at that given version due to the Go module's minimal version selection.

type Module

type Module struct {
	Main    bool         // is this the main module?
	Path    string       // module path
	Replace *Module      // replaced by this module
	Version string       // module version
	Time    *time.Time   // time version was created
	Update  *Module      // available update, if any (with -u)
	GoMod   string       // the path to this module's go.mod file
	Error   *ModuleError // error loading module
}

type ModuleError

type ModuleError struct {
	Err string // the error itself
}

type Node

type Node struct {
	Module       *Module
	Predecessors *NodeMap
	Successors   *NodeMap
}

Node represents a module in a Go module's dependency graph.

func (*Node) Name

func (n *Node) Name() string

Name of the module represented by this Node in the DepGraph instance.

func (*Node) SelectedVersion

func (n *Node) SelectedVersion() string

SelectedVersion corresponds to the version of the dependency represented by this Node which was selected for use.

func (*Node) Timestamp

func (n *Node) Timestamp() *time.Time

type NodeMap

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

func NewNodeMap

func NewNodeMap() *NodeMap

func (*NodeMap) Add

func (m *NodeMap) Add(nodeReference *NodeReference)

func (*NodeMap) Copy

func (m *NodeMap) Copy() *NodeMap

func (*NodeMap) Delete

func (m *NodeMap) Delete(name string)

func (*NodeMap) Get

func (m *NodeMap) Get(name string) (*NodeReference, bool)

func (*NodeMap) Len

func (m *NodeMap) Len() int

func (*NodeMap) List

func (m *NodeMap) List() []*NodeReference

type NodeReference

type NodeReference struct {
	*Node
	VersionConstraint string
}

Jump to

Keyboard shortcuts

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