Skip to content

Commit 1ae87f5

Browse files
committed
de-linting
1 parent 4192303 commit 1ae87f5

File tree

24 files changed

+24
-178
lines changed

24 files changed

+24
-178
lines changed

internal/addrs/resource.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,10 @@ func (r AbsResource) absMoveableSigil() {
194194
// AbsResource is moveable
195195
}
196196

197-
type absResourceKey string
198-
199197
func (r AbsResource) UniqueKey() UniqueKey {
200198
return absResourceInstanceKey(r.String())
201199
}
202200

203-
func (rk absResourceKey) uniqueKeySigil() {}
204-
205201
// AbsResourceInstance is an absolute address for a resource instance under a
206202
// given module path.
207203
type AbsResourceInstance struct {

internal/backend/remote/backend.go

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ func (b *Remote) VerifyWorkspaceTerraformVersion(workspaceName string) tfdiags.D
888888

889889
// If the workspace has remote operations disabled, the remote Terraform
890890
// version is effectively meaningless, so we'll skip version verification.
891-
if workspace.Operations == false {
891+
if !workspace.Operations {
892892
return nil
893893
}
894894

@@ -963,22 +963,6 @@ func (b *Remote) IsLocalOperations() bool {
963963
return b.forceLocal
964964
}
965965

966-
// Colorize returns the Colorize structure that can be used for colorizing
967-
// output. This is guaranteed to always return a non-nil value and so useful
968-
// as a helper to wrap any potentially colored strings.
969-
//
970-
// TODO SvH: Rename this back to Colorize as soon as we can pass -no-color.
971-
func (b *Remote) cliColorize() *colorstring.Colorize {
972-
if b.CLIColor != nil {
973-
return b.CLIColor
974-
}
975-
976-
return &colorstring.Colorize{
977-
Colors: colorstring.DefaultColors,
978-
Disable: true,
979-
}
980-
}
981-
982966
func generalError(msg string, err error) error {
983967
var diags tfdiags.Diagnostics
984968

internal/backend/remote/backend_apply_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,7 @@ func TestRemote_applyVersionCheck(t *testing.T) {
15941594
}
15951595

15961596
// RUN: prepare the apply operation and run it
1597-
op, configCleanup, done := testOperationApply(t, "./testdata/apply")
1597+
op, configCleanup, _ := testOperationApply(t, "./testdata/apply")
15981598
defer configCleanup()
15991599

16001600
streams, done := terminal.StreamsForTesting(t)

internal/command/apply.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ func (c *ApplyCommand) Run(rawArgs []string) int {
4545

4646
// Instantiate the view, even if there are flag errors, so that we render
4747
// diagnostics according to the desired view
48-
var view views.Apply
49-
view = views.NewApply(args.ViewType, c.Destroy, c.View)
48+
view := views.NewApply(args.ViewType, c.Destroy, c.View)
5049

5150
if diags.HasErrors() {
5251
view.Diagnostics(diags)

internal/command/apply_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,6 +1779,7 @@ func TestApply_terraformEnvNonDefault(t *testing.T) {
17791779
},
17801780
}
17811781
if code := newCmd.Run([]string{"test"}); code != 0 {
1782+
t.Fatal("error creating workspace")
17821783
}
17831784
}
17841785

@@ -1792,6 +1793,7 @@ func TestApply_terraformEnvNonDefault(t *testing.T) {
17921793
},
17931794
}
17941795
if code := selCmd.Run(args); code != 0 {
1796+
t.Fatal("error switching workspace")
17951797
}
17961798
}
17971799

internal/command/format/diff.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func ResourceChange(
7070
buf.WriteString(color.Color(fmt.Sprintf("[bold] # %s[reset] will be [bold][red]destroyed", dispAddr)))
7171
if change.DeposedKey != states.NotDeposed {
7272
// Some extra context about this unusual situation.
73-
buf.WriteString(color.Color(fmt.Sprint("\n # (left over from a partially-failed replacement of this instance)")))
73+
buf.WriteString(color.Color("\n # (left over from a partially-failed replacement of this instance)"))
7474
}
7575
default:
7676
// should never happen, since the above is exhaustive
@@ -755,8 +755,6 @@ func (p *blockBodyDiffPrinter) writeNestedAttrDiff(
755755
p.buf.WriteString(" -> (known after apply)")
756756
}
757757
}
758-
759-
return
760758
}
761759

762760
func (p *blockBodyDiffPrinter) writeNestedBlockDiffs(name string, blockS *configschema.NestedBlock, old, new cty.Value, blankBefore bool, indent int, path cty.Path) int {

internal/command/jsonplan/values.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -274,28 +274,3 @@ func marshalPlanModules(
274274

275275
return ret, nil
276276
}
277-
278-
// marshalSensitiveValues returns a map of sensitive attributes, with the value
279-
// set to true. It returns nil if the value is nil or if there are no sensitive
280-
// vals.
281-
func marshalSensitiveValues(value cty.Value) map[string]bool {
282-
if value.RawEquals(cty.NilVal) || value.IsNull() {
283-
return nil
284-
}
285-
286-
ret := make(map[string]bool)
287-
288-
it := value.ElementIterator()
289-
for it.Next() {
290-
k, v := it.Element()
291-
s := jsonstate.SensitiveAsBool(v)
292-
if !s.RawEquals(cty.False) {
293-
ret[k.AsString()] = true
294-
}
295-
}
296-
297-
if len(ret) == 0 {
298-
return nil
299-
}
300-
return ret
301-
}

internal/command/login.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,9 @@ func (c *LoginCommand) outputDefaultTFELoginSuccess(dispHostname string) {
311311
}
312312

313313
func (c *LoginCommand) outputDefaultTFCLoginSuccess() {
314-
c.Ui.Output(
315-
fmt.Sprintf(
316-
c.Colorize().Color(strings.TrimSpace(`
314+
c.Ui.Output(c.Colorize().Color(strings.TrimSpace(`
317315
[green][bold]Success![reset] [bold]Logged in to Terraform Cloud[reset]
318-
`)),
319-
) + "\n",
320-
)
316+
` + "\n")))
321317
}
322318

323319
func (c *LoginCommand) logMOTDError(err error) {

internal/command/meta.go

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import (
1515
"time"
1616

1717
plugin "github.com/hashicorp/go-plugin"
18-
"github.com/hashicorp/hcl/v2"
19-
"github.com/hashicorp/hcl/v2/hclsyntax"
2018
"github.com/hashicorp/terraform-svchost/disco"
2119
"github.com/hashicorp/terraform/internal/addrs"
2220
"github.com/hashicorp/terraform/internal/backend"
@@ -554,43 +552,6 @@ func (m *Meta) extendedFlagSet(n string) *flag.FlagSet {
554552
return f
555553
}
556554

557-
// parseTargetFlags must be called for any commands supporting -target
558-
// arguments. This method attempts to parse each -target flag into an
559-
// addrs.Target, storing in the Meta.targets slice.
560-
//
561-
// If any flags cannot be parsed, we rewrap the first error diagnostic with a
562-
// custom title to clarify the source of the error. The normal approach of
563-
// directly returning the diags from HCL or the addrs package results in
564-
// confusing incorrect "source" results when presented.
565-
func (m *Meta) parseTargetFlags() tfdiags.Diagnostics {
566-
var diags tfdiags.Diagnostics
567-
m.targets = nil
568-
for _, tf := range m.targetFlags {
569-
traversal, syntaxDiags := hclsyntax.ParseTraversalAbs([]byte(tf), "", hcl.Pos{Line: 1, Column: 1})
570-
if syntaxDiags.HasErrors() {
571-
diags = diags.Append(tfdiags.Sourceless(
572-
tfdiags.Error,
573-
fmt.Sprintf("Invalid target %q", tf),
574-
syntaxDiags[0].Detail,
575-
))
576-
continue
577-
}
578-
579-
target, targetDiags := addrs.ParseTarget(traversal)
580-
if targetDiags.HasErrors() {
581-
diags = diags.Append(tfdiags.Sourceless(
582-
tfdiags.Error,
583-
fmt.Sprintf("Invalid target %q", tf),
584-
targetDiags[0].Description().Detail,
585-
))
586-
continue
587-
}
588-
589-
m.targets = append(m.targets, target.Subject)
590-
}
591-
return diags
592-
}
593-
594555
// process will process any -no-color entries out of the arguments. This
595556
// will potentially modify the args in-place. It will return the resulting
596557
// slice, and update the Meta and Ui.

internal/command/meta_backend.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"strconv"
1313
"strings"
1414

15-
"github.com/hashicorp/errwrap"
1615
"github.com/hashicorp/hcl/v2"
1716
"github.com/hashicorp/hcl/v2/hcldec"
1817
"github.com/hashicorp/terraform/internal/backend"
@@ -244,7 +243,7 @@ func (m *Meta) BackendForPlan(settings plans.Backend) (backend.Enhanced, tfdiags
244243
schema := b.ConfigSchema()
245244
configVal, err := settings.Config.Decode(schema.ImpliedType())
246245
if err != nil {
247-
diags = diags.Append(errwrap.Wrapf("saved backend configuration is invalid: {{err}}", err))
246+
diags = diags.Append(fmt.Errorf("saved backend configuration is invalid: %w", err))
248247
return nil, diags
249248
}
250249

0 commit comments

Comments
 (0)