From 69b145e83faa1df0b16a01976e64df72872103ec Mon Sep 17 00:00:00 2001 From: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com> Date: Thu, 6 Aug 2020 11:13:19 +0200 Subject: [PATCH] artifactPrepareVersion: improve error categorization (#1889) * artifactPrepareVersion: improve error categorization * go mod tidy --- cmd/artifactPrepareVersion.go | 14 ++++++++++++++ go.sum | 2 ++ 2 files changed, 16 insertions(+) diff --git a/cmd/artifactPrepareVersion.go b/cmd/artifactPrepareVersion.go index 6ae63eae5..18d8e00bc 100644 --- a/cmd/artifactPrepareVersion.go +++ b/cmd/artifactPrepareVersion.go @@ -330,6 +330,20 @@ func pushChanges(config *artifactPrepareVersionOptions, newVersion string, repos err = repository.Push(&pushOptions) if err != nil { + errText := fmt.Sprint(err) + switch { + case strings.Contains(errText, "ssh: handshake failed"): + log.SetErrorCategory(log.ErrorConfiguration) + case strings.Contains(errText, "Permission"): + log.SetErrorCategory(log.ErrorConfiguration) + case strings.Contains(errText, "knownhosts: illegal base64"): + err = errors.Wrap(err, "known_hosts file seems invalid") + log.SetErrorCategory(log.ErrorConfiguration) + case strings.Contains(errText, "unable to find any valid known_hosts file"): + log.SetErrorCategory(log.ErrorConfiguration) + case strings.Contains(errText, "connection timed out"): + log.SetErrorCategory(log.ErrorInfrastructure) + } return commitID, err } diff --git a/go.sum b/go.sum index b7fd8fb42..02323d190 100644 --- a/go.sum +++ b/go.sum @@ -75,6 +75,7 @@ github.com/Azure/go-autorest/autorest/validation v0.1.0/go.mod h1:Ha3z/SqBeaalWQ github.com/Azure/go-autorest/autorest/validation v0.2.0/go.mod h1:3EEqHnBxQGHXRYq3HT1WyXAvT7LLY3tl70hw6tQIbjI= github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a/go.mod h1:EFZQ978U7x8IRnstaskI3IysnWY5Ao3QgZUKOXlsAdw= @@ -1452,6 +1453,7 @@ honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= k8s.io/api v0.17.4/go.mod h1:5qxx6vjmwUVG2nHQTKGlLts8Tbok8PzHl4vHtVFuZCA= k8s.io/apimachinery v0.17.4/go.mod h1:gxLnyZcGNdZTCLnq3fgzyg2A5BVCHTNDFrw8AmuJ+0g=