Skip to content
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

handled case sensitivity #2245

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/cache/cache_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (c *CacheOpts) Set(value string) error {
return errors.Errorf("invalid field '%s' must be a key=value pair", field)
}
key := strings.ToLower(parts[0])
value := strings.ToLower(parts[1])
value := parts[1]
if key == "type" {
switch value {
case "build":
Expand All @@ -86,7 +86,7 @@ func (c *CacheOpts) Set(value string) error {
return errors.Errorf("invalid field '%s' must be a key=value pair", field)
}
key := strings.ToLower(parts[0])
value := strings.ToLower(parts[1])
value := parts[1]
switch key {
case "format":
switch value {
Expand Down
21 changes: 21 additions & 0 deletions pkg/cache/cache_opts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,16 @@ func testCacheOpts(t *testing.T, when spec.G, it spec.S) {
input: fmt.Sprintf("type=launch;format=bind;source=%s/test-bind-volume-cache", homeDir),
output: fmt.Sprintf("type=build;format=volume;type=launch;format=bind;source=%s/test-bind-volume-cache/launch-cache;", homeDir),
},
{
name: "Case sensitivity test with uppercase path",
input: fmt.Sprintf("type=build;format=bind;source=%s/TestBindBuildCache", homeDir),
output: fmt.Sprintf("type=build;format=bind;source=%s/TestBindBuildCache/build-cache;type=launch;format=volume;", homeDir),
},
{
name: "Case sensitivity test with mixed case path",
input: fmt.Sprintf("type=build;format=bind;source=%s/TeStBiNdBuildCaChe", homeDir),
output: fmt.Sprintf("type=build;format=bind;source=%s/TeStBiNdBuildCaChe/build-cache;type=launch;format=volume;", homeDir),
},
}
} else {
testcases = []CacheOptTestCase{
Expand All @@ -253,6 +263,17 @@ func testCacheOpts(t *testing.T, when spec.G, it spec.S) {
input: fmt.Sprintf("type=launch;format=bind;source=%s\\test-bind-volume-cache", homeDir),
output: fmt.Sprintf("type=build;format=volume;type=launch;format=bind;source=%s\\test-bind-volume-cache\\launch-cache;", homeDir),
},
// Case sensitivity test cases for Windows
{
name: "Case sensitivity test with uppercase path",
input: fmt.Sprintf("type=build;format=bind;source=%s\\TestBindBuildCache", homeDir),
output: fmt.Sprintf("type=build;format=bind;source=%s\\TestBindBuildCache\\build-cache;type=launch;format=volume;", homeDir),
},
{
name: "Case sensitivity test with mixed case path",
input: fmt.Sprintf("type=build;format=bind;source=%s\\TeStBiNdBuildCaChe", homeDir),
output: fmt.Sprintf("type=build;format=bind;source=%s\\TeStBiNdBuildCaChe\\build-cache;type=launch;format=volume;", homeDir),
},
}
}

Expand Down
Loading