From 6fd8a7ed3a4dae7d00ed91f10c0d2879674a628e Mon Sep 17 00:00:00 2001 From: Hans Wernetti Date: Wed, 24 Sep 2025 13:24:06 -0700 Subject: [PATCH 01/11] Go 1.25 --- .github/workflows/lint.yml | 2 +- .github/workflows/test.yml | 2 +- go.mod | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 186a3d12a..9a5722dac 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/setup-go@v3 with: - go-version: 1.24 + go-version: 1.25 - uses: actions/checkout@v3 - name: Run golangci-lint uses: golangci/golangci-lint-action@v3.2.0 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1549c694b..577f992ca 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,6 +24,6 @@ jobs: && sudo cp conftest /usr/local/bin/conftest - uses: actions/setup-go@v3 with: - go-version: 1.24 + go-version: 1.25 - uses: actions/checkout@v3 - run: make test-all diff --git a/go.mod b/go.mod index b27439258..f0de80586 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/runatlantis/atlantis -go 1.24 +go 1.25 replace google.golang.org/grpc => google.golang.org/grpc v1.45.0 From 72c6a258c2d2d8e68573cfc56acf0c5e723729c0 Mon Sep 17 00:00:00 2001 From: Hans Wernetti Date: Wed, 24 Sep 2025 13:28:16 -0700 Subject: [PATCH 02/11] update golangci-lint to v2 --- .github/workflows/lint.yml | 2 +- .golangci.bck.yml | 38 +++++++++++++++++++++ .golangci.yml | 67 +++++++++++++++++++++----------------- 3 files changed, 76 insertions(+), 31 deletions(-) create mode 100644 .golangci.bck.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9a5722dac..ae274d826 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,4 +17,4 @@ jobs: uses: golangci/golangci-lint-action@v3.2.0 with: args: --timeout 3m --verbose --disable revive - version: v1.64.5 + version: v2.4.0 diff --git a/.golangci.bck.yml b/.golangci.bck.yml new file mode 100644 index 000000000..5986dec2e --- /dev/null +++ b/.golangci.bck.yml @@ -0,0 +1,38 @@ +linters: + enable: + - errcheck + - gochecknoinits + # We don't use goconst because it gives false positives in the tests. + # - goconst + - gofmt + # We don't use revive because it gives false positives in the tests. + # - revive + - gosec + - gosimple + - ineffassign + - staticcheck + - typecheck + - unconvert + - unused + - vet + - vetshadow + - dogsled + - dupword + - unparam + - interfacebloat + - usestdlibvars + - whitespace +issues: + exclude-rules: + - path: server/legacy/controllers/events/events_controller(.+)test.go + linters: + - dogsled + - path: server/legacy/events/event_parser_test.go + linters: + - dogsled + - path: server/legacy/events/command_runner_test.go + linters: + - dogsled +linters-settings: + interfacebloat: + max: 7 diff --git a/.golangci.yml b/.golangci.yml index 5986dec2e..f35694eb9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,38 +1,45 @@ +version: "2" linters: enable: - - errcheck + - dogsled + - dupword - gochecknoinits - # We don't use goconst because it gives false positives in the tests. - # - goconst - - gofmt - # We don't use revive because it gives false positives in the tests. - # - revive - gosec - - gosimple - - ineffassign - - staticcheck - - typecheck + - interfacebloat - unconvert - - unused - - vet - - vetshadow - - dogsled - - dupword - unparam - - interfacebloat - usestdlibvars - whitespace -issues: - exclude-rules: - - path: server/legacy/controllers/events/events_controller(.+)test.go - linters: - - dogsled - - path: server/legacy/events/event_parser_test.go - linters: - - dogsled - - path: server/legacy/events/command_runner_test.go - linters: - - dogsled -linters-settings: - interfacebloat: - max: 7 + settings: + interfacebloat: + max: 7 + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + rules: + - linters: + - dogsled + path: server/legacy/controllers/events/events_controller(.+)test.go + - linters: + - dogsled + path: server/legacy/events/event_parser_test.go + - linters: + - dogsled + path: server/legacy/events/command_runner_test.go + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gofmt + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ From 473a5f2254858a5c0b472c046c12240c9c4b0011 Mon Sep 17 00:00:00 2001 From: Hans Wernetti Date: Wed, 24 Sep 2025 13:29:04 -0700 Subject: [PATCH 03/11] rm backup config --- .golangci.bck.yml | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 .golangci.bck.yml diff --git a/.golangci.bck.yml b/.golangci.bck.yml deleted file mode 100644 index 5986dec2e..000000000 --- a/.golangci.bck.yml +++ /dev/null @@ -1,38 +0,0 @@ -linters: - enable: - - errcheck - - gochecknoinits - # We don't use goconst because it gives false positives in the tests. - # - goconst - - gofmt - # We don't use revive because it gives false positives in the tests. - # - revive - - gosec - - gosimple - - ineffassign - - staticcheck - - typecheck - - unconvert - - unused - - vet - - vetshadow - - dogsled - - dupword - - unparam - - interfacebloat - - usestdlibvars - - whitespace -issues: - exclude-rules: - - path: server/legacy/controllers/events/events_controller(.+)test.go - linters: - - dogsled - - path: server/legacy/events/event_parser_test.go - linters: - - dogsled - - path: server/legacy/events/command_runner_test.go - linters: - - dogsled -linters-settings: - interfacebloat: - max: 7 From 40790db7ad4697d7de3a24f6d493d5792ddcff3f Mon Sep 17 00:00:00 2001 From: Hans Wernetti Date: Wed, 24 Sep 2025 13:33:31 -0700 Subject: [PATCH 04/11] automatic lint fixes --- server/config/parser_validator_test.go | 4 ++-- server/config/raw/project.go | 2 +- .../events/events_controller_e2e_test.go | 4 ++-- .../core/runtime/policy/conftest_executor.go | 2 +- .../runtime/pre_workflow_hook_runner_test.go | 2 +- .../core/runtime/run_step_runner_test.go | 2 +- server/legacy/core/runtime/runtime.go | 4 ++-- .../legacy/events/command/project_context.go | 2 +- .../legacy/events/pending_plan_finder_test.go | 2 +- .../pre_workflow_hooks_command_runner_test.go | 6 ++--- .../events/project_command_builder_test.go | 2 +- .../events/vcs/github_client_lyft_test.go | 10 ++++----- .../legacy/events/vcs/github_client_test.go | 17 ++++++-------- server/legacy/events/working_dir.go | 4 ++-- server/legacy/server.go | 2 +- server/models/models.go | 10 ++++----- .../gateway/config/root_config_builder.go | 8 +++---- server/neptune/http/server_proxy.go | 2 +- server/neptune/lyft/activities/github.go | 2 +- server/neptune/temporal/client.go | 12 +++++----- server/neptune/temporalworker/job/store.go | 2 +- .../neptune/workflows/activities/conftest.go | 2 +- .../deploy/revision/queue/deployer_test.go | 5 +++-- .../internal/deploy/revision/queue/updater.go | 2 +- .../internal/deploy/revision/revision.go | 2 +- .../internal/deploy/terraform/state.go | 5 +++-- .../internal/pr/revision/policy/handler.go | 6 ++--- .../internal/terraform/job/runner.go | 2 +- server/recovery/recovery.go | 2 +- server/vcs/markdown/markdown_renderer_test.go | 22 +++++++++---------- server/vcs/markdown/template_resolver.go | 8 +++---- 31 files changed, 76 insertions(+), 81 deletions(-) diff --git a/server/config/parser_validator_test.go b/server/config/parser_validator_test.go index bc17034a6..3e057acb4 100644 --- a/server/config/parser_validator_test.go +++ b/server/config/parser_validator_test.go @@ -1090,7 +1090,7 @@ repos: act, err := r.ParseGlobalCfg(path, valid.NewGlobalCfg("somedir")) if c.expErr != "" { - expErr := strings.Replace(c.expErr, "", path, -1) + expErr := strings.ReplaceAll(c.expErr, "", path) ErrEquals(t, expErr, err) return } @@ -1405,7 +1405,7 @@ deployment_workflows: act, err := r.ParseGlobalCfg(path, valid.NewGlobalCfg("somedir")) if c.expErr != "" { - expErr := strings.Replace(c.expErr, "", path, -1) + expErr := strings.ReplaceAll(c.expErr, "", path) ErrEquals(t, expErr, err) return } diff --git a/server/config/raw/project.go b/server/config/raw/project.go index 1723de2a7..20ab2feac 100644 --- a/server/config/raw/project.go +++ b/server/config/raw/project.go @@ -118,7 +118,7 @@ func (p Project) ToValid(defaultWorkflowModeType valid.WorkflowModeType) valid.P // support any characters that must be url escaped *except* for '/' because // users like to name their projects to match the directory it's in. func validProjectName(name string) bool { - nameWithoutSlashes := strings.Replace(name, "/", "-", -1) + nameWithoutSlashes := strings.ReplaceAll(name, "/", "-") return nameWithoutSlashes == url.QueryEscape(nameWithoutSlashes) } diff --git a/server/legacy/controllers/events/events_controller_e2e_test.go b/server/legacy/controllers/events/events_controller_e2e_test.go index c2c3db631..5ec3e2b33 100644 --- a/server/legacy/controllers/events/events_controller_e2e_test.go +++ b/server/legacy/controllers/events/events_controller_e2e_test.go @@ -785,7 +785,7 @@ func GitHubPullRequestOpenedEvent(t *testing.T, headSHA string) *http.Request { }, ) // Replace sha with expected sha. - requestJSONStr := strings.Replace(pullRequestOpenedJSON, "c31fd9ea6f557ad2ea659944c3844a059b83bc5d", headSHA, -1) + requestJSONStr := strings.ReplaceAll(pullRequestOpenedJSON, "c31fd9ea6f557ad2ea659944c3844a059b83bc5d", headSHA) req, err := http.NewRequest(http.MethodPost, "/events", bytes.NewBuffer([]byte(requestJSONStr))) Ok(t, err) req.Header.Set("Content-Type", "application/json") @@ -820,7 +820,7 @@ func GitHubPullRequestReviewedEvent(t *testing.T, headSHA string) *http.Request }, ) // Replace sha with expected sha. - requestJSONStr := strings.Replace(pullRequestReviewedJSON, "c31fd9ea6f557ad2ea659944c3844a059b83bc5d", headSHA, -1) + requestJSONStr := strings.ReplaceAll(pullRequestReviewedJSON, "c31fd9ea6f557ad2ea659944c3844a059b83bc5d", headSHA) req, err := http.NewRequest(http.MethodPost, "/events", bytes.NewBuffer([]byte(requestJSONStr))) Ok(t, err) req.Header.Set("Content-Type", "application/json") diff --git a/server/legacy/core/runtime/policy/conftest_executor.go b/server/legacy/core/runtime/policy/conftest_executor.go index 70479ebb3..0ee46126e 100644 --- a/server/legacy/core/runtime/policy/conftest_executor.go +++ b/server/legacy/core/runtime/policy/conftest_executor.go @@ -123,7 +123,7 @@ func (c *ConfTestExecutor) buildTitle(policySetNames []string) string { } func (c *ConfTestExecutor) sanitizeOutput(inputFile string, output string) string { - return strings.Replace(output, inputFile, "", -1) + return strings.ReplaceAll(output, inputFile, "") } func (c *ConfTestExecutor) processOutput(output string, policySet valid.PolicySet, err error) string { diff --git a/server/legacy/core/runtime/pre_workflow_hook_runner_test.go b/server/legacy/core/runtime/pre_workflow_hook_runner_test.go index e95839951..da055d96c 100644 --- a/server/legacy/core/runtime/pre_workflow_hook_runner_test.go +++ b/server/legacy/core/runtime/pre_workflow_hook_runner_test.go @@ -72,7 +72,7 @@ func TestPreWorkflowHookRunner_Run(t *testing.T) { // Replace $DIR in the exp with the actual temp dir. We do this // here because when constructing the cases we don't yet know the // temp dir. - expOut := strings.Replace(c.ExpOut, "$DIR", tmpDir, -1) + expOut := strings.ReplaceAll(c.ExpOut, "$DIR", tmpDir) Equals(t, expOut, out) }) } diff --git a/server/legacy/core/runtime/run_step_runner_test.go b/server/legacy/core/runtime/run_step_runner_test.go index 5254e24fc..a43d220b3 100644 --- a/server/legacy/core/runtime/run_step_runner_test.go +++ b/server/legacy/core/runtime/run_step_runner_test.go @@ -146,7 +146,7 @@ func TestRunStepRunner_Run(t *testing.T) { // Replace $DIR in the exp with the actual temp dir. We do this // here because when constructing the cases we don't yet know the // temp dir. - expOut := strings.Replace(c.ExpOut, "$DIR", tmpDir, -1) + expOut := strings.ReplaceAll(c.ExpOut, "$DIR", tmpDir) Equals(t, expOut, out) terraform.VerifyWasCalledOnce().EnsureVersion(logger, projVersion) diff --git a/server/legacy/core/runtime/runtime.go b/server/legacy/core/runtime/runtime.go index 7a6b256fa..20ffa76ea 100644 --- a/server/legacy/core/runtime/runtime.go +++ b/server/legacy/core/runtime/runtime.go @@ -89,7 +89,7 @@ func GetPlanFilename(workspace string, projName string) string { if projName == "" { return fmt.Sprintf("%s.tfplan", workspace) } - projName = strings.Replace(projName, "/", planfileSlashReplace, -1) + projName = strings.ReplaceAll(projName, "/", planfileSlashReplace) return fmt.Sprintf("%s-%s.tfplan", projName, workspace) } @@ -115,5 +115,5 @@ func ProjectNameFromPlanfile(workspace string, filename string) (string, error) return "", nil } rawProjName := projMatch[0][1] - return strings.Replace(rawProjName, planfileSlashReplace, "/", -1), nil + return strings.ReplaceAll(rawProjName, planfileSlashReplace, "/"), nil } diff --git a/server/legacy/events/command/project_context.go b/server/legacy/events/command/project_context.go index 1eb88ab84..bd8c9a013 100644 --- a/server/legacy/events/command/project_context.go +++ b/server/legacy/events/command/project_context.go @@ -185,7 +185,7 @@ func (p ProjectContext) GetShowResultFileName() string { if p.ProjectName == "" { return fmt.Sprintf("%s.json", p.Workspace) } - projName := strings.Replace(p.ProjectName, "/", planfileSlashReplace, -1) + projName := strings.ReplaceAll(p.ProjectName, "/", planfileSlashReplace) return fmt.Sprintf("%s-%s.json", projName, p.Workspace) } diff --git a/server/legacy/events/pending_plan_finder_test.go b/server/legacy/events/pending_plan_finder_test.go index bafadfad0..5eafd14cb 100644 --- a/server/legacy/events/pending_plan_finder_test.go +++ b/server/legacy/events/pending_plan_finder_test.go @@ -202,7 +202,7 @@ func TestPendingPlanFinder_Find(t *testing.T) { // Replace the actual dir with ??? to allow for comparison. var actPlansComparable []events.PendingPlan for _, p := range actPlans { - p.RepoDir = strings.Replace(p.RepoDir, tmpDir, "???", -1) + p.RepoDir = strings.ReplaceAll(p.RepoDir, tmpDir, "???") actPlansComparable = append(actPlansComparable, p) } Equals(t, c.expPlans, actPlansComparable) diff --git a/server/legacy/events/pre_workflow_hooks_command_runner_test.go b/server/legacy/events/pre_workflow_hooks_command_runner_test.go index 9d5a20993..5bd8e1f23 100644 --- a/server/legacy/events/pre_workflow_hooks_command_runner_test.go +++ b/server/legacy/events/pre_workflow_hooks_command_runner_test.go @@ -71,7 +71,7 @@ func TestRunPreHooks_Clone(t *testing.T) { t.Run("success hooks in cfg", func(t *testing.T) { preWorkflowHooksSetup(t) - var unlockCalled *bool = Bool(false) + var unlockCalled = Bool(false) unlockFn := func() { unlockCalled = Bool(true) } @@ -156,7 +156,7 @@ func TestRunPreHooks_Clone(t *testing.T) { t.Run("error cloning", func(t *testing.T) { preWorkflowHooksSetup(t) - var unlockCalled *bool = Bool(false) + var unlockCalled = Bool(false) unlockFn := func() { unlockCalled = Bool(true) } @@ -188,7 +188,7 @@ func TestRunPreHooks_Clone(t *testing.T) { t.Run("error running pre hook", func(t *testing.T) { preWorkflowHooksSetup(t) - var unlockCalled *bool = Bool(false) + var unlockCalled = Bool(false) unlockFn := func() { unlockCalled = Bool(true) } diff --git a/server/legacy/events/project_command_builder_test.go b/server/legacy/events/project_command_builder_test.go index 412555569..14feca4bc 100644 --- a/server/legacy/events/project_command_builder_test.go +++ b/server/legacy/events/project_command_builder_test.go @@ -925,7 +925,7 @@ projects: "main.tf": fmt.Sprintf(baseVersionConfig, exactSymbols[0]), }, "project2": map[string]interface{}{ - "main.tf": strings.Replace(fmt.Sprintf(baseVersionConfig, exactSymbols[0]), "0.12.8", "0.12.9", -1), + "main.tf": strings.ReplaceAll(fmt.Sprintf(baseVersionConfig, exactSymbols[0]), "0.12.8", "0.12.9"), }, }, ModifiedFiles: []string{"project1/main.tf", "project2/main.tf"}, diff --git a/server/legacy/events/vcs/github_client_lyft_test.go b/server/legacy/events/vcs/github_client_lyft_test.go index 8fafe82d0..e12042587 100644 --- a/server/legacy/events/vcs/github_client_lyft_test.go +++ b/server/legacy/events/vcs/github_client_lyft_test.go @@ -166,14 +166,12 @@ func TestLyftGithubClient_PullisMergeable_BlockedStatus(t *testing.T) { w.Write([]byte(pullResponse)) // nolint: errcheck return case "/api/v3/repos/owner/repo/commits/2/status?per_page=100": - _, _ = w.Write([]byte( - fmt.Sprintf(combinedStatusJSON, strings.Join(c.statuses, ",")), - )) // nolint: errcheck + _, _ = fmt.Fprintf(w, + combinedStatusJSON, strings.Join(c.statuses, ",")) // nolint: errcheck return case "/api/v3/repos/owner/repo/commits/2/check-runs?per_page=100": - _, _ = w.Write([]byte( - fmt.Sprintf(combinedChecksJSON, strings.Join(c.checks, ",")), - )) + _, _ = fmt.Fprintf(w, + combinedChecksJSON, strings.Join(c.checks, ",")) return default: t.Errorf("got unexpected request at %q", r.RequestURI) diff --git a/server/legacy/events/vcs/github_client_test.go b/server/legacy/events/vcs/github_client_test.go index ecd67c1ad..9bdedfb27 100644 --- a/server/legacy/events/vcs/github_client_test.go +++ b/server/legacy/events/vcs/github_client_test.go @@ -515,12 +515,11 @@ func TestGithubClient_PullIsMergeable(t *testing.T) { w.Write([]byte(response)) // nolint: errcheck return case "/api/v3/repos/owner/repo/commits/2/status?per_page=100": - _, _ = w.Write([]byte( - fmt.Sprintf(combinedStatusJSON, fmt.Sprintf(statusJSON, "success", "some_status")), - )) // nolint: errcheck + _, _ = fmt.Fprintf(w, + combinedStatusJSON, fmt.Sprintf(statusJSON, "success", "some_status")) // nolint: errcheck return case "/api/v3/repos/owner/repo/commits/2/check-runs?per_page=100": - _, _ = w.Write([]byte(fmt.Sprintf(checksJSON, "completed", "success"))) + _, _ = fmt.Fprintf(w, checksJSON, "completed", "success") return default: t.Errorf("got unexpected request at %q", r.RequestURI) @@ -662,14 +661,12 @@ func TestGithubClient_PullisMergeable_BlockedStatus(t *testing.T) { http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.RequestURI { case "/api/v3/repos/owner/repo/commits/2/status?per_page=100": - _, _ = w.Write([]byte( - fmt.Sprintf(combinedStatusJSON, strings.Join(c.statuses, ",")), - )) // nolint: errcheck + _, _ = fmt.Fprintf(w, + combinedStatusJSON, strings.Join(c.statuses, ",")) // nolint: errcheck return case "/api/v3/repos/owner/repo/commits/2/check-runs?per_page=100": - _, _ = w.Write([]byte( - fmt.Sprintf(combinedChecksJSON, len(c.checks), strings.Join(c.checks, ",")), - )) + _, _ = fmt.Fprintf(w, + combinedChecksJSON, len(c.checks), strings.Join(c.checks, ",")) return case "/api/v3/repos/owner/repo/pulls/1": w.Write([]byte(pullResponse)) // nolint: errcheck diff --git a/server/legacy/events/working_dir.go b/server/legacy/events/working_dir.go index 1e57b881e..7c5af3f5a 100644 --- a/server/legacy/events/working_dir.go +++ b/server/legacy/events/working_dir.go @@ -331,6 +331,6 @@ func (w *FileWorkspace) cloneDir(r models.Repo, p models.PullRequest, workspace // sanitizeGitCredentials replaces any git clone urls that contain credentials // in s with the sanitized versions. func (w *FileWorkspace) sanitizeGitCredentials(s string, base models.Repo, head models.Repo) string { - baseReplaced := strings.Replace(s, base.CloneURL, base.SanitizedCloneURL, -1) - return strings.Replace(baseReplaced, head.CloneURL, head.SanitizedCloneURL, -1) + baseReplaced := strings.ReplaceAll(s, base.CloneURL, base.SanitizedCloneURL) + return strings.ReplaceAll(baseReplaced, head.CloneURL, head.SanitizedCloneURL) } diff --git a/server/legacy/server.go b/server/legacy/server.go index 942479243..6c6d044a8 100644 --- a/server/legacy/server.go +++ b/server/legacy/server.go @@ -1012,7 +1012,7 @@ func ParseAtlantisURL(u string) (*url.URL, error) { if err != nil { return nil, err } - if !(parsed.Scheme == "http" || parsed.Scheme == "https") { + if parsed.Scheme != "http" && parsed.Scheme != "https" { return nil, errors.New("http or https must be specified") } // We want the path to end without a trailing slash so we know how to diff --git a/server/models/models.go b/server/models/models.go index ff81ecfa6..55c888620 100644 --- a/server/models/models.go +++ b/server/models/models.go @@ -98,7 +98,7 @@ func NewRepo(vcsHostType VCSHostType, repoFullName string, cloneURL string, vcsU // We url encode because we're using them in a URL and weird characters can // mess up git. - cloneURL = strings.Replace(cloneURL, " ", "%20", -1) + cloneURL = strings.ReplaceAll(cloneURL, " ", "%20") escapedVCSUser := url.QueryEscape(vcsUser) escapedVCSToken := url.QueryEscape(vcsToken) auth := fmt.Sprintf("%s:%s@", escapedVCSUser, escapedVCSToken) @@ -106,10 +106,10 @@ func NewRepo(vcsHostType VCSHostType, repoFullName string, cloneURL string, vcsU // Construct clone urls with http and https auth. Need to do both // because Bitbucket supports http. - authedCloneURL := strings.Replace(cloneURL, "https://", "https://"+auth, -1) - authedCloneURL = strings.Replace(authedCloneURL, "http://", "http://"+auth, -1) - sanitizedCloneURL := strings.Replace(cloneURL, "https://", "https://"+redactedAuth, -1) - sanitizedCloneURL = strings.Replace(sanitizedCloneURL, "http://", "http://"+redactedAuth, -1) + authedCloneURL := strings.ReplaceAll(cloneURL, "https://", "https://"+auth) + authedCloneURL = strings.ReplaceAll(authedCloneURL, "http://", "http://"+auth) + sanitizedCloneURL := strings.ReplaceAll(cloneURL, "https://", "https://"+redactedAuth) + sanitizedCloneURL = strings.ReplaceAll(sanitizedCloneURL, "http://", "http://"+redactedAuth) // Get the owner and repo names from the full name. owner, repo := SplitRepoFullName(repoFullName) diff --git a/server/neptune/gateway/config/root_config_builder.go b/server/neptune/gateway/config/root_config_builder.go index b63c1af91..ac4805248 100644 --- a/server/neptune/gateway/config/root_config_builder.go +++ b/server/neptune/gateway/config/root_config_builder.go @@ -49,12 +49,12 @@ type ModifiedRootsStrategy struct { func (s *ModifiedRootsStrategy) FindMatches(ctx context.Context, config valid.RepoCfg, repo *LocalRepo, installationToken int64) ([]valid.Project, error) { // Fetch files modified in commit - modifiedFiles, err := s.FileFetcher.GetModifiedFiles(ctx, repo.RepoCommit.Repo, installationToken, github.FileFetcherOptions{ - PRNum: repo.RepoCommit.OptionalPRNum, - Sha: repo.RepoCommit.Sha, + modifiedFiles, err := s.FileFetcher.GetModifiedFiles(ctx, repo.Repo, installationToken, github.FileFetcherOptions{ + PRNum: repo.OptionalPRNum, + Sha: repo.Sha, }) if err != nil { - debugStr := fmt.Sprintf("sha: %s, prNum: %d, dir %s", repo.RepoCommit.Sha, repo.RepoCommit.OptionalPRNum, repo.Dir) + debugStr := fmt.Sprintf("sha: %s, prNum: %d, dir %s", repo.Sha, repo.OptionalPRNum, repo.Dir) return nil, errors.Wrapf(err, "finding modified files: %s, debug str: %s", modifiedFiles, debugStr) } diff --git a/server/neptune/http/server_proxy.go b/server/neptune/http/server_proxy.go index 44d688a6d..fae9f7fbc 100644 --- a/server/neptune/http/server_proxy.go +++ b/server/neptune/http/server_proxy.go @@ -15,7 +15,7 @@ type ServerProxy struct { func (p *ServerProxy) ListenAndServe() error { if p.SSLCertFile != "" && p.SSLKeyFile != "" { - return p.Server.ListenAndServeTLS(p.SSLCertFile, p.SSLKeyFile) + return p.ListenAndServeTLS(p.SSLCertFile, p.SSLKeyFile) } return p.Server.ListenAndServe() diff --git a/server/neptune/lyft/activities/github.go b/server/neptune/lyft/activities/github.go index c9ee83ae7..89daecef4 100644 --- a/server/neptune/lyft/activities/github.go +++ b/server/neptune/lyft/activities/github.go @@ -139,7 +139,7 @@ func (a *Github) listPullRequests(ctx context.Context, installationToken int64, Sort: sortBy, Direction: order, } - prListOptions.ListOptions.Page = nextPage + prListOptions.Page = nextPage return client.PullRequests.List(ctx, owner, repo, &prListOptions) } diff --git a/server/neptune/temporal/client.go b/server/neptune/temporal/client.go index 8fd8f4bca..e6b2f9389 100644 --- a/server/neptune/temporal/client.go +++ b/server/neptune/temporal/client.go @@ -137,7 +137,7 @@ func (i *clientMetricsOutboundInterceptor) ExecuteWorkflow(ctx context.Context, timer := s.Timer("latency").Start() defer timer.Stop() - run, err := i.ClientOutboundInterceptorBase.Next.ExecuteWorkflow(ctx, in) + run, err := i.Next.ExecuteWorkflow(ctx, in) if err != nil { s.Counter("error").Inc(1) @@ -155,7 +155,7 @@ func (i *clientMetricsOutboundInterceptor) SignalWorkflow(ctx context.Context, i timer := s.Timer("latency").Start() defer timer.Stop() - if err := i.ClientOutboundInterceptorBase.Next.SignalWorkflow(ctx, in); err != nil { + if err := i.Next.SignalWorkflow(ctx, in); err != nil { s.Counter("error").Inc(1) return err } @@ -171,7 +171,7 @@ func (i *clientMetricsOutboundInterceptor) SignalWithStartWorkflow(ctx context.C timer := s.Timer("latency").Start() defer timer.Stop() - run, err := i.ClientOutboundInterceptorBase.Next.SignalWithStartWorkflow(ctx, in) + run, err := i.Next.SignalWithStartWorkflow(ctx, in) if err != nil { s.Counter("error").Inc(1) @@ -189,7 +189,7 @@ func (i *clientMetricsOutboundInterceptor) CancelWorkflow(ctx context.Context, i timer := s.Timer("latency").Start() defer timer.Stop() - if err := i.ClientOutboundInterceptorBase.Next.CancelWorkflow(ctx, in); err != nil { + if err := i.Next.CancelWorkflow(ctx, in); err != nil { s.Counter("error").Inc(1) return err } @@ -205,7 +205,7 @@ func (i *clientMetricsOutboundInterceptor) TerminateWorkflow(ctx context.Context timer := s.Timer("latency").Start() defer timer.Stop() - if err := i.ClientOutboundInterceptorBase.Next.TerminateWorkflow(ctx, in); err != nil { + if err := i.Next.TerminateWorkflow(ctx, in); err != nil { s.Counter("error").Inc(1) return err } @@ -221,7 +221,7 @@ func (i *clientMetricsOutboundInterceptor) QueryWorkflow(ctx context.Context, in timer := s.Timer("latency").Start() defer timer.Stop() - val, err := i.ClientOutboundInterceptorBase.Next.QueryWorkflow(ctx, in) + val, err := i.Next.QueryWorkflow(ctx, in) if err != nil { s.Counter("error").Inc(1) diff --git a/server/neptune/temporalworker/job/store.go b/server/neptune/temporalworker/job/store.go index cfeb275b2..991ff93a0 100644 --- a/server/neptune/temporalworker/job/store.go +++ b/server/neptune/temporalworker/job/store.go @@ -208,7 +208,7 @@ func (s *StorageBackendJobStore) Remove(jobID string) { // Persist all jobs in memory func (s *StorageBackendJobStore) Cleanup(ctx context.Context) error { failedJobs := []string{} - for jobID, job := range s.InMemoryStore.GetJobs() { + for jobID, job := range s.GetJobs() { _, err := s.storageBackend.Write(ctx, jobID, job.Output) // Track failed jobs, log errors and continue with other jobs diff --git a/server/neptune/workflows/activities/conftest.go b/server/neptune/workflows/activities/conftest.go index 4402b41d8..eaa3d9270 100644 --- a/server/neptune/workflows/activities/conftest.go +++ b/server/neptune/workflows/activities/conftest.go @@ -137,7 +137,7 @@ func (c *conftestActivity) buildTitle(policySetNames []string) string { } func (c *conftestActivity) sanitizeOutput(inputFile string, output string) string { - return strings.Replace(output, inputFile, "", -1) + return strings.ReplaceAll(output, inputFile, "") } func (c *conftestActivity) processOutput(output string, policySet PolicySet, err error) string { diff --git a/server/neptune/workflows/internal/deploy/revision/queue/deployer_test.go b/server/neptune/workflows/internal/deploy/revision/queue/deployer_test.go index 9989e8dbc..ff036f675 100644 --- a/server/neptune/workflows/internal/deploy/revision/queue/deployer_test.go +++ b/server/neptune/workflows/internal/deploy/revision/queue/deployer_test.go @@ -47,9 +47,10 @@ type testTerraformWorkflowRunner struct { } func (r testTerraformWorkflowRunner) Run(ctx workflow.Context, deploymentInfo terraform.DeploymentInfo, PlanApproval model.PlanApproval, scope metrics.Scope) error { - if r.expectedErrorType == PlanRejectionError { + switch r.expectedErrorType { + case PlanRejectionError: return terraform.NewPlanRejectionError("plan rejected") - } else if r.expectedErrorType == TerraformClientError { + case TerraformClientError: return activities.NewTerraformClientError(errors.New("error")) } return nil diff --git a/server/neptune/workflows/internal/deploy/revision/queue/updater.go b/server/neptune/workflows/internal/deploy/revision/queue/updater.go index dfd42bd30..d2b7d8f3b 100644 --- a/server/neptune/workflows/internal/deploy/revision/queue/updater.go +++ b/server/neptune/workflows/internal/deploy/revision/queue/updater.go @@ -26,7 +26,7 @@ func (u *LockStateUpdater) UpdateQueuedRevisions(ctx workflow.Context, queue *De var actions []github.CheckRunAction var summary string - var revisionsSummary string = queue.GetQueuedRevisionsSummary() + var revisionsSummary = queue.GetQueuedRevisionsSummary() state := github.CheckRunQueued if queueLock.Status == lock.LockedStatus { actions = append(actions, github.CreateUnlockAction()) diff --git a/server/neptune/workflows/internal/deploy/revision/revision.go b/server/neptune/workflows/internal/deploy/revision/revision.go index 9d2b6a924..17af5eb68 100644 --- a/server/neptune/workflows/internal/deploy/revision/revision.go +++ b/server/neptune/workflows/internal/deploy/revision/revision.go @@ -138,7 +138,7 @@ func (n *Receiver) Receive(c workflow.ReceiveChannel, more bool) { func (n *Receiver) createCheckRun(ctx workflow.Context, id, revision string, root activity.Root, repo github.Repo) int64 { queueLock := n.queue.GetLockState() var actions []github.CheckRunAction - var revisionsSummary string = n.queue.GetQueuedRevisionsSummary() + var revisionsSummary = n.queue.GetQueuedRevisionsSummary() summary := "This deploy is queued and will be processed as soon as possible.\n" + revisionsSummary state := github.CheckRunQueued diff --git a/server/neptune/workflows/internal/deploy/terraform/state.go b/server/neptune/workflows/internal/deploy/terraform/state.go index 8d806199a..659db470e 100644 --- a/server/neptune/workflows/internal/deploy/terraform/state.go +++ b/server/neptune/workflows/internal/deploy/terraform/state.go @@ -73,10 +73,11 @@ func (n *StateReceiver) Receive(ctx workflow.Context, c workflow.ReceiveChannel, var actions []github.CheckRunAction var summary string - if workflowState.Apply.Status == state.WaitingJobStatus { + switch workflowState.Apply.Status { + case state.WaitingJobStatus: runLink := github.BuildRunURLMarkdown(deploymentInfo.Repo.GetFullName(), deploymentInfo.Commit.Revision, deploymentInfo.CheckRunID) summary = fmt.Sprintf("This deploy is queued pending action on run for revision %s.\n%s", runLink, revisionsSummary) - } else if workflowState.Apply.Status == state.RejectedJobStatus || workflowState.Apply.Status == state.InProgressJobStatus { + case state.RejectedJobStatus, state.InProgressJobStatus: // If the current deployment is Rejected or In Progress status, we need to restore the queued check runs to reflect that the queued deployments are not blocked. // If the queue is currently locked we need to provide the unlock action. queueLock := n.Queue.GetLockState() diff --git a/server/neptune/workflows/internal/pr/revision/policy/handler.go b/server/neptune/workflows/internal/pr/revision/policy/handler.go index 125e94aa9..12b98db56 100644 --- a/server/neptune/workflows/internal/pr/revision/policy/handler.go +++ b/server/neptune/workflows/internal/pr/revision/policy/handler.go @@ -98,10 +98,8 @@ func (f *FailedPolicyHandler) Handle(ctx workflow.Context, revision revision.Rev // perform initial check immediately (subsequent polls can occur at larger intervals) cancelTimer, _ := s.AddTimeout(ctx, time.Millisecond, onTimeout) - for { - if len(failingTerraformWorkflows) == 0 { - break - } + for len(failingTerraformWorkflows) != 0 { + s.Select(ctx) switch action { case onShutdown: diff --git a/server/neptune/workflows/internal/terraform/job/runner.go b/server/neptune/workflows/internal/terraform/job/runner.go index c55686c72..954b881d3 100644 --- a/server/neptune/workflows/internal/terraform/job/runner.go +++ b/server/neptune/workflows/internal/terraform/job/runner.go @@ -289,7 +289,7 @@ func (r *JobRunner) closeTerraformJob(executionCtx *ExecutionContext) { // create a new disconnected ctx since we want this run even in the event of // cancellation ctx := executionCtx.Context - if temporal.IsCanceledError(executionCtx.Context.Err()) { + if temporal.IsCanceledError(executionCtx.Err()) { var cancel workflow.CancelFunc ctx, cancel = workflow.NewDisconnectedContext(executionCtx.Context) defer cancel() diff --git a/server/recovery/recovery.go b/server/recovery/recovery.go index 950ab7c88..a5c289090 100644 --- a/server/recovery/recovery.go +++ b/server/recovery/recovery.go @@ -92,6 +92,6 @@ func function(pc uintptr) []byte { if period := bytes.Index(name, dot); period >= 0 { name = name[period+1:] } - name = bytes.Replace(name, centerDot, dot, -1) + name = bytes.ReplaceAll(name, centerDot, dot) return name } diff --git a/server/vcs/markdown/markdown_renderer_test.go b/server/vcs/markdown/markdown_renderer_test.go index 0a17a27f9..a8da51711 100644 --- a/server/vcs/markdown/markdown_renderer_test.go +++ b/server/vcs/markdown/markdown_renderer_test.go @@ -187,7 +187,7 @@ $$$ res := command.Result{ ProjectResults: c.ProjectResults, } - expWithBackticks := strings.Replace(c.Expected, "$", "`", -1) + expWithBackticks := strings.ReplaceAll(c.Expected, "$", "`") t.Run(fmt.Sprintf("%s_%t", c.Description, false), func(t *testing.T) { s := r.Render(res, c.Command, testRepo) Equals(t, expWithBackticks, s) @@ -887,7 +887,7 @@ $$$ } t.Run(c.Description, func(t *testing.T) { s := r.Render(res, c.Command, testRepo) - expWithBackticks := strings.Replace(c.Expected, "$", "`", -1) + expWithBackticks := strings.ReplaceAll(c.Expected, "$", "`") Equals(t, expWithBackticks, s) }) }) @@ -1038,7 +1038,7 @@ $$$ } t.Run(c.Description, func(t *testing.T) { s := r.Render(res, c.Command, testRepo) - expWithBackticks := strings.Replace(c.Expected, "$", "`", -1) + expWithBackticks := strings.ReplaceAll(c.Expected, "$", "`") Equals(t, expWithBackticks, s) }) }) @@ -1182,7 +1182,7 @@ $$$ } t.Run(c.Description, func(t *testing.T) { s := r.Render(res, c.Command, testRepo) - expWithBackticks := strings.Replace(c.Expected, "$", "`", -1) + expWithBackticks := strings.ReplaceAll(c.Expected, "$", "`") Equals(t, expWithBackticks, s) }) }) @@ -1271,7 +1271,7 @@ $$$ ` } - expWithBackticks := strings.Replace(exp, "$", "`", -1) + expWithBackticks := strings.ReplaceAll(exp, "$", "`") Equals(t, expWithBackticks, rendered) }) } @@ -1402,7 +1402,7 @@ $$$ } } - expWithBackticks := strings.Replace(exp, "$", "`", -1) + expWithBackticks := strings.ReplaceAll(exp, "$", "`") Equals(t, expWithBackticks, rendered) }) } @@ -1451,7 +1451,7 @@ $$$ --- ` - expWithBackticks := strings.Replace(exp, "$", "`", -1) + expWithBackticks := strings.ReplaceAll(exp, "$", "`") Equals(t, expWithBackticks, rendered) } @@ -1526,7 +1526,7 @@ Plan: 1 to add, 0 to change, 0 to destroy. * :put_litter_in_its_place: To delete all plans and locks for the PR, comment: * $atlantis unlock$ ` - expWithBackticks := strings.Replace(exp, "$", "`", -1) + expWithBackticks := strings.ReplaceAll(exp, "$", "`") Equals(t, expWithBackticks, rendered) } @@ -1804,7 +1804,7 @@ Plan: 1 to add, 1 to change, 1 to destroy. Type: c.VCSHost, }, }) - expWithBackticks := strings.Replace(c.Expected, "$", "`", -1) + expWithBackticks := strings.ReplaceAll(c.Expected, "$", "`") Equals(t, expWithBackticks, s) }) }) @@ -1886,7 +1886,7 @@ $$$`, r := Renderer{ TemplateResolver: templateResolver, } - expWithBackticks := strings.Replace(c.Expected, "$", "`", -1) + expWithBackticks := strings.ReplaceAll(c.Expected, "$", "`") t.Run(fmt.Sprintf("%s_%t", c.Description, false), func(t *testing.T) { s := r.RenderProject(c.ProjectResult, c.Command, testRepo) fmt.Println(s) @@ -2050,7 +2050,7 @@ $$$ t.Run(c.Description, func(t *testing.T) { s := r.RenderProject(c.ProjectResult, c.Command, testRepo) fmt.Print(s) - expWithBackticks := strings.Replace(c.Expected, "$", "`", -1) + expWithBackticks := strings.ReplaceAll(c.Expected, "$", "`") Equals(t, expWithBackticks, s) }) } diff --git a/server/vcs/markdown/template_resolver.go b/server/vcs/markdown/template_resolver.go index e790fe4d7..549f4e8d8 100644 --- a/server/vcs/markdown/template_resolver.go +++ b/server/vcs/markdown/template_resolver.go @@ -83,12 +83,12 @@ func (t *TemplateResolver) Resolve(common commonData, baseRepo models.Repo, numP } var tmpl *template.Template - switch { - case common.Command == planCommandTitle, common.Command == policyCheckCommandTitle: + switch common.Command { + case planCommandTitle, policyCheckCommandTitle: tmpl = t.getPlanTmpl(common, templateOverrides, numPrjResults, numPlanSuccesses, numPolicyCheckSuccesses) - case common.Command == applyCommandTitle: + case applyCommandTitle: tmpl = t.getApplyTmpl(templateOverrides, numPrjResults) - case common.Command == versionCommandTitle: + case versionCommandTitle: tmpl = t.getVersionTmpl(templateOverrides, common, numPrjResults, numVersionSuccesses) } From 26ea1f0e0c6e813add8394249109b48a2188bcd2 Mon Sep 17 00:00:00 2001 From: Hans Wernetti Date: Wed, 24 Sep 2025 13:47:49 -0700 Subject: [PATCH 05/11] use golangci-lint v2.4.0 in CI --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 88242ec2e..034fec969 100644 --- a/Makefile +++ b/Makefile @@ -61,7 +61,7 @@ lint: ## Run linter locally golangci-lint run check-lint: ## Run linter in CI/CD. If running locally use 'lint' - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b ./bin v1.39.0 + curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b ./bin v2.4.0 ./bin/golangci-lint run -j 4 --timeout 5m check-fmt: ## Fail if not formatted From f52adb0597abcbc5926a557f2c3776a37f72fa2f Mon Sep 17 00:00:00 2001 From: Hans Wernetti Date: Wed, 24 Sep 2025 13:55:30 -0700 Subject: [PATCH 06/11] fix all lint errors --- .claude/settings.local.json | 10 ++++++++++ .../controllers/events/handlers/pull_request.go | 2 +- .../controllers/websocket/instrumented_mux.go | 3 ++- server/legacy/core/runtime/apply_step_runner.go | 2 +- server/legacy/events/command_runner_test.go | 3 +-- server/legacy/events/matchers/logging_logger.go | 3 ++- server/legacy/events/matchers/models_pullrequest.go | 3 ++- server/legacy/events/matchers/models_repo.go | 3 ++- server/legacy/events/mock_workingdir_test.go | 5 +++-- .../events/size_limited_project_command_builder.go | 2 +- server/legacy/events/vcs/fixtures/fixtures.go | 4 ++-- server/legacy/events/working_dir_locker.go | 6 +++--- server/legacy/server.go | 2 +- .../adhocexecutionhelpers/adhoc_execution_params.go | 3 +-- .../adhocexecutionhelpers/root_helpers_test.go | 7 +++---- server/neptune/exec/exec_test.go | 3 ++- server/neptune/gateway/api/deploy.go | 1 + .../gateway/config/root_config_builder_test.go | 13 +++++++------ server/neptune/gateway/deploy/signaler_test.go | 10 +++++----- server/neptune/gateway/server.go | 7 +++---- server/neptune/lyft/activities/sns/writer.go | 3 +-- server/neptune/lyft/feature/retriever.go | 1 + server/neptune/sync/crons/ratelimit_stats.go | 3 ++- server/neptune/template/loader.go | 2 +- server/neptune/temporal/propagator.go | 1 + server/neptune/workflows/activities/conftest.go | 3 ++- .../workflows/activities/conftest/summary.go | 3 ++- .../workflows/activities/conftest/summary_test.go | 3 ++- .../neptune/workflows/activities/conftest_test.go | 5 +++-- .../activities/github/markdown/renderer.go | 3 ++- .../workflows/activities/github/middleware.go | 5 +++-- .../workflows/activities/temporal/heartbeat.go | 3 ++- .../workflows/activities/terraform/summary.go | 2 +- .../internal/deploy/revision/queue/worker.go | 11 +++++------ .../neptune/workflows/internal/deploy/workflow.go | 3 ++- .../neptune/workflows/internal/notifier/github.go | 1 + .../internal/notifier/github_cache_test.go | 3 ++- .../workflows/internal/notifier/github_test.go | 3 ++- .../internal/pr/revision/policy/dismisser.go | 3 ++- .../internal/pr/revision/policy/dismisser_test.go | 5 +++-- .../internal/pr/revision/policy/filter_test.go | 3 ++- .../internal/pr/revision/policy/handler.go | 1 - .../internal/pr/revision/policy/handler_test.go | 5 +++-- .../internal/pr/revision/processor_test.go | 5 +++-- .../neptune/workflows/internal/pr/revision/state.go | 1 + .../workflows/internal/pr/revision/state_test.go | 5 +++-- server/neptune/workflows/internal/pr/runner.go | 3 ++- server/neptune/workflows/internal/pr/runner_test.go | 5 +++-- server/neptune/workflows/internal/pr/shutdown.go | 1 + .../neptune/workflows/internal/pr/shutdown_test.go | 5 +++-- server/neptune/workflows/internal/pr/workflow.go | 5 +++-- .../neptune/workflows/internal/temporal/selector.go | 3 ++- .../workflows/internal/terraform/job/runner_test.go | 3 ++- .../workflows/internal/terraform/state/store.go | 3 ++- .../workflows/internal/terraform/state/workflow.go | 3 ++- server/vcs/provider/github/git_cred_writer_test.go | 3 ++- server/vcs/provider/github/list_iterator.go | 3 ++- server/vcs/provider/github/list_iterator_test.go | 5 +++-- server/vcs/provider/github/pr_fetcher.go | 3 ++- server/vcs/provider/github/request/handler_test.go | 3 +-- server/vcs/provider/github/team_fetcher.go | 1 + 61 files changed, 136 insertions(+), 91 deletions(-) create mode 100644 .claude/settings.local.json diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 000000000..9847bcf66 --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,10 @@ +{ + "permissions": { + "allow": [ + "Bash(make lint)", + "Bash(make fmt:*)" + ], + "deny": [], + "ask": [] + } +} \ No newline at end of file diff --git a/server/legacy/controllers/events/handlers/pull_request.go b/server/legacy/controllers/events/handlers/pull_request.go index d3ffdb38f..8d44087dd 100644 --- a/server/legacy/controllers/events/handlers/pull_request.go +++ b/server/legacy/controllers/events/handlers/pull_request.go @@ -120,7 +120,7 @@ func (h *PullRequestEvent) Handle(ctx context.Context, request *http.BufferedReq eventType := event.EventType if !h.RepoAllowlistChecker.IsAllowlisted(baseRepo.FullName, baseRepo.VCSHost.Hostname) { - return fmt.Errorf("Pull request event from non-allowlisted repo \"%s/%s\"", baseRepo.VCSHost.Hostname, baseRepo.FullName) + return fmt.Errorf("Pull request event from non-allowlisted repo \"%s/%s\"", baseRepo.VCSHost.Hostname, baseRepo.FullName) // nolint:staticcheck } switch eventType { diff --git a/server/legacy/controllers/websocket/instrumented_mux.go b/server/legacy/controllers/websocket/instrumented_mux.go index 66d7c90d0..d1644417b 100644 --- a/server/legacy/controllers/websocket/instrumented_mux.go +++ b/server/legacy/controllers/websocket/instrumented_mux.go @@ -1,8 +1,9 @@ package websocket import ( - "github.com/uber-go/tally/v4" "net/http" + + "github.com/uber-go/tally/v4" ) type InstrumentedMultiplexor struct { diff --git a/server/legacy/core/runtime/apply_step_runner.go b/server/legacy/core/runtime/apply_step_runner.go index fe3dfad98..21ef2aa92 100644 --- a/server/legacy/core/runtime/apply_step_runner.go +++ b/server/legacy/core/runtime/apply_step_runner.go @@ -201,7 +201,7 @@ func (a *ApplyStepRunner) remotePlanChanged(planfileContents string, applyOut st // Strip plan output after the prompt to execute the plan. planEndIdx := strings.Index(output, "Do you want to perform these actions in workspace \"") if planEndIdx < 0 { - return fmt.Errorf("Couldn't find plan end when parsing apply output:\n%q", applyOut) + return fmt.Errorf("Couldn't find plan end when parsing apply output:\n%q", applyOut) // nolint:staticcheck } currPlan := strings.TrimSpace(output[:planEndIdx]) diff --git a/server/legacy/events/command_runner_test.go b/server/legacy/events/command_runner_test.go index 3fe4db789..d54c9bc71 100644 --- a/server/legacy/events/command_runner_test.go +++ b/server/legacy/events/command_runner_test.go @@ -36,7 +36,6 @@ import ( lockingmocks "github.com/runatlantis/atlantis/server/legacy/core/locking/mocks" "github.com/runatlantis/atlantis/server/legacy/events" "github.com/runatlantis/atlantis/server/legacy/events/mocks" - eventmocks "github.com/runatlantis/atlantis/server/legacy/events/mocks" "github.com/runatlantis/atlantis/server/legacy/events/mocks/matchers" vcsmocks "github.com/runatlantis/atlantis/server/legacy/events/vcs/mocks" "github.com/runatlantis/atlantis/server/models" @@ -85,7 +84,7 @@ func setup(t *testing.T) *vcsmocks.MockClient { Ok(t, err) drainer = &events.Drainer{} - deleteLockCommand = eventmocks.NewMockDeleteLockCommand() + deleteLockCommand = mocks.NewMockDeleteLockCommand() applyLockChecker = lockingmocks.NewMockApplyLockChecker() dbUpdater = &events.DBUpdater{ diff --git a/server/legacy/events/matchers/logging_logger.go b/server/legacy/events/matchers/logging_logger.go index d43fd90e9..19eae48f9 100644 --- a/server/legacy/events/matchers/logging_logger.go +++ b/server/legacy/events/matchers/logging_logger.go @@ -2,9 +2,10 @@ package matchers import ( - "github.com/petergtz/pegomock" "reflect" + "github.com/petergtz/pegomock" + logging "github.com/runatlantis/atlantis/server/logging" ) diff --git a/server/legacy/events/matchers/models_pullrequest.go b/server/legacy/events/matchers/models_pullrequest.go index 94e36a1ab..eff31445d 100644 --- a/server/legacy/events/matchers/models_pullrequest.go +++ b/server/legacy/events/matchers/models_pullrequest.go @@ -2,9 +2,10 @@ package matchers import ( - "github.com/petergtz/pegomock" "reflect" + "github.com/petergtz/pegomock" + models "github.com/runatlantis/atlantis/server/models" ) diff --git a/server/legacy/events/matchers/models_repo.go b/server/legacy/events/matchers/models_repo.go index b36c3ee7c..bcf147850 100644 --- a/server/legacy/events/matchers/models_repo.go +++ b/server/legacy/events/matchers/models_repo.go @@ -2,9 +2,10 @@ package matchers import ( - "github.com/petergtz/pegomock" "reflect" + "github.com/petergtz/pegomock" + models "github.com/runatlantis/atlantis/server/models" ) diff --git a/server/legacy/events/mock_workingdir_test.go b/server/legacy/events/mock_workingdir_test.go index c0a932289..77ded22d2 100644 --- a/server/legacy/events/mock_workingdir_test.go +++ b/server/legacy/events/mock_workingdir_test.go @@ -4,11 +4,12 @@ package events import ( + "reflect" + "time" + pegomock "github.com/petergtz/pegomock" logging "github.com/runatlantis/atlantis/server/logging" models "github.com/runatlantis/atlantis/server/models" - "reflect" - "time" ) type MockWorkingDir struct { diff --git a/server/legacy/events/size_limited_project_command_builder.go b/server/legacy/events/size_limited_project_command_builder.go index 136a2f34f..aec558058 100644 --- a/server/legacy/events/size_limited_project_command_builder.go +++ b/server/legacy/events/size_limited_project_command_builder.go @@ -47,7 +47,7 @@ func (b *SizeLimitedProjectCommandBuilder) CheckAgainstLimit(projects []command. "2) Pull Request batch is too large for the given Atlantis instance\n\n"+ "Please break this pull request into smaller batches and try again.", b.Limit, - ) + ) // nolint:staticcheck } return nil } diff --git a/server/legacy/events/vcs/fixtures/fixtures.go b/server/legacy/events/vcs/fixtures/fixtures.go index 4ce4e184b..f2b79e2cd 100644 --- a/server/legacy/events/vcs/fixtures/fixtures.go +++ b/server/legacy/events/vcs/fixtures/fixtures.go @@ -335,7 +335,7 @@ func validateGithubToken(tokenString string) error { token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) { // Don't forget to validate the alg is what you expect: if _, ok := token.Method.(*jwt.SigningMethodRSA); !ok { - err := fmt.Errorf("Unexpected signing method: %v", token.Header["alg"]) + err := fmt.Errorf("Unexpected signing method: %v", token.Header["alg"]) // nolint:staticcheck return nil, err } @@ -347,7 +347,7 @@ func validateGithubToken(tokenString string) error { } if claims, ok := token.Claims.(jwt.MapClaims); !ok || !token.Valid || claims["iss"] != "1" { - return fmt.Errorf("Invalid token") + return fmt.Errorf("Invalid token") // nolint:staticcheck } return nil } diff --git a/server/legacy/events/working_dir_locker.go b/server/legacy/events/working_dir_locker.go index 7642e0ca2..71442d712 100644 --- a/server/legacy/events/working_dir_locker.go +++ b/server/legacy/events/working_dir_locker.go @@ -65,7 +65,7 @@ func (d *DefaultWorkingDirLocker) TryLockPull(repoFullName string, pullNum int) if l == pullKey || strings.HasPrefix(l, pullKey+"/") { 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.") // nolint:staticcheck } } 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) for _, l := range d.locks { if l == pullKey || l == workspaceKey { - return func() {}, fmt.Errorf("The %s workspace is currently locked by another"+ + return func() {}, fmt.Errorf("the %s workspace 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) + "Wait until the previous command is complete and try again", workspace) } } d.locks = append(d.locks, workspaceKey) diff --git a/server/legacy/server.go b/server/legacy/server.go index 6c6d044a8..dc85a7530 100644 --- a/server/legacy/server.go +++ b/server/legacy/server.go @@ -899,7 +899,7 @@ func (s *Server) Start() error { s.CtxLogger.Error(err.Error()) } - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) // nolint: vet + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() if err := server.Shutdown(ctx); err != nil { return cli.NewExitError(fmt.Sprintf("while shutting down: %s", err), 1) diff --git a/server/neptune/adhoc/adhocexecutionhelpers/adhoc_execution_params.go b/server/neptune/adhoc/adhocexecutionhelpers/adhoc_execution_params.go index cae5502de..a03c9ca26 100644 --- a/server/neptune/adhoc/adhocexecutionhelpers/adhoc_execution_params.go +++ b/server/neptune/adhoc/adhocexecutionhelpers/adhoc_execution_params.go @@ -4,7 +4,6 @@ import ( "context" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/neptune/gateway/config" root_config "github.com/runatlantis/atlantis/server/neptune/gateway/config" "github.com/runatlantis/atlantis/server/neptune/workflows/activities/github" "github.com/runatlantis/atlantis/server/neptune/workflows/activities/terraform" @@ -44,7 +43,7 @@ func ConstructAdhocExecParams( return AdhocTerraformWorkflowExecutionParams{}, errors.Wrap(err, "converting commit") } - opts := config.BuilderOptions{ + opts := root_config.BuilderOptions{ RepoFetcherOptions: &internal_gh.RepoFetcherOptions{ CloneDepth: 1, SimplePath: true, diff --git a/server/neptune/adhoc/adhocexecutionhelpers/root_helpers_test.go b/server/neptune/adhoc/adhocexecutionhelpers/root_helpers_test.go index f818ef172..ade3ab7ec 100644 --- a/server/neptune/adhoc/adhocexecutionhelpers/root_helpers_test.go +++ b/server/neptune/adhoc/adhocexecutionhelpers/root_helpers_test.go @@ -3,7 +3,6 @@ package adhoc import ( "testing" - "github.com/runatlantis/atlantis/server/config/valid" v "github.com/runatlantis/atlantis/server/config/valid" "github.com/runatlantis/atlantis/server/neptune/workflows" "github.com/runatlantis/atlantis/server/neptune/workflows/activities/execute" @@ -12,11 +11,11 @@ import ( func TestPrependPlanEnvSteps(t *testing.T) { tests := []struct { - cfg *valid.MergedProjectCfg + cfg *v.MergedProjectCfg expectedSteps []workflows.Step }{ { - cfg: &valid.MergedProjectCfg{ + cfg: &v.MergedProjectCfg{ Tags: map[string]string{"manifest_path": "manifest_path"}, DeploymentWorkflow: v.Workflow{ Plan: v.Stage{ @@ -48,7 +47,7 @@ func TestPrependPlanEnvSteps(t *testing.T) { }, }, { - cfg: &valid.MergedProjectCfg{ + cfg: &v.MergedProjectCfg{ Tags: map[string]string{"foo": "foo"}, DeploymentWorkflow: v.Workflow{ Plan: v.Stage{ diff --git a/server/neptune/exec/exec_test.go b/server/neptune/exec/exec_test.go index 2ce74be73..07c9ead78 100644 --- a/server/neptune/exec/exec_test.go +++ b/server/neptune/exec/exec_test.go @@ -2,10 +2,11 @@ package exec_test import ( "context" + "testing" + "github.com/runatlantis/atlantis/server/logging" subprocess_exec "github.com/runatlantis/atlantis/server/neptune/exec" "github.com/stretchr/testify/assert" - "testing" ) func TestCmd_RunWithNewProcessGroup(t *testing.T) { diff --git a/server/neptune/gateway/api/deploy.go b/server/neptune/gateway/api/deploy.go index 549262d19..d3f7bb5e7 100644 --- a/server/neptune/gateway/api/deploy.go +++ b/server/neptune/gateway/api/deploy.go @@ -2,6 +2,7 @@ package api import ( "context" + "github.com/runatlantis/atlantis/server/logging" "github.com/runatlantis/atlantis/server/neptune/gateway/api/request" "github.com/runatlantis/atlantis/server/neptune/gateway/deploy" diff --git a/server/neptune/gateway/config/root_config_builder_test.go b/server/neptune/gateway/config/root_config_builder_test.go index 29d233e5b..0987f4d2e 100644 --- a/server/neptune/gateway/config/root_config_builder_test.go +++ b/server/neptune/gateway/config/root_config_builder_test.go @@ -17,7 +17,8 @@ import ( var rcb config.Builder var globalCfg valid.GlobalCfg -var expectedErr = errors.New("some error") //nolint:revive // error name is fine for testing purposes +var errTest = errors.New("some error") + const testRoot = "testroot" func setupTesting(t *testing.T) { @@ -147,7 +148,7 @@ func TestRootConfigBuilder_DetermineRootsError(t *testing.T) { Sha: "1234", } mockRootFinder := &mockRootFinder{ - error: expectedErr, + error: errTest, } rcb.Strategy.RootFinder = mockRootFinder projectConfigs, err := rcb.Build(context.Background(), commit, 2) @@ -166,7 +167,7 @@ func TestRootConfigBuilder_ParserValidatorParseError(t *testing.T) { Sha: "1234", } mockParserValidator := &mockParserValidator{ - error: expectedErr, + error: errTest, } rcb.ParserValidator = mockParserValidator projectConfigs, err := rcb.Build(context.Background(), commit, 2) @@ -185,7 +186,7 @@ func TestRootConfigBuilder_GetModifiedFilesError(t *testing.T) { Sha: "1234", } rcb.Strategy.FileFetcher = &mockFileFetcher{ - error: expectedErr, + error: errTest, } projectConfigs, err := rcb.Build(context.Background(), commit, 2) assert.Error(t, err) @@ -203,7 +204,7 @@ func TestRootConfigBuilder_CloneError(t *testing.T) { Sha: "1234", } rcb.RepoFetcher = &mockRepoFetcher{ - cloneError: expectedErr, + cloneError: errTest, } projectConfigs, err := rcb.Build(context.Background(), commit, 2) assert.Error(t, err) @@ -221,7 +222,7 @@ func TestRootConfigBuilder_HooksRunnerError(t *testing.T) { Sha: "1234", } mockHooksRunner := &mockHooksRunner{ - error: expectedErr, + error: errTest, } rcb.HooksRunner = mockHooksRunner projectConfigs, err := rcb.Build(context.Background(), commit, 2) diff --git a/server/neptune/gateway/deploy/signaler_test.go b/server/neptune/gateway/deploy/signaler_test.go index af347947a..3d56a7cf6 100644 --- a/server/neptune/gateway/deploy/signaler_test.go +++ b/server/neptune/gateway/deploy/signaler_test.go @@ -15,7 +15,7 @@ import ( "go.temporal.io/sdk/client" ) -var expectedErr = errors.New("some error") //nolint:revive // error name is fine for testing purposes +var errTest = errors.New("some error") type testRun struct{} @@ -44,7 +44,7 @@ type testSignaler struct { expectedOptions client.StartWorkflowOptions expectedWorkflow interface{} expectedWorkflowArgs interface{} - expectedErr error + errTest error called bool } @@ -56,7 +56,7 @@ func (s *testSignaler) SignalWorkflow(ctx context.Context, workflowID string, ru assert.Equal(s.t, s.expectedSignalName, signalName) assert.Equal(s.t, s.expectedSignalArg, arg) - return s.expectedErr + return s.errTest } func (s *testSignaler) SignalWithStartWorkflow(ctx context.Context, workflowID string, signalName string, signalArg interface{}, @@ -70,7 +70,7 @@ func (s *testSignaler) SignalWithStartWorkflow(ctx context.Context, workflowID s assert.IsType(s.t, s.expectedWorkflow, workflow) assert.Equal(s.t, []interface{}{s.expectedWorkflowArgs}, workflowArgs) - return testRun{}, s.expectedErr + return testRun{}, s.errTest } func TestSignalWithStartWorkflow_Success(t *testing.T) { @@ -332,7 +332,7 @@ func TestSignalWithStartWorkflow_Failure(t *testing.T) { Name: rootCfg.Name, }, }, - expectedErr: expectedErr, + errTest: errTest, } deploySignaler := deploy.WorkflowSignaler{ TemporalClient: testSignaler, diff --git a/server/neptune/gateway/server.go b/server/neptune/gateway/server.go index 53e5fb466..ff6e789e0 100644 --- a/server/neptune/gateway/server.go +++ b/server/neptune/gateway/server.go @@ -30,7 +30,6 @@ import ( "github.com/runatlantis/atlantis/server/neptune/gateway/event/preworkflow" httpInternal "github.com/runatlantis/atlantis/server/neptune/http" "github.com/runatlantis/atlantis/server/neptune/lyft/feature" - "github.com/runatlantis/atlantis/server/neptune/sync" internalSync "github.com/runatlantis/atlantis/server/neptune/sync" "github.com/runatlantis/atlantis/server/neptune/sync/crons" "github.com/runatlantis/atlantis/server/neptune/temporal" @@ -78,7 +77,7 @@ type Server struct { Logger logging.Logger Port int Drainer *events.Drainer - Scheduler *sync.AsyncScheduler + Scheduler *internalSync.AsyncScheduler Server httpInternal.ServerProxy TemporalClient client.Client CronScheduler *internalSync.CronScheduler @@ -186,11 +185,11 @@ func NewServer(config Config) (*Server, error) { GithubUser: config.GithubAppSlug, } - syncScheduler := &sync.SynchronousScheduler{ + syncScheduler := &internalSync.SynchronousScheduler{ Logger: ctxLogger, PanicRecoveryEnabled: true, } - asyncScheduler := sync.NewAsyncScheduler(ctxLogger, syncScheduler) + asyncScheduler := internalSync.NewAsyncScheduler(ctxLogger, syncScheduler) vcsStatusUpdater := &command.VCSStatusUpdater{Client: vcsClient, TitleBuilder: vcs.StatusTitleBuilder{TitlePrefix: config.GithubStatusName}} repoConverter := github_converter.RepoConverter{} diff --git a/server/neptune/lyft/activities/sns/writer.go b/server/neptune/lyft/activities/sns/writer.go index e8256d176..390826993 100644 --- a/server/neptune/lyft/activities/sns/writer.go +++ b/server/neptune/lyft/activities/sns/writer.go @@ -2,12 +2,11 @@ package sns import ( "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/sns" awsSns "github.com/aws/aws-sdk-go/service/sns" ) type snsPublisher interface { - Publish(*sns.PublishInput) (*sns.PublishOutput, error) + Publish(*awsSns.PublishInput) (*awsSns.PublishOutput, error) } type Writer struct { diff --git a/server/neptune/lyft/feature/retriever.go b/server/neptune/lyft/feature/retriever.go index 57f7e23b0..210716003 100644 --- a/server/neptune/lyft/feature/retriever.go +++ b/server/neptune/lyft/feature/retriever.go @@ -2,6 +2,7 @@ package feature import ( "context" + "github.com/pkg/errors" gh "github.com/runatlantis/atlantis/server/vcs/provider/github" ) diff --git a/server/neptune/sync/crons/ratelimit_stats.go b/server/neptune/sync/crons/ratelimit_stats.go index 9382ab014..5d3db177c 100644 --- a/server/neptune/sync/crons/ratelimit_stats.go +++ b/server/neptune/sync/crons/ratelimit_stats.go @@ -2,11 +2,12 @@ package crons import ( "context" + "net/http" + "github.com/palantir/go-githubapp/githubapp" "github.com/pkg/errors" "github.com/runatlantis/atlantis/server/metrics" "github.com/uber-go/tally/v4" - "net/http" ) const ( diff --git a/server/neptune/template/loader.go b/server/neptune/template/loader.go index 7d88f215f..7e3a2f145 100644 --- a/server/neptune/template/loader.go +++ b/server/neptune/template/loader.go @@ -94,7 +94,7 @@ func (l Loader[T]) Load(id Key, repo models.Repo, data T) (string, error) { buf := &bytes.Buffer{} if err := tmpl.Execute(buf, data); err != nil { - return "", fmt.Errorf("Failed to render template: %v", err) + return "", fmt.Errorf("failed to render template: %v", err) } return buf.String(), nil } diff --git a/server/neptune/temporal/propagator.go b/server/neptune/temporal/propagator.go index 078f5330d..9082335fb 100644 --- a/server/neptune/temporal/propagator.go +++ b/server/neptune/temporal/propagator.go @@ -2,6 +2,7 @@ package temporal import ( "context" + internalContext "github.com/runatlantis/atlantis/server/neptune/context" "github.com/pkg/errors" diff --git a/server/neptune/workflows/activities/conftest.go b/server/neptune/workflows/activities/conftest.go index eaa3d9270..a94646fa9 100644 --- a/server/neptune/workflows/activities/conftest.go +++ b/server/neptune/workflows/activities/conftest.go @@ -4,11 +4,12 @@ import ( "bytes" "context" "fmt" + "strings" + "github.com/hashicorp/go-version" "github.com/runatlantis/atlantis/server/neptune/workflows/activities/command" "github.com/runatlantis/atlantis/server/neptune/workflows/activities/temporal" "go.temporal.io/sdk/activity" - "strings" ) type asyncClient interface { diff --git a/server/neptune/workflows/activities/conftest/summary.go b/server/neptune/workflows/activities/conftest/summary.go index 7b1cc0231..d2eb935dd 100644 --- a/server/neptune/workflows/activities/conftest/summary.go +++ b/server/neptune/workflows/activities/conftest/summary.go @@ -2,8 +2,9 @@ package conftest import ( "fmt" - "github.com/runatlantis/atlantis/server/neptune/workflows/activities" "strings" + + "github.com/runatlantis/atlantis/server/neptune/workflows/activities" ) type ValidateSummary struct { diff --git a/server/neptune/workflows/activities/conftest/summary_test.go b/server/neptune/workflows/activities/conftest/summary_test.go index 5d8d509ce..4892f0354 100644 --- a/server/neptune/workflows/activities/conftest/summary_test.go +++ b/server/neptune/workflows/activities/conftest/summary_test.go @@ -1,9 +1,10 @@ package conftest import ( + "testing" + "github.com/runatlantis/atlantis/server/neptune/workflows/activities" "gopkg.in/go-playground/assert.v1" - "testing" ) func TestNewValidateSummaryFromResults(t *testing.T) { diff --git a/server/neptune/workflows/activities/conftest_test.go b/server/neptune/workflows/activities/conftest_test.go index 5d3d264d6..b45681133 100644 --- a/server/neptune/workflows/activities/conftest_test.go +++ b/server/neptune/workflows/activities/conftest_test.go @@ -1,12 +1,13 @@ package activities import ( + "strings" + "testing" + "github.com/hashicorp/go-version" "github.com/runatlantis/atlantis/server/neptune/workflows/activities/command" "github.com/stretchr/testify/assert" "go.temporal.io/sdk/testsuite" - "strings" - "testing" ) func TestConftest_RequestValidation(t *testing.T) { diff --git a/server/neptune/workflows/activities/github/markdown/renderer.go b/server/neptune/workflows/activities/github/markdown/renderer.go index da4f822a0..0cddad60d 100644 --- a/server/neptune/workflows/activities/github/markdown/renderer.go +++ b/server/neptune/workflows/activities/github/markdown/renderer.go @@ -4,9 +4,10 @@ import ( "bytes" _ "embed" //embedding files "fmt" + "html/template" + "github.com/runatlantis/atlantis/server/neptune/workflows/activities/github" "github.com/runatlantis/atlantis/server/neptune/workflows/activities/terraform" - "html/template" "github.com/runatlantis/atlantis/server/neptune/workflows/internal/terraform/state" ) diff --git a/server/neptune/workflows/activities/github/middleware.go b/server/neptune/workflows/activities/github/middleware.go index f27c794da..c0020c459 100644 --- a/server/neptune/workflows/activities/github/middleware.go +++ b/server/neptune/workflows/activities/github/middleware.go @@ -1,11 +1,12 @@ package github import ( + "net/http" + "strconv" + "github.com/gregjones/httpcache" "github.com/palantir/go-githubapp/githubapp" "github.com/uber-go/tally/v4" - "net/http" - "strconv" ) const ( diff --git a/server/neptune/workflows/activities/temporal/heartbeat.go b/server/neptune/workflows/activities/temporal/heartbeat.go index 7d37481bf..41077dd8f 100644 --- a/server/neptune/workflows/activities/temporal/heartbeat.go +++ b/server/neptune/workflows/activities/temporal/heartbeat.go @@ -2,8 +2,9 @@ package temporal import ( "context" - "go.temporal.io/sdk/activity" "time" + + "go.temporal.io/sdk/activity" ) const HeartbeatTimeout = 5 * time.Second diff --git a/server/neptune/workflows/activities/terraform/summary.go b/server/neptune/workflows/activities/terraform/summary.go index eab26df8d..45006dca7 100644 --- a/server/neptune/workflows/activities/terraform/summary.go +++ b/server/neptune/workflows/activities/terraform/summary.go @@ -4,7 +4,7 @@ import ( "encoding/json" "fmt" - "github.com/hashicorp/terraform-json" + tfjson "github.com/hashicorp/terraform-json" "github.com/pkg/errors" ) diff --git a/server/neptune/workflows/internal/deploy/revision/queue/worker.go b/server/neptune/workflows/internal/deploy/revision/queue/worker.go index f2acd0287..46887c6d0 100644 --- a/server/neptune/workflows/internal/deploy/revision/queue/worker.go +++ b/server/neptune/workflows/internal/deploy/revision/queue/worker.go @@ -10,7 +10,6 @@ import ( metricNames "github.com/runatlantis/atlantis/server/metrics" "github.com/pkg/errors" - internalContext "github.com/runatlantis/atlantis/server/neptune/context" "github.com/runatlantis/atlantis/server/neptune/workflows/activities/deployment" tfModel "github.com/runatlantis/atlantis/server/neptune/workflows/activities/terraform" "github.com/runatlantis/atlantis/server/neptune/workflows/internal/deploy/lock" @@ -285,11 +284,11 @@ func (w *Worker) awaitWork(ctx workflow.Context) workflow.Future { } func setContextKeys(ctx workflow.Context, requestedDeployment terraform.DeploymentInfo) workflow.Context { - ctx = workflow.WithValue(ctx, internalContext.SHAKey, requestedDeployment.Commit.Revision) - ctx = workflow.WithValue(ctx, internalContext.BranchKey, requestedDeployment.Commit.Branch) - ctx = workflow.WithValue(ctx, internalContext.DeploymentIDKey, requestedDeployment.ID) - ctx = workflow.WithValue(ctx, internalContext.PlanMode, string(requestedDeployment.Root.Plan.GetPlanMode())) - ctx = workflow.WithValue(ctx, internalContext.Trigger, string(requestedDeployment.Root.TriggerInfo.Type)) + ctx = workflow.WithValue(ctx, key.SHAKey, requestedDeployment.Commit.Revision) + ctx = workflow.WithValue(ctx, key.BranchKey, requestedDeployment.Commit.Branch) + ctx = workflow.WithValue(ctx, key.DeploymentIDKey, requestedDeployment.ID) + ctx = workflow.WithValue(ctx, key.PlanMode, string(requestedDeployment.Root.Plan.GetPlanMode())) + ctx = workflow.WithValue(ctx, key.Trigger, string(requestedDeployment.Root.TriggerInfo.Type)) return ctx } diff --git a/server/neptune/workflows/internal/deploy/workflow.go b/server/neptune/workflows/internal/deploy/workflow.go index 986317743..384e1896d 100644 --- a/server/neptune/workflows/internal/deploy/workflow.go +++ b/server/neptune/workflows/internal/deploy/workflow.go @@ -1,9 +1,10 @@ package deploy import ( - "github.com/runatlantis/atlantis/server/neptune/workflows/internal/notifier" "time" + "github.com/runatlantis/atlantis/server/neptune/workflows/internal/notifier" + "github.com/pkg/errors" key "github.com/runatlantis/atlantis/server/neptune/context" "github.com/runatlantis/atlantis/server/neptune/workflows/activities" diff --git a/server/neptune/workflows/internal/notifier/github.go b/server/neptune/workflows/internal/notifier/github.go index 45a7cd081..5f9a8d99f 100644 --- a/server/neptune/workflows/internal/notifier/github.go +++ b/server/neptune/workflows/internal/notifier/github.go @@ -3,6 +3,7 @@ package notifier import ( "context" "fmt" + "github.com/google/uuid" "github.com/pkg/errors" "github.com/runatlantis/atlantis/server/neptune/workflows/activities" diff --git a/server/neptune/workflows/internal/notifier/github_cache_test.go b/server/neptune/workflows/internal/notifier/github_cache_test.go index a38f8efa6..b09ea7ab2 100644 --- a/server/neptune/workflows/internal/notifier/github_cache_test.go +++ b/server/neptune/workflows/internal/notifier/github_cache_test.go @@ -2,10 +2,11 @@ package notifier_test import ( "context" - "github.com/runatlantis/atlantis/server/neptune/workflows/internal/notifier" "testing" "time" + "github.com/runatlantis/atlantis/server/neptune/workflows/internal/notifier" + "github.com/runatlantis/atlantis/server/neptune/workflows/activities" "github.com/runatlantis/atlantis/server/neptune/workflows/activities/github" "github.com/stretchr/testify/assert" diff --git a/server/neptune/workflows/internal/notifier/github_test.go b/server/neptune/workflows/internal/notifier/github_test.go index e638ad608..a50eb3ae8 100644 --- a/server/neptune/workflows/internal/notifier/github_test.go +++ b/server/neptune/workflows/internal/notifier/github_test.go @@ -1,11 +1,12 @@ package notifier_test import ( - "github.com/runatlantis/atlantis/server/neptune/workflows/internal/notifier" "net/url" "testing" "time" + "github.com/runatlantis/atlantis/server/neptune/workflows/internal/notifier" + "github.com/google/uuid" "github.com/runatlantis/atlantis/server/neptune/workflows/activities/github" "github.com/runatlantis/atlantis/server/neptune/workflows/activities/github/markdown" diff --git a/server/neptune/workflows/internal/pr/revision/policy/dismisser.go b/server/neptune/workflows/internal/pr/revision/policy/dismisser.go index efb7e8d4e..de2866fb9 100644 --- a/server/neptune/workflows/internal/pr/revision/policy/dismisser.go +++ b/server/neptune/workflows/internal/pr/revision/policy/dismisser.go @@ -2,11 +2,12 @@ package policy import ( "context" + "sort" + "github.com/google/go-github/v45/github" "github.com/runatlantis/atlantis/server/neptune/workflows/activities" "github.com/runatlantis/atlantis/server/neptune/workflows/internal/pr/revision" "go.temporal.io/sdk/workflow" - "sort" ) type dismisserGithubActivities interface { diff --git a/server/neptune/workflows/internal/pr/revision/policy/dismisser_test.go b/server/neptune/workflows/internal/pr/revision/policy/dismisser_test.go index 86385a82f..0ab76c9e7 100644 --- a/server/neptune/workflows/internal/pr/revision/policy/dismisser_test.go +++ b/server/neptune/workflows/internal/pr/revision/policy/dismisser_test.go @@ -2,6 +2,9 @@ package policy_test import ( "context" + "testing" + "time" + "github.com/google/go-github/v45/github" "github.com/runatlantis/atlantis/server/neptune/workflows/activities" gh "github.com/runatlantis/atlantis/server/neptune/workflows/activities/github" @@ -10,8 +13,6 @@ import ( "github.com/stretchr/testify/assert" "go.temporal.io/sdk/testsuite" "go.temporal.io/sdk/workflow" - "testing" - "time" ) type dismissRequest struct { diff --git a/server/neptune/workflows/internal/pr/revision/policy/filter_test.go b/server/neptune/workflows/internal/pr/revision/policy/filter_test.go index 67073c796..2a4b5ddde 100644 --- a/server/neptune/workflows/internal/pr/revision/policy/filter_test.go +++ b/server/neptune/workflows/internal/pr/revision/policy/filter_test.go @@ -1,11 +1,12 @@ package policy_test import ( + "testing" + "github.com/google/go-github/v45/github" "github.com/runatlantis/atlantis/server/neptune/workflows/activities" "github.com/runatlantis/atlantis/server/neptune/workflows/internal/pr/revision/policy" "github.com/stretchr/testify/assert" - "testing" ) func TestFilter_FilterOutTeamA(t *testing.T) { diff --git a/server/neptune/workflows/internal/pr/revision/policy/handler.go b/server/neptune/workflows/internal/pr/revision/policy/handler.go index 12b98db56..153d0ae19 100644 --- a/server/neptune/workflows/internal/pr/revision/policy/handler.go +++ b/server/neptune/workflows/internal/pr/revision/policy/handler.go @@ -99,7 +99,6 @@ func (f *FailedPolicyHandler) Handle(ctx workflow.Context, revision revision.Rev cancelTimer, _ := s.AddTimeout(ctx, time.Millisecond, onTimeout) for len(failingTerraformWorkflows) != 0 { - s.Select(ctx) switch action { case onShutdown: diff --git a/server/neptune/workflows/internal/pr/revision/policy/handler_test.go b/server/neptune/workflows/internal/pr/revision/policy/handler_test.go index fcdbf1615..d1e66f035 100644 --- a/server/neptune/workflows/internal/pr/revision/policy/handler_test.go +++ b/server/neptune/workflows/internal/pr/revision/policy/handler_test.go @@ -2,6 +2,9 @@ package policy_test import ( "context" + "testing" + "time" + "github.com/google/go-github/v45/github" "github.com/runatlantis/atlantis/server/neptune/workflows/activities" gh "github.com/runatlantis/atlantis/server/neptune/workflows/activities/github" @@ -13,8 +16,6 @@ import ( "github.com/stretchr/testify/assert" "go.temporal.io/sdk/testsuite" "go.temporal.io/sdk/workflow" - "testing" - "time" ) type request struct { diff --git a/server/neptune/workflows/internal/pr/revision/processor_test.go b/server/neptune/workflows/internal/pr/revision/processor_test.go index f7d248cd4..511e2ef50 100644 --- a/server/neptune/workflows/internal/pr/revision/processor_test.go +++ b/server/neptune/workflows/internal/pr/revision/processor_test.go @@ -1,6 +1,9 @@ package revision_test import ( + "testing" + "time" + "github.com/runatlantis/atlantis/server/neptune/workflows/activities" "github.com/runatlantis/atlantis/server/neptune/workflows/activities/github" terraformActivities "github.com/runatlantis/atlantis/server/neptune/workflows/activities/terraform" @@ -11,8 +14,6 @@ import ( "github.com/stretchr/testify/assert" "go.temporal.io/sdk/testsuite" "go.temporal.io/sdk/workflow" - "testing" - "time" ) const ( diff --git a/server/neptune/workflows/internal/pr/revision/state.go b/server/neptune/workflows/internal/pr/revision/state.go index 633d7f15a..cdaa87d02 100644 --- a/server/neptune/workflows/internal/pr/revision/state.go +++ b/server/neptune/workflows/internal/pr/revision/state.go @@ -2,6 +2,7 @@ package revision import ( "fmt" + "github.com/pkg/errors" "github.com/runatlantis/atlantis/server/metrics" "github.com/runatlantis/atlantis/server/neptune/workflows/internal/notifier" diff --git a/server/neptune/workflows/internal/pr/revision/state_test.go b/server/neptune/workflows/internal/pr/revision/state_test.go index e4ffad9a1..1cf6cc037 100644 --- a/server/neptune/workflows/internal/pr/revision/state_test.go +++ b/server/neptune/workflows/internal/pr/revision/state_test.go @@ -1,12 +1,13 @@ package revision_test import ( - "github.com/runatlantis/atlantis/server/neptune/workflows/internal/notifier" - "github.com/runatlantis/atlantis/server/neptune/workflows/internal/pr/revision" "net/url" "testing" "time" + "github.com/runatlantis/atlantis/server/neptune/workflows/internal/notifier" + "github.com/runatlantis/atlantis/server/neptune/workflows/internal/pr/revision" + "github.com/google/uuid" "github.com/runatlantis/atlantis/server/neptune/workflows/activities/github" "github.com/runatlantis/atlantis/server/neptune/workflows/activities/terraform" diff --git a/server/neptune/workflows/internal/pr/runner.go b/server/neptune/workflows/internal/pr/runner.go index 8de8e9d4c..d6db0cd90 100644 --- a/server/neptune/workflows/internal/pr/runner.go +++ b/server/neptune/workflows/internal/pr/runner.go @@ -2,9 +2,10 @@ package pr import ( "context" + "time" + tfModel "github.com/runatlantis/atlantis/server/neptune/workflows/activities/terraform" "github.com/runatlantis/atlantis/server/neptune/workflows/internal/notifier" - "time" metricNames "github.com/runatlantis/atlantis/server/metrics" internalContext "github.com/runatlantis/atlantis/server/neptune/context" diff --git a/server/neptune/workflows/internal/pr/runner_test.go b/server/neptune/workflows/internal/pr/runner_test.go index 050ab318e..84035c52c 100644 --- a/server/neptune/workflows/internal/pr/runner_test.go +++ b/server/neptune/workflows/internal/pr/runner_test.go @@ -2,6 +2,9 @@ package pr import ( "context" + "testing" + "time" + "github.com/runatlantis/atlantis/server/neptune/workflows/activities" "github.com/runatlantis/atlantis/server/neptune/workflows/internal/metrics" "github.com/runatlantis/atlantis/server/neptune/workflows/internal/pr/revision" @@ -9,8 +12,6 @@ import ( "github.com/stretchr/testify/mock" "go.temporal.io/sdk/testsuite" "go.temporal.io/sdk/workflow" - "testing" - "time" ) type request struct { diff --git a/server/neptune/workflows/internal/pr/shutdown.go b/server/neptune/workflows/internal/pr/shutdown.go index d94121142..de22742ab 100644 --- a/server/neptune/workflows/internal/pr/shutdown.go +++ b/server/neptune/workflows/internal/pr/shutdown.go @@ -2,6 +2,7 @@ package pr import ( "context" + "github.com/runatlantis/atlantis/server/neptune/workflows/activities" "github.com/runatlantis/atlantis/server/neptune/workflows/internal/pr/revision" "go.temporal.io/sdk/workflow" diff --git a/server/neptune/workflows/internal/pr/shutdown_test.go b/server/neptune/workflows/internal/pr/shutdown_test.go index be39fb7a8..d9f2e2126 100644 --- a/server/neptune/workflows/internal/pr/shutdown_test.go +++ b/server/neptune/workflows/internal/pr/shutdown_test.go @@ -2,6 +2,9 @@ package pr_test import ( "context" + "testing" + "time" + "github.com/runatlantis/atlantis/server/neptune/workflows/activities" "github.com/runatlantis/atlantis/server/neptune/workflows/activities/github" "github.com/runatlantis/atlantis/server/neptune/workflows/internal/pr" @@ -9,8 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.temporal.io/sdk/testsuite" "go.temporal.io/sdk/workflow" - "testing" - "time" ) type request struct { diff --git a/server/neptune/workflows/internal/pr/workflow.go b/server/neptune/workflows/internal/pr/workflow.go index 06e7c4712..8054874fd 100644 --- a/server/neptune/workflows/internal/pr/workflow.go +++ b/server/neptune/workflows/internal/pr/workflow.go @@ -1,12 +1,13 @@ package pr import ( + "strconv" + "time" + "github.com/runatlantis/atlantis/server/neptune/workflows/activities" workflowMetrics "github.com/runatlantis/atlantis/server/neptune/workflows/internal/metrics" "github.com/runatlantis/atlantis/server/neptune/workflows/internal/pr/revision" "go.temporal.io/sdk/workflow" - "strconv" - "time" ) const TaskQueue = "pr" diff --git a/server/neptune/workflows/internal/temporal/selector.go b/server/neptune/workflows/internal/temporal/selector.go index fb7eda644..174cabdd4 100644 --- a/server/neptune/workflows/internal/temporal/selector.go +++ b/server/neptune/workflows/internal/temporal/selector.go @@ -1,8 +1,9 @@ package temporal import ( - "go.temporal.io/sdk/workflow" "time" + + "go.temporal.io/sdk/workflow" ) // SelectorWithTimeout makes it a bit easier to add Timeout futures diff --git a/server/neptune/workflows/internal/terraform/job/runner_test.go b/server/neptune/workflows/internal/terraform/job/runner_test.go index 7c4e4f378..36239d8fb 100644 --- a/server/neptune/workflows/internal/terraform/job/runner_test.go +++ b/server/neptune/workflows/internal/terraform/job/runner_test.go @@ -2,10 +2,11 @@ package job_test import ( "context" - "github.com/runatlantis/atlantis/server/neptune/workflows/activities/command" "testing" "time" + "github.com/runatlantis/atlantis/server/neptune/workflows/activities/command" + "github.com/runatlantis/atlantis/server/neptune/workflows/activities" "github.com/runatlantis/atlantis/server/neptune/workflows/activities/execute" "github.com/runatlantis/atlantis/server/neptune/workflows/activities/github" diff --git a/server/neptune/workflows/internal/terraform/state/store.go b/server/neptune/workflows/internal/terraform/state/store.go index 049d45fda..45488d5b5 100644 --- a/server/neptune/workflows/internal/terraform/state/store.go +++ b/server/neptune/workflows/internal/terraform/state/store.go @@ -2,10 +2,11 @@ package state import ( "fmt" - "github.com/runatlantis/atlantis/server/neptune/workflows/activities/conftest" "net/url" "time" + "github.com/runatlantis/atlantis/server/neptune/workflows/activities/conftest" + "github.com/gorilla/mux" "github.com/pkg/errors" "github.com/runatlantis/atlantis/server/neptune/workflows/activities/terraform" diff --git a/server/neptune/workflows/internal/terraform/state/workflow.go b/server/neptune/workflows/internal/terraform/state/workflow.go index 43056f898..96a1cc9ab 100644 --- a/server/neptune/workflows/internal/terraform/state/workflow.go +++ b/server/neptune/workflows/internal/terraform/state/workflow.go @@ -1,10 +1,11 @@ package state import ( - "github.com/runatlantis/atlantis/server/neptune/workflows/activities/conftest" "net/url" "time" + "github.com/runatlantis/atlantis/server/neptune/workflows/activities/conftest" + "github.com/runatlantis/atlantis/server/neptune/workflows/activities/github" "github.com/runatlantis/atlantis/server/neptune/workflows/activities/terraform" "github.com/runatlantis/atlantis/server/neptune/workflows/plugins" diff --git a/server/vcs/provider/github/git_cred_writer_test.go b/server/vcs/provider/github/git_cred_writer_test.go index c7f6bdc52..edc1ef57e 100644 --- a/server/vcs/provider/github/git_cred_writer_test.go +++ b/server/vcs/provider/github/git_cred_writer_test.go @@ -2,12 +2,13 @@ package github_test import ( "fmt" - "github.com/runatlantis/atlantis/server/vcs/provider/github" "os" "os/exec" "path/filepath" "testing" + "github.com/runatlantis/atlantis/server/vcs/provider/github" + "github.com/runatlantis/atlantis/server/logging" . "github.com/runatlantis/atlantis/testing" ) diff --git a/server/vcs/provider/github/list_iterator.go b/server/vcs/provider/github/list_iterator.go index f5db50700..94c564c7d 100644 --- a/server/vcs/provider/github/list_iterator.go +++ b/server/vcs/provider/github/list_iterator.go @@ -3,9 +3,10 @@ package github import ( "context" "fmt" + "net/http" + gh "github.com/google/go-github/v45/github" "github.com/pkg/errors" - "net/http" ) func Iterate[T interface{}]( diff --git a/server/vcs/provider/github/list_iterator_test.go b/server/vcs/provider/github/list_iterator_test.go index 57afa2c65..003b59874 100644 --- a/server/vcs/provider/github/list_iterator_test.go +++ b/server/vcs/provider/github/list_iterator_test.go @@ -2,11 +2,12 @@ package github_test import ( "context" + "net/http" + "testing" + gh "github.com/google/go-github/v45/github" "github.com/runatlantis/atlantis/server/vcs/provider/github" "github.com/stretchr/testify/assert" - "net/http" - "testing" ) const ( diff --git a/server/vcs/provider/github/pr_fetcher.go b/server/vcs/provider/github/pr_fetcher.go index 8f5cf907a..3782411c0 100644 --- a/server/vcs/provider/github/pr_fetcher.go +++ b/server/vcs/provider/github/pr_fetcher.go @@ -3,10 +3,11 @@ package github import ( "context" "fmt" + "net/http" + gh "github.com/google/go-github/v45/github" "github.com/palantir/go-githubapp/githubapp" "github.com/pkg/errors" - "net/http" ) type PRFetcher struct { diff --git a/server/vcs/provider/github/request/handler_test.go b/server/vcs/provider/github/request/handler_test.go index bab9f3e81..50e488e5f 100644 --- a/server/vcs/provider/github/request/handler_test.go +++ b/server/vcs/provider/github/request/handler_test.go @@ -9,7 +9,6 @@ import ( "github.com/google/go-github/v45/github" "github.com/runatlantis/atlantis/server/legacy/controllers/events/errors" - buffered "github.com/runatlantis/atlantis/server/legacy/http" httputils "github.com/runatlantis/atlantis/server/legacy/http" "github.com/runatlantis/atlantis/server/logging" "github.com/runatlantis/atlantis/server/metrics" @@ -125,7 +124,7 @@ type assertingPullRequestReviewHandler struct { expectedInput event.PullRequestReview } -func (h assertingPullRequestReviewHandler) Handle(_ context.Context, input event.PullRequestReview, _ *buffered.BufferedRequest) error { +func (h assertingPullRequestReviewHandler) Handle(_ context.Context, input event.PullRequestReview, _ *httputils.BufferedRequest) error { assert.Equal(h.t, h.expectedInput, input) return nil } diff --git a/server/vcs/provider/github/team_fetcher.go b/server/vcs/provider/github/team_fetcher.go index 05a471523..0c5e5a339 100644 --- a/server/vcs/provider/github/team_fetcher.go +++ b/server/vcs/provider/github/team_fetcher.go @@ -2,6 +2,7 @@ package github import ( "context" + gh "github.com/google/go-github/v45/github" "github.com/palantir/go-githubapp/githubapp" "github.com/pkg/errors" From 678211b4fd73f468ba21b1ac4a5ccf82f801a87d Mon Sep 17 00:00:00 2001 From: Hans Wernetti Date: Wed, 24 Sep 2025 13:59:02 -0700 Subject: [PATCH 07/11] use latest action --- .github/workflows/lint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ae274d826..c94c4a065 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,7 +14,7 @@ jobs: go-version: 1.25 - uses: actions/checkout@v3 - name: Run golangci-lint - uses: golangci/golangci-lint-action@v3.2.0 + uses: golangci/golangci-lint-action@v8.0.0 with: - args: --timeout 3m --verbose --disable revive + args: --timeout 3m --verbose version: v2.4.0 From 2103d5f8955ebc6ed443fff046239e9723d3653c Mon Sep 17 00:00:00 2001 From: Hans Wernetti Date: Wed, 24 Sep 2025 13:59:53 -0700 Subject: [PATCH 08/11] rm claude settings --- .claude/settings.local.json | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 .claude/settings.local.json diff --git a/.claude/settings.local.json b/.claude/settings.local.json deleted file mode 100644 index 9847bcf66..000000000 --- a/.claude/settings.local.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "permissions": { - "allow": [ - "Bash(make lint)", - "Bash(make fmt:*)" - ], - "deny": [], - "ask": [] - } -} \ No newline at end of file From 964a3260dca3fcae0b5576065828d9c4aea3ebef Mon Sep 17 00:00:00 2001 From: Hans Wernetti Date: Wed, 24 Sep 2025 14:06:04 -0700 Subject: [PATCH 09/11] exclude standard staticcheck rules --- .golangci.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index f35694eb9..b5cbc300a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -13,6 +13,20 @@ linters: settings: interfacebloat: max: 7 + staticcheck: + checks: + - all + - -QF1001 + - -QF1007 + - -QF1008 + - -QF1011 + - -ST1000 + - -ST1003 + - -ST1016 + - -ST1020 + - -ST1021 + - -ST1022 + - -ST1023 exclusions: generated: lax presets: From f419d1702d33ebdcb557f1c98f8592b3469e3c21 Mon Sep 17 00:00:00 2001 From: Hans Wernetti Date: Wed, 24 Sep 2025 14:09:21 -0700 Subject: [PATCH 10/11] undo some changes --- .../events/size_limited_project_command_builder.go | 3 ++- server/legacy/events/working_dir_locker.go | 8 +++++--- server/neptune/gateway/config/root_config_builder.go | 8 ++++---- server/neptune/http/server_proxy.go | 2 +- server/neptune/lyft/activities/github.go | 2 +- server/neptune/template/loader.go | 2 +- server/neptune/temporal/client.go | 12 ++++++------ server/neptune/temporalworker/job/store.go | 2 +- .../workflows/internal/terraform/job/runner.go | 2 +- 9 files changed, 22 insertions(+), 19 deletions(-) diff --git a/server/legacy/events/size_limited_project_command_builder.go b/server/legacy/events/size_limited_project_command_builder.go index aec558058..7e2f2f915 100644 --- a/server/legacy/events/size_limited_project_command_builder.go +++ b/server/legacy/events/size_limited_project_command_builder.go @@ -41,13 +41,14 @@ func (b *SizeLimitedProjectCommandBuilder) CheckAgainstLimit(projects []command. } if b.Limit != InfiniteProjectsPerPR && len(planCommands) > b.Limit { + // nolint:staticcheck return fmt.Errorf( "Number of projects cannot exceed %d. This can either be caused by:\n"+ "1) GH failure in recognizing the diff\n"+ "2) Pull Request batch is too large for the given Atlantis instance\n\n"+ "Please break this pull request into smaller batches and try again.", b.Limit, - ) // nolint:staticcheck + ) } return nil } diff --git a/server/legacy/events/working_dir_locker.go b/server/legacy/events/working_dir_locker.go index 71442d712..22ddf9ef4 100644 --- a/server/legacy/events/working_dir_locker.go +++ b/server/legacy/events/working_dir_locker.go @@ -63,9 +63,10 @@ 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+"/") { + // nolint:staticcheck 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.") // nolint:staticcheck + "Wait until the previous command is complete and try again.") } } d.locks = append(d.locks, pullKey) @@ -82,9 +83,10 @@ func (d *DefaultWorkingDirLocker) TryLock(repoFullName string, pullNum int, work workspaceKey := d.workspaceKey(repoFullName, pullNum, workspace) for _, l := range d.locks { if l == pullKey || l == workspaceKey { - return func() {}, fmt.Errorf("the %s workspace is currently locked by another"+ + // nolint:staticcheck + return func() {}, fmt.Errorf("The %s workspace 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) + "Wait until the previous command is complete and try again.", workspace) } } d.locks = append(d.locks, workspaceKey) diff --git a/server/neptune/gateway/config/root_config_builder.go b/server/neptune/gateway/config/root_config_builder.go index ac4805248..b63c1af91 100644 --- a/server/neptune/gateway/config/root_config_builder.go +++ b/server/neptune/gateway/config/root_config_builder.go @@ -49,12 +49,12 @@ type ModifiedRootsStrategy struct { func (s *ModifiedRootsStrategy) FindMatches(ctx context.Context, config valid.RepoCfg, repo *LocalRepo, installationToken int64) ([]valid.Project, error) { // Fetch files modified in commit - modifiedFiles, err := s.FileFetcher.GetModifiedFiles(ctx, repo.Repo, installationToken, github.FileFetcherOptions{ - PRNum: repo.OptionalPRNum, - Sha: repo.Sha, + modifiedFiles, err := s.FileFetcher.GetModifiedFiles(ctx, repo.RepoCommit.Repo, installationToken, github.FileFetcherOptions{ + PRNum: repo.RepoCommit.OptionalPRNum, + Sha: repo.RepoCommit.Sha, }) if err != nil { - debugStr := fmt.Sprintf("sha: %s, prNum: %d, dir %s", repo.Sha, repo.OptionalPRNum, repo.Dir) + debugStr := fmt.Sprintf("sha: %s, prNum: %d, dir %s", repo.RepoCommit.Sha, repo.RepoCommit.OptionalPRNum, repo.Dir) return nil, errors.Wrapf(err, "finding modified files: %s, debug str: %s", modifiedFiles, debugStr) } diff --git a/server/neptune/http/server_proxy.go b/server/neptune/http/server_proxy.go index fae9f7fbc..44d688a6d 100644 --- a/server/neptune/http/server_proxy.go +++ b/server/neptune/http/server_proxy.go @@ -15,7 +15,7 @@ type ServerProxy struct { func (p *ServerProxy) ListenAndServe() error { if p.SSLCertFile != "" && p.SSLKeyFile != "" { - return p.ListenAndServeTLS(p.SSLCertFile, p.SSLKeyFile) + return p.Server.ListenAndServeTLS(p.SSLCertFile, p.SSLKeyFile) } return p.Server.ListenAndServe() diff --git a/server/neptune/lyft/activities/github.go b/server/neptune/lyft/activities/github.go index 89daecef4..c9ee83ae7 100644 --- a/server/neptune/lyft/activities/github.go +++ b/server/neptune/lyft/activities/github.go @@ -139,7 +139,7 @@ func (a *Github) listPullRequests(ctx context.Context, installationToken int64, Sort: sortBy, Direction: order, } - prListOptions.Page = nextPage + prListOptions.ListOptions.Page = nextPage return client.PullRequests.List(ctx, owner, repo, &prListOptions) } diff --git a/server/neptune/template/loader.go b/server/neptune/template/loader.go index 7e3a2f145..ec286b091 100644 --- a/server/neptune/template/loader.go +++ b/server/neptune/template/loader.go @@ -94,7 +94,7 @@ func (l Loader[T]) Load(id Key, repo models.Repo, data T) (string, error) { buf := &bytes.Buffer{} if err := tmpl.Execute(buf, data); err != nil { - return "", fmt.Errorf("failed to render template: %v", err) + return "", fmt.Errorf("Failed to render template: %v", err) // nolint:staticcheck } return buf.String(), nil } diff --git a/server/neptune/temporal/client.go b/server/neptune/temporal/client.go index e6b2f9389..8fd8f4bca 100644 --- a/server/neptune/temporal/client.go +++ b/server/neptune/temporal/client.go @@ -137,7 +137,7 @@ func (i *clientMetricsOutboundInterceptor) ExecuteWorkflow(ctx context.Context, timer := s.Timer("latency").Start() defer timer.Stop() - run, err := i.Next.ExecuteWorkflow(ctx, in) + run, err := i.ClientOutboundInterceptorBase.Next.ExecuteWorkflow(ctx, in) if err != nil { s.Counter("error").Inc(1) @@ -155,7 +155,7 @@ func (i *clientMetricsOutboundInterceptor) SignalWorkflow(ctx context.Context, i timer := s.Timer("latency").Start() defer timer.Stop() - if err := i.Next.SignalWorkflow(ctx, in); err != nil { + if err := i.ClientOutboundInterceptorBase.Next.SignalWorkflow(ctx, in); err != nil { s.Counter("error").Inc(1) return err } @@ -171,7 +171,7 @@ func (i *clientMetricsOutboundInterceptor) SignalWithStartWorkflow(ctx context.C timer := s.Timer("latency").Start() defer timer.Stop() - run, err := i.Next.SignalWithStartWorkflow(ctx, in) + run, err := i.ClientOutboundInterceptorBase.Next.SignalWithStartWorkflow(ctx, in) if err != nil { s.Counter("error").Inc(1) @@ -189,7 +189,7 @@ func (i *clientMetricsOutboundInterceptor) CancelWorkflow(ctx context.Context, i timer := s.Timer("latency").Start() defer timer.Stop() - if err := i.Next.CancelWorkflow(ctx, in); err != nil { + if err := i.ClientOutboundInterceptorBase.Next.CancelWorkflow(ctx, in); err != nil { s.Counter("error").Inc(1) return err } @@ -205,7 +205,7 @@ func (i *clientMetricsOutboundInterceptor) TerminateWorkflow(ctx context.Context timer := s.Timer("latency").Start() defer timer.Stop() - if err := i.Next.TerminateWorkflow(ctx, in); err != nil { + if err := i.ClientOutboundInterceptorBase.Next.TerminateWorkflow(ctx, in); err != nil { s.Counter("error").Inc(1) return err } @@ -221,7 +221,7 @@ func (i *clientMetricsOutboundInterceptor) QueryWorkflow(ctx context.Context, in timer := s.Timer("latency").Start() defer timer.Stop() - val, err := i.Next.QueryWorkflow(ctx, in) + val, err := i.ClientOutboundInterceptorBase.Next.QueryWorkflow(ctx, in) if err != nil { s.Counter("error").Inc(1) diff --git a/server/neptune/temporalworker/job/store.go b/server/neptune/temporalworker/job/store.go index 991ff93a0..cfeb275b2 100644 --- a/server/neptune/temporalworker/job/store.go +++ b/server/neptune/temporalworker/job/store.go @@ -208,7 +208,7 @@ func (s *StorageBackendJobStore) Remove(jobID string) { // Persist all jobs in memory func (s *StorageBackendJobStore) Cleanup(ctx context.Context) error { failedJobs := []string{} - for jobID, job := range s.GetJobs() { + for jobID, job := range s.InMemoryStore.GetJobs() { _, err := s.storageBackend.Write(ctx, jobID, job.Output) // Track failed jobs, log errors and continue with other jobs diff --git a/server/neptune/workflows/internal/terraform/job/runner.go b/server/neptune/workflows/internal/terraform/job/runner.go index 954b881d3..c55686c72 100644 --- a/server/neptune/workflows/internal/terraform/job/runner.go +++ b/server/neptune/workflows/internal/terraform/job/runner.go @@ -289,7 +289,7 @@ func (r *JobRunner) closeTerraformJob(executionCtx *ExecutionContext) { // create a new disconnected ctx since we want this run even in the event of // cancellation ctx := executionCtx.Context - if temporal.IsCanceledError(executionCtx.Err()) { + if temporal.IsCanceledError(executionCtx.Context.Err()) { var cancel workflow.CancelFunc ctx, cancel = workflow.NewDisconnectedContext(executionCtx.Context) defer cancel() From 389631fcaf78b288917a38a26ba2cdcb890cd93d Mon Sep 17 00:00:00 2001 From: Hans Wernetti Date: Wed, 24 Sep 2025 14:16:14 -0700 Subject: [PATCH 11/11] undo more --- .../legacy/events/pre_workflow_hooks_command_runner_test.go | 6 +++--- server/neptune/workflows/activities/terraform/summary.go | 2 +- .../workflows/internal/deploy/revision/queue/updater.go | 2 +- .../neptune/workflows/internal/deploy/revision/revision.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/server/legacy/events/pre_workflow_hooks_command_runner_test.go b/server/legacy/events/pre_workflow_hooks_command_runner_test.go index 5bd8e1f23..9d5a20993 100644 --- a/server/legacy/events/pre_workflow_hooks_command_runner_test.go +++ b/server/legacy/events/pre_workflow_hooks_command_runner_test.go @@ -71,7 +71,7 @@ func TestRunPreHooks_Clone(t *testing.T) { t.Run("success hooks in cfg", func(t *testing.T) { preWorkflowHooksSetup(t) - var unlockCalled = Bool(false) + var unlockCalled *bool = Bool(false) unlockFn := func() { unlockCalled = Bool(true) } @@ -156,7 +156,7 @@ func TestRunPreHooks_Clone(t *testing.T) { t.Run("error cloning", func(t *testing.T) { preWorkflowHooksSetup(t) - var unlockCalled = Bool(false) + var unlockCalled *bool = Bool(false) unlockFn := func() { unlockCalled = Bool(true) } @@ -188,7 +188,7 @@ func TestRunPreHooks_Clone(t *testing.T) { t.Run("error running pre hook", func(t *testing.T) { preWorkflowHooksSetup(t) - var unlockCalled = Bool(false) + var unlockCalled *bool = Bool(false) unlockFn := func() { unlockCalled = Bool(true) } diff --git a/server/neptune/workflows/activities/terraform/summary.go b/server/neptune/workflows/activities/terraform/summary.go index 45006dca7..eab26df8d 100644 --- a/server/neptune/workflows/activities/terraform/summary.go +++ b/server/neptune/workflows/activities/terraform/summary.go @@ -4,7 +4,7 @@ import ( "encoding/json" "fmt" - tfjson "github.com/hashicorp/terraform-json" + "github.com/hashicorp/terraform-json" "github.com/pkg/errors" ) diff --git a/server/neptune/workflows/internal/deploy/revision/queue/updater.go b/server/neptune/workflows/internal/deploy/revision/queue/updater.go index d2b7d8f3b..dfd42bd30 100644 --- a/server/neptune/workflows/internal/deploy/revision/queue/updater.go +++ b/server/neptune/workflows/internal/deploy/revision/queue/updater.go @@ -26,7 +26,7 @@ func (u *LockStateUpdater) UpdateQueuedRevisions(ctx workflow.Context, queue *De var actions []github.CheckRunAction var summary string - var revisionsSummary = queue.GetQueuedRevisionsSummary() + var revisionsSummary string = queue.GetQueuedRevisionsSummary() state := github.CheckRunQueued if queueLock.Status == lock.LockedStatus { actions = append(actions, github.CreateUnlockAction()) diff --git a/server/neptune/workflows/internal/deploy/revision/revision.go b/server/neptune/workflows/internal/deploy/revision/revision.go index 17af5eb68..9d2b6a924 100644 --- a/server/neptune/workflows/internal/deploy/revision/revision.go +++ b/server/neptune/workflows/internal/deploy/revision/revision.go @@ -138,7 +138,7 @@ func (n *Receiver) Receive(c workflow.ReceiveChannel, more bool) { func (n *Receiver) createCheckRun(ctx workflow.Context, id, revision string, root activity.Root, repo github.Repo) int64 { queueLock := n.queue.GetLockState() var actions []github.CheckRunAction - var revisionsSummary = n.queue.GetQueuedRevisionsSummary() + var revisionsSummary string = n.queue.GetQueuedRevisionsSummary() summary := "This deploy is queued and will be processed as soon as possible.\n" + revisionsSummary state := github.CheckRunQueued