Skip to content

Conversation

@thaJeztah
Copy link
Member

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,

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>
@thaJeztah thaJeztah added status/2-code-review kind/refactor PR's that refactor, or clean-up code labels Aug 30, 2022
Comment on lines -26 to -28
func TestCanonicalTarNameForPath(t *testing.T) {
cases := []struct{ in, expected string }{
{"foo", "foo"},
Copy link
Member Author

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.

Comment on lines +561 to +563
func CanonicalTarNameForPath(relativePath string) string {
return filepath.ToSlash(relativePath)
}
Copy link
Member Author

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.

@thaJeztah
Copy link
Member Author

@tonistiigi @corhere PTAL

@thaJeztah
Copy link
Member Author

let me bring this one in

@thaJeztah thaJeztah merged commit a39ba09 into moby:master Sep 21, 2022
@thaJeztah thaJeztah deleted the archive_cleanup branch September 21, 2022 16:01
@thaJeztah thaJeztah changed the title pkg/archive: make CanonicalTarNameForPath and alias for filepath.ToSlash pkg/archive: make CanonicalTarNameForPath an alias for filepath.ToSlash Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/refactor PR's that refactor, or clean-up code status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants