config
napt.config
Configuration loading and management for NAPT.
This module provides tools for loading, merging, and validating YAML-based configuration files with a layered approach:
- Organization-wide defaults (defaults/org.yaml)
- Vendor-specific defaults (defaults/vendors/{Vendor}.yaml)
- Recipe-specific configuration (recipes/{Vendor}/{app}.yaml)
The loader performs deep merging where dicts are merged recursively and lists/scalars are replaced (last wins). Relative paths are resolved against the recipe file location for relocatability.
Example
Basic usage:
load_effective_config
Loads and merges the effective configuration for a recipe.
Performs the following operations:
- Read recipe YAML
- Find defaults root by scanning upwards for defaults/org.yaml
- Load org defaults (required if defaults root exists)
- Determine vendor (param vendor > folder name > recipe contents)
- Load vendor defaults if present
- Merge: org -> vendor -> recipe (dicts deep-merge, lists replace)
- Resolve known relative paths (relative to the recipe directory)
- Inject dynamic fields (AppScriptDate = today if absent)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
recipe_path
|
Path
|
Path to the recipe YAML file. |
required |
vendor
|
str | None
|
Optional vendor name override. If not provided, vendor is detected from the folder name or recipe contents. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A merged configuration dict ready for downstream processors. If no defaults were found in the tree, the recipe is returned as-is (with path resolution and injection). |
Raises:
| Type | Description |
|---|---|
ConfigError
|
On YAML parse errors, empty files, invalid structure, or if the recipe file is missing. |
Source code in napt/config/loader.py
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 | |