Patching with comments
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 869
- Forks
- 33
- PR merge metrics
- No merged PRs in 30d
Description
Hey all- we're updating our tailnet config to have a posture/ grant per production device on our network, since we have a load of devices, and we don't want to manage this by hand, and because we want to use time-based/ device-based access.
It's working very nicely (loving the Value.Patch() function).
Is there anyway of patching in comments, too, outside of the patched in object? We still want people to be able to hand read/ review the policy, and being able to add comments would help that a lot.
If I set my patch like:
err = v.Patch([]byte(`[
{"op": "add", "path": "/grants/0", "value":{
"src": ["autogroup:member"],
// My super duper device
"dst": ["ipset:super_duper_device"],
"srcPosture": ["posture:super_duper_device_TemporaryFullAccess"]}}
]`))
if err != nil {
panic(err)
}
Then sure enough, I see:
"grants": [
{
"src": ["autogroup:member"],
// My super duper device
"dst": ["ipset:super_duper_device"],
"srcPosture": ["posture:super_duper_device_TemporaryFullAccess"],
},
But if I move the comment outside of the block as per:
err = v.Patch([]byte(`[
{"op": "add", "path": "/grants/0", "value":
// My super duper device
{
"src": ["autogroup:member"],
"dst": ["ipset:super_duper_device"],
"srcPosture": ["posture:super_duper_device_TemporaryFullAccess"]}}
]`))
if err != nil {
panic(err)
}
Then the comment isn't persisted:
"grants": [
{
"src": ["autogroup:member"],
"dst": ["ipset:super_duper_device"],
"srcPosture": ["posture:super_duper_device_TemporaryFullAccess"],
},
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Value.Patch entry point and compare the two patch examples to trace how comments are handled around an inserted value. Determine whether comments outside the patched object can be retained, and verify that the resulting policy preserves the requested human-readable comment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100