config

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTemplate = `` /* 526-byte string literal not displayed */

DefaultTemplate is the template for new config files

Variables

This section is empty.

Functions

func CreateDefault

func CreateDefault(path string) error

CreateDefault creates a default config file at the given path

func DefaultConfigPath

func DefaultConfigPath() string

func Exists

func Exists(path string) bool

Exists checks if a config file exists at the given path For remote URLs (HTTP/SSH), always returns true (validation will fail if not accessible)

func IsRemote

func IsRemote(path string) bool

IsRemote checks if the path is a remote URL (HTTP or SSH)

func SourcesDirPath added in v0.7.1

func SourcesDirPath() string

SourcesDirPath returns the path to the sources.d directory

func ValidateFile

func ValidateFile(path string) error

ValidateFile validates a config file without loading it fully

Types

type Config

type Config struct {
	Sources []Source `yaml:"sources"`
}

func Load

func Load(path string) (*Config, error)

func (*Config) ExpandPaths

func (c *Config) ExpandPaths()

func (*Config) Save

func (c *Config) Save(path string) error

func (*Config) Validate

func (c *Config) Validate() error

func (*Config) ValidateCredentials

func (c *Config) ValidateCredentials() []string

ValidateCredentials checks that required API tokens are available for non-manual strategies

type FileStrategy

type FileStrategy struct {
	Filename string `yaml:"filename"`
}

type RegexStrategy

type RegexStrategy struct {
	Pattern string `yaml:"pattern"`
}

type RepoEntry added in v0.8.0

type RepoEntry struct {
	Name      string `yaml:"name"`
	LocalPath string `yaml:"local_path,omitempty"`
}

RepoEntry represents a repository in the config. It supports both plain string format ("user/repo") and object format with an optional local_path override.

func RepoEntriesFromNames added in v0.8.0

func RepoEntriesFromNames(names []string) []RepoEntry

RepoEntriesFromNames converts a slice of repo name strings to a RepoEntry slice.

func (RepoEntry) HasCustomLocalPath added in v0.8.0

func (r RepoEntry) HasCustomLocalPath() bool

HasCustomLocalPath returns true if this repo has a custom local_path override.

func (RepoEntry) MarshalYAML added in v0.8.0

func (r RepoEntry) MarshalYAML() (interface{}, error)

MarshalYAML emits a plain string when no LocalPath is set, or an object otherwise.

func (RepoEntry) ResolvedLocalPath added in v0.8.0

func (r RepoEntry) ResolvedLocalPath(sourceLocalPath string) string

ResolvedLocalPath returns the effective local path for this repo. If LocalPath is set, it returns that; otherwise filepath.Join(sourceLocalPath, baseName).

func (*RepoEntry) UnmarshalYAML added in v0.8.0

func (r *RepoEntry) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML allows RepoEntry to be unmarshaled from either a plain string or a mapping with name and local_path fields.

type SSHOptions

type SSHOptions struct {
	Port       int    `yaml:"port,omitempty"`
	PrivateKey string `yaml:"private_key,omitempty"`
	Submodules bool   `yaml:"submodules,omitempty"`
}

type Source

type Source struct {
	Name          string        `yaml:"name"`
	Source        string        `yaml:"source"`
	Strategy      Strategy      `yaml:"strategy"`
	Type          string        `yaml:"type,omitempty"` // "github", "gitea", "bitbucket", or auto-detect from host
	FileStrategy  FileStrategy  `yaml:"file_strategy,omitempty"`
	RegexStrategy RegexStrategy `yaml:"regex_strategy,omitempty"`
	LocalPath     string        `yaml:"local_path"`
	SSHOptions    SSHOptions    `yaml:"ssh_options,omitempty"`
	PrivateKey    string        `yaml:"private_key,omitempty"` // deprecated: use ssh_options.private_key
	Branch        string        `yaml:"branch,omitempty"`
	Repos         []RepoEntry   `yaml:"repos,omitempty"`
}

func (*Source) GetBranch

func (s *Source) GetBranch() string

GetBranch returns the configured branch, or empty string to use remote default

func (*Source) GetConnectorType

func (s *Source) GetConnectorType() connector.ConnectorType

GetConnectorType returns the connector type for this source

func (*Source) GetHost

func (s *Source) GetHost() string

GetHost extracts the host from the source field

func (*Source) GetPrivateKey

func (s *Source) GetPrivateKey() string

GetPrivateKey returns the SSH private key path, checking both locations

func (*Source) GetRepoURL

func (s *Source) GetRepoURL(repo string) string

func (*Source) GetUserOrOrg

func (s *Source) GetUserOrOrg() string

GetUserOrOrg extracts the user/org from the source field

type Strategy

type Strategy string
const (
	StrategyManual Strategy = "manual"
	StrategyAll    Strategy = "all"
	StrategyFile   Strategy = "file"
	StrategyRegex  Strategy = "regex"
)

Jump to

Keyboard shortcuts

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