Skip to content

Patching with comments #41

@jspc

Description

@jspc

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"],                                                                                                         
                },                                                                        

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions