From 683a44ac0d6ced36387236ef85dc5e9b5918bb42 Mon Sep 17 00:00:00 2001 From: laurentsimon Date: Wed, 4 May 2022 20:17:08 +0000 Subject: [PATCH] updates --- checks/remediations.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/checks/remediations.go b/checks/remediations.go index ca18b5e0164..32b78b91d67 100644 --- a/checks/remediations.go +++ b/checks/remediations.go @@ -25,9 +25,10 @@ import ( ) var ( - remediationBranch string - remediationRepo string - remediationOnce *sync.Once + remediationBranch string + remediationRepo string + remediationOnce *sync.Once + remediationSetupErr error ) //nolint:gochecknoinits @@ -36,12 +37,11 @@ func init() { } func remdiationSetup(c *checker.CheckRequest) error { - var setupErr error remediationOnce.Do(func() { // Get the branch for remediation. b, err := c.RepoClient.GetDefaultBranch() if err != nil && !errors.Is(err, clients.ErrUnsupportedFeature) { - setupErr = err + remediationSetupErr = err return } if b.Name != nil { @@ -49,13 +49,14 @@ func remdiationSetup(c *checker.CheckRequest) error { uri := c.Repo.URI() parts := strings.Split(uri, "/") if len(parts) != 3 { - setupErr = fmt.Errorf("%w: %s", errInvalidArgLength, uri) + remediationSetupErr = fmt.Errorf("%w: %s", errInvalidArgLength, uri) return } remediationRepo = fmt.Sprintf("%s/%s", parts[1], parts[2]) } }) - return setupErr + + return remediationSetupErr } func createWorkflowPermissionRemediation(filepath string) *checker.Remediation {