@@ -547,70 +547,61 @@ obol network install ethereum --id holesky-test --network=holesky
547547
548548## Network Install Implementation Details
549549
550- ### Annotation Parser
550+ ### Template Field Parser
551551
552- **Location**: `internal/network/network .go` - `ParseEmbeddedNetworkEnvVars ()`
552+ **Location**: `internal/network/parser .go` - `ParseTemplateFields ()`
553553
554554**Annotations supported**:
555555- `@enum`: Comma-separated valid values
556556- `@default`: Default value if flag not provided
557557- `@description`: Help text for flag
558558
559559**Parsing logic**:
560- 1. Read embedded `helmfile.yaml.gotmpl`
561- 2. Find `values:` section
562- 3. Extract environment variable references: `{{ env "VAR_NAME" | default "value" }}`
563- 4. Parse annotations from comments above each value
564- 5. Generate `EnvVar` struct with:
565- - Name: Environment variable name (e.g., `ETHEREUM_NETWORK`)
566- - FlagName: CLI flag name (lowercase, dashed, e.g., `network`)
567- - DefaultValue: From `default` pipe or `@default` annotation
560+ 1. Read embedded `values.yaml.gotmpl`
561+ 2. Parse Go template to extract field references (e.g., `{{.Network}}`, `{{.ExecutionClient}}`)
562+ 3. Parse annotations from comments above each field
563+ 4. Generate `TemplateField` struct with:
564+ - Name: Template field name (e.g., `Network`, `ExecutionClient`)
565+ - FlagName: CLI flag name (lowercase, dashed, e.g., `network`, `execution-client`)
566+ - DefaultValue: From `@default` annotation
568567 - EnumValues: From `@enum` annotation
569568 - Description: From `@description` annotation
570- - Required: True if no default value
569+ - Required: True if no `@ default` annotation present
571570
572571### CLI Flag Generation
573572
574573**Location**: `cmd/obol/network.go` - `buildNetworkInstallCommands()`
575574
576575**Process**:
5775761. For each embedded network:
578- - Parse helmfile annotations
579- - Build `cli.Flag` for each environment variable
577+ - Parse values template to extract template fields
578+ - Build `cli.Flag` for each template field
580579 - Add enum validation to flag usage
581580 - Set Required based on default presence
5825812. Create network-specific subcommand: `obol network install <network>`
5835823. Attach flags and validation action
5845834. Register subcommand dynamically
585584
586585**Flag naming convention**:
587- - Environment variable : `ETHEREUM_EXECUTION_CLIENT `
586+ - Template field : `ExecutionClient `
588587- Flag name: `--execution-client`
589- - Transformation: Remove network prefix, lowercase, dash-separated
588+ - Transformation: Insert hyphens before uppercase letters, lowercase
590589
591590### Install Implementation
592591
593592**Location**: `internal/network/network.go` - `Install()`
594593
595- **Current implementation** (temporary, until two-stage templating):
596- 1. Parse embedded helmfile for environment variables
597- 2. Display configuration to user (with overrides highlighted)
598- 3. Create temporary directory: `/tmp/obol-network-<network>-XXXX`
599- 4. Copy embedded network to temp directory
600- 5. Set environment variables in process
601- 6. Run: `helmfile -f <temp-dir>/helmfile.yaml.gotmpl sync`
602- 7. Helmfile processes template with environment variables
603- 8. Deploy to cluster
604- 9. Remove temp directory
605-
606- **Future implementation** (two-stage templating):
607- 1. Generate unique namespace (petname)
608- 2. Parse embedded helmfile
609- 3. Template Stage 1: Populate `{{.Network}}`, `{{.ExecutionClient}}`, etc. with flag values
610- 4. Save templated helmfile to: `$CONFIG_DIR/networks/<network>/<namespace>/`
611- 5. Run: `helmfile sync -f <saved-helmfile>`
612- 6. Helmfile templates Stage 2 and applies to cluster
613- 7. User can edit saved helmfile and re-sync later
594+ **Implementation** (two-stage templating):
595+ 1. Generate unique deployment ID (petname or user-specified via `--id`)
596+ 2. Parse embedded values template to extract template fields
597+ 3. Build template data map from CLI flag overrides and defaults
598+ 4. Display configuration to user (showing overrides and defaults)
599+ 5. Execute Go template on `values.yaml.gotmpl` with template data
600+ 6. Write rendered `values.yaml` to: `$CONFIG_DIR/networks/<network>/<id>/values.yaml`
601+ 7. Copy network files (`helmfile.yaml.gotmpl`, `Chart.yaml`, `templates/`) to deployment directory
602+ 8. User runs `obol network sync <network>/<id>` to deploy
603+ 9. Sync command runs: `helmfile sync --state-values-file values.yaml`
604+ 10. Helmfile reads values.yaml, templates Stage 2 (substitutes `{{.Values.*}}`), and applies to cluster
614605
615606## Key Implementation Patterns
616607
0 commit comments