config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config reads the team settings committed with a vault (.okvault.yaml).

The file holds shared, non-secret settings only: tracker location, project keys, folder owners, the review interval and git policy. Credentials come from the environment, never from the vault.

Index

Constants

View Source
const (
	GitOff    = "off"    // okvault never runs git (default)
	GitCommit = "commit" // commit okvault's writes locally
	GitPush   = "push"   // also rebase on the upstream branch and push to it
	GitPR     = "pr"     // work on a personal branch with one open GitHub pull request
)

Git modes.

View Source
const (
	FilterMine        = "My tickets"
	FilterMissingDocs = "Missing docs"
)

Default filter names.

View Source
const DefaultPullInterval = 5 * time.Minute

DefaultPullInterval is how often a serving okvault fetches and rebases in push and pr modes when the config does not say otherwise.

View Source
const DefaultReviewInterval = 180 * 24 * time.Hour

DefaultReviewInterval is how long a verification stays fresh when the config does not say otherwise.

View Source
const File = ".okvault.yaml"

File is the config file name at the vault root.

Variables

This section is empty.

Functions

func JQLString added in v0.5.0

func JQLString(s string) string

JQLString quotes s as a JQL string literal.

func NormalizeKey

func NormalizeKey(k string) (string, bool)

NormalizeKey upper-cases a ticket key and reports whether it looks like one (ABC-123).

func ParseInterval

func ParseInterval(s string) (time.Duration, error)

ParseInterval accepts "30d", "4w" or any Go duration ("720h").

Types

type Config

type Config struct {
	Tracker Tracker `yaml:"tracker"`
	// Owners maps a vault folder (e.g. "ops" or "ops/runbooks") to its default
	// owners. A note's own `owners` frontmatter wins; otherwise the longest
	// matching folder applies. "." is the whole vault.
	Owners map[string][]string `yaml:"owners"`
	// ReviewInterval is how long a human verification stays fresh, e.g. "180d",
	// "26w" or a Go duration. `okvault verify` sets stale_after from it.
	ReviewInterval string `yaml:"review_interval"`
	// Git sets how okvault records changes in the vault's git repository.
	Git Git `yaml:"git"`
	// contains filtered or unexported fields
}

Config is the team configuration of a vault.

func Load

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

Load reads root/.okvault.yaml. A missing file yields an empty config.

func Parse

func Parse(src []byte) (*Config, error)

Parse parses config YAML. Unknown keys are rejected so that typos and misplaced secrets (token:, password:) fail loudly instead of being committed silently.

func (*Config) BrowseURL

func (c *Config) BrowseURL(key string) string

BrowseURL returns the human link for a ticket, or "" when no tracker is configured.

func (*Config) FilterURL added in v0.5.0

func (c *Config) FilterURL(jql string) string

FilterURL returns the Jira issue search page for a JQL query, or "" without a tracker URL.

func (*Config) OwnersFor

func (c *Config) OwnersFor(notePath string) []string

OwnersFor returns the default owners of a vault-relative note path.

func (*Config) Review

func (c *Config) Review() time.Duration

Review returns the review interval.

func (*Config) TicketFilters added in v0.5.0

func (c *Config) TicketFilters() []Filter

TicketFilters returns the configured filters, or the defaults when none are configured: the token owner's open tickets and, with a doc_label, finished tickets that lack it. Both are limited to the configured projects.

func (*Config) TicketKeys

func (c *Config) TicketKeys(text string) []string

TicketKeys finds ticket keys of the configured projects in text. Without configured projects it finds nothing: a generic pattern would match UTF-8 or ISO-8601.

type Filter added in v0.5.0

type Filter struct {
	Name string `yaml:"name" json:"name"`
	JQL  string `yaml:"jql" json:"jql"`
}

Filter is a named JQL query listing tickets.

type Git

type Git struct {
	Mode   string `yaml:"mode"`   // off, commit, push or pr
	Remote string `yaml:"remote"` // default origin
	// Base is the branch pull requests target (pr mode); default the remote's default branch.
	Base string `yaml:"base"`
	// Branch is the working branch in pr mode; default okvault/<git user name>.
	Branch string `yaml:"branch"`
	// PullInterval is how often to fetch, rebase and push while serving (push
	// and pr modes), e.g. "5m"; "0" means only after okvault's own writes.
	PullInterval string `yaml:"pull_interval"`
	// CommitEdits commits changes made outside okvault (in Obsidian, by hand)
	// once the vault has been quiet this long, e.g. "10m". Empty: never.
	CommitEdits string `yaml:"commit_edits"`
	// contains filtered or unexported fields
}

Git holds the vault's git settings. They are team policy, so they are committed; a machine can still turn git off with `okvault serve --git off`.

func (Git) Every

func (g Git) Every() time.Duration

Every returns the periodic sync interval (0: only after writes).

func (Git) Quiet

func (g Git) Quiet() time.Duration

Quiet returns how long edits made outside okvault rest before they are committed (0: they are not).

type Tracker

type Tracker struct {
	Kind     string   `yaml:"kind"`     // "jira", or "" / "none" for links without fetching
	URL      string   `yaml:"url"`      // e.g. https://acme.atlassian.net
	Projects []string `yaml:"projects"` // project keys, e.g. [PROJ, OPS]; used to spot ticket keys
	API      string   `yaml:"api"`      // Jira REST version "3" or "2"; default 3 on atlassian.net, else 2
	Browse   string   `yaml:"browse"`   // browse URL template with {key}; default {url}/browse/{key}
	// DocLabel is the Jira label a ticket gets once what the team learned on
	// it is documented, e.g. "documented". It drives the default
	// "Missing docs" filter.
	DocLabel string `yaml:"doc_label"`
	// Filters are the ticket lists the ticket workspace and kb_tickets offer,
	// as JQL. Unset: "My tickets", plus "Missing docs" when doc_label is set.
	// A Jira saved filter is `jql: filter = 12345`.
	Filters []Filter `yaml:"filters"`
}

Tracker points at the team's ticketing system.

Jump to

Keyboard shortcuts

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