Conversation
Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
Add detailed specification for TypeScript as Go templates alternative: - HelmContext API and types - SDK package structure - Development and deployment workflow - CLI commands - Design decisions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
| Files: Files | ||
|
|
||
| // Functions (injected from Go) | ||
| lookup<T = unknown>(apiVersion: string, kind: string, namespace: string, name: string): T | null |
| lookup<T = unknown>(apiVersion: string, kind: string, namespace: string, name: string): T | null | ||
|
|
||
| // Serialization | ||
| toYaml(obj: unknown): string |
There was a problem hiding this comment.
all of these functions not needed. Let the user use the libraries he wants
|
|
||
| **Helper for conditionals:** | ||
| ```typescript | ||
| import { when } from '@nelm/sdk' |
Key changes: - Switch from quickjs-go to goja (pure Go, no CGO) - Add data mechanism for external data fetching - Remove lookup from render phase (deterministic renders) - Remove helper functions (users use npm libraries) - Add esbuild embedded in Nelm notes - Add @nelm/types package structure with K8s types 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
I updated my draft |
| ## Files | ||
|
|
||
| ```typescript | ||
| interface Files { |
There was a problem hiding this comment.
Let's make it
interface File {
Name string
Data []byte
}
We don't really need all these methods, the user can do it himself. And we have all the Data from files already at this point (Helm reads all of them into the memory, even if not used).
| Chart: Chart | ||
| Capabilities: Capabilities | ||
| Files: Files | ||
| Data: D // Results from data() phase |
There was a problem hiding this comment.
We'll probably need something like this, but not now.
| ownerReferences?: OwnerReference[] | ||
| finalizers?: string[] |
There was a problem hiding this comment.
| ownerReferences?: OwnerReference[] | |
| finalizers?: string[] |
Not needed
| apiVersion: string | ||
| kind: string | ||
| metadata: ObjectMeta | ||
| [key: string]: unknown |
There was a problem hiding this comment.
Not sure how can it be done in TS, but this must work for data, spec, or whatever else, or a combination of.
| return condition ? items : [] | ||
| } | ||
|
|
||
| export default function render(ctx: HelmContext<Values>): Manifest[] { |
There was a problem hiding this comment.
I'd like to see something like RenderResult here instead of Manifest[].
interface RenderResult {
ApiVersion: string // v1 for now
Manifests: []Manifest
}
| @@ -0,0 +1,367 @@ | |||
| # Data Mechanism Proposal | |||
There was a problem hiding this comment.
Not interested in this for now.
|
|
||
| ```bash | ||
| # Nelm runs internally: | ||
| esbuild src/index.ts --bundle --target=es5 --format=iife --outfile=vendor/bundle.js |
There was a problem hiding this comment.
| esbuild src/index.ts --bundle --target=es5 --format=iife --outfile=vendor/bundle.js | |
| esbuild src/index.ts --bundle --target=es5.1 --format=iife --outfile=vendor/bundle.js |
if possible
|
|
||
| | Package | Type | Purpose | | ||
| |---------|------|---------| | ||
| | `@nelm/types` | Types | HelmContext, Manifest, K8s resources | |
There was a problem hiding this comment.
I'm not into TS/JS, so I don't know how to organize the TS SDK.
|
|
||
| K8s types generated from OpenAPI spec in CI. Version managed in CI pipeline. | ||
|
|
||
| ## @nelm/crd-to-ts |
There was a problem hiding this comment.
We can go without it for now. I guess for CRs you can just use any/unknown.
| "name": "mychart-ts", | ||
| "private": true, | ||
| "scripts": { | ||
| "generate:values": "json2ts ../values.schema.json -o src/generated/values.types.ts", | ||
| "generate:crd": "crd-to-ts --crd servicemonitors.monitoring.coreos.com -o src/generated/", | ||
| "typecheck": "tsc --noEmit", | ||
| "build": "esbuild src/index.ts --bundle --target=es5 --format=iife --outfile=vendor/bundle.js" | ||
| }, |
There was a problem hiding this comment.
I don't work with TS/JS, but I just want everything here to be as conventional/standard as possible.
| @@ -0,0 +1,158 @@ | |||
| # Feature: Go templates alternative | |||
There was a problem hiding this comment.
There is more up-to-date version now, which contains additional details, here:
Summary
Files
docs/proposals/go-template-alternative/README.md— Overviewdocs/proposals/go-template-alternative/api.md— HelmContext APIdocs/proposals/go-template-alternative/sdk.md— SDK structuredocs/proposals/go-template-alternative/workflow.md— Workflowdocs/proposals/go-template-alternative/cli.md— CLI commandsdocs/proposals/go-template-alternative/decisions.md— Design decisionsKey Decisions
render(ctx) → Manifest[](return-based, not emit)ctx(no globals, no imports for runtime)when()helper, all runtime from Go🤖 Generated with Claude Code