@@ -6,7 +6,7 @@ Complete guide to configuring CostCutter.
66
77CostCutter merges configuration from multiple sources in this order (later sources override earlier ones):
88
9- 1 . ** Default Config** - Built-in defaults (` src/costcutter/conf/ config.yaml ` )
9+ 1 . ** Default Config** - Built-in defaults (defined in ` src/costcutter/config.py ` )
10102 . ** Home Config** - User's home directory (` ~/.costcutter.{yaml,yml,toml,json} ` )
11113 . ** Explicit File** - File specified via ` --config ` flag or ` config_file ` parameter
12124 . ** Environment Variables** - Shell environment variables with ` COSTCUTTER_ ` prefix
@@ -18,7 +18,7 @@ CostCutter merges configuration from multiple sources in this order (later sourc
1818
1919### Method 1: Default Configuration (Built-in)
2020
21- Located at ` src/costcutter/conf/ config.yaml ` . Used automatically if no other config is provided.
21+ Defined in ` src/costcutter/config.py ` . Used automatically if no other config is provided.
2222
2323** Default Configuration:**
2424
@@ -114,9 +114,9 @@ costcutter --config /path/to/myconfig.yaml
114114
115115` ` ` python
116116from pathlib import Path
117- from costcutter.conf. config import get_config
117+ from costcutter.config import load_config
118118
119- config = get_config(config_file=Path("/path/to/myconfig.yaml") )
119+ config = load_config( )
120120` ` `
121121
122122**Supported formats:** `.yaml`, `.yml`, `.toml`, `.json`
@@ -177,12 +177,12 @@ export COSTCUTTER_AWS__SERVICES="[ec2, s3]" # List
177177
178178` ` ` python
179179import os
180- from costcutter.conf. config import get_config
180+ from costcutter.config import load_config
181181
182182os.environ["COSTCUTTER_DRY_RUN"] = "false"
183183os.environ["COSTCUTTER_AWS__REGION"] = "[us-east-1]"
184184
185- config = get_config ()
185+ config = load_config ()
186186` ` `
187187
188188**Priority:** Overrides defaults, home config, and explicit files. Only CLI arguments have higher priority.
@@ -207,7 +207,7 @@ costcutter --config myconfig.yaml --dry-run
207207**Python API:**
208208
209209` ` ` python
210- from costcutter.conf. config import get_config
210+ from costcutter.config import load_config
211211
212212cli_overrides = {
213213 "dry_run": False,
@@ -216,7 +216,7 @@ cli_overrides = {
216216 }
217217}
218218
219- config = get_config(cli_args =cli_overrides)
219+ config = load_config(overrides =cli_overrides)
220220` ` `
221221
222222**Priority:** Highest priority. Overrides all other sources.
@@ -228,11 +228,11 @@ Import and configure programmatically:
228228# ## Basic Usage
229229
230230` ` ` python
231- from costcutter.conf. config import get_config
231+ from costcutter.config import load_config
232232from costcutter.orchestrator import orchestrate_services
233233
234234# Load default config
235- config = get_config ()
235+ config = load_config ()
236236
237237# Run cleanup
238238orchestrate_services(dry_run=True)
@@ -241,53 +241,42 @@ orchestrate_services(dry_run=True)
241241# ## Custom Configuration
242242
243243` ` ` python
244- from pathlib import Path
245- from costcutter.conf.config import get_config
244+ from costcutter.config import load_config
246245
247- # Method 1: Use config file
248- config = get_config(config_file=Path("./myconfig.yaml") )
246+ # Method 1: Load with defaults (auto-discovers config files)
247+ config = load_config( )
249248
250- # Method 2: Override via CLI args
251- config = get_config(cli_args ={
249+ # Method 2: Override via runtime parameters
250+ config = load_config(overrides ={
252251 "dry_run": False,
253252 "aws": {
254253 "region": ["us-west-2"],
255254 "services": ["ec2", "s3"]
256255 }
257256})
258-
259- # Method 3: Combine both
260- config = get_config(
261- config_file=Path("./base.yaml"),
262- cli_args={"dry_run": False}
263- )
264257` ` `
265258
266259# ## Reload Configuration
267260
268261` ` ` python
269- from costcutter.conf. config import reload_config
262+ from costcutter.config import load_config
270263
271264# Reload with new settings
272- config = reload_config(cli_args ={"dry_run": False})
265+ config = load_config(overrides ={"dry_run": False})
273266` ` `
274267
275268# ## Access Configuration Values
276269
277270` ` ` python
278- config = get_config ()
271+ config = load_config ()
279272
280273# Dot notation
281274print(config.dry_run)
282275print(config.aws.region)
283276print(config.logging.level)
284277
285- # Dictionary notation
286- print(config["dry_run"])
287- print(config["aws"]["region"])
288-
289278# Convert to dict
290- config_dict = config.to_dict ()
279+ config_dict = config.model_dump ()
291280print(config_dict["aws"]["services"])
292281` ` `
293282
@@ -525,22 +514,18 @@ costcutter
525514
526515` ` ` python
527516# cleanup.py
528- from pathlib import Path
529- from costcutter.conf.config import get_config
517+ from costcutter.config import load_config
530518from costcutter.orchestrator import orchestrate_services
531519from costcutter.logger import setup_logging
532520
533- # Load configuration
534- config = get_config(
535- config_file=Path("./config.yaml"),
536- cli_args={
537- "dry_run": False,
538- "aws": {
539- "region": ["us-east-1"],
540- "services": ["ec2"]
541- }
521+ # Load configuration with overrides
522+ config = load_config(overrides={
523+ "dry_run": False,
524+ "aws": {
525+ "region": ["us-east-1"],
526+ "services": ["ec2"]
542527 }
543- )
528+ } )
544529
545530# Setup logging
546531setup_logging(config)
@@ -644,10 +629,10 @@ costcutter --config myconfig.txt
644629**Debug configuration:**
645630
646631` ` ` python
647- from costcutter.conf. config import get_config
632+ from costcutter.config import load_config
648633
649- config = get_config ()
650- print(config.to_dict ()) # See final merged config
634+ config = load_config ()
635+ print(config.model_dump ()) # See final merged config
651636` ` `
652637
653638# ## Environment variables not working
@@ -662,7 +647,7 @@ print(config.to_dict()) # See final merged config
662647
663648` ` ` bash
664649export COSTCUTTER_DRY_RUN=false
665- python -c "import os; from costcutter.conf. config import get_config ; print(get_config ().dry_run)"
650+ python -c "import os; from costcutter.config import load_config ; print(load_config ().dry_run)"
666651# Should print: False
667652` ` `
668653
0 commit comments