Skip to content

Commit 163e04a

Browse files
authored
chore: Running go fix ./... (#6758)
* chore: Running `go fix ./...` * chore: Addressing lint failures
1 parent 36409fa commit 163e04a

38 files changed

Lines changed: 160 additions & 181 deletions

internal/cli/commands/catalog/tui/keys.go

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -178,30 +178,28 @@ func (keys PagerKeyMap) FullHelp() [][]key.Binding {
178178
// NewPagerKeyMap returns a set of keybindings for the pager view.
179179
func NewPagerKeyMap() PagerKeyMap {
180180
return PagerKeyMap{
181-
KeyMap: viewport.KeyMap{
182-
HalfPageUp: key.NewBinding(
183-
key.WithDisabled(),
184-
),
185-
HalfPageDown: key.NewBinding(
186-
key.WithDisabled(),
187-
),
188-
Up: key.NewBinding(
189-
key.WithKeys("k", "up", "ctrl+p"),
190-
key.WithHelp("k/↑", "move up"),
191-
),
192-
Down: key.NewBinding(
193-
key.WithKeys("j", "down", "ctrl+n"),
194-
key.WithHelp("j/↓", "move down"),
195-
),
196-
PageDown: key.NewBinding(
197-
key.WithKeys("l", "right", "pgdown", "ctrl+v"),
198-
key.WithHelp("l/→", "page down"),
199-
),
200-
PageUp: key.NewBinding(
201-
key.WithKeys("h", "left", "pgup", "alt+v"),
202-
key.WithHelp("h/←", "page up"),
203-
),
204-
},
181+
HalfPageUp: key.NewBinding(
182+
key.WithDisabled(),
183+
),
184+
HalfPageDown: key.NewBinding(
185+
key.WithDisabled(),
186+
),
187+
Up: key.NewBinding(
188+
key.WithKeys("k", "up", "ctrl+p"),
189+
key.WithHelp("k/↑", "move up"),
190+
),
191+
Down: key.NewBinding(
192+
key.WithKeys("j", "down", "ctrl+n"),
193+
key.WithHelp("j/↓", "move down"),
194+
),
195+
PageDown: key.NewBinding(
196+
key.WithKeys("l", "right", "pgdown", "ctrl+v"),
197+
key.WithHelp("l/→", "page down"),
198+
),
199+
PageUp: key.NewBinding(
200+
key.WithKeys("h", "left", "pgup", "alt+v"),
201+
key.WithHelp("h/←", "page up"),
202+
),
205203
HelpModel: help.New(),
206204
Navigation: key.NewBinding(
207205
key.WithKeys("tab", "shift+tab"),

internal/cli/commands/catalog/tui/layout.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ func takeWidthSuffix(s string, maxW int) string {
114114

115115
w := 0
116116

117-
for i := len(rs) - 1; i >= 0; i-- {
118-
r := rs[i]
117+
for _, r := range slices.Backward(rs) {
119118
rw := lipgloss.Width(string(r))
120119

121120
if w+rw > maxW {

internal/cli/commands/stack/stack.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"path/filepath"
7+
"slices"
78

89
"github.com/gruntwork-io/terragrunt/internal/configbridge"
910
"github.com/gruntwork-io/terragrunt/internal/telemetry"
@@ -213,8 +214,8 @@ func FilterOutputs(outputs cty.Value, index string) (cty.Value, error) {
213214
current = next
214215
}
215216

216-
for i := len(segments) - 1; i >= 0; i-- {
217-
current = cty.ObjectVal(map[string]cty.Value{segments[i]: current})
217+
for _, segment := range slices.Backward(segments) {
218+
current = cty.ObjectVal(map[string]cty.Value{segment: current})
218219
}
219220

220221
return current, nil

internal/clihelper/command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ func (cmd *Command) flagSetParse(
278278

279279
for i, arg := range args {
280280
// `--var=input=from_env` trims to `var`
281-
trimmed := strings.SplitN(strings.Trim(arg, "-"), "=", 2)[0] //nolint:mnd
281+
trimmed, _, _ := strings.Cut(strings.Trim(arg, "-"), "=")
282282
if trimmed == undefArg {
283283
undefArgs = append(undefArgs, arg)
284284
notFoundMatch = true

internal/discovery/phase_parse.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,7 @@ func parseComponent(
416416
)
417417
if err != nil {
418418
if discovery.suppressParseErrors {
419-
var notFoundErr config.TerragruntConfigNotFoundError
420-
if errors.As(err, &notFoundErr) {
419+
if _, ok := errors.AsType[config.TerragruntConfigNotFoundError](err); ok {
421420
l.Debugf(
422421
"Skipping missing config during discovery: %s",
423422
parseOpts.TerragruntConfigPath,

internal/engine/engine.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -897,12 +897,10 @@ func createEngine(
897897
}
898898

899899
client := plugin.NewClient(&plugin.ClientConfig{
900-
Logger: logger,
901-
HandshakeConfig: plugin.HandshakeConfig{
902-
ProtocolVersion: engineVersion,
903-
MagicCookieKey: engineCookieKey,
904-
MagicCookieValue: engineCookieValue,
905-
},
900+
Logger: logger,
901+
ProtocolVersion: engineVersion,
902+
MagicCookieKey: engineCookieKey,
903+
MagicCookieValue: engineCookieValue,
906904
Plugins: map[string]plugin.Plugin{
907905
"plugin": &engine.TerragruntGRPCEngine{},
908906
},

internal/errorconfig/types.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ func ExtractErrorMessage(err error) string {
132132

133133
// For ProcessExecutionError, match only against stderr and the underlying error,
134134
// not the full command string with flags.
135-
var processErr util.ProcessExecutionError
136-
if errors.As(err, &processErr) {
135+
if processErr, ok := errors.AsType[util.ProcessExecutionError](err); ok {
137136
errText = processErr.Output.Stderr.String() + "\n" + processErr.Err.Error()
138137
} else {
139138
errText = err.Error()

internal/filter/filters.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ func ParseFilterQueries(l log.Logger, filterStrings []string) (Filters, error) {
4444
for i, filterString := range filterStrings {
4545
filter, err := Parse(filterString)
4646
if err != nil {
47-
var parseErr ParseError
48-
if errors.As(err, &parseErr) {
47+
if parseErr, ok := errors.AsType[ParseError](err); ok {
4948
diagnostics = append(diagnostics, FormatDiagnostic(&parseErr, i, useColor))
5049

5150
continue

internal/getter/oci.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,8 +775,7 @@ func (g *OCIGetter) extractModuleWithLimits(
775775

776776
err = g.promoteModule(staging, sourcePath, dstPath)
777777

778-
var restoreErr OCIRestoreError
779-
if errors.As(err, &restoreErr) {
778+
if _, ok := errors.AsType[OCIRestoreError](err); ok {
780779
keepStaging = true
781780
}
782781

internal/getter/oci_auth_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/json"
77
"errors"
88
"io"
9+
"maps"
910
"path/filepath"
1011
"strings"
1112
"sync/atomic"
@@ -1213,9 +1214,7 @@ func credentialVenv(home string, extra map[string]string) *venv.Venv {
12131214
// credentialVenvForGOOS builds a hermetic in-memory Venv for goos.
12141215
func credentialVenvForGOOS(goos, home string, extra map[string]string) *venv.Venv {
12151216
env := map[string]string{}
1216-
for name, value := range extra {
1217-
env[name] = value
1218-
}
1217+
maps.Copy(env, extra)
12191218

12201219
return venvtest.New().
12211220
WithGOOS(goos).

0 commit comments

Comments
 (0)