util

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package util provides utility functions for the application.

Index

Constants

View Source
const (
	// NamespaceAll is a special value that can be used to specify that all secrets from all
	// namespaces should be used.
	NamespaceAll = apiV1.NamespaceAll

	// SecretAll is a special value that can be used to specify that all secrets from the specified
	// namespace should be used.
	SecretAll = "<all>"
)

Variables

This section is empty.

Functions

func ClientFromFlags

func ClientFromFlags(flags *genericclioptions.ConfigFlags) (kubernetes.Interface, error)

ClientFromFlags creates a Kubernetes client from the flags passed to the CLI.

func DecodeBase64 added in v0.4.0

func DecodeBase64(s string) ([]byte, error)

DecodeBase64 decodes a base64 encoded string, returning the decoded bytes or an error if the string could not be decoded.

func GetNamespace

func GetNamespace(flags *genericclioptions.ConfigFlags, allNamespaces bool) string

GetNamespace returns the namespace to use for the command. If allNamespaces is true, the namespace is set to metaV1.NamespaceAll. Otherwise, the namespace is set from the context or value of the --namespace flag.

func HumanDuration

func HumanDuration(d time.Duration) string

HumanDuration returns a human readable string representing the given duration.

func HumanDurationComparedToNow

func HumanDurationComparedToNow(t time.Time) string

HumanDurationComparedToNow returns a human readable string representing the duration between the given time and now. Always returns a positive duration.

func HumanDurationUntilNow

func HumanDurationUntilNow(t time.Time) string

HumanDurationUntilNow returns a human readable string representing the duration between the given time and now.

func ReadFile added in v0.4.0

func ReadFile(path string) ([]byte, error)

ReadFile reads the file at the given path and returns the contents of the file or an error if the file could not be read.

func SetupLogging

func SetupLogging(out io.Writer, withDebug bool) error

SetupLogging sets up logging for the application, to be used in the root command preRun hook.

func ShortHumanDuration

func ShortHumanDuration(d time.Duration) string

ShortHumanDuration returns a short human readable string representing the given duration.

func ShortHumanDurationComparedToNow

func ShortHumanDurationComparedToNow(t time.Time) string

ShortHumanDurationComparedToNow returns a short human readable string representing the duration between the given time and now. Always returns a positive duration.

func ShortHumanDurationUntilNow

func ShortHumanDurationUntilNow(t time.Time) string

ShortHumanDurationUntilNow returns a short human readable string representing the duration between the given time and now.

func StringSliceToCommaSeparatedString

func StringSliceToCommaSeparatedString(slice []string) string

StringSliceToCommaSeparatedString returns a normalized string representation of a string slice separated by commas and spaces, suitable for use in CLI flag usage strings, e.g. "one, two, three".

func ValidateSortOptions added in v0.4.0

func ValidateSortOptions(validSortOptions, sortOptions []string) error

ValidateSortOptions validates the specified sort options to ensure that they are valid.

Types

This section is empty.

Jump to

Keyboard shortcuts

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