Merge pull request #1474 from tiborvass/fix-build-stream

build: update session support detection
This commit is contained in:
Tibor Vass 2018-10-22 16:01:12 -07:00 committed by GitHub
commit ea836abed5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -350,7 +350,7 @@ func runBuild(dockerCli command.Cli, options buildOptions) error {
buildCtx = dockerfileCtx buildCtx = dockerfileCtx
} }
s, err := trySession(dockerCli, contextDir) s, err := trySession(dockerCli, contextDir, true)
if err != nil { if err != nil {
return err return err
} }

View File

@ -43,7 +43,7 @@ var errDockerfileConflict = errors.New("ambiguous Dockerfile source: both stdin
func runBuildBuildKit(dockerCli command.Cli, options buildOptions) error { func runBuildBuildKit(dockerCli command.Cli, options buildOptions) error {
ctx := appcontext.Context() ctx := appcontext.Context()
s, err := trySession(dockerCli, options.context) s, err := trySession(dockerCli, options.context, false)
if err != nil { if err != nil {
return err return err
} }

View File

@ -27,16 +27,16 @@ import (
const clientSessionRemote = "client-session" const clientSessionRemote = "client-session"
func isSessionSupported(dockerCli command.Cli) bool { func isSessionSupported(dockerCli command.Cli, forStream bool) bool {
if versions.GreaterThanOrEqualTo(dockerCli.Client().ClientVersion(), "1.39") { if !forStream && versions.GreaterThanOrEqualTo(dockerCli.Client().ClientVersion(), "1.39") {
return true return true
} }
return dockerCli.ServerInfo().HasExperimental && versions.GreaterThanOrEqualTo(dockerCli.Client().ClientVersion(), "1.31") return dockerCli.ServerInfo().HasExperimental && versions.GreaterThanOrEqualTo(dockerCli.Client().ClientVersion(), "1.31")
} }
func trySession(dockerCli command.Cli, contextDir string) (*session.Session, error) { func trySession(dockerCli command.Cli, contextDir string, forStream bool) (*session.Session, error) {
var s *session.Session var s *session.Session
if isSessionSupported(dockerCli) { if isSessionSupported(dockerCli, forStream) {
sharedKey, err := getBuildSharedKey(contextDir) sharedKey, err := getBuildSharedKey(contextDir)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "failed to get build shared key") return nil, errors.Wrap(err, "failed to get build shared key")