render

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2016 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UncontainedID    = "uncontained"
	UncontainedMajor = "Uncontained"

	TheInternetID    = "theinternet"
	TheInternetMajor = "The Internet"

	ContainersKey = "containers"

	AmazonECSContainerNameLabel  = "com.amazonaws.ecs.container-name"
	KubernetesContainerNameLabel = "io.kubernetes.container.name"
)

Constants are used in the tests.

View Source
const (
	Circle   = "circle"
	Square   = "square"
	Heptagon = "heptagon"
	Hexagon  = "hexagon"
	Cloud    = "cloud"
)

Shapes that are allowed

View Source
const IsConnected = "is_connected"

IsConnected is the key added to Node.Metadata by ColorConnected to indicate a node has an edge pointing to it or from it

Variables

View Source
var (
	// SelectEndpoint selects the endpoint topology.
	SelectEndpoint = TopologySelector(func(r report.Report) RenderableNodes {
		return MakeRenderableNodes(r.Endpoint)
	})

	// SelectProcess selects the process topology.
	SelectProcess = TopologySelector(func(r report.Report) RenderableNodes {
		return MakeRenderableNodes(r.Process)
	})

	// SelectContainer selects the container topology.
	SelectContainer = TopologySelector(func(r report.Report) RenderableNodes {
		return MakeRenderableNodes(r.Container)
	})

	// SelectContainerImage selects the container image topology.
	SelectContainerImage = TopologySelector(func(r report.Report) RenderableNodes {
		return MakeRenderableNodes(r.ContainerImage)
	})

	// SelectAddress selects the address topology.
	SelectAddress = TopologySelector(func(r report.Report) RenderableNodes {
		return MakeRenderableNodes(r.Address)
	})

	// SelectHost selects the address topology.
	SelectHost = TopologySelector(func(r report.Report) RenderableNodes {
		return MakeRenderableNodes(r.Host)
	})

	// SelectPod selects the pod topology.
	SelectPod = TopologySelector(func(r report.Report) RenderableNodes {
		return MakeRenderableNodes(r.Pod)
	})

	// SelectService selects the service topology.
	SelectService = TopologySelector(func(r report.Report) RenderableNodes {
		return MakeRenderableNodes(r.Service)
	})
)

AddressRenderer is a Renderer which produces a renderable address graph from the address topology.

ContainerHostnameRenderer is a Renderer which produces a renderable container by hostname graph..

ContainerImageRenderer is a Renderer which produces a renderable container image graph by merging the container graph and the container image topology.

View Source
var ContainerRenderer = MakeReduce(
	MakeFilter(
		func(n RenderableNode) bool {
			_, inContainer := n.Node.Latest.Lookup(docker.ContainerID)
			_, isConnected := n.Node.Latest.Lookup(IsConnected)
			return inContainer || isConnected
		},
		MakeMap(
			MapProcess2Container,
			ColorConnected(ProcessRenderer),
		),
	),

	FilterUnconnected(MakeMap(
		MapIP2Container,
		MakeReduce(
			MakeMap(
				MapContainer2IP,
				SelectContainer,
			),
			MakeMap(
				MapEndpoint2IP,
				SelectEndpoint,
			),
		),
	)),

	MakeMap(
		MapContainerIdentity,
		SelectContainer,
	),
)

ContainerRenderer is a Renderer which produces a renderable container graph by merging the process graph and the container topology. NB We only want processes in container _or_ processes with network connections but we need to be careful to ensure we only include each edge once, by only including the ProcessRenderer once.

View Source
var ContainerWithHostIPsRenderer = containerWithHostIPsRenderer{ContainerRenderer}

ContainerWithHostIPsRenderer is a Renderer which produces a container graph enriched with host IPs on containers where NetworkMode is Host

View Source
var ContainerWithImageNameRenderer = containerWithImageNameRenderer{ContainerWithHostIPsRenderer}

ContainerWithImageNameRenderer is a Renderer which produces a container graph where the ranks are the image names, not their IDs

EndpointRenderer is a Renderer which produces a renderable endpoint graph.

HostRenderer is a Renderer which produces a renderable host graph from the host topology and address graph.

PodRenderer is a Renderer which produces a renderable kubernetes graph by merging the container graph and the pods topology.

PodServiceRenderer is a Renderer which produces a renderable kubernetes services graph by merging the pods graph and the services topology.

ProcessNameRenderer is a Renderer which produces a renderable process name graph by munging the progess graph.

ProcessRenderer is a Renderer which produces a renderable process graph by merging the endpoint graph and the process topology.

View Source
var ProcessWithContainerNameRenderer = processWithContainerNameRenderer{ProcessRenderer}

ProcessWithContainerNameRenderer is a Renderer which produces a process graph enriched with container names where appropriate

Functions

func GetRenderableContainerName added in v0.7.0

func GetRenderableContainerName(nmd report.Node) (string, bool)

GetRenderableContainerName obtains a user-friendly container name, to render in the UI

func ImageNameWithoutVersion added in v0.12.0

func ImageNameWithoutVersion(name string) string

ImageNameWithoutVersion splits the image name apart, returning the name without the version, if possible

func LocalNetworks

func LocalNetworks(r report.Report) report.Networks

LocalNetworks returns a superset of the networks (think: CIDRs) that are "local" from the perspective of each host represented in the report. It's used to determine which nodes in the report are "remote", i.e. outside of our infrastructure.

func MakeAddressID

func MakeAddressID(hostID, addr string) string

MakeAddressID makes an address node ID for rendered nodes.

func MakeContainerID added in v0.12.0

func MakeContainerID(containerID string) string

MakeContainerID makes a container node ID for rendered nodes.

func MakeContainerImageID added in v0.12.0

func MakeContainerImageID(imageID string) string

MakeContainerImageID makes a container image node ID for rendered nodes.

func MakeEndpointID

func MakeEndpointID(hostID, addr, port string) string

MakeEndpointID makes an endpoint node ID for rendered nodes.

func MakeHostID

func MakeHostID(hostID string) string

MakeHostID makes a host node ID for rendered nodes.

func MakePodID added in v0.12.0

func MakePodID(podID string) string

MakePodID makes a pod node ID for rendered nodes.

func MakeProcessID

func MakeProcessID(hostID, pid string) string

MakeProcessID makes a process node ID for rendered nodes.

func MakePseudoNodeID

func MakePseudoNodeID(parts ...string) string

MakePseudoNodeID produces a pseudo node ID from its composite parts, for use in rendered nodes.

func MakeServiceID added in v0.12.0

func MakeServiceID(serviceID string) string

MakeServiceID makes a service node ID for rendered nodes.

func ResetCache added in v0.12.0

func ResetCache()

ResetCache blows away the rendered node cache.

Types

type CustomRenderer added in v0.7.0

type CustomRenderer struct {
	RenderFunc func(RenderableNodes) RenderableNodes
	Renderer
}

CustomRenderer allow for mapping functions that recived the entire topology in one call - useful for functions that need to consider the entire graph. We should minimise the use of this renderer type, as it is very inflexible.

func (CustomRenderer) Render added in v0.7.0

Render implements Renderer

type Diff

type Diff struct {
	Add    []RenderableNode `json:"add"`
	Update []RenderableNode `json:"update"`
	Remove []string         `json:"remove"`
}

Diff is returned by TopoDiff. It represents the changes between two RenderableNode maps.

func TopoDiff

func TopoDiff(a, b RenderableNodes) Diff

TopoDiff gives you the diff to get from A to B.

type Filter added in v0.7.0

type Filter struct {
	Renderer
	FilterFunc func(RenderableNode) bool
}

Filter removes nodes from a view based on a predicate.

func (*Filter) Render added in v0.7.0

func (f *Filter) Render(rpt report.Report) RenderableNodes

Render implements Renderer

func (Filter) Stats added in v0.8.0

func (f Filter) Stats(rpt report.Report) Stats

Stats implements Renderer

type Map

type Map struct {
	MapFunc
	Renderer
}

Map is a Renderer which produces a set of RenderableNodes from the set of RenderableNodes produced by another Renderer.

func (*Map) Render

func (m *Map) Render(rpt report.Report) RenderableNodes

Render transforms a set of RenderableNodes produces by another Renderer. using a map function

func (*Map) Stats added in v0.8.0

func (m *Map) Stats(rpt report.Report) Stats

Stats implements Renderer

type MapFunc

MapFunc is anything which can take an arbitrary RenderableNode and return a set of other RenderableNodes.

If the output is empty, the node shall be omitted from the rendered topology.

type Reduce

type Reduce []Renderer

Reduce renderer is a Renderer which merges together the output of several other renderers.

func (*Reduce) Render

func (r *Reduce) Render(rpt report.Report) RenderableNodes

Render produces a set of RenderableNodes given a Report.

func (*Reduce) Stats added in v0.8.0

func (r *Reduce) Stats(rpt report.Report) Stats

Stats implements Renderer

type RenderableNode

type RenderableNode struct {
	ID          string         `json:"id"`                    //
	LabelMajor  string         `json:"label_major"`           // e.g. "process", human-readable
	LabelMinor  string         `json:"label_minor,omitempty"` // e.g. "hostname", human-readable, optional
	Rank        string         `json:"rank"`                  // to help the layout engine
	Pseudo      bool           `json:"pseudo,omitempty"`      // sort-of a placeholder node, for rendering purposes
	Children    report.NodeSet `json:"children,omitempty"`    // Nodes which have been grouped into this one
	ControlNode string         `json:"-"`                     // ID of node from which to show the controls in the UI
	Shape       string         `json:"shape"`                 // Shape node should be rendered as
	Stack       bool           `json:"stack"`                 // Should UI render this node as a stack?

	report.EdgeMetadata `json:"metadata"` // Numeric sums
	report.Node
}

RenderableNode is the data type that's yielded to the JavaScript layer as an element of a topology. It should contain information that's relevant to rendering a node when there are many nodes visible at once.

func NewDerivedNode added in v0.7.0

func NewDerivedNode(id string, node RenderableNode) RenderableNode

NewDerivedNode create a renderable node based on node, but with a new ID

func NewRenderableNode

func NewRenderableNode(id string) RenderableNode

NewRenderableNode makes a new RenderableNode

func NewRenderableNodeWith added in v0.7.0

func NewRenderableNodeWith(id, major, minor, rank string, node RenderableNode) RenderableNode

NewRenderableNodeWith makes a new RenderableNode with some fields filled in

func (RenderableNode) Copy added in v0.7.0

func (rn RenderableNode) Copy() RenderableNode

Copy makes a deep copy of rn

func (RenderableNode) Merge

Merge merges rn with other and returns a new RenderableNode

func (RenderableNode) Prune added in v0.7.0

func (rn RenderableNode) Prune() RenderableNode

Prune returns a copy of the RenderableNode with all information not strictly necessary for rendering nodes and edges stripped away. Specifically, that means cutting out parts of the Node.

func (RenderableNode) WithNode added in v0.7.0

func (rn RenderableNode) WithNode(n report.Node) RenderableNode

WithNode creates a new RenderableNode based on rn, with n

func (RenderableNode) WithParents added in v0.12.0

func (rn RenderableNode) WithParents(p report.Sets) RenderableNode

WithParents creates a new RenderableNode based on rn, where n has the given parents set

type RenderableNodes

type RenderableNodes map[string]RenderableNode

RenderableNodes is a set of RenderableNodes

func MakeRenderableNodes added in v0.7.0

func MakeRenderableNodes(t report.Topology) RenderableNodes

MakeRenderableNodes converts a topology to a set of RenderableNodes

func MapAddressIdentity

func MapAddressIdentity(m RenderableNode, local report.Networks) RenderableNodes

MapAddressIdentity maps an address topology node to an address renderable node. As it is only ever run on address topology nodes, we expect that certain keys are present.

func MapContainer2ContainerImage

func MapContainer2ContainerImage(n RenderableNode, _ report.Networks) RenderableNodes

MapContainer2ContainerImage maps container RenderableNodes to container image RenderableNodes.

If this function is given a node without a docker_image_id (including other pseudo nodes), it will produce an "Uncontained" pseudo node.

Otherwise, this function will produce a node with the correct ID format for a container, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a container graph to get that info.

func MapContainer2Hostname added in v0.9.0

func MapContainer2Hostname(n RenderableNode, _ report.Networks) RenderableNodes

MapContainer2Hostname maps container RenderableNodes to 'hostname' renderabled nodes..

func MapContainer2IP added in v0.7.0

func MapContainer2IP(m RenderableNode, _ report.Networks) RenderableNodes

MapContainer2IP maps container nodes to their IP addresses (outputs multiple nodes). This allows container to be joined directly with the endpoint topology.

func MapContainer2Pod added in v0.9.0

func MapContainer2Pod(n RenderableNode, _ report.Networks) RenderableNodes

MapContainer2Pod maps container RenderableNodes to pod RenderableNodes.

If this function is given a node without a kubernetes_pod_id (including other pseudo nodes), it will produce an "Unmanaged" pseudo node.

Otherwise, this function will produce a node with the correct ID format for a container, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a container graph to get that info.

func MapContainerIdentity

func MapContainerIdentity(m RenderableNode, _ report.Networks) RenderableNodes

MapContainerIdentity maps a container topology node to a container renderable node. As it is only ever run on container topology nodes, we expect that certain keys are present.

func MapContainerImage2Name added in v0.5.0

func MapContainerImage2Name(n RenderableNode, _ report.Networks) RenderableNodes

MapContainerImage2Name maps container images RenderableNodes to RenderableNodes for each container image name.

This mapper is unlike the other foo2bar mappers as the intention is not to join the information with another topology. Therefore it outputs a properly-formed node with labels etc.

func MapContainerImageIdentity

func MapContainerImageIdentity(m RenderableNode, _ report.Networks) RenderableNodes

MapContainerImageIdentity maps a container image topology node to container image renderable node. As it is only ever run on container image topology nodes, we expect that certain keys are present.

func MapCountContainers added in v0.7.0

func MapCountContainers(n RenderableNode, _ report.Networks) RenderableNodes

MapCountContainers maps 1:1 container image nodes, counting the number of containers grouped together and putting that info in the minor label.

func MapCountPods added in v0.9.0

func MapCountPods(n RenderableNode, _ report.Networks) RenderableNodes

MapCountPods maps 1:1 service nodes, counting the number of pods grouped together and putting that info in the minor label.

func MapCountProcessName added in v0.7.0

func MapCountProcessName(n RenderableNode, _ report.Networks) RenderableNodes

MapCountProcessName maps 1:1 process name nodes, counting the number of processes grouped together and putting that info in the minor label.

func MapEndpoint2IP added in v0.7.0

func MapEndpoint2IP(m RenderableNode, local report.Networks) RenderableNodes

MapEndpoint2IP maps endpoint nodes to their IP address, for joining with container nodes. We drop endpoint nodes with pids, as they will be joined to containers through the process topology, and we don't want to double count edges.

func MapEndpoint2Process

func MapEndpoint2Process(n RenderableNode, _ report.Networks) RenderableNodes

MapEndpoint2Process maps endpoint RenderableNodes to process RenderableNodes.

If this function is given a pseudo node, then it will just return it; Pseudo nodes will never have pids in them, and therefore will never be able to be turned into a Process node.

Otherwise, this function will produce a node with the correct ID format for a process, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a process graph to get that info.

func MapEndpointIdentity

func MapEndpointIdentity(m RenderableNode, local report.Networks) RenderableNodes

MapEndpointIdentity maps an endpoint topology node to a single endpoint renderable node. As it is only ever run on endpoint topology nodes, we expect that certain keys are present.

func MapHostIdentity

func MapHostIdentity(m RenderableNode, _ report.Networks) RenderableNodes

MapHostIdentity maps a host topology node to a host renderable node. As it is only ever run on host topology nodes, we expect that certain keys are present.

func MapIP2Container added in v0.7.0

func MapIP2Container(n RenderableNode, _ report.Networks) RenderableNodes

MapIP2Container maps IP nodes produced from MapContainer2IP back to container nodes. If there is more than one container with a given IP, it is dropped.

func MapPod2Service added in v0.9.0

func MapPod2Service(n RenderableNode, _ report.Networks) RenderableNodes

MapPod2Service maps pod RenderableNodes to service RenderableNodes.

If this function is given a node without a kubernetes_pod_id (including other pseudo nodes), it will produce an "Uncontained" pseudo node.

Otherwise, this function will produce a node with the correct ID format for a container, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a pod graph to get that info.

func MapPodIdentity added in v0.9.0

func MapPodIdentity(m RenderableNode, _ report.Networks) RenderableNodes

MapPodIdentity maps a pod topology node to pod renderable node. As it is only ever run on pod topology nodes, we expect that certain keys are present.

func MapProcess2Container

func MapProcess2Container(n RenderableNode, _ report.Networks) RenderableNodes

MapProcess2Container maps process RenderableNodes to container RenderableNodes.

If this function is given a node without a docker_container_id (including other pseudo nodes), it will produce an "Uncontained" pseudo node.

Otherwise, this function will produce a node with the correct ID format for a container, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a container graph to get that info.

func MapProcess2Name

func MapProcess2Name(n RenderableNode, _ report.Networks) RenderableNodes

MapProcess2Name maps process RenderableNodes to RenderableNodes for each process name.

This mapper is unlike the other foo2bar mappers as the intention is not to join the information with another topology. Therefore it outputs a properly-formed node with labels etc.

func MapProcessIdentity

func MapProcessIdentity(m RenderableNode, _ report.Networks) RenderableNodes

MapProcessIdentity maps a process topology node to a process renderable node. As it is only ever run on process topology nodes, we expect that certain keys are present.

func MapServiceIdentity added in v0.9.0

func MapServiceIdentity(m RenderableNode, _ report.Networks) RenderableNodes

MapServiceIdentity maps a service topology node to service renderable node. As it is only ever run on service topology nodes, we expect that certain keys are present.

func MapX2Host added in v0.12.0

MapX2Host maps any RenderableNodes to host RenderableNodes.

If this function is given a node without a hostname (including other pseudo nodes), it will drop the node.

Otherwise, this function will produce a node with the correct ID format for a container, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a container graph to get that info.

func (RenderableNodes) Copy added in v0.7.0

func (rns RenderableNodes) Copy() RenderableNodes

Copy produces a deep copy of the RenderableNodes

func (RenderableNodes) Merge

Merge merges two sets of RenderableNodes, returning a new set.

func (RenderableNodes) Prune added in v0.7.0

func (rns RenderableNodes) Prune() RenderableNodes

Prune returns a copy of the RenderableNodes with all information not strictly necessary for rendering nodes and edges in the UI cut away.

type Renderer

type Renderer interface {
	Render(report.Report) RenderableNodes
	Stats(report.Report) Stats
}

Renderer is something that can render a report to a set of RenderableNodes.

func ColorConnected added in v0.7.0

func ColorConnected(r Renderer) Renderer

ColorConnected colors nodes with the IsConnected key if they have edges to or from them. Edges to/from yourself are not counted here (see #656).

func FilterNoop added in v0.10.0

func FilterNoop(in Renderer) Renderer

FilterNoop does nothing.

func FilterPseudo added in v0.12.0

func FilterPseudo(r Renderer) Renderer

FilterPseudo produces a renderer that removes pseudo nodes from the given renderer

func FilterStopped added in v0.10.0

func FilterStopped(r Renderer) Renderer

FilterStopped filters out stopped containers.

func FilterSystem added in v0.7.0

func FilterSystem(r Renderer) Renderer

FilterSystem is a Renderer which filters out system nodes.

func FilterUnconnected

func FilterUnconnected(r Renderer) Renderer

FilterUnconnected produces a renderer that filters unconnected nodes from the given renderer

func MakeFilter added in v0.12.0

func MakeFilter(f func(RenderableNode) bool, r Renderer) Renderer

MakeFilter makes a new Filter.

func MakeMap added in v0.12.0

func MakeMap(f MapFunc, r Renderer) Renderer

MakeMap makes a new Map

func MakeReduce

func MakeReduce(renderers ...Renderer) Renderer

MakeReduce is the only sane way to produce a Reduce Renderer.

func Memoise added in v0.12.0

func Memoise(r Renderer) Renderer

Memoise wraps the renderer in a loving embrace of caching

type Stats added in v0.8.0

type Stats struct {
	FilteredNodes int
}

Stats is the type returned by Renderer.Stats

type TopologySelector added in v0.7.0

type TopologySelector func(r report.Report) RenderableNodes

TopologySelector selects a single topology from a report. NB it is also a Renderer!

func (TopologySelector) Render added in v0.7.0

Render implements Renderer

func (TopologySelector) Stats added in v0.8.0

func (t TopologySelector) Stats(r report.Report) Stats

Stats implements Renderer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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