Documentation ¶
Overview ¶
Package util provides utility functions for the application.
Index ¶
- Constants
- func ClientFromFlags(flags *genericclioptions.ConfigFlags) (kubernetes.Interface, error)
- func DecodeBase64(s string) ([]byte, error)
- func GetNamespace(flags *genericclioptions.ConfigFlags, allNamespaces bool) string
- func HumanDuration(d time.Duration) string
- func HumanDurationComparedToNow(t time.Time) string
- func HumanDurationUntilNow(t time.Time) string
- func ReadFile(path string) ([]byte, error)
- func SetupLogging(out io.Writer, withDebug bool) error
- func ShortHumanDuration(d time.Duration) string
- func ShortHumanDurationComparedToNow(t time.Time) string
- func ShortHumanDurationUntilNow(t time.Time) string
- func StringSliceToCommaSeparatedString(slice []string) string
- func ValidateSortOptions(validSortOptions, sortOptions []string) error
Constants ¶
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
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 ¶
HumanDuration returns a human readable string representing the given duration.
func HumanDurationComparedToNow ¶
HumanDurationComparedToNow returns a human readable string representing the duration between the given time and now. Always returns a positive duration.
func HumanDurationUntilNow ¶
HumanDurationUntilNow returns a human readable string representing the duration between the given time and now.
func ReadFile ¶ added in v0.4.0
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 ¶
SetupLogging sets up logging for the application, to be used in the root command preRun hook.
func ShortHumanDuration ¶
ShortHumanDuration returns a short human readable string representing the given duration.
func ShortHumanDurationComparedToNow ¶
ShortHumanDurationComparedToNow returns a short human readable string representing the duration between the given time and now. Always returns a positive duration.
func ShortHumanDurationUntilNow ¶
ShortHumanDurationUntilNow returns a short human readable string representing the duration between the given time and now.
func StringSliceToCommaSeparatedString ¶
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
ValidateSortOptions validates the specified sort options to ensure that they are valid.
Types ¶
This section is empty.