moduleconfig

package
v0.398.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 7 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.

type CustomDefaults added in v0.377.0

type CustomDefaults struct {
	DeployDir          string
	Watch              []string
	BuildLock          optional.Option[string]
	Build              optional.Option[string]
	DevModeBuild       optional.Option[string]
	GeneratedSchemaDir optional.Option[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"`
	// Build is the command to build the module in dev mode.
	DevModeBuild string `toml:"dev-mode-build"`
	// BuildLock is file lock path to prevent concurrent builds of a module.
	BuildLock string `toml:"build-lock"`
	// 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) 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