Documentation
¶
Index ¶
- func AggregateIpsToRanges(ips []string) ([]string, error)
- func AreMapsEqual[K comparable, V comparable](a, b map[K]V) bool
- func BoolToShellString(b bool) string
- func CheckTolerations(taints []corev1.Taint, tolerations []corev1.Toleration, ignoreTaints []string) bool
- func ConvertToUnstructured[T runtime.Object](obj T) (*unstructured.Unstructured, error)
- func ExpandIpRanges(ipRanges []string) ([]string, error)
- func FileExists(filename string) bool
- func GeneratePassword(length int) string
- func GetHash(s string, n int) string
- func GetKubeField(obj *unstructured.Unstructured, fieldPath string) (interface{}, error)
- func GetKubeFieldValue[T any](obj *unstructured.Unstructured, fieldPath string) (T, error)
- func GetKubeObjectFieldValue[T any, K runtime.Object](obj K, fieldPath string) (T, error)
- func GetKubernetesVersion(restConfig *rest.Config) (string, error)
- func GetMinValue(a, b int) int
- func GetNonZeroOrDefault(val, defaultVal int) int
- func GetOperatorDeployment(ctx context.Context, k8sClient crclient.Client) (*appsv1.Deployment, error)
- func GetPodNamespace() (string, error)
- func HashStruct(s any) (string, error)
- func HumanReadableIops(iops float64) string
- func HumanReadableSize(bytes int64) string
- func HumanReadableThroughput(bytesPerSecond float64) string
- func Int32Ref(i int32) *int32
- func IsEqualConfigMapData(cm1, cm2 *v1.ConfigMap) bool
- func IsIpv6(ip string) bool
- func MapMissingItems(originalMap, newMap map[string]string) map[string]string
- func MapOrdered[K cmp.Ordered, V any](m map[K]V) iter.Seq2[K, V]
- func MergeMaps(originalMap, newMap map[string]string) map[string]string
- func NodeSelectorMatchesNode(nodeSelector map[string]string, node *v1.Node) bool
- func RemoveKeysStartingWithPrefix(originalMap map[string]string, prefix string) map[string]string
- func SanitizeK8sName(name string) string
- func SendGetRequest(ctx context.Context, url string, options RequestOptions) (*http.Response, error)
- func SendJsonRequest(ctx context.Context, url string, jsonData []byte, options RequestOptions) (*http.Response, error)
- func Shuffle[T any](slice []T)
- func SliceEquals[T comparable](a, b []T) bool
- func StringPtrOrDefault(ptr *string, defaultValue string) string
- func TolerationsEqual(a, b corev1.Toleration) bool
- func TolerationsEqualExceptSeconds(a, b corev1.Toleration) bool
- type ConfigurationError
- type Exec
- func NewExecInPod(restClient rest.Interface, cfg *rest.Config, pod *v1.Pod) (Exec, error)
- func NewExecInPodByName(restClient rest.Interface, cfg *rest.Config, pod *v1.Pod, containerName string, ...) (Exec, error)
- func NewExecInPodWithTimeout(restClient rest.Interface, cfg *rest.Config, pod *v1.Pod, ...) (Exec, error)
- func NewExecWithConfig(restClient rest.Interface, cfg *rest.Config, pod types.NamespacedName, ...) (Exec, error)
- type HashableMap
- type PodExec
- func (e *PodExec) Exec(ctx context.Context, command []string) (stdout, stderr bytes.Buffer, err error)
- func (e *PodExec) ExecNamed(ctx context.Context, name string, command []string) (stdout, stderr bytes.Buffer, err error)
- func (e *PodExec) ExecSensitive(ctx context.Context, name string, command []string) (stdout, stderr bytes.Buffer, err error)
- type RequestOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AggregateIpsToRanges ¶ added in v1.9.0
AggregateIpsToRanges converts a list of individual IPs into ranges to reduce API calls. Examples:
- IPv4: ["10.200.1.200", "10.200.1.201", "10.200.1.202"] -> ["10.200.1.200-202"]
- IPv6: ["2001:db8::1", "2001:db8::2", "2001:db8::3"] -> ["2001:db8::1-2001:db8::3"]
Uses net.ParseIP for validation and supports both IPv4 and IPv6.
func AreMapsEqual ¶ added in v1.7.0
func AreMapsEqual[K comparable, V comparable](a, b map[K]V) bool
func BoolToShellString ¶
func CheckTolerations ¶
func CheckTolerations(taints []corev1.Taint, tolerations []corev1.Toleration, ignoreTaints []string) bool
CheckTolerations Check if the given taints can be tolerated by the given tolerations.
func ConvertToUnstructured ¶
func ConvertToUnstructured[T runtime.Object](obj T) (*unstructured.Unstructured, error)
ConvertToUnstructured converts any typed object (e.g. corev1.Node, corev1.Pod) to an unstructured.Unstructured.
func ExpandIpRanges ¶ added in v1.9.0
ExpandIpRanges expands IP range strings into individual IP addresses. Supports multiple formats:
- Single IP: "10.200.1.200"
- Full range: "10.200.1.200-10.200.1.203"
- Short form (IPv4 only): "10.200.1.200-203"
- IPv6 ranges: "2001:db8::1-2001:db8::4"
Uses net.ParseIP for robust validation and supports both IPv4 and IPv6.
func FileExists ¶
func GeneratePassword ¶
func GetKubeField ¶
func GetKubeField(obj *unstructured.Unstructured, fieldPath string) (interface{}, error)
func GetKubeFieldValue ¶
func GetKubeFieldValue[T any](obj *unstructured.Unstructured, fieldPath string) (T, error)
GetKubeFieldValue converts the retrieved field to any specified type.
func GetKubeObjectFieldValue ¶
GetKubeObjectFieldValue combines conversion and field extraction. It accepts any runtime.Object (like corev1.Node or corev1.Pod) and returns the field value of the specified type.
func GetKubernetesVersion ¶ added in v1.8.2
func GetMinValue ¶
func GetNonZeroOrDefault ¶ added in v1.11.0
func GetOperatorDeployment ¶ added in v1.8.3
func GetPodNamespace ¶
func HashStruct ¶
HashStruct generates a hash of a struct NOTE: This function returns an error if the struct contains maps. For structs with maps, use HashableMap instead.
func HumanReadableIops ¶
func HumanReadableSize ¶
HumanReadableSize converts a size in bytes to a human-readable string with appropriate size units (B, KiB, MiB, GiB, TiB)
func HumanReadableThroughput ¶
func IsEqualConfigMapData ¶
func MapMissingItems ¶
MapMissingItems returns a map containing the items that are in the newMap but not in the originalMap
func NodeSelectorMatchesNode ¶
func RemoveKeysStartingWithPrefix ¶ added in v1.10.1
func SanitizeK8sName ¶ added in v1.10.3
SanitizeK8sName replaces characters not allowed in DNS-1035 labels (dots) with hyphens.
func SendGetRequest ¶
func SendJsonRequest ¶
func Shuffle ¶
func Shuffle[T any](slice []T)
Shuffle shuffles any slice in place using Go generics.
func SliceEquals ¶
func SliceEquals[T comparable](a, b []T) bool
func StringPtrOrDefault ¶ added in v1.9.0
StringPtrOrDefault returns the default value if the pointer is nil, otherwise returns the dereferenced value
func TolerationsEqual ¶ added in v1.9.0
func TolerationsEqual(a, b corev1.Toleration) bool
TolerationsEqual checks if two tolerations are equal
func TolerationsEqualExceptSeconds ¶ added in v1.9.0
func TolerationsEqualExceptSeconds(a, b corev1.Toleration) bool
TolerationsEqualExceptSeconds checks if two tolerations are equal ignoring tolerationSeconds
Types ¶
type ConfigurationError ¶
func (*ConfigurationError) Error ¶
func (e *ConfigurationError) Error() string
type Exec ¶
type Exec interface {
Exec(ctx context.Context, command []string) (stdout, stderr bytes.Buffer, err error)
ExecNamed(ctx context.Context, name string, command []string) (stdout, stderr bytes.Buffer, err error)
ExecSensitive(ctx context.Context, name string, command []string) (stdout, stderr bytes.Buffer, err error)
}
func NewExecInPod ¶
func NewExecInPodByName ¶
func NewExecInPodWithTimeout ¶
type HashableMap ¶
type HashableMap struct {
Entries []hashMapEntry
}
HashableMap is a struct that can replace a map in order to be hashed Create a new HashableMap instance with NewHashableMap from a map[string]string and use it in place of a map
func NewHashableMap ¶
func NewHashableMap(m map[string]string) *HashableMap
func (*HashableMap) Equals ¶
func (hm *HashableMap) Equals(other *HashableMap) bool
Allows to compare two HashableMap instances
type PodExec ¶
type PodExec struct {
RestClient rest.Interface
RestConfig *rest.Config
Pod types.NamespacedName
ContainerName string
// node name is provided for debugging purposes only, it is not used for anything else
NodeName string
// contains filtered or unexported fields
}
func (*PodExec) Exec ¶
func (e *PodExec) Exec(ctx context.Context, command []string) (stdout, stderr bytes.Buffer, err error)
Exec executes a command in a pod. Logs input and output if exit code != 0. Should be used in rare cases as might reveal sensitive data.
type RequestOptions ¶
type RequestOptions struct {
AuthHeader string
}