From a3912a4713db1d64d33e56df560435e6a99a6d41 Mon Sep 17 00:00:00 2001 From: Silvin Lubecki Date: Tue, 2 Apr 2019 13:22:30 +0200 Subject: [PATCH] cli/command/image/build_session.go:133:45: getBuildSharedKey - result 1 (error) is always nil (unparam) Signed-off-by: Silvin Lubecki (cherry picked from commit 75c60c1af7c8a3ca79e1af2f351b5b0d29960900) Signed-off-by: Sebastiaan van Stijn --- cli/command/image/build_session.go | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/cli/command/image/build_session.go b/cli/command/image/build_session.go index c19120758d..aa7b3fe9bf 100644 --- a/cli/command/image/build_session.go +++ b/cli/command/image/build_session.go @@ -35,16 +35,13 @@ func isSessionSupported(dockerCli command.Cli, forStream bool) bool { } func trySession(dockerCli command.Cli, contextDir string, forStream bool) (*session.Session, error) { - var s *session.Session - if isSessionSupported(dockerCli, forStream) { - sharedKey, err := getBuildSharedKey(contextDir) - if err != nil { - return nil, errors.Wrap(err, "failed to get build shared key") - } - s, err = session.NewSession(context.Background(), filepath.Base(contextDir), sharedKey) - if err != nil { - return nil, errors.Wrap(err, "failed to create session") - } + if !isSessionSupported(dockerCli, forStream) { + return nil, nil + } + sharedKey := getBuildSharedKey(contextDir) + s, err := session.NewSession(context.Background(), filepath.Base(contextDir), sharedKey) + if err != nil { + return nil, errors.Wrap(err, "failed to create session") } return s, nil } @@ -130,10 +127,10 @@ func (bw *bufferedWriter) String() string { return fmt.Sprintf("%s", bw.Writer) } -func getBuildSharedKey(dir string) (string, error) { +func getBuildSharedKey(dir string) string { // build session is hash of build dir with node based randomness s := sha256.Sum256([]byte(fmt.Sprintf("%s:%s", tryNodeIdentifier(), dir))) - return hex.EncodeToString(s[:]), nil + return hex.EncodeToString(s[:]) } func tryNodeIdentifier() string {