-
Notifications
You must be signed in to change notification settings - Fork 279
Open
Labels
Description
What?
In the same way @env()
and @akv()
allow for string replacements in the DAB configuration, introduce @file()
which will read from a designated JSON file with a simple name/value dictionary <string, string>
.
Configuration
{
"metadata-file": {
"path": "./metadata.json"
}
}
Rules
These rules govern the implementation.
- Any property name or value can be set using
@file()
. - The
@file()
function is a string replacement in the same way@env()
and@akv()
are. - The metadata file cannot have duplicate keys (this is a core feature of a dictionary already).
- The metadata file is read before configuration parsing and is not hot-reloaded.
Order of operation
For string replacement in the configuration:
@env()
is first and optional.@akv()
is second and optional.@file()
is third and optional.
sequenceDiagram
actor Engine as Engine
participant ConfigInMem as ConfigInMem
participant Environment as Environment
participant AKV as AKV
participant File as MetadataFile
participant Config as ConfigFile
Engine ->> Engine: Pre-Start
Engine ->> Config: Load Config
Config -->> Engine: Config Data
Engine ->> ConfigInMem: Create In-Memory Config
Note over Engine: Perform Config Replacements
activate Engine
ConfigInMem -->> Engine: Parse @env Values
Engine ->> Environment: Get
Environment -->> Engine: Values
Engine ->> ConfigInMem: Replace @env Values
deactivate Engine
Note over Engine: Use Config With ENV Replacements
activate Engine
ConfigInMem -->> Engine: Parse @akv Values
Engine ->> AKV: Request
AKV -->> Engine: Secrets
Engine ->> ConfigInMem: Replace @akv Values
deactivate Engine
Note over Engine: Use Config With AKV Replacements
activate Engine
ConfigInMem -->> Engine: Parse @file Values
Engine ->> File: Read
File -->> Engine: Key/Value Pairs
Engine ->> ConfigInMem: Replace @file Values
deactivate Engine
Note over Engine: Use Config With FILE Replacements
Engine ->> Engine: Start
Now: this means metadata-file.path
could be set using @env()
or @akv
if the developer wants to.
JSON schema
metadata-file
is an optional property of typeobject
.metadata-file.path
is an optional property of typestring
.- There are no schema-level constraints for these properties.
Command line
Configuration
- Add
dab configure --metadata-file.path './file.json'
.
Validation & errors
These rules are implemented in dab validate
and dab start
:
- If
@file()
is present in the configuration, thenmetadata-file.path
is required. - If
metadata-file.path
is set using@file()
, then throw an exception. - If
metadata-file.path
does not point to an existing file, then throw an exception. - If
metadata-file.path
does not contain valid JSON with a<string, string>
dictionary, then throw an exception. - If a
@file(key)
reference is not found in the metadata file, then throw an exception. - If
metadata-file.path
is defined but no@file(key)
references are present, then do not throw an exception.
Metadata file format
This format is intentionally as simple as possible.
{
"key1": "value",
"key2": "value"
}
Configuration sample
This sample shows how both names and values can be replaced using @file()
.
{
"metadata-file": {
"path": "./metadata.json"
},
"entities": {
"@file('dbo.Users.Alias')": {
"description": "@file('dbo.Users.MS_Description')",
"source": {
"object": "dbo.User",
"type": "table"
}
}
}
}
Consideration
- Include an OTEL activity wrapping the replacement.
- (Would be nice) Include an OTEL activity wrapping the replacement for
@env()
and@akv()
.