Skip to content

Commit 7879f61

Browse files
authored
Merge pull request #10 from Zipstack/feature/value-class-implementation
feat(models): Implement Value class for configuration management
2 parents 8b82f54 + ace1483 commit 7879f61

File tree

15 files changed

+946
-136
lines changed

15 files changed

+946
-136
lines changed

CONTRIBUTING.md

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,53 @@ We use GitHub to host code, to track issues and feature requests, as well as acc
1919
5. Make sure your code passes all code quality checks.
2020
6. Issue that pull request!
2121

22+
## Version Control Guidelines
23+
24+
### Branch Naming
25+
- Feature branches: `feature/short-description`
26+
- Bug fixes: `fix/issue-description`
27+
- Documentation: `docs/what-changed`
28+
- Release branches: `release/version-number`
29+
30+
### Commit Messages
31+
Follow the [Conventional Commits](https://www.conventionalcommits.org/) specification:
32+
```
33+
<type>[optional scope]: <description>
34+
35+
[optional body]
36+
37+
[optional footer(s)]
38+
```
39+
40+
Types:
41+
- `feat`: New feature
42+
- `fix`: Bug fix
43+
- `docs`: Documentation only changes
44+
- `style`: Changes that do not affect the meaning of the code
45+
- `refactor`: Code change that neither fixes a bug nor adds a feature
46+
- `test`: Adding missing tests or correcting existing tests
47+
- `chore`: Changes to the build process or auxiliary tools
48+
49+
Example:
50+
```
51+
feat(value): add support for remote storage backends
52+
53+
- Implement ValueBackend interface
54+
- Add AWS Secrets Manager backend
55+
- Add Azure Key Vault backend
56+
57+
Closes #123
58+
```
59+
60+
## Important Documentation
61+
62+
Before contributing, please review these important documents:
63+
64+
1. [Code Structure](docs/Development/code-structure.md) - Understanding the codebase organization
65+
2. [Testing Guide](docs/Development/testing.md) - Testing standards and practices
66+
3. [Architecture Overview](docs/Design/low-level-design.md) - System architecture and design decisions
67+
4. [ADRs](docs/ADRs/) - Architecture Decision Records
68+
2269
## Development Setup
2370

2471
1. Clone your fork:
@@ -86,12 +133,6 @@ tox -e py39 # For Python 3.9
86133
- Follow Google style for docstrings
87134
- Keep the README.md and other documentation up to date
88135

89-
### Documentation Requirements
90-
91-
- Use docstrings for all public modules, functions, classes, and methods
92-
- Follow Google style for docstrings
93-
- Keep the README.md and other documentation up to date
94-
95136
#### Required Extensions
96137

97138
When contributing to documentation, please note that we use the following extensions:
@@ -115,7 +156,7 @@ To preview Mermaid diagrams locally, you can:
115156

116157
## Any contributions you make will be under the MIT Software License
117158

118-
In short, when you submit code changes, your submissions are understood to be under the same [MIT License](LICENSE) that covers the project. Feel free to contact the maintainers if that's a concern.
159+
In short, when you submit code changes, your submissions are understood to be under the same [MIT License](./LICENSE) that covers the project. Feel free to contact the maintainers if that's a concern.
119160

120161
## Report bugs using GitHub's [issue tracker](https://github.com/zipstack/helm-values-manager/issues)
121162

@@ -135,4 +176,4 @@ We use GitHub issues to track public bugs. Report a bug by [opening a new issue]
135176

136177
## License
137178

138-
By contributing, you agree that your contributions will be licensed under its MIT License.
179+
By contributing, you agree that your contributions will be licensed under its [MIT License](./LICENSE).

docs/ADRs/001-helm-values-manager.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Managing configurations and secrets across multiple Kubernetes deployments is a
99
Key challenges include:
1010
- Ensuring configurations remain consistent across different environments (e.g., dev, staging, production).
1111
- Managing sensitive values securely using external secret management systems.
12-
- Automating the generation of `values.json` while integrating with GitOps tools like ArgoCD.
12+
- Automating the generation of `values.yaml` while integrating with GitOps tools like ArgoCD.
1313
- Providing a user-friendly CLI that integrates well with Helm workflows.
1414

1515
## Decision
@@ -22,7 +22,7 @@ We have decided to implement the **Helm Values Manager** as a **Helm plugin writ
2222
4. **Secret Storage Abstraction:** Securely manages sensitive values by integrating with AWS Secrets Manager, Azure Key Vault, and HashiCorp Vault.
2323
5. **CLI-Based Approach:** Interactive commands for managing configurations and secrets.
2424
6. **Autocomplete Support:** Smooth CLI experience.
25-
7. **ArgoCD Compatibility:** Generates `values.json` dynamically for GitOps workflows.
25+
7. **ArgoCD Compatibility:** Generates `values.yaml` dynamically for GitOps workflows.
2626
8. **JSON for Configuration:** Using JSON for configuration files provides better schema validation and consistent parsing across different platforms.
2727

2828
### Value Storage Model
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# ADR-005: Unified Backend Approach for Value Storage
2+
3+
## Status
4+
Proposed
5+
6+
## Context
7+
Currently, the Value class handles two distinct storage types: local and remote. This creates a split in logic within the Value class, requiring different code paths and validation rules based on the storage type. This complexity makes the code harder to maintain and test.
8+
9+
## Decision
10+
We will remove the storage_type distinction from the Value class and implement a SimpleValueBackend for non-sensitive data (previously handled as "local" storage). This means:
11+
12+
1. Value class will:
13+
- Only interact with backends through a unified interface
14+
- Not need to know about storage types
15+
- Have simpler logic and better separation of concerns
16+
17+
2. Storage backends will:
18+
- Include a new SimpleValueBackend for non-sensitive data
19+
- All implement the same ValueBackend interface
20+
- Be responsible for their specific storage mechanisms
21+
22+
3. Configuration will:
23+
- Use SimpleValueBackend internally for non-sensitive values
24+
- Use secure backends (AWS/Azure) for sensitive values
25+
- Backend selection handled by the system based on value sensitivity
26+
27+
## Consequences
28+
29+
### Positive
30+
1. **Cleaner Value Class**
31+
- Removes storage type logic
32+
- Single consistent interface for all operations
33+
- Better separation of concerns
34+
35+
2. **Unified Testing**
36+
- All storage types tested through the same interface
37+
- No need for separate local/remote test cases
38+
- Easier to mock and verify behavior
39+
40+
3. **More Flexible**
41+
- Easy to add new backend types
42+
- Consistent interface for all storage types
43+
- Clear extension points
44+
45+
4. **Better Security Model**
46+
- Storage backend choice driven by data sensitivity
47+
- Clear separation between sensitive and non-sensitive data
48+
- Explicit in configuration
49+
50+
### Negative
51+
1. **Slight Performance Impact**
52+
- Additional method calls for simple value operations
53+
- Extra object creation for SimpleValueBackend
54+
55+
### Neutral
56+
1. **Configuration Changes**
57+
- Backend selection based on value sensitivity
58+
- Transparent to end users
59+
60+
## Implementation Plan
61+
62+
1. **Backend Development**
63+
```python
64+
class SimpleValueBackend(ValueBackend):
65+
def __init__(self):
66+
self._values = {}
67+
68+
def get_value(self, path: str, environment: str) -> str:
69+
key = self._make_key(path, environment)
70+
return self._values[key]
71+
72+
def set_value(self, path: str, environment: str, value: str) -> None:
73+
key = self._make_key(path, environment)
74+
self._values[key] = value
75+
```
76+
77+
2. **Value Class Simplification**
78+
```python
79+
@dataclass
80+
class Value:
81+
path: str
82+
environment: str
83+
_backend: ValueBackend
84+
85+
def get(self) -> str:
86+
return self._backend.get_value(self.path, self.environment)
87+
88+
def set(self, value: str) -> None:
89+
if not isinstance(value, str):
90+
raise ValueError("Value must be a string")
91+
self._backend.set_value(self.path, self.environment, value)
92+
```
93+
94+
3. **Configuration Example**
95+
```json
96+
{
97+
"version": "1.0",
98+
"release": "my-app",
99+
"deployments": {
100+
"prod": {
101+
"backend": "aws",
102+
"auth": {
103+
"type": "managed_identity"
104+
},
105+
"backend_config": {
106+
"region": "us-west-2"
107+
}
108+
}
109+
},
110+
"config": [
111+
{
112+
"path": "app.replicas",
113+
"description": "Number of application replicas",
114+
"required": true,
115+
"sensitive": false,
116+
"values": {
117+
"dev": "3",
118+
"prod": "5"
119+
}
120+
},
121+
{
122+
"path": "app.secretKey",
123+
"description": "Application secret key",
124+
"required": true,
125+
"sensitive": true,
126+
"values": {
127+
"dev": "dev-key-123",
128+
"prod": "prod-key-456"
129+
}
130+
}
131+
]
132+
}
133+
```
134+
135+
The system will automatically:
136+
- Use SimpleValueBackend for non-sensitive values (app.replicas)
137+
- Use configured secure backend for sensitive values (app.secretKey)

0 commit comments

Comments
 (0)