utils

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package utils provides utility functions and helpers for batch-tool.

Index

Constants

This section is empty.

Variables

View Source
var (
	// CatalogProjectLookup is a function type for looking up project from catalog
	CatalogProjectLookup = defaultProjectLookup
	// CatalogBranchLookup is a function type for looking up branch from catalog
	CatalogBranchLookup = defaultBranchLookup
)

functions initialized in catalog package to avoid circular import

Functions

func BindBoolFlags added in v0.9.6

func BindBoolFlags(cmd *cobra.Command, key, yesName, noName string) error

BindBoolFlags binds a pair of mutually exclusive boolean flags to the current viper context.

func BuildBoolFlags added in v0.9.6

func BuildBoolFlags(cmd *cobra.Command, yesName, yesShort, noName, noShort, description string)

BuildBoolFlags adds a pair of mutually exclusive boolean flags to the given command. The "yes" flag enables the feature (default true), and the "no" flag disables it.

func BuildBoolFlagsDefault added in v0.11.0

func BuildBoolFlagsDefault(cmd *cobra.Command, yesName, yesShort, noName, noShort string, defaultValue bool, description string)

BuildBoolFlagsDefault adds a pair of mutually exclusive boolean flags to the given command with a specified default value.

func CheckMutuallyExclusiveFlags added in v0.9.6

func CheckMutuallyExclusiveFlags(cmd *cobra.Command, flags ...string) error

CheckMutuallyExclusiveFlags validates that at most one flag from each set of mutually exclusive flags is set. Each argument is a slice of flag names that are mutually exclusive with each other. Returns an error if more than one flag in any set is explicitly set.

func CleanFilter added in v0.9.6

func CleanFilter(ctx context.Context, input string) string

CleanFilter standardizes the formatting of an imput argument by removing all configured signal tokens

func Cmd added in v0.11.0

func Cmd(ctx context.Context, repo, command string, arguments ...string) (*exec.Cmd, error)

Cmd creates an exec.Cmd configured for the given repository context, to facilitate consistent environment and working directory setup.

func Env added in v0.11.0

func Env(ctx context.Context, repo string) ([]string, error)

Env constructs the environment variables for an Exec call. It processes the CmdEnv config which can contain either: - key=value pairs (used as-is) - file paths to .env files (read and all values added to environment) If a file path is provided but cannot be read, an error is returned.

func LookupBranch

func LookupBranch(ctx context.Context, name string) (string, error)

LookupBranch returns the target branch for the given repository

func ParseRepo

func ParseRepo(ctx context.Context, repo string) (host, project, name string)

ParseRepo splits a repo identifier into its component parts

func RepoPath

func RepoPath(ctx context.Context, repo string) string

RepoPath returns the full repository path for the given name

func RepoURL

func RepoURL(ctx context.Context, repo string) string

RepoURL returns the repository remote url for the given name

func ValidateEnumConfig added in v0.9.6

func ValidateEnumConfig(cmd *cobra.Command, key string, validChoices []string) error

ValidateEnumConfig validates that a config value is one of the allowed choices.

func ValidateRequiredConfig

func ValidateRequiredConfig(ctx context.Context, opts ...string) error

ValidateRequiredConfig checks viper and returns an error if a key isn't set

Types

This section is empty.

Directories

Path Synopsis
Package testing provides utility functions for testing purposes across multiple packages.
Package testing provides utility functions for testing purposes across multiple packages.

Jump to

Keyboard shortcuts

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