Skip to content

Commit

Permalink
DEVCON-7212: Upgrade atlantis to Go 1.23 (#770)
Browse files Browse the repository at this point in the history
Time to upgrade to Go 1.23 

I had to update a few function calls with new lint checks for go vet,
similar to how it was done in
runatlantis/atlantis@37580ba

Also had to ignore `gosec` linter in a few instances because it wanted
us to use `0600` instead and that made all the tests fail and when we
inspected with an IDE it showed the dirs not available with those
  • Loading branch information
miguelmolina95 authored Sep 10, 2024
1 parent 85c9409 commit 5368355
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.22
go-version: 1.23
- uses: actions/checkout@v3
- name: Run golangci-lint
uses: golangci/[email protected]
with:
args: --timeout 3m --verbose --disable revive
version: v1.56.2
version: v1.60.1
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ jobs:
&& sudo cp conftest /usr/local/bin/conftest
- uses: actions/setup-go@v3
with:
go-version: 1.22
go-version: 1.23
- uses: actions/checkout@v3
- run: make test-all
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/runatlantis/atlantis

go 1.22
go 1.23

replace google.golang.org/grpc => google.golang.org/grpc v1.45.0

Expand Down
4 changes: 2 additions & 2 deletions server/legacy/controllers/jobs_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (j *JobsController) getProjectJobs(w http.ResponseWriter, r *http.Request)
jobID, err := j.KeyGenerator.Generate(r)

if err != nil {
j.respond(w, http.StatusBadRequest, err.Error())
j.respond(w, http.StatusBadRequest, "%s", err.Error())
return err
}

Expand Down Expand Up @@ -71,7 +71,7 @@ func (j *JobsController) getProjectJobsWS(w http.ResponseWriter, r *http.Request
err := j.WsMux.Handle(w, r)

if err != nil {
j.respond(w, http.StatusBadRequest, err.Error())
j.respond(w, http.StatusBadRequest, "%s", err.Error())
return err
}

Expand Down
2 changes: 1 addition & 1 deletion server/legacy/core/runtime/show_step_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (p *ShowStepRunner) Run(ctx context.Context, prjCtx command.ProjectContext,
return output, errors.Wrap(err, "running terraform show")
}

if err := os.WriteFile(showResultFile, []byte(output), os.ModePerm); err != nil {
if err := os.WriteFile(showResultFile, []byte(output), os.ModePerm); err != nil { //nolint:gosec
return "", errors.Wrap(err, "writing terraform show result")
}

Expand Down
12 changes: 6 additions & 6 deletions server/legacy/events/working_dir_iterator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestListCurrentWorkingDirPulls(t *testing.T) {
t.Run("pull not found", func(t *testing.T) {
baseDir := t.TempDir()

_ = os.MkdirAll(filepath.Join(baseDir, "repos", "nish", "repo1", "1", "default"), os.ModePerm)
_ = os.MkdirAll(filepath.Join(baseDir, "repos", "nish", "repo1", "1", "default"), os.ModePerm) //nolint:gosec

pullNotFound := &vcs.PullRequestNotFound{Err: errors.New("error")}

Expand Down Expand Up @@ -72,7 +72,7 @@ func TestListCurrentWorkingDirPulls(t *testing.T) {

baseDir := t.TempDir()

_ = os.MkdirAll(filepath.Join(baseDir, "repos", "nish", "repo1", "1", "default"), os.ModePerm)
_ = os.MkdirAll(filepath.Join(baseDir, "repos", "nish", "repo1", "1", "default"), os.ModePerm) //nolint:gosec

pegomock.When(mockGHClient.GetPullRequestFromName("repo1", "nish", 1)).ThenReturn(expectedGithubPull, nil)
pegomock.When(mockEventParser.ParseGithubPull(expectedGithubPull)).ThenReturn(expectedInternalPull, models.Repo{}, models.Repo{}, nil)
Expand Down Expand Up @@ -112,8 +112,8 @@ func TestListCurrentWorkingDirPulls(t *testing.T) {

baseDir := t.TempDir()

_ = os.MkdirAll(filepath.Join(baseDir, "repos", "nish", "repo1", "1", "default"), os.ModePerm)
_ = os.MkdirAll(filepath.Join(baseDir, "repos", "nish", "repo1", "2", "default"), os.ModePerm)
_ = os.MkdirAll(filepath.Join(baseDir, "repos", "nish", "repo1", "1", "default"), os.ModePerm) //nolint:gosec
_ = os.MkdirAll(filepath.Join(baseDir, "repos", "nish", "repo1", "2", "default"), os.ModePerm) //nolint:gosec

pegomock.When(mockGHClient.GetPullRequestFromName("repo1", "nish", pullNum1)).ThenReturn(expectedGithubPull1, nil)
pegomock.When(mockGHClient.GetPullRequestFromName("repo1", "nish", pullNum2)).ThenReturn(expectedGithubPull2, nil)
Expand Down Expand Up @@ -156,8 +156,8 @@ func TestListCurrentWorkingDirPulls(t *testing.T) {

baseDir := t.TempDir()

_ = os.MkdirAll(filepath.Join(baseDir, "repos", "nish", "repo1", "1", "default"), os.ModePerm)
_ = os.MkdirAll(filepath.Join(baseDir, "repos", "nish", "repo2", "2", "default"), os.ModePerm)
_ = os.MkdirAll(filepath.Join(baseDir, "repos", "nish", "repo1", "1", "default"), os.ModePerm) //nolint:gosec
_ = os.MkdirAll(filepath.Join(baseDir, "repos", "nish", "repo2", "2", "default"), os.ModePerm) //nolint:gosec

pegomock.When(mockGHClient.GetPullRequestFromName("repo1", "nish", pullNum1)).ThenReturn(expectedGithubPull1, nil)
pegomock.When(mockGHClient.GetPullRequestFromName("repo2", "nish", pullNum2)).ThenReturn(expectedGithubPull2, nil)
Expand Down
4 changes: 2 additions & 2 deletions server/neptune/temporalworker/controllers/job_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func NewJobsController(
func (j *JobsController) getProjectJobs(w http.ResponseWriter, r *http.Request) error {
jobID, err := j.KeyGenerator.Generate(r)
if err != nil {
j.respond(w, http.StatusBadRequest, err.Error())
j.respond(w, http.StatusBadRequest, "%s", err.Error())
return err
}

Expand Down Expand Up @@ -106,7 +106,7 @@ func (j *JobsController) GetProjectJobs(w http.ResponseWriter, r *http.Request)
func (j *JobsController) getProjectJobsWS(w http.ResponseWriter, r *http.Request) error {
err := j.WsMux.Handle(w, r)
if err != nil {
j.respond(w, http.StatusBadRequest, err.Error())
j.respond(w, http.StatusBadRequest, "%s", err.Error())
return err
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion server/neptune/workflows/activities/file/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import "os"
type Writer struct{}

func (f *Writer) Write(name string, data []byte) error {
return os.WriteFile(name, data, os.ModePerm)
return os.WriteFile(name, data, os.ModePerm) //nolint:gosec
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (c *Credentials) safeReadFile(file string) (string, error) {
}

func (c *Credentials) writeConfig(file string, contents []byte) error {
if err := c.safeWriteFile(file, contents, os.ModePerm); err != nil {
if err := c.safeWriteFile(file, contents, os.ModePerm); err != nil { //nolint:gosec
return err
}
if err := c.Git("config", "--global", "credential.helper", "store"); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func TestRefresh(t *testing.T) {
credentialsFile := filepath.Join(dir, ".git-credentials")
oldContents := "https://x-access-token:[email protected]"

err := os.WriteFile(credentialsFile, []byte(oldContents), os.ModePerm)
err := os.WriteFile(credentialsFile, []byte(oldContents), os.ModePerm) //nolint:gosec
assert.NoError(t, err)

capturedGitArgs := [][]string{}
Expand Down Expand Up @@ -159,7 +159,7 @@ func TestRefresh(t *testing.T) {
credentialsFile := filepath.Join(dir, ".git-credentials")
oldContents := "https://x-access-token:[email protected]"

err := os.WriteFile(credentialsFile, []byte(oldContents), os.ModePerm)
err := os.WriteFile(credentialsFile, []byte(oldContents), os.ModePerm) //nolint:gosec
assert.NoError(t, err)

tc := &testInstallationTransport{
Expand Down
6 changes: 3 additions & 3 deletions server/neptune/workflows/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func buildConfig(t *testing.T) config.Config {
dataDir := t.TempDir()

// storage client uses this for it's local backend.
err = os.Mkdir(filepath.Join(dataDir, "container"), os.ModePerm)
err = os.Mkdir(filepath.Join(dataDir, "container"), os.ModePerm) //nolint:gosec
assert.NoError(t, err)
conftestVersion, err := version.NewVersion("0.25.0")
assert.NoError(t, err)
Expand Down Expand Up @@ -238,13 +238,13 @@ var fileContents = ` resource "null_resource" "null" {}
func GetLocalTestRoot(ctx context.Context, dst, src string) error {
// dst will be the repo path here but we also need to create the root itself
dst = filepath.Join(dst, "terraform", "mytestroot")
err := os.MkdirAll(dst, os.ModePerm)
err := os.MkdirAll(dst, os.ModePerm) //nolint:gosec

if err != nil {
return errors.Wrapf(err, "creating directory at %s", dst)
}

if err := os.WriteFile(filepath.Join(dst, "main.tf"), []byte(fileContents), os.ModePerm); err != nil {
if err := os.WriteFile(filepath.Join(dst, "main.tf"), []byte(fileContents), os.ModePerm); err != nil { //nolint:gosec
return errors.Wrapf(err, "writing file")
}

Expand Down

0 comments on commit 5368355

Please sign in to comment.