Skip to content

Commit 9587b11

Browse files
builder: remove instances of confighelper.Trilean
Since most of those instances of confighelper were not necessary as there is not a config package, nor is there local name conflicts as well, we can remove those instaces, especially the one from Config as it caused the (fragile) typechecks from the SDK to not render it as a boolean in the web docs otherwise.
1 parent 3c9034f commit 9587b11

15 files changed

Lines changed: 30 additions & 31 deletions

File tree

.web-docs/components/builder/ebs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ JSON example:
519519

520520
<!-- Code generated from the comments of the RunConfig struct in builder/common/run_config.go; DO NOT EDIT MANUALLY -->
521521

522-
- `associate_public_ip_address` (confighelper.Trilean) - If using a non-default VPC,
522+
- `associate_public_ip_address` (boolean) - If using a non-default VPC,
523523
public IP addresses are not provided by default. If this is true, your
524524
new instance will get a Public IP. default: unset
525525

.web-docs/components/builder/ebssurrogate/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ JSON example:
530530

531531
<!-- Code generated from the comments of the RunConfig struct in builder/common/run_config.go; DO NOT EDIT MANUALLY -->
532532

533-
- `associate_public_ip_address` (confighelper.Trilean) - If using a non-default VPC,
533+
- `associate_public_ip_address` (boolean) - If using a non-default VPC,
534534
public IP addresses are not provided by default. If this is true, your
535535
new instance will get a Public IP. default: unset
536536

.web-docs/components/builder/ebsvolume/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concept
484484

485485
<!-- Code generated from the comments of the RunConfig struct in builder/common/run_config.go; DO NOT EDIT MANUALLY -->
486486

487-
- `associate_public_ip_address` (confighelper.Trilean) - If using a non-default VPC,
487+
- `associate_public_ip_address` (boolean) - If using a non-default VPC,
488488
public IP addresses are not provided by default. If this is true, your
489489
new instance will get a Public IP. default: unset
490490

.web-docs/components/builder/instance/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ JSON example:
517517

518518
<!-- Code generated from the comments of the RunConfig struct in builder/common/run_config.go; DO NOT EDIT MANUALLY -->
519519

520-
- `associate_public_ip_address` (confighelper.Trilean) - If using a non-default VPC,
520+
- `associate_public_ip_address` (boolean) - If using a non-default VPC,
521521
public IP addresses are not provided by default. If this is true, your
522522
new instance will get a Public IP. default: unset
523523

builder/chroot/step_create_volume_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
"github.com/aws/aws-sdk-go/aws"
1010
"github.com/aws/aws-sdk-go/service/ec2"
11-
confighelper "github.com/hashicorp/packer-plugin-sdk/template/config"
11+
"github.com/hashicorp/packer-plugin-sdk/template/config"
1212
"github.com/stretchr/testify/assert"
1313
)
1414

@@ -79,17 +79,17 @@ func TestCreateVolume_gp2_to_io1(t *testing.T) {
7979
}
8080

8181
func TestCreateVolume_Encrypted(t *testing.T) {
82-
stepCreateVolume := StepCreateVolume{RootVolumeEncryptBoot: confighelper.TrileanFromBool(true)}
82+
stepCreateVolume := StepCreateVolume{RootVolumeEncryptBoot: config.TrileanFromBool(true)}
8383
testRootDevice := buildTestRootDevice()
8484
ret, err := stepCreateVolume.buildCreateVolumeInput("test-az", testRootDevice)
8585
assert.NoError(t, err)
8686
// Ensure that the new value is equal to the the value passed in
87-
assert.Equal(t, confighelper.TrileanFromBool(*ret.Encrypted), stepCreateVolume.RootVolumeEncryptBoot)
87+
assert.Equal(t, config.TrileanFromBool(*ret.Encrypted), stepCreateVolume.RootVolumeEncryptBoot)
8888
}
8989

9090
func TestCreateVolume_Custom_KMS_Key_Encrypted(t *testing.T) {
9191
stepCreateVolume := StepCreateVolume{
92-
RootVolumeEncryptBoot: confighelper.TrileanFromBool(true),
92+
RootVolumeEncryptBoot: config.TrileanFromBool(true),
9393
RootVolumeKmsKeyId: "alias/1234",
9494
}
9595
testRootDevice := buildTestRootDevice()

builder/chroot/step_register_ami.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ import (
1313
"github.com/hashicorp/packer-plugin-sdk/multistep"
1414
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
1515
"github.com/hashicorp/packer-plugin-sdk/random"
16-
confighelper "github.com/hashicorp/packer-plugin-sdk/template/config"
16+
"github.com/hashicorp/packer-plugin-sdk/template/config"
1717
)
1818

1919
// StepRegisterAMI creates the AMI.
2020
type StepRegisterAMI struct {
2121
PollingConfig *awscommon.AWSPollingConfig
2222
RootVolumeSize int64
23-
EnableAMIENASupport confighelper.Trilean
23+
EnableAMIENASupport config.Trilean
2424
EnableAMISriovNetSupport bool
2525
AMISkipBuildRegion bool
2626
BootMode string

builder/common/run_config.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616

1717
"github.com/hashicorp/packer-plugin-sdk/communicator"
1818
"github.com/hashicorp/packer-plugin-sdk/template/config"
19-
confighelper "github.com/hashicorp/packer-plugin-sdk/template/config"
2019
"github.com/hashicorp/packer-plugin-sdk/template/interpolate"
2120
"github.com/hashicorp/packer-plugin-sdk/uuid"
2221
)
@@ -134,7 +133,7 @@ type RunConfig struct {
134133
// `ec2:DescribeInstanceTypeOfferings` action to the role running the build.
135134
// Otherwise, Packer will pick the most available subnet in the VPC selected,
136135
// which may not be able to host the instance type you provided.
137-
AssociatePublicIpAddress confighelper.Trilean `mapstructure:"associate_public_ip_address" required:"false"`
136+
AssociatePublicIpAddress config.Trilean `mapstructure:"associate_public_ip_address" required:"false"`
138137
// Destination availability zone to launch
139138
// instance in. Leave this empty to allow Amazon to auto-assign.
140139
AvailabilityZone string `mapstructure:"availability_zone" required:"false"`

builder/common/step_modify_ebs_instance.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import (
1212
"github.com/aws/aws-sdk-go/service/ec2/ec2iface"
1313
"github.com/hashicorp/packer-plugin-sdk/multistep"
1414
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
15-
confighelper "github.com/hashicorp/packer-plugin-sdk/template/config"
15+
"github.com/hashicorp/packer-plugin-sdk/template/config"
1616
)
1717

1818
type StepModifyEBSBackedInstance struct {
1919
Skip bool
20-
EnableAMIENASupport confighelper.Trilean
20+
EnableAMIENASupport config.Trilean
2121
EnableAMISriovNetSupport bool
2222
}
2323

@@ -50,7 +50,7 @@ func (s *StepModifyEBSBackedInstance) Run(ctx context.Context, state multistep.S
5050

5151
// Handle EnaSupport flag.
5252
// As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge
53-
if s.EnableAMIENASupport != confighelper.TriUnset {
53+
if s.EnableAMIENASupport != config.TriUnset {
5454
var prefix string
5555
if s.EnableAMIENASupport.True() {
5656
prefix = "En"

builder/common/step_network_info.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"github.com/aws/aws-sdk-go/service/ec2/ec2iface"
1616
"github.com/hashicorp/packer-plugin-sdk/multistep"
1717
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
18-
confighelper "github.com/hashicorp/packer-plugin-sdk/template/config"
18+
"github.com/hashicorp/packer-plugin-sdk/template/config"
1919
)
2020

2121
// StepNetworkInfo queries AWS for information about
@@ -31,7 +31,7 @@ type StepNetworkInfo struct {
3131
VpcFilter VpcFilterOptions
3232
SubnetId string
3333
SubnetFilter SubnetFilterOptions
34-
AssociatePublicIpAddress confighelper.Trilean
34+
AssociatePublicIpAddress config.Trilean
3535
AvailabilityZone string
3636
SecurityGroupIds []string
3737
SecurityGroupFilter SecurityGroupFilterOptions
@@ -152,7 +152,7 @@ func (s *StepNetworkInfo) Run(ctx context.Context, state multistep.StateBag) mul
152152

153153
// Set VPC/Subnet if we explicitely enable or disable public IP assignment to the instance
154154
// and we did not set or get a subnet ID before
155-
if s.AssociatePublicIpAddress != confighelper.TriUnset && s.SubnetId == "" {
155+
if s.AssociatePublicIpAddress != config.TriUnset && s.SubnetId == "" {
156156
err := s.GetDefaultVPCAndSubnet(ui, ec2conn, state)
157157
if err != nil {
158158
ui.Say("associate_public_ip_address is set without a subnet_id.")

builder/common/step_run_source_instance.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ import (
2020
"github.com/hashicorp/packer-plugin-sdk/multistep"
2121
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
2222
"github.com/hashicorp/packer-plugin-sdk/retry"
23-
confighelper "github.com/hashicorp/packer-plugin-sdk/template/config"
23+
"github.com/hashicorp/packer-plugin-sdk/template/config"
2424
"github.com/hashicorp/packer-plugin-sdk/template/interpolate"
2525
)
2626

2727
type StepRunSourceInstance struct {
2828
PollingConfig *AWSPollingConfig
29-
AssociatePublicIpAddress confighelper.Trilean
29+
AssociatePublicIpAddress config.Trilean
3030
LaunchMappings EC2BlockDeviceMappingsBuilder
3131
CapacityReservationPreference string
3232
CapacityReservationId string
@@ -217,7 +217,7 @@ func (s *StepRunSourceInstance) Run(ctx context.Context, state multistep.StateBa
217217

218218
subnetId := state.Get("subnet_id").(string)
219219

220-
if subnetId != "" && s.AssociatePublicIpAddress != confighelper.TriUnset {
220+
if subnetId != "" && s.AssociatePublicIpAddress != config.TriUnset {
221221
ui.Say(fmt.Sprintf("changing public IP address config to %t for instance on subnet %q",
222222
*s.AssociatePublicIpAddress.ToBoolPointer(),
223223
subnetId))

0 commit comments

Comments
 (0)