Skip to content

Commit 8d70f26

Browse files
committed
docs: Add ADR for custom configuration file paths
- Added ADR-009 for supporting custom configuration file paths - Created a separate ADR template file - Updated README.md to reference the template file - Moved 'Creating New ADRs' section to the top of README.md
1 parent e7147d8 commit 8d70f26

File tree

3 files changed

+157
-17
lines changed

3 files changed

+157
-17
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# 9. Custom Configuration File Paths
2+
3+
Date: 2025-02-27
4+
5+
## Status
6+
7+
Proposed
8+
9+
## Context
10+
11+
Currently, the Helm Values Manager uses hardcoded file paths for its configuration and lock files:
12+
- Configuration file: `helm-values.json`
13+
- Lock file: `.helm-values.lock`
14+
15+
These paths are defined in the `BaseCommand` class and used across all commands. This approach has several limitations:
16+
17+
1. **Limited Flexibility**: Users cannot manage multiple configurations in the same directory
18+
2. **Naming Constraints**: Organizations may have specific naming conventions that conflict with our hardcoded names
19+
3. **Integration Challenges**: Difficult to integrate with existing systems that might have their own file organization
20+
4. **Location Restrictions**: Configuration files must be in the current working directory
21+
22+
Users have expressed interest in being able to specify custom file paths for their configuration files, which would address these limitations and provide greater flexibility.
23+
24+
## Decision
25+
26+
We will enhance the Helm Values Manager to support custom configuration file paths by:
27+
28+
1. **Adding a `--config-file` option to all commands**:
29+
```python
30+
config_file: str = typer.Option(
31+
"helm-values.json",
32+
"--config-file",
33+
"-c",
34+
help="Path to the configuration file"
35+
)
36+
```
37+
38+
2. **Updating the `BaseCommand` class to accept a config file path**:
39+
```python
40+
def __init__(self, config_file: str = "helm-values.json") -> None:
41+
"""Initialize the base command.
42+
43+
Args:
44+
config_file: Path to the configuration file
45+
"""
46+
self.config_file = config_file
47+
self.lock_file = self._generate_lock_file_path(config_file)
48+
self._lock_fd: Optional[int] = None
49+
```
50+
51+
3. **Generating the lock file name based on the config file path**:
52+
```python
53+
def _generate_lock_file_path(self, config_file: str) -> str:
54+
"""Generate the lock file path based on the config file path.
55+
56+
Args:
57+
config_file: Path to the configuration file
58+
59+
Returns:
60+
str: Path to the lock file
61+
"""
62+
config_path = Path(config_file)
63+
lock_file = f".{config_path.name}.lock"
64+
return str(config_path.parent / lock_file)
65+
```
66+
67+
4. **Propagating the config file path to all command instances**:
68+
```python
69+
@app.command()
70+
def init(
71+
release_name: str = typer.Option(..., "--release", "-r", help="Name of the Helm release"),
72+
config_file: str = typer.Option("helm-values.json", "--config-file", "-c", help="Path to the configuration file"),
73+
):
74+
"""Initialize a new helm-values configuration."""
75+
command = InitCommand(config_file=config_file)
76+
result = command.execute(release_name=release_name)
77+
echo(result)
78+
```
79+
80+
## Consequences
81+
82+
### Positive
83+
84+
1. **Increased Flexibility**: Users can manage multiple configurations in the same directory
85+
2. **Custom Naming**: Organizations can follow their own naming conventions
86+
3. **Better Integration**: Easier to integrate with existing systems and workflows
87+
4. **Location Freedom**: Configuration files can be placed in any directory
88+
89+
### Negative
90+
91+
1. **API Change**: All command functions need to be updated to accept the new parameter
92+
2. **Complexity**: Slightly more complex code to handle different file paths
93+
3. **Testing**: Additional test cases needed to verify the functionality
94+
4. **Documentation**: Documentation needs to be updated to reflect the new option
95+
96+
### Neutral
97+
98+
1. **Backward Compatibility**: Default values ensure backward compatibility with existing usage
99+
2. **Lock File Naming**: Lock files will be named based on the configuration file name
100+
101+
## Implementation Notes
102+
103+
1. The implementation should be backward compatible, using the current hardcoded paths as defaults
104+
2. All commands should propagate the config file path to their respective command instances
105+
3. Documentation should be updated to reflect the new option
106+
4. Tests should be added to verify the functionality with custom file paths
107+
108+
## Related Issues
109+
110+
- GitHub Issue #[TBD]: Support for custom configuration file paths

docs/ADRs/README.md

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ This directory contains Architecture Decision Records (ADRs) for the Helm Values
55
## What is an ADR?
66
An Architecture Decision Record (ADR) is a document that captures an important architectural decision made along with its context and consequences.
77

8+
## Creating New ADRs
9+
10+
For new ADRs, use the [ADR template](adr-template.md) as a starting point.
11+
812
## ADR Index
913

1014
### [ADR-001: Helm Values Manager as a Helm Plugin](001-helm-values-manager.md)
@@ -61,20 +65,9 @@ An Architecture Decision Record (ADR) is a document that captures an important a
6165
- **Decision**: Remove registry in favor of direct command instantiation
6266
- **Impact**: Simplifies code and aligns better with Typer's design
6367

64-
## ADR Template
65-
For new ADRs, use this template:
66-
```markdown
67-
# ADR-NNN: Title
68-
69-
## Status
70-
[Proposed | Accepted | Deprecated | Superseded]
71-
72-
## Context
73-
What is the issue that we're seeing that is motivating this decision or change?
74-
75-
## Decision
76-
What is the change that we're proposing and/or doing?
77-
78-
## Consequences
79-
What becomes easier or more difficult to do because of this change?
80-
```
68+
### [ADR-009: Custom Configuration File Paths](009-custom-configuration-file-paths.md)
69+
- **Status**: Proposed
70+
- **Context**: Limited flexibility with hardcoded configuration file paths
71+
- **Decision**: Add support for custom configuration file paths
72+
- **Impact**: Increases flexibility and improves integration capabilities
73+
- **Dependencies**: ADR-001

docs/ADRs/adr-template.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# ADR-NNN: Title
2+
3+
Date: YYYY-MM-DD
4+
5+
## Status
6+
7+
[Proposed | Accepted | Deprecated | Superseded]
8+
9+
## Context
10+
11+
What is the issue that we're seeing that is motivating this decision or change?
12+
13+
## Decision
14+
15+
What is the change that we're proposing and/or doing?
16+
17+
## Consequences
18+
19+
### Positive
20+
21+
What becomes easier because of this change?
22+
23+
### Negative
24+
25+
What becomes more difficult because of this change?
26+
27+
### Neutral
28+
29+
What other effects does this change have?
30+
31+
## Implementation Notes
32+
33+
Additional notes on implementation details, if applicable.
34+
35+
## Related Issues
36+
37+
- GitHub Issue #[TBD]: Related issue title

0 commit comments

Comments
 (0)