-
Notifications
You must be signed in to change notification settings - Fork 15
support create-version operation #148
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
Conversation
a133b51 to
8f07909
Compare
8f07909 to
93cfe6c
Compare
93cfe6c to
92b39fc
Compare
creachadair
left a comment
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.
Mechanically this LGTM, though I would like to ask for a bit more text and test while we're here.
92b39fc to
1db40b0
Compare
acl/acl.go
Outdated
| // ActionCreateVersion ("create-version" in the API) denotes permission to | ||
| // create a specific version of a secret if and only if that version has no | ||
| // current value. |
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.
Optional simplification:
| // ActionCreateVersion ("create-version" in the API) denotes permission to | |
| // create a specific version of a secret if and only if that version has no | |
| // current value. | |
| // ActionCreateVersion ("create-version" in the API) denotes permission to | |
| // create a specific version of a secret if and only if that version does | |
| // not exist. |
since we do not allow version values to change.
And this actually raises an interesting corner case I hadn't considered: Previously it was not possible to delete and replace a version (because any new version got a previously-unused version counter), but this allows that to happen.
I'm not sure if we care about that, but it makes me worry slightly: Does it matter if someone has a reliance interest on a value that may be now different, i.e., that the ID is no longer a reliable indicator of its content?
I wonder if we should consider making deleting a version leave a tombstone (remove the value, set a flag, perhaps), so that we cannot re-create the same version again later.
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 wonder if we should consider making deleting a version leave a tombstone
This is where my mind went after reading your previous sentence :)
Really great catch!
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.
Okay, I implemented this. I considered using a sentinel value, but instead I track deletions in their own map. This way we don't have to try to discern between a sentinel value and a real value.
| // UNIX timestamps. This simulates that. | ||
| year2099 := api.SecretVersion(time.Date(2099, 12, 31, 24, 60, 60, 0, time.UTC).Unix()) | ||
|
|
||
| t.Run("create", func(t *testing.T) { |
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.
Nit: The convention we used in the existing tests was MixedCase or MixedCase_withQualifier.
60213be to
6d62412
Compare
creachadair
left a comment
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! I appreciate your patience talking through it all.
The `create-version` operation Creates a specific version of a secret, sets its value and immediately activates that version. It fails with HTTP status 412 (precondition failed) if this version of the secret was ever set, even if it has since been deleted.. Updates tailscale/corp#34020 Signed-off-by: Percy Wegmann <[email protected]>
6d62412 to
74b6c38
Compare
Likewise! |
The
create-versionoperation Creates a specific version of a secret, sets its value andimmediately activates that version. It fails with HTTP status 412 (precondition failed) if this
version of the secret already has a value.
Updates tailscale/corp#34020