Documentation
¶
Index ¶
- Constants
- Variables
- func AddCat(cat string)
- func CleanseNamespace(ns string) string
- func FQN(ns, n string) string
- func IsAllNamespace(ns string) bool
- func IsAllNamespaces(ns string) bool
- func IsClusterScoped(ns string) bool
- func IsClusterWide(ns string) bool
- func IsNamespaced(ns string) bool
- func ListCats() []string
- func Namespaced(p string) (string, string)
- func ToMB(v int64) int64
- func ToPercentage(v1, v2 int64) int
- func ToPercentageStr(v1, v2 int64) string
- type Authorizer
- type Cat
- type ClusterMetrics
- type CurrentMetrics
- type Error
- type NodeMetrics
- type NodesMetrics
- type PodMetrics
- type PodsMetrics
Constants ¶
const ( // NA Not available. NA = "n/a" // NamespaceAll designates the fictional all namespace. NamespaceAll = "all" // AllNamespaces designates all namespaces. AllNamespaces = "" // DefaultNamespace designates the default namespace. DefaultNamespace = "default" // ClusterScope designates a resource is not namespaced. ClusterScope = "-" // NotNamespaced designates a non resource namespace. NotNamespaced = "*" // CreateVerb represents create access on a resource. CreateVerb = "create" // UpdateVerb represents an update access on a resource. UpdateVerb = "update" // PatchVerb represents a patch access on a resource. PatchVerb = "patch" // DeleteVerb represents a delete access on a resource. DeleteVerb = "delete" // GetVerb represents a get access on a resource. GetVerb = "get" // ListVerb represents a list access on a resource. ListVerb = "list" // WatchVerb represents a watch access on a resource. WatchVerb = "watch" )
const MegaByte = 1024 * 1024
MegaByte represents a megabyte.
Variables ¶
var ( // GetAccess reads a resource. GetAccess = []string{GetVerb} // ListAccess list resources. ListAccess = []string{ListVerb} // MonitorAccess monitors a collection of resources. MonitorAccess = []string{ListVerb, WatchVerb} // ReadAllAccess represents an all read access to a resource. ReadAllAccess = []string{GetVerb, ListVerb, WatchVerb} )
Functions ¶
func CleanseNamespace ¶
CleanseNamespace ensures all ns maps to blank.
func IsAllNamespaces ¶
IsAllNamespaces returns true if all namespaces, false otherwise.
func IsClusterScoped ¶
IsClusterScoped returns true if resource is not namespaced.
func IsClusterWide ¶
IsClusterWide returns true if ns designates cluster scope, false otherwise.
func IsNamespaced ¶
IsNamespaced returns true if a specific ns is given.
func Namespaced ¶
Namespaced converts a resource path to namespace and resource name.
func ToPercentage ¶
ToPercentage computes percentage as string otherwise n/aa.
func ToPercentageStr ¶
ToPercentageStr computes percentage, but if v2 is 0, it will return NAValue instead of 0.
Types ¶
type Authorizer ¶
type Authorizer interface { // CanI returns true if the user can use these actions for a given resource. CanI(ns, gvr string, verbs []string) (bool, error) }
Authorizer checks what a user can or cannot do to a resource.
type ClusterMetrics ¶
type ClusterMetrics struct {
PercCPU, PercMEM, PercEphemeral int
}
ClusterMetrics summarizes total node metrics as percentages.
type CurrentMetrics ¶
type CurrentMetrics struct {
CurrentCPU, CurrentMEM, CurrentEphemeral int64
}
CurrentMetrics tracks current cpu/mem.
type NodeMetrics ¶
type NodeMetrics struct { CurrentMetrics AllocatableCPU, AllocatableMEM, AllocatableEphemeral int64 AvailableCPU, AvailableMEM, AvailableEphemeral int64 TotalCPU, TotalMEM, TotalEphemeral int64 }
NodeMetrics describes raw node metrics.
type NodesMetrics ¶
type NodesMetrics map[string]NodeMetrics
NodesMetrics tracks usage metrics per nodes.
type PodMetrics ¶
type PodMetrics CurrentMetrics
PodMetrics represent an aggregation of all pod containers metrics.
type PodsMetrics ¶
type PodsMetrics map[string]PodMetrics
PodsMetrics tracks usage metrics per pods.