config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package config provides configuration loading for gitlab-duo-acp. Configuration can be provided via a YAML file and/or environment variables, with environment variables taking precedence.

Index

Constants

View Source
const (
	// DefaultConfigPath is the default location for the config file.
	DefaultConfigPath = "~/.config/gitlab-duo-acp/config.yml"

	// DefaultGitLabURL is the default GitLab instance URL.
	DefaultGitLabURL = "https://gitlab.com"

	// EnvGitLabURL is the environment variable for GitLab URL.
	EnvGitLabURL = "GITLAB_URL"

	// EnvGitLabAuthToken is the environment variable for GitLab auth token.
	EnvGitLabAuthToken = "GITLAB_AUTH_TOKEN" //nolint:gosec // G101: not a credential, just an env var name
)

Variables

View Source
var (
	// ErrMissingGitLabURL is returned when gitlab_url is not configured.
	ErrMissingGitLabURL = errors.New("gitlab_url is required")

	// ErrMissingAuthToken is returned when gitlab_auth_token is not configured.
	ErrMissingAuthToken = errors.New("gitlab_auth_token is required")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// GitLabURL is the URL of the GitLab instance.
	GitLabURL string `yaml:"gitlab_url"`

	// GitLabAuthToken is the authentication token for GitLab API.
	GitLabAuthToken string `yaml:"gitlab_auth_token"`
}

Config holds the configuration for gitlab-duo-acp.

func Load

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

Load loads configuration from a file and environment variables. If configPath is empty, the default config path is used. Environment variables take precedence over file values.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the configuration is valid.

type EnvFunc

type EnvFunc func(string) string

EnvFunc is a function that looks up environment variables.

type Loader

type Loader struct {
	// GetEnv is the function used to look up environment variables.
	// Defaults to os.Getenv if nil.
	GetEnv EnvFunc

	// ReadFile is the function used to read files.
	// Defaults to os.ReadFile if nil.
	ReadFile func(string) ([]byte, error)

	// UserHomeDir is the function used to get the user's home directory.
	// Defaults to os.UserHomeDir if nil.
	UserHomeDir func() (string, error)
}

Loader handles configuration loading with injectable dependencies.

func DefaultLoader

func DefaultLoader() *Loader

DefaultLoader returns a Loader with default OS functions.

func (*Loader) Load

func (l *Loader) Load(configPath string) (*Config, error)

Load loads configuration using the loader's configured functions.

Jump to

Keyboard shortcuts

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