repoconfig

package
v0.13.3 Latest Latest
Warning

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

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

Documentation

Overview

Package repoconfig is a repo's settings file, .anfra/config.yml: committed, written by hand, and by anfra only through SetString, which changes nothing but the value it sets.

Index

Constants

View Source
const FileName = "config.yml"

FileName is the settings file, in the repo's config folder.

Variables

This section is empty.

Functions

func Hint

func Hint(section, key string) string

Hint is how a message names a setting, for a person to find it: ".anfra/config.yml org.url".

func Path

func Path(dir string) string

Path is the settings file of the repo at dir.

func SetString

func SetString(path, section, key, value string) error

SetString sets section.key to value in the YAML file at path, as git config sets a key: the file is parsed only to find where things are, and the new file is the old one's bytes with the value's bytes replaced, so comments, order and formatting are untouched; written to a lock file and renamed over the original, so a reader sees one or the other and two writers cannot interleave.

  • No file: it is created.
  • No section: a block for it is appended at the end, which disturbs nothing above it.
  • The key, a scalar on one line: its value's bytes are replaced.
  • Anything else (the section without the key, flow style, a value spanning lines): refused, naming the line to write by hand, rather than guessed at.

value must be a plain scalar that reads back as itself; the result is parsed again and checked before it replaces the file.

Types

type Config

type Config struct {
	Org struct {
		// URL is the org `anfra publish` publishes the repo to, by its address on
		// its server. Never a credential.
		URL string `yaml:"url"`
	} `yaml:"org"`
	Apps struct {
		// AllowOrigins are the origins the repo's Data Apps may load from beyond
		// the SDK's own CDNs, as `anfra serve` runs them. Never published: an org
		// holds its own list (AllowedOrigins checks them).
		AllowOrigins []string `yaml:"allow_origins"`
	} `yaml:"apps"`
}

Config is what anfra reads from the settings file.

func Read

func Read(dir string) (Config, error)

Read is the settings of the repo at dir: none set when it has no file.

func (Config) AllowedOrigins added in v0.12.0

func (c Config) AllowedOrigins() ([]string, error)

AllowedOrigins is apps.allow_origins, each an origin a Data App's content policy can take (repoformat.CheckOrigin), or an error naming the first that is not.

Jump to

Keyboard shortcuts

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