Skip to content

Commit 7e9331e

Browse files
authored
chore: Update Go to 1.26.0 and golangci-lint to v2.10.0 (#114)
Co-authored-by: Leo Antoli <lantoli@users.noreply.github.com>
1 parent 19d59f6 commit 7e9331e

7 files changed

Lines changed: 38 additions & 19 deletions

File tree

.github/workflows/code-health.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
- name: golangci-lint
4949
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20
5050
with:
51-
version: v2.8.0 # Also update GOLANGCI_VERSION variable in Makefile when updating this version
51+
version: v2.10.0 # Also update GOLANGCI_VERSION variable in Makefile when updating this version
5252
- name: actionlint
5353
run: |
5454
make tools
@@ -57,3 +57,25 @@ jobs:
5757
shell: bash
5858
- name: shellcheck
5959
uses: bewuethr/shellcheck-action@80bac2daa9fcf95d648200a793d00060857e6dc4
60+
61+
check-go-files:
62+
runs-on: ubuntu-latest
63+
permissions: {}
64+
steps:
65+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
66+
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5
67+
with:
68+
go-version-file: 'go.mod'
69+
- run: go mod tidy
70+
- run: go fix ./...
71+
- name: Find mutations
72+
id: self_mutation
73+
run: |-
74+
git add .
75+
git diff --staged --patch --exit-code > doc.repo.patch || echo "self_mutation_happened=true" >> "${GITHUB_OUTPUT}"
76+
- name: Fail build on mutation
77+
if: steps.self_mutation.outputs.self_mutation_happened
78+
run: |-
79+
echo "::error::Files were changed. Make sure to run 'go mod tidy' and 'go fix ./...'"
80+
cat doc.repo.patch
81+
exit 1

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CLI_DESTINATION=./bin/$(CLI_BINARY_NAME)
44
MANIFEST_FILE?=./bin/manifest.yml
55
WIN_MANIFEST_FILE?=./bin/manifest.windows.yml
66

7-
GOLANGCI_VERSION=v2.8.0 # Also update golangci-lint GH action in code-health.yml when updating this version
7+
GOLANGCI_VERSION=v2.10.0 # Also update golangci-lint GH action in code-health.yml when updating this version
88

99
.PHONY: build
1010
build: ## Generate the binary in ./bin

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/mongodb-labs/atlas-cli-plugin-terraform
22

3-
go 1.25.7
3+
go 1.26.0
44

55
require (
66
github.com/fsnotify/fsnotify v1.9.0

internal/cli/clu2adv/clu2adv.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package clu2adv
33
import (
44
"github.com/mongodb-labs/atlas-cli-plugin-terraform/internal/cli"
55
"github.com/mongodb-labs/atlas-cli-plugin-terraform/internal/convert"
6-
"github.com/mongodb-labs/atlas-cli-plugin-terraform/internal/flag"
6+
"github.com/mongodb-labs/atlas-cli-plugin-terraform/internal/flags"
77
"github.com/spf13/afero"
88
"github.com/spf13/cobra"
99
)
@@ -29,7 +29,7 @@ func Builder() *cobra.Command {
2929
RunE: o.RunE,
3030
}
3131
cli.SetupCommonFlags(cmd, &o.BaseOpts)
32-
cmd.Flags().BoolVarP(&o.includeMoved, flag.IncludeMoved, flag.IncludeMovedShort, false,
32+
cmd.Flags().BoolVarP(&o.includeMoved, flags.IncludeMoved, flags.IncludeMovedShort, false,
3333
"include moved blocks in the output file")
3434
return cmd
3535
}

internal/cli/common.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66

77
"github.com/fsnotify/fsnotify"
88
"github.com/mongodb-labs/atlas-cli-plugin-terraform/internal/file"
9-
"github.com/mongodb-labs/atlas-cli-plugin-terraform/internal/flag"
9+
"github.com/mongodb-labs/atlas-cli-plugin-terraform/internal/flags"
1010
"github.com/spf13/afero"
1111
"github.com/spf13/cobra"
1212
)
@@ -119,12 +119,12 @@ func (o *BaseOpts) waitForFileEvent(watcher *fsnotify.Watcher) error {
119119

120120
// SetupCommonFlags sets up the common flags used by all commands.
121121
func SetupCommonFlags(cmd *cobra.Command, opts *BaseOpts) {
122-
cmd.Flags().StringVarP(&opts.File, flag.File, flag.FileShort, "", "input file")
123-
_ = cmd.MarkFlagRequired(flag.File)
124-
cmd.Flags().StringVarP(&opts.Output, flag.Output, flag.OutputShort, "", "output file")
125-
_ = cmd.MarkFlagRequired(flag.Output)
126-
cmd.Flags().BoolVarP(&opts.ReplaceOutput, flag.ReplaceOutput, flag.ReplaceOutputShort, false,
122+
cmd.Flags().StringVarP(&opts.File, flags.File, flags.FileShort, "", "input file")
123+
_ = cmd.MarkFlagRequired(flags.File)
124+
cmd.Flags().StringVarP(&opts.Output, flags.Output, flags.OutputShort, "", "output file")
125+
_ = cmd.MarkFlagRequired(flags.Output)
126+
cmd.Flags().BoolVarP(&opts.ReplaceOutput, flags.ReplaceOutput, flags.ReplaceOutputShort, false,
127127
"replace output file if exists")
128-
cmd.Flags().BoolVarP(&opts.Watch, flag.Watch, flag.WatchShort, false,
128+
cmd.Flags().BoolVarP(&opts.Watch, flags.Watch, flags.WatchShort, false,
129129
"keeps the plugin running and watches the input file for changes")
130130
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package flag
1+
package flags
22

33
const (
44
File = "file"

test/e2e/e2e_helper.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package e2e
22

33
import (
44
"context"
5+
"maps"
56
"os"
67
"os/exec"
78
"strconv"
@@ -112,12 +113,8 @@ func RunTests(t *testing.T, cmdName string, extraTests map[string]TestCase) {
112113
}
113114

114115
allTests := make(map[string]TestCase)
115-
for name, test := range commonTests {
116-
allTests[name] = test
117-
}
118-
for name, test := range extraTests {
119-
allTests[name] = test
120-
}
116+
maps.Copy(allTests, commonTests)
117+
maps.Copy(allTests, extraTests)
121118

122119
for name, tc := range allTests {
123120
t.Run(name, func(t *testing.T) {

0 commit comments

Comments
 (0)