-
Notifications
You must be signed in to change notification settings - Fork 12
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
Compile and run on Windows #186
Conversation
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.
Thanks for the PR.
Please undo the changes to the vendored files, as described in the comments.
There are more occurrences of using functions of the path
instead of the filepath
package when working with filesystem paths in the code.
Don't they all need to be replaced?
I feel like these changes can be made independently from actually building a Windows binary at this time.
Yes, we can do that in a follow-up step.
Before offering windows binaries we also need to run all tests also on Windows in CI.
@@ -103,13 +102,13 @@ func mkdirall(path string, applyACL bool, sddl string) error { | |||
// and Local System. | |||
func mkdirWithACL(name string, sddl string) error { | |||
sa := windows.SecurityAttributes{Length: 0} | |||
sd, err := winio.SddlToSecurityDescriptor(sddl) | |||
sd, err := windows.SecurityDescriptorFromString(sddl) |
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.
The file of vendored libraries must never be changed. They must be in the same state then the upstream library in the same version.
If the change is in the upstream library please update it via go get
and go mod vendor
.
If it is not, we have to try to get the change into the upstream version. In the worst case the library needs to be forked.
Can we postpone the change until the upstream library was updated? What will break without the change?
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.
Thanks for explaining this to me. As mentioned I'm new to Go and did find it a bit strange that the vendor files are committed into the repo compared to how other languages work (e.g. the dist
directory isn't normally committed when using npm).
It appears that the required change has been made in the upstream library, I'll work towards getting the module reference updated.
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.
It appears that the upstream library has the required change but an updated package has not yet been released.
I will close this PR until github.com/docker/docker
is released with this change.
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.
Thanks for explaining this to me. As mentioned I'm new to Go and did find it a bit strange that the vendor files are committed into the repo compared to how other languages work (e.g. the
dist
directory isn't normally committed when using npm).
By default they aren't. Only the versions and checksums of 3. party libraries are listed in the go.mod and go.sum files.
I prefer to create the offline copies of the libraries, to not have dependencies to 3. party services.
If github and the go module proxies became unavailable or the references are deleted, it would not be possible to build baur anymore.
It also speeds up CI tasks a bit, if the GOCACHE is not shared between all steps :-).
It appears that the upstream library has the required change but an updated package has not yet been released.
I will close this PR until github.com/docker/docker is released with this change.
Could you explain to me why the change is a must have?
Without it, it's not possible to upload docker images at all?
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.
Sorry about the lack of response. I'm looking at supporting baur on Windows again now.
baur does not compile on Windows without this change
$ go build
# github.com/docker/docker/pkg/system
vendor\github.com\docker\docker\pkg\system\filesys_windows.go:112:24: cannot use uintptr(unsafe.Pointer(&sd[0])) (type uintptr) as type *"golang.org/x/sys/windows".SECURITY_DESCRIPTOR in assignment
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.
Ok, best might be switching to using the official docker client instead of fsouze/go-dockerclient (#189).
All other issues that were fixed in this PR should already be in master. The filepath functions are used, Commands are run directly not via /bin/sh
anymore.
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.
Having the Commands run directly has been great so far, thanks for making that change 💯
Unfortunately the issue resides in the official docker client, not in fsouze/go-dockerclient.
This describes the breaking change to the golang.org/x/sys module golang/go#34610
The fix (moby/moby#40021) was merged into the official docker client master branch late last year but has not been released yet. It appears it will be a part of v20 and has not been back-ported into any of the older versions.
There are 2 options that I can think of:
- Wait until the official docker client has been released with the fix
- Pin the golang.org/x/sys module to the version before the breaking change was made. Rancher have made this change (pin golang.org/x/sys due to breaking API change rancher/rke#2204).
I have got baur compiling with option 2 and am working through the initial test failures on Windows
@@ -191,7 +191,7 @@ func NewApp(repository *Repository, cfgPath string) (*App, error) { | |||
cfgPath) | |||
} | |||
|
|||
appAbsPath := path.Dir(cfgPath) | |||
appAbsPath := filepath.Dir(cfgPath) |
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.
Same here, we can not change vendored files.
Instead we have to it the following way:
I created a branch based on baur 0.18.0 to replace path
pkg uses with using the functions from the filepath
package instead: 5951bd9.
Please double-check if it contains all needed changes.
If it looks fine to you, I'll create a baur 0.18.1 release.
Then we update the reference of the vendored github.com/simplesurance/baur
version to 0.18.1 in your branch.
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.
Even though I plan on closing this PR until the github.com/docker/docker
module is updated with the required changes it would still be helpful to create the 0.18.1 release with the path
-> filepath
changes.
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 was trying to limit the amount of change to only what was required to getting Baur running on Windows. I'm more than happy to update any other references to |
Closing until |
@StephenDiligent we could also fix the |
This fixes issues when running baur on non-unix operation systems related pr: #186
This fixes issues when running baur on non-unix operation systems related pr: #186
This will allow Baur to compile and run on Windows.
path
have been replaced withfilepath
. From the Go documentation Package filepath implements utility routines for manipulating filename paths in a way compatible with the target operating system-defined file paths.filesys_windows.go
has been updated to use the newer SecurityAttributes struct, see Move to upstream Sddl/SecurityAttribute functions.I feel like these changes can be made independently from actually building a Windows binary at this time.
I plan on making the required changes to the
Makefile
to produce the Windows binary and updating the CI process to run the test cases in due time.