graph

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

This example demonstrates a distance queue built using the heap interface.

Index

Constants

View Source
const (
	// CostFactorOfInAppFiltering = 4 means, we assume that the cost of listing all resources and
	// filtering them in the app (instead of using kube-apiserver) is 5x of that via label based selection
	CostFactorOfInAppFiltering = 4

	MetadataNamespace      = "metadata.namespace"
	MetadataNamespaceQuery = "{." + MetadataNamespace + "}"
	MetadataLabels         = "metadata.labels"
	MetadataNameQuery      = "{.metadata.name}"
)

Variables

This section is empty.

Functions

func DecodeJSON

func DecodeJSON(input map[string]interface{}, output interface{}) error

func Extract

func Extract(u unstructured.Unstructured, fieldPath string, v interface{}) (bool, error)

func ExtractName

func ExtractName(name, selector string) (string, bool)

func ExtractSelector

func ExtractSelector(u unstructured.Unstructured, fieldPath string) (string, labels.Selector, error)

func IsOwnedBy

func IsOwnedBy(obj metav1.Object, owner metav1.Object) bool

func Namespaces

func Namespaces(ref unstructured.Unstructured, nsSelector string) ([]string, error)

len([]string) == 0 && err == nil => all namespaces

Types

type AdjacencyMap

type AdjacencyMap map[schema.GroupVersionResource]*Edge

type Edge

type Graph

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

func LoadGraph

func LoadGraph(r *hub.Registry) (*Graph, error)

func LoadGraphOfKnownResources added in v0.2.2

func LoadGraphOfKnownResources() (*Graph, error)

func NewGraph

func NewGraph(r *hub.Registry) *Graph

func (*Graph) AddEdge

func (g *Graph) AddEdge(e *Edge)

func (*Graph) ResourcesFor

type Item

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

An Item is something we manage in a priority queue.

type NamespaceSelector

type NamespaceSelector struct {
	// Boolean describing whether all namespaces are selected in contrast to a
	// list restricting them.
	Any bool `json:"any,omitempty"`
	// List of namespace names.
	MatchNames []string `json:"matchNames,omitempty"`
}

ref: https://github.com/coreos/prometheus-operator/blob/cc584ecfa08d2eb95ba9401f116e3a20bf71be8b/pkg/apis/monitoring/v1/types.go#L578 NamespaceSelector is a selector for selecting either all namespaces or a list of namespaces. +k8s:openapi-gen=true

type Path

type Path struct {
	Source   schema.GroupVersionResource
	Target   schema.GroupVersionResource
	Distance uint64
	Edges    []*Edge
}

type Queue

type Queue []*Item

A Queue implements heap.Interface and holds Items.

func (Queue) Len

func (q Queue) Len() int

func (Queue) Less

func (q Queue) Less(i, j int) bool

func (*Queue) Pop

func (q *Queue) Pop() interface{}

func (*Queue) Push

func (q *Queue) Push(x interface{})

func (Queue) Swap

func (q Queue) Swap(i, j int)

func (*Queue) Update

func (q *Queue) Update(item *Item, dist uint64)

Update modifies the priority and value of an Item in the queue.

type ResourceRef

type ResourceRef struct {
	// Name is the name of resource being referenced
	Name string `json:"name"`
	// Namespace is the namespace of resource being referenced
	Namespace string `json:"namespace,omitempty"`
	// Kind is the type of resource being referenced
	Kind string `json:"kind,omitempty"`
	// APIGroup is the group for the resource being referenced
	APIGroup string `json:"apiGroup,omitempty"`
}

ResourceRef contains information that points to the resource being used

func ParseResourceRefs

func ParseResourceRefs(records [][]string) ([]ResourceRef, error)

Jump to

Keyboard shortcuts

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