Documentation
¶
Overview ¶
Package utils provides shared helper functions used across packages for command construction, selector normalization, and small cross-cutting operations.
Helpers in this package are generic and reusable; package-specific workflow policy lives with its domain package.
Index ¶
- Variables
- func BindBoolFlags(cmd *cobra.Command, key, yesName, noName string) error
- func BuildBoolFlags(cmd *cobra.Command, yesName, yesShort, noName, noShort, description string)
- func BuildBoolFlagsDefault(cmd *cobra.Command, yesName, yesShort, noName, noShort string, ...)
- func CheckMutuallyExclusiveFlags(cmd *cobra.Command, flags ...string) error
- func CleanFilter(ctx context.Context, input string) string
- func Cmd(ctx context.Context, repo, command string, arguments ...string) (*exec.Cmd, error)
- func DisplayRepo(ctx context.Context, repo string) string
- func Env(ctx context.Context, repo string) ([]string, error)
- func LookupBranch(ctx context.Context, name string) (string, error)
- func ParseRepo(ctx context.Context, repo string) (host, project, name string)
- func RepoPath(ctx context.Context, repo string) string
- func RepoURL(ctx context.Context, repo string) string
- func ResolveRepoName(repo string) string
- func SplitRepo(ctx context.Context, repo string) (project, name string)
- func ValidateEnumConfig(cmd *cobra.Command, key string, validChoices []string) error
- func ValidateRequiredConfig(ctx context.Context, opts ...string) error
Constants ¶
This section is empty.
Variables ¶
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
BindBoolFlags binds a pair of mutually exclusive boolean flags to the current viper context.
func BuildBoolFlags ¶ added in v0.9.6
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
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
CleanFilter standardizes the formatting of an imput argument by removing all configured signal tokens
func Cmd ¶ added in v0.11.0
Cmd creates an exec.Cmd configured for the given repository context, to facilitate consistent environment and working directory setup.
func DisplayRepo ¶ added in v1.1.0
DisplayRepo returns the user-facing form of a canonical repository name, trimming the default project prefix so that only repositories outside of it remain qualified.
func Env ¶ added in v0.11.0
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 ¶
LookupBranch returns the target branch for the given repository
func ResolveRepoName ¶ added in v0.12.0
ResolveRepoName returns the SCM repository name for the given argument. The special repo argument "." resolves to the current directory basename.
func SplitRepo ¶ added in v1.1.0
SplitRepo returns the project and bare repository name for the given identifier. The special repo argument "." resolves to the current directory basename, which is then resolved against the catalog to determine its project.
func ValidateEnumConfig ¶ added in v0.9.6
ValidateEnumConfig validates that a config value is one of the allowed choices.
Types ¶
This section is empty.