From 6eee14aeb6f7d225da518d75a2478c618ae44fa0 Mon Sep 17 00:00:00 2001 From: "Rodrigo C. Moraes" Date: Fri, 10 May 2024 12:16:36 -0300 Subject: [PATCH] format the code --- builder/chroot/step_attach_volume.go | 5 +-- builder/chroot/step_create_volume.go | 3 +- builder/chroot/step_flock.go | 3 +- builder/chroot/step_mount_device.go | 5 +-- builder/chroot/step_snapshot.go | 3 +- builder/common/access_config.go | 34 +++++++++++-------- builder/common/awserrors/utils.go | 6 ++-- builder/common/block_device.go | 25 ++++++++------ builder/common/state.go | 20 ++++++----- builder/common/step_network_info.go | 7 ++-- builder/common/step_pre_validate.go | 1 - builder/common/step_pre_validate_test.go | 2 +- builder/common/step_source_ami_info.go | 3 +- builder/ebssurrogate/step_snapshot_volumes.go | 3 +- 14 files changed, 69 insertions(+), 51 deletions(-) diff --git a/builder/chroot/step_attach_volume.go b/builder/chroot/step_attach_volume.go index cb0223efd..13c329285 100644 --- a/builder/chroot/step_attach_volume.go +++ b/builder/chroot/step_attach_volume.go @@ -16,8 +16,9 @@ import ( // available device location. // // Produces: -// device string - The location where the volume was attached. -// attach_cleanup CleanupFunc +// +// device string - The location where the volume was attached. +// attach_cleanup CleanupFunc type StepAttachVolume struct { PollingConfig *awscommon.AWSPollingConfig attached bool diff --git a/builder/chroot/step_create_volume.go b/builder/chroot/step_create_volume.go index b99636c19..6797bac2e 100644 --- a/builder/chroot/step_create_volume.go +++ b/builder/chroot/step_create_volume.go @@ -19,7 +19,8 @@ import ( // device of the AMI. // // Produces: -// volume_id string - The ID of the created volume +// +// volume_id string - The ID of the created volume type StepCreateVolume struct { PollingConfig *awscommon.AWSPollingConfig volumeId string diff --git a/builder/chroot/step_flock.go b/builder/chroot/step_flock.go index ada3b53fd..b55a5b2a8 100644 --- a/builder/chroot/step_flock.go +++ b/builder/chroot/step_flock.go @@ -14,7 +14,8 @@ import ( // StepFlock provisions the instance within a chroot. // // Produces: -// flock_cleanup Cleanup - To perform early cleanup +// +// flock_cleanup Cleanup - To perform early cleanup type StepFlock struct { fh *os.File } diff --git a/builder/chroot/step_mount_device.go b/builder/chroot/step_mount_device.go index 201dfd0c7..2ac664106 100644 --- a/builder/chroot/step_mount_device.go +++ b/builder/chroot/step_mount_device.go @@ -24,8 +24,9 @@ type mountPathData struct { // StepMountDevice mounts the attached device. // // Produces: -// mount_path string - The location where the volume was mounted. -// mount_device_cleanup CleanupFunc - To perform early cleanup +// +// mount_path string - The location where the volume was mounted. +// mount_device_cleanup CleanupFunc - To perform early cleanup type StepMountDevice struct { MountOptions []string MountPartition string diff --git a/builder/chroot/step_snapshot.go b/builder/chroot/step_snapshot.go index 4f39f2ffd..85b3dc48f 100644 --- a/builder/chroot/step_snapshot.go +++ b/builder/chroot/step_snapshot.go @@ -14,7 +14,8 @@ import ( // StepSnapshot creates a snapshot of the created volume. // // Produces: -// snapshot_id string - ID of the created snapshot +// +// snapshot_id string - ID of the created snapshot type StepSnapshot struct { PollingConfig *awscommon.AWSPollingConfig snapshotId string diff --git a/builder/common/access_config.go b/builder/common/access_config.go index a88f78de1..c85465b7a 100644 --- a/builder/common/access_config.go +++ b/builder/common/access_config.go @@ -32,26 +32,30 @@ import ( // HCL config example: // // ```HCL -// source "amazon-ebs" "example" { -// assume_role { -// role_arn = "arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME" -// session_name = "SESSION_NAME" -// external_id = "EXTERNAL_ID" -// } -// } +// +// source "amazon-ebs" "example" { +// assume_role { +// role_arn = "arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME" +// session_name = "SESSION_NAME" +// external_id = "EXTERNAL_ID" +// } +// } +// // ``` // // JSON config example: // // ```json -// builder{ -// "type": "amazon-ebs", -// "assume_role": { -// "role_arn" : "arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME", -// "session_name": "SESSION_NAME", -// "external_id" : "EXTERNAL_ID" -// } -// } +// +// builder{ +// "type": "amazon-ebs", +// "assume_role": { +// "role_arn" : "arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME", +// "session_name": "SESSION_NAME", +// "external_id" : "EXTERNAL_ID" +// } +// } +// // ``` type AssumeRoleConfig struct { // Amazon Resource Name (ARN) of the IAM Role to assume. diff --git a/builder/common/awserrors/utils.go b/builder/common/awserrors/utils.go index 676ef9b4a..a504554fc 100644 --- a/builder/common/awserrors/utils.go +++ b/builder/common/awserrors/utils.go @@ -7,9 +7,9 @@ import ( ) // Returns true if the err matches all these conditions: -// * err is of type awserr.Error -// * Error.Code() matches code -// * Error.Message() contains message +// - err is of type awserr.Error +// - Error.Code() matches code +// - Error.Message() contains message func Matches(err error, code string, message string) bool { if err, ok := err.(awserr.Error); ok { return err.Code() == code && strings.Contains(err.Message(), message) diff --git a/builder/common/block_device.go b/builder/common/block_device.go index b2bde0084..ca6eb9f33 100644 --- a/builder/common/block_device.go +++ b/builder/common/block_device.go @@ -33,21 +33,25 @@ const ( // HCL2 example: // // ```hcl -// launch_block_device_mappings { -// device_name = "/dev/sda1" -// encrypted = true -// kms_key_id = "1a2b3c4d-5e6f-1a2b-3c4d-5e6f1a2b3c4d" -// } +// +// launch_block_device_mappings { +// device_name = "/dev/sda1" +// encrypted = true +// kms_key_id = "1a2b3c4d-5e6f-1a2b-3c4d-5e6f1a2b3c4d" +// } +// // ``` // // JSON example: // ```json // "launch_block_device_mappings": [ -// { -// "device_name": "/dev/sda1", -// "encrypted": true, -// "kms_key_id": "1a2b3c4d-5e6f-1a2b-3c4d-5e6f1a2b3c4d" -// } +// +// { +// "device_name": "/dev/sda1", +// "encrypted": true, +// "kms_key_id": "1a2b3c4d-5e6f-1a2b-3c4d-5e6f1a2b3c4d" +// } +// // ] // ``` // @@ -56,7 +60,6 @@ const ( // // Documentation for Block Devices Mappings can be found here: // https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html -// type BlockDevice struct { // Indicates whether the EBS volume is deleted on instance termination. // Default false. NOTE: If this value is not explicitly set to true and diff --git a/builder/common/state.go b/builder/common/state.go index 48b5f0e05..c8afeff95 100644 --- a/builder/common/state.go +++ b/builder/common/state.go @@ -45,18 +45,22 @@ type StateChangeConf struct { // // HCL2 example: // ```hcl -// aws_polling { -// delay_seconds = 30 -// max_attempts = 50 -// } +// +// aws_polling { +// delay_seconds = 30 +// max_attempts = 50 +// } +// // ``` // // JSON example: // ```json -// "aws_polling" : { -// "delay_seconds": 30, -// "max_attempts": 50 -// } +// +// "aws_polling" : { +// "delay_seconds": 30, +// "max_attempts": 50 +// } +// // ``` type AWSPollingConfig struct { // Specifies the maximum number of attempts the waiter will check for resource state. diff --git a/builder/common/step_network_info.go b/builder/common/step_network_info.go index e47c68132..3ce31fb52 100644 --- a/builder/common/step_network_info.go +++ b/builder/common/step_network_info.go @@ -16,9 +16,10 @@ import ( // VPC's and Subnets that is used throughout the AMI creation process. // // Produces (adding them to the state bag): -// vpc_id string - the VPC ID -// subnet_id string - the Subnet ID -// availability_zone string - the AZ name +// +// vpc_id string - the VPC ID +// subnet_id string - the Subnet ID +// availability_zone string - the AZ name type StepNetworkInfo struct { VpcId string VpcFilter VpcFilterOptions diff --git a/builder/common/step_pre_validate.go b/builder/common/step_pre_validate.go index a8a18089c..481e5ea01 100644 --- a/builder/common/step_pre_validate.go +++ b/builder/common/step_pre_validate.go @@ -17,7 +17,6 @@ import ( // StepPreValidate provides an opportunity to pre-validate any configuration for // the build before actually doing any time consuming work -// type StepPreValidate struct { DestAmiName string ForceDeregister bool diff --git a/builder/common/step_pre_validate_test.go b/builder/common/step_pre_validate_test.go index ffaf946f9..8ab7896a2 100644 --- a/builder/common/step_pre_validate_test.go +++ b/builder/common/step_pre_validate_test.go @@ -9,7 +9,7 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" ) -//DescribeVpcs mocks an ec2.DescribeVpcsOutput for a given input +// DescribeVpcs mocks an ec2.DescribeVpcsOutput for a given input func (m *mockEC2Conn) DescribeVpcs(input *ec2.DescribeVpcsInput) (*ec2.DescribeVpcsOutput, error) { if input == nil || aws.StringValue(input.VpcIds[0]) == "" { diff --git a/builder/common/step_source_ami_info.go b/builder/common/step_source_ami_info.go index 200460ca9..66d111db2 100644 --- a/builder/common/step_source_ami_info.go +++ b/builder/common/step_source_ami_info.go @@ -16,7 +16,8 @@ import ( // that is used throughout the AMI creation process. // // Produces: -// source_image *ec2.Image - the source AMI info +// +// source_image *ec2.Image - the source AMI info type StepSourceAMIInfo struct { SourceAmi string EnableAMISriovNetSupport bool diff --git a/builder/ebssurrogate/step_snapshot_volumes.go b/builder/ebssurrogate/step_snapshot_volumes.go index fba4ac444..baf7a0d00 100644 --- a/builder/ebssurrogate/step_snapshot_volumes.go +++ b/builder/ebssurrogate/step_snapshot_volumes.go @@ -18,7 +18,8 @@ import ( // StepSnapshotVolumes creates snapshots of the created volumes. // // Produces: -// snapshot_ids map[string]string - IDs of the created snapshots +// +// snapshot_ids map[string]string - IDs of the created snapshots type StepSnapshotVolumes struct { PollingConfig *awscommon.AWSPollingConfig LaunchDevices []*ec2.BlockDeviceMapping