Skip to content

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

Merged
thaJeztah merged 1 commit into
docker:masterfrom
tiborvass:hide-buildkit-flags-if-not-enabled
Oct 11, 2018
Merged

build: only show buildkit-specific flags if buildkit is enabled#1427
thaJeztah merged 1 commit into
docker:masterfrom
tiborvass:hide-buildkit-flags-if-not-enabled

Conversation

@tiborvass

Copy link
Copy Markdown
Collaborator

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

@codecov-io

codecov-io commented Oct 10, 2018

Copy link
Copy Markdown

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

@thaJeztahthaJeztah left a comment

Copy link
Copy Markdown
Member

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

Comment threadcmd/docker/docker.go

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
tiborvassforce-pushed the hide-buildkit-flags-if-not-enabled branch from 6a509ee to efeec06CompareOctober 10, 2018 18:11
@tiborvass

Copy link
Copy Markdown
CollaboratorAuthor

@thaJeztah@AkihiroSuda fixed!

@AkihiroSuda

AkihiroSuda commented Oct 10, 2018

Copy link
Copy Markdown
Collaborator

--squash seems also ignored in BuildKit mode now?

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

cc @tonistiigi

@AkihiroSuda

Copy link
Copy Markdown
Collaborator

--compress also needs no-buildkit

@tiborvass
tiborvassforce-pushed the hide-buildkit-flags-if-not-enabled branch from efeec06 to 37ac307CompareOctober 10, 2018 19:03
@tiborvass

Copy link
Copy Markdown
CollaboratorAuthor

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

Comment threadcli/command/cli.go Outdated
serverInfo ServerInfo
clientInfo ClientInfo
contentTrust bool
buildkitEnabled *bool

Copy link
Copy Markdown
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)

Comment threadcli/command/cli.go Outdated

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

@tonistiigitonistiigiOct 10, 2018

Copy link
Copy Markdown
Member

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
tiborvassforce-pushed the hide-buildkit-flags-if-not-enabled branch 2 times, most recently from fcefefd to b98f5d5CompareOctober 10, 2018 21:08
Signed-off-by: Tibor Vass <tibor@docker.com>
@tiborvass
tiborvassforce-pushed the hide-buildkit-flags-if-not-enabled branch from b98f5d5 to bbd01feCompareOctober 10, 2018 21:09
Comment threadcmd/docker/docker.go
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
Copy Markdown
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
Copy Markdown
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

@thaJeztahthaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

Comment threadcmd/docker/docker.go
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
Copy Markdown
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 freeto 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

@tiborvass@codecov-io@AkihiroSuda@tonistiigi@thaJeztah@GordonTheTurtle