Repository navigation
chore: consolidate mechanical syntax and style cleanups - #377
Merged
Merged
Conversation
Reorganize `go.mod` to match current Go module formatting: - Moves the `go` directive near the top. - Consolidates `require` blocks, and separate direct vs indirect dependencies consistently. This is a structural cleanup of dependency declarations without introducing functional code changes. Signed-off-by: Ryan Johnson <ryan@tenthirtyam.org>
Go 1.20+ automatically seeds the global random number generator, making the manual `rand.Seed(time.Now().UTC().UnixNano())` call in `init() `unnecessary. Removes the `init `function along with its unused imports and the now-obsolete `TestPluginServerRandom` test. Signed-off-by: Ryan Johnson <ryan@tenthirtyam.org>
`reflect.Ptr` is marked `//go:fix inline` to `Pointer`; use the canonical Kind name in the test helper switch. Signed-off-by: Ryan Johnson <ryan@tenthirtyam.org>
Add no-op `default` branches with clarifying comments in two reflection-based switch statements (`structTypes` and `renderWalker.Exit`). The compiler does not require exhaustive switches, but unlisted `reflectwalk.Location` and `reflect.Kind `values were left implicit. This documents intentional handling for non-container kinds and keeps the switch logic explicit without changing behavior. Signed-off-by: Ryan Johnson <ryan@tenthirtyam.org>
`encoding/json` treats struct values as never empty, so `json:",omitempty"` on the embedded `OnlyExcept` field in `PostProcessor` and `Provisioner` has no effect. Removes the misleading tags; `OnlyExcept `already applies `omitempty` to its `Only` and `Except` slice fields, and JSON output is unchanged. Signed-off-by: Ryan Johnson <ryan@tenthirtyam.org>
This refactor renames several local variables that were shadowing imported package names or using ambiguous names (for example `structtag`, `path`, `uuid`, and `errors`). It improves readability and avoids confusion in helper methods and tests without changing behavior. Signed-off-by: Ryan Johnson <ryan@tenthirtyam.org>
Removes unnecessary `else` clauses after terminating statements. Signed-off-by: Ryan Johnson <ryan@tenthirtyam.org>
Prefer American English spellings (`-ize`, single `-l-`, `-or`) and "different from", while keeping the public `StateCancelled` key and deprecated option names. Ref: https://www.merriam-webster.com/grammar/canceled-or-cancelled Signed-off-by: Ryan Johnson <ryan@tenthirtyam.org>
Modernize Go type declarations by using the equivalent `any` alias throughout the SDK. Reports type declarations that use interface{} and can be simplified by using `any` since `any` is an alias for `interface{}`.
Signed-off-by: Ryan Johnson <ryan@tenthirtyam.org>
This was referenced Nov 12, 2026
There was a problem hiding this comment.
🟢 Approval recommended
The review reports no active issues requiring changes.
No open issues 🎉
What changed in this PR
Consolidates mechanical cleanups across the Packer Plugin SDK, its tooling, and tests to reduce merge churn. Lifecycle, concurrency, and error-matching changes remain in separate PRs.
Changes:
- Modernizes Go syntax with
any,reflect.Pointer, simpler return paths, and removal of manual random seeding. - Clarifies local names, normalizes American English spelling, and removes ineffective JSON tags.
- Reorganizes root module declarations without changing versions; separately updates fixer fixture dependencies and adds fixture checksums.
| File | Description |
|---|---|
template/template.hcl2spec.go |
Uses any in generated configuration maps. |
template/template.go |
Uses any and removes ineffective embedded JSON tags. |
template/parse.go |
Uses any throughout template parsing. |
template/parse_test.go |
Updates test inputs to any. |
template/interpolate/render.go |
Uses any and documents the no-op switch default. |
template/interpolate/render_test.go |
Updates rendering fixtures to any. |
template/interpolate/i.go |
Uses any for interpolation context data. |
template/interpolate/funcs.go |
Uses any and simplifies a return branch. |
template/interpolate/funcs_test.go |
Updates interpolation fixtures to any. |
template/interpolate/aws/secretsmanager/secretsmanager.go |
Uses any for decoded secret values. |
template/funcs.go |
Uses any in the Vault data assertion. |
template/config/decode.go |
Uses any in decoding APIs and hooks. |
template/config/decode_test.go |
Updates decoding fixtures to any. |
template/config/custom_types.go |
Removes a redundant return branch. |
shell-local/run.go |
Uses any for generated data. |
shell-local/config.go |
Uses any in configuration fields and decoding. |
sdk-internals/communicator/ssh/password_test.go |
Uses any in an interface assertion test. |
sdk-internals/communicator/ssh/communicator.go |
Removes redundant else branches. |
sdk-internals/communicator/ssh/communicator_test.go |
Uses any in an interface assertion test. |
sdk-internals/communicator/none/communicator_test.go |
Uses any in an interface assertion test. |
rpc/ui.go |
Uses any for UI RPC arguments and replies. |
rpc/ui_progress_tracking.go |
Uses any for progress RPC arguments and replies. |
rpc/provisioner.go |
Uses any and normalizes cancellation logs. |
rpc/provisioner_test.go |
Updates RPC test data to any. |
rpc/post_processor.go |
Uses any and normalizes cancellation logs. |
rpc/post_processor_test.go |
Updates mocks and assertions to any. |
rpc/init.go |
Uses []any in gob registration. |
rpc/hook.go |
Uses any and normalizes cancellation logs. |
rpc/fileinfo.go |
Uses any for Sys. |
rpc/fileinfo_test.go |
Updates the file-info mock to any. |
rpc/datasource.go |
Uses any and normalizes deserialization messages. |
rpc/datasource_test.go |
Updates datasource mocks and fixtures to any. |
rpc/cty_encode.go |
Uses []any in encoding helpers. |
rpc/convert.go |
Normalizes spelling in a comment. |
rpc/communicator.go |
Uses any for communicator RPC replies. |
rpc/communicator_test.go |
Uses any in an interface assertion test. |
rpc/common.go |
Uses any and normalizes serialization wording. |
rpc/client.go |
Normalizes spelling in a comment. |
rpc/builder.go |
Uses any and normalizes cancellation logs. |
rpc/builder_test.go |
Uses any and normalizes cancellation identifiers. |
rpc/build.go |
Uses any and normalizes cancellation logs. |
rpc/build_test.go |
Uses any and simplifies a return branch. |
rpc/artifact.go |
Uses any in artifact RPC methods. |
retry/utils_test.go |
Uses any, reflect.Pointer, and an explicit default. |
retry/retry.go |
Normalizes cancellation spelling in documentation. |
retry/retry_test.go |
Normalizes cancellation names and test labels. |
plugin/set.go |
Normalizes serialization spelling in documentation. |
plugin/server.go |
Removes manual random seeding and unused imports. |
plugin/server_test.go |
Removes the obsolete random-seeding test. |
pathing/config_file.go |
Adjusts comment wording only. |
packerbuilderdata/generated_data.go |
Uses any for generated data storage. |
packerbuilderdata/generated_data_test.go |
Updates the generated-data assertion to any. |
packer/registry/image/image.go |
Uses any in image conversion APIs. |
packer/registry/image/image_test.go |
Updates image fixtures and callbacks to any. |
packer/registry/image/frommappeddata_example_test.go |
Updates example signatures to any. |
packer/registry/image/fromartifact_example_test.go |
Updates example signatures and maps to any. |
packer/provisioner.go |
Uses any in the provisioner interface. |
packer/provisioner_mock.hcl2spec.go |
Uses []any in the generated mock configuration. |
packer/provisioner_mock.go |
Updates mock fields and methods to any. |
packer/post_processor.go |
Uses any and normalizes a cancellation comment. |
packer/multi_error_test.go |
Uses any and avoids shadowing errors. |
packer/hook.go |
Uses any in hook interfaces and dispatch. |
packer/hook_test.go |
Uses any and normalizes a cancellation comment. |
packer/hook_mock.go |
Uses any in the hook mock. |
packer/datasource.go |
Uses any in the datasource interface. |
packer/datasource_mock.go |
Uses any in datasource mock configuration. |
packer/communicator.go |
Uses any and normalizes a cancellation comment. |
packer/communicator_mock_test.go |
Uses any in an interface assertion test. |
packer/builder.go |
Uses any in the builder interface. |
packer/builder_mock.hcl2spec.go |
Uses []any in the generated mock configuration. |
packer/builder_mock.go |
Updates builder mock fields and methods to any. |
packer/build.go |
Normalizes cancellation spelling in documentation. |
packer/artifact.go |
Uses any for artifact state. |
packer/artifact_test.go |
Uses any in the test artifact. |
packer/artifact_mock.go |
Uses any in mock artifact state. |
net/configure_port.go |
Normalizes cancellation spelling in documentation. |
multistep/statebag.go |
Uses any in state storage APIs. |
multistep/statebag_test.go |
Uses any in an interface assertion test. |
multistep/multistep.go |
Normalizes comments while retaining the public cancellation key. |
multistep/multistep_test.go |
Updates the internal cancellation state name. |
multistep/doc.go |
Normalizes cancellation spelling in documentation. |
multistep/debug_runner_test.go |
Uses any and normalizes cancellation names. |
multistep/commonsteps/step_provision.go |
Uses any and normalizes cancellation logs. |
multistep/commonsteps/step_provision_test.go |
Updates test data and assertions to any. |
multistep/commonsteps/step_output_dir.go |
Renames a local cancellation flag. |
multistep/commonsteps/step_output_dir_test.go |
Normalizes a test name. |
multistep/commonsteps/step_http_server.go |
Renames a local variable that shadows path. |
multistep/commonsteps/step_http_server_test.go |
Uses any for expected port values. |
multistep/commonsteps/step_download.go |
Normalizes cancellation error spelling. |
multistep/commonsteps/step_create_floppy.go |
Clarifies path variable and parameter names. |
multistep/commonsteps/step_create_floppy_test.go |
Uses any and clarifies a filename variable. |
multistep/commonsteps/step_create_cdrom_test.go |
Uses any in an interface assertion test. |
multistep/commonsteps/multistep_runner.go |
Simplifies runner selection and uses any. |
multistep/basic_runner.go |
Renames the internal cancellation state. |
multistep/basic_runner_test.go |
Uses any and normalizes cancellation names. |
json/unmarshal.go |
Uses any for the decode target. |
hcl2helper/values.go |
Uses any and normalizes comment spelling. |
hcl2helper/values_test.go |
Updates conversion fixtures to any. |
guestexec/elevated.go |
Renames a variable that shadows uuid. |
guestexec/elevated_test.go |
Updates configuration fixtures to any. |
go.mod |
Reorganizes declarations without changing dependency versions. |
communicator/step_connect.go |
Normalizes a cancellation variable and comment. |
communicator/step_connect_winrm.go |
Normalizes cancellation comments, logs, and errors. |
communicator/step_connect_ssh.go |
Normalizes cancellation comments, logs, and errors. |
communicator/sshkey/generate.go |
Uses any for key inputs. |
communicator/config.go |
Uses any and normalizes comment spelling. |
cmd/packer-sdc/internal/renderdocs/renderdocs.go |
Renames the local flag-set variable. |
cmd/packer-sdc/internal/renderdocs/docs-partials/packer-plugin-sdk/communicator/SSHInterface-not-required.mdx |
Normalizes spelling in rendered documentation. |
cmd/packer-sdc/internal/mapstructure-to-hcl2/mapstructure-to-hcl2.go |
Uses any and avoids shadowing structtag. |
cmd/packer-sdc/internal/fix/testdata/unfixed/version/go.sum |
Adds module checksums for the version fixture. |
cmd/packer-sdc/internal/fix/testdata/unfixed/basic/go.sum |
Adds module checksums for the unfixed basic fixture. |
cmd/packer-sdc/internal/fix/testdata/missing-requires/packer-plugin-sdk/go.sum |
Adds checksums for the missing-SDK fixture. |
cmd/packer-sdc/internal/fix/testdata/missing-requires/packer-plugin-sdk/go.mod |
Updates the fixture’s go-cmp version. |
cmd/packer-sdc/internal/fix/testdata/missing-requires/go-cty/go.sum |
Adds checksums for the missing-cty fixture. |
cmd/packer-sdc/internal/fix/testdata/missing-requires/go-cty/go.mod |
Updates fixture dependency versions. |
cmd/packer-sdc/internal/fix/testdata/missing-requires/both/go.sum |
Adds checksums for the missing-both fixture. |
cmd/packer-sdc/internal/fix/testdata/fixed/basic/go.sum |
Adds checksums for the fixed basic fixture. |
chroot/step_mount_extra_test.go |
Uses any in an interface assertion test. |
chroot/step_copy_files_test.go |
Uses any in an interface assertion test. |
chroot/communicator_test.go |
Uses any in an interface assertion test. |
bootcommand/boot_command_ast.go |
Uses []any and normalizes a cancellation comment. |
adapter/scp.go |
Uses any for file-info Sys. |
acctest/provisioneracc/provisioners.go |
Removes a redundant cleanup else branch. |
acctest/pluginacc.go |
Uses any and removes redundant cleanup branches. |
Review effort: Balanced
tanmay-hc
approved these changes
Nov 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Consolidates the mechanical syntax and style cleanups into a single PR, as requested, to reduce review overhead and merge churn.
This PR cherry-picks the following changes as separate commits:
go.moddependency declarations #368 tidygo.moddependency declarations (godirective at the top; direct vs indirectrequireblocks). Versions andgo.sumare unchanged.rand.Seedfrom plugin server init #361 remove deprecatedrand.Seedfrom plugin server initreflect.Pointerover deprecatedPtralias #357 preferreflect.Pointerover the deprecatedPtraliasdefaultbranches in reflect switch blocksomitemptyon nestedOnlyExceptfieldsstateCancellingand updates a few log and error strings (for exampleSSH wait cancelled).interface{}withanyThese PRs remain open for individual review of lifecycle, concurrency, and error-matching implications:
scpUploadStatemethods #366 pointer receivers onscpUploadStateerrors.As/Isfor idiomatic error checks #363errors.As/errors.Isfor idiomatic error checksThe folded PRs will be closed in favor of this one.
Rollback Plan
Revert commit.
Changes to Security Controls
None.