Skip to content

Commit

Permalink
chore: Fix Go Static Check Errors (runatlantis#3637)
Browse files Browse the repository at this point in the history
* Fix Go Static Checks

* Fix working dir tests
  • Loading branch information
X-Guardian authored and ijames-gc committed Feb 13, 2024
1 parent c40fb2a commit f7c56a1
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 13 deletions.
3 changes: 1 addition & 2 deletions server/events/github_app_working_dir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -59,7 +58,7 @@ func TestClone_GithubAppNoneExisting(t *testing.T) {
}

func TestClone_GithubAppSetsCorrectUrl(t *testing.T) {
pegomock.RegisterMockTestingT(t)
RegisterMockTestingT(t)

workingDir := eventMocks.NewMockWorkingDir()

Expand Down
1 change: 0 additions & 1 deletion server/events/plan_command_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion server/events/project_command_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion server/events/project_command_context_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions server/events/project_finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions server/events/working_dir_locker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions server/events/working_dir_locker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit f7c56a1

Please sign in to comment.