util

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyFlagChanged added in v0.16.0

func AnyFlagChanged(cmd *cobra.Command, flags []string) bool

AnyFlagChanged reports whether any flag in the given list was set by the user.

func ApplyIPs added in v0.10.1

func ApplyIPs(existing []string, changes *IPChanges) []string

ApplyIPs applies IPChanges to an existing IP list and returns a new sorted slice. The input slice is not modified. Removing an IP that does not exist is a silent no-op.

func ApplyLabels added in v0.10.1

func ApplyLabels(existing []*commonv1.KeyValue, changes *LabelChanges) []*commonv1.KeyValue

ApplyLabels applies LabelChanges to an existing label set and returns a new slice sorted by key. The input slice is not modified. Removing a key that does not exist is a silent no-op.

func ApplyListChanges added in v0.30.0

func ApplyListChanges(existing []string, changes *ListChanges) []string

ApplyListChanges applies ListChanges to an existing list and returns a new sorted slice. The input slice is not modified. Removing an entry that does not exist is a silent no-op.

func ConfirmAction

func ConfirmAction(force bool, w io.Writer, prompt string) bool

ConfirmAction prompts the user for confirmation. Returns true if they confirm. If force is true, skips the prompt and returns true. The prompt is written to w.

func ExactArgs

func ExactArgs(n int, usage string) cobra.PositionalArgs

ExactArgs returns a PositionalArgs that requires exactly n args with a descriptive error.

func IsUUID added in v0.16.0

func IsUUID(s string) bool

IsUUID returns true if s is a valid UUID.

func NextCronRun added in v0.30.0

func NextCronRun(cronExpr string) (time.Time, bool)

NextCronRun returns the next time after now (UTC) at which the cron expression fires. It returns false if the expression cannot be parsed.

Types

type IPChanges added in v0.10.1

type IPChanges = ListChanges

IPChanges holds the parsed result of --allowed-ip flags.

func ParseIPs added in v0.10.1

func ParseIPs(raw []string) (*IPChanges, error)

ParseIPs parses a slice of raw --allowed-ip flag values into additions and removals.

Accepted forms:

  • "10.0.0.0/8" -- add the IP CIDR
  • "10.0.0.0/8-" -- remove the IP CIDR (trailing dash)

When the same IP appears multiple times, the last occurrence wins.

type LabelChanges added in v0.10.1

type LabelChanges struct {
	Set    map[string]string
	Remove map[string]bool
}

LabelChanges holds the parsed result of --label flags.

func ParseLabels added in v0.10.1

func ParseLabels(raw []string) (*LabelChanges, error)

ParseLabels parses a slice of raw --label flag values into upserts and removals.

Accepted forms:

  • "key=value" -- upsert (empty value is valid: "key=")
  • "key-" -- remove the label with that key

Returns an error for malformed entries like "key" (no = and no trailing -), "=value" (empty key), or "" (empty string).

When the same key appears multiple times, the last occurrence wins.

type ListChanges added in v0.30.0

type ListChanges struct {
	Add    []string
	Remove map[string]bool
}

ListChanges holds the parsed result of a string-list flag that supports additions and removals (e.g. --allowed-ip, --allowed-origin).

func ParseListChanges added in v0.30.0

func ParseListChanges(flag, item string, raw []string) (*ListChanges, error)

ParseListChanges parses a slice of raw flag values into additions and removals. A value with a trailing '-' marks the entry for removal; any other value is added. flag and item are only used in error messages (e.g. "--allowed-origin", "origin").

When the same entry appears multiple times, the last occurrence wins.

Jump to

Keyboard shortcuts

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