Skip to content

Conversation

@atombrella
Copy link
Contributor

@atombrella atombrella commented Jan 11, 2026

Description

  • Remove a few redundant else-branches. Found a bit by random with search to check for return or t.Fatalf as the last call in the if-branch.
  • Remove unneeded assignment in for-loops.
  • Use for range instead of the for i := 0; ... syntax. GoLang 1.22 added support for it. It's marginally faster.
  • Use slices.Contains instead of for-loop
  • Add MinimumTlsVersion a couple of places. This was highlighted by gosec. The affected test-function contains deprecated function use. I didn't want to make an effort updating the tests.
➜ make test                 
?   	github.com/hashicorp/packer-plugin-azure	[no test files]
ok  	github.com/hashicorp/packer-plugin-azure/builder/azure/arm	40.376s
ok  	github.com/hashicorp/packer-plugin-azure/builder/azure/chroot	1.144s
ok  	github.com/hashicorp/packer-plugin-azure/builder/azure/common	1.084s
?   	github.com/hashicorp/packer-plugin-azure/builder/azure/common/cli	[no test files]
ok  	github.com/hashicorp/packer-plugin-azure/builder/azure/common/client	2.687s
?   	github.com/hashicorp/packer-plugin-azure/builder/azure/common/constants	[no test files]
?   	github.com/hashicorp/packer-plugin-azure/builder/azure/common/log	[no test files]
?   	github.com/hashicorp/packer-plugin-azure/builder/azure/common/logutil	[no test files]
ok  	github.com/hashicorp/packer-plugin-azure/builder/azure/common/template	1.270s
ok  	github.com/hashicorp/packer-plugin-azure/builder/azure/dtl	7.614s
ok  	github.com/hashicorp/packer-plugin-azure/builder/azure/pkcs12	6.526s
ok  	github.com/hashicorp/packer-plugin-azure/builder/azure/pkcs12/rc2	1.023s
ok  	github.com/hashicorp/packer-plugin-azure/datasource/keyvaultsecret	1.070s
?   	github.com/hashicorp/packer-plugin-azure/provisioner/azure-dtlartifact	[no test files]
ok  	github.com/hashicorp/packer-plugin-azure/version	1.028s

Resolved Issues

If your PR resolves any open issue(s), please indicate them like this so they will be closed when your PR is merged:

Closes #xxx
Closes #xxx

Rollback Plan

If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

* Remove a few redundant else-branches
* Use for range
* Use slices.Contains instead of for-loop
* Add MinimumTlsVersion a couple of places
*
@atombrella atombrella requested a review from a team as a code owner January 11, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant