client

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
const MegaByte = 1024 * 1024

MegaByte represents a megabyte.

Variables

View Source
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 AddCat

func AddCat(cat string)

func CleanseNamespace

func CleanseNamespace(ns string) string

CleanseNamespace ensures all ns maps to blank.

func FQN

func FQN(ns, n string) string

FQN returns a fully qualified resource name.

func IsAllNamespace

func IsAllNamespace(ns string) bool

IsAllNamespace returns true if ns == all.

func IsAllNamespaces

func IsAllNamespaces(ns string) bool

IsAllNamespaces returns true if all namespaces, false otherwise.

func IsClusterScoped

func IsClusterScoped(ns string) bool

IsClusterScoped returns true if resource is not namespaced.

func IsClusterWide

func IsClusterWide(ns string) bool

IsClusterWide returns true if ns designates cluster scope, false otherwise.

func IsNamespaced

func IsNamespaced(ns string) bool

IsNamespaced returns true if a specific ns is given.

func ListCats

func ListCats() []string

func Namespaced

func Namespaced(p string) (string, string)

Namespaced converts a resource path to namespace and resource name.

func ToMB

func ToMB(v int64) int64

ToMB converts bytes to megabytes.

func ToPercentage

func ToPercentage(v1, v2 int64) int

ToPercentage computes percentage as string otherwise n/aa.

func ToPercentageStr

func ToPercentageStr(v1, v2 int64) string

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 Cat

type Cat struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Cat) Add

func (c *Cat) Add(cat string)

func (*Cat) All

func (c *Cat) All() []string

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 Error

type Error string

Error represents an error.

func (Error) Error

func (e Error) Error() string

Error returns the error text.

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.

Jump to

Keyboard shortcuts

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