-
Notifications
You must be signed in to change notification settings - Fork 24
docs: TypeScript charts specification #500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
docs: TypeScript charts specification #500
Conversation
Signed-off-by: Ilya Lesikov <[email protected]>
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 <[email protected]>
|
| Files: Files | ||
|
|
||
| // Functions (injected from Go) | ||
| lookup<T = unknown>(apiVersion: string, kind: string, namespace: string, name: string): T | null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all of these functions not needed. Let the user use the libraries he wants
|
|
||
| **Helper for conditionals:** | ||
| ```typescript | ||
| import { when } from '@nelm/sdk' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no
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 <[email protected]>
|
I updated my draft |
| ## Files | ||
|
|
||
| ```typescript | ||
| interface Files { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll probably need something like this, but not now.
| ownerReferences?: OwnerReference[] | ||
| finalizers?: string[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ownerReferences?: OwnerReference[] | |
| finalizers?: string[] |
Not needed
| apiVersion: string | ||
| kind: string | ||
| metadata: ObjectMeta | ||
| [key: string]: unknown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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