timonel 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +256 -0
- package/SECURITY.md +44 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +407 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/ChartFactory.d.ts +389 -0
- package/dist/lib/ChartFactory.d.ts.map +1 -0
- package/dist/lib/ChartFactory.js +583 -0
- package/dist/lib/ChartFactory.js.map +1 -0
- package/dist/lib/HelmChartWriter.d.ts +67 -0
- package/dist/lib/HelmChartWriter.d.ts.map +1 -0
- package/dist/lib/HelmChartWriter.js +154 -0
- package/dist/lib/HelmChartWriter.js.map +1 -0
- package/dist/lib/helm.d.ts +32 -0
- package/dist/lib/helm.d.ts.map +1 -0
- package/dist/lib/helm.js +74 -0
- package/dist/lib/helm.js.map +1 -0
- package/package.json +101 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Franklin García
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# Timonel
|
|
2
|
+
|
|
3
|
+
[![License: MIT][license-badge]][license-url]
|
|
4
|
+
[![npm version][npm-badge]][npm-url]
|
|
5
|
+
[![Security][security-badge]][security-url]
|
|
6
|
+
[![CodeQL][codeql-badge]][codeql-url]
|
|
7
|
+
[![CI][ci-badge]][ci-url]
|
|
8
|
+
[![pnpm][pnpm-badge]][pnpm-url]
|
|
9
|
+
[![Node.js][node-badge]][node-url]
|
|
10
|
+
[![TypeScript][ts-badge]][ts-url]
|
|
11
|
+
[![Maintained by KenkoGeek][maintained-badge]][maintained-url]
|
|
12
|
+
|
|
13
|
+
Timonel (Spanish for “helmsman”) is a TypeScript library to programmatically
|
|
14
|
+
generate Helm charts using cdk8s. Define Kubernetes resources with classes and
|
|
15
|
+
synthesize a full Helm chart with `Chart.yaml`, `values.yaml`, per‑environment
|
|
16
|
+
values files, and `templates/`.
|
|
17
|
+
|
|
18
|
+
Key features:
|
|
19
|
+
|
|
20
|
+
- Type-safe API (strict TypeScript) with cdk8s constructs.
|
|
21
|
+
- Helm templating helpers to embed `{{ .Values.* }}` where needed.
|
|
22
|
+
- Simple multi-environment setup: `values.yaml`, `values-dev.yaml`, `values-prod.yaml`, etc.
|
|
23
|
+
- Minimal CLI (`tl`) to scaffold an example and synthesize the chart.
|
|
24
|
+
|
|
25
|
+
Advanced templating:
|
|
26
|
+
|
|
27
|
+
- Programmatic Helm helpers: generate `templates/_helpers.tpl` and call helpers using `template()`/`include()`.
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
### Using npm
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install timonel
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Development setup
|
|
38
|
+
|
|
39
|
+
Requirements: Node.js 20+ (Corepack enabled)
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
corepack enable
|
|
43
|
+
corepack prepare pnpm@latest --activate
|
|
44
|
+
pnpm install
|
|
45
|
+
pnpm run build
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Developer setup (git hooks)
|
|
49
|
+
|
|
50
|
+
After installing dependencies, enable git hooks with Husky:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pnpm dlx husky init || npx husky init
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
This sets up pre-commit and commit-msg hooks to run lint-staged and commitlint.
|
|
57
|
+
The pre-commit hook also runs Node-based Markdown linting (markdownlint)
|
|
58
|
+
automatically.
|
|
59
|
+
|
|
60
|
+
Markdown commands:
|
|
61
|
+
|
|
62
|
+
- Lint: `pnpm run md:lint`
|
|
63
|
+
- Fix: `pnpm run md:fix`
|
|
64
|
+
|
|
65
|
+
## Quick start
|
|
66
|
+
|
|
67
|
+
<!-- markdownlint-disable MD029 -->
|
|
68
|
+
|
|
69
|
+
1. Create an example project
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
tl init my-app-src
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
This generates `charts/my-app-src/chart.ts` with a working example.
|
|
76
|
+
|
|
77
|
+
2. Synthesize Helm chart artifacts
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
tl synth charts/my-app-src charts/my-app/
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Expected output:
|
|
84
|
+
|
|
85
|
+
- `charts/my-app/Chart.yaml`
|
|
86
|
+
- `charts/my-app/values.yaml`
|
|
87
|
+
- `charts/my-app/values-dev.yaml`, `values-prod.yaml` (if defined)
|
|
88
|
+
- `charts/my-app/templates/*.yaml`
|
|
89
|
+
|
|
90
|
+
3. Use with Helm
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
helm template charts/my-app -f charts/my-app/values-dev.yaml
|
|
94
|
+
helm install my-app charts/my-app -f charts/my-app/values-prod.yaml
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Note: the output directory (`charts/my-app/` in this example) is overwritten if files
|
|
98
|
+
exist. Use a clean folder or move old artifacts before running synth.
|
|
99
|
+
|
|
100
|
+
### Package the chart (tgz)
|
|
101
|
+
|
|
102
|
+
Requires Helm installed locally (`helm version`). Packages the chart directory into a
|
|
103
|
+
`.tgz` that you can publish or attach to releases:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
tl package charts/my-app charts/
|
|
107
|
+
# or set HELM_BIN if helm is not in PATH
|
|
108
|
+
HELM_BIN=/usr/local/bin/helm tl package charts/my-app charts/
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Library API
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { ChartFactory } from 'timonel';
|
|
115
|
+
import {
|
|
116
|
+
valuesRef,
|
|
117
|
+
helm,
|
|
118
|
+
template,
|
|
119
|
+
include,
|
|
120
|
+
numberRef,
|
|
121
|
+
boolRef,
|
|
122
|
+
stringRef,
|
|
123
|
+
floatRef,
|
|
124
|
+
} from 'timonel/lib/helm';
|
|
125
|
+
|
|
126
|
+
const factory = new ChartFactory({
|
|
127
|
+
meta: { name: 'my-app', version: '0.1.0', appVersion: '1.0.0' },
|
|
128
|
+
defaultValues: {
|
|
129
|
+
image: { repository: 'nginx', tag: '1.27' },
|
|
130
|
+
replicas: 2,
|
|
131
|
+
service: { port: 80 },
|
|
132
|
+
},
|
|
133
|
+
envValues: { dev: { replicas: 1 }, prod: { replicas: 4 } },
|
|
134
|
+
helpersTpl: [
|
|
135
|
+
{
|
|
136
|
+
name: 'timonel.fullname',
|
|
137
|
+
body: `{{- printf "%s-%s" .Chart.Name .Release.Name | trunc 63 | trimSuffix "-" -}}`,
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
factory.addDeployment({
|
|
143
|
+
name: 'my-app',
|
|
144
|
+
image: `${valuesRef('image.repository')}:${valuesRef('image.tag')}`,
|
|
145
|
+
replicas: numberRef('replicas') as any,
|
|
146
|
+
containerPort: 80,
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
factory.addService({ name: 'my-app', port: numberRef('service.port') as any });
|
|
150
|
+
|
|
151
|
+
// Use a named helper in annotations (example)
|
|
152
|
+
factory.addDeployment({
|
|
153
|
+
name: 'annotated',
|
|
154
|
+
image: 'nginx',
|
|
155
|
+
containerPort: 80,
|
|
156
|
+
env: {
|
|
157
|
+
FULLNAME: include('timonel.fullname'),
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
factory.write('dist/charts/my-app');
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
- `valuesRef(path)`: returns a Helm placeholder string for `.Values.*`.
|
|
165
|
+
- You can pass these strings directly into cdk8s constructs; they are preserved in the YAML.
|
|
166
|
+
- `template(name, ctx='.')` and `include(name, ctx='.')`: inject calls to helpers defined in `_helpers.tpl`.
|
|
167
|
+
- `numberRef(path)`, `boolRef(path)`: cast `.Values.*` to numeric/boolean using Sprig
|
|
168
|
+
(`int`, `toBool`). Use `as any` where constructs expect typed numbers/bools.
|
|
169
|
+
- `stringRef(path)`, `floatRef(path)`: cast `.Values.*` to string/float using Sprig
|
|
170
|
+
(`toString`, `float64`).
|
|
171
|
+
|
|
172
|
+
## Multi-environment values
|
|
173
|
+
|
|
174
|
+
Provide `envValues` in the `ChartFactory` constructor to automatically create
|
|
175
|
+
`values-<env>.yaml` files. Each environment file overrides defaults from
|
|
176
|
+
`values.yaml`.
|
|
177
|
+
|
|
178
|
+
## Security
|
|
179
|
+
|
|
180
|
+
- ESLint security plugin with comprehensive vulnerability detection
|
|
181
|
+
- Automated dependency scanning via Dependabot
|
|
182
|
+
- Security audit in CI/CD pipeline
|
|
183
|
+
- Provenance-enabled npm publishing
|
|
184
|
+
- CodeQL analysis for code security
|
|
185
|
+
|
|
186
|
+
## Notes on cdk8s and Helm templates
|
|
187
|
+
|
|
188
|
+
- cdk8s synthesizes Kubernetes manifests. Timonel wraps them into a Helm chart
|
|
189
|
+
structure and allows Helm placeholders to appear in string fields (e.g.,
|
|
190
|
+
`{{ .Values.image.tag }}`).
|
|
191
|
+
- For advanced templating, Timonel can generate `_helpers.tpl`. Provide `helpersTpl`
|
|
192
|
+
in `ChartFactory` as a string (verbatim) or as named helpers. Use `template()` or `include()`
|
|
193
|
+
to reference them in your manifests.
|
|
194
|
+
|
|
195
|
+
## Roadmap
|
|
196
|
+
|
|
197
|
+
- Helpers for common patterns (HPA, auto-scaling)
|
|
198
|
+
- Richer CLI (resource generators, diff)
|
|
199
|
+
- Enhanced multi-cloud support
|
|
200
|
+
- Template validation and testing utilities
|
|
201
|
+
|
|
202
|
+
## Contributing
|
|
203
|
+
|
|
204
|
+
1. Fork the repository
|
|
205
|
+
2. Create a feature branch: `git checkout -b feature/amazing-feature`
|
|
206
|
+
3. Make your changes following the existing code style
|
|
207
|
+
4. Run tests: `pnpm run lint && pnpm run build`
|
|
208
|
+
5. Commit using conventional commits: `git commit -m 'feat: add amazing feature'`
|
|
209
|
+
6. Push to the branch: `git push origin feature/amazing-feature`
|
|
210
|
+
7. Open a Pull Request
|
|
211
|
+
|
|
212
|
+
## Troubleshooting
|
|
213
|
+
|
|
214
|
+
### Common Issues
|
|
215
|
+
|
|
216
|
+
#### Error: chart.ts not found
|
|
217
|
+
|
|
218
|
+
- Ensure you're running `tl synth` from the correct directory
|
|
219
|
+
- Verify the chart.ts file exists in the specified path
|
|
220
|
+
|
|
221
|
+
#### TypeScript compilation errors
|
|
222
|
+
|
|
223
|
+
- Check Node.js version (requires 20+)
|
|
224
|
+
- Run `pnpm install` to ensure dependencies are installed
|
|
225
|
+
- Verify TypeScript configuration in tsconfig.json
|
|
226
|
+
|
|
227
|
+
#### Helm template errors
|
|
228
|
+
|
|
229
|
+
- Validate YAML syntax in generated templates
|
|
230
|
+
- Check Helm values references match your values.yaml structure
|
|
231
|
+
- Use `helm template --debug` for detailed error information
|
|
232
|
+
|
|
233
|
+
## License
|
|
234
|
+
|
|
235
|
+
MIT
|
|
236
|
+
|
|
237
|
+
<!-- Badges section -->
|
|
238
|
+
|
|
239
|
+
[license-badge]: https://img.shields.io/badge/License-MIT-yellow.svg
|
|
240
|
+
[license-url]: https://opensource.org/licenses/MIT
|
|
241
|
+
[npm-badge]: https://img.shields.io/npm/v/timonel.svg
|
|
242
|
+
[npm-url]: https://www.npmjs.com/package/timonel
|
|
243
|
+
[security-badge]: https://img.shields.io/badge/Security-Policy-2ea44f?logo=security&logoColor=fff
|
|
244
|
+
[security-url]: SECURITY.md
|
|
245
|
+
[pnpm-badge]: https://img.shields.io/badge/pm-pnpm-ffd95a?logo=pnpm&logoColor=fff&labelColor=24292e
|
|
246
|
+
[pnpm-url]: https://pnpm.io/
|
|
247
|
+
[node-badge]: https://img.shields.io/badge/node-%3E%3D20-339933?logo=node.js&logoColor=fff
|
|
248
|
+
[node-url]: https://nodejs.org/
|
|
249
|
+
[ts-badge]: https://img.shields.io/badge/TypeScript-5.x-3178C6?logo=typescript&logoColor=fff
|
|
250
|
+
[ts-url]: https://www.typescriptlang.org/
|
|
251
|
+
[maintained-badge]: https://img.shields.io/badge/maintained%20by-KenkoGeek-6C78AF?style=flat
|
|
252
|
+
[maintained-url]: https://github.com/kenkogeek/
|
|
253
|
+
[ci-badge]: https://github.com/KenkoGeek/timonel/actions/workflows/ci.yml/badge.svg?branch=main
|
|
254
|
+
[ci-url]: https://github.com/KenkoGeek/timonel/actions/workflows/ci.yml
|
|
255
|
+
[codeql-badge]: https://github.com/KenkoGeek/timonel/actions/workflows/codeql.yml/badge.svg
|
|
256
|
+
[codeql-url]: https://github.com/KenkoGeek/timonel/actions/workflows/codeql.yml
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Reporting Security Vulnerabilities
|
|
4
|
+
|
|
5
|
+
- **DO NOT** create public GitHub issues for security vulnerabilities
|
|
6
|
+
- Report vulnerabilities privately via project maintainers or GitHub Security Advisories
|
|
7
|
+
- Include detailed information about the vulnerability and steps to reproduce
|
|
8
|
+
- We aim to triage within 5 business days and provide updates within 10 business days
|
|
9
|
+
|
|
10
|
+
## Supported Versions
|
|
11
|
+
|
|
12
|
+
| Version | Supported |
|
|
13
|
+
| ------- | ------------------ |
|
|
14
|
+
| 0.1.x | :white_check_mark: |
|
|
15
|
+
|
|
16
|
+
## Development Security
|
|
17
|
+
|
|
18
|
+
### Static Analysis
|
|
19
|
+
|
|
20
|
+
- TypeScript strict mode enabled with comprehensive compiler checks
|
|
21
|
+
- ESLint with security plugin (`eslint-plugin-security`) in CI/CD
|
|
22
|
+
- SonarJS plugin for code quality and security analysis
|
|
23
|
+
- Automated dependency vulnerability scanning via `pnpm audit`
|
|
24
|
+
|
|
25
|
+
### Dependencies
|
|
26
|
+
|
|
27
|
+
- Regular dependency updates via Dependabot
|
|
28
|
+
- Security-focused dependency management
|
|
29
|
+
- No runtime network calls in library APIs
|
|
30
|
+
- Minimal dependency footprint
|
|
31
|
+
|
|
32
|
+
### CI/CD Security
|
|
33
|
+
|
|
34
|
+
- GitHub Actions with minimal permissions
|
|
35
|
+
- Dependency caching with integrity checks
|
|
36
|
+
- Automated security audits on every build
|
|
37
|
+
- CodeQL analysis for vulnerability detection
|
|
38
|
+
|
|
39
|
+
### Best Practices
|
|
40
|
+
|
|
41
|
+
- Input validation and sanitization
|
|
42
|
+
- Secure coding practices following OWASP guidelines
|
|
43
|
+
- Regular security reviews of code changes
|
|
44
|
+
- Principle of least privilege in all configurations
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|