cli/command/image/build_session.go:133:45: getBuildSharedKey - result 1 (error) is always nil (unparam)

Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
This commit is contained in:
Silvin Lubecki 2019-04-02 13:22:30 +02:00 committed by Sebastiaan van Stijn
parent 28ac2f82c6
commit 75c60c1af7
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 9 additions and 12 deletions

View File

@ -27,24 +27,21 @@ func isSessionSupported(dockerCli command.Cli, forStream bool) bool {
} }
func trySession(dockerCli command.Cli, contextDir string, forStream bool) (*session.Session, error) { func trySession(dockerCli command.Cli, contextDir string, forStream bool) (*session.Session, error) {
var s *session.Session if !isSessionSupported(dockerCli, forStream) {
if isSessionSupported(dockerCli, forStream) { return nil, nil
sharedKey, err := getBuildSharedKey(contextDir) }
if err != nil { sharedKey := getBuildSharedKey(contextDir)
return nil, errors.Wrap(err, "failed to get build shared key") s, err := session.NewSession(context.Background(), filepath.Base(contextDir), sharedKey)
} if err != nil {
s, err = session.NewSession(context.Background(), filepath.Base(contextDir), sharedKey) return nil, errors.Wrap(err, "failed to create session")
if err != nil {
return nil, errors.Wrap(err, "failed to create session")
}
} }
return s, nil return s, nil
} }
func getBuildSharedKey(dir string) (string, error) { func getBuildSharedKey(dir string) string {
// build session is hash of build dir with node based randomness // build session is hash of build dir with node based randomness
s := sha256.Sum256([]byte(fmt.Sprintf("%s:%s", tryNodeIdentifier(), dir))) s := sha256.Sum256([]byte(fmt.Sprintf("%s:%s", tryNodeIdentifier(), dir)))
return hex.EncodeToString(s[:]), nil return hex.EncodeToString(s[:])
} }
func tryNodeIdentifier() string { func tryNodeIdentifier() string {