Reserved keyword registry#333
Open
RiSKeD wants to merge 4 commits into
Open
Conversation
CommandKeywords and DeviceKeywords list names that dutctl reserves for
client-side use ("help" for both, with room for future additions). The
registry is the single source of truth so dutctl and dutagent config
validation cannot drift as more keywords are added.
ErrReservedName lets dutagent return a typed sentinel when a config
tries to name a device or command with a reserved keyword.
Signed-off-by: Fabian Wienand <fabian.wienand@blindspot.software>
When loading the YAML config the dutagent now refuses any device or command whose name appears in dut.DeviceKeywords or dut.CommandKeywords respectively, returning dut.ErrReservedName via the existing ConfigError wrapper. Signed-off-by: Fabian Wienand <fabian.wienand@blindspot.software>
Replace the hard-coded `cmdArgs[0] == "help"` branch with a lookup into a local handler map keyed by dut.CommandKeywords / DeviceKeywords. An init() check guarantees every name in the registry has a handler, so adding a future keyword is one entry in pkg/dut/reserved.go and one in the dutctl handler map. `dutctl help` now prints the program usage instead of attempting to list commands for a "help" device. Signed-off-by: Fabian Wienand <fabian.wienand@blindspot.software>
Modules must not be configured with a reserved keyword name and must not expect one as the first argument to Run. Point readers at dut.CommandKeywords and dut.DeviceKeywords for the authoritative list. Signed-off-by: Fabian Wienand <fabian.wienand@blindspot.software>
Contributor
Author
|
Only thing i am not sure about or happy with is that we need to expose the global keywords and their handlers as global vars. Another approach would be to hide these behind functions, which in my opinion is even more cumbersome though... |
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.
resolves #84