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

build: only show buildkit-specific flags if buildkit is enabled #1427

Merged

Conversation

tiborvass
Copy link
Collaborator

Signed-off-by: Tibor Vass tibor@docker.com

@codecov-io
Copy link

codecov-io commented Oct 10, 2018

Codecov Report

Merging #1427 into master will decrease coverage by 0.02%.
The diff coverage is 23.33%.

@@            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

Copy link
Member

@thaJeztah thaJeztah left a 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

cmd/docker/docker.go Show resolved Hide resolved
@@ -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.

@tiborvass tiborvass force-pushed the hide-buildkit-flags-if-not-enabled branch from 6a509ee to efeec06 Compare October 10, 2018 18:11
@tiborvass
Copy link
Collaborator Author

@thaJeztah @AkihiroSuda fixed!

@AkihiroSuda
Copy link
Collaborator

AkihiroSuda commented Oct 10, 2018

--squash seems also ignored in BuildKit mode now?

Probably, we should explicitly reject --squash for security purpose.

cc @tonistiigi

@AkihiroSuda
Copy link
Collaborator

--compress also needs no-buildkit

@tiborvass tiborvass force-pushed the hide-buildkit-flags-if-not-enabled branch from efeec06 to 37ac307 Compare October 10, 2018 19:03
@tiborvass
Copy link
Collaborator Author

@AkihiroSuda fixed. I didn't error out for squash yet, unless we agree it's needed.
@tonistiigi changed the BuildKitEnabled() method to a utility function.

@@ -69,6 +70,7 @@ type DockerCli struct {
serverInfo ServerInfo
clientInfo ClientInfo
contentTrust bool
buildkitEnabled *bool
Copy link
Member

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)

@@ -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) {
Copy link
Member

@tonistiigi tonistiigi Oct 10, 2018

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) {

@tiborvass tiborvass force-pushed the hide-buildkit-flags-if-not-enabled branch 2 times, most recently from fcefefd to b98f5d5 Compare October 10, 2018 21:08
Signed-off-by: Tibor Vass <tibor@docker.com>
@tiborvass tiborvass force-pushed the hide-buildkit-flags-if-not-enabled branch from b98f5d5 to bbd01fe Compare October 10, 2018 21:09
@@ -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
Copy link
Collaborator

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

Copy link
Member

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

Copy link
Member

@thaJeztah thaJeztah left a 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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants