graph

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// Hardcode "k8s.io/kubernetes/pkg/security/podsecuritypolicy/util.ValidatedPSPAnnotation"
	// as "kubernetes.io/psp" so we don't need import the entire k8s.io/kubernetes
	// package.
	ValidatedPSPAnnotation = "kubernetes.io/psp"
)

Well-known labels & annotations.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	*unstructuredv1.Unstructured
	UID             types.UID
	Group           string
	Version         string
	Kind            string
	Resource        string
	Namespaced      bool
	Namespace       string
	Name            string
	OwnerReferences []metav1.OwnerReference
	Dependencies    map[types.UID]RelationshipSet
	Dependents      map[types.UID]RelationshipSet
	Depth           uint
}

Node represents a Kubernetes object in an relationship tree.

func (*Node) AddDependency added in v0.4.0

func (n *Node) AddDependency(uid types.UID, r Relationship)

func (*Node) AddDependent

func (n *Node) AddDependent(uid types.UID, r Relationship)

func (*Node) GetAPIResource added in v0.3.0

func (n *Node) GetAPIResource() metav1.APIResource

func (*Node) GetDeps added in v0.4.0

func (n *Node) GetDeps(depsIsDependencies bool) map[types.UID]RelationshipSet

func (*Node) GetNestedString

func (n *Node) GetNestedString(fields ...string) string

func (*Node) GetObjectReferenceKey

func (n *Node) GetObjectReferenceKey() ObjectReferenceKey

type NodeList

type NodeList []*Node

NodeList contains a list of nodes.

func (NodeList) Len

func (n NodeList) Len() int

func (NodeList) Less

func (n NodeList) Less(i, j int) bool

func (NodeList) Swap

func (n NodeList) Swap(i, j int)

type NodeMap

type NodeMap map[types.UID]*Node

NodeMap contains a relationship tree stored as a map of nodes.

func ResolveDependencies added in v0.4.0

func ResolveDependencies(m meta.RESTMapper, objects []unstructuredv1.Unstructured, uids []types.UID) (NodeMap, error)

ResolveDependencies resolves all dependencies of the provided objects and returns a relationship tree.

func ResolveDependents

func ResolveDependents(m meta.RESTMapper, objects []unstructuredv1.Unstructured, uids []types.UID) (NodeMap, error)

ResolveDependents resolves all dependents of the provided objects and returns a relationship tree.

type ObjectLabelSelector

type ObjectLabelSelector struct {
	Group     string
	Kind      string
	Namespace string
	Selector  labels.Selector
}

ObjectLabelSelector is a reference to a collection of Kubernetes objects.

func (*ObjectLabelSelector) Key

Key converts the ObjectLabelSelector into a ObjectLabelSelectorKey.

type ObjectLabelSelectorKey

type ObjectLabelSelectorKey string

ObjectLabelSelectorKey is a compact representation of an ObjectLabelSelector. Typically used as key types for maps.

type ObjectReference

type ObjectReference struct {
	Group     string
	Kind      string
	Namespace string
	Name      string
}

ObjectReference is a reference to a Kubernetes object.

func (*ObjectReference) Key

Key converts the ObjectReference into a ObjectReferenceKey.

type ObjectReferenceKey

type ObjectReferenceKey string

ObjectReferenceKey is a compact representation of an ObjectReference. Typically used as key types for maps.

type ObjectSelector added in v0.3.0

type ObjectSelector struct {
	Group      string
	Kind       string
	Namespaces sets.String
}

ObjectSelector is a reference to a collection of Kubernetes objects.

func (*ObjectSelector) Key added in v0.3.0

Key converts the ObjectSelector into a ObjectSelectorKey.

type ObjectSelectorKey added in v0.3.0

type ObjectSelectorKey string

ObjectSelectorKey is a compact representation of an ObjectSelector. Typically used as key types for maps.

type Relationship

type Relationship string

Relationship represents a relationship type between two Kubernetes objects.

const (
	// Helm relationships.
	RelationshipHelmRelease Relationship = "HelmRelease"
	RelationshipHelmStorage Relationship = "HelmStorage"
)
const (
	// Kubernetes APIService relationships.
	RelationshipAPIService Relationship = "APIService"

	// Kubernetes ClusterRole, ClusterRoleBinding, RoleBinding relationships.
	RelationshipClusterRoleAggregationRule Relationship = "ClusterRoleAggregationRule"
	RelationshipClusterRolePolicyRule      Relationship = "ClusterRolePolicyRule"
	RelationshipClusterRoleBindingSubject  Relationship = "ClusterRoleBindingSubject"
	RelationshipClusterRoleBindingRole     Relationship = "ClusterRoleBindingRole"
	RelationshipRoleBindingSubject         Relationship = "RoleBindingSubject"
	RelationshipRoleBindingRole            Relationship = "RoleBindingRole"
	RelationshipRolePolicyRule             Relationship = "RolePolicyRule"

	// Kubernetes CSINode relationships.
	RelationshipCSINodeDriver Relationship = "CSINodeDriver"

	// Kubernetes CSIStorageCapacity relationships.
	RelationshipCSIStorageCapacityStorageClass Relationship = "CSIStorageCapacityStorageClass"

	// Kubernetes Event relationships.
	RelationshipEventRegarding Relationship = "EventRegarding"
	RelationshipEventRelated   Relationship = "EventRelated"

	// Kubernetes Ingress & IngressClass relationships.
	RelationshipIngressClass           Relationship = "IngressClass"
	RelationshipIngressClassParameters Relationship = "IngressClassParameters"
	RelationshipIngressResource        Relationship = "IngressResource"
	RelationshipIngressService         Relationship = "IngressService"
	RelationshipIngressTLSSecret       Relationship = "IngressTLSSecret"

	// Kubernetes MutatingWebhookConfiguration & ValidatingWebhookConfiguration relationships.
	RelationshipWebhookConfigurationService Relationship = "WebhookConfigurationService"

	// Kubernetes RelationshipNetworkPolicy relationships.
	RelationshipNetworkPolicy Relationship = "NetworkPolicy"

	// Kubernetes Owner-Dependent relationships.
	RelationshipControllerRef Relationship = "ControllerReference"
	RelationshipOwnerRef      Relationship = "OwnerReference"

	// Kubernetes PersistentVolume & PersistentVolumeClaim relationships.
	RelationshipPersistentVolumeClaim           Relationship = "PersistentVolumeClaim"
	RelationshipPersistentVolumeCSIDriver       Relationship = "PersistentVolumeCSIDriver"
	RelationshipPersistentVolumeCSIDriverSecret Relationship = "PersistentVolumeCSIDriverSecret"
	RelationshipPersistentVolumeStorageClass    Relationship = "PersistentVolumeStorageClass"

	// Kubernetes Pod relationships.
	RelationshipPodContainerEnv          Relationship = "PodContainerEnvironment"
	RelationshipPodImagePullSecret       Relationship = "PodImagePullSecret" //nolint:gosec
	RelationshipPodNode                  Relationship = "PodNode"
	RelationshipPodPriorityClass         Relationship = "PodPriorityClass"
	RelationshipPodRuntimeClass          Relationship = "PodRuntimeClass"
	RelationshipPodSecurityPolicy        Relationship = "PodSecurityPolicy"
	RelationshipPodServiceAccount        Relationship = "PodServiceAccount"
	RelationshipPodVolume                Relationship = "PodVolume"
	RelationshipPodVolumeCSIDriver       Relationship = "PodVolumeCSIDriver"
	RelationshipPodVolumeCSIDriverSecret Relationship = "PodVolumeCSIDriverSecret" //nolint:gosec

	// Kubernetes PodDisruptionBudget relationships.
	RelationshipPodDisruptionBudget Relationship = "PodDisruptionBudget"

	// Kubernetes PodSecurityPolicy relationships.
	RelationshipPodSecurityPolicyAllowedCSIDriver    Relationship = "PodSecurityPolicyAllowedCSIDriver"
	RelationshipPodSecurityPolicyAllowedRuntimeClass Relationship = "PodSecurityPolicyAllowedRuntimeClass"
	RelationshipPodSecurityPolicyDefaultRuntimeClass Relationship = "PodSecurityPolicyDefaultRuntimeClass"

	// Kubernetes RuntimeClass relationships.
	RelationshipRuntimeClass Relationship = "RuntimeClass"

	// Kubernetes Service relationships.
	RelationshipService Relationship = "Service"

	// Kubernetes ServiceAccount relationships.
	RelationshipServiceAccountImagePullSecret Relationship = "ServiceAccountImagePullSecret"
	RelationshipServiceAccountSecret          Relationship = "ServiceAccountSecret"

	// Kubernetes StorageClass relationships.
	RelationshipStorageClassProvisioner Relationship = "StorageClassProvisioner"

	// Kubernetes VolumeAttachment relationships.
	RelationshipVolumeAttachmentAttacher                    Relationship = "VolumeAttachmentAttacher"
	RelationshipVolumeAttachmentNode                        Relationship = "VolumeAttachmentNode"
	RelationshipVolumeAttachmentSourceVolume                Relationship = "VolumeAttachmentSourceVolume"
	RelationshipVolumeAttachmentSourceVolumeClaim           Relationship = "VolumeAttachmentSourceVolumeClaim"
	RelationshipVolumeAttachmentSourceVolumeCSIDriver       Relationship = "VolumeAttachmentSourceVolumeCSIDriver"
	RelationshipVolumeAttachmentSourceVolumeCSIDriverSecret Relationship = "VolumeAttachmentSourceVolumeCSIDriverSecret"
	RelationshipVolumeAttachmentSourceVolumeStorageClass    Relationship = "VolumeAttachmentSourceVolumeStorageClass"
)

type RelationshipMap

type RelationshipMap struct {
	DependenciesByLabelSelector map[ObjectLabelSelectorKey]RelationshipSet
	DependenciesByRef           map[ObjectReferenceKey]RelationshipSet
	DependenciesBySelector      map[ObjectSelectorKey]RelationshipSet
	DependenciesByUID           map[types.UID]RelationshipSet
	DependentsByLabelSelector   map[ObjectLabelSelectorKey]RelationshipSet
	DependentsByRef             map[ObjectReferenceKey]RelationshipSet
	DependentsBySelector        map[ObjectSelectorKey]RelationshipSet
	DependentsByUID             map[types.UID]RelationshipSet
	ObjectLabelSelectors        map[ObjectLabelSelectorKey]ObjectLabelSelector
	ObjectSelectors             map[ObjectSelectorKey]ObjectSelector
}

RelationshipMap contains a map of relationships a Kubernetes object has with other objects in the cluster.

func (*RelationshipMap) AddDependencyByKey

func (m *RelationshipMap) AddDependencyByKey(k ObjectReferenceKey, r Relationship)

func (*RelationshipMap) AddDependencyByLabelSelector

func (m *RelationshipMap) AddDependencyByLabelSelector(o ObjectLabelSelector, r Relationship)

func (*RelationshipMap) AddDependencyBySelector added in v0.3.0

func (m *RelationshipMap) AddDependencyBySelector(o ObjectSelector, r Relationship)

func (*RelationshipMap) AddDependencyByUID

func (m *RelationshipMap) AddDependencyByUID(uid types.UID, r Relationship)

func (*RelationshipMap) AddDependentByKey

func (m *RelationshipMap) AddDependentByKey(k ObjectReferenceKey, r Relationship)

func (*RelationshipMap) AddDependentByLabelSelector

func (m *RelationshipMap) AddDependentByLabelSelector(o ObjectLabelSelector, r Relationship)

func (*RelationshipMap) AddDependentBySelector added in v0.3.0

func (m *RelationshipMap) AddDependentBySelector(o ObjectSelector, r Relationship)

func (*RelationshipMap) AddDependentByUID

func (m *RelationshipMap) AddDependentByUID(uid types.UID, r Relationship)

type RelationshipSet

type RelationshipSet map[Relationship]struct{}

RelationshipSet contains a set of relationships.

func (RelationshipSet) List

func (s RelationshipSet) List() []string

List returns the contents as a sorted string slice.

Jump to

Keyboard shortcuts

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