freeconf / yang

Standards-based management for Golang microservices
Apache License 2.0
38 stars 15 forks source link

Allow update a root node even if the strategy is insert #87

Closed HRogge closed 10 months ago

HRogge commented 1 year ago

This PR is a bit more experimental, but it allows to do a PUT request directly on the root node instead of only on sub-containers/nodes.

HRogge commented 1 year ago

I think the existing code in node/edit.go contains a bug... the block in the "editInsert" case is exactly the same as the code BEFORE the whole switch block.

What is going on there?

dhubler commented 11 months ago

I would not be surprised if replace/update to the root has issues and I can see how this would be very useful to support. For me to understand there is an issue, i'd like a test case that proves this. maybe you supplied one long ago, not sure, but can you post something here so i can verify the issue?

HRogge commented 11 months ago

Can you explain the code in node/edit.go a bit? The part in the function node() from line 156 (current master) to line 190.

If I understand this right the block line 174-180 does the same thing as line 187-190. Why do both of them exist?

There is also the point that if "strategy==editInsert" then an existing toChild will be released (by line 174-180) and then the whole function terminates with an error (line 185). Which suggests that at least the call to "Release" belongs into the switch-case block and not before it.

HRogge commented 10 months ago

I withdraw this for the moment because I am slowly becoming convinced I miss a piece of the puzzle... I might revisit it later with a new PR.