Documentation
¶
Overview ¶
This example demonstrates a distance queue built using the heap interface.
Index ¶
- Constants
- func DecodeJSON(input map[string]interface{}, output interface{}) error
- func Dijkstra(graph *Graph, src schema.GroupVersionResource) (dist map[schema.GroupVersionResource]uint64, ...)
- func Extract(u *unstructured.Unstructured, fieldPath string, v interface{}) (bool, error)
- func ExtractName(name, selector string) (string, bool)
- func ExtractSelector(u *unstructured.Unstructured, fieldPath string) (string, labels.Selector, error)
- func GeneratePaths(src schema.GroupVersionResource, dist map[schema.GroupVersionResource]uint64, ...) map[schema.GroupVersionResource]*Path
- func IsOwnedBy(obj metav1.Object, owner metav1.Object) bool
- func Namespaces(ref *unstructured.Unstructured, nsSelector string) ([]string, error)
- type AdjacencyMap
- type Edge
- type Graph
- func (g *Graph) AddEdge(e *Edge)
- func (g *Graph) Edges(src schema.GroupVersionResource) AdjacencyMap
- func (g *Graph) List(f dynamicfactory.Factory, src *unstructured.Unstructured, ...) ([]*unstructured.Unstructured, error)
- func (g *Graph) ListUsingDFS(f dynamicfactory.Factory, src *unstructured.Unstructured, ...) ([]*unstructured.Unstructured, error)
- func (g *Graph) ListUsingDijkstra(f dynamicfactory.Factory, src *unstructured.Unstructured, ...) ([]*unstructured.Unstructured, error)
- type Item
- type NamespaceSelector
- type ObjectFinder
- func (finder ObjectFinder) Get(ref *v1alpha1.ObjectRef) (*unstructured.Unstructured, error)
- func (finder ObjectFinder) List(src *unstructured.Unstructured, path []*Edge) ([]*unstructured.Unstructured, error)
- func (finder ObjectFinder) ListConnectedPartials(src *unstructured.Unstructured, edges AdjacencyMap) (map[schema.GroupVersionResource][]*metav1.PartialObjectMetadata, error)
- func (finder ObjectFinder) ListConnectedResources(src *unstructured.Unstructured, edges AdjacencyMap) (map[schema.GroupVersionResource][]*unstructured.Unstructured, error)
- func (finder ObjectFinder) Locate(locator *v1alpha1.ObjectLocator, edgeList []v1alpha1.NamedEdge) (*unstructured.Unstructured, error)
- func (finder ObjectFinder) ResourcesFor(src *unstructured.Unstructured, e *Edge) ([]*unstructured.Unstructured, error)
- type Path
- type Queue
- type ResourceRef
Constants ¶
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 Dijkstra ¶
func Dijkstra(graph *Graph, src schema.GroupVersionResource) (dist map[schema.GroupVersionResource]uint64, prev map[schema.GroupVersionResource]*Edge)
func Extract ¶
func Extract(u *unstructured.Unstructured, fieldPath string, v interface{}) (bool, error)
func ExtractName ¶
func ExtractSelector ¶
func ExtractSelector(u *unstructured.Unstructured, fieldPath string) (string, labels.Selector, error)
func GeneratePaths ¶
func GeneratePaths(src schema.GroupVersionResource, dist map[schema.GroupVersionResource]uint64, prev map[schema.GroupVersionResource]*Edge) map[schema.GroupVersionResource]*Path
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 Edge struct { Src schema.GroupVersionResource Dst schema.GroupVersionResource W uint64 Connection v1alpha1.ResourceConnectionSpec Forward bool }
func GetConnectedGraph ¶ added in v0.5.3
func GetConnectedGraph(config *rest.Config, reg *hub.Registry, srcGVR schema.GroupVersionResource, ref types.NamespacedName) ([]*Edge, error)
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
func LoadGraphOfKnownResources ¶ added in v0.2.2
func (*Graph) Edges ¶ added in v0.5.5
func (g *Graph) Edges(src schema.GroupVersionResource) AdjacencyMap
func (*Graph) List ¶
func (g *Graph) List(f dynamicfactory.Factory, src *unstructured.Unstructured, dstGVR schema.GroupVersionResource) ([]*unstructured.Unstructured, error)
func (*Graph) ListUsingDFS ¶ added in v0.5.3
func (g *Graph) ListUsingDFS(f dynamicfactory.Factory, src *unstructured.Unstructured, dstGVR schema.GroupVersionResource) ([]*unstructured.Unstructured, error)
func (*Graph) ListUsingDijkstra ¶ added in v0.5.3
func (g *Graph) ListUsingDijkstra(f dynamicfactory.Factory, src *unstructured.Unstructured, dstGVR schema.GroupVersionResource) ([]*unstructured.Unstructured, error)
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 ObjectFinder ¶ added in v0.5.5
type ObjectFinder struct { Factory dynamicfactory.Factory Mapper disco_util.ResourceMapper }
func (ObjectFinder) Get ¶ added in v0.5.5
func (finder ObjectFinder) Get(ref *v1alpha1.ObjectRef) (*unstructured.Unstructured, error)
func (ObjectFinder) List ¶ added in v0.5.5
func (finder ObjectFinder) List(src *unstructured.Unstructured, path []*Edge) ([]*unstructured.Unstructured, error)
func (ObjectFinder) ListConnectedPartials ¶ added in v0.5.5
func (finder ObjectFinder) ListConnectedPartials(src *unstructured.Unstructured, edges AdjacencyMap) (map[schema.GroupVersionResource][]*metav1.PartialObjectMetadata, error)
func (ObjectFinder) ListConnectedResources ¶ added in v0.5.5
func (finder ObjectFinder) ListConnectedResources(src *unstructured.Unstructured, edges AdjacencyMap) (map[schema.GroupVersionResource][]*unstructured.Unstructured, error)
func (ObjectFinder) Locate ¶ added in v0.5.5
func (finder ObjectFinder) Locate(locator *v1alpha1.ObjectLocator, edgeList []v1alpha1.NamedEdge) (*unstructured.Unstructured, error)
func (ObjectFinder) ResourcesFor ¶ added in v0.5.5
func (finder ObjectFinder) ResourcesFor(src *unstructured.Unstructured, e *Edge) ([]*unstructured.Unstructured, error)
type Path ¶
type Path struct { Source schema.GroupVersionResource Target schema.GroupVersionResource Distance uint64 Edges []*Edge }
func FindPaths ¶ added in v0.5.3
func FindPaths(graph *Graph, src, dst schema.GroupVersionResource) []*Path
https://efficientcodeblog.wordpress.com/2018/02/15/finding-all-paths-between-two-nodes-in-a-graph/ https://www.baeldung.com/cs/simple-paths-between-two-vertices FindPaths returns all simple paths betweek 2 vertices of a graph.
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)