resource-metadata: kmodules.xyz/resource-metadata/pkg/graph Index | Files

package graph

import "kmodules.xyz/resource-metadata/pkg/graph"

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

Index

Package Files

heap.go lib.go load_graph.go types.go

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}"
)

func DecodeJSON Uses

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

func Dijkstra Uses

func Dijkstra(graph *Graph, src schema.GroupVersionResource) (dist map[schema.GroupVersionResource]uint64, prev map[schema.GroupVersionResource]*Edge)

func Extract Uses

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

func ExtractName Uses

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

func ExtractSelector Uses

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

func GeneratePaths Uses

func GeneratePaths(src schema.GroupVersionResource, dist map[schema.GroupVersionResource]uint64, prev map[schema.GroupVersionResource]*Edge) map[schema.GroupVersionResource]*Path

func IsOwnedBy Uses

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

func Namespaces Uses

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

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

type AdjacencyMap Uses

type AdjacencyMap map[schema.GroupVersionResource]*Edge

type Edge Uses

type Edge struct {
    Src        schema.GroupVersionResource
    Dst        schema.GroupVersionResource
    W          uint64
    Connection v1alpha1.ResourceConnectionSpec
    Forward    bool
}

type Graph Uses

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

func LoadGraph Uses

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

func LoadGraphOfKnownResources Uses

func LoadGraphOfKnownResources() (*Graph, error)

func NewGraph Uses

func NewGraph(r *hub.Registry) *Graph

func (*Graph) AddEdge Uses

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

func (*Graph) List Uses

func (g *Graph) List(dc dynamic.Interface, src unstructured.Unstructured, dstGVR schema.GroupVersionResource) ([]unstructured.Unstructured, error)

func (*Graph) ResourcesFor Uses

func (g *Graph) ResourcesFor(dc dynamic.Interface, src unstructured.Unstructured, e Edge) ([]unstructured.Unstructured, error)

type Item Uses

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

An Item is something we manage in a priority queue.

type NamespaceSelector Uses

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 Uses

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

type Queue Uses

type Queue []*Item

A Queue implements heap.Interface and holds Items.

func (Queue) Len Uses

func (q Queue) Len() int

func (Queue) Less Uses

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

func (*Queue) Pop Uses

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

func (*Queue) Push Uses

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

func (Queue) Swap Uses

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

func (*Queue) Update Uses

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

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

type ResourceRef Uses

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 Uses

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

Package graph imports 19 packages (graph) and is imported by 2 packages. Updated 2019-12-19. Refresh now. Tools for package owners.