[kubeadm/app/..add other packages]Switch to github.com/pkg/errors

This commit is contained in:
qingsenLi
2018-11-09 18:54:03 +08:00
parent 66989e8bf3
commit e94dd19e03
12 changed files with 133 additions and 117 deletions

View File

@@ -17,10 +17,11 @@ limitations under the License.
package preflight
import (
"fmt"
"regexp"
"strings"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/util/version"
utilsexec "k8s.io/utils/exec"
)
@@ -38,7 +39,7 @@ func GetKubeletVersion(execer utilsexec.Interface) (*version.Version, error) {
cleanOutput := strings.TrimSpace(string(out))
subs := kubeletVersionRegex.FindAllStringSubmatch(cleanOutput, -1)
if len(subs) != 1 || len(subs[0]) < 2 {
return nil, fmt.Errorf("Unable to parse output from Kubelet: %q", cleanOutput)
return nil, errors.Errorf("Unable to parse output from Kubelet: %q", cleanOutput)
}
return version.ParseSemantic(subs[0][1])
}