Documentation
¶
Index ¶
- Variables
- func DefaultConfFile() string
- func DotToEnvVar(dot string) string
- func EnsureTrailingSlashOnFilePath(s string) string
- func EnsureTrailingSlashOnURL(s string) string
- func EnvVarToDot(env string) string
- func FormatConfigList(values map[string]string, showSecrets bool) string
- func GetAbsolutePathToCloneTo() string
- func GetCloudScmTypeHostnames() string
- func GetOrSetToken()
- func GetRequiredString(key string) string
- func GetTokenFromFile(path string) string
- func GhorgConfDir() string
- func GhorgIgnoreDetected() bool
- func GhorgIgnoreLocation() string
- func GhorgOnlyDetected() bool
- func GhorgOnlyLocation() string
- func GhorgQuiet() bool
- func GhorgReCloneDetected() bool
- func GhorgReCloneLocation() string
- func HomeDir() string
- func IsFilePath(path string) bool
- func ListConfigValues(path string) (map[string]string, error)
- func Load()
- func ReadConfigFile(path string) (map[string]string, error)
- func ReadConfigValue(path, dotKey string) (string, bool, error)
- func Sections() []string
- func UnsetConfigValue(path, dotKey string) error
- func VerifyConfigsSetCorrectly() error
- func VerifyTokenSet() error
- func WriteConfigValue(path, dotKey, value string) error
- func XConfigHomeSet() bool
- type ConfigKey
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoGitHubToken error message when token is not found //nolint:staticcheck // ST1005: User-facing error message, capitalization is intentional ErrNoGitHubToken = errors.New("Could not find a valid github token. GHORG_GITHUB_TOKEN or (--token, -t) flag must be set. Create a personal access token, then set it in your $HOME/.config/ghorg/conf.yaml or use the (--token, -t) flag, see 'GitHub Setup' in README.md") // ErrNoGitLabToken error message when token is not found //nolint:staticcheck // ST1005: User-facing error message, capitalization is intentional ErrNoGitLabToken = errors.New("Could not find a valid gitlab token. GHORG_GITLAB_TOKEN or (--token, -t) flag must be set. Create a token from gitlab then set it in your $HOME/.config/ghorg/conf.yaml or use the (--token, -t) flag, see 'GitLab Setup' in README.md") // ErrNoGiteaToken error message when token is not found //nolint:staticcheck // ST1005: User-facing error message, capitalization is intentional ErrNoGiteaToken = errors.New("Could not find a valid gitea token. GHORG_GITEA_TOKEN or (--token, -t) flag must be set. Create a token from gitea then set it in your $HOME/.config/ghorg/conf.yaml or use the (--token, -t) flag, see 'Gitea Setup' in README.md") // ErrNoSourcehutToken error message when token is not found //nolint:staticcheck // ST1005: User-facing error message, capitalization is intentional ErrNoSourcehutToken = errors.New("Could not find a valid sourcehut token. GHORG_SOURCEHUT_TOKEN or (--token, -t) flag must be set. Create a token from sourcehut then set it in your $HOME/.config/ghorg/conf.yaml or use the (--token, -t) flag, see 'Sourcehut Setup' in README.md") // ErrNoBitbucketUsername error message when no username found //nolint:staticcheck // ST1005: User-facing error message, capitalization is intentional ErrNoBitbucketUsername = errors.New("Could not find bitbucket username. GHORG_BITBUCKET_USERNAME or (--bitbucket-username) must be set to clone repos from bitbucket, see 'BitBucket Setup' in README.md") // ErrNoBitbucketAppPassword error message when no app password found //nolint:staticcheck // ST1005: User-facing error message, capitalization is intentional ErrNoBitbucketAppPassword = errors.New("Could not find a valid bitbucket app password. GHORG_BITBUCKET_APP_PASSWORD or (--token, -t) must be set to clone repos from bitbucket, see 'BitBucket Setup' in README.md") // ErrNoBitbucketCredentials error message when no valid bitbucket credentials are found //nolint:staticcheck // ST1005: User-facing error message, capitalization is intentional ErrNoBitbucketCredentials = errors.New("Could not find valid bitbucket credentials. Set one of: GHORG_BITBUCKET_API_TOKEN (with GHORG_BITBUCKET_API_EMAIL), GHORG_BITBUCKET_APP_PASSWORD (with GHORG_BITBUCKET_USERNAME), or GHORG_BITBUCKET_OAUTH_TOKEN") // ErrIncorrectScmType indicates an unsupported scm type being used ErrIncorrectScmType = errors.New("GHORG_SCM_TYPE or --scm must be one of " + strings.Join(scm.SupportedClients(), ", ")) // ErrIncorrectCloneType indicates an unsupported clone type being used ErrIncorrectCloneType = errors.New("GHORG_CLONE_TYPE or --clone-type must be one of org or user") // ErrIncorrectProtocolType indicates an unsupported protocol type being used ErrIncorrectProtocolType = errors.New("GHORG_CLONE_PROTOCOL or --protocol must be one of https or ssh") // ErrIncorrectGithubUserOptionValue indicates an incorrectly set GHORG_GITHUB_USER_OPTION value ErrIncorrectGithubUserOptionValue = errors.New("GHORG_GITHUB_USER_OPTION or --github-user-option must be one of 'owner', 'member', or 'all' and is only available to be used when GHORG_CLONE_TYPE: user or --clone-type=user is set") )
var AllKeys = []ConfigKey{ { DotNotation: "core.path", EnvVar: "GHORG_ABSOLUTE_PATH_TO_CLONE_TO", DefaultValue: "", Description: "Absolute path to clone repositories into", }, { DotNotation: "core.output-dir", EnvVar: "GHORG_OUTPUT_DIR", DefaultValue: "", Description: "Override the output directory name (defaults to org/user name)", }, { DotNotation: "core.concurrency", EnvVar: "GHORG_CONCURRENCY", DefaultValue: "25", Description: "Maximum number of concurrent clone operations", }, { DotNotation: "core.color", EnvVar: "GHORG_COLOR", DefaultValue: "disabled", Description: "Enable colored output (enabled/disabled)", }, { DotNotation: "core.quiet", EnvVar: "GHORG_QUIET", DefaultValue: "false", IsBool: true, Description: "Emit only critical output", }, { DotNotation: "core.dry-run", EnvVar: "GHORG_DRY_RUN", DefaultValue: "false", IsBool: true, Description: "Show what would be cloned without actually cloning", }, { DotNotation: "core.no-dir-size", EnvVar: "GHORG_NO_DIR_SIZE", DefaultValue: "false", IsBool: true, Description: "Skip directory size calculation after cloning", }, { DotNotation: "scm.type", EnvVar: "GHORG_SCM_TYPE", DefaultValue: "github", Description: "Source code management provider (github, gitlab, gitea, bitbucket, sourcehut)", }, { DotNotation: "scm.base-url", EnvVar: "GHORG_SCM_BASE_URL", DefaultValue: "", Description: "Base URL for self-hosted SCM instances", }, { DotNotation: "clone.protocol", EnvVar: "GHORG_CLONE_PROTOCOL", DefaultValue: "https", Description: "Clone protocol (https or ssh)", }, { DotNotation: "clone.type", EnvVar: "GHORG_CLONE_TYPE", DefaultValue: "org", Description: "Clone target type (org or user)", }, { DotNotation: "clone.branch", EnvVar: "GHORG_BRANCH", DefaultValue: "", Description: "Branch to checkout after cloning", }, { DotNotation: "clone.depth", EnvVar: "GHORG_CLONE_DEPTH", DefaultValue: "", Description: "Shallow clone depth (empty for full clone)", }, { DotNotation: "clone.delay-seconds", EnvVar: "GHORG_CLONE_DELAY_SECONDS", DefaultValue: "0", Description: "Delay in seconds between clone operations (forces concurrency to 1)", }, { DotNotation: "clone.wiki", EnvVar: "GHORG_CLONE_WIKI", DefaultValue: "false", IsBool: true, Description: "Clone wiki repositories", }, { DotNotation: "clone.snippets", EnvVar: "GHORG_CLONE_SNIPPETS", DefaultValue: "false", IsBool: true, Description: "Clone GitLab snippets", }, { DotNotation: "clone.backup", EnvVar: "GHORG_BACKUP", DefaultValue: "false", IsBool: true, Description: "Mirror clone for backup purposes", }, { DotNotation: "clone.no-clean", EnvVar: "GHORG_NO_CLEAN", DefaultValue: "false", IsBool: true, Description: "Skip git clean on existing repositories", }, { DotNotation: "clone.include-submodules", EnvVar: "GHORG_INCLUDE_SUBMODULES", DefaultValue: "false", IsBool: true, Description: "Initialize and update submodules after cloning", }, { DotNotation: "clone.sync-default-branch", EnvVar: "GHORG_SYNC_DEFAULT_BRANCH", DefaultValue: "false", IsBool: true, Description: "Sync local default branch with remote on existing repos", }, { DotNotation: "clone.preserve-dir", EnvVar: "GHORG_PRESERVE_DIRECTORY_STRUCTURE", DefaultValue: "false", IsBool: true, Description: "Preserve GitLab namespace directory structure", }, { DotNotation: "clone.preserve-scm-hostname", EnvVar: "GHORG_PRESERVE_SCM_HOSTNAME", DefaultValue: "false", IsBool: true, Description: "Append SCM hostname to clone path", }, { DotNotation: "clone.protect-local", EnvVar: "GHORG_PROTECT_LOCAL", DefaultValue: "false", IsBool: true, Description: "Skip repos with uncommitted changes or unpushed commits", }, { DotNotation: "auth.no-token", EnvVar: "GHORG_NO_TOKEN", DefaultValue: "false", IsBool: true, Description: "Clone without authentication", }, { DotNotation: "git.filter", EnvVar: "GHORG_GIT_FILTER", DefaultValue: "", Description: "Git filter options (e.g., blob:none for partial clones)", }, { DotNotation: "git.backend", EnvVar: "GHORG_GIT_BACKEND", DefaultValue: "golang", Description: "Git backend: golang (pure Go) or exec (system git)", }, { DotNotation: "filter.skip-archived", EnvVar: "GHORG_SKIP_ARCHIVED", DefaultValue: "false", IsBool: true, Description: "Skip archived repositories", }, { DotNotation: "filter.skip-forks", EnvVar: "GHORG_SKIP_FORKS", DefaultValue: "false", IsBool: true, Description: "Skip forked repositories", }, { DotNotation: "filter.topics", EnvVar: "GHORG_TOPICS", DefaultValue: "", Description: "Comma-separated topic filter", }, { DotNotation: "filter.match-prefix", EnvVar: "GHORG_MATCH_PREFIX", DefaultValue: "", Description: "Include repos matching prefix (comma-separated, case-insensitive)", }, { DotNotation: "filter.exclude-match-prefix", EnvVar: "GHORG_EXCLUDE_MATCH_PREFIX", DefaultValue: "", Description: "Exclude repos matching prefix (comma-separated, case-insensitive)", }, { DotNotation: "filter.match-regex", EnvVar: "GHORG_MATCH_REGEX", DefaultValue: "", Description: "Include repos matching regex pattern", }, { DotNotation: "filter.exclude-match-regex", EnvVar: "GHORG_EXCLUDE_MATCH_REGEX", DefaultValue: "", Description: "Exclude repos matching regex pattern", }, { DotNotation: "filter.ignore-path", EnvVar: "GHORG_IGNORE_PATH", DefaultValue: "", Description: "Path to ghorgignore file", }, { DotNotation: "filter.only-path", EnvVar: "GHORG_ONLY_PATH", DefaultValue: "", Description: "Path to ghorgonly file", }, { DotNotation: "filter.target-repos-path", EnvVar: "GHORG_TARGET_REPOS_PATH", DefaultValue: "", Description: "Path to file listing specific repos to clone", }, { DotNotation: "prune.enabled", EnvVar: "GHORG_PRUNE", DefaultValue: "false", IsBool: true, Description: "Delete local repos not found on remote", }, { DotNotation: "prune.no-confirm", EnvVar: "GHORG_PRUNE_NO_CONFIRM", DefaultValue: "false", IsBool: true, Description: "Skip confirmation when pruning", }, { DotNotation: "prune.untouched", EnvVar: "GHORG_PRUNE_UNTOUCHED", DefaultValue: "false", IsBool: true, Description: "Prune repos that were not cloned or updated", }, { DotNotation: "prune.untouched-no-confirm", EnvVar: "GHORG_PRUNE_UNTOUCHED_NO_CONFIRM", DefaultValue: "false", IsBool: true, Description: "Skip confirmation when pruning untouched repos", }, { DotNotation: "fetch.all", EnvVar: "GHORG_FETCH_ALL", DefaultValue: "false", IsBool: true, Description: "Fetch all remote branches", }, { DotNotation: "fetch.prune", EnvVar: "GHORG_FETCH_PRUNE", DefaultValue: "false", IsBool: true, Description: "Append --prune to fetch (requires fetch.all)", }, { DotNotation: "exit-code.clone-infos", EnvVar: "GHORG_EXIT_CODE_ON_CLONE_INFOS", DefaultValue: "0", Description: "Exit code when clone info messages are present", }, { DotNotation: "exit-code.clone-issues", EnvVar: "GHORG_EXIT_CODE_ON_CLONE_ISSUES", DefaultValue: "1", Description: "Exit code when clone errors occur", }, { DotNotation: "stats.enabled", EnvVar: "GHORG_STATS_ENABLED", DefaultValue: "false", IsBool: true, Description: "Generate a stats CSV file after cloning", }, { DotNotation: "ssh.hostname", EnvVar: "GHORG_SSH_HOSTNAME", DefaultValue: "", Description: "Custom SSH hostname alias for clone URLs", }, { DotNotation: "github.token", EnvVar: "GHORG_GITHUB_TOKEN", DefaultValue: "", IsSecret: true, Description: "GitHub personal access token", }, { DotNotation: "github.token-from-app", EnvVar: "GHORG_GITHUB_TOKEN_FROM_GITHUB_APP", DefaultValue: "false", IsBool: true, Description: "Treat token as a GitHub App token", }, { DotNotation: "github.app-pem-path", EnvVar: "GHORG_GITHUB_APP_PEM_PATH", DefaultValue: "", Description: "Path to GitHub App PEM private key file", }, { DotNotation: "github.app-installation-id", EnvVar: "GHORG_GITHUB_APP_INSTALLATION_ID", DefaultValue: "", Description: "GitHub App installation ID", }, { DotNotation: "github.app-id", EnvVar: "GHORG_GITHUB_APP_ID", DefaultValue: "", Description: "GitHub App application ID", }, { DotNotation: "github.user-option", EnvVar: "GHORG_GITHUB_USER_OPTION", DefaultValue: "owner", Description: "GitHub user repo filter: owner, member, or all", }, { DotNotation: "github.filter-language", EnvVar: "GHORG_GITHUB_FILTER_LANGUAGE", DefaultValue: "", Description: "Filter GitHub repos by language (comma-separated)", }, { DotNotation: "github.user-gists", EnvVar: "GHORG_GITHUB_USER_GISTS", DefaultValue: "false", IsBool: true, Description: "Clone GitHub user gists", }, { DotNotation: "gitlab.token", EnvVar: "GHORG_GITLAB_TOKEN", DefaultValue: "", IsSecret: true, Description: "GitLab personal access token", }, { DotNotation: "gitlab.insecure", EnvVar: "GHORG_INSECURE_GITLAB_CLIENT", DefaultValue: "false", IsBool: true, Description: "Skip TLS verification for GitLab", }, { DotNotation: "gitlab.group-exclude-match-regex", EnvVar: "GHORG_GITLAB_GROUP_EXCLUDE_MATCH_REGEX", DefaultValue: "", Description: "Exclude GitLab groups matching regex", }, { DotNotation: "gitlab.group-match-regex", EnvVar: "GHORG_GITLAB_GROUP_MATCH_REGEX", DefaultValue: "", Description: "Include only GitLab groups matching regex", }, { DotNotation: "bitbucket.app-password", EnvVar: "GHORG_BITBUCKET_APP_PASSWORD", DefaultValue: "", IsSecret: true, Description: "Bitbucket app password", }, { DotNotation: "bitbucket.username", EnvVar: "GHORG_BITBUCKET_USERNAME", DefaultValue: "", Description: "Bitbucket username for app password auth", }, { DotNotation: "bitbucket.oauth-token", EnvVar: "GHORG_BITBUCKET_OAUTH_TOKEN", DefaultValue: "", IsSecret: true, Description: "Bitbucket OAuth token", }, { DotNotation: "bitbucket.api-token", EnvVar: "GHORG_BITBUCKET_API_TOKEN", DefaultValue: "", IsSecret: true, Description: "Bitbucket Cloud API token", }, { DotNotation: "bitbucket.api-email", EnvVar: "GHORG_BITBUCKET_API_EMAIL", DefaultValue: "", Description: "Email associated with Bitbucket API token", }, { DotNotation: "bitbucket.insecure", EnvVar: "GHORG_INSECURE_BITBUCKET_CLIENT", DefaultValue: "false", IsBool: true, Description: "Allow HTTP for Bitbucket Server", }, { DotNotation: "gitea.token", EnvVar: "GHORG_GITEA_TOKEN", DefaultValue: "", IsSecret: true, Description: "Gitea personal access token", }, { DotNotation: "gitea.insecure", EnvVar: "GHORG_INSECURE_GITEA_CLIENT", DefaultValue: "false", IsBool: true, Description: "Allow HTTP for Gitea", }, { DotNotation: "sourcehut.token", EnvVar: "GHORG_SOURCEHUT_TOKEN", DefaultValue: "", IsSecret: true, Description: "Sourcehut personal access token", }, { DotNotation: "sourcehut.insecure", EnvVar: "GHORG_INSECURE_SOURCEHUT_CLIENT", DefaultValue: "false", IsBool: true, Description: "Allow HTTP for Sourcehut", }, { DotNotation: "reclone.path", EnvVar: "GHORG_RECLONE_PATH", DefaultValue: "", Description: "Path to reclone.yaml configuration file", }, { DotNotation: "reclone.quiet", EnvVar: "GHORG_RECLONE_QUIET", DefaultValue: "false", IsBool: true, Description: "Suppress reclone output", }, { DotNotation: "reclone.env-config-only", EnvVar: "GHORG_RECLONE_ENV_CONFIG_ONLY", DefaultValue: "false", IsBool: true, Description: "Use only environment variables for reclone config", }, { DotNotation: "reclone.server-port", EnvVar: "GHORG_RECLONE_SERVER_PORT", DefaultValue: ":8080", Description: "Port for the reclone HTTP server", }, { DotNotation: "reclone.cron-timer-minutes", EnvVar: "GHORG_CRON_TIMER_MINUTES", DefaultValue: "60", Description: "Interval in minutes for cron-based recloning", }, }
AllKeys is the complete registry of configuration keys.
Functions ¶
func DefaultConfFile ¶
func DefaultConfFile() string
func DotToEnvVar ¶ added in v0.1.0
DotToEnvVar converts a dot-notation key to its environment variable name. Returns empty string if the key is not in the registry.
func EnsureTrailingSlashOnFilePath ¶
EnsureTrailingSlashOnFilePath takes a filepath and ensures a single / is appened
func EnsureTrailingSlashOnURL ¶
EnsureTrailingSlashOnURL takes a url and ensures a single / is appened
func EnvVarToDot ¶ added in v0.1.0
EnvVarToDot converts an environment variable name to its dot-notation key. Returns empty string if the env var is not in the registry.
func FormatConfigList ¶ added in v0.1.0
FormatConfigList formats config key-value pairs for display, sorted by key. Secret values are redacted unless showSecrets is true.
func GetAbsolutePathToCloneTo ¶
func GetAbsolutePathToCloneTo() string
func GetCloudScmTypeHostnames ¶
func GetCloudScmTypeHostnames() string
func GetRequiredString ¶
GetRequiredString verifies env is set
func GetTokenFromFile ¶
func GhorgIgnoreDetected ¶
func GhorgIgnoreDetected() bool
GhorgIgnoreDetected returns true if a ghorgignore file exists.
func GhorgIgnoreLocation ¶
func GhorgIgnoreLocation() string
GhorgIgnoreLocation returns the path of users ghorgignore
func GhorgOnlyDetected ¶
func GhorgOnlyDetected() bool
GhorgOnlyDetected returns true if a ghorgonly file exists.
func GhorgOnlyLocation ¶
func GhorgOnlyLocation() string
GhorgOnlyLocation returns the path of users ghorgonly
func GhorgQuiet ¶
func GhorgQuiet() bool
func GhorgReCloneDetected ¶
func GhorgReCloneDetected() bool
GhorgReCloneDetected returns true if a reclone.yaml file exists.
func GhorgReCloneLocation ¶
func GhorgReCloneLocation() string
GhorgReCloneLocation returns the path of users ghorgignore
func IsFilePath ¶
func ListConfigValues ¶ added in v0.1.0
ListConfigValues reads a config file and returns all values mapped to their dot-notation keys. Legacy GHORG_* keys are translated.
func Load ¶
func Load()
Load triggers the configs to load first, not sure if this is actually needed
func ReadConfigFile ¶ added in v0.1.0
ReadConfigFile reads a YAML config file and returns all key-value pairs as dot-notation keys. Supports both the new nested format and legacy flat format.
func ReadConfigValue ¶ added in v0.1.0
ReadConfigValue reads a single dot-notation key from a config file. It checks both nested YAML and legacy GHORG_* flat keys.
func Sections ¶ added in v0.1.0
func Sections() []string
Sections returns a deduplicated, ordered list of all section names.
func UnsetConfigValue ¶ added in v0.1.0
UnsetConfigValue removes a dot-notation key from a YAML config file.
func VerifyConfigsSetCorrectly ¶
func VerifyConfigsSetCorrectly() error
VerifyConfigsSetCorrectly makes sure flags are set to appropriate values
func VerifyTokenSet ¶
func VerifyTokenSet() error
VerifyTokenSet checks to make sure env is set for the correct scm provider
func WriteConfigValue ¶ added in v0.1.0
WriteConfigValue sets a dot-notation key in a YAML config file. Creates the file if it doesn't exist. Uses nested YAML structure.
Types ¶
type ConfigKey ¶ added in v0.1.0
type ConfigKey struct {
// DotNotation is the canonical key name (e.g., "scm.type").
DotNotation string
// EnvVar is the legacy environment variable name (e.g., "GHORG_SCM_TYPE").
EnvVar string
// DefaultValue is the hard-coded default, empty string means no default.
DefaultValue string
// IsBool indicates this key stores a boolean value ("true"/"false").
IsBool bool
// IsSecret indicates this key stores sensitive data (tokens, passwords).
// Secret values are redacted in `ghorg config --list` output.
IsSecret bool
// Description is a short human-readable description of the key.
Description string
}
ConfigKey represents a single configuration key with all its representations.
func LookupByDot ¶ added in v0.1.0
LookupByDot returns the ConfigKey for a dot-notation key, or nil if not found.
func LookupByEnvVar ¶ added in v0.1.0
LookupByEnvVar returns the ConfigKey for an environment variable name, or nil if not found.