From f7c56a1b9a5786d08b3a862b41281e0b394cad8c Mon Sep 17 00:00:00 2001 From: Simon Heather <32168619+X-Guardian@users.noreply.github.com> Date: Sat, 5 Aug 2023 21:41:54 +0100 Subject: [PATCH] chore: Fix Go Static Check Errors (#3637) * Fix Go Static Checks * Fix working dir tests --- server/events/github_app_working_dir_test.go | 3 +-- server/events/plan_command_runner_test.go | 1 - server/events/project_command_builder.go | 2 +- server/events/project_command_context_builder.go | 2 +- server/events/project_finder.go | 4 ++-- server/events/working_dir_locker.go | 8 ++++---- server/events/working_dir_locker_test.go | 4 ++-- 7 files changed, 11 insertions(+), 13 deletions(-) diff --git a/server/events/github_app_working_dir_test.go b/server/events/github_app_working_dir_test.go index fff758652f..8a8bc6f3dc 100644 --- a/server/events/github_app_working_dir_test.go +++ b/server/events/github_app_working_dir_test.go @@ -5,7 +5,6 @@ import ( "testing" . "github.com/petergtz/pegomock/v4" - pegomock "github.com/petergtz/pegomock/v4" "github.com/runatlantis/atlantis/server/events" eventMocks "github.com/runatlantis/atlantis/server/events/mocks" "github.com/runatlantis/atlantis/server/events/models" @@ -59,7 +58,7 @@ func TestClone_GithubAppNoneExisting(t *testing.T) { } func TestClone_GithubAppSetsCorrectUrl(t *testing.T) { - pegomock.RegisterMockTestingT(t) + RegisterMockTestingT(t) workingDir := eventMocks.NewMockWorkingDir() diff --git a/server/events/plan_command_runner_test.go b/server/events/plan_command_runner_test.go index e388ef2499..80ed066d7f 100644 --- a/server/events/plan_command_runner_test.go +++ b/server/events/plan_command_runner_test.go @@ -496,7 +496,6 @@ func TestPlanCommandRunner_ExecutionOrder(t *testing.T) { } planCommandRunner.Run(ctx, cmd) - type RepoModel interface{ models.Repo } for i := range c.ProjectContexts { projectCommandRunner.VerifyWasCalled(c.RunnerInvokeMatch[i]).Plan(c.ProjectContexts[i]) diff --git a/server/events/project_command_builder.go b/server/events/project_command_builder.go index fc8700bb7b..aa898630f7 100644 --- a/server/events/project_command_builder.go +++ b/server/events/project_command_builder.go @@ -769,7 +769,7 @@ func (p *DefaultProjectCommandBuilder) buildProjectCommandCtx(ctx *command.Conte if repoCfgPtr.ParallelPlan != nil { parallelPlan = *repoCfgPtr.ParallelPlan } - abortOnExcecutionOrderFail = *&repoCfgPtr.AbortOnExcecutionOrderFail + abortOnExcecutionOrderFail = repoCfgPtr.AbortOnExcecutionOrderFail } if len(matchingProjects) > 0 { diff --git a/server/events/project_command_context_builder.go b/server/events/project_command_context_builder.go index c4e2b03cc6..2170bfb8e2 100644 --- a/server/events/project_command_context_builder.go +++ b/server/events/project_command_context_builder.go @@ -194,7 +194,7 @@ func (cb *PolicyCheckProjectCommandContextBuilder) BuildProjectContext( terraformClient, ) - if cmdName == command.Plan && prjCfg.PolicyCheck != false { + if cmdName == command.Plan && prjCfg.PolicyCheck { ctx.Log.Debug("Building project command context for %s", command.PolicyCheck) steps := prjCfg.Workflow.PolicyCheck.Steps diff --git a/server/events/project_finder.go b/server/events/project_finder.go index 8d5ecafe52..661495faf6 100644 --- a/server/events/project_finder.go +++ b/server/events/project_finder.go @@ -224,7 +224,7 @@ func (p *DefaultProjectFinder) DetermineProjectsViaConfig(log logging.SimpleLogg // If any of the modified files matches the pattern then this project is // considered modified. for _, file := range modifiedFiles { - match, err := pm.Matches(file) + match, err := pm.MatchesOrParentMatches(file) if err != nil { log.Debug("match err for file %q: %s", file, err) continue @@ -266,7 +266,7 @@ func (p *DefaultProjectFinder) filterToFileList(log logging.SimpleLogging, files if p.shouldIgnore(fileName) { continue } - match, err := patternMatcher.Matches(fileName) + match, err := patternMatcher.MatchesOrParentMatches(fileName) if err != nil { log.Debug("filter err for file %q: %s", fileName, err) continue diff --git a/server/events/working_dir_locker.go b/server/events/working_dir_locker.go index 464014cdb1..06af44ec5a 100644 --- a/server/events/working_dir_locker.go +++ b/server/events/working_dir_locker.go @@ -63,9 +63,9 @@ func (d *DefaultWorkingDirLocker) TryLockPull(repoFullName string, pullNum int) pullKey := d.pullKey(repoFullName, pullNum) for _, l := range d.locks { if l == pullKey || strings.HasPrefix(l, pullKey+"/") { - return func() {}, fmt.Errorf("The Atlantis working dir is currently locked by another" + + return func() {}, fmt.Errorf("the Atlantis working dir is currently locked by another" + " command that is running for this pull request.\n" + - "Wait until the previous command is complete and try again.") + "Wait until the previous command is complete and try again") } } d.locks = append(d.locks, pullKey) @@ -82,9 +82,9 @@ func (d *DefaultWorkingDirLocker) TryLock(repoFullName string, pullNum int, work workspaceKey := d.workspaceKey(repoFullName, pullNum, workspace, path) for _, l := range d.locks { if l == pullKey || l == workspaceKey { - return func() {}, fmt.Errorf("The %s workspace at path %s is currently locked by another"+ + return func() {}, fmt.Errorf("the %s workspace at path %s is currently locked by another"+ " command that is running for this pull request.\n"+ - "Wait until the previous command is complete and try again.", workspace, path) + "Wait until the previous command is complete and try again", workspace, path) } } d.locks = append(d.locks, workspaceKey) diff --git a/server/events/working_dir_locker_test.go b/server/events/working_dir_locker_test.go index a61d724f13..11c21ea151 100644 --- a/server/events/working_dir_locker_test.go +++ b/server/events/working_dir_locker_test.go @@ -33,9 +33,9 @@ func TestTryLock(t *testing.T) { // Now another lock for the same repo, workspace, and pull should fail _, err = locker.TryLock(repo, 1, workspace, path) - ErrEquals(t, "The default workspace at path . is currently locked by another"+ + ErrEquals(t, "the default workspace at path . is currently locked by another"+ " command that is running for this pull request.\n"+ - "Wait until the previous command is complete and try again.", err) + "Wait until the previous command is complete and try again", err) // Unlock should work. unlockFn()