mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
Address most linting issues in tofu
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
This commit is contained in:
@@ -306,6 +306,7 @@ func (c *Context) watchStop(walker *ContextGraphWalker) (chan struct{}, <-chan s
|
||||
// We ignore the error for now since there isn't any reasonable
|
||||
// action to take if there is an error here, since the stop is still
|
||||
// advisory: OpenTofu will exit once the graph node completes.
|
||||
//nolint:errcheck
|
||||
p.Stop()
|
||||
}
|
||||
}
|
||||
@@ -323,6 +324,7 @@ func (c *Context) watchStop(walker *ContextGraphWalker) (chan struct{}, <-chan s
|
||||
// We ignore the error for now since there isn't any reasonable
|
||||
// action to take if there is an error here, since the stop is still
|
||||
// advisory: OpenTofu will exit once the graph node completes.
|
||||
//nolint:errcheck
|
||||
p.Stop()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1458,7 +1458,7 @@ output "out" {
|
||||
_, diags = ctx.Plan(context.Background(), m, state, opts)
|
||||
assertNoErrors(t, diags)
|
||||
return
|
||||
// TODO: unreachable code
|
||||
//nolint:govet // TODO: unreachable code
|
||||
otherProvider.ConfigureProviderCalled = false
|
||||
otherProvider.ConfigureProviderFn = func(req providers.ConfigureProviderRequest) (resp providers.ConfigureProviderResponse) {
|
||||
// check that our config is complete, even during a destroy plan
|
||||
|
||||
@@ -88,7 +88,11 @@ func (cp *contextPlugins) ProviderSchema(addr addrs.Provider) (providers.Provide
|
||||
if err != nil {
|
||||
return schemas, fmt.Errorf("failed to instantiate provider %q to obtain schema: %w", addr, err)
|
||||
}
|
||||
defer provider.Close()
|
||||
defer func() {
|
||||
if err := provider.Close(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
|
||||
resp := provider.GetProviderSchema()
|
||||
if resp.Diagnostics.HasErrors() {
|
||||
@@ -170,7 +174,11 @@ func (cp *contextPlugins) ProvisionerSchema(typ string) (*configschema.Block, er
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to instantiate provisioner %q to obtain schema: %w", typ, err)
|
||||
}
|
||||
defer provisioner.Close()
|
||||
defer func() {
|
||||
if err := provisioner.Close(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
|
||||
resp := provisioner.GetSchema()
|
||||
if resp.Diagnostics.HasErrors() {
|
||||
|
||||
@@ -110,7 +110,9 @@ func testModuleInline(t testing.TB, sources map[string]string) *configs.Config {
|
||||
}
|
||||
|
||||
_, err = io.Copy(cfgF, strings.NewReader(configStr))
|
||||
cfgF.Close()
|
||||
if ferr := cfgF.Close(); ferr != nil {
|
||||
t.Fatal(ferr)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating temporary file for config: %s", err)
|
||||
}
|
||||
|
||||
@@ -107,7 +107,9 @@ func (ctx *TestContext) evaluate(state *states.SyncState, changes *plans.Changes
|
||||
defer func() {
|
||||
for addr, inst := range providerInstances {
|
||||
log.Printf("[INFO] Shutting down test provider %s", addr)
|
||||
inst.Close()
|
||||
if err := inst.Close(); err != nil {
|
||||
log.Printf("[WARN] Unable to shut down provider %s in test context: %s", addr, err)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
@@ -58,7 +58,9 @@ func TestModuleTransformAttachConfigTransformer(t *testing.T) {
|
||||
for _, attr := range attrs {
|
||||
val, _ := attr.Expr.Value(nil)
|
||||
var target int
|
||||
gocty.FromCtyValue(val, &target)
|
||||
if err := gocty.FromCtyValue(val, &target); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
values[attr.Name] = target
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user