-
Notifications
You must be signed in to change notification settings - Fork 8
policyfile: add SetAndGet method #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
policyfile: add SetAndGet method #8
Conversation
policyfile.go
Outdated
|
|
||
| // Set sets the [ACL] for the tailnet and returns the resulting [ACL]. | ||
| // etag is an optional value that, if supplied, will be used in the "If-Match" HTTP request header. | ||
| func (pr *PolicyFileResource) SetAndGet(ctx context.Context, acl any, etag string) (*ACL, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just modify the behaviour of Set to return the *ACL instead of adding a new method, or are you thinking there is worth in keeping both here to ease v1 -> v2 migration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a 2nd method for three reasons:
- To avoid breaking clients who already use the existing method
- To avoid doing work that the above clients don't need (i.e. deserializing the response JSON)
Setaccepts both anACLas well as a HuJSON string. For symmetry, that would imply thatSetwould return either anACLor a HuJSON string depending on what was passed in, meaning that the return type would have to beany, which isn't very ergonomic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set accepts both an ACL as well as a HuJSON string
Having said that out loud, I'm now realizing that the new method does the same. Thinking ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signature fixed.
74a18f6 to
62faeb5
Compare
Add 'AdvertisedRoutes', 'EnabledRoutes' and 'ClientConnectivity' to the 'Device' type and add the method 'ListWithAllFields' to obtain Devices with those fields populated. Updates tailscale/corp#22748 Signed-off-by: Percy Wegmann <[email protected]>
a6b6284 to
f78cb7b
Compare
This variant of Set returns the resulting ACL with its updated ETag. Updates tailscale/corp#22748 Signed-off-by: Percy Wegmann <[email protected]>
f78cb7b to
2b21016
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after a rebase / retargeting of the branch to main.
This variant of Set returns the resulting ACL with its updated ETag.
Updates tailscale/corp#22748