Skip to content

feat: valueFrom.fromBinding env var projection#432

Open
JamesSprow wants to merge 5 commits into
mainfrom
feat/from-binding-env-projection
Open

feat: valueFrom.fromBinding env var projection#432
JamesSprow wants to merge 5 commits into
mainfrom
feat/from-binding-env-projection

Conversation

@JamesSprow

@JamesSprow JamesSprow commented May 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • valueFrom.fromBinding: New CRD field on EnvVar lets users project specific keys from bound app credentials into custom-named env vars (e.g. DB_PASS from pg.password). Resolver validates the ref is in the env's bindings list and the key exists on the bound app.
  • valueFrom.secretRef fix: The field existed on the CRD but the controller never resolved it. Now reads the referenced Secret from the env namespace.
  • Flash bug fix: Bindings and Credentials section + buttons would flash a new row then immediately disappear due to SSE-triggered $effect re-runs resetting UI state. Fixed with lastLoadedEnv/lastLoadedApp guards.
  • BindingsPicker rewrite: Replaced dead ${{bindings.X.Y}} template syntax with real CRD field writes. Picker now writes fromBinding or secretRef entries to the app spec, and the UI displays binding vars with a "binding" badge and ref -> key display.
  • API: New GET /binding-keys endpoint returns available keys for a bound app. GET /env response enriched with bindingRef/bindingKey metadata.

Scope note

SPEC S5.8b says fromBinding is supported in both sharedVars and env. This PR implements it for env only. sharedVars support is intentionally deferred -- shared vars are app-level (not per-environment), which raises scoping questions about which environment's bindings list to validate against. Will address in a follow-up.

Changes

Area Files What
CRD app_types.go, deepcopy, CRD YAML BindingVarSource struct, FromBinding field on EnvVarSource
Resolver resolver.go, resolver_test.go ResolveSingle(), AvailableKeys() + 10 new tests
Controller app_controller.go, app_controller_test.go resolveEnvVarValue() for literal/secretRef/fromBinding + 7 tests
API bindings.go, env.go, server.go binding-keys endpoint, env response enrichment
UI VariablesTab, VarTable, BindingsPicker, BindingsSection, CredentialsSection fromBinding flow, flash bug fix, binding display
E2E app-variables-full.spec.ts, bindings.spec.ts 3 new fromBinding tests, 1 flash bug test, rewritten binding ref test
Integration bindings_test.go TestFromBindingProjectsNamedKey

Test plan

  • Unit tests pass (1106 tests, 22 packages)
  • svelte-check passes (0 errors)
  • Manual test: created pg+web apps with fromBinding, verified env vars resolve correctly via API
  • Manual test: binding-keys endpoint returns correct keys
  • CI: unit + envtest
  • CI: integration tests
  • CI: UI E2E (157 tests)
  • CI: helm lint + template tests
  • CI: go vet + staticcheck
  • CI: UI typecheck + build

Generated with Claude Code

JamesSprow and others added 5 commits May 30, 2026 12:34
Allow users to project specific keys from bound app credentials into
custom-named env vars via `valueFrom.fromBinding.{ref, key}` on the
CRD spec. Also fixes `valueFrom.secretRef` resolution (was declared
on the CRD but never resolved by the controller), fixes a flash/
disappear bug on the Bindings and Credentials section + buttons
caused by SSE-triggered $effect re-runs, and rewires BindingsPicker
to write real CRD fields instead of the non-functional ${{bindings}}
template syntax.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Route fromBinding-resolved env vars into the binding-source list so
they survive the ReplaceSource("binding", ...) call that manages
auto-injected vars. Also fix E2E selectors: scope picker assertions
to the picker panel to avoid strict mode violations, and fix the
auto-injected button title assertion.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Increase DB_PASS visibility timeout to 15s (controller reconcile needed)
- Use .first() for binding badge assertion (multiple badges in section)
- Add exact: true to Projects heading assertion (navigation.spec.ts)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Append fromBinding vars after auto-generated binding vars so explicit
  user projections win when names collide (was prepending, which let
  auto-generated vars silently overwrite user intent)
- Add exact: true to getByRole calls in E2E tests

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant