moonrockz/moon-lander/config

Types

BindFailure

pub(all) struct BindFailure {
  at : Array[Located]
  detail : String
} derive(Eq, @moonbitlang/core/debug.Debug)

A binding failure: the decoder or validation detail and the paths that it names. at holds one or more paths and is never empty.

Source

BindFailure::equal

fn BindFailure::equal(BindFailure, BindFailure) -> Bool

Source

BindFailure::not_equal

fn BindFailure::not_equal(x : BindFailure, y : BindFailure) -> Bool

Source

BindFailure::to_repr

fn BindFailure::to_repr(BindFailure) -> @moonbitlang/core/debug.Repr

Source

Blame

pub(all) enum Blame {
  Set(Array[Origin])
  Table(Array[Origin])
  Default
  Unset
} derive(Eq, @moonbitlang/core/debug.Debug)

The sources to blame for a value that failed to decode.

Source

Blame::equal

fn Blame::equal(Blame, Blame) -> Bool

Source

Blame::not_equal

fn Blame::not_equal(x : Blame, y : Blame) -> Bool

Source

Blame::to_repr

fn Blame::to_repr(Blame) -> @moonbitlang/core/debug.Repr

Source

Config

pub struct Config {
  // private fields
}

A merged configuration with the reports of its sources. Its root is always a struct.

Source

Config::bind

fn[T : @moonbitlang/core/json.FromJson] Config::bind(self : Config, key : String) -> T raise ConfigError

Decode the section at key into a T, as bind does.

Source

Config::bind_or

fn[T : @moonbitlang/core/json.FromJson + ToJson] Config::bind_or(self : Config, key : String, default : T, unknown? : UnknownKeys) -> T raise ConfigError

Decode the section at key merged over default, as bind_or does.

Source

Config::get

fn Config::get(self : Config, key : KeyPath) -> ConfigValue?

The value at key, or None when no value is there.

Source

Config::origins

fn Config::origins(self : Config, key : KeyPath) -> Array[Origin]

The origins of the leaf at key: one origin for a replaced leaf or list. A struct has no origin of its own, so a struct or a missing key gives an empty array.

Source

Config::provenance

fn Config::provenance(self : Config) -> Array[(KeyPath, Array[Origin])]

The origins of every leaf, in tree order. Each array is not empty.

Source

Config::reports

fn Config::reports(self : Config) -> Array[SourceReport]

The source reports in merge order.

Source

Config::secret

fn[R : SecretResolver] Config::secret(self : Config, key : String, resolver : R) -> Secret raise SecretError

Resolve the secret at key. A plain string is a literal secret and does not call the resolver. A secret reference calls resolver with the leaf origin.

Source

Config::value

fn Config::value(self : Config) -> ConfigValue

The merged value tree.

Source

Config::warnings

fn Config::warnings(self : Config) -> Array[ConfigWarning]

The warnings of the load: the warnings of the source providers, then the warnings of each source report in merge order.

Source

ConfigBuilder

pub struct ConfigBuilder {
  // private fields
}

An immutable list of sources and source providers in merge order, the registered formats, and the explicit inputs of one run: the variable set, the working directory, and the platform. Each function returns a new builder.

Source

ConfigBuilder::formats

fn ConfigBuilder::formats(self : ConfigBuilder) -> Array[Format]

The registered formats in registration order.

Source

ConfigBuilder::given_env_vars

fn ConfigBuilder::given_env_vars(self : ConfigBuilder) -> Map[String, String]?

The variable set that the builder holds, or None when nobody gave one. A host reads the process variables only when this is None.

Source

ConfigBuilder::given_platform

fn ConfigBuilder::given_platform(self : ConfigBuilder) -> Platform?

The platform that the builder holds, or None when nobody gave one.

Source

ConfigBuilder::given_working_dir

fn ConfigBuilder::given_working_dir(self : ConfigBuilder) -> String?

The working directory that the builder holds, or None when nobody gave one.

Source

ConfigNode

pub struct ConfigNode {
  // private fields
}

One value of the configuration tree for exact decoding: its decode path, the value or its absence, and the sources to blame. A node in a list has a decode path with an index suffix and the blame of the list.

Source

ConfigNode::blame

fn ConfigNode::blame(self : ConfigNode) -> Blame

The sources to blame for the value of the node.

Source

ConfigNode::child

fn ConfigNode::child(self : ConfigNode, name : String) -> ConfigNode

The node of the field name. The node has no value when this node is not a table or has no such field.

Source

ConfigNode::children

fn ConfigNode::children(self : ConfigNode) -> Array[(String, ConfigNode)]

The fields of a table, with their nodes, in configuration order. A node that is not a table has no fields.

Source

ConfigNode::fail

fn[T] ConfigNode::fail(self : ConfigNode, detail : String) -> T raise ConfigError

Raise Decode at the node with detail and the blame of the node. Use it for a rule that a FromConfig implementation checks while it decodes.

Source

ConfigNode::get

fn[T : FromConfig] ConfigNode::get(self : ConfigNode, name : String) -> T raise ConfigError

Decode the field name exactly.

Source

ConfigNode::items

fn ConfigNode::items(self : ConfigNode) -> Array[ConfigNode]

The items of a list, in order. Each item node has the index in its decode path and the blame of the list. A node that is not a list has no items.

Source

ConfigNode::json

fn[T : @moonbitlang/core/json.FromJson] ConfigNode::json(self : ConfigNode) -> T raise ConfigError

Decode the node with FromJson, with the same error translation as bind: a failure names the full decode path from the bound section. A node with no value decodes as null. A secret reference in the node raises Decode.

Source

ConfigNode::path

fn ConfigNode::path(self : ConfigNode) -> DecodePath

The decode path of the node.

Source

ConfigNode::value

fn ConfigNode::value(self : ConfigNode) -> ConfigValue?

The value of the node, or None when no source sets it.

Source

ConfigSource

pub struct ConfigSource {
  // private fields
}

An immutable configuration source: a kind, a display name, an optional display priority, the list merge policy, key-path policies, the input, and the key paths to exclude.

Source

ConfigSource::candidates

fn ConfigSource::candidates(paths : Array[String], display~ : String, role? : FileRole, name? : String, priority? : Int) -> ConfigSource

A file source over an explicit list of candidate files at one location. No existing candidate gives the status NotFound, one loads it, and more than one raises Ambiguous with display. A candidate exists when the listing of its directory holds its exact name as a file. The name is display when no name is given.

Source

ConfigSource::defaults

fn ConfigSource::defaults(json : Json, name? : String, priority? : Int) -> ConfigSource raise ConfigError

A defaults source from a JSON value, for example Defaults::default().to_json(). The root must be an object.

Source

ConfigSource::defaults_value

fn ConfigSource::defaults_value(value : ConfigValue, name? : String, priority? : Int) -> ConfigSource raise ConfigError

A defaults source from a value tree. The root must be a struct.

Source

ConfigSource::env

fn ConfigSource::env(prefix~ : String, reserved? : Array[String], selection? : SourceSelection[Map[String, String]], name? : String, priority? : Int) -> ConfigSource

An environment variable source. A variable counts when its name, in upper case, starts with prefix and _ and is not in reserved (compared in upper case). After the prefix, leading _ characters go, __ separates names, and each name is written in lower case: ACME_SERVER__PORT sets server.port. An empty name raises InvalidEnvKey.

Discover reads the variable set of the builder, and reports NotFound when the builder holds none. Explicit(vars) reads only vars. Skip loads nothing. Each value gets a type: true or false in any case is a Boolean, an optional sign and digits that fit Int64 are an integer, JSON text that starts with [ or { is a list or a struct, and other text is a string. The origin of each value names its variable.

Source

ConfigSource::exclude

fn ConfigSource::exclude(self : ConfigSource, paths : Array[KeyPath], warn~ : Bool) -> ConfigSource

A new source that removes the subtrees at paths after the parse and before the merge. When warn is true, each removed key that the source held adds a KeyRemoved warning to its report.

Source

ConfigSource::file

fn ConfigSource::file(path : String, role? : FileRole, name? : String, priority? : Int) -> ConfigSource

A file source at an explicit path. A relative path joins the working directory of the builder. The extension selects the registered format. The load raises FileNotFound when the file does not exist. The name is the path when no name is given.

Source

ConfigSource::kind

fn ConfigSource::kind(self : ConfigSource) -> SourceKind

The kind of the source.

Source

ConfigSource::name

fn ConfigSource::name(self : ConfigSource) -> String

The display name of the source.

Source

ConfigSource::overrides

fn ConfigSource::overrides(pairs : Array[(String, ConfigValue)], name? : String, priority? : Int) -> ConfigSource raise ConfigError

An overrides source from key-path pairs, for example command-line values. It has the kind Overrides and the default priority 700.

Source

ConfigSource::overrides_value

fn ConfigSource::overrides_value(value : ConfigValue, name? : String, priority? : Int) -> ConfigSource raise ConfigError

An overrides source from a value tree. The root must be a struct.

Source

ConfigSource::parsed_file

fn ConfigSource::parsed_file(path : String, value : ConfigValue, role? : FileRole, name? : String, priority? : Int) -> ConfigSource raise ConfigError

A file source whose text the caller already read and turned into a value tree, for example a legacy file with its own format. The report and the origins show path, which joins the working directory when it is relative. The root must be a struct.

Source

ConfigSource::skipped

fn ConfigSource::skipped(kind : SourceKind, name? : String, priority? : Int) -> ConfigSource

A source that loads nothing and reports the status Skipped. The name is the report name of kind when no name is given.

Source

ConfigSource::with_key_policy

fn ConfigSource::with_key_policy(self : ConfigSource, key : KeyPath, policy : MergePolicy) -> ConfigSource

A new source with the list merge policy policy at key. A key-path policy beats the source policy.

Source

ConfigSource::with_policy

fn ConfigSource::with_policy(self : ConfigSource, policy : MergePolicy) -> ConfigSource

A new source with the list merge policy policy for every list that has no key-path policy.

Source

ConfigValue

pub struct ConfigValue {
  // private fields
} derive(@moonbitlang/core/debug.Debug)

An immutable configuration value over an Ion value. Every format and source gives values of this one type before the merge.

Source

ConfigValue::equal

fn ConfigValue::equal(self : ConfigValue, other : ConfigValue) -> Bool

Source

ConfigValue::from_ion

fn ConfigValue::from_ion(ion : @moonrockz/ion/ion.Ion, origin? : String) -> ConfigValue raise ConfigError

A source tree from an Ion value. The root must be a struct, else this raises InvalidRoot with origin. A struct field name with no text, such as an unresolved symbol ID, raises Parse for the Ion format. Two fields with the same name in one struct raise DuplicateKey. The key path of a field in a list item holds the struct field names only, because a key path does not select list items.

Source

ConfigValue::from_json

fn ConfigValue::from_json(json : Json, origin? : String) -> ConfigValue raise ConfigError

A source tree from a JSON value, through its Ion form. The rules of ConfigValue::from_ion apply.

Source

ConfigValue::not_equal

fn ConfigValue::not_equal(x : ConfigValue, y : ConfigValue) -> Bool

Source

ConfigValue::to_ion

fn ConfigValue::to_ion(self : ConfigValue) -> @moonrockz/ion/ion.Ion

The Ion value.

Source

ConfigValue::to_repr

fn ConfigValue::to_repr(ConfigValue) -> @moonbitlang/core/debug.Repr

Source

ConfigValue::type_name

fn ConfigValue::type_name(self : ConfigValue) -> String

The Ion type name in lowercase, for example struct or list.

Source

impl Eq for ConfigValue

Eq::equal

fn equal(self : ConfigValue, other : ConfigValue) -> Bool

Equality of the Ion data model. Struct fields compare as an unordered set.

Source

ConfigWarning

pub(all) enum ConfigWarning {
  KeyRemoved(KeyPath, Origin)
  Note(source~ : String, message~ : String)
} derive(Eq, @moonbitlang/core/debug.Debug)

A warning of a load.

Source

ConfigWarning::equal

fn ConfigWarning::equal(ConfigWarning, ConfigWarning) -> Bool

Source

ConfigWarning::not_equal

fn ConfigWarning::not_equal(x : ConfigWarning, y : ConfigWarning) -> Bool

Source

ConfigWarning::to_repr

fn ConfigWarning::to_repr(ConfigWarning) -> @moonbitlang/core/debug.Repr

Source

DecodePath

pub(all) struct DecodePath {
  key : KeyPath?
  suffix : Array[DecodeStep]
} derive(Eq, @moonbitlang/core/debug.Debug)

The path of a value that failed to decode. key holds the leading names up to the first list index, and None is the root of the bound tree. suffix is empty or starts with an Index step.

Source

DecodePath::equal

fn DecodePath::equal(DecodePath, DecodePath) -> Bool

Source

DecodePath::not_equal

fn DecodePath::not_equal(x : DecodePath, y : DecodePath) -> Bool

Source

DecodePath::output

fn DecodePath::output(self : DecodePath, logger : &Logger) -> Unit

Source

DecodePath::to_repr

fn DecodePath::to_repr(DecodePath) -> @moonbitlang/core/debug.Repr

Source

DecodePath::to_string

fn DecodePath::to_string(self : DecodePath) -> String

Source

impl Show for DecodePath

Show::output

fn output(self : DecodePath, logger : &Logger) -> Unit

The text form, for example targets[1].level or servers."eu.west".port. A field name uses the quote rule of KeyPath. A path with no key and no suffix gives (root).

Source

DecodeStep

pub(all) enum DecodeStep {
  Field(String)
  Index(Int)
} derive(Eq, @moonbitlang/core/debug.Debug)

One step of a decode path after the key path: a list index or a field name.

Source

DecodeStep::equal

fn DecodeStep::equal(DecodeStep, DecodeStep) -> Bool

Source

DecodeStep::not_equal

fn DecodeStep::not_equal(x : DecodeStep, y : DecodeStep) -> Bool

Source

DecodeStep::to_repr

fn DecodeStep::to_repr(DecodeStep) -> @moonbitlang/core/debug.Repr

Source

DirEntry

pub(all) struct DirEntry {
  name : String
  kind : EntryKind
} derive(Eq, @moonbitlang/core/debug.Debug)

One entry of a directory listing, with its real name.

Source

DirEntry::equal

fn DirEntry::equal(DirEntry, DirEntry) -> Bool

Source

DirEntry::not_equal

fn DirEntry::not_equal(x : DirEntry, y : DirEntry) -> Bool

Source

DirEntry::to_repr

fn DirEntry::to_repr(DirEntry) -> @moonbitlang/core/debug.Repr

Source

EntryKind

pub(all) enum EntryKind {
  File
  Directory
  Other
} derive(Eq, @moonbitlang/core/debug.Debug)

The kind of a directory entry.

Source

EntryKind::equal

fn EntryKind::equal(EntryKind, EntryKind) -> Bool

Source

EntryKind::not_equal

fn EntryKind::not_equal(x : EntryKind, y : EntryKind) -> Bool

Source

EntryKind::to_repr

fn EntryKind::to_repr(EntryKind) -> @moonbitlang/core/debug.Repr

Source

EnvResolver

pub struct EnvResolver {
  // private fields
}

A resolver over an explicit variable map. It resolves only Env references.

Source

EnvResolver::resolve

fn EnvResolver::resolve(self : EnvResolver, reference : SecretRef, _origin : Origin) -> Secret raise SecretError

Source

impl SecretResolver for EnvResolver

SecretResolver::resolve

fn resolve(self : EnvResolver, reference : SecretRef, _origin : Origin) -> Secret raise SecretError

Source

Expansion

pub(all) struct Expansion {
  sources : Array[ConfigSource]
  warnings : Array[ConfigWarning]
}

The sources that a provider gives, in merge order, and its warnings.

Source

FileRequest

pub(all) enum FileRequest {
  ListDir(String)
  ReadFile(String)
} derive(Eq, Hash, @moonbitlang/core/debug.Debug)

A request that the pure load passes out to a host: the listing of a directory or the text of a file. Paths use / separators.

Source

FileRequest::equal

fn FileRequest::equal(FileRequest, FileRequest) -> Bool

Source

FileRequest::hash

fn FileRequest::hash(self : FileRequest) -> Int

Source

FileRequest::hash_combine

fn FileRequest::hash_combine(FileRequest, Hasher) -> Unit

Source

FileRequest::not_equal

fn FileRequest::not_equal(x : FileRequest, y : FileRequest) -> Bool

Source

FileRequest::to_repr

fn FileRequest::to_repr(FileRequest) -> @moonbitlang/core/debug.Repr

Source

FileRole

pub(all) enum FileRole {
  Explicit
  System
  Global
  Workspace
  Member
  EnvironmentFile
  LocalOverride
  UserOverride
  Legacy
} derive(Eq, @moonbitlang/core/debug.Debug)

The role of a file source. Reports and error text show a role by its report name, for example user-override.

Source

FileRole::equal

fn FileRole::equal(FileRole, FileRole) -> Bool

Source

FileRole::not_equal

fn FileRole::not_equal(x : FileRole, y : FileRole) -> Bool

Source

FileRole::to_repr

fn FileRole::to_repr(FileRole) -> @moonbitlang/core/debug.Repr

Source

FileTree

pub struct FileTree {
  // private fields
}

An immutable snapshot of the files that a load can read: directory listings, file text, and absence records, keyed by path with / separators. In a complete tree, a path that the tree does not hold is absent. The pure load asks only for paths that the tree does not know.

Source

FileTree::file

fn FileTree::file(self : FileTree, path : String) -> Lookup[String]

The text of the file path.

Source

FileTree::is_complete

fn FileTree::is_complete(self : FileTree) -> Bool

Whether the tree is complete.

Source

FileTree::is_file

fn FileTree::is_file(self : FileTree, path : String) -> Lookup[Bool]

Whether path exists as a file: the listing of its directory holds its exact name as a file. The compare is case-sensitive on every platform. A missing directory gives Found(false).

Source

FileTree::listing

fn FileTree::listing(self : FileTree, dir : String) -> Lookup[Array[DirEntry]]

The listing of the directory dir.

Source

FileTree::new

fn FileTree::new(complete? : Bool) -> FileTree

An empty tree. With complete=true, every path is absent until a with_* call adds it, so a load over it never asks for files.

Source

FileTree::with_file

fn FileTree::with_file(self : FileTree, path : String, text : String) -> FileTree

A new tree that also holds the text of the file path.

Source

FileTree::with_listing

fn FileTree::with_listing(self : FileTree, dir : String, entries : Array[DirEntry]) -> FileTree

A new tree that also holds the listing of the directory dir.

Source

FileTree::with_missing

fn FileTree::with_missing(self : FileTree, path : String) -> FileTree

A new tree that records path as absent. When path is a directory, every path under it is also absent.

Source

Format

pub(all) struct Format {
  name : String
  extensions : Array[String]
  parse : (String, String) -> ConfigValue raise ConfigError
}

A configuration file format. parse takes the text and the origin, for example a file path, and gives a value tree with a struct root.

Source

KeyPath

pub struct KeyPath {
  // private fields
} derive(Eq, Hash, @moonbitlang/core/debug.Debug)

A path to a value in a configuration tree: a non-empty list of non-empty field names. Name matches are exact and case-sensitive. A key path does not select list items.

Source

KeyPath::equal

fn KeyPath::equal(KeyPath, KeyPath) -> Bool

Source

KeyPath::from_names

fn KeyPath::from_names(names : Array[String]) -> KeyPath raise ConfigError

A key path from field names, from the root down. The list and each name must not be empty.

Source

KeyPath::hash

fn KeyPath::hash(self : KeyPath) -> Int

Source

KeyPath::hash_combine

fn KeyPath::hash_combine(KeyPath, Hasher) -> Unit

Source

KeyPath::names

fn KeyPath::names(self : KeyPath) -> Array[String]

The field names, from the root down.

Source

KeyPath::not_equal

fn KeyPath::not_equal(x : KeyPath, y : KeyPath) -> Bool

Source

KeyPath::output

fn KeyPath::output(self : KeyPath, logger : &Logger) -> Unit

Source

KeyPath::parse

fn KeyPath::parse(text : String) -> KeyPath raise ConfigError

Parse the dotted text form, for example ir.strict_mode. A name that contains . or " uses double quotes, for example servers."eu.west".port. In a quoted name, \" gives " and \\ gives \.

Source

KeyPath::to_repr

fn KeyPath::to_repr(KeyPath) -> @moonbitlang/core/debug.Repr

Source

KeyPath::to_string

fn KeyPath::to_string(self : KeyPath) -> String

Source

impl Show for KeyPath

Show::output

fn output(self : KeyPath, logger : &Logger) -> Unit

The text form, which KeyPath::parse reads back to an equal key path.

Source

LoadContext

pub(all) struct LoadContext {
  tree : FileTree
  platform : Platform?
  env_vars : Map[String, String]
  working_dir : String?
  formats : Array[Format]
}

The inputs that a source provider gets during a load. platform is None when no host gave it, and env_vars is empty when the builder holds no variable set.

Source

LoadStep

pub(all) enum LoadStep[T] {
  Need(Array[FileRequest])
  Done(T)
} derive(Eq, @moonbitlang/core/debug.Debug)

One step of a pure load: the file requests that it still needs, or the result.

Source

LoadStep::equal

fn[T : Eq] LoadStep::equal(LoadStep[T], LoadStep[T]) -> Bool

Source

LoadStep::not_equal

fn[T : Eq] LoadStep::not_equal(x : LoadStep[T], y : LoadStep[T]) -> Bool

Source

LoadStep::to_repr

fn[T : @moonbitlang/core/debug.Debug] LoadStep::to_repr(LoadStep[T]) -> @moonbitlang/core/debug.Repr

Source

Located

pub(all) struct Located {
  path : DecodePath
  blame : Blame
} derive(Eq, @moonbitlang/core/debug.Debug)

A decode path and the sources to blame for it.

Source

Located::equal

fn Located::equal(Located, Located) -> Bool

Source

Located::not_equal

fn Located::not_equal(x : Located, y : Located) -> Bool

Source

Located::to_repr

fn Located::to_repr(Located) -> @moonbitlang/core/debug.Repr

Source

Lookup

pub(all) enum Lookup[T] {
  Found(T)
  Missing
  Unknown
} derive(Eq, @moonbitlang/core/debug.Debug)

What a file tree knows about a path: it holds the value, it records the path as absent, or it does not know.

Source

Lookup::equal

fn[T : Eq] Lookup::equal(Lookup[T], Lookup[T]) -> Bool

Source

Lookup::not_equal

fn[T : Eq] Lookup::not_equal(x : Lookup[T], y : Lookup[T]) -> Bool

Source

Lookup::to_repr

fn[T : @moonbitlang/core/debug.Debug] Lookup::to_repr(Lookup[T]) -> @moonbitlang/core/debug.Repr

Source

MergePolicy

pub(all) enum MergePolicy {
  Replace
  Append
  MergeByKey(String)
} derive(Eq, @moonbitlang/core/debug.Debug)

How two lists merge at one key path. The default is Replace. A key-path policy beats the source policy.

Source

MergePolicy::equal

fn MergePolicy::equal(MergePolicy, MergePolicy) -> Bool

Source

MergePolicy::not_equal

fn MergePolicy::not_equal(x : MergePolicy, y : MergePolicy) -> Bool

Source

MergePolicy::output

fn MergePolicy::output(self : MergePolicy, logger : &Logger) -> Unit

Source

MergePolicy::to_repr

fn MergePolicy::to_repr(MergePolicy) -> @moonbitlang/core/debug.Repr

Source

MergePolicy::to_string

fn MergePolicy::to_string(self : MergePolicy) -> String

Source

impl Show for MergePolicy

Show::output

fn output(self : MergePolicy, logger : &Logger) -> Unit

Source

NamedOptions

pub struct NamedOptions[T] {
  // private fields
}

The options values of the children of one section, one for each instance name, in configuration order.

Source

NamedOptions::get

fn[T] NamedOptions::get(self : NamedOptions[T], name : String) -> Options[T]?

The options value of the instance name, or None when the section has no child with that name.

Source

NamedOptions::names

fn[T] NamedOptions::names(self : NamedOptions[T]) -> Array[String]

The instance names, in configuration order.

Source

Options

pub struct Options[T] {
  value : T
  key : KeyPath
  name : String?
}

A bound and validated value, the key path of its section, and the instance name of a named option. An options value exists only after decoding and validation succeed.

Source

Origin

pub(all) struct Origin {
  kind : SourceKind
  source : String
  priority : Int
  location : String?
} derive(Eq, @moonbitlang/core/debug.Debug)

The source that set a value: its kind, display name, display priority, and location. The location is a file path in the / form or an environment variable name.

Source

Origin::equal

fn Origin::equal(Origin, Origin) -> Bool

Source

Origin::not_equal

fn Origin::not_equal(x : Origin, y : Origin) -> Bool

Source

Origin::to_repr

fn Origin::to_repr(Origin) -> @moonbitlang/core/debug.Repr

Source

Platform

pub(all) enum Platform {
  Linux
  MacOs
  Windows
} derive(Eq, @moonbitlang/core/debug.Debug)

The operating system of a run.

Source

Platform::equal

fn Platform::equal(Platform, Platform) -> Bool

Source

Platform::not_equal

fn Platform::not_equal(x : Platform, y : Platform) -> Bool

Source

Platform::to_repr

fn Platform::to_repr(Platform) -> @moonbitlang/core/debug.Repr

Source

Secret

pub struct Secret {
  // private fields
}

An opaque resolved secret. Show writes <redacted>.

Source

Secret::expose

fn Secret::expose(self : Secret) -> String

The secret text. Callers that display a value must not use this.

Source

Secret::output

fn Secret::output(_self : Secret, logger : &Logger) -> Unit

Source

Secret::to_string

fn Secret::to_string(self : Secret) -> String

Source

impl Show for Secret

Show::output

fn output(_self : Secret, logger : &Logger) -> Unit

Source

SecretRef

pub(all) enum SecretRef {
  Env(String)
  File(String)
  Command(Array[String])
  Keyring(service~ : String, account~ : String)
} derive(Eq, @moonbitlang/core/debug.Debug)

A secret reference leaf: one of the Morphir shapes.

Source

SecretRef::equal

fn SecretRef::equal(SecretRef, SecretRef) -> Bool

Source

SecretRef::from_config

fn SecretRef::from_config(node : ConfigNode) -> SecretRef raise ConfigError

Source

SecretRef::not_equal

fn SecretRef::not_equal(x : SecretRef, y : SecretRef) -> Bool

Source

SecretRef::to_repr

fn SecretRef::to_repr(SecretRef) -> @moonbitlang/core/debug.Repr

Source

impl FromConfig for SecretRef

FromConfig::from_config

fn from_config(node : ConfigNode) -> SecretRef raise ConfigError

The unresolved reference. Binding never resolves it; use Config::secret for that.

Source

SecretSyntax

pub(all) enum SecretSyntax {
  Standard
  None
} derive(Eq, @moonbitlang/core/debug.Debug)

Whether the load and the merge treat one-field env / file / command / keyring structs as secret references.

Source

SecretSyntax::equal

fn SecretSyntax::equal(SecretSyntax, SecretSyntax) -> Bool

Source

SecretSyntax::none

fn SecretSyntax::none() -> SecretSyntax

Turn secret-reference recognition off.

Source

SecretSyntax::not_equal

fn SecretSyntax::not_equal(x : SecretSyntax, y : SecretSyntax) -> Bool

Source

SecretSyntax::standard

fn SecretSyntax::standard() -> SecretSyntax

The Morphir secret-reference shapes. Recognition is on when the syntax is Standard.

Source

SecretSyntax::to_repr

fn SecretSyntax::to_repr(SecretSyntax) -> @moonbitlang/core/debug.Repr

Source

ShowFormat

pub(all) enum ShowFormat {
  Toml
  Json
  Ion
} derive(Eq, @moonbitlang/core/debug.Debug)

The text form of a show helper.

Source

ShowFormat::equal

fn ShowFormat::equal(ShowFormat, ShowFormat) -> Bool

Source

ShowFormat::not_equal

fn ShowFormat::not_equal(x : ShowFormat, y : ShowFormat) -> Bool

Source

ShowFormat::to_repr

fn ShowFormat::to_repr(ShowFormat) -> @moonbitlang/core/debug.Repr

Source

SourceKind

pub(all) enum SourceKind {
  Defaults
  InMemory
  File(FileRole)
  Environment
  Overrides
} derive(Eq, @moonbitlang/core/debug.Debug)

The kind of a configuration source.

Source

SourceKind::equal

fn SourceKind::equal(SourceKind, SourceKind) -> Bool

Source

SourceKind::not_equal

fn SourceKind::not_equal(x : SourceKind, y : SourceKind) -> Bool

Source

SourceKind::report_name

fn SourceKind::report_name(self : SourceKind) -> String

The report name of a source kind, as Morphir names its layers. A file source shows the name of its role: project for workspace, explicit, and legacy files.

Source

SourceKind::to_repr

fn SourceKind::to_repr(SourceKind) -> @moonbitlang/core/debug.Repr

Source

SourceProvider

pub(all) struct SourceProvider {
  name : String
  expand : (LoadContext) -> LoadStep[Expansion] raise ConfigError
}

A step of the builder that gives sources during the load. expand gives the file requests that it still needs, or its sources. With a complete tree it must give its sources.

Source

SourceReport

pub(all) struct SourceReport {
  kind : SourceKind
  name : String
  priority : Int
  path : String?
  candidates : Array[String]
  status : SourceStatus
  warnings : Array[ConfigWarning]
} derive(Eq, @moonbitlang/core/debug.Debug)

The report of one source after a load. path is the file that the source read, and candidates are the files that a candidate list looked for.

Source

SourceReport::equal

fn SourceReport::equal(SourceReport, SourceReport) -> Bool

Source

SourceReport::not_equal

fn SourceReport::not_equal(x : SourceReport, y : SourceReport) -> Bool

Source

SourceReport::to_repr

fn SourceReport::to_repr(SourceReport) -> @moonbitlang/core/debug.Repr

Source

SourceSelection

pub(all) enum SourceSelection[T] {
  Discover
  Explicit(T)
  Skip
} derive(Eq, @moonbitlang/core/debug.Debug)

The selection of a source location or input. Discover uses the values that a host or a source provider supplies, Explicit uses only the given value, and Skip loads nothing.

Source

SourceSelection::equal

fn[T : Eq] SourceSelection::equal(SourceSelection[T], SourceSelection[T]) -> Bool

Source

SourceSelection::not_equal

fn[T : Eq] SourceSelection::not_equal(x : SourceSelection[T], y : SourceSelection[T]) -> Bool

Source

SourceSelection::to_repr

fn[T : @moonbitlang/core/debug.Debug] SourceSelection::to_repr(SourceSelection[T]) -> @moonbitlang/core/debug.Repr

Source

SourceStatus

pub(all) enum SourceStatus {
  Loaded
  NotFound
  Skipped
} derive(Eq, @moonbitlang/core/debug.Debug)

What a load did with a source.

Source

SourceStatus::equal

fn SourceStatus::equal(SourceStatus, SourceStatus) -> Bool

Source

SourceStatus::not_equal

fn SourceStatus::not_equal(x : SourceStatus, y : SourceStatus) -> Bool

Source

SourceStatus::to_repr

fn SourceStatus::to_repr(SourceStatus) -> @moonbitlang/core/debug.Repr

Source

Sourced

pub struct Sourced[T] {
  value : T
  blame : Blame
} derive(Eq, @moonbitlang/core/debug.Debug)

A decoded value with the sources to blame for it, for example to resolve a relative path against the file that set it.

Source

Sourced::equal

fn[T : Eq] Sourced::equal(Sourced[T], Sourced[T]) -> Bool

Source

Sourced::from_config

fn[T : FromConfig] Sourced::from_config(node : ConfigNode) -> Sourced[T] raise ConfigError

Source

Sourced::not_equal

fn[T : Eq] Sourced::not_equal(x : Sourced[T], y : Sourced[T]) -> Bool

Source

Sourced::to_repr

fn[T : @moonbitlang/core/debug.Debug] Sourced::to_repr(Sourced[T]) -> @moonbitlang/core/debug.Repr

Source

impl FromConfig for Sourced[T]

FromConfig::from_config

fn[T : FromConfig] from_config(node : ConfigNode) -> Sourced[T] raise ConfigError

Source

UnknownKeys

pub(all) enum UnknownKeys {
  Allow
  Reject
  RejectExcept(Array[String])
} derive(Eq, @moonbitlang/core/debug.Debug)

What bind_or does with a configured key that the bound value does not hold. FromJson ignores unknown keys, so a misspelled key has no effect unless the check is on.

Source

UnknownKeys::equal

fn UnknownKeys::equal(UnknownKeys, UnknownKeys) -> Bool

Source

UnknownKeys::not_equal

fn UnknownKeys::not_equal(x : UnknownKeys, y : UnknownKeys) -> Bool

Source

UnknownKeys::to_repr

fn UnknownKeys::to_repr(UnknownKeys) -> @moonbitlang/core/debug.Repr

Source

Violation

pub(all) struct Violation {
  at : Array[Array[DecodeStep]]
  detail : String
} derive(Eq, @moonbitlang/core/debug.Debug)

A broken validation rule: the paths of the values it names, relative to the bound section, and a detail text. An empty at names the section.

Source

Violation::equal

fn Violation::equal(Violation, Violation) -> Bool

Source

Violation::not_equal

fn Violation::not_equal(x : Violation, y : Violation) -> Bool

Source

Violation::to_repr

fn Violation::to_repr(Violation) -> @moonbitlang/core/debug.Repr

Source

Errors

ConfigError

pub(all) suberror ConfigError {
  Parse(format~ : String, origin~ : String, message~ : String, line~ : Int?, column~ : Int?)
  UnsupportedYaml(origin~ : String, feature~ : String, line~ : Int, column~ : Int)
  InvalidRoot(origin~ : String, found~ : String)
  DuplicateKey(origin~ : String, key~ : KeyPath)
  FileNotFound(path~ : String)
  UnsupportedFormat(path~ : String, extensions~ : Array[String])
  Ambiguous(display~ : String, location~ : String, candidates~ : Array[String])
  InvalidKeyPath(text~ : String, reason~ : String)
  InvalidEnvKey(variable~ : String)
  MergeKey(key~ : KeyPath, index~ : Int, source~ : String)
  InvalidSecret(key~ : KeyPath, origin~ : String, reason~ : String)
  KeyNotFound(key~ : KeyPath)
  Render(format~ : String, key~ : KeyPath, reason~ : String)
  SourceOrder(source~ : String, priority~ : Int, previous~ : String, previous_priority~ : Int)
  OutsideBoundary(start~ : String, boundary~ : String)
  InvalidEnvironmentName(name~ : String, reason~ : String)
  UnknownProject(selector~ : String, workspace~ : String)
  AmbiguousProject(selector~ : String, matches~ : Array[String])
  Decode(failure~ : BindFailure)
  Validation(failures~ : Array[BindFailure])
} derive(Eq, @moonbitlang/core/debug.Debug)

A configuration failure. Each case is one failure class, so a caller can match it without a string compare. The core, conventions, and binding capabilities raise these cases and have no error type of their own.

Source

ConfigError::equal

fn ConfigError::equal(ConfigError, ConfigError) -> Bool

Source

ConfigError::message

fn ConfigError::message(self : ConfigError) -> String

Text for people that describes the failure. Paths show as the error holds them; the host adapter gives them in the / form.

Source

ConfigError::not_equal

fn ConfigError::not_equal(x : ConfigError, y : ConfigError) -> Bool

Source

ConfigError::to_repr

fn ConfigError::to_repr(ConfigError) -> @moonbitlang/core/debug.Repr

Source

SecretError

pub(all) suberror SecretError {
  MissingConfigKey(key~ : KeyPath)
  EmptyEnvironment(variable~ : String)
  FileRead(path~ : String, reason~ : String)
  InvalidSecretValue(reason~ : String)
  CommandFailed(reason~ : String)
  KeyringLookupFailed(reason~ : String)
} derive(Eq, @moonbitlang/core/debug.Debug)

A failure while resolving a secret. Messages never hold the secret or the backend output.

Source

SecretError::equal

fn SecretError::equal(SecretError, SecretError) -> Bool

Source

SecretError::message

fn SecretError::message(self : SecretError) -> String

Text for people that names the failure class and never holds a secret.

Source

SecretError::not_equal

fn SecretError::not_equal(x : SecretError, y : SecretError) -> Bool

Source

SecretError::to_repr

fn SecretError::to_repr(SecretError) -> @moonbitlang/core/debug.Repr

Source

Traits

FromConfig

pub(open) trait FromConfig {
  fn from_config(ConfigNode) -> Self raise ConfigError
}

Exact decoding from the configuration tree. Unlike FromJson, it keeps Ion decimals, timestamps and integers of any size, and it can read the blame of each value.

Source

impl FromConfig for Bool

FromConfig::from_config

fn from_config(node : ConfigNode) -> Bool raise ConfigError

Source

impl FromConfig for Int

FromConfig::from_config

fn from_config(node : ConfigNode) -> Int raise ConfigError

An integer in the range of Int. A fraction fails.

Source

impl FromConfig for Int64

FromConfig::from_config

fn from_config(node : ConfigNode) -> Int64 raise ConfigError

An integer in the range of Int64. A fraction fails.

Source

impl FromConfig for UInt64

FromConfig::from_config

fn from_config(node : ConfigNode) -> UInt64 raise ConfigError

An integer in the range of UInt64. A fraction fails.

Source

impl FromConfig for Double

FromConfig::from_config

fn from_config(node : ConfigNode) -> Double raise ConfigError

A float, an integer or a decimal, as the nearest Double.

Source

impl FromConfig for String

FromConfig::from_config

fn from_config(node : ConfigNode) -> String raise ConfigError

Text or a symbol with text.

Source

impl FromConfig for Option[T]

FromConfig::from_config

fn[T : FromConfig] from_config(node : ConfigNode) -> T? raise ConfigError

None when no source sets the value or the value is a null.

Source

impl FromConfig for BigInt

FromConfig::from_config

fn from_config(node : ConfigNode) -> @moonbitlang/core/bigint.BigInt raise ConfigError

An integer of any size.

Source

impl FromConfig for Array[T]

FromConfig::from_config

fn[T : FromConfig] from_config(node : ConfigNode) -> Array[T] raise ConfigError

Each item of a list, in order.

Source

impl FromConfig for Map[String, T]

FromConfig::from_config

fn[T : FromConfig] from_config(node : ConfigNode) -> Map[String, T] raise ConfigError

Each field of a table, in configuration order.

Source

impl FromConfig for Decimal

FromConfig::from_config

fn from_config(node : ConfigNode) -> @moonrockz/ion/ion.Decimal raise ConfigError

A decimal, or an integer as a decimal with exponent 0. A float fails, because a binary float has no exact decimal scale.

Source

impl FromConfig for Timestamp

FromConfig::from_config

fn from_config(node : ConfigNode) -> @moonrockz/ion/ion.Timestamp raise ConfigError

A timestamp with its precision, fraction and offset.

Source

SecretResolver

pub(open) trait SecretResolver {
  fn resolve(Self, SecretRef, Origin) -> Secret raise SecretError
}

Resolves a secret reference. The origin lets a file resolver anchor a relative path to the directory of the declaring file.

Source

Validate

pub(open) trait Validate {
  fn validate(Self) -> Array[Violation] = _
}

Validation rules that run after decoding. validate is pure: it returns every broken rule and never raises. A type with no rules uses the default, which returns no violations.

Source

impl Validate for Option[T]

Validate::validate

fn[T : Validate] validate(self : T?) -> Array[Violation]

The violations of the value, or none for None.

Source

impl Validate for Array[T]

Validate::validate

fn[T : Validate] validate(self : Array[T]) -> Array[Violation]

The violations of each item, below its list index.

Source

impl Validate for Map[String, T]

Validate::validate

fn[T : Validate] validate(self : Map[String, T]) -> Array[Violation]

The violations of each value, below its key.

Source

Values

add

fn add(builder : ConfigBuilder, source : ConfigSource) -> ConfigBuilder

Add source after the sources that the builder holds.

Source

bind

fn[T : @moonbitlang/core/json.FromJson] bind(config : Config, key : String) -> T raise ConfigError

Decode the section at key into a T. key is the text form of a key path, for example ir or servers."eu.west". A section that no source sets decodes as null, so an Option target gives None. A decode failure raises Decode with the decode path, the decoder detail, and the sources to blame. A secret reference in the section raises Decode, and binding never resolves it. Binding does not change the configuration.

Source

bind_or

fn[T : @moonbitlang/core/json.FromJson + ToJson] bind_or(config : Config, key : String, default : T, unknown? : UnknownKeys) -> T raise ConfigError

Decode the section at key merged over default. The default is written with ToJson, the configured section merges over it with the core merge rules, and the result decodes into a T: tables merge, a configured list or scalar replaces the default, and an absent section keeps the default. A None field of the default is not written, so a configured value fills it. A failure in a value that the default gave has the blame Default. A secret reference in the configured section raises Decode before the merge. The default does not change.

unknown turns on the unknown-key check: with Reject, each configured key that the ToJson form of the result does not hold is a failure with its sources, and all of them raise one Validation error. The check is correct only when ToJson writes every key that FromJson accepts, under the same name; RejectExcept lists the other keys that the type accepts.

Source

bind_root

fn[T : @moonbitlang/core/json.FromJson] bind_root(config : Config) -> T raise ConfigError

Decode the full configuration into a T. Decode paths start at the root.

Source

bind_with

fn[T : FromConfig] bind_with(config : Config, key : String) -> T raise ConfigError

Decode the section at key exactly into a T. A section that no source sets gives a node with no value, so an Option target gives None. A failure raises Decode with the decode path and the sources to blame. Binding never resolves a secret reference: only SecretRef accepts one.

Source

bool

fn bool(value : Bool) -> ConfigValue

A Boolean value.

Source

build

fn build(sources : Array[ConfigSource]) -> Config raise ConfigError

Load the sources in list order over a complete empty file tree: a later source wins. A file source raises FileNotFound, so this suits value sources.

Source

builder

fn builder() -> ConfigBuilder

A builder with no sources, no formats, and no run inputs.

Source

default_redact_fragments

fn default_redact_fragments() -> Array[String]

The Morphir key-name fragments that mark a sensitive key.

Source

defaults

fn defaults(builder : ConfigBuilder, json : Json) -> ConfigBuilder raise ConfigError

Add a defaults source from a JSON value, for example Defaults::default().to_json().

Source

env

fn env(builder : ConfigBuilder, prefix~ : String, reserved? : Array[String], selection? : SourceSelection[Map[String, String]]) -> ConfigBuilder

Add an environment variable source, as ConfigSource::env gives it.

Source

env_resolver

fn env_resolver(vars : Map[String, String]) -> EnvResolver

A resolver over vars. File, command, and keyring references raise InvalidSecretValue.

Source

env_vars

fn env_vars(builder : ConfigBuilder, vars : Map[String, String]) -> ConfigBuilder

Set the variable set of the run. Source providers read variables only from this set.

Source

explain

fn explain(config : Config, key : String) -> Array[(KeyPath, Array[Origin])] raise ConfigError

The origins of key: one entry for a leaf, or each descendant leaf for a struct. A missing key raises KeyNotFound.

Source

fields

fn fields(fields : Array[(String, ConfigValue)]) -> ConfigValue

A struct value with the fields in the given order. When a name occurs more than once, the last value wins at the position of the first.

Source

file

fn file(builder : ConfigBuilder, path : String, role? : FileRole, name? : String, priority? : Int) -> ConfigBuilder

Add a file source at an explicit path, as ConfigSource::file gives it.

Source

float

fn float(value : Double) -> ConfigValue

A floating-point value.

Source

format

fn format(builder : ConfigBuilder, format : Format) -> ConfigBuilder

Register format after the formats that the builder holds.

Source

get_json

fn get_json(config : Config, key : String) -> Json raise ConfigError

The value at the key path key as a JSON object with the fields key and value, after redaction. A missing key raises KeyNotFound.

Source

get_text

fn get_text(config : Config, key : String) -> String raise ConfigError

The value at the key path key as text, after redaction: a string gives its text, and any other value gives compact JSON. A missing key raises KeyNotFound.

Source

in_memory

fn in_memory(value : ConfigValue, name? : String, priority? : Int) -> ConfigSource raise ConfigError

An in-memory source from a value tree. The root must be a struct.

Source

in_memory_pairs

fn in_memory_pairs(pairs : Array[(String, ConfigValue)], name? : String, priority? : Int) -> ConfigSource raise ConfigError

An in-memory source from flat key-path pairs, for example ("ir.layout", @config.string("tree")). Pairs apply in list order with the merge rules, so a later pair wins. Pair values keep their type.

Source

int

fn int(value : Int64) -> ConfigValue

An integer value.

Source

list

fn list(items : Array[ConfigValue]) -> ConfigValue

A list value.

Source

load

fn load(builder : ConfigBuilder, tree : FileTree) -> LoadStep[Config] raise ConfigError

Load the configuration from the builder and the file tree. This is pure: it reads only its inputs and gives the same result on every target.

It runs each provider at its position, then checks the priorities over the expanded list and raises SourceOrder when a priority decreases. When a provider or a file source needs a path that the tree does not know, it gives all such requests in one Need. Otherwise it parses, excludes, and merges the sources in list order and gives Done.

Source

merge

fn merge(base : ConfigValue, overlay : ConfigValue, policy? : MergePolicy, key_policies? : Array[(KeyPath, MergePolicy)], source? : String, secret_syntax? : SecretSyntax) -> ConfigValue raise ConfigError

Merge overlay over base. A null overlay keeps the base value. A secret reference replaces and is not merged with a struct. Two structs merge field by field, with base fields first and new overlay fields after. Two lists use policy, or a matching entry of key_policies when one exists for the path. In all other cases the overlay value wins. The inputs do not change, and unchanged subtrees are shared.

Source

named

fn[T] named(config : Config, key : String, bind_one : (Config, String) -> Options[T] raise ConfigError) -> NamedOptions[T] raise ConfigError

Bind each child of the section at key as one named instance. bind_one gets the configuration and the key text of one child, for example backends.ts, and gives its options value; bind, bind_or and bind_with with validated all fit. Each options value gets the child name as its instance name. The Decode and Validation failures of all instances raise one Validation error. A section that no source sets gives no instances. A section that is not a table raises Decode.

Source

nested

fn nested(field : String, found : Array[Violation]) -> Array[Violation]

The violations of the value in field, with each path moved below field. A violation of the whole nested value names field.

Source

options

fn[T : @moonbitlang/core/json.FromJson + Validate] options(config : Config, key : String) -> Options[T] raise ConfigError

Bind the section at key and validate it: bind, then validated.

Source

overrides

fn overrides(builder : ConfigBuilder, pairs : Array[(String, ConfigValue)]) -> ConfigBuilder raise ConfigError

Add an overrides source from key-path pairs.

Source

parse_file

fn parse_file(formats : Array[Format], path : String, text : String) -> ConfigValue raise ConfigError

Parse the text of the file path with the format that its extension selects from formats. The extension compares in lowercase. No match raises UnsupportedFormat with the registered extensions.

Source

path_json

fn path_json(reports : Array[SourceReport]) -> Json

Source reports as JSON, in ascending priority (merge order).

Source

path_text

fn path_text(reports : Array[SourceReport]) -> String

Source reports as text: highest priority first.

Source

platform

fn platform(builder : ConfigBuilder, p : Platform) -> ConfigBuilder

Set the platform of the run.

Source

provider

fn provider(builder : ConfigBuilder, p : SourceProvider) -> ConfigBuilder

Add a source provider. During the load, its sources take its place in merge order.

Source

redact

fn redact(value : ConfigValue, fragments? : Array[String]) -> ConfigValue

A copy of value with each sensitive subtree replaced by the text <redacted>. A key is sensitive when its name, in lowercase with - changed to _, holds a fragment. The default fragment list is Morphir's.

Source

secret_syntax

fn secret_syntax(builder : ConfigBuilder, syntax : SecretSyntax) -> ConfigBuilder

Set whether one-field env / file / command / keyring structs are secret references. The default is SecretSyntax::standard().

Source

show

fn show(config : Config, format : ShowFormat) -> String raise ConfigError

Render the redacted configuration as TOML, JSON, or Ion text.

Source

string

fn string(text : String) -> ConfigValue

A string value.

Source

validated

fn[T : Validate] validated(value : T, config : Config, key : String, name? : String) -> Options[T] raise ConfigError

Validate value, the section at key of config, and give it as an options value. Each violation becomes a failure with its full decode path and the sources to blame, and all of them raise one Validation. The value comes first, so validated ends a binding pipeline: config |> bind_or("ir", default) |> validated(config, "ir").

Source

violation

fn violation(fields : Array[String], detail : String) -> Violation

A violation that names one field of the section for each name in fields, or the section itself when fields is empty. A rule over two fields names both, so the error shows the source of each value.

Source

working_dir

fn working_dir(builder : ConfigBuilder, dir : String) -> ConfigBuilder

Set the working directory of the run. A relative explicit file path joins it.

Source