Skip to content

Replace hand-written PythonBinPath absolute-path check with mount_path validation tag#34

Open
spapa013 wants to merge 11 commits intonauticalab:mainfrom
spapa013:spapadop/plt-983-replace-hand-written-pythonbinpath-absolute-path-check-with
Open

Replace hand-written PythonBinPath absolute-path check with mount_path validation tag#34
spapa013 wants to merge 11 commits intonauticalab:mainfrom
spapa013:spapadop/plt-983-replace-hand-written-pythonbinpath-absolute-path-check-with

Conversation

@spapa013
Copy link
Collaborator

⚠️ This PR is stacked on #33 . Rebase onto main after that PR is merged before merging this one.

Summary

  • Replaces the hand-written validatePythonBinPathAbsolute() function with the existing mount_path struct tag on PythonBinPath, consistent with how HomeDirMountBase, LocalPath, and ContainerPath are validated.
  • Removes both explicit call sites in ValidateDevEnvConfig and ValidateBaseConfig.
  • Updates tests to reflect the tag-based error message format.

Context

Identified during PLT-863. The mount_path validator already covers the same contract: non-empty, absolute, syntactically valid path. The hand-written check was redundant and kept validation logic split across two places with no obvious connection.

Testing

  • Updated TestValidateBaseConfig_PythonBinPathMustBeAbsolute and TestValidateDevEnvConfig_PythonBinPathMustBeAbsolute to assert against the tag-based error message format.
  • Ran go test ./internal/config/... — all tests pass.

Closes PLT-983

spapa013 added 11 commits March 11, 2026 23:22
Align config validation with the ingress manifests that generation can produce.

The original validation path did not fully enforce the conditions needed
to render ingress safely. This change centralizes HTTP/hostname checks,
tightens auth validation, and updates tests and fixtures to reflect the
actual supported config combinations.

- add helpers for HTTP exposure and hostname presence
- require hostName when httpPort is set
- reject enableAuth combined with skipAuth
- require authURL and authSignIn when auth is enabled
- expand validation tests for ingress and auth dependencies
- update the ingress golden fixture to use a valid hostname
Extract template selection and ownership into an explicit RenderPlan.

The original renderer implicitly owned the template sets for dev and
system generation. This change moves that planning logic into a separate
module so template selection is explicit, testable, and reusable by the
rest of the generation pipeline.

- add RenderPlan with TemplateNames and ManagedTemplates
- add BuildDevRenderPlan and BuildSystemRenderPlan
- define dev/system base and optional template sets outside the renderer
- add contract tests for dev and system plans
- add invariants to ensure all planned templates are managed
- cover ingress inclusion and exclusion through plan tests
Introduce an explicit post-render phase for manifest output handling.

This change adds a dedicated post-render step that manages generated
outputs after a successful render, including cleanup of stale managed
files from previous runs that are no longer planned.

- add RunPostRender for post-render output handling
- add cleanup behavior for managed outputs that are no longer planned
- add post-render tests for managed, planned, and unmanaged outputs
- keep renderer tests focused on rendering behavior and failure paths
- make the invalid output directory test deterministic
- document the dev/system renderer wrappers as convenience helpers
Refactor manifest generation around an explicit GenerationSpec.

The original generate command assembled rendering inputs directly inside
the system and developer generation paths. This change packages the
generation contract into a typed spec, adds a shared generateManifests
pipeline, and introduces a no-cleanup flag for post-render behavior.

- add GenerationSpec with dev and system builders
- add NewPostRenderOptions for explicit post-render policy creation
- add --no-cleanup and map it into post-render behavior
- standardize the CLI flow on spec -> render -> post-render
- add a shared generateManifests helper for dev and system generation
- switch the command path to the generic NewRenderer constructor
- keep RenderPlan focused on TemplateNames only
- build dev plans by filtering the full dev template set
- add explicit cleanup-scope helpers for dev and system templates
- make BuildDevRenderPlan return an error for nil config
- update renderer/tests to use the new plan contract
- move cleanup to a pre-render step gated by --no-cleanup
- scope cleanup to known template outputs
- restore explicit generateSystemManifests / generateDeveloperManifests flows
use NewSystemRenderer and NewDevRenderer again instead of hardcoding generic render flow
- keep post-render invocation as an explicit pipeline stage
… no-op hook

- remove GenerationSpec and its builders
- simplify post-render to a no-op extension point for future work
- keep PostRenderOptions minimal
- reduce tests to cover the current no-op post-render contract
LoadGlobalConfig now returns an error when devenv.yaml is absent, rather than silently falling back to system defaults. The error message names the missing file and tells the user what to create and where.

Tests updated to reflect the new contract; the two test cases that asserted the silent-default behavior have been replaced with error assertions.

Refs: PLT-855
Replace the two-step os.Stat + os.ReadFile pattern in all three config load functions with a single os.ReadFile call, inspecting the error for os.IsNotExist. Eliminates a redundant syscall and the race window between the existence check and the read.

Refs: PLT-855
Adds HomeDirMountBase to BaseConfig, allowing the host path prefix for per-developer home and linuxbrew volumes to be configured rather than being hardcoded to /mnt/devenv in the StatefulSet template.

Defaults to /mnt/devenv to preserve existing behavior. Also removes stray trailing whitespace from the StatefulSet golden file.
…eck with mount_path tag

- Update PythonBinPath validate tag from `omitempty,min=1` to `omitempty,mount_path`
- Delete validatePythonBinPathAbsolute() and its two call sites in
  ValidateDevEnvConfig and ValidateBaseConfig
- Update tests to match tag-based error message format

Refs PLT-983
@spapa013 spapa013 requested a review from eywalker March 18, 2026 17:22
@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

❌ Patch coverage is 58.75000% with 33 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/devenv/generate.go 0.00% 26 Missing ⚠️
internal/templates/renderer.go 70.00% 2 Missing and 1 partial ⚠️
internal/config/parser.go 71.42% 2 Missing ⚠️
internal/config/types.go 71.42% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

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