graph

package
v0.0.39 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: Apache-2.0 Imports: 59 Imported by: 1

Documentation

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

View Source
var (
	OPAInstalled     atomic.Bool
	ScannerInstalled atomic.Bool
)
View Source
var Schema = getGraphQLSchema()

Functions

func ExecGraphQLQuery

func ExecGraphQLQuery(c client.Client, query string, vars map[string]interface{}) ([]unstructured.Unstructured, 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) (labels.Selector, error)

func IsOwnedBy

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

func LocatePods added in v0.0.12

func Namespaces

func Namespaces(kc client.Client, ref *unstructured.Unstructured, ns *rsapi.NamespaceRef) ([]string, error)

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

func Render added in v0.0.3

func Render(src kmapi.OID) (*runtime.RawExtension, error)

func RenderDashboard added in v0.0.3

func RenderExec added in v0.0.6

func RenderLayout

func RenderLayout(
	kc client.Client,
	oc openvizcs.Interface,
	src kmapi.ObjectInfo,
	layoutName string,
	pageName string,
	convertToTable bool,
	renderBlocks sets.Set[string],
) (*rsapi.ResourceView, error)

func RenderPageBlock

func RenderPageBlock(kc client.Client, oc openvizcs.Interface, src kmapi.ObjectInfo, block *rsapi.PageBlockLayout, convertToTable bool) (*rsapi.PageBlockView, error)

func ResourceGraph

func ResourceGraph(mapper meta.RESTMapper, src kmapi.ObjectID, includeEdgesBesidesOffshoot []kmapi.EdgeLabel) (*rsapi.ResourceGraphResponse, error)

func SetupGraphReconciler

func SetupGraphReconciler(mgr manager.Manager) func(ctx context.Context) error

Types

type AdjacencyMap

type AdjacencyMap map[schema.GroupVersionKind]*Edge

type Edge

type Edge struct {
	Src        schema.GroupVersionKind
	Dst        schema.GroupVersionKind
	W          uint64
	Connection rsapi.ResourceConnectionSpec
	Forward    bool
}

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

type ObjectFinder struct {
	Client client.Client
}

func (ObjectFinder) Get

func (ObjectFinder) List

func (finder ObjectFinder) List(src *unstructured.Unstructured, path []*Edge) ([]*unstructured.Unstructured, error)

func (ObjectFinder) ListConnectedObjectIDs

func (finder ObjectFinder) ListConnectedObjectIDs(src *unstructured.Unstructured, connections []rsapi.ResourceConnection) (map[kmapi.EdgeLabel]ksets.OID, error)

func (ObjectFinder) ListConnectedPartials

func (finder ObjectFinder) ListConnectedPartials(src *unstructured.Unstructured, edges AdjacencyMap) (map[schema.GroupVersionKind][]*metav1.PartialObjectMetadata, error)

func (ObjectFinder) ListConnectedResources

func (finder ObjectFinder) ListConnectedResources(src *unstructured.Unstructured, edges AdjacencyMap) (map[schema.GroupVersionKind][]*unstructured.Unstructured, error)

func (ObjectFinder) Locate

func (finder ObjectFinder) Locate(locator *rsapi.ObjectLocator, edgeList []rsapi.NamedEdge) (*unstructured.Unstructured, error)

func (ObjectFinder) ResourcesFor

func (finder ObjectFinder) ResourcesFor(src *unstructured.Unstructured, e *Edge) ([]*unstructured.Unstructured, error)

type ObjectGraph

type ObjectGraph struct {

	// bool == true , self link
	Edges map[kmapi.OID]map[kmapi.EdgeLabel]map[kmapi.OID]bool `json:"edges,omitempty"` // oid -> label -> Edges
	IDs   map[kmapi.OID]map[kmapi.EdgeLabel]ksets.OID          `json:"ids,omitempty"`   // oid -> label -> Edges
	// contains filtered or unexported fields
}
func (g *ObjectGraph) Links(oid *kmapi.ObjectID, edgeLabel kmapi.EdgeLabel) (map[metav1.GroupKind][]kmapi.ObjectID, error)

func (*ObjectGraph) Update

func (g *ObjectGraph) Update(src kmapi.OID, connsPerLabel map[kmapi.EdgeLabel]ksets.OID)

type Reconciler

type Reconciler struct {
	client.Client
	R      kmapi.ResourceID
	Scheme *runtime.Scheme
}

Reconciler reconciles a Release object

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error)

func (*Reconciler) SetupWithManager

func (r *Reconciler) SetupWithManager(mgr manager.Manager) error

SetupWithManager sets up the controller with the Manager.

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