-
Notifications
You must be signed in to change notification settings - Fork 932
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
Make shared.IsSnapshot()
a bit more strict
#14577
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Simon Deziel <[email protected]>
Signed-off-by: Simon Deziel <[email protected]>
Signed-off-by: Simon Deziel <[email protected]>
Signed-off-by: Simon Deziel <[email protected]>
Signed-off-by: Simon Deziel <[email protected]>
Signed-off-by: Simon Deziel <[email protected]>
Signed-off-by: Simon Deziel <[email protected]>
3c4ab2e
to
9b1edc8
Compare
9b1edc8
to
3b81126
Compare
Avoid accessing slice out of bound if no `%d` is present in the pattern. The snapshot pattern doesn't need `%d` to be escaped now that `Sprintf` isn't used. Signed-off-by: Simon Deziel <[email protected]>
Signed-off-by: Simon Deziel <[email protected]>
Signed-off-by: Simon Deziel <[email protected]>
Signed-off-by: Simon Deziel <[email protected]>
…itting Signed-off-by: Simon Deziel <[email protected]>
Signed-off-by: Simon Deziel <[email protected]>
Signed-off-by: Simon Deziel <[email protected]>
Signed-off-by: Simon Deziel <[email protected]>
Signed-off-by: Simon Deziel <[email protected]>
Avoid accessing slice out of bound if no `%d` is present in the pattern. The snapshot pattern doesn't need `%d` to be escaped now that `Sprintf` isn't used. Signed-off-by: Simon Deziel <[email protected]>
Signed-off-by: Simon Deziel <[email protected]>
Signed-off-by: Simon Deziel <[email protected]>
The validate.IsHostname() already rejects `/` so there is no need to explicitly check for `/` in the instance name. Signed-off-by: Simon Deziel <[email protected]>
Signed-off-by: Simon Deziel <[email protected]>
Signed-off-by: Simon Deziel <[email protected]>
Signed-off-by: Simon Deziel <[email protected]>
Signed-off-by: Simon Deziel <[email protected]>
Signed-off-by: Simon Deziel <[email protected]>
Signed-off-by: Simon Deziel <[email protected]>
3b81126
to
b952518
Compare
parts := strings.SplitN(name, shared.SnapshotDelimiter, 2) | ||
instanceName := parts[0] | ||
snapshotName := parts[1] | ||
if shared.IsSnapshot(name) { |
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.
Maybe we should just use api.GetParentAndSnapshotName
everywhere (or at least in more places) and update it to use strings.Cut. This way we don't have to repeat the check for /
in the string.
@@ -651,9 +651,10 @@ func (r BytesReadCloser) Close() error { | |||
return nil | |||
} | |||
|
|||
// IsSnapshot returns true if a given name contains the snapshot delimiter. | |||
// IsSnapshot returns true if a given name contains a snapshot delimiter not at the end. | |||
func IsSnapshot(name string) bool { |
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.
Probably we should centralise the "is snapshot/extract snapshot parts" into api.GetParentAndSnapshotName instead.
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've not gone through this in detail yet, but one comment is that we've consciously avoided using IsSnapshot
or api.GetParentAndSnapshotName
in the past in places where the variable being checked isn't representing a possible instance or volume fully qualified snapshot name.
I.e instance backups follows the same style but they represent different things and could evolve separately, so maybe we also need a separate function for other conceptual fully qualified entities.
No description provided.