refactor: cli failfast validation prerune#106
Open
kangeunchan wants to merge 2 commits intoaltuslabsxyz:mainfrom
Open
refactor: cli failfast validation prerune#106kangeunchan wants to merge 2 commits intoaltuslabsxyz:mainfrom
kangeunchan wants to merge 2 commits intoaltuslabsxyz:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enhancement Description
Make CLI validation fail-fast by moving checks to
PreRunEand centralizing shared validators.Summary
This PR moves validation out of
RunEand intoPreRunE(or parent persistent hooks where appropriate), so invalid input fails before expensive initialization.It also introduces a shared validation package for consistent error rules/messages.
Scope
RunEtoPreRunEin key command paths.internal/cmd/validation.dvbto rootPersistentPreRunEvia command annotations.MarkFlagRequiredalready enforces them.Main Changes
internal/cmd/validation:devnet-buildercommand updates:manage/deploy: addedPreRunEvalidation and shared validatorscore/init: addedPreRunEvalidation and shared validatorsmanage/start: moved mode validation toPreRunEmanage/upgrade: moved mode/voting-period/resume-stage validation toPreRunEdvbcommand updates:requireDaemon()checks from daemon-dependent subcommandsprovision: added pre-run validation path for flag mode and centralized option validation--upgrade-nameempty check in upgrade create (already covered byMarkFlagRequired).gitignorefix:devnet-builderignore rule to/devnet-builderto avoid ignoringcmd/devnet-builder/**source files.Why
Validation
Executed:
go test ./internal/cmd/validation/...go test ./cmd/devnet-builder/commands/manage/...go test ./cmd/devnet-builder/commands/core/...go test ./cmd/dvb/...Non-Goals
Risk & Mitigation