Skip to content

Commit 7363040

Browse files
committed
refactor: remove NewDefaultFileConfigProvider function
- Remove NewDefaultFileConfigProvider() from file/provider.go - Update documentation to reflect single constructor pattern - Replace factory method examples with explicit NewFileConfigProvider(configFile) usage - Update architecture docs to emphasize --config flag support over factory methods - Simplify API by having only one constructor for FileConfigProvider This simplifies the API surface and makes config file handling more explicit. The --config flag implementation now provides all the functionality that the factory method was intended to provide, but with better user control and transparency.
1 parent 42ad811 commit 7363040

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

docs/architecture/configuration.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -330,24 +330,25 @@ stacks:
330330
The file provider offers two creation methods to support different architectural needs:
331331

332332
```go
333-
// Method 1: Explicit filename (for custom config files)
334-
provider := file.NewFileConfigProvider("custom-config.yaml")
333+
// Create file provider with explicit filename
334+
provider := file.NewFileConfigProvider("stackaroo.yaml")
335335
336-
// Method 2: Default factory (recommended - no hardcoded filenames)
337-
provider := file.NewDefaultFileConfigProvider() // Uses "stackaroo.yaml"
336+
// Or with custom config file
337+
provider := file.NewFileConfigProvider("custom-config.yaml")
338338
```
339339

340-
**Architectural Benefits of `NewDefaultFileConfigProvider()`:**
341-
- **Encapsulates filename knowledge** - Consumer modules don't need to know config filename
342-
- **Consistent defaults** - All applications use same config file name
343-
- **Easy configuration** - Single source of truth for default behavior
340+
**Architectural Benefits:**
341+
- **Explicit configuration** - Clear specification of config file location
342+
- **Flexible configuration** - Support for custom config file names via --config flag
343+
- **Consistent interface** - Single constructor pattern for all use cases
344344
- **Testable** - Mock providers can use different factory implementations
345345

346346
### **Loading Configuration**
347347

348348
```go
349-
// Create file provider with default config file
350-
provider := file.NewDefaultFileConfigProvider()
349+
// Create file provider with specified config file
350+
configFile := "stackaroo.yaml" // From --config flag or default
351+
provider := file.NewFileConfigProvider(configFile)
351352
352353
// Load configuration for specific context
353354
cfg, err := provider.LoadConfig(ctx, "prod")
@@ -357,8 +358,6 @@ if err != nil {
357358
358359
// Access resolved configuration
359360
fmt.Printf("Deploying to account: %s\n", cfg.Context.Account)
360-
fmt.Printf("Region: %s\n", cfg.Context.Region)
361-
fmt.Printf("Stacks: %d\n", len(cfg.Stacks))
362361
```
363362

364363
### **Individual Stack Access**

docs/architecture/resolver.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ flowchart LR
202202

203203
```go
204204
// Example usage in deploy command
205-
configProvider := file.NewDefaultFileConfigProvider() // No hardcoded filename
205+
configFile := "stackaroo.yaml" // From --config flag or default
206+
configProvider := file.NewFileConfigProvider(configFile)
206207
templateReader := &resolve.FileTemplateReader{}
207208
resolver := resolve.NewStackResolver(configProvider, templateReader)
208209

@@ -244,11 +245,11 @@ graph TD
244245

245246
#### **cmd/deploy Module**
246247
- **Pure CLI orchestration** - No file system knowledge
247-
- **Uses factory methods** - `file.NewDefaultFileConfigProvider()` instead of hardcoded filenames
248+
- **Uses explicit config files** - `file.NewFileConfigProvider(configFile)` with --config flag support
248249
- **Dependency injection** - Accepts resolver and configuration provider interfaces
249250

250251
#### **config/file Module**
251-
- **Owns "stackaroo.yaml" filename** - Via `NewDefaultFileConfigProvider()` factory
252+
- **Handles config file resolution** - Via --config flag with "stackaroo.yaml" default
252253
- **Path-to-URI conversion** - Converts relative paths to `file://` URIs
253254
- **Configuration file knowledge** - Understands YAML structure and resolution
254255

internal/config/file/provider.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ func NewFileConfigProvider(filename string) *FileConfigProvider {
2828
}
2929
}
3030

31-
// NewDefaultFileConfigProvider creates a new file-based ConfigProvider using the default config filename
32-
func NewDefaultFileConfigProvider() *FileConfigProvider {
33-
return NewFileConfigProvider("stackaroo.yaml")
34-
}
35-
3631
// LoadConfig loads and resolves configuration for the specified context
3732
func (fp *FileConfigProvider) LoadConfig(ctx context.Context, context string) (*config.Config, error) {
3833
// Load raw config if not already loaded

0 commit comments

Comments
 (0)