Standardize `namerctl dtab update` behaviour when a version is included in the dtab file
- Dominant language
- Go
- Stars
- 30
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
We check the `version` of the dtab on `namerctl dtab update` if we send the dtab in json format (and do a versioned update), but we don't if the dtab is sent via yaml, where the version is included in a comment (i.e. we do a versionless update).
If you just have a json file without setting the `version` key, (or a yaml file with or without the version included as a comment) then both json and yaml behave the same, i.e. will do versionless updated unless a version is provided using the `--version` flag.
This is confusing for users (#21). We should standardize. i.e. when a version is included in json or yaml, we should use it in both cases.
## Example
When you do a `namerctl dtab get `, namerctl prints the dtab string with the version as a yaml comment. The user can then make updates to the dtab they received and run a `namerctl dtab update ` and the update will work:
```bash
$ namerctl dtab get default
# version AAAAAAAAAAQ=
/svc => /#/io.l5d.fs ;
$ namerctl dtab get default > default.yaml
# update default.yaml without changing the version
$ namerctl dtab update default default.yaml
Updated default
# update default.yaml *again* without changing the version
$ namerctl dtab update default default.yaml
Updated default
```
However, if you do the same steps, but add `--json`, you'll get a `unexpected response: 412 Precondition Failed` because we do check the version if it's included in the json payload:
```bash
$ namerctl dtab get default --json
{"version":"AAAAAAAAAAg=","dtab":[{"prefix":"/svc","dst":"/#/io.l5d.fs"}]}
$ namerctl dtab get default --json > default.json
# update default.json without changing the version
$ namerctl dtab update default default.json
Updated default
# update default.json *again* without changing the version
$ namerctl dtab update default default.json
Error: unexpected response: 412 Precondition Failed
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing the `namerctl dtab update` handling for JSON and YAML input, focusing on how each format extracts and sends a version. Verify the behavior with the command examples in this issue; done means an embedded version is handled consistently for both formats, including repeated updates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100