config

package
v0.0.0-...-57fe098 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package config parses, validates and normalizes configuration files.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultDirectory is the standard location for Grit configuration files.
	DefaultDirectory = filepath.Join("~", ".config", "grit")

	// DefaultClonesDirectory is the default path in which grit stores local
	// clones of remote repositories.
	DefaultClonesDirectory = filepath.Join("~", "grit")
)

Functions

This section is empty.

Types

type Clones

type Clones struct {
	// Dir is the path to the directory in which local clones are kept.
	Dir string
}

Clones is the configuration that controls how Grit stores local clones of remote repositories.

type Config

type Config struct {
	// Daemon is the configuration of the Grit daemon.
	Daemon Daemon

	// Sources is the set of repository sources from which repositories can be
	// cloned.
	Sources []Source
}

Config contains an entire Grit configuration.

func Load

func Load(dir string, reg *DriverRegistry) (Config, error)

Load loads the configuration from all files in the given directory.

If the directory doesn't exist or does not contain any configuration files, then DefaultConfig is returned.

reg is a registry of drivers that can be used within the configuration. It may be nil.

type Daemon

type Daemon struct {
	// Socket is the path of the Unix socket used for communication between
	// the Grit CLI and the Grit daemon (via gRPC).
	Socket string
}

Daemon holds the configuration for the Grit daemon.

type DriverRegistry

type DriverRegistry struct {
	Parent *DriverRegistry
	// contains filtered or unexported fields
}

DriverRegistry is a collection of driver implementations that are available to the configuration.

func (*DriverRegistry) RegisterSourceDriver

func (r *DriverRegistry) RegisterSourceDriver(alias string, reg sourcedriver.Registration)

RegisterSourceDriver adds a source driver to the registry.

func (*DriverRegistry) RegisterVCSDriver

func (r *DriverRegistry) RegisterVCSDriver(alias string, reg vcsdriver.Registration)

RegisterVCSDriver adds a VCS driver to the registry.

func (*DriverRegistry) SourceDriverAliases

func (r *DriverRegistry) SourceDriverAliases() []string

SourceDriverAliases returns a sorted slice containing the aliases of all registered source drivers.

func (*DriverRegistry) SourceDriverByAlias

func (r *DriverRegistry) SourceDriverByAlias(alias string) (sourcedriver.Registration, bool)

SourceDriverByAlias returns the source driver with the given alias.

func (*DriverRegistry) SourceDrivers

func (r *DriverRegistry) SourceDrivers() map[string]sourcedriver.Registration

SourceDrivers returns all of the registered source drivers.

func (*DriverRegistry) VCSDriverAliases

func (r *DriverRegistry) VCSDriverAliases() []string

VCSDriverAliases returns a sorted slice containing the aliases of all registered VCS drivers.

func (*DriverRegistry) VCSDriverByAlias

func (r *DriverRegistry) VCSDriverByAlias(alias string) (vcsdriver.Registration, bool)

VCSDriverByAlias returns the VCS driver with the given alias.

func (*DriverRegistry) VCSDrivers

func (r *DriverRegistry) VCSDrivers() map[string]vcsdriver.Registration

VCSDrivers returns all of the registered vcs drivers.

type Source

type Source struct {
	// Name is a short identifier for the source. Each source in the
	// configuration has a unique name. Names are case-insensitive.
	Name string

	// Enabled is true if the source is enabled. Disabled sources are not used
	// when searching for repositories to be cloned.
	Enabled bool

	// Clones is the configuration that controls how Grit stores local
	// repository clones for this source.
	Clones Clones

	// Driver contains driver-specific configuration for this source.
	Driver sourcedriver.Config
}

Source is the configuration for a source of repositories.

Jump to

Keyboard shortcuts

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