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

cli/command/container: use local copy of pkg/system.IsAbs #5697

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

thaJeztah
Copy link
Member

@thaJeztah thaJeztah added status/2-code-review kind/refactor PR's that refactor, or clean-up code area/go-sdk Changes affecting the Go SDK process/cherry-pick/27.x labels Dec 16, 2024
@thaJeztah thaJeztah added this to the 28.0.0 milestone Dec 16, 2024
@thaJeztah thaJeztah self-assigned this Dec 16, 2024
@codecov-commenter
Copy link

codecov-commenter commented Dec 16, 2024

Codecov Report

Attention: Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 59.52%. Comparing base (91d097e) to head (1eda498).
Report is 20 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5697   +/-   ##
=======================================
  Coverage   59.51%   59.52%           
=======================================
  Files         346      346           
  Lines       29379    29381    +2     
=======================================
+ Hits        17486    17488    +2     
  Misses      10923    10923           
  Partials      970      970           

Comment on lines +451 to +461
// IsAbs is a platform-agnostic wrapper for filepath.IsAbs.
//
// On Windows, golang filepath.IsAbs does not consider a path \windows\system32
// as absolute as it doesn't start with a drive-letter/colon combination. However,
// in docker we need to verify things such as WORKDIR /windows/system32 in
// a Dockerfile (which gets translated to \windows\system32 when being processed
// by the daemon). This SHOULD be treated as absolute from a docker processing
// perspective.
func isAbs(path string) bool {
return filepath.IsAbs(path) || strings.HasPrefix(path, string(os.PathSeparator))
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually wondering now if we should share the implementation from the compose-loader, which has a more comprehensive implementation adopted from go stdlib;

// This file contains utilities to check for Windows absolute paths on Linux.
// The code in this file was largely copied from the Golang filepath package
// https://github.com/golang/go/blob/1d0e94b1e13d5e8a323a63cd1cc1ef95290c9c36/src/path/filepath/path_windows.go#L12-L65
func isSlash(c uint8) bool {
return c == '\\' || c == '/'
}
// isAbs reports whether the path is a Windows absolute path.
func isAbs(path string) (b bool) {
l := volumeNameLen(path)
if l == 0 {
return false
}
path = path[l:]
if path == "" {
return false
}
return isSlash(path[0])
}

Copy link
Member Author

@thaJeztah thaJeztah Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think we can currently consolidate those as they have slightly different semantics (compose allows C:\some-path, C:/some-path, but not /some-path or \\some-path), but possibly something to look into

Copy link
Member

@laurazard laurazard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thaJeztah thaJeztah merged commit 8454e01 into docker:master Dec 16, 2024
107 checks passed
@thaJeztah thaJeztah deleted the remove_system_isabs branch December 16, 2024 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/go-sdk Changes affecting the Go SDK kind/refactor PR's that refactor, or clean-up code process/cherry-picked status/2-code-review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants