moduleconfig

package
v0.377.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbsModuleConfig added in v0.343.0

type AbsModuleConfig ModuleConfig

AbsModuleConfig is a ModuleConfig with all paths made absolute.

This is a type alias to prevent accidental use of the wrong type.

func (AbsModuleConfig) Schema added in v0.376.0

func (c AbsModuleConfig) Schema() string

type CustomDefaults added in v0.377.0

type CustomDefaults struct {
	Build              string
	DeployDir          string
	GeneratedSchemaDir string
	Watch              []string

	// only the root keys in LanguageConfig are used to find missing values that can be defaulted
	LanguageConfig map[string]any `toml:"-"`
}

type ModuleConfig

type ModuleConfig struct {
	// Dir is the absolute path to the root of the module.
	Dir string `toml:"-"`

	Language string `toml:"language"`
	Realm    string `toml:"realm"`
	Module   string `toml:"module"`
	// Build is the command to build the module.
	Build string `toml:"build"`
	// DeployDir is the directory to deploy from, relative to the module directory.
	DeployDir string `toml:"deploy-dir"`
	// GeneratedSchemaDir is the directory to generate protobuf schema files into. These can be picked up by language specific build tools
	GeneratedSchemaDir string `toml:"generated-schema-dir"`
	// Watch is the list of files to watch for changes.
	Watch []string `toml:"watch"`

	// LanguageConfig is a map of language specific configuration.
	// It is saved in the toml with the value of Language as the key.
	LanguageConfig map[string]any `toml:"-"`
}

ModuleConfig is the configuration for an FTL module.

Module config files are currently TOML.

func (ModuleConfig) Abs added in v0.343.0

func (c ModuleConfig) Abs() AbsModuleConfig

Abs creates a clone of ModuleConfig with all paths made absolute.

This function will panic if any paths are not beneath the module directory. This should never happen under normal use, as LoadModuleConfig performs this validation separately. This is just a sanity check.

func (ModuleConfig) Schema

func (c ModuleConfig) Schema() string

func (ModuleConfig) String added in v0.343.0

func (c ModuleConfig) String() string

func (*ModuleConfig) UnmarshalTOML added in v0.377.0

func (c *ModuleConfig) UnmarshalTOML(data []byte) error

type UnvalidatedModuleConfig added in v0.377.0

type UnvalidatedModuleConfig ModuleConfig

UnvalidatedModuleConfig is a ModuleConfig that holds only the values read from the toml file.

It has not had it's defaults set or been validated, so values may be empty or invalid. Use FillDefaultsAndValidate() to get a ModuleConfig.

func LoadConfig

func LoadConfig(dir string) (UnvalidatedModuleConfig, error)

LoadConfig from a directory. This returns only the values found in the toml file. To get the full config with defaults and validation, use FillDefaultsAndValidate.

func (UnvalidatedModuleConfig) FillDefaultsAndValidate added in v0.377.0

func (c UnvalidatedModuleConfig) FillDefaultsAndValidate(customDefaults CustomDefaults) (ModuleConfig, error)

FillDefaultsAndValidate sets values for empty fields and validates the config. It involves standard defaults for Real and Errors fields, and also looks at CustomDefaults for defaulting other fields.

Jump to

Keyboard shortcuts

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