Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
format the code
Browse files Browse the repository at this point in the history
  • Loading branch information
RodrigoCMoraes committed May 10, 2024
1 parent 1cab260 commit 6eee14a
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 51 deletions.
5 changes: 3 additions & 2 deletions builder/chroot/step_attach_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion builder/chroot/step_create_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion builder/chroot/step_flock.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 3 additions & 2 deletions builder/chroot/step_mount_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion builder/chroot/step_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 19 additions & 15 deletions builder/common/access_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions builder/common/awserrors/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 14 additions & 11 deletions builder/common/block_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
// }
//
// ]
// ```
//
Expand All @@ -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
Expand Down
20 changes: 12 additions & 8 deletions builder/common/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 4 additions & 3 deletions builder/common/step_network_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion builder/common/step_pre_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion builder/common/step_pre_validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]) == "" {
Expand Down
3 changes: 2 additions & 1 deletion builder/common/step_source_ami_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion builder/ebssurrogate/step_snapshot_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6eee14a

Please sign in to comment.