-
Notifications
You must be signed in to change notification settings - Fork 18.9k
pkg/archive: make CanonicalTarNameForPath an alias for filepath.ToSlash #44060
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
filepath.ToSlash is already a no-op on non-Windows platforms, so there's no need to provide multiple implementations. We could consider deprecating this function, but it's used in the CLI, and perhaps it's still useful to have a canonical location to perform this normalization. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Now that CanonicalTarNameForPath is an alias for filepath.ToSlash, they were mostly redundant, and only testing Go's stdlib. Coverage for filepath.ToSlash is provided through TestCanonicalTarName, which does a superset of CanonicalTarNameForPath, Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| func TestCanonicalTarNameForPath(t *testing.T) { | ||
| cases := []struct{ in, expected string }{ | ||
| {"foo", "foo"}, |
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 kept the removal of the tests as a separate commit; if there's concerns about not having these tests (they should be covered by TestCanonicalTarName below), I can drop the second commit.
| func CanonicalTarNameForPath(relativePath string) string { | ||
| return filepath.ToSlash(relativePath) | ||
| } |
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.
FWIW; #37356 (comment) already suggested to (deprecate and) remove this function altogether, which is something that still could be considered.
|
@tonistiigi @corhere PTAL |
|
let me bring this one in |
pkg/archive: make CanonicalTarNameForPath and alias for filepath.ToSlash
filepath.ToSlash is already a no-op on non-Windows platforms, so there's no
need to provide multiple implementations.
We could consider deprecating this function, but it's used in the CLI, and
perhaps it's still useful to have a canonical location to perform this normalization.
pkg/archive: remove tests for CanonicalTarNameForPath
Now that CanonicalTarNameForPath is an alias for filepath.ToSlash, they were
mostly redundant, and only testing Go's stdlib. Coverage for filepath.ToSlash is
provided through TestCanonicalTarName, which does a superset of CanonicalTarNameForPath,