cli: Improve error message when pack lacks .nomad.tpl parent templates#831
cli: Improve error message when pack lacks .nomad.tpl parent templates#831TIMMAREDDYDEEKSHITHA-ship-it wants to merge 12 commits intomainfrom
Conversation
hashi-divyansh
left a comment
There was a problem hiding this comment.
@TIMMAREDDYDEEKSHITHA-ship-it Added my comment.
Missing implementation for render cmd.
here 'render' command has different behaviour - it succeeds if it renders either parent templates or dependent pack templates. Since it has different validation logic, I kept existing generic error message for it. The improved error message specifically addresses issue in #510 which affects 'plan' and 'run' commands where parent templates are strictly required |
- Add nomadVariable() function to retrieve specific variable - Add nomadVariables() function to list all variables - Add comprehensive unit tests with mocked API - Verify integration with live Nomad cluster - Update documentation with usage examples Closes #409
- Added ErrNoParentTemplates error constant - Enhanced error message to explain .nomad.tpl naming requirement - Shows template naming convention rules with examples - Lists actual template files found in templates/ directory - Provides specific guidance on how to fix the issue - Applied to both plan and run commands for consistency The new error message clearly shows users: 1. What went wrong (no .nomad.tpl files) 2. The naming convention rules 3. Which files exist that need renaming 4. How to fix the issue This replaces the previous unclear 'no templates were rendered' error that left users confused for hours. Fixes #510
f3b90f3 to
5a56c0b
Compare
hashi-divyansh
left a comment
There was a problem hiding this comment.
Please update the PR title, it should be a bit more elaborative.
Sure |
b5b9791
jrasell
left a comment
There was a problem hiding this comment.
Looking really good thanks for the recent changes. A final thought seeing that the code is duplicated in plan and run, do we want to have a helper function that can be used to generate the context in these cases? We could also then test this helper, meaning we have assertions of what is included.
Description
Fixes #510
Problem
Users were confused by the unclear error "no templates were rendered by the renderer process run" when their pack lacked
.nomad.tplfiles. This led to hours of debugging, as reported in the issue.Solution
Enhanced the error message to:
.nomad.tplfiles are required for parent templatesChanges
ErrNoParentTemplateserror constant ininternal/pkg/errors/ui_context.goplancommand (internal/cli/plan.go)runcommand (internal/cli/run.go)pack renders successfully with .nomad.tpl file
Reproducing the error ->
File structure after renaming (missing .nomad.tpl)
After: Improved Error Message ->
Running nomad-pack plan now shows clear, actionable error
Refactored UIErrorContext version of the error:
Reminders
CHANGELOG.mdentryChanges to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.