config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config resolves file locations, the user config file and the Taiga URL/project context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeURL

func NormalizeURL(raw string) (string, error)

NormalizeURL returns scheme://host[:port] (host lowercased) without trailing slash or /api/v1 suffix.

func Save

func Save(path string, f File) error

Save writes the config atomically with mode 0600.

func WriteFileAtomic

func WriteFileAtomic(path string, data []byte) error

WriteFileAtomic writes via a temp file + rename, creating parent dirs with 0700 and the file with 0600.

Types

type Context

type Context struct {
	URL     Value `json:"url"`
	Project Value `json:"project"`
}

func Resolve

func Resolve(in Inputs) (Context, error)

Resolve applies flag > env > .taiga.toml > user config for URL and project.

type File

type File struct {
	DefaultHost string `toml:"default_host,omitempty"`
	Hosts       []Host `toml:"hosts"`
}

func Load

func Load(path string) (File, error)

Load reads the config file; a missing file is an empty config.

func (File) Host

func (f File) Host(u string) (Host, bool)

func (*File) Upsert

func (f *File) Upsert(h Host)

type Host

type Host struct {
	URL           string   `toml:"url"`
	Username      string   `toml:"username"`
	SecretSource  string   `toml:"secret_source"`
	SecretCommand []string `toml:"secret_command,omitempty"`
	Project       string   `toml:"project,omitempty"`
}

type Inputs

type Inputs struct {
	FlagURL, FlagProject string
	Env                  func(string) string
	Cwd                  string
	File                 File
	ConfigPath           string
}

type Paths

type Paths struct {
	ConfigFile string
	StateDir   string
	SecretsDir string
}

func DefaultPaths

func DefaultPaths(env func(string) string) (Paths, error)

DefaultPaths honours TAIGA_CONFIG, TAIGA_STATE_DIR and the XDG base directories. Relative XDG_* (and HOME) values are ignored, as the XDG spec requires.

type RepoFile

type RepoFile struct {
	URL     string `toml:"url"`
	Project string `toml:"project"`
}

func FindRepoFile

func FindRepoFile(startDir string) (RepoFile, string, error)

FindRepoFile walks up from startDir looking for .taiga.toml.

type Value

type Value struct {
	Value  string `json:"value"`
	Source string `json:"source"`
}

Jump to

Keyboard shortcuts

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