utils

package
v1.3.1-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RedBg = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("#FF0000"))
)

Functions

func BuildFilterQuery

func BuildFilterQuery(input string) string

func ComputeDisksArray

func ComputeDisksArray(disks string, numDisks int) ([]string, error)

func ComputeIPsArray

func ComputeIPsArray(ips string, numIPs int) ([]string, error)

func ComputeMountPointsArray

func ComputeMountPointsArray(mountPoints string, numDisks int) ([]string, error)

func ComputeNamesArray

func ComputeNamesArray(names string, numNodes int) []string

func ComputePortsArray

func ComputePortsArray(ports string, numPorts int) ([]int, error)

func Contains

func Contains[T comparable](s []T, e T) bool

func Count

func Count[T any](slice []T, findFn func(cmp T) bool) int

func CreateTar

func CreateTar(output string, src string) error

func ExtractTar

func ExtractTar(r io.Reader, dest string) error

func Find

func Find[T any](slice []T, findFn func(cmp T) bool) (T, bool)

func GenerateKeyPair

func GenerateKeyPair() (ed25519.PublicKey, ed25519.PrivateKey, error)

GenerateKeyPair generates an ed25519 keypair

func GenerateKeyPairFromSeed

func GenerateKeyPairFromSeed(seed []byte) (ed25519.PublicKey, ed25519.PrivateKey, error)

GenerateKeyPairFromSeed generates an ed25519 keypair

func GenerateSecret

func GenerateSecret() (string, error)

func GetOptionalStringFlag

func GetOptionalStringFlag(cmd *cobra.Command, flagName string) (*string, error)

func GetStructSchema

func GetStructSchema(schemaTemplate map[string]interface{}) string

func IsHumanMode

func IsHumanMode() bool

func IsQuietMode

func IsQuietMode() bool

func IsValidFilter

func IsValidFilter(input string) bool

func IsValidIP

func IsValidIP(ip string) bool

func PEMDecodeKeyPair

func PEMDecodeKeyPair(pub []byte, priv []byte) (ed25519.PublicKey, ed25519.PrivateKey, error)

PEMDecodeKeyPair decodes an ed25519 PEM keypair encoded with PKIX and PKCS8 standards

func PEMDecodePrivateKey

func PEMDecodePrivateKey(priv []byte) (ed25519.PrivateKey, error)

PEMDecodePrivateKey decodes an ed25519 PEM encoded with PKCS8 standard

func PEMDecodePublicKey

func PEMDecodePublicKey(pub []byte) (ed25519.PublicKey, error)

PEMDecodePublicKey decodes an ed25519 PEM encoded with PKIX standard

func PEMEncodeKeyPair

func PEMEncodeKeyPair(pubKey ed25519.PublicKey, privKey ed25519.PrivateKey) (pub []byte, priv []byte, err error)

PEMEncodeKeyPair encodes an ed25519 keypair using the common PKIX and PKCS8 standards with a PEM format

func PEMEncodePrivateKey

func PEMEncodePrivateKey(privKey ed25519.PrivateKey) (priv []byte, err error)

PEMEncodePrivateKey encodes an ed25519 private key using the common PKCS8 standard with a PEM format

func PEMEncodePublicKey

func PEMEncodePublicKey(pubKey ed25519.PublicKey) (pub []byte, err error)

PEMEncodePublicKey encodes an ed25519 public key using the common PKIX standard with a PEM format

func PrintCreateSuccess

func PrintCreateSuccess(resourceType, id string)

func PrintDelete

func PrintDelete(s string)

func PrintEmptyLine

func PrintEmptyLine()

func PrintEmptyList

func PrintEmptyList()

func PrintError

func PrintError(err error)

func PrintErrorWithWriter

func PrintErrorWithWriter(writer io.Writer, err error)

func PrintFormattedData

func PrintFormattedData(writer io.Writer, data interface{}, format string)

func PrintHint

func PrintHint(s string)

func PrintInfo

func PrintInfo(s string)

func PrintList

func PrintList(s string)

func PrintNotFound

func PrintNotFound(s string)

func PrintQuiet

func PrintQuiet(writer io.Writer, fields ...string)

func PrintSimpleList

func PrintSimpleList(items []string)

func PrintSmartOutput

func PrintSmartOutput[T any](
	cmd *cobra.Command,
	items []T,
	fieldsFunc func(T) []string,
	config *SmartOutputConfig[T],
) error

func PrintSuccess

func PrintSuccess(s string)

func PrintVerbose

func PrintVerbose(writer io.Writer, data interface{}, noHeaders bool)

func PrintWarn

func PrintWarn(s string)

func SetOutputMode

func SetOutputMode(mode OutputMode)

func SignChallenge

func SignChallenge(
	salt string,
	challenge string,
	password string,
) ([]byte, error)

func StringOrEmpty

func StringOrEmpty(v *string) string

func TimeOrEmpty

func TimeOrEmpty(v *time.Time) string

func ValidateIPsInput

func ValidateIPsInput(ips string, numNodes int) error

func ValidateNamesInput

func ValidateNamesInput(names string, numNodes int) error

func WriteFile

func WriteFile(filename string, data []byte) error

Types

type JSONMap

type JSONMap map[string]interface{}

func JSONMapFromCommand

func JSONMapFromCommand(cmd *cobra.Command, flagName string, validators ...JSONMapValidator) (JSONMap, error)

func NewJSONMapFromString

func NewJSONMapFromString(value string, validators ...JSONMapValidator) (JSONMap, error)

func (*JSONMap) Set

func (j *JSONMap) Set(value string) error

func (*JSONMap) String

func (j *JSONMap) String() string

func (*JSONMap) Type

func (j *JSONMap) Type() string

func (*JSONMap) Validate

func (j *JSONMap) Validate(validators ...JSONMapValidator) error

type JSONMapValidator

type JSONMapValidator func(JSONMap) error

type OutputMode

type OutputMode int
const (
	OutputQuiet OutputMode = iota
	OutputHuman
)

type QueryOperator

type QueryOperator string

type SmartOutputConfig

type SmartOutputConfig[T any] struct {
	SingleResource              bool
	SingleResourceCompactOutput bool
	DefaultOutput               configuration.OutputFormat
}

Jump to

Keyboard shortcuts

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