graph

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2015 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnknownGraphKind = iota
	ImageStreamTagGraphKind
	DockerRepositoryGraphKind
	BuildConfigGraphKind
	DeploymentConfigGraphKind
	SourceRepositoryGraphKind
	ServiceGraphKind
	ImageGraphKind
	PodGraphKind
	ImageStreamGraphKind
	ReplicationControllerGraphKind
	ImageLayerGraphKind
	BuildGraphKind
)
View Source
const (
	UnknownGraphEdgeKind = iota
	ReferencedByGraphEdgeKind
	BuildInputImageGraphEdgeKind
	TriggersDeploymentGraphEdgeKind
	BuildInputGraphEdgeKind
	BuildOutputGraphEdgeKind
	UsedInDeploymentGraphEdgeKind
	ExposedThroughServiceGraphEdgeKind
	ReferencedImageGraphEdgeKind
	WeakReferencedImageGraphEdgeKind
	ReferencedImageLayerGraphEdgeKind
)

Variables

This section is empty.

Functions

func AddReversedEdge

func AddReversedEdge(g Interface, head, tail graph.Node, edgeKind int) bool

AddReversedEdge adds a reversed edge for every passed edge and preserves the existing edge. Used to convert a one directional edge into a bidirectional edge, but will create duplicate edges if a bidirectional edge between two nodes already exists.

func AllNodes

func AllNodes(g Interface, node graph.Node) bool

AllNodes includes all nodes in the graph

func Build

func Build(g MutableUniqueGraph, build *build.Build) graph.Node

Build adds a graph node for the build if it does not already exist.

func BuildConfig

func BuildConfig(g MutableUniqueGraph, config *build.BuildConfig) graph.Node

BuildConfig adds a graph node for the specific build config if it does not exist, and will link the build config to other nodes for the images and source repositories it depends on.

func CompareImagePipeline

func CompareImagePipeline(a, b *ImagePipeline) bool

func CompareObjectMeta

func CompareObjectMeta(a, b *kapi.ObjectMeta) bool

func DeploymentConfig

func DeploymentConfig(g MutableUniqueGraph, config *deploy.DeploymentConfig) graph.Node

DeploymentConfig adds the provided deployment config to the graph if it does not exist, and will create edges that point to named Docker image repositories for each image used in the deployment.

func DeploymentPipelines

func DeploymentPipelines(g Graph) (DeploymentPipelineMap, NodeSet)

DeploymentPipelines returns a map of DeploymentConfigs to the deployment flows that create them, extracted from the provided Graph.

func DockerRepository

func DockerRepository(g MutableUniqueGraph, name, tag string) graph.Node

DockerRepository adds the named Docker repository tag reference to the graph if it does not already exist. If the reference is invalid, the Name field of the graph will be used directly.

func EachTemplateImage

func EachTemplateImage(pod *kapi.PodSpec, triggerFn TriggeredByFunc, fn func(TemplateImage, error))

func ExistingDirectEdge

func ExistingDirectEdge(g Interface, head, tail graph.Node, edgeKind int) bool

ExistingDirectEdge returns true if both head and tail already exist in the graph and the edge kind is not ReferencedByGraphEdgeKind (the generic reverse edge kind). This will purge the graph of any edges created by AddReversedEdge.

func FindImage

func FindImage(g MutableUniqueGraph, imageName string) graph.Node

func FindImageStream

func FindImageStream(g MutableUniqueGraph, stream *image.ImageStream) graph.Node

func Fprint

func Fprint(out io.Writer, g Graph)

func Image

func Image(g MutableUniqueGraph, img *image.Image) graph.Node

func ImageLayer

func ImageLayer(g MutableUniqueGraph, layer string) graph.Node

ImageLayer adds a graph node for the layer if it does not already exist.

func ImageStream

func ImageStream(g MutableUniqueGraph, stream *image.ImageStream) graph.Node

ImageStream adds a graph node for the Image Stream if it does not already exist.

func ImageStreamTag

func ImageStreamTag(g MutableUniqueGraph, namespace, name, tag string) graph.Node

ImageStreamTag adds a graph node for the specific tag in an Image Stream if it does not already exist.

func JoinBuilds

func JoinBuilds(node *BuildConfigNode, builds []build.Build)

func JoinDeployments

func JoinDeployments(node *DeploymentConfigNode, deploys []kapi.ReplicationController)

func NodesByKind

func NodesByKind(g Interface, nodes []graph.Node, kinds ...int) [][]graph.Node

func Pod

func Pod(g MutableUniqueGraph, pod *kapi.Pod) graph.Node

func ReplicationController

func ReplicationController(g MutableUniqueGraph, rc *kapi.ReplicationController) graph.Node

ReplicationController adds a graph node for the ReplicationController if it does not already exist.

func ReverseExistingDirectEdge

func ReverseExistingDirectEdge(g Interface, head, tail graph.Node, edgeKind int) bool

ReverseExistingDirectEdge reverses the order of the edge and drops the existing edge only if both head and tail already exist in the graph and the edge kind is not ReferencedByGraphEdgeKind (the generic reverse edge kind).

func ReverseGraphEdge

func ReverseGraphEdge(g Interface, head, tail graph.Node, edgeKind int) bool

ReverseGraphEdge reverses the order of the edge and drops the existing edge.

func Service

func Service(g MutableUniqueGraph, svc *kapi.Service) graph.Node

Service adds the provided service to the graph if it does not already exist. It does not link the service to covered nodes (that is a separate method).

func SourceRepository

func SourceRepository(g MutableUniqueGraph, source build.BuildSource) (graph.Node, bool)

SourceRepository adds the specific BuildSource to the graph if it does not already exist.

Types

type BuildConfigNode

type BuildConfigNode struct {
	Node
	*build.BuildConfig

	LastSuccessfulBuild   *build.Build
	LastUnsuccessfulBuild *build.Build
	ActiveBuilds          []build.Build
}

func (*BuildConfigNode) Kind

func (*BuildConfigNode) Kind() int

func (BuildConfigNode) Object

func (n BuildConfigNode) Object() interface{}

func (BuildConfigNode) String

func (n BuildConfigNode) String() string

type BuildNode

type BuildNode struct {
	Node
	Build *build.Build
}

func (*BuildNode) Kind

func (*BuildNode) Kind() int

func (BuildNode) Object

func (n BuildNode) Object() interface{}

func (BuildNode) String

func (n BuildNode) String() string

type DeploymentConfigNode

type DeploymentConfigNode struct {
	Node
	*deploy.DeploymentConfig

	ActiveDeployment *kapi.ReplicationController
	Deployments      []*kapi.ReplicationController
}

func (*DeploymentConfigNode) Kind

func (*DeploymentConfigNode) Kind() int

func (DeploymentConfigNode) Object

func (n DeploymentConfigNode) Object() interface{}

func (DeploymentConfigNode) String

func (n DeploymentConfigNode) String() string

type DeploymentFlow

type DeploymentFlow struct {
	Deployment *DeploymentConfigNode
	Images     []ImagePipeline
}

type DeploymentPipelineMap

type DeploymentPipelineMap map[*DeploymentConfigNode][]ImagePipeline

DeploymentPipelineMap describes a single deployment config and the objects that contributed to that deployment.

type DockerImageRepositoryNode

type DockerImageRepositoryNode struct {
	Node
	Ref image.DockerImageReference
}

func (DockerImageRepositoryNode) ImageSpec

func (n DockerImageRepositoryNode) ImageSpec() string

func (DockerImageRepositoryNode) ImageTag

func (n DockerImageRepositoryNode) ImageTag() string

func (*DockerImageRepositoryNode) Kind

func (DockerImageRepositoryNode) String

func (n DockerImageRepositoryNode) String() string

type Edge

type Edge struct {
	concrete.Edge
	K int
}

func NewEdge

func NewEdge(head, tail graph.Node, kind int) Edge

func (Edge) Kind

func (e Edge) Kind() int

type EdgeFunc

type EdgeFunc func(g Interface, head, tail graph.Node, edgeKind int) bool

EdgeFunc is passed a new graph, an edge in the current graph, and should mutate the new graph as needed. If true is returned, the existing edge will be added to the graph.

func AddGraphEdgesTo

func AddGraphEdgesTo(g Interface) EdgeFunc

AddGraphEdgesTo returns an EdgeFunc that will add the selected edges to the passed graph.

func UncoveredDeploymentFlowEdges

func UncoveredDeploymentFlowEdges(covered NodeSet) EdgeFunc

UncoveredDeploymentFlowEdges preserves (and duplicates) edges that were not covered by a deployment flow. As a special case, it preserves edges between Services and DeploymentConfigs.

type Graph

type Graph struct {
	// the standard graph
	graph.DirectedGraph
	// helper methods for switching on the kind and types of the node
	GraphDescriber
	// contains filtered or unexported fields
}

func CoverServices

func CoverServices(g Graph) Graph

CoverServices ensures that a directed edge exists between all deployment configs and the services that expose them (via label selectors).

func New

func New() Graph

New initializes a graph from input to output.

func (Graph) AddEdge

func (g Graph) AddEdge(head, tail graph.Node, edgeKind int)

AddEdge implements MutableUniqueGraph

func (Graph) AddNode

func (g Graph) AddNode(n graph.Node)

func (Graph) ConnectedEdgeSubgraph

func (g Graph) ConnectedEdgeSubgraph(fn EdgeFunc) Graph

ConnectedEdgeSubgraph creates a new graph that iterates through all edges in the graph and includes all edges the provided function returns true for. Nodes not referenced by an edge will be dropped unless the function adds them explicitly.

func (Graph) EdgeList

func (g Graph) EdgeList() []graph.Edge

func (Graph) EdgeSubgraph

func (g Graph) EdgeSubgraph(edgeFn EdgeFunc) Graph

EdgeSubgraph returns the directed subgraph with only the edges that match the provided function.

func (Graph) Find

func (g Graph) Find(name UniqueName) graph.Node

func (Graph) FindOrCreate

func (g Graph) FindOrCreate(name UniqueName, fn NodeInitializerFunc) (graph.Node, bool)

func (Graph) PredecessorEdges

func (g Graph) PredecessorEdges(node graph.Node, fn EdgeFunc, edgeKind ...int)

PredecessorEdges invokes fn with all of the predecessor edges of node that have the specified edge kind.

func (Graph) RootNodes

func (g Graph) RootNodes() []graph.Node

RootNodes returns all the roots of this graph.

func (Graph) Subgraph

func (g Graph) Subgraph(nodeFn NodeFunc, edgeFn EdgeFunc) Graph

Subgraph returns the directed subgraph with only the nodes and edges that match the provided functions.

func (Graph) SubgraphWithNodes

func (g Graph) SubgraphWithNodes(nodes []graph.Node, fn EdgeFunc) Graph

SubgraphWithNodes returns the directed subgraph with only the listed nodes and edges that match the provided function.

func (Graph) SuccessorEdges

func (g Graph) SuccessorEdges(node graph.Node, fn EdgeFunc, edgeKind ...int)

SuccessorEdges invokes fn with all of the successor edges of node that have the specified edge kind.

type GraphDescriber

type GraphDescriber interface {
	Name(node graph.Node) string
	Kind(node graph.Node) int
	Object(node graph.Node) interface{}
	EdgeKind(edge graph.Edge) int
}

type ImageLayerNode

type ImageLayerNode struct {
	Node
	Layer string
}

func (*ImageLayerNode) Kind

func (*ImageLayerNode) Kind() int

func (ImageLayerNode) Object

func (n ImageLayerNode) Object() interface{}

func (ImageLayerNode) String

func (n ImageLayerNode) String() string

type ImageNode

type ImageNode struct {
	Node
	Image *image.Image
}

func (*ImageNode) Kind

func (*ImageNode) Kind() int

func (ImageNode) Object

func (n ImageNode) Object() interface{}

func (ImageNode) String

func (n ImageNode) String() string

type ImagePipeline

type ImagePipeline struct {
	Image ImageTagLocation
	Build *BuildConfigNode
	// If set, the base image used by the build
	BaseImage ImageTagLocation
	// If set, the source repository that inputs to the build
	Source SourceLocation
}

ImagePipeline represents a build, its output, and any inputs. The input to a build may be another ImagePipeline.

func ImagePipelineFromNode

func ImagePipelineFromNode(g Graph, n graph.Node, covered NodeSet) (ImagePipeline, bool)

ImagePipelineFromNode attempts to locate a build flow from the provided node. If no such build flow can be located, false is returned.

type ImageStreamNode

type ImageStreamNode struct {
	Node
	*image.ImageStream
}

func (*ImageStreamNode) Kind

func (*ImageStreamNode) Kind() int

func (ImageStreamNode) Object

func (n ImageStreamNode) Object() interface{}

func (ImageStreamNode) String

func (n ImageStreamNode) String() string

type ImageStreamTagNode

type ImageStreamTagNode struct {
	Node
	*image.ImageStream
	Tag string
}

func (ImageStreamTagNode) ImageSpec

func (n ImageStreamTagNode) ImageSpec() string

func (ImageStreamTagNode) ImageTag

func (n ImageStreamTagNode) ImageTag() string

func (*ImageStreamTagNode) Kind

func (*ImageStreamTagNode) Kind() int

func (ImageStreamTagNode) Object

func (n ImageStreamTagNode) Object() interface{}

func (ImageStreamTagNode) String

func (n ImageStreamTagNode) String() string

type ImageTagLocation

type ImageTagLocation interface {
	ID() int
	ImageSpec() string
	ImageTag() string
}

ImageTagLocation identifies the source or destination of an image. Represents both a tag in a Docker image repository, as well as a tag in an OpenShift image stream.

type MutableDirectedEdge

type MutableDirectedEdge interface {
	AddEdge(head, tail graph.Node, edgeKind int)
}

type Node

type Node struct {
	concrete.Node
	UniqueName
}

type NodeFinder

type NodeFinder interface {
	Find(name UniqueName) graph.Node
}

type NodeFunc

type NodeFunc func(g Interface, n graph.Node) bool

NodeFunc is passed a new graph, a node in the graph, and should return true if the node should be included.

func UncoveredDeploymentFlowNodes

func UncoveredDeploymentFlowNodes(covered NodeSet) NodeFunc

UncoveredDeploymentFlowNodes includes nodes that either services or deployment configs, or which haven't previously been covered.

type NodeInitializerFunc

type NodeInitializerFunc func(Node) graph.Node

type NodeSet

type NodeSet map[int]struct{}

func (NodeSet) Add

func (n NodeSet) Add(id int)

func (NodeSet) Has

func (n NodeSet) Has(id int) bool

type PodNode

type PodNode struct {
	Node
	Pod *kapi.Pod
}

type RecentBuildReferences

type RecentBuildReferences []*build.Build

func (RecentBuildReferences) Len

func (m RecentBuildReferences) Len() int

func (RecentBuildReferences) Less

func (m RecentBuildReferences) Less(i, j int) bool

func (RecentBuildReferences) Swap

func (m RecentBuildReferences) Swap(i, j int)

type RecentDeploymentReferences

type RecentDeploymentReferences []*kapi.ReplicationController

func (RecentDeploymentReferences) Len

func (RecentDeploymentReferences) Less

func (m RecentDeploymentReferences) Less(i, j int) bool

func (RecentDeploymentReferences) Swap

func (m RecentDeploymentReferences) Swap(i, j int)

type ReplicationControllerNode

type ReplicationControllerNode struct {
	Node
	*kapi.ReplicationController
}

func (*ReplicationControllerNode) Kind

func (ReplicationControllerNode) Object

func (n ReplicationControllerNode) Object() interface{}

func (ReplicationControllerNode) String

func (n ReplicationControllerNode) String() string

type ServiceGroup

type ServiceGroup struct {
	Services    []ServiceReference
	Deployments []DeploymentFlow
	Builds      []ImagePipeline
}

ServiceGroup is a related set of resources that should be displayed together logically. They are usually sorted internally.

func ServiceAndDeploymentGroups

func ServiceAndDeploymentGroups(g Graph) []ServiceGroup

ServiceAndDeploymentGroups breaks the provided graph of API relationships into ServiceGroup objects, ordered consistently. Groups are organized so that overlapping Services and DeploymentConfigs are part of the same group, Deployment Configs are each in their own group, and then BuildConfigs are part of the last service group.

type ServiceNode

type ServiceNode struct {
	Node
	*kapi.Service
}

func (*ServiceNode) Kind

func (*ServiceNode) Kind() int

func (ServiceNode) Object

func (n ServiceNode) Object() interface{}

func (ServiceNode) String

func (n ServiceNode) String() string

type ServiceReference

type ServiceReference struct {
	Service *ServiceNode
	Covers  []*DeploymentConfigNode
}

ServiceReference is a service and the DeploymentConfigs it covers

type SortedDeploymentPipelines

type SortedDeploymentPipelines []DeploymentFlow

func (SortedDeploymentPipelines) Len

func (SortedDeploymentPipelines) Less

func (m SortedDeploymentPipelines) Less(i, j int) bool

func (SortedDeploymentPipelines) Swap

func (m SortedDeploymentPipelines) Swap(i, j int)

type SortedImagePipelines

type SortedImagePipelines []ImagePipeline

func (SortedImagePipelines) Len

func (m SortedImagePipelines) Len() int

func (SortedImagePipelines) Less

func (m SortedImagePipelines) Less(i, j int) bool

func (SortedImagePipelines) Swap

func (m SortedImagePipelines) Swap(i, j int)

type SortedServiceGroups

type SortedServiceGroups []ServiceGroup

func (SortedServiceGroups) Len

func (m SortedServiceGroups) Len() int

func (SortedServiceGroups) Less

func (m SortedServiceGroups) Less(i, j int) bool

func (SortedServiceGroups) Swap

func (m SortedServiceGroups) Swap(i, j int)

type SortedServiceReferences

type SortedServiceReferences []ServiceReference

func (SortedServiceReferences) Len

func (m SortedServiceReferences) Len() int

func (SortedServiceReferences) Less

func (m SortedServiceReferences) Less(i, j int) bool

func (SortedServiceReferences) Swap

func (m SortedServiceReferences) Swap(i, j int)

type SourceLocation

type SourceLocation interface {
	ID() int
}

SourceLocation identifies a repository that is an input to a build.

type SourceRepositoryNode

type SourceRepositoryNode struct {
	Node
	Source build.BuildSource
}

func (SourceRepositoryNode) Kind

func (SourceRepositoryNode) Kind() int

func (SourceRepositoryNode) String

func (n SourceRepositoryNode) String() string

type TemplateImage

type TemplateImage struct {
	Image string

	Ref *image.DockerImageReference

	From    *kapi.ObjectReference
	FromTag string
}

type TriggeredByFunc

type TriggeredByFunc func(container *kapi.Container) (TemplateImage, bool)

func DeploymentConfigHasTrigger

func DeploymentConfigHasTrigger(config *deploy.DeploymentConfig) TriggeredByFunc

type UniqueName

type UniqueName string

func (UniqueName) UniqueName

func (n UniqueName) UniqueName() string

type UniqueNodeInitializer

type UniqueNodeInitializer interface {
	FindOrCreate(name UniqueName, fn NodeInitializerFunc) (graph.Node, bool)
}

UniqueNodeInitializer is a graph that allows nodes with a unique name to be added without duplication. If the node is newly added, true will be returned.

Jump to

Keyboard shortcuts

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