TRITON-2502

terraform-provider-triton should pass all linter checks

Status:
Resolved
Created:
2025-09-01T04:47:21.162-0400
Updated:
2025-09-03T10:40:45.434-0400

Description

Nahum mentioned that terraform-provider-triton needs a fix for a valid issue the go linter found.

All staticcheck checks should pass as well.

Currently failing checks:

❯ make lint
golangci-lint run
triton/client.go:27:15: SA1019: errwrap.Wrapf is deprecated: Use fmt.Errorf() (staticcheck)
		return nil, errwrap.Wrapf("Error Creating Triton Account Client: {{err}}", err)
		            ^
triton/client.go:39:15: SA1019: errwrap.Wrapf is deprecated: Use fmt.Errorf() (staticcheck)
		return nil, errwrap.Wrapf("Error Creating Triton Compute Client: {{err}}", err)
		            ^
triton/client.go:50:15: SA1019: errwrap.Wrapf is deprecated: Use fmt.Errorf() (staticcheck)
		return nil, errwrap.Wrapf("Error Creating Triton Identity Client: {{err}}", err)
		            ^
triton/client.go:61:15: SA1019: errwrap.Wrapf is deprecated: Use fmt.Errorf() (staticcheck)
		return nil, errwrap.Wrapf("Error Creating Triton Network Client: {{err}}", err)
		            ^
triton/client.go:72:15: SA1019: errwrap.Wrapf is deprecated: Use fmt.Errorf() (staticcheck)
		return nil, errwrap.Wrapf("Error Creating Triton Services Client: {{err}}", err)
		            ^
triton/data_source_image.go:117:10: ST1005: error strings should not end with punctuation or newlines (staticcheck)
		return fmt.Errorf("Your query returned no results. Please change " +
		       ^
triton/data_source_image.go:127:11: ST1005: error strings should not end with punctuation or newlines (staticcheck)
			return fmt.Errorf("Your query returned more than one result. " +
			       ^
triton/data_source_package.go:133:11: ST1005: error strings should not end with punctuation or newlines (staticcheck)
			return fmt.Errorf("Please set filters on your package data source.")
			       ^
triton/data_source_package.go:167:10: ST1005: error strings should not end with punctuation or newlines (staticcheck)
		return fmt.Errorf("Your query returned no results. Please change " +
		       ^
triton/data_source_package.go:195:10: ST1005: error strings should not end with punctuation or newlines (staticcheck)
		return fmt.Errorf(
		       ^
triton/data_source_volume.go:87:10: ST1005: error strings should not end with punctuation or newlines (staticcheck)
		return fmt.Errorf("Your query returned no results. Please change " +
		       ^
triton/data_source_volume.go:93:10: ST1005: error strings should not end with punctuation or newlines (staticcheck)
		return fmt.Errorf("Your query returned more than one result. " +
		       ^
triton/data_source_volume.go:97:13: ST1023: should omit type *compute.Volume from declaration; it will be inferred from the right-hand side (staticcheck)
	var volume *compute.Volume = volumes[0]
	           ^
triton/provider.go:7:2: SA1019: "io/ioutil" has been deprecated since Go 1.19: As of Go 1.16, the same functionality is now provided by package [io] or package [os], and those implementations should be preferred in new code. See the specific function documentation for details. (staticcheck)
	"io/ioutil"
	^
triton/provider.go:112:32: ST1005: error strings should not be capitalized (staticcheck)
		err = multierror.Append(err, stderrors.New("Key ID must be configured for the Triton provider"))
		                             ^
triton/provider.go:132:16: SA1019: errwrap.Wrapf is deprecated: Use fmt.Errorf() (staticcheck)
			return nil, errwrap.Wrapf("Error Creating SSH Agent Signer: {{err}}", err)
			            ^
triton/provider.go:139:17: ST1005: error strings should not be capitalized (staticcheck)
				return nil, fmt.Errorf("Error reading key material from %s: %s",
				            ^
triton/provider.go:144:17: ST1005: error strings should not be capitalized (staticcheck)
				return nil, fmt.Errorf(
				            ^
triton/provider.go:149:17: ST1005: error strings should not end with punctuation or newlines (staticcheck)
				return nil, fmt.Errorf(
				            ^
triton/provider.go:165:16: SA1019: errwrap.Wrapf is deprecated: Use fmt.Errorf() (staticcheck)
			return nil, errwrap.Wrapf("Error Creating SSH Private Key Signer: {{err}}", err)
			            ^
triton/resource_fabric.go:140:11: ST1005: error strings should not be capitalized (staticcheck)
			return fmt.Errorf(`Cannot use "%v" as an IP address`, v)
			       ^
triton/resource_fabric_migrate.go:17:14: ST1005: error strings should not be capitalized (staticcheck)
		return is, fmt.Errorf("Unexpected schema version: %d", v)
		           ^
triton/resource_firewall_rule.go:29:13: S1034: assigning the result of this type assertion to a variable (switch v := v.(type)) could eliminate type assertions in switch cases (staticcheck)
					switch v.(type) {
					       ^
triton/resource_firewall_rule.go:31:32: S1034(related information): could eliminate this type assertion (staticcheck)
						return strings.TrimSpace(v.(string))
						                         ^
triton/resource_key.go:53:11: ST1005: error strings should not be capitalized (staticcheck)
			return errors.New("No key name specified, and key material has no comment")
			       ^
triton/resource_key_test.go:155:9: SA1019: resource.Retry is deprecated: Use helper/retry package instead. This is required for migrating acceptance testing to terraform-plugin-testing. (staticcheck)
	return resource.Retry(1*time.Minute, func() *resource.RetryError {
	       ^
triton/resource_key_test.go:169:12: SA1019: resource.RetryableError is deprecated: Use helper/retry package instead. This is required for migrating acceptance testing to terraform-plugin-testing. (staticcheck)
				return resource.RetryableError(fmt.Errorf("Bad: Key %q still exists", rs.Primary.ID))
				       ^
triton/resource_machine.go:410:7: S1002: should omit comparison to bool constant, can be simplified to !ok (staticcheck)
			if ok == false {
			   ^
triton/resource_machine.go:414:7: S1002: should omit comparison to bool constant, can be simplified to !ok (staticcheck)
			if ok == false {
			   ^
triton/resource_machine.go:481:16: SA1019: resource.StateChangeConf is deprecated: Use helper/retry package instead. This is required for migrating acceptance testing to terraform-plugin-testing. (staticcheck)
	stateConf := &resource.StateChangeConf{
	              ^
triton/resource_machine.go:635:17: SA1019: resource.StateChangeConf is deprecated: Use helper/retry package instead. This is required for migrating acceptance testing to terraform-plugin-testing. (staticcheck)
		stateConf := &resource.StateChangeConf{
		              ^
triton/resource_machine.go:712:17: SA1019: resource.StateChangeConf is deprecated: Use helper/retry package instead. This is required for migrating acceptance testing to terraform-plugin-testing. (staticcheck)
		stateConf := &resource.StateChangeConf{
		              ^
triton/resource_machine.go:749:17: SA1019: resource.StateChangeConf is deprecated: Use helper/retry package instead. This is required for migrating acceptance testing to terraform-plugin-testing. (staticcheck)
		stateConf := &resource.StateChangeConf{
		              ^
triton/resource_machine.go:787:17: SA1019: resource.StateChangeConf is deprecated: Use helper/retry package instead. This is required for migrating acceptance testing to terraform-plugin-testing. (staticcheck)
		stateConf := &resource.StateChangeConf{
		              ^
triton/resource_machine.go:854:18: SA1019: resource.StateChangeConf is deprecated: Use helper/retry package instead. This is required for migrating acceptance testing to terraform-plugin-testing. (staticcheck)
			stateConf := &resource.StateChangeConf{
			              ^
triton/resource_machine.go:899:17: SA1019: resource.StateChangeConf is deprecated: Use helper/retry package instead. This is required for migrating acceptance testing to terraform-plugin-testing. (staticcheck)
		stateConf := &resource.StateChangeConf{
		              ^
triton/resource_machine.go:961:17: SA1019: resource.StateChangeConf is deprecated: Use helper/retry package instead. This is required for migrating acceptance testing to terraform-plugin-testing. (staticcheck)
		stateConf := &resource.StateChangeConf{
		              ^
triton/resource_machine.go:1007:16: SA1019: resource.StateChangeConf is deprecated: Use helper/retry package instead. This is required for migrating acceptance testing to terraform-plugin-testing. (staticcheck)
	stateConf := &resource.StateChangeConf{
	              ^
triton/resource_snapshot.go:83:16: SA1019: resource.StateChangeConf is deprecated: Use helper/retry package instead. This is required for migrating acceptance testing to terraform-plugin-testing. (staticcheck)
	stateConf := &resource.StateChangeConf{
	              ^
triton/resource_volume.go:131:16: SA1019: resource.StateChangeConf is deprecated: Use helper/retry package instead. This is required for migrating acceptance testing to terraform-plugin-testing. (staticcheck)
	stateConf := &resource.StateChangeConf{
	              ^
triton/resource_volume.go:234:17: SA1019: resource.StateChangeConf is deprecated: Use helper/retry package instead. This is required for migrating acceptance testing to terraform-plugin-testing. (staticcheck)
		stateConf := &resource.StateChangeConf{
		              ^
triton/resource_volume.go:279:16: SA1019: resource.StateChangeConf is deprecated: Use helper/retry package instead. This is required for migrating acceptance testing to terraform-plugin-testing. (staticcheck)
	stateConf := &resource.StateChangeConf{
	              ^
triton/tritonerr.go:15:9: SA1019: resource.Retry is deprecated: Use helper/retry package instead. This is required for migrating acceptance testing to terraform-plugin-testing. (staticcheck)
	err := resource.Retry(2*time.Minute, func() *resource.RetryError {
	       ^
triton/tritonerr.go:20:12: SA1019: resource.RetryableError is deprecated: Use helper/retry package instead. This is required for migrating acceptance testing to terraform-plugin-testing. (staticcheck)
				return resource.RetryableError(err)
				       ^
triton/tritonerr.go:22:11: SA1019: resource.NonRetryableError is deprecated: Use helper/retry package instead. This is required for migrating acceptance testing to terraform-plugin-testing. (staticcheck)
			return resource.NonRetryableError(err)
			       ^
45 issues:
* staticcheck: 45
make: *** [GNUmakefile:16: lint] Error 1

Comments (1)

Jhonas Wernery commented on 2025-09-02T10:57:52.846-0400:

Testing notes:

make lint passes:

❯ make lint
golangci-lint run
0 issues.

Acceptance tests pass:

❯ make testacc
golangci-lint run
0 issues.
TF_ACC=1 go test ./... -v  -timeout 120m
?   	github.com/TritonDataCenter/terraform-provider-triton	[no test files]
=== RUN   TestAccTritonAccount
--- PASS: TestAccTritonAccount (5.21s)
=== RUN   TestAccTritonDataCenter
--- PASS: TestAccTritonDataCenter (5.00s)
=== RUN   TestAccTritonFabricNetwork_MissingArguments
--- PASS: TestAccTritonFabricNetwork_MissingArguments (0.11s)
=== RUN   TestAccTritonFabricNetwork_BadArguments
--- PASS: TestAccTritonFabricNetwork_BadArguments (0.11s)
=== RUN   TestAccTritonFabricNetwork_NotFound
--- PASS: TestAccTritonFabricNetwork_NotFound (8.01s)
=== RUN   TestAccTritonFabricNetwork_Basic
--- PASS: TestAccTritonFabricNetwork_Basic (22.48s)
=== RUN   TestAccTritonFabricVLAN_MissingArguments
--- PASS: TestAccTritonFabricVLAN_MissingArguments (0.34s)
=== RUN   TestAccTritonFabricVLAN_BadArguments
--- PASS: TestAccTritonFabricVLAN_BadArguments (0.11s)
=== RUN   TestAccTritonFabricVLAN_Basic
--- PASS: TestAccTritonFabricVLAN_Basic (12.22s)
=== RUN   TestAccTritonFabricVLAN_WildCard
--- PASS: TestAccTritonFabricVLAN_WildCard (13.00s)
=== RUN   TestAccTritonFabricVLAN_Filters
--- PASS: TestAccTritonFabricVLAN_Filters (13.55s)
=== RUN   TestAccTritonFabricVLAN_NotFound
--- PASS: TestAccTritonFabricVLAN_NotFound (0.98s)
=== RUN   TestAccTritonFabricVLAN_FiltersNotFound
--- PASS: TestAccTritonFabricVLAN_FiltersNotFound (8.74s)
=== RUN   TestAccTritonFabricVLAN_MultipleFound
--- PASS: TestAccTritonFabricVLAN_MultipleFound (8.47s)
=== RUN   TestAccTritonImage_multipleResults
--- PASS: TestAccTritonImage_multipleResults (0.91s)
=== RUN   TestAccTritonImage_noResults
--- PASS: TestAccTritonImage_noResults (0.92s)
=== RUN   TestAccTritonImage_mostRecent
--- PASS: TestAccTritonImage_mostRecent (4.98s)
=== RUN   TestAccTritonImage_nameVersionAndMostRecent
--- PASS: TestAccTritonImage_nameVersionAndMostRecent (5.08s)
=== RUN   TestAccTritonNetwork_Basic
--- PASS: TestAccTritonNetwork_Basic (14.94s)
=== RUN   TestAccTritonNetwork_NotFound
--- PASS: TestAccTritonNetwork_NotFound (1.34s)
=== RUN   TestAccTritonPackage_basic
--- PASS: TestAccTritonPackage_basic (5.38s)
=== RUN   TestAccTritonDataVolume_basic
--- PASS: TestAccTritonDataVolume_basic (94.51s)
=== RUN   TestAccTritonDataVolume_noResults
--- PASS: TestAccTritonDataVolume_noResults (1.11s)
=== RUN   TestAccTritonDataVolume_BadSize
--- PASS: TestAccTritonDataVolume_BadSize (0.11s)
=== RUN   TestProvider
--- PASS: TestProvider (0.00s)
=== RUN   TestFabricMigrateState
--- PASS: TestFabricMigrateState (0.00s)
=== RUN   TestAccTritonFabric_basic
--- PASS: TestAccTritonFabric_basic (25.22s)
=== RUN   TestAccTritonFirewallRule_basic
--- PASS: TestAccTritonFirewallRule_basic (10.08s)
=== RUN   TestAccTritonFirewallRule_update
--- PASS: TestAccTritonFirewallRule_update (13.87s)
=== RUN   TestAccTritonFirewallRule_enable
--- PASS: TestAccTritonFirewallRule_enable (14.66s)
=== RUN   TestAccTritonFirewallRule_heredoc
--- PASS: TestAccTritonFirewallRule_heredoc (6.70s)
=== RUN   TestAccTritonKey_basic
--- PASS: TestAccTritonKey_basic (23.14s)
=== RUN   TestAccTritonKey_noKeyName
--- PASS: TestAccTritonKey_noKeyName (21.59s)
=== RUN   TestAccTritonMachine_basic
--- PASS: TestAccTritonMachine_basic (113.57s)
=== RUN   TestAccTritonMachine_affinity
--- PASS: TestAccTritonMachine_affinity (136.90s)
=== RUN   TestAccTritonMachine_dns
--- PASS: TestAccTritonMachine_dns (110.54s)
=== RUN   TestAccTritonMachine_nic
--- PASS: TestAccTritonMachine_nic (114.29s)
=== RUN   TestAccTritonMachine_addNIC
--- PASS: TestAccTritonMachine_addNIC (332.83s)
=== RUN   TestAccTritonMachine_firewall
--- PASS: TestAccTritonMachine_firewall (119.78s)
=== RUN   TestAccTritonMachine_metadata
--- PASS: TestAccTritonMachine_metadata (232.06s)
=== RUN   TestAccTritonMachine_cns
--- PASS: TestAccTritonMachine_cns (154.22s)
=== RUN   TestAccTritonMachine_locality
--- PASS: TestAccTritonMachine_locality (226.50s)
=== RUN   TestAccTritonMachine_deletionProtection
--- PASS: TestAccTritonMachine_deletionProtection (119.45s)
=== RUN   TestAccTritonMachine_volume
--- PASS: TestAccTritonMachine_volume (159.96s)
=== RUN   TestAccTritonSnapshot_basic
--- PASS: TestAccTritonSnapshot_basic (129.89s)
=== RUN   TestAccTritonVLAN_basic
--- PASS: TestAccTritonVLAN_basic (8.52s)
=== RUN   TestAccTritonVLAN_update
--- PASS: TestAccTritonVLAN_update (13.77s)
=== RUN   TestAccTritonVolume_basic
--- PASS: TestAccTritonVolume_basic (95.09s)
=== RUN   TestAccTritonVolume_singleNetwork
--- PASS: TestAccTritonVolume_singleNetwork (87.98s)
=== RUN   TestWildcardMatch
--- PASS: TestWildcardMatch (0.00s)
=== RUN   TestValidateVLANIdentifier
--- PASS: TestValidateVLANIdentifier (0.00s)
PASS
ok  	github.com/TritonDataCenter/terraform-provider-triton/triton	2593.601s

Related Links