config

package
v1.21.2 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const IngitDBDirName = ".ingitdb"

IngitDBDirName is the directory that holds all inGitDB configuration files.

View Source
const NamespaceImportSuffix = ".*"

NamespaceImportSuffix is the suffix used to identify namespace import keys.

View Source
const RootCollectionsFileName = "root-collections.yaml"

RootCollectionsFileName is the file that maps collection IDs to local paths. It is a flat YAML map with no wrapper key.

View Source
const SettingsFileName = "settings.yaml"

SettingsFileName is the file that holds per-database settings.

View Source
const SubscribersConfigFileName = ".ingitdb/subscribers.yaml"

Variables

This section is empty.

Functions

func IsNamespaceImport added in v0.25.0

func IsNamespaceImport(key string) bool

IsNamespaceImport returns true if the key ends with ".*" suffix, indicating it is a namespace import that references another directory's .ingitdb/root-collections.yaml file.

func ReadRootCollectionsFromFile added in v0.28.1

func ReadRootCollectionsFromFile(dirPath string, o ingitdb.ReadOptions) (map[string]string, error)

ReadRootCollectionsFromFile reads .ingitdb/root-collections.yaml from dirPath. If the file does not exist, returns nil map with no error.

func ResolveRecordFormat added in v1.2.0

func ResolveRecordFormat(collection *ingitdb.CollectionDef, settings *Settings) ingitdb.RecordFormat

ResolveRecordFormat returns the effective RecordFormat for a collection, applying the fallback chain:

collection.RecordFile.Format -> settings.DefaultRecordFormat -> ingitdb.RecordFormatYAML.

The helper tolerates a nil collection, a collection with a nil RecordFile, an empty Format string, and a nil settings — each is treated as "no per-tier setting" and the helper falls through to the next tier.

Note on call-site migration: existing call sites that read CollectionDef.RecordFile.Format directly operate downstream of RecordFileDef.Validate (which rejects empty Format), so they cannot observe a project-level fallback today. Wholesale migration is therefore deferred — see the outstanding question in spec/features/record-format/project-default/README.md. This helper is the canonical entry point for new code paths (csv read/write, programmatic content writers, future dalgo schema-modification consumers) and SHOULD be used wherever the caller cannot guarantee Format is set.

func WriteRootCollectionsToFile added in v1.9.0

func WriteRootCollectionsToFile(dirPath string, m map[string]string) error

WriteRootCollectionsToFile writes the given id→path map to <dirPath>/.ingitdb/root-collections.yaml as a flat YAML map. Keys are emitted in sorted order for deterministic on-disk content. Creates the .ingitdb/ directory if absent. An empty map writes a zero-byte file (intentional — see REQ:auto-deregister-from-root-collections in the dalgo2ingitdb-dbschema-ddl-coverage Feature spec).

Types

type Language

type Language struct {
	Required string `yaml:"required,omitempty"`
	Optional string `yaml:"optional,omitempty"`
}

Language defines a supported language for this database.

type RootConfig

type RootConfig struct {
	Settings
	RootCollections map[string]string // loaded from root-collections.yaml; no yaml tag (loaded separately)
}

RootConfig holds the full configuration for an inGitDB database. Settings is loaded from .ingitdb/settings.yaml. RootCollections is loaded from .ingitdb/root-collections.yaml (flat YAML map).

func ReadRootConfigFromFile

func ReadRootConfigFromFile(dirPath string, o ingitdb.ReadOptions) (RootConfig, error)

ReadRootConfigFromFile reads both .ingitdb/settings.yaml and .ingitdb/root-collections.yaml from dirPath, merges them into a RootConfig, optionally validates, and resolves namespace imports. Missing files are not errors; zero-values are used instead.

func (*RootConfig) ResolveNamespaceImports added in v0.25.0

func (rc *RootConfig) ResolveNamespaceImports(baseDirPath string) error

ResolveNamespaceImports resolves all namespace import keys (ending with ".*") in rootCollections. For each such key, it reads the .ingitdb/root-collections.yaml file from the referenced directory and imports all its entries with the namespace prefix prepended.

baseDirPath is the directory containing the current .ingitdb/ directory.

Returns an error if:

  • The referenced directory does not exist
  • The referenced directory has no .ingitdb/root-collections.yaml file
  • The referenced root-collections.yaml has no entries

func (*RootConfig) Validate

func (rc *RootConfig) Validate() error

type Settings added in v0.28.1

type Settings struct {
	// DefaultNamespace is used as the collection ID prefix when this DB is
	// opened directly (not imported via a namespace import). For example,
	// if DefaultNamespace is "todo" and the DB has collection "tasks",
	// it becomes "todo.tasks" when opened directly.
	DefaultNamespace string `yaml:"default_namespace,omitempty"`

	// DefaultRecordFormat is the project-level fallback record format used
	// when a collection's record_file.format is empty. See ResolveRecordFormat
	// for the full fallback chain (collection -> project -> hard yaml default).
	// Empty value means "no project default; use the hard fallback."
	DefaultRecordFormat ingitdb.RecordFormat `yaml:"default_record_format,omitempty"`

	Languages []Language `yaml:"languages,omitempty"`
}

Settings holds per-database settings stored in .ingitdb/settings.yaml.

func ReadSettingsFromFile added in v0.28.1

func ReadSettingsFromFile(dirPath string, o ingitdb.ReadOptions) (Settings, error)

ReadSettingsFromFile reads .ingitdb/settings.yaml from dirPath. If the file does not exist, returns zero Settings with no error.

func (*Settings) Validate added in v1.2.0

func (s *Settings) Validate() error

Validate checks that Settings field values are well-formed. An empty DefaultRecordFormat is permitted (it means "no project default; use the hard fallback"); any non-empty value MUST match one of the seven supported record formats. Other Settings fields are validated by RootConfig.Validate today and not duplicated here.

type SubscribersConfig added in v0.24.3

type SubscribersConfig struct {
	Subscribers map[string]*ingitdb.SubscriberDef `yaml:"subscribers,omitempty"`
}

func (*SubscribersConfig) Validate added in v0.24.3

func (sc *SubscribersConfig) Validate() error

Jump to

Keyboard shortcuts

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