fixed issue with windows using bash script

This commit is contained in:
Brad Rydzewski
2019-11-01 09:28:42 -07:00
parent fcfc72f508
commit 2e1fc1a142
6 changed files with 57 additions and 12 deletions

View File

@@ -0,0 +1,26 @@
// Copyright 2019 Drone.IO Inc. All rights reserved.
// Use of this source code is governed by the Polyform License
// that can be found in the LICENSE file.
package errors
import (
"errors"
"strings"
)
// TrimExtraInfo is a helper function that trims extra information
// from a Docker error. Specifically, on Windows, this can expose
// environment variables and other sensitive data.
func TrimExtraInfo(err error) error {
s := err.Error()
i := strings.Index(s, "extra info:")
if i > 0 {
s = s[:i]
s = strings.TrimSpace(s)
s = strings.TrimSuffix(s, "(0x2)")
s = strings.TrimSpace(s)
return errors.New(s)
}
return err
}