Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4761fd8

Browse files
thaJeztahndeloof
authored andcommitted
pkg/compose: build: remove permissions warning on Windows
This warning was added in [moby@4a8b3ca] to print a warning when building Linux images from a Windows client. Window's filesystem does not have an "executable" bit, which mean that, for example, copying a shell script to an image during build would lose the executable bit. So for Windows clients, the executable bit would be set on all files, unconditionally. Originally this was detected in the client, which had direct access to the API response headers, but when refactoring the client to use a common library in [moby@535c4c9], this was refactored into a `ImageBuildResponse` wrapper, deconstructing the API response into an `io.Reader` and a string field containing only the `OSType` header. This was the only use and only purpose of the `OSType` field, and now that BuildKit is the default builder for Linux images, this warning didn't get printed unless BuildKit was explicitly disabled. This patch removes the warning, so that we can potentially remove the field, or the `ImageBuildResponse` type altogether. [moby@4a8b3ca]: moby/moby@4a8b3ca [moby@535c4c9]: moby/moby@535c4c9 Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 02c8e63 commit 4761fd8

File tree

2 files changed

+1
-15
lines changed

2 files changed

+1
-15
lines changed

pkg/api/dryrunclient.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,7 @@ func (d *DryRunClient) ImageBuild(ctx context.Context, reader io.Reader, options
218218
rc := io.NopCloser(bytes.NewReader(jsonMessage))
219219

220220
return build.ImageBuildResponse{
221-
Body: rc,
222-
OSType: "",
221+
Body: rc,
223222
}, nil
224223
}
225224

pkg/compose/build_classic.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"io"
2525
"os"
2626
"path/filepath"
27-
"runtime"
2827
"strings"
2928

3029
"github.com/compose-spec/compose-go/v2/types"
@@ -195,18 +194,6 @@ func (s *composeService) doBuildClassic(ctx context.Context, project *types.Proj
195194
}
196195
return "", err
197196
}
198-
199-
// Windows: show error message about modified file permissions if the
200-
// daemon isn't running Windows.
201-
if response.OSType != "windows" && runtime.GOOS == "windows" {
202-
// if response.OSType != "windows" && runtime.GOOS == "windows" && !options.quiet {
203-
_, _ = fmt.Fprintln(s.stdout(), "SECURITY WARNING: You are building a Docker "+
204-
"image from Windows against a non-Windows Docker host. All files and "+
205-
"directories added to build context will have '-rwxr-xr-x' permissions. "+
206-
"It is recommended to double check and reset permissions for sensitive "+
207-
"files and directories.")
208-
}
209-
210197
return imageID, nil
211198
}
212199

0 commit comments

Comments
 (0)