utils

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EntrySeparator = ";"
	PartSeparator  = ":"
)

Variables

This section is empty.

Functions

func AssertValueProvided

func AssertValueProvided(c *components.Context, fieldName string) error

func ParseDelimitedSlice

func ParseDelimitedSlice(input string) [][]string

ParseDelimitedSlice splits a delimited string into a slice of string slices. Example: input "a:1;b:2" returns [][]string{{"a","1"},{"b","2"}}

func ParseKeyValueString

func ParseKeyValueString(value, separator string) (map[string]string, error)

func ParseListPropertiesFlag

func ParseListPropertiesFlag(propertiesStr string) (map[string][]string, error)

ParseListPropertiesFlag parses a properties string into a map of keys to value slices. Format: "key1=value1[,value2,...];key2=value3[,value4,...]" Examples:

  • "status=rc" -> {"status": ["rc"]}
  • "status=rc,validated" -> {"status": ["rc", "validated"]}
  • "status=rc;deployed_to=staging" -> {"status": ["rc"], "deployed_to": ["staging"]}
  • "old_flag=" -> {"old_flag": []} (clears values)

func ParseMapFlag

func ParseMapFlag(flagValue string) (map[string]string, error)

ParseMapFlag parses a semicolon-separated string of key=value pairs into a map[string]string. Returns an error if any pair does not contain exactly one '='.

func ParseNameVersionPairs

func ParseNameVersionPairs(input string) ([][2]string, error)

ParseNameVersionPairs parses a delimited string (e.g., "name1:version1;name2:version2") into a slice of [2]string pairs. Returns an error if any entry does not have exactly two parts.

func ParseSliceFlag

func ParseSliceFlag(flagValue string) []string

ParseSliceFlag parses a comma-separated string into a slice of strings.

func ServerDetailsByFlags

func ServerDetailsByFlags(ctx *components.Context) (*coreConfig.ServerDetails, error)

func ValidateEnumFlag

func ValidateEnumFlag(flagName, value string, defaultValue string, allowedValues []string) (string, error)

ValidateEnumFlag validates that a flag value is in the list of allowed values. If the value is empty, returns the default value. Otherwise, returns an error if the value is not in the allowed values.

Types

This section is empty.

Jump to

Keyboard shortcuts

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