-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
build: only show buildkit-specific flags if buildkit is enabled #1427
build: only show buildkit-specific flags if buildkit is enabled #1427
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1427 +/- ##
=========================================
- Coverage 54.22% 54.2% -0.03%
=========================================
Files 289 289
Lines 19359 19378 +19
=========================================
+ Hits 10498 10503 +5
- Misses 8185 8199 +14
Partials 676 676 |
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.
changes LGTM, but left a command on updating the flag descriptions
@@ -159,9 +158,11 @@ func NewBuildCommand(dockerCli command.Cli) *cobra.Command { | |||
|
|||
flags.StringArrayVar(&options.secrets, "secret", []string{}, "Secret file to expose to the build (only if BuildKit enabled): id=mysecret,src=/local/secret") | |||
flags.SetAnnotation("secret", "version", []string{"1.39"}) | |||
flags.SetAnnotation("secret", "buildkit", nil) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
6a509ee
to
efeec06
Compare
@thaJeztah @AkihiroSuda fixed! |
Probably, we should explicitly reject cc @tonistiigi |
|
efeec06
to
37ac307
Compare
@AkihiroSuda fixed. I didn't error out for squash yet, unless we agree it's needed. |
cli/command/cli.go
Outdated
@@ -69,6 +70,7 @@ type DockerCli struct { | |||
serverInfo ServerInfo | |||
clientInfo ClientInfo | |||
contentTrust bool | |||
buildkitEnabled *bool |
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.
linting is failing on this one;
cli/command/cli.go:73:2:warning: field buildkitEnabled is unused (U1000) (unused)
cli/command/cli.go
Outdated
@@ -133,6 +135,20 @@ func (cli *DockerCli) ContentTrustEnabled() bool { | |||
return cli.contentTrust | |||
} | |||
|
|||
// BuildKitEnabled returns whether buildkit is enabled either through a daemon setting | |||
// or otherwise the client-side DOCKER_BUILDKIT environment variable | |||
func BuildKitEnabled(cli interface{ ServerInfo() ServerInfo }) (bool, error) { |
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.
func BuildKitEnabled(si ServerInfo) (bool, error) {
fcefefd
to
b98f5d5
Compare
Signed-off-by: Tibor Vass <tibor@docker.com>
b98f5d5
to
bbd01fe
Compare
@@ -313,6 +324,7 @@ func areFlagsSupported(cmd *cobra.Command, details versionDetails) error { | |||
if _, ok := f.Annotations["experimentalCLI"]; ok && !hasExperimentalCLI { | |||
errs = append(errs, fmt.Sprintf("\"--%s\" is on a Docker cli with experimental cli features enabled", f.Name)) | |||
} | |||
// buildkit-specific flags are noop when buildkit is not enabled, so we do not add an error in that case |
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.
Maybe we can still print logrus.Warn
warnings, especially for NOP --squash
with BuildKit mode
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.
Could make sense to inform them that an option is only supported with/without buildkit, and will be ignored.
Given that we're already ignoring those flags in the current code, I think that'd be good to do separately, in a follow-up;
DOCKER_BUILDKIT=1 docker build --squash .
[+] Building 0.3s (4/4) FINISHED
=> local://context (.dockerignore) 0.0s
=> => transferring context: 2B 0.0s
=> local://dockerfile (Dockerfile) 0.0s
=> => transferring dockerfile: 31B 0.0s
=> CACHED docker-image://docker.io/library/alpine:latest 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:0b4ed36840824a86314da6264a95047c664f3c2fe90d0b1a6ddb118e20f106a2
DOCKER_BUILDKIT=0 docker build --progress=plain .
Sending build context to Docker daemon 2.048kB
Step 1/1 : FROM alpine
---> 11cd0b38bc3c
Successfully built 11cd0b38bc3c
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.
LGTM, thanks!
@@ -313,6 +324,7 @@ func areFlagsSupported(cmd *cobra.Command, details versionDetails) error { | |||
if _, ok := f.Annotations["experimentalCLI"]; ok && !hasExperimentalCLI { | |||
errs = append(errs, fmt.Sprintf("\"--%s\" is on a Docker cli with experimental cli features enabled", f.Name)) | |||
} | |||
// buildkit-specific flags are noop when buildkit is not enabled, so we do not add an error in that case |
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.
Could make sense to inform them that an option is only supported with/without buildkit, and will be ignored.
Given that we're already ignoring those flags in the current code, I think that'd be good to do separately, in a follow-up;
DOCKER_BUILDKIT=1 docker build --squash .
[+] Building 0.3s (4/4) FINISHED
=> local://context (.dockerignore) 0.0s
=> => transferring context: 2B 0.0s
=> local://dockerfile (Dockerfile) 0.0s
=> => transferring dockerfile: 31B 0.0s
=> CACHED docker-image://docker.io/library/alpine:latest 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:0b4ed36840824a86314da6264a95047c664f3c2fe90d0b1a6ddb118e20f106a2
DOCKER_BUILDKIT=0 docker build --progress=plain .
Sending build context to Docker daemon 2.048kB
Step 1/1 : FROM alpine
---> 11cd0b38bc3c
Successfully built 11cd0b38bc3c
Signed-off-by: Tibor Vass tibor@docker.com