Repository navigation
fix(smd): document iface commands and accept multiple network pairs - #225
Conversation
ac9f361 to
ed420b7
Compare
The iface section of ochami-smd(1) only described "get". Add entries for "add" and "delete", following the compep and rfe sections: their forms, the payload input options, --all and --no-confirm for delete, and the rule that delete only uses each payload item's ID (blank or path-like IDs are a usage error, and no ID is derived from MACAddress). Fixes #206 Signed-off-by: anyingiit <49945850+anyingiit@users.noreply.github.com>
Accept at least three positional arguments so iface add can consume every network,IPv4 pair advertised by its help text and examples. Keep all pairs on one Ethernet interface in the request rather than rejecting commands that specify more than one address. Reject pairs without a comma or network name before indexing their fields to report a usage error instead of panicking. Preserve IPv4 validation and validate every pair before sending the interface to SMD. Update the man page to describe repeated pair arguments. Add command tests that verify the complete multi-address request and reject malformed pairs, including invalid later pairs, without sending a request. Follow the test/organize conventions for test names, files, comments, and runtimes. Signed-off-by: Devon Bautista <17506592+synackd@users.noreply.github.com>
ed420b7 to
2d30dae
Compare
State that iface add and delete payloads must be an array of EthernetInterface objects, even for a single interface. Both commands unmarshal -d data directly into a slice, so a bare object is rejected, and the data structure example already showed an array while calling it a single EthernetInterface. Correct the delete validation rule to cover only the IDs used to select interfaces. With --all or -d, positional arguments are ignored with a warning and never validated, so the previous wording promised a usage error that --all never raised. Document that --all takes precedence over -d after the payload is validated, and that add also ignores positional arguments when -d is passed. Signed-off-by: Devon Bautista <17506592+synackd@users.noreply.github.com>
|
I don't think this is directly related to this PR, but I noticed that the config is checked before input validation. For example, if I intentionally run the following command to produce an error: ochami smd --ignore-config iface add node de:ca:fc:0f:fe:ee externalI believe 2026-10-29T14:33:55-06:00 ERR root.go:247 > failed to execute command error="failed to get base URI for SMD: could not get smd base URI: base URI for smd not found (neither cluster.uri nor smd.uri specified)"
2026-10-29T14:33:55-06:00 ERR cli.go:59 > see 'ochami smd iface add --help' for long command help
exit status 3However, if you include the ochami smd --ignore-config iface add --uri http://127.0.0.1:18080 --no-token node de:ca:fc:0f:fe:ee externalAnd here's the corresponding error message: 2026-10-29T14:37:28-06:00 ERR root.go:247 > failed to execute command error="invalid network,ip pair \"external\": expected a network name and IPv4 address separated by a comma"
2026-10-29T14:37:28-06:00 ERR cli.go:59 > see 'ochami smd iface add --help' for long command help
exit status 2If I'm including the |
This is intentional. If you pass |
Description
Document
smd iface addandsmd iface deleteinochami-smd(1), including positional and payload input forms, options, and delete ID validation. Carry forward the documentation from #217.Accept multiple
network,IPv4arguments iniface addto match its existing help and examples. Reject malformed pairs with a usage error instead of panicking, and validate all pairs before sending a request. Add regression tests for the complete multi-address request and invalid input using the conventions fromtest/organize.Fixes #206
Supersedes #217
Checklist
make test(or equivalent) locally and all tests passgit commit -s) with my real name and email<filename>.licensesidecar (not applicable; none added or modified)LICENSES/directoryType of Change