Documentation ¶
Index ¶
- Constants
- Variables
- func AccessModeToString(accessModeArray []corev1.PersistentVolumeAccessMode) string
- func CheckErr(err error, handleErr func(string))
- func CheckError(err error)
- func ColorStringOnStatus(stringToColor string) string
- func ColorText(s string, c Color) string
- func ConvertToIBytes(value string) string
- func Duration(d time.Duration) string
- func Fatal(msg string)
- func GetAvailableCapacity(total string, used string) string
- func GetCasType(v1PV *corev1.PersistentVolume, v1SC *v1.StorageClass) string
- func GetCasTypeFromPV(v1PV *corev1.PersistentVolume) string
- func GetCasTypeFromSC(v1SC *v1.StorageClass) string
- func GetReadyContainers(containers []corev1.ContainerStatus) string
- func GetUsedPercentage(total string, used string) float64
- func HandleEmptyTableError(resource string, ns string, casType string) error
- func IsValidCasType(casType string) bool
- func PrintByTemplate(templateName string, resourceTemplate string, resource interface{}) error
- func PromptToStartAgain(label string, defaultOption bool) bool
- func TablePrinter(columns []metav1.TableColumnDefinition, rows []metav1.TableRow, ...)
- func TemplatePrinter(template string, obj runtime.Object)
- type Color
- type ComponentData
- type Key
- type LVMPVCInfo
- type LVMVolDesc
- type LocalHostPathVolInfo
- type MapOptions
- type PVCInfo
- type ReturnType
- type Volume
- type VolumeInfo
- type ZFSPVCInfo
- type ZFSVolDesc
Constants ¶
const ( // OpenEBSCasTypeKey present in label of PV OpenEBSCasTypeKey = "openebs.io/cas-type" // Unknown to be retuned when cas type is not known Unknown = "unknown" // OpenEBSCasTypeKeySc present in parameter of SC OpenEBSCasTypeKeySc = "cas-type" // ZFSCasType cas type name ZFSCasType = "localpv-zfs" // LVMCasType cas type name LVMCasType = "localpv-lvm" // LocalPvHostpathCasType cas type name LocalPvHostpathCasType = "localpv-hostpath" // LocalHostpathCasLabel cas-type label in dynamic-localpv-provisioner LocalHostpathCasLabel = "local-hostpath" // StorageKey key present in pvc status.capacity StorageKey = "storage" // NotAvailable shows something is missing, could be a component, // unknown version, or some other unknowns NotAvailable = "N/A" )
const ( // ZFSCSIDriver is the name of the ZFS localpv CSI driver ZFSCSIDriver = "zfs.csi.openebs.io" // LocalPVLVMCSIDriver is the name of the LVM LocalPV CSI driver // NOTE: This might also mean local-hostpath, local-device or zfs-localpv later. LocalPVLVMCSIDriver = "local.csi.openebs.io" )
const ( // LVMLocalPVcsiControllerLabelValue is the label value of CSI controller STS & pod LVMLocalPVcsiControllerLabelValue = "openebs-lvm-controller" // ZFSLocalPVcsiControllerLabelValue is the label value of CSI controller STS & pod ZFSLocalPVcsiControllerLabelValue = "openebs-zfs-controller" )
Constant CSI component-name label values
const ( // LVMComponentNames for the lvm control plane components LVMComponentNames = "openebs-lvm-controller,openebs-lvm-node" // ZFSComponentNames for the zfs control plane components ZFSComponentNames = "openebs-zfs-controller,openebs-zfs-node" // HostpathComponentNames for the hostpath control plane components HostpathComponentNames = "openebs-localpv-provisioner" )
const ( // List If we want the return type as a list List ReturnType = "list" // Map If we want the return type as a map Map ReturnType = "map" // Name key if we want the keys to be made on name Name Key = "name" // Label key if want to make the keys on labels Label Key = "label" )
Variables ¶
var ( // CasTypeAndComponentNameMap stores the component name of the corresponding cas type CasTypeAndComponentNameMap = map[string]string{ LVMCasType: LVMLocalPVcsiControllerLabelValue, ZFSCasType: ZFSLocalPVcsiControllerLabelValue, LocalPvHostpathCasType: HostpathComponentNames, } // ComponentNameToCasTypeMap is a reverse map of CasTypeAndComponentNameMap ComponentNameToCasTypeMap = map[string]string{ LVMLocalPVcsiControllerLabelValue: LVMCasType, ZFSLocalPVcsiControllerLabelValue: ZFSCasType, HostpathComponentNames: LocalPvHostpathCasType, } // ProvsionerAndCasTypeMap stores the cas type name of the corresponding provisioner ProvsionerAndCasTypeMap = map[string]string{ LocalPVLVMCSIDriver: LVMCasType, ZFSCSIDriver: ZFSCasType, } // CasTypeToCSIProvisionerMap stores the provisioner of corresponding cas-types CasTypeToCSIProvisionerMap = map[string]string{ LVMCasType: LocalPVLVMCSIDriver, ZFSCasType: ZFSCSIDriver, } // CasTypeToComponentNamesMap stores the names of the control-plane components of each cas-types. // To show statuses of new CasTypes, please update this map. CasTypeToComponentNamesMap = map[string]string{ LocalPvHostpathCasType: HostpathComponentNames, ZFSCasType: ZFSComponentNames, LVMCasType: LVMComponentNames, } // VolumeListColumnDefinations stores the Table headers for Volume Details VolumeListColumnDefinations = []metav1.TableColumnDefinition{ {Name: "Namespace", Type: "string"}, {Name: "Name", Type: "string"}, {Name: "Status", Type: "string"}, {Name: "Version", Type: "string"}, {Name: "Capacity", Type: "string"}, {Name: "Storage Class", Type: "string"}, {Name: "Attached", Type: "string"}, {Name: "Access Mode", Type: "string"}, {Name: "Attached Node", Type: "string"}, } // LVMvolgroupListColumnDefinitions stores the table headers for listing lvm vg-group when displayed as tree LVMvolgroupListColumnDefinitions = []metav1.TableColumnDefinition{ {Name: "Name", Type: "string"}, {Name: "FreeSize", Type: "string"}, {Name: "TotalSize", Type: "string"}, } // ZFSPoolListColumnDefinitions stores the table headers for listing zfs pools when displayed as tree ZFSPoolListColumnDefinitions = []metav1.TableColumnDefinition{ {Name: "Name", Type: "string"}, {Name: "FreeSize", Type: "string"}, } VersionColumnDefinition = []metav1.TableColumnDefinition{ {Name: "Component", Type: "string"}, {Name: "Version", Type: "string"}, } // ClusterInfoColumnDefinitions stores the Table headers for Cluster-Info details ClusterInfoColumnDefinitions = []metav1.TableColumnDefinition{ {Name: "Cas-Type", Type: "string"}, {Name: "Namespace", Type: "string"}, {Name: "Version", Type: "string"}, {Name: "Working", Type: "string"}, {Name: "Status", Type: "string"}, } )
var Kubeconfig string
Functions ¶
func AccessModeToString ¶
func AccessModeToString(accessModeArray []corev1.PersistentVolumeAccessMode) string
AccessModeToString Flattens the arrat of AccessModes and returns a string fit to display in the output
func CheckError ¶
func CheckError(err error)
CheckError prints err to stderr and exits with code 1 if err is not nil. Otherwise, it is a no-op.
func ColorStringOnStatus ¶ added in v0.3.0
ColorStringOnStatus is used for coloring the strings based on statuses
func ConvertToIBytes ¶
ConvertToIBytes humanizes all the passed units to IBytes format
func Duration ¶
Duration return the time.Duration in no.of days,hour, mins, seconds format. The number of terms to be shown can be increased or decreased using maxTerms constant.
func Fatal ¶
func Fatal(msg string)
Fatal prints the message (if provided) and then exits. If V(2) or greater, klog.Fatal is invoked for extended information.
func GetAvailableCapacity ¶ added in v0.3.0
GetAvailableCapacity returns the available capacity irrespective of units
func GetCasType ¶
func GetCasType(v1PV *corev1.PersistentVolume, v1SC *v1.StorageClass) string
GetCasType from the v1pv and v1sc, this is a fallback checker method, it checks both the resource only if the castype is not found.
func GetCasTypeFromPV ¶
func GetCasTypeFromPV(v1PV *corev1.PersistentVolume) string
GetCasTypeFromPV from the passed PersistentVolume or the Stora
func GetCasTypeFromSC ¶
func GetCasTypeFromSC(v1SC *v1.StorageClass) string
GetCasTypeFromSC by passing the storage class
func GetReadyContainers ¶
func GetReadyContainers(containers []corev1.ContainerStatus) string
GetReadyContainers to show the number of ready vs total containers of pod i.e 2/3
func GetUsedPercentage ¶ added in v0.3.0
GetUsedPercentage returns the usage percentage irrespective of units
func HandleEmptyTableError ¶ added in v0.4.0
HandleEmptyTableError handles error when resources or set of resources are not found
func IsValidCasType ¶ added in v0.4.0
IsValidCasType to return true if the casType is supported
func PrintByTemplate ¶
PrintByTemplate of the provided template and resource
func PromptToStartAgain ¶ added in v0.5.0
PromptToStartAgain opens prompt and waits for the user for response
func TablePrinter ¶
func TablePrinter(columns []metav1.TableColumnDefinition, rows []metav1.TableRow, options printers.PrintOptions)
TablePrinter uses cli-runtime TablePrinter to create a similar UI for the ctl
func TemplatePrinter ¶
TemplatePrinter uses cli-runtime TemplatePrinter to print by template without extra type
Types ¶
type ComponentData ¶ added in v0.4.0
ComponentData stores the data for each component of an engine
type Key ¶
type Key string
Key defines what should be the key if we create a map, i.e. Label or Name
type LVMPVCInfo ¶ added in v0.4.0
type LVMPVCInfo struct { Name string Namespace string CasType string BoundVolume string StorageClassName string Size string PVCStatus corev1.PersistentVolumeClaimPhase MountPods string }
LVMPVCInfo struct will have all the details we want to give in the output for describe pvc details section for lvm pvc
type LVMVolDesc ¶ added in v0.3.0
type LVMVolDesc struct { Name string Namespace string AccessMode string CSIDriver string Capacity string PVC string VolumePhase corev1.PersistentVolumePhase StorageClass string Version string Status string VolumeGroup string ThinProvisioned string NodeID string }
LVMVolDesc is the output helper for LVMVolDesc
type LocalHostPathVolInfo ¶ added in v0.4.0
type LocalHostPathVolInfo struct { VolumeInfo Path string ReclaimPolicy string CasType string }
type MapOptions ¶
MapOptions struct to get the resources as Map with the provided options Key defines what to use as a key, ex:- name, label, currently these two are supported, add more according to need. LabelKey defines which Label to use as key.
type PVCInfo ¶
type PVCInfo struct { Name string Namespace string CasType string BoundVolume string StorageClassName string Size string PVStatus corev1.PersistentVolumePhase MountPods string }
PVCInfo struct will have all the details we want to give in the output for describe pvc details section for generic pvc
type ReturnType ¶
type ReturnType string
ReturnType defines in which format the object needs to be returned i.e. List or Map
type Volume ¶
type Volume struct { // AccessModes contains all ways the volume can be mounted AccessMode string // Attachment status of the PV and it's claim AttachementStatus string // Represents the actual capacity of the underlying volume. Capacity string Name string //Namespace defines the space within each name must be unique. // An empty namespace is equivalent to the "default" namespace Namespace string Node string // Name of the PVClaim of the underlying Persistent Volume PVC string // Name of StorageClass to which this persistent volume belongs. StorageClass string // version of the spec used to create the volumes Version string }
Volume struct will have all the details we want to give in the output for openebsctl commands
type VolumeInfo ¶
type VolumeInfo struct { AccessMode string // Capacity of the underlying PV Capacity string // Name of the volume & Namespace on which it exists Name string PVC string // Phase indicates if a volume is available, bound to a claim, or released // by a claim. VolumePhase corev1.PersistentVolumePhase // Name of StorageClass to which this persistent volume belongs. StorageClass string Size string }
VolumeInfo struct will have all the details we want to give in the output for openebsctl command volume describe
type ZFSPVCInfo ¶ added in v0.4.0
type ZFSPVCInfo struct { Name string Namespace string CasType string BoundVolume string StorageClassName string Size string PVCStatus corev1.PersistentVolumeClaimPhase MountPods string }
ZFSPVCInfo struct will have all the details we want to give in the output for describe pvc details section for zfs pvc
type ZFSVolDesc ¶ added in v0.3.0
type ZFSVolDesc struct { Name string Namespace string AccessMode string CSIDriver string Capacity string PVC string VolumePhase corev1.PersistentVolumePhase StorageClass string Version string Status string VolumeType string PoolName string FileSystem string Compression string Dedup string NodeID string Recordsize string }
ZFSVolDesc is the output helper for ZfsVolDesc