internal

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstructClusterResourceTree

func ConstructClusterResourceTree(ctx context.Context, defaultClient client.Client, runtimeClient ctrlclient.Client, dcOptions client.DescribeClusterOptions) (*ClusterResourceNode, *HTTPError)

ConstructClusterResourceTree returns a tree with nodes representing the Cluster API resources in the Cluster. Note: ObjectReferenceObjects do not have the virtual annotation so we can assume that all virtual objects are collapsible

func ConstructInClusterKubeconfig

func ConstructInClusterKubeconfig(ctx context.Context, restConfig *rest.Config, namespace string) (*clientcmdapi.Config, error)

func ConstructMultiClusterTree

func ConstructMultiClusterTree(ctx context.Context, ctrlClient ctrlclient.Client, k8sConfigClient *api.Config) (*MultiClusterTreeNode, *HTTPError)

ConstructMultiClusterTree returns a tree representing the workload cluster discovered in the management cluster.

func GetKubeadmClusterName

func GetKubeadmClusterName(restConfig *rest.Config, namespace string, name string) (string, error)

func GetNestedValue added in v1.3.0

func GetNestedValue(data map[string]any, path []string) (result string, found bool)

GetNestedValue returns the value of a nested key in a map.

func GetPodLogsForResource added in v1.3.0

func GetPodLogsForResource(ctx context.Context, c client.Client, restConfig *rest.Config, kind string, namespace string, name string) ([]string, error)

GetPodLogsForResource returns logs for a given resource from the CAPI controllers containing the provider name label.

func OwnerRefToObjectRef added in v1.3.0

func OwnerRefToObjectRef(ownerRef metav1.OwnerReference, namespace string) *corev1.ObjectReference

OwnerRefToObjectRef returns an object reference to the ownerRef of an object.

func RemoveTransitiveOwners added in v1.3.0

func RemoveTransitiveOwners(start types.UID, ownershipGraph *OwnershipGraph)

RemoveTransitiveOwners removes transitive owners from the graph, i.e. if I is owned by J and K, and J is also owned by K, then K is removed as an owner of I as it is implicitly owned by K through J.

func WriteKubeconfigToFile

func WriteKubeconfigToFile(ctx context.Context, filePath string, clientConfig clientcmdapi.Config) error

Types

type ClusterResourceNode

type ClusterResourceNode struct {
	Name        string                 `json:"name"`
	Namespace   string                 `json:"namespace"`
	DisplayName string                 `json:"displayName"`
	Kind        string                 `json:"kind"`
	Group       string                 `json:"group"`
	Version     string                 `json:"version"`
	Provider    string                 `json:"provider"`
	UID         string                 `json:"uid"`
	Collapsible bool                   `json:"collapsible"`
	Collapsed   bool                   `json:"collapsed"`
	Ready       bool                   `json:"ready"`
	Severity    string                 `json:"severity"`
	HasReady    bool                   `json:"hasReady"`
	Children    []*ClusterResourceNode `json:"children"`
}

ClusterResourceNode represents a node in the Cluster API resource tree and is used to configure the frontend with additional options like collapsibility and provider.

type ClusterResourceTreeOptions

type ClusterResourceTreeOptions struct {
	GroupMachines                bool
	AddControlPlaneVirtualNode   bool
	KindsToCollapse              map[string]struct{}
	VNodesToInheritChildProvider map[string]struct{}
	// contains filtered or unexported fields
}

type HTTPError

type HTTPError struct {
	Status  int
	Message string
}

func GetCustomResource

func GetCustomResource(ctx context.Context, runtimeClient ctrlclient.Client, kind string, apiVersion string, namespace string, name string) (*unstructured.Unstructured, *HTTPError)

func NewInternalError

func NewInternalError(err error) *HTTPError

func (*HTTPError) Error

func (e *HTTPError) Error() string

type LogEntry added in v1.3.0

type LogEntry struct {
	Timestamp float64 `json:"ts"`
	Entry     string  `json:"entry"`
}

LogEntry is a struct to hold a log entry and its timestamp.

type MultiClusterTreeNode

type MultiClusterTreeNode struct {
	Name                   string                  `json:"name"`
	Namespace              string                  `json:"namespace"`
	InfrastructureProvider string                  `json:"infrastructureProvider"`
	IsManagement           bool                    `json:"isManagement"`
	Phase                  string                  `json:"phase"`
	Ready                  bool                    `json:"ready"`
	Children               []*MultiClusterTreeNode `json:"children"`
}

type OwnershipGraph added in v1.3.0

type OwnershipGraph struct {
	// Objects is a map of objects indexed by their UID. They indicate nodes in the graph.
	Objects map[types.UID]ctrlclient.Object

	// OwnerRefs is a map of objects to a set of their ownerRefs. They indicate directed edges in the graph, such that an edge from
	// node I to J means that I is owned by J.
	// The set is implemented as a `map[types.UID]struct{}` (meaning a map with empty structs as values) for fast lookup.
	OwnerRefs map[types.UID]map[types.UID]struct{}
}

OwnershipGraph is a graph of objects and their ownerRefs.

func NewOwnershipGraph added in v1.3.0

func NewOwnershipGraph(ctx context.Context, c ctrlclient.Client, object ctrlclient.Object) *OwnershipGraph

NewOwnershipGraph returns a new OwnershipGraph by recursively traversing the ownerRefs of the given object.

Jump to

Keyboard shortcuts

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