From e5e2bfa83f82c26d249bade7da24bdf394a92d07 Mon Sep 17 00:00:00 2001 From: Lars Lehtonen Date: Thu, 31 Oct 2019 12:09:32 -0700 Subject: [PATCH] builder/amazon/common: remove nil check on slice, len() on nil slices is zero --- builder/amazon/common/ami_config_test.go | 1 - builder/amazon/common/errors.go | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/builder/amazon/common/ami_config_test.go b/builder/amazon/common/ami_config_test.go index 8430c964c..2448965db 100644 --- a/builder/amazon/common/ami_config_test.go +++ b/builder/amazon/common/ami_config_test.go @@ -69,7 +69,6 @@ func TestAMIConfigPrepare_regions(t *testing.T) { if errs = c.prepareRegions(accessConf); len(errs) > 0 { t.Fatalf("shouldn't have err: %#v", errs) } - errs = errs[:0] c.AMIRegions = []string{"us-east-1", "us-west-1", "us-east-1"} if errs = c.prepareRegions(accessConf); len(errs) > 0 { diff --git a/builder/amazon/common/errors.go b/builder/amazon/common/errors.go index f12f58e7d..bca247bfa 100644 --- a/builder/amazon/common/errors.go +++ b/builder/amazon/common/errors.go @@ -24,7 +24,7 @@ type stsDecoder interface { func decodeAWSError(decoder stsDecoder, err error) error { groups := encodedFailureMessagePattern.FindStringSubmatch(err.Error()) - if groups != nil && len(groups) > 1 { + if len(groups) > 1 { result, decodeErr := decoder.DecodeAuthorizationMessage(&sts.DecodeAuthorizationMessageInput{ EncodedMessage: aws.String(groups[2]), })