config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LibraryName

func LibraryName(provider string, repoName string, ref RefConfig, page PageConfig) string

LibraryName returns the library name for a given source context. For git: repo.Name/ref.Ref unless ref.Name is set. For confluence: page.Name if set, else page.Space/page.ID.

func ResolvePath

func ResolvePath(explicit string) (string, error)

ResolvePath finds the config file to use. Priority:

  1. explicit (non-empty string passed by caller)
  2. $DOCSERVE_CONFIG environment variable
  3. ./docserve.yaml
  4. /etc/docserve/docserve.yaml

Types

type AuthConfig

type AuthConfig struct {
	Type        string `yaml:"type"` // "basic", "bearer", or "" (github token)
	TokenEnv    string `yaml:"token_env"`
	UsernameEnv string `yaml:"username_env"`
	PasswordEnv string `yaml:"password_env"`
}

AuthConfig holds authentication settings for a provider or repo.

type Config

type Config struct {
	DataDir   string           `yaml:"data_dir"`
	Listen    string           `yaml:"listen"`
	Proxy     ProxyConfig      `yaml:"proxy"`
	Providers []ProviderConfig `yaml:"providers"`
}

Config holds the full docserve configuration.

func Load

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

Load reads the YAML config at path, applies defaults, and validates it.

type PageConfig added in v1.0.1

type PageConfig struct {
	Name  string `yaml:"name"`
	Space string `yaml:"space"`
	ID    string `yaml:"id"`
	Depth *int   `yaml:"depth"` // nil -> -1 (unlimited)
}

PageConfig describes a Confluence page to index.

type ProviderConfig added in v1.0.1

type ProviderConfig struct {
	Type     string       `yaml:"type"`     // "github", "azure-devops", "confluence"
	BaseURL  string       `yaml:"base_url"` // required for azure-devops, confluence
	Proxy    bool         // default true; handled via custom UnmarshalYAML
	Schedule string       `yaml:"schedule"`
	Auth     AuthConfig   `yaml:"auth"`
	Repos    []RepoConfig `yaml:"repos"` // git providers only
	Pages    []PageConfig `yaml:"pages"` // confluence only
}

ProviderConfig describes a documentation provider and its repositories or pages.

func (*ProviderConfig) UnmarshalYAML added in v1.0.1

func (p *ProviderConfig) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler so that Proxy defaults to true.

type ProxyConfig

type ProxyConfig struct {
	HTTP  string `yaml:"http"`
	HTTPS string `yaml:"https"`
}

ProxyConfig holds HTTP/HTTPS proxy settings.

type RefConfig

type RefConfig struct {
	Name  string   `yaml:"name"` // optional, override library name
	Ref   string   `yaml:"ref"`  // branch/tag/sha
	Paths []string `yaml:"paths"`
}

RefConfig describes a single ref (branch/tag) within a repo.

type RepoConfig added in v1.0.1

type RepoConfig struct {
	Name     string      `yaml:"name"`     // required
	Slug     string      `yaml:"slug"`     // owner/repo (github) or repo name (azure-devops)
	Project  string      `yaml:"project"`  // azure-devops only
	Schedule string      `yaml:"schedule"` // override provider schedule
	Auth     AuthConfig  `yaml:"auth"`     // override provider auth
	Refs     []RefConfig `yaml:"refs"`
}

RepoConfig describes a repository within a git provider.

type ResolvedSource added in v1.0.1

type ResolvedSource struct {
	// Common
	Name     string
	Provider string // "github", "azure-devops", "confluence"
	BaseURL  string
	Proxy    bool
	Schedule string
	Auth     AuthConfig

	// Git providers
	Slug    string // owner/repo or repo name
	Project string // azure-devops only
	Refs    []RefConfig

	// Confluence
	Pages []PageConfig
}

ResolvedSource is a fully resolved source with auth/schedule/proxy inherited from the provider. This is what the rest of the codebase consumes.

func FlattenProviders added in v1.0.1

func FlattenProviders(providers []ProviderConfig) []ResolvedSource

FlattenProviders converts hierarchical ProviderConfig entries into a flat list of ResolvedSource entries suitable for the rest of the codebase. For git providers (github, azure-devops): one ResolvedSource per repo. For confluence: one ResolvedSource per provider (with all pages).

Jump to

Keyboard shortcuts

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