mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-19 17:59:05 -05:00
Implement the first part of RFC 20250303-linter-policy (#2577)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
This commit is contained in:
@@ -1,64 +0,0 @@
|
|||||||
# Copyright (c) The OpenTofu Authors
|
|
||||||
# SPDX-License-Identifier: MPL-2.0
|
|
||||||
# Copyright (c) 2023 HashiCorp, Inc.
|
|
||||||
# SPDX-License-Identifier: MPL-2.0
|
|
||||||
|
|
||||||
# This is a temporary variant of .golangci.yml to support our work on improving
|
|
||||||
# existing functions to pass the code complexity lint rules:
|
|
||||||
# https://github.com/opentofu/opentofu/issues/2325
|
|
||||||
#
|
|
||||||
# If you are working on the code complexity improvement project then you can
|
|
||||||
# check our progress on the complexity-related lints by running the linters
|
|
||||||
# as follows:
|
|
||||||
# golangci-lint run -c .golangci-complexity.yml
|
|
||||||
#
|
|
||||||
# Many existing functions were failing multiple linters at once at the start
|
|
||||||
# of this project, and for as long as that remains true it might be helpful
|
|
||||||
# to add the --uniq-by-line=false option to review all of the failures at
|
|
||||||
# once.
|
|
||||||
#
|
|
||||||
# This file should be deleted at the same time as we re-enable the five
|
|
||||||
# complexity-related linters in .golangci.yml.
|
|
||||||
|
|
||||||
run:
|
|
||||||
timeout: 30m
|
|
||||||
|
|
||||||
linters-settings:
|
|
||||||
funlen:
|
|
||||||
lines: 100
|
|
||||||
statements: 50
|
|
||||||
ignore-comments: true
|
|
||||||
|
|
||||||
nolintlint:
|
|
||||||
require-explanation: true
|
|
||||||
require-specific: true
|
|
||||||
|
|
||||||
cyclop:
|
|
||||||
max-complexity: 20
|
|
||||||
|
|
||||||
gocognit:
|
|
||||||
min-complexity: 50
|
|
||||||
|
|
||||||
nestif:
|
|
||||||
min-complexity: 6
|
|
||||||
|
|
||||||
issues:
|
|
||||||
exclude-rules:
|
|
||||||
- path: (.+)_test.go
|
|
||||||
linters:
|
|
||||||
- funlen
|
|
||||||
- dupl
|
|
||||||
- revive
|
|
||||||
- path: (.+)_test.go
|
|
||||||
text: "ST1003"
|
|
||||||
- path: (.+)_test.go
|
|
||||||
text: "var-naming: don't use underscores in Go names"
|
|
||||||
|
|
||||||
linters:
|
|
||||||
disable-all: true
|
|
||||||
enable:
|
|
||||||
- cyclop
|
|
||||||
- funlen
|
|
||||||
- gocognit
|
|
||||||
- gocyclo
|
|
||||||
- nestif
|
|
||||||
123
.golangci.yml
123
.golangci.yml
@@ -6,119 +6,12 @@
|
|||||||
run:
|
run:
|
||||||
timeout: 30m
|
timeout: 30m
|
||||||
|
|
||||||
linters-settings:
|
|
||||||
errcheck:
|
|
||||||
check-type-assertions: true
|
|
||||||
|
|
||||||
exhaustive:
|
|
||||||
check:
|
|
||||||
- switch
|
|
||||||
- map
|
|
||||||
|
|
||||||
funlen:
|
|
||||||
lines: 100
|
|
||||||
statements: 50
|
|
||||||
ignore-comments: true
|
|
||||||
|
|
||||||
govet:
|
|
||||||
enable-all: true
|
|
||||||
disable:
|
|
||||||
- fieldalignment # rule is too strict
|
|
||||||
|
|
||||||
nolintlint:
|
|
||||||
require-explanation: true
|
|
||||||
require-specific: true
|
|
||||||
|
|
||||||
cyclop:
|
|
||||||
max-complexity: 20
|
|
||||||
|
|
||||||
gocognit:
|
|
||||||
min-complexity: 50
|
|
||||||
|
|
||||||
goconst:
|
|
||||||
ignore-tests: true # Is documented to be the default behaviour, but that doesn't seem to be the case
|
|
||||||
|
|
||||||
gocritic:
|
|
||||||
settings:
|
|
||||||
ifElseChain:
|
|
||||||
minThreshold: 4
|
|
||||||
|
|
||||||
nestif:
|
|
||||||
min-complexity: 6
|
|
||||||
|
|
||||||
issues:
|
issues:
|
||||||
exclude-rules:
|
exclude-files:
|
||||||
- path: (.+)_test.go
|
# We have a few patterns that are excluded from linting completely because
|
||||||
linters:
|
# they contain effectively-frozen code that we're preserving for backward
|
||||||
- funlen
|
# compatibility, where changes would be risky and that risk isn't warranted
|
||||||
- dupl
|
# since we don't expect to be doing any significant maintenence on these.
|
||||||
- revive
|
- "^internal/ipaddr/"
|
||||||
- gocognit
|
- "^internal/legacy/"
|
||||||
- cyclop
|
- "^internal/states/statefile/version\\d+_upgrade\\.go$"
|
||||||
- path: (.+)_test.go
|
|
||||||
text: "ST1003"
|
|
||||||
- path: (.+)_test.go
|
|
||||||
text: "var-naming: don't use underscores in Go names"
|
|
||||||
|
|
||||||
linters:
|
|
||||||
disable-all: true
|
|
||||||
enable:
|
|
||||||
- asasalint
|
|
||||||
- asciicheck
|
|
||||||
- bidichk
|
|
||||||
- bodyclose
|
|
||||||
#- cyclop # (refer to .golangci-complexity.yml)
|
|
||||||
- dupl
|
|
||||||
- durationcheck
|
|
||||||
- errcheck
|
|
||||||
- errname
|
|
||||||
- errorlint
|
|
||||||
- exhaustive
|
|
||||||
- forbidigo
|
|
||||||
#- funlen # (refer to .golangci-complexity.yml)
|
|
||||||
- gocheckcompilerdirectives
|
|
||||||
- gochecknoglobals
|
|
||||||
- gochecknoinits
|
|
||||||
#- gocognit # (refer to .golangci-complexity.yml)
|
|
||||||
- goconst
|
|
||||||
- gocritic
|
|
||||||
#- gocyclo # (refer to .golangci-complexity.yml)
|
|
||||||
- goimports
|
|
||||||
#- gomoddirectives Disabled while we deal with the HCL fork
|
|
||||||
- gomodguard
|
|
||||||
- goprintffuncname
|
|
||||||
- gosec
|
|
||||||
- gosimple
|
|
||||||
- govet
|
|
||||||
- ineffassign
|
|
||||||
- loggercheck
|
|
||||||
- makezero
|
|
||||||
- mirror
|
|
||||||
- mnd
|
|
||||||
- musttag
|
|
||||||
- nakedret
|
|
||||||
#- nestif # (refer to .golangci-complexity.yml)
|
|
||||||
- nilerr
|
|
||||||
- nilnil
|
|
||||||
- noctx
|
|
||||||
- nolintlint
|
|
||||||
- nonamedreturns
|
|
||||||
- nosprintfhostport
|
|
||||||
- predeclared
|
|
||||||
- promlinter
|
|
||||||
- reassign
|
|
||||||
- revive
|
|
||||||
- rowserrcheck
|
|
||||||
- sqlclosecheck
|
|
||||||
- staticcheck
|
|
||||||
- stylecheck
|
|
||||||
- tenv
|
|
||||||
- testableexamples
|
|
||||||
- tparallel
|
|
||||||
- typecheck
|
|
||||||
- unconvert
|
|
||||||
- unparam
|
|
||||||
- unused
|
|
||||||
- usestdlibvars
|
|
||||||
- wastedassign
|
|
||||||
- whitespace
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
//nolint:cyclop // The complexity of this test naturally scales by the number of test conditions, and would be less readable/maintainable if broken into smaller parts.
|
|
||||||
func TestMap(t *testing.T) {
|
func TestMap(t *testing.T) {
|
||||||
variableName := InputVariable{Name: "name"}
|
variableName := InputVariable{Name: "name"}
|
||||||
localHello := LocalValue{Name: "hello"}
|
localHello := LocalValue{Name: "hello"}
|
||||||
|
|||||||
@@ -127,8 +127,6 @@ func ParseAbsProviderConfig(traversal hcl.Traversal) (AbsProviderConfig, tfdiags
|
|||||||
|
|
||||||
// ParseAbsProviderConfigInstance behaves identically to ParseAbsProviderConfig, but additionally
|
// ParseAbsProviderConfigInstance behaves identically to ParseAbsProviderConfig, but additionally
|
||||||
// allows an instance key after the alias.
|
// allows an instance key after the alias.
|
||||||
//
|
|
||||||
//nolint:mnd // traversals with specific indices
|
|
||||||
func ParseAbsProviderConfigInstance(traversal hcl.Traversal) (AbsProviderConfig, InstanceKey, tfdiags.Diagnostics) {
|
func ParseAbsProviderConfigInstance(traversal hcl.Traversal) (AbsProviderConfig, InstanceKey, tfdiags.Diagnostics) {
|
||||||
modInst, remain, diags := parseModuleInstancePrefix(traversal)
|
modInst, remain, diags := parseModuleInstancePrefix(traversal)
|
||||||
var ret AbsProviderConfig
|
var ret AbsProviderConfig
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ func TraversalStr(traversal hcl.Traversal) string {
|
|||||||
buf.WriteString(fmt.Sprintf("%q", tStep.Key.AsString()))
|
buf.WriteString(fmt.Sprintf("%q", tStep.Key.AsString()))
|
||||||
case cty.Number:
|
case cty.Number:
|
||||||
bf := tStep.Key.AsBigFloat()
|
bf := tStep.Key.AsBigFloat()
|
||||||
//nolint:mnd // numerical precision
|
|
||||||
buf.WriteString(bf.Text('g', 10))
|
buf.WriteString(bf.Text('g', 10))
|
||||||
default:
|
default:
|
||||||
buf.WriteString("...")
|
buf.WriteString("...")
|
||||||
|
|||||||
@@ -94,7 +94,6 @@ func (c *RemoteClient) Lock(info *statemgr.LockInfo) (string, error) {
|
|||||||
creationLockID := c.composeCreationLockID()
|
creationLockID := c.composeCreationLockID()
|
||||||
|
|
||||||
// Try to acquire locks for the existing row `id` and the creation lock.
|
// Try to acquire locks for the existing row `id` and the creation lock.
|
||||||
//nolint:gosec // we only parameterize user passed values
|
|
||||||
query := fmt.Sprintf(`SELECT %s.id, pg_try_advisory_lock(%s.id), pg_try_advisory_lock(%s) FROM %s.%s WHERE %s.name = $1`,
|
query := fmt.Sprintf(`SELECT %s.id, pg_try_advisory_lock(%s.id), pg_try_advisory_lock(%s) FROM %s.%s WHERE %s.name = $1`,
|
||||||
statesTableName, statesTableName, creationLockID, c.SchemaName, statesTableName, statesTableName)
|
statesTableName, statesTableName, creationLockID, c.SchemaName, statesTableName, statesTableName)
|
||||||
|
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ func TestConcurrentCreationLocksInDifferentSchemas(t *testing.T) {
|
|||||||
// during the same session.
|
// during the same session.
|
||||||
if _, err = thirdClient.Lock(lock); err == nil {
|
if _, err = thirdClient.Lock(lock); err == nil {
|
||||||
t.Fatal("Expected an error to be thrown on a second lock attempt")
|
t.Fatal("Expected an error to be thrown on a second lock attempt")
|
||||||
} else if lockErr := err.(*statemgr.LockError); lockErr.Info != lock && //nolint:errcheck,errorlint // this is a test, I am fine with panic here
|
} else if lockErr := err.(*statemgr.LockError); lockErr.Info != lock && //nolint:errcheck // this is a test, I am fine with panic here
|
||||||
lockErr.Err.Error() != "Already locked for workspace creation: default" {
|
lockErr.Err.Error() != "Already locked for workspace creation: default" {
|
||||||
t.Fatalf("Unexpected error thrown on a second lock attempt: %v", err)
|
t.Fatalf("Unexpected error thrown on a second lock attempt: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -492,7 +492,6 @@ func (c *RemoteClient) getLockInfoFromS3(ctx context.Context) (*statemgr.LockInf
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
var nb *types.NoSuchBucket
|
var nb *types.NoSuchBucket
|
||||||
if errors.As(err, &nb) {
|
if errors.As(err, &nb) {
|
||||||
//nolint:stylecheck // error message already used in multiple places. Not recommended to be updated
|
|
||||||
return nil, fmt.Errorf(errS3NoSuchBucket, err)
|
return nil, fmt.Errorf(errS3NoSuchBucket, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -340,7 +340,6 @@ func (b *Remote) costEstimate(stopCtx, cancelCtx context.Context, op *backend.Op
|
|||||||
b.CLI.Output("\n------------------------------------------------------------------------")
|
b.CLI.Output("\n------------------------------------------------------------------------")
|
||||||
return nil
|
return nil
|
||||||
case tfe.CostEstimateCanceled:
|
case tfe.CostEstimateCanceled:
|
||||||
//nolint:revive,stylecheck // Caller UI relies on this non-idiomatic error string form
|
|
||||||
return fmt.Errorf("%s canceled.", msgPrefix)
|
return fmt.Errorf("%s canceled.", msgPrefix)
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("Unknown or unexpected cost estimate state: %s", ce.Status)
|
return fmt.Errorf("Unknown or unexpected cost estimate state: %s", ce.Status)
|
||||||
@@ -418,10 +417,8 @@ func (b *Remote) checkPolicy(stopCtx, cancelCtx context.Context, op *backend.Ope
|
|||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
case tfe.PolicyErrored:
|
case tfe.PolicyErrored:
|
||||||
//nolint:revive,stylecheck // Caller UI relies on this non-idiomatic error string form
|
|
||||||
return fmt.Errorf("%s errored.", msgPrefix)
|
return fmt.Errorf("%s errored.", msgPrefix)
|
||||||
case tfe.PolicyHardFailed:
|
case tfe.PolicyHardFailed:
|
||||||
//nolint:revive,stylecheck // Caller UI relies on this non-idiomatic error string form
|
|
||||||
return fmt.Errorf("%s hard failed.", msgPrefix)
|
return fmt.Errorf("%s hard failed.", msgPrefix)
|
||||||
case tfe.PolicySoftFailed:
|
case tfe.PolicySoftFailed:
|
||||||
runUrl := fmt.Sprintf(runHeader, b.hostname, b.organization, op.Workspace, r.ID)
|
runUrl := fmt.Sprintf(runHeader, b.hostname, b.organization, op.Workspace, r.ID)
|
||||||
|
|||||||
@@ -312,7 +312,6 @@ func (b *Cloud) costEstimate(stopCtx, cancelCtx context.Context, op *backend.Ope
|
|||||||
b.CLI.Output("\n------------------------------------------------------------------------")
|
b.CLI.Output("\n------------------------------------------------------------------------")
|
||||||
return nil
|
return nil
|
||||||
case tfe.CostEstimateCanceled:
|
case tfe.CostEstimateCanceled:
|
||||||
//nolint:revive,stylecheck // Caller UI relies on this non-idiomatic error string form
|
|
||||||
return fmt.Errorf("%s canceled.", msgPrefix)
|
return fmt.Errorf("%s canceled.", msgPrefix)
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("Unknown or unexpected cost estimate state: %s", ce.Status)
|
return fmt.Errorf("Unknown or unexpected cost estimate state: %s", ce.Status)
|
||||||
@@ -390,10 +389,8 @@ func (b *Cloud) checkPolicy(stopCtx, cancelCtx context.Context, op *backend.Oper
|
|||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
case tfe.PolicyErrored:
|
case tfe.PolicyErrored:
|
||||||
//nolint:revive,stylecheck // Caller UI relies on this non-idiomatic error string form
|
|
||||||
return fmt.Errorf("%s errored.", msgPrefix)
|
return fmt.Errorf("%s errored.", msgPrefix)
|
||||||
case tfe.PolicyHardFailed:
|
case tfe.PolicyHardFailed:
|
||||||
//nolint:revive,stylecheck // Caller UI relies on this non-idiomatic error string form
|
|
||||||
return fmt.Errorf("%s hard failed.", msgPrefix)
|
return fmt.Errorf("%s hard failed.", msgPrefix)
|
||||||
case tfe.PolicySoftFailed:
|
case tfe.PolicySoftFailed:
|
||||||
runUrl := fmt.Sprintf(runHeader, b.hostname, b.organization, op.Workspace, r.ID)
|
runUrl := fmt.Sprintf(runHeader, b.hostname, b.organization, op.Workspace, r.ID)
|
||||||
@@ -417,7 +414,6 @@ func (b *Cloud) checkPolicy(stopCtx, cancelCtx context.Context, op *backend.Oper
|
|||||||
}
|
}
|
||||||
err = b.confirm(stopCtx, op, opts, r, "override")
|
err = b.confirm(stopCtx, op, opts, r, "override")
|
||||||
if err != nil && err != errRunOverridden {
|
if err != nil && err != errRunOverridden {
|
||||||
//nolint:revive,stylecheck // Caller UI relies on this non-idiomatic error string form
|
|
||||||
return fmt.Errorf("Failed to override: %s\n%s\n", err.Error(), runUrl)
|
return fmt.Errorf("Failed to override: %s\n%s\n", err.Error(), runUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
//nolint:revive,staticcheck //Disabling because we want to just stub out some methods
|
//nolint:staticcheck //Disabling because we want to just stub out some methods
|
||||||
package cloud
|
package cloud
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ func (c *consoleBracketState) UpdateState(line string) (string, int) {
|
|||||||
|
|
||||||
tokens, _ := hclsyntax.LexConfig([]byte(line), "<console-input>", hcl.Pos{Line: 1, Column: 1})
|
tokens, _ := hclsyntax.LexConfig([]byte(line), "<console-input>", hcl.Pos{Line: 1, Column: 1})
|
||||||
for _, token := range tokens {
|
for _, token := range tokens {
|
||||||
switch token.Type { //nolint:exhaustive // we only care about these specific types
|
switch token.Type { // we only care about these specific types
|
||||||
case hclsyntax.TokenOBrace:
|
case hclsyntax.TokenOBrace:
|
||||||
c.brace++
|
c.brace++
|
||||||
case hclsyntax.TokenCBrace:
|
case hclsyntax.TokenCBrace:
|
||||||
|
|||||||
@@ -186,8 +186,6 @@ func NewDiagnostic(diag tfdiags.Diagnostic, sources map[string]*hcl.File) *Diagn
|
|||||||
// ensure that the whole of an expression gets included in the snippet even if
|
// ensure that the whole of an expression gets included in the snippet even if
|
||||||
// the problem is just one operand of the expression and the expression is wrapped
|
// the problem is just one operand of the expression and the expression is wrapped
|
||||||
// over multiple lines.
|
// over multiple lines.
|
||||||
//
|
|
||||||
//nolint:nonamedreturns // These names are for documentation purposes, to differentiate two results that have the same type
|
|
||||||
func prepareDiagnosticRanges(subject, context *tfdiags.SourceRange) (highlight, snippet *tfdiags.SourceRange) {
|
func prepareDiagnosticRanges(subject, context *tfdiags.SourceRange) (highlight, snippet *tfdiags.SourceRange) {
|
||||||
if subject == nil {
|
if subject == nil {
|
||||||
// If we don't even have a "subject" then we have no ranges to report at all.
|
// If we don't even have a "subject" then we have no ranges to report at all.
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ type MockValueComposer struct {
|
|||||||
|
|
||||||
func NewMockValueComposer(seed int64) MockValueComposer {
|
func NewMockValueComposer(seed int64) MockValueComposer {
|
||||||
return MockValueComposer{
|
return MockValueComposer{
|
||||||
rand: rand.New(rand.NewSource(seed)), //nolint:gosec // It doesn't need to be secure.
|
rand: rand.New(rand.NewSource(seed)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ func (s SelectiveLoader) filter(input []*File) []*File {
|
|||||||
Locals: inFile.Locals,
|
Locals: inFile.Locals,
|
||||||
}
|
}
|
||||||
|
|
||||||
switch s { //nolint:exhaustive // SelectiveLoadAll handled above
|
switch s {
|
||||||
case SelectiveLoadBackend:
|
case SelectiveLoadBackend:
|
||||||
outFile.Backends = inFile.Backends
|
outFile.Backends = inFile.Backends
|
||||||
outFile.CloudConfigs = inFile.CloudConfigs
|
outFile.CloudConfigs = inFile.CloudConfigs
|
||||||
|
|||||||
@@ -1136,7 +1136,6 @@ var testRunModuleBlockSchema = &hcl.BodySchema{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:gochecknoglobals // To follow existing code style.
|
|
||||||
var overrideResourceBlockSchema = &hcl.BodySchema{
|
var overrideResourceBlockSchema = &hcl.BodySchema{
|
||||||
Attributes: []hcl.AttributeSchema{
|
Attributes: []hcl.AttributeSchema{
|
||||||
{
|
{
|
||||||
@@ -1150,7 +1149,6 @@ var overrideResourceBlockSchema = &hcl.BodySchema{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:gochecknoglobals // To follow existing code style.
|
|
||||||
var overrideModuleBlockSchema = &hcl.BodySchema{
|
var overrideModuleBlockSchema = &hcl.BodySchema{
|
||||||
Attributes: []hcl.AttributeSchema{
|
Attributes: []hcl.AttributeSchema{
|
||||||
{
|
{
|
||||||
@@ -1164,7 +1162,6 @@ var overrideModuleBlockSchema = &hcl.BodySchema{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:gochecknoglobals // To follow existing code style.
|
|
||||||
var mockProviderBlockSchema = &hcl.BodySchema{
|
var mockProviderBlockSchema = &hcl.BodySchema{
|
||||||
Attributes: []hcl.AttributeSchema{
|
Attributes: []hcl.AttributeSchema{
|
||||||
{
|
{
|
||||||
@@ -1190,7 +1187,6 @@ var mockProviderBlockSchema = &hcl.BodySchema{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:gochecknoglobals // To follow existing code style.
|
|
||||||
var mockResourceBlockSchema = &hcl.BodySchema{
|
var mockResourceBlockSchema = &hcl.BodySchema{
|
||||||
Attributes: []hcl.AttributeSchema{
|
Attributes: []hcl.AttributeSchema{
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -142,7 +142,6 @@ func (base *baseEncryption) encrypt(data []byte, enhance func(basedata) interfac
|
|||||||
return jsond, nil
|
return jsond, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:revive // this name is fine
|
|
||||||
type EncryptionStatus int
|
type EncryptionStatus int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ func filterKeyProviderReferences(cfg *config.EncryptionConfig, deps []hcl.Traver
|
|||||||
// Setting up key providers from deps.
|
// Setting up key providers from deps.
|
||||||
for _, dep := range deps {
|
for _, dep := range deps {
|
||||||
// Key Provider references should be in the form key_provider.type.name
|
// Key Provider references should be in the form key_provider.type.name
|
||||||
if len(dep) != 3 { //nolint:mnd // linting
|
if len(dep) != 3 {
|
||||||
nonKeyProviderDeps = append(nonKeyProviderDeps, dep)
|
nonKeyProviderDeps = append(nonKeyProviderDeps, dep)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ func (k keyProvider) Provide(rawMeta keyprovider.KeyMeta) (keyprovider.Output, k
|
|||||||
|
|
||||||
stderr := &bytes.Buffer{}
|
stderr := &bytes.Buffer{}
|
||||||
|
|
||||||
cmd := exec.CommandContext(ctx, k.command[0], k.command[1:]...) //nolint:gosec //Launching external commands here is the entire point.
|
cmd := exec.CommandContext(ctx, k.command[0], k.command[1:]...)
|
||||||
|
|
||||||
handler := &ioHandler{
|
handler := &ioHandler{
|
||||||
false,
|
false,
|
||||||
@@ -107,7 +107,7 @@ func (i *ioHandler) Write(p []byte) (int, error) {
|
|||||||
return n, nil
|
return n, nil
|
||||||
}
|
}
|
||||||
// Check if the full header is present.
|
// Check if the full header is present.
|
||||||
parts := strings.SplitN(string(i.output), "\n", 2) //nolint:mnd //This rule is dumb.
|
parts := strings.SplitN(string(i.output), "\n", 2)
|
||||||
if len(parts) == 1 {
|
if len(parts) == 1 {
|
||||||
return n, nil
|
return n, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,11 +34,11 @@ go 1.22`)
|
|||||||
|
|
||||||
tempDir := t.TempDir()
|
tempDir := t.TempDir()
|
||||||
dir := path.Join(tempDir, "testprovider-go")
|
dir := path.Join(tempDir, "testprovider-go")
|
||||||
if err := os.MkdirAll(dir, 0700); err != nil { //nolint:mnd // This check is stupid
|
if err := os.MkdirAll(dir, 0700); err != nil {
|
||||||
t.Errorf("Failed to create temporary directory (%v)", err)
|
t.Errorf("Failed to create temporary directory (%v)", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.WriteFile(path.Join(dir, "go.mod"), goMod, 0600); err != nil { //nolint:mnd // This check is stupid
|
if err := os.WriteFile(path.Join(dir, "go.mod"), goMod, 0600); err != nil {
|
||||||
t.Errorf("%v", err)
|
t.Errorf("%v", err)
|
||||||
}
|
}
|
||||||
if err := ejectFile("testprovider.go", path.Join(dir, "testprovider.go")); err != nil {
|
if err := ejectFile("testprovider.go", path.Join(dir, "testprovider.go")); err != nil {
|
||||||
@@ -68,7 +68,7 @@ func Python(t *testing.T) []string {
|
|||||||
|
|
||||||
tempDir := t.TempDir()
|
tempDir := t.TempDir()
|
||||||
dir := path.Join(tempDir, "testprovider-py")
|
dir := path.Join(tempDir, "testprovider-py")
|
||||||
if err := os.MkdirAll(dir, 0700); err != nil { //nolint:mnd // This check is stupid
|
if err := os.MkdirAll(dir, 0700); err != nil {
|
||||||
t.Errorf("Failed to create temporary directory (%v)", err)
|
t.Errorf("Failed to create temporary directory (%v)", err)
|
||||||
}
|
}
|
||||||
target := path.Join(dir, "testprovider.py")
|
target := path.Join(dir, "testprovider.py")
|
||||||
@@ -86,7 +86,7 @@ func POSIXShell(t *testing.T) []string {
|
|||||||
|
|
||||||
tempDir := t.TempDir()
|
tempDir := t.TempDir()
|
||||||
dir := path.Join(tempDir, "testprovider-sh")
|
dir := path.Join(tempDir, "testprovider-sh")
|
||||||
if err := os.MkdirAll(dir, 0700); err != nil { //nolint:mnd // This check is stupid
|
if err := os.MkdirAll(dir, 0700); err != nil {
|
||||||
t.Errorf("Failed to create temporary directory (%v)", err)
|
t.Errorf("Failed to create temporary directory (%v)", err)
|
||||||
}
|
}
|
||||||
target := path.Join(dir, "testprovider.sh")
|
target := path.Join(dir, "testprovider.sh")
|
||||||
@@ -102,7 +102,7 @@ func ejectFile(file string, target string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to read %s file from embedded dataset (%w)", file, err)
|
return fmt.Errorf("failed to read %s file from embedded dataset (%w)", file, err)
|
||||||
}
|
}
|
||||||
if err := os.WriteFile(target, contents, 0600); err != nil { //nolint:mnd // This check is stupid
|
if err := os.WriteFile(target, contents, 0600); err != nil {
|
||||||
return fmt.Errorf("failed to create %s file at %s (%w)", file, target, err)
|
return fmt.Errorf("failed to create %s file at %s (%w)", file, target, err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ func (c command) run(command []string, input any) ([]byte, error) {
|
|||||||
|
|
||||||
stderr := &bytes.Buffer{}
|
stderr := &bytes.Buffer{}
|
||||||
|
|
||||||
cmd := exec.CommandContext(ctx, command[0], command[1:]...) //nolint:gosec //Launching external commands here is the entire point.
|
cmd := exec.CommandContext(ctx, command[0], command[1:]...)
|
||||||
|
|
||||||
handler := &ioHandler{
|
handler := &ioHandler{
|
||||||
false,
|
false,
|
||||||
@@ -152,7 +152,7 @@ func (i *ioHandler) Write(p []byte) (int, error) {
|
|||||||
return n, nil
|
return n, nil
|
||||||
}
|
}
|
||||||
// Check if the full header is present.
|
// Check if the full header is present.
|
||||||
parts := strings.SplitN(string(i.output), "\n", 2) //nolint:mnd //This rule is dumb.
|
parts := strings.SplitN(string(i.output), "\n", 2)
|
||||||
if len(parts) == 1 {
|
if len(parts) == 1 {
|
||||||
return n, nil
|
return n, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,9 @@ func TestCompliancePython(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runTest(t *testing.T, cmd []string) {
|
func runTest(t *testing.T, cmd []string) {
|
||||||
encryptCommand := append(cmd, "--encrypt") //nolint:gocritic //It's intentionally a different slice.
|
cmd = slices.Clip(cmd) // Make sure that the following appends are forced to allocate capacity
|
||||||
decryptCommand := append(cmd, "--decrypt") //nolint:gocritic //It's intentionally a different slice.
|
encryptCommand := append(cmd, "--encrypt")
|
||||||
|
decryptCommand := append(cmd, "--decrypt")
|
||||||
|
|
||||||
compliancetest.ComplianceTest(t, compliancetest.TestConfiguration[*descriptor, *Config, *command]{
|
compliancetest.ComplianceTest(t, compliancetest.TestConfiguration[*descriptor, *Config, *command]{
|
||||||
Descriptor: New().(*descriptor), //nolint:errcheck //This is safe.
|
Descriptor: New().(*descriptor), //nolint:errcheck //This is safe.
|
||||||
|
|||||||
@@ -32,11 +32,11 @@ go 1.22`)
|
|||||||
|
|
||||||
tempDir := t.TempDir()
|
tempDir := t.TempDir()
|
||||||
dir := path.Join(tempDir, "testmethod-go")
|
dir := path.Join(tempDir, "testmethod-go")
|
||||||
if err := os.MkdirAll(dir, 0700); err != nil { //nolint:mnd // This check is stupid
|
if err := os.MkdirAll(dir, 0700); err != nil {
|
||||||
t.Errorf("Failed to create temporary directory (%v)", err)
|
t.Errorf("Failed to create temporary directory (%v)", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.WriteFile(path.Join(dir, "go.mod"), goMod, 0600); err != nil { //nolint:mnd // This check is stupid
|
if err := os.WriteFile(path.Join(dir, "go.mod"), goMod, 0600); err != nil {
|
||||||
t.Errorf("%v", err)
|
t.Errorf("%v", err)
|
||||||
}
|
}
|
||||||
if err := ejectFile("testmethod.go", path.Join(dir, "testmethod.go")); err != nil {
|
if err := ejectFile("testmethod.go", path.Join(dir, "testmethod.go")); err != nil {
|
||||||
@@ -65,7 +65,7 @@ func Python(t *testing.T) []string {
|
|||||||
|
|
||||||
tempDir := t.TempDir()
|
tempDir := t.TempDir()
|
||||||
dir := path.Join(tempDir, "testmethod-py")
|
dir := path.Join(tempDir, "testmethod-py")
|
||||||
if err := os.MkdirAll(dir, 0700); err != nil { //nolint:mnd // This check is stupid
|
if err := os.MkdirAll(dir, 0700); err != nil {
|
||||||
t.Errorf("Failed to create temporary directory (%v)", err)
|
t.Errorf("Failed to create temporary directory (%v)", err)
|
||||||
}
|
}
|
||||||
target := path.Join(dir, "testmethod.py")
|
target := path.Join(dir, "testmethod.py")
|
||||||
@@ -81,7 +81,7 @@ func ejectFile(file string, target string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to read %s file from embedded dataset (%w)", file, err)
|
return fmt.Errorf("failed to read %s file from embedded dataset (%w)", file, err)
|
||||||
}
|
}
|
||||||
if err := os.WriteFile(target, contents, 0600); err != nil { //nolint:mnd // This check is stupid
|
if err := os.WriteFile(target, contents, 0600); err != nil {
|
||||||
return fmt.Errorf("failed to create %s file at %s (%w)", file, target, err)
|
return fmt.Errorf("failed to create %s file at %s (%w)", file, target, err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ func methodConfigsFromTarget(cfg *config.EncryptionConfig, target *config.Target
|
|||||||
traversal, travDiags := hcl.AbsTraversalForExpr(target.Method)
|
traversal, travDiags := hcl.AbsTraversalForExpr(target.Method)
|
||||||
diags = diags.Extend(travDiags)
|
diags = diags.Extend(travDiags)
|
||||||
if !travDiags.HasErrors() {
|
if !travDiags.HasErrors() {
|
||||||
if len(traversal) != 3 { //nolint:mnd // linting
|
if len(traversal) != 3 {
|
||||||
diags = diags.Append(&hcl.Diagnostic{
|
diags = diags.Append(&hcl.Diagnostic{
|
||||||
Severity: hcl.DiagError,
|
Severity: hcl.DiagError,
|
||||||
Summary: "Invalid encryption method identifier",
|
Summary: "Invalid encryption method identifier",
|
||||||
|
|||||||
@@ -516,7 +516,7 @@ func (s signatureAuthentication) findSigningKey() (*SigningKey, string, error) {
|
|||||||
if entity != nil && entity.PrimaryKey != nil {
|
if entity != nil && entity.PrimaryKey != nil {
|
||||||
expiredKeyID = entity.PrimaryKey.KeyIdString()
|
expiredKeyID = entity.PrimaryKey.KeyIdString()
|
||||||
} else {
|
} else {
|
||||||
expiredKeyID = "n/a" //nolint:goconst // This is a placeholder value
|
expiredKeyID = "n/a"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
@@ -533,7 +533,6 @@ func (s signatureAuthentication) findSigningKey() (*SigningKey, string, error) {
|
|||||||
|
|
||||||
// Warn only once when ALL keys are expired.
|
// Warn only once when ALL keys are expired.
|
||||||
if expiredKey != nil && !s.shouldEnforceGPGExpiration() {
|
if expiredKey != nil && !s.shouldEnforceGPGExpiration() {
|
||||||
//nolint:forbidigo // This is a warning message and is fine to be handled this way
|
|
||||||
fmt.Printf("[WARN] Provider %s/%s (%v) gpg key expired, this will fail in future versions of OpenTofu\n",
|
fmt.Printf("[WARN] Provider %s/%s (%v) gpg key expired, this will fail in future versions of OpenTofu\n",
|
||||||
s.Meta.Provider.Namespace, s.Meta.Provider.Type, s.Meta.Provider.Hostname)
|
s.Meta.Provider.Namespace, s.Meta.Provider.Type, s.Meta.Provider.Hostname)
|
||||||
return expiredKey, expiredKeyID, nil
|
return expiredKey, expiredKeyID, nil
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
// This library accepts either size of byte slice but always
|
// This library accepts either size of byte slice but always
|
||||||
// returns 16-byte addresses.
|
// returns 16-byte addresses.
|
||||||
|
|
||||||
//nolint:cyclop,funlen,gochecknoglobals,gocritic,nonamedreturns,mnd // This file is copied from the Go codebase and intended to remain close to the original in case we need to backport changes.
|
|
||||||
package ipaddr
|
package ipaddr
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//nolint:gochecknoglobals,gocritic,govet // This file is copied from the Go codebase and intended to remain close to the original in case we need to backport changes.
|
|
||||||
package ipaddr
|
package ipaddr
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
// Simple file i/o and string manipulation, to avoid
|
// Simple file i/o and string manipulation, to avoid
|
||||||
// depending on strconv and bufio and strings.
|
// depending on strconv and bufio and strings.
|
||||||
|
|
||||||
//nolint:nonamedreturns,mnd // This file is copied from the Go codebase and intended to remain close to the original in case we need to backport changes.
|
|
||||||
package ipaddr
|
package ipaddr
|
||||||
|
|
||||||
// Bigger than we need, not too big to worry about overflow
|
// Bigger than we need, not too big to worry about overflow
|
||||||
|
|||||||
@@ -107,8 +107,6 @@ func (s *Scope) experimentalFunction(experiment experiments.Experiment, fn funct
|
|||||||
// This function intentionally always returns a fresh map on each call because the
|
// This function intentionally always returns a fresh map on each call because the
|
||||||
// caller is expected to modify it further before storing it as part of a
|
// caller is expected to modify it further before storing it as part of a
|
||||||
// particular [Scope], based on the unique settings of that scope.
|
// particular [Scope], based on the unique settings of that scope.
|
||||||
//
|
|
||||||
//nolint:funlen // The length of this function naturally scales with the number of functions in the OpenTofu language.
|
|
||||||
func makeBaseFunctionTable(baseDir string) map[string]function.Function {
|
func makeBaseFunctionTable(baseDir string) map[string]function.Function {
|
||||||
// Some of our functions are just directly the cty stdlib functions.
|
// Some of our functions are just directly the cty stdlib functions.
|
||||||
// Others are implemented in the subdirectory "funcs" here in this
|
// Others are implemented in the subdirectory "funcs" here in this
|
||||||
|
|||||||
@@ -43,8 +43,6 @@ import (
|
|||||||
// it really is registered correctly) and possibly a small set of additional
|
// it really is registered correctly) and possibly a small set of additional
|
||||||
// functions showing real-world use-cases that rely on type conversion
|
// functions showing real-world use-cases that rely on type conversion
|
||||||
// behaviors.
|
// behaviors.
|
||||||
//
|
|
||||||
//nolint:gocognit // This test intentionally embraces mainloop complexity so that maintenence can primarily focus on the declarative test table rather than the actual test logic.
|
|
||||||
func TestFunctions(t *testing.T) {
|
func TestFunctions(t *testing.T) {
|
||||||
// used in `pathexpand()` test
|
// used in `pathexpand()` test
|
||||||
homePath, err := homedir.Dir()
|
homePath, err := homedir.Dir()
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
// Copyright (c) 2023 HashiCorp, Inc.
|
// Copyright (c) 2023 HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
//nolint:cyclop,funlen,gocognit // This legacy code is frozen from an older version of the codebase and will not be updated to pass any linters.
|
|
||||||
package schema
|
package schema
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
// Copyright (c) 2023 HashiCorp, Inc.
|
// Copyright (c) 2023 HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
//nolint:cyclop,funlen,nestif // This legacy code is frozen from an older version of the codebase and will not be updated to pass any linters.
|
|
||||||
package schema
|
package schema
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
// Copyright (c) 2023 HashiCorp, Inc.
|
// Copyright (c) 2023 HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
//nolint:cyclop,gocyclo,gocognit,nestif // This legacy code is frozen from an older version of the codebase and will not be updated to pass any linters.
|
|
||||||
package schema
|
package schema
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
// Copyright (c) 2023 HashiCorp, Inc.
|
// Copyright (c) 2023 HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
//nolint:cyclop // This legacy code is frozen from an older version of the codebase and will not be updated to pass any linters.
|
|
||||||
package schema
|
package schema
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
// Copyright (c) 2023 HashiCorp, Inc.
|
// Copyright (c) 2023 HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
//nolint:cyclop,funlen,nestif // This legacy code is frozen from an older version of the codebase and will not be updated to pass any linters.
|
|
||||||
package schema
|
package schema
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -14,8 +14,6 @@
|
|||||||
// everything else is meant to just work.
|
// everything else is meant to just work.
|
||||||
//
|
//
|
||||||
// A good starting point is to view the Provider structure.
|
// A good starting point is to view the Provider structure.
|
||||||
//
|
|
||||||
//nolint:cyclop,funlen,gocognit,gocyclo,nestif // This legacy code is frozen from an older version of the codebase and will not be updated to pass any linters.
|
|
||||||
package schema
|
package schema
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
// Copyright (c) 2023 HashiCorp, Inc.
|
// Copyright (c) 2023 HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
//nolint:funlen // This legacy code is frozen from an older version of the codebase and will not be updated to pass any linters.
|
|
||||||
package schema
|
package schema
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
// Copyright (c) 2023 HashiCorp, Inc.
|
// Copyright (c) 2023 HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
//nolint:cyclop,gocognit // This legacy code is frozen from an older version of the codebase and will not be updated to pass any linters.
|
|
||||||
package schema
|
package schema
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
// Copyright (c) 2023 HashiCorp, Inc.
|
// Copyright (c) 2023 HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
//nolint:cyclop,funlen,gocognit,gocyclo,nestif // This legacy code is frozen from an older version of the codebase and will not be updated to pass any linters.
|
|
||||||
package tofu
|
package tofu
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
// Copyright (c) 2023 HashiCorp, Inc.
|
// Copyright (c) 2023 HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
//nolint:nestif // This legacy code is frozen from an older version of the codebase and will not be updated to pass any linters.
|
|
||||||
package tofu
|
package tofu
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
// Copyright (c) 2023 HashiCorp, Inc.
|
// Copyright (c) 2023 HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
//nolint:nestif // This legacy code is frozen from an older version of the codebase and will not be updated to pass any linters.
|
|
||||||
package tofu
|
package tofu
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
// Copyright (c) 2023 HashiCorp, Inc.
|
// Copyright (c) 2023 HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
//nolint:cyclop,funlen // This legacy code is frozen from an older version of the codebase and will not be updated to pass any linters.
|
|
||||||
package tofu
|
package tofu
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
// Copyright (c) 2023 HashiCorp, Inc.
|
// Copyright (c) 2023 HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
//nolint:gocognit,nestif // This legacy code is frozen from an older version of the codebase and will not be updated to pass any linters.
|
|
||||||
package tofu
|
package tofu
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
// Copyright (c) 2023 HashiCorp, Inc.
|
// Copyright (c) 2023 HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
//nolint:cyclop,gocyclo // This legacy code is frozen from an older version of the codebase and will not be updated to pass any linters.
|
|
||||||
package tofu
|
package tofu
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -657,8 +657,7 @@ func (p *GRPCProvider) MoveResourceState(r providers.MoveResourceStateRequest) p
|
|||||||
protoReq := &proto.MoveResourceState_Request{
|
protoReq := &proto.MoveResourceState_Request{
|
||||||
SourceProviderAddress: r.SourceProviderAddress,
|
SourceProviderAddress: r.SourceProviderAddress,
|
||||||
SourceTypeName: r.SourceTypeName,
|
SourceTypeName: r.SourceTypeName,
|
||||||
//nolint:gosec // this will be refactored eventually
|
SourceSchemaVersion: int64(r.SourceSchemaVersion),
|
||||||
SourceSchemaVersion: int64(r.SourceSchemaVersion),
|
|
||||||
SourceState: &proto.RawState{
|
SourceState: &proto.RawState{
|
||||||
Json: r.SourceStateJSON,
|
Json: r.SourceStateJSON,
|
||||||
Flatmap: r.SourceStateFlatmap,
|
Flatmap: r.SourceStateFlatmap,
|
||||||
|
|||||||
@@ -646,8 +646,7 @@ func (p *GRPCProvider) MoveResourceState(r providers.MoveResourceStateRequest) p
|
|||||||
protoReq := &proto6.MoveResourceState_Request{
|
protoReq := &proto6.MoveResourceState_Request{
|
||||||
SourceProviderAddress: r.SourceProviderAddress,
|
SourceProviderAddress: r.SourceProviderAddress,
|
||||||
SourceTypeName: r.SourceTypeName,
|
SourceTypeName: r.SourceTypeName,
|
||||||
//nolint:gosec // this will be refactored eventually
|
SourceSchemaVersion: int64(r.SourceSchemaVersion),
|
||||||
SourceSchemaVersion: int64(r.SourceSchemaVersion),
|
|
||||||
SourceState: &proto6.RawState{
|
SourceState: &proto6.RawState{
|
||||||
Json: r.SourceStateJSON,
|
Json: r.SourceStateJSON,
|
||||||
Flatmap: r.SourceStateFlatmap,
|
Flatmap: r.SourceStateFlatmap,
|
||||||
|
|||||||
@@ -675,8 +675,6 @@ func (i *Installer) ensureProviderVersionsInstall(
|
|||||||
// If sourceDir has a package that appears to be for the selected provider
|
// If sourceDir has a package that appears to be for the selected provider
|
||||||
// version but there are any problems with that package that prevent it from
|
// version but there are any problems with that package that prevent it from
|
||||||
// being installed then it returns a non-nil error describing the problem.
|
// being installed then it returns a non-nil error describing the problem.
|
||||||
//
|
|
||||||
//nolint:nonamedreturns // The "installed" name explains what this bool represents as part of the signature
|
|
||||||
func tryInstallPackageFromCacheDir(
|
func tryInstallPackageFromCacheDir(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
sourceDir *Dir,
|
sourceDir *Dir,
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
// Copyright (c) 2023 HashiCorp, Inc.
|
// Copyright (c) 2023 HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
//nolint:govet,mnd,nilnil // The functions in this file are effectively frozen to support an older state format version, so they will never be updated to pass lint rules.
|
|
||||||
package statefile
|
package statefile
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
// Copyright (c) 2023 HashiCorp, Inc.
|
// Copyright (c) 2023 HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
//nolint:cyclop,errcheck,funlen,gocritic,gocognit,gocyclo,predeclared,revive,unparam // The functions in this file are effectively frozen to support an older state format version, so they will never be updated to pass lint rules.
|
|
||||||
package statefile
|
package statefile
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
// Copyright (c) 2023 HashiCorp, Inc.
|
// Copyright (c) 2023 HashiCorp, Inc.
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
//nolint:cyclop,exhaustive,funlen,goconst,gocognit,gosec,govet,gocyclo,mnd,nestif,predeclared,revive // The functions in this file are effectively frozen to support an older state format version, so they will never be updated to pass lint rules.
|
|
||||||
package statefile
|
package statefile
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -99,7 +99,6 @@ func upgradeResourceStateTransform(args stateTransformArgs) (cty.Value, []byte,
|
|||||||
// to all protobuf target languages so in practice we use int64
|
// to all protobuf target languages so in practice we use int64
|
||||||
// on the wire. In future we will change all of our internal
|
// on the wire. In future we will change all of our internal
|
||||||
// representations to int64 too.
|
// representations to int64 too.
|
||||||
//nolint:gosec // this will be refactored eventually
|
|
||||||
Version: int64(args.objectSrc.SchemaVersion),
|
Version: int64(args.objectSrc.SchemaVersion),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user