Some checks failed
Rust CI / Security Audit (push) Has been cancelled
Rust CI / Check + Test + Lint (nightly) (push) Has been cancelled
Rust CI / Check + Test + Lint (stable) (push) Has been cancelled
mdBook Build & Deploy / Build mdBook (push) Has been cancelled
Nickel Type Check / Nickel Type Checking (push) Has been cancelled
mdBook Build & Deploy / Documentation Quality Check (push) Has been cancelled
mdBook Build & Deploy / Deploy to GitHub Pages (push) Has been cancelled
mdBook Build & Deploy / Notification (push) Has been cancelled
40 lines
1.3 KiB
Plaintext
40 lines
1.3 KiB
Plaintext
# Helper functions for configuration composition
|
|
#
|
|
# Provides utilities for merging base schemas with deployment mode overlays
|
|
# and composing final configurations.
|
|
|
|
{
|
|
# Merge configuration records with override support
|
|
# apply_merge : record -> record -> record
|
|
apply_merge = fun defaults overrides =>
|
|
defaults & overrides,
|
|
|
|
# Compose final configuration from base schema, mode defaults, and user customizations
|
|
# compose_config : record -> record -> record -> record
|
|
compose_config = fun schema mode_defaults user_customizations =>
|
|
let base = schema in
|
|
let with_mode = base & mode_defaults in
|
|
with_mode & user_customizations,
|
|
|
|
# Validate required fields are not empty (for sensitive configs)
|
|
# validate_non_empty : String -> String -> {Bool}
|
|
validate_non_empty = fun field_name value =>
|
|
if std.string.length value > 0 then
|
|
{valid = true}
|
|
else
|
|
{
|
|
valid = false,
|
|
error = "Field '%{field_name}' must not be empty",
|
|
},
|
|
|
|
# Convert config to JSON for export
|
|
# to_json : record -> String
|
|
to_json = fun config =>
|
|
config | std.serialize 'Json,
|
|
|
|
# Convert config to TOML-compatible JSON (removes nested Nickel types)
|
|
# to_toml : record -> String
|
|
to_toml = fun config =>
|
|
config | std.serialize 'Json,
|
|
}
|