Documentation
¶
Index ¶
- Constants
- Variables
- func GetConditions(obj client.Object) []*metav1.Condition
- func GetGroupItems(obj client.Object) string
- func GetMetaName(obj client.Object) string
- func GetZOrder(obj client.Object) int
- func HasConditions(obj client.Object) bool
- func IsGroupObject(obj client.Object) bool
- func IsGroupingObject(obj client.Object) bool
- func IsShowConditionsObject(obj client.Object) bool
- func IsVirtualObject(obj client.Object) bool
- func PrintObjectTree(tree *ObjectTree) error
- func UnstructuredUnmarshalField(obj *unstructured.Unstructured, v interface{}, fields ...string) error
- func VirtualObject(namespace, kind, name string) *unstructured.Unstructured
- func VirtualObjectForVisualization(obj client.Object, kind string) *unstructured.Unstructured
- type AddObjectOption
- type GroupingObject
- type NoEcho
- type ObjectMetaName
- type ObjectTree
- func Discover(ctx context.Context, c client.Client, opts ObjectTreeOptions, subCmd string) (*ObjectTree, error)
- func DiscoverDPUClusters(ctx context.Context, tree *ObjectTree, scope objectScope, ...) (*ObjectTree, error)
- func DiscoverDPUDeployments(ctx context.Context, tree *ObjectTree, scope objectScope, ...) (*ObjectTree, error)
- func DiscoverDPUServices(ctx context.Context, tree *ObjectTree, scope objectScope, ...) (*ObjectTree, error)
- func DiscoverDPUSets(ctx context.Context, tree *ObjectTree, scope objectScope, ...) (*ObjectTree, error)
- func DiscoverDPUVPCs(ctx context.Context, tree *ObjectTree, scope objectScope, ...) (*ObjectTree, error)
- func DiscoverStorage(ctx context.Context, tree *ObjectTree, scope objectScope, ...) (*ObjectTree, error)
- func NewObjectTree(root client.Object, options ObjectTreeOptions) *ObjectTree
- func (od ObjectTree) Add(parent, obj client.Object, opts ...AddObjectOption) (added bool, visible bool)
- func (od ObjectTree) AddMultipleWithHeader(parent client.Object, objs []client.Object, headerName string, ...)
- func (od ObjectTree) GetObject(id types.UID) client.Object
- func (od ObjectTree) GetObjectsByParent(id types.UID) []client.Object
- func (od ObjectTree) GetParent(id types.UID) client.Object
- func (od ObjectTree) GetRoot() client.Object
- func (od ObjectTree) IsObjectWithChild(id types.UID) bool
- func (od ObjectTree) PruneHealthy()
- type ObjectTreeOptions
- type ZOrder
Constants ¶
const ( // ShowObjectConditionsAnnotation documents that the presentation layer should show all the conditions for the object. ShowObjectConditionsAnnotation = "tree.dpu.nvidia.com/show-conditions" // ObjectMetaNameAnnotation contains the meta name that should be used for the object in the presentation layer, // e.g. control plane for KCP. ObjectMetaNameAnnotation = "tree.dpu.nvidia.com/meta-name" // VirtualObjectAnnotation documents that the object does not correspond to any real object, but instead is // a virtual object introduced to provide a better representation of the DPF status, e.g. Applications. VirtualObjectAnnotation = "tree.dpu.nvidia.com/virtual-object" // GroupingObjectAnnotation is an annotation that should be applied to a node in order to trigger the grouping action // when adding the node's children. e.g. if you have a DPUSet, and you apply this annotation, then // the DPUs added as a children of this node will be grouped in case the ready condition // has the same Status and Reason. GroupingObjectAnnotation = "tree.dpu.nvidia.com/grouping-object" // GroupObjectAnnotation is an annotation that documents that a node is the result of a grouping operation, and // thus the node is representing group of sibling nodes, e.g. a group of DPUs. GroupObjectAnnotation = "tree.dpu.nvidia.com/group-object" // GroupItemsAnnotation contains the list of names for the objects included in a group object. GroupItemsAnnotation = "tree.dpu.nvidia.com/group-items" // GroupItemsSeparator is the separator used in the GroupItemsAnnotation. GroupItemsSeparator = ", " // ObjectZOrderAnnotation contains an integer that defines the sorting of child objects when the object tree is printed. // Objects are sorted by their z-order from highest to lowest, and then by their name in alphabetical order if the // z-order is the same. Objects with no z-order set are assumed to have a default z-order of 0. ObjectZOrderAnnotation = "tree.dpu.nvidia.com/z-order" )
const ( // CharSet defines the alphanumeric set for random string generation. // Copy from: https://github.com/kubernetes-sigs/cluster-api/blob/release-1.9/util/util.go#L56 CharSet = "0123456789abcdefghijklmnopqrstuvwxyz" )
Variables ¶
var ( // ErrUnstructuredFieldNotFound determines that a field // in an unstructured object could not be found. // Copy from: https://github.com/kubernetes-sigs/cluster-api/blob/release-1.9/util/util.go#L67 ErrUnstructuredFieldNotFound = fmt.Errorf("field not found") )
Functions ¶
func GetConditions ¶
GetConditions returns the other conditions (all the conditions except ready) for an object, if defined. Adoption from: https://github.com/kubernetes-sigs/cluster-api/blob/release-1.9/cmd/clusterctl/client/tree/util.go#L104
func GetGroupItems ¶
GetGroupItems returns the list of names for the objects included in a group object.
func GetMetaName ¶
GetMetaName returns the object meta name that should be used for the object in the presentation layer, if defined.
func GetZOrder ¶
GetZOrder return the zOrder of the object. Objects with no zOrder have a default zOrder of 0.
func HasConditions ¶
HasConditions returns true if the object has conditions to show.
func IsGroupObject ¶
IsGroupObject returns true if the object is the result of a grouping operation, and thus the object is representing group of sibling object, e.g. a group of DPUs.
func IsGroupingObject ¶
IsGroupingObject returns true in case the object is responsible to trigger the grouping action when adding the object's children. e.g. A DPUSet object, could be responsible of grouping the DPUs while added as a children objects.
func IsShowConditionsObject ¶
IsShowConditionsObject returns true if the presentation layer should show all the conditions for the object.
func IsVirtualObject ¶
IsVirtualObject returns true if the object does not correspond to any real object, but instead it is a virtual object introduced to provide a better representation of the DPF status.
func PrintObjectTree ¶
func PrintObjectTree(tree *ObjectTree) error
PrintObjectTree prints the DPF status to stdout. Adopted from: https://github.com/kubernetes-sigs/cluster-api/blob/release-1.9/cmd/clusterctl/cmd/describe_cluster.go#L213
func UnstructuredUnmarshalField ¶
func UnstructuredUnmarshalField(obj *unstructured.Unstructured, v interface{}, fields ...string) error
UnstructuredUnmarshalField is a wrapper around JSON and Unstructured objects to decode and copy a specific field value into an object. Copied and private from: https://github.com/kubernetes-sigs/cluster-api/blob/release-1.9/util/util.go#L395
func VirtualObject ¶
func VirtualObject(namespace, kind, name string) *unstructured.Unstructured
VirtualObject returns a new virtual object. Adoption from: https://github.com/kubernetes-sigs/cluster-api/blob/release-1.9/cmd/clusterctl/client/tree/util.go#L174
func VirtualObjectForVisualization ¶
func VirtualObjectForVisualization(obj client.Object, kind string) *unstructured.Unstructured
VirtualObjectForVisualization creates a virtual representation of an object to enable visualization. This is primarily used for objects like Argo Applications and BFBs that lack metav1.Conditions. The virtual object mimics the original, but strips specific annotations and optionally carries a deletion timestamp to reflect its lifecycle state in dpfctl.
Types ¶
type AddObjectOption ¶
type AddObjectOption interface {
ApplyToAdd(*addObjectOptions)
}
AddObjectOption define an option for the ObjectTree Add operation.
type GroupingObject ¶
type GroupingObject bool
The GroupingObject option makes this node responsible of triggering the grouping action when adding the node's children.
func (GroupingObject) ApplyToAdd ¶
func (n GroupingObject) ApplyToAdd(options *addObjectOptions)
ApplyToAdd applies the given options.
type NoEcho ¶
type NoEcho bool
The NoEcho options defines if the object should be hidden if the object's ready condition has the same Status, Severity and Reason of the parent's object ready condition (it is an echo).
func (NoEcho) ApplyToAdd ¶
func (n NoEcho) ApplyToAdd(options *addObjectOptions)
ApplyToAdd applies the given options.
type ObjectMetaName ¶
type ObjectMetaName string
The ObjectMetaName option defines the meta name that should be used for the object in the presentation layer, e.g. control plane for KCP.
func (ObjectMetaName) ApplyToAdd ¶
func (n ObjectMetaName) ApplyToAdd(options *addObjectOptions)
ApplyToAdd applies the given options.
type ObjectTree ¶
type ObjectTree struct {
// contains filtered or unexported fields
}
ObjectTree defines an object tree representing the status of DPF resources. Copy from: https://github.com/kubernetes-sigs/cluster-api/blob/release-1.9/cmd/clusterctl/client/tree/tree.go#L65
func Discover ¶
func Discover(ctx context.Context, c client.Client, opts ObjectTreeOptions, subCmd string) (*ObjectTree, error)
func DiscoverDPUClusters ¶
func DiscoverDPUClusters(ctx context.Context, tree *ObjectTree, scope objectScope, dpfOperatorConfig *operatorv1.DPFOperatorConfig, _ func(map[string]string) bool) (*ObjectTree, error)
DiscoverDPUClusters returns a tree of objects representing the DPF status.
func DiscoverDPUDeployments ¶
func DiscoverDPUDeployments(ctx context.Context, tree *ObjectTree, scope objectScope, dpfOperatorConfig *operatorv1.DPFOperatorConfig, _ func(map[string]string) bool) (*ObjectTree, error)
DiscoverDPUDeployments returns a tree of objects representing the DPF status.
func DiscoverDPUServices ¶
func DiscoverDPUServices(ctx context.Context, tree *ObjectTree, scope objectScope, dpfOperatorConfig *operatorv1.DPFOperatorConfig, skipFunc func(map[string]string) bool) (*ObjectTree, error)
DiscoverDPUServices returns a tree of objects representing the DPF status.
func DiscoverDPUSets ¶
func DiscoverDPUSets(ctx context.Context, tree *ObjectTree, scope objectScope, dpfOperatorConfig *operatorv1.DPFOperatorConfig, skipFunc func(map[string]string) bool) (*ObjectTree, error)
DiscoverDPUSets returns a tree of objects representing the DPF status.
func DiscoverDPUVPCs ¶
func DiscoverDPUVPCs(ctx context.Context, tree *ObjectTree, scope objectScope, dpfOperatorConfig *operatorv1.DPFOperatorConfig, _ func(map[string]string) bool) (*ObjectTree, error)
DiscoverDPUVPCs returns a tree of objects representing the DPUVPC status.
func DiscoverStorage ¶
func DiscoverStorage(ctx context.Context, tree *ObjectTree, scope objectScope, dpfOperatorConfig *operatorv1.DPFOperatorConfig, _ func(map[string]string) bool) (*ObjectTree, error)
DiscoverStorage returns a tree of objects representing the storage resources status.
func NewObjectTree ¶
func NewObjectTree(root client.Object, options ObjectTreeOptions) *ObjectTree
NewObjectTree creates a new object tree with the given root and options. Copy from: https://github.com/kubernetes-sigs/cluster-api/blob/release-1.9/cmd/clusterctl/client/tree/tree.go#L73
func (ObjectTree) Add ¶
func (od ObjectTree) Add(parent, obj client.Object, opts ...AddObjectOption) (added bool, visible bool)
Add a object to the object tree. Adoption from: https://github.com/kubernetes-sigs/cluster-api/blob/release-1.9/cmd/clusterctl/client/tree/tree.go#L89
func (ObjectTree) AddMultipleWithHeader ¶
func (od ObjectTree) AddMultipleWithHeader(parent client.Object, objs []client.Object, headerName string, opts ...AddObjectOption)
func (ObjectTree) GetObject ¶
func (od ObjectTree) GetObject(id types.UID) client.Object
GetObject returns the object with the given uid. Copy from: https://github.com/kubernetes-sigs/cluster-api/blob/release-1.9/cmd/clusterctl/client/tree/tree.go#L250
func (ObjectTree) GetObjectsByParent ¶
func (od ObjectTree) GetObjectsByParent(id types.UID) []client.Object
GetObjectsByParent returns all the dependant objects for the given uid. Copy from: https://github.com/kubernetes-sigs/cluster-api/blob/release-1.9/cmd/clusterctl/client/tree/tree.go#L259
func (ObjectTree) GetParent ¶
func (od ObjectTree) GetParent(id types.UID) client.Object
GetParent returns parent of an object.
func (ObjectTree) GetRoot ¶
func (od ObjectTree) GetRoot() client.Object
GetRoot returns the root of the tree. Copy from: https://github.com/kubernetes-sigs/cluster-api/blob/release-1.9/cmd/clusterctl/client/tree/tree.go#L248
func (ObjectTree) IsObjectWithChild ¶
func (od ObjectTree) IsObjectWithChild(id types.UID) bool
IsObjectWithChild determines if an object has dependants. Copy from: https://github.com/kubernetes-sigs/cluster-api/blob/release-1.9/cmd/clusterctl/client/tree/tree.go#L253
func (ObjectTree) PruneHealthy ¶
func (od ObjectTree) PruneHealthy()
PruneHealthy removes healthy subtrees from the object tree, keeping only resources with non-Ready conditions and their parent chain.
type ObjectTreeOptions ¶
type ObjectTreeOptions struct {
// ShowResources is a list of comma separated kind or kind/name that should be shown in the output.
ShowResources string
// ShowChildResources can be set to true if all child resources should be shown.
ShowChildResources bool
// ShowOtherConditions is a list of comma separated kind or kind/name for which we should add the ShowObjectConditionsAnnotation
// to signal to the presentation layer to show all the conditions for the objects.
ShowOtherConditions string
// ExpandResources is a list of comma separated kind or kind/name that should be expanded in the output.
ExpandResources string
// Grouping groups sibling object in case the ready conditions
// have the same Status, Severity and Reason
Grouping bool
// Colors enables color output
// Default is true
Colors bool
// Output is the output format
// Default is "table"
Output string
// ShowStorage enables showing storage resources (DPUVolume, DPUVolumeAttachment, DPUStoragePolicy, DPUStorageVendor)
// Default is false
ShowStorage bool
// ShowPending enables showing conditions with Reason=Pending and Status=Unknown
// Default is false
ShowPending bool
}
ObjectTreeOptions defines the options for an ObjectTree.
type ZOrder ¶
type ZOrder int
The ZOrder options defines the sorting of child objects when the tree is printed. Objects are sorted by their z-order from highest to lowest, and then by their name in alphaebetical order if the z-order is the same. Objects with no z-order set are assumed to have a default z-order of 0.
func (ZOrder) ApplyToAdd ¶
func (z ZOrder) ApplyToAdd(options *addObjectOptions)
ApplyToAdd applies the given options.