Skip to content

Commit

Permalink
go: lint all go files
Browse files Browse the repository at this point in the history
  • Loading branch information
lbajolet-hashicorp committed Aug 2, 2023
1 parent 4a33eb5 commit 175e937
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 62 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 @@ -19,8 +19,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 @@ -22,7 +22,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 @@ -17,7 +17,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 @@ -27,8 +27,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 @@ -17,7 +17,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 @@ -35,26 +35,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 @@ -10,9 +10,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 @@ -36,21 +36,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 @@ -59,7 +63,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
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 @@ -12,7 +12,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 @@ -19,7 +19,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 @@ -21,7 +21,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
30 changes: 17 additions & 13 deletions docs-partials/builder/common/AssumeRoleConfig.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,30 @@ Usage example:
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"
}
}
}

```

<!-- End of code generated from the comments of the AssumeRoleConfig struct in builder/common/access_config.go; -->
24 changes: 14 additions & 10 deletions docs-partials/builder/common/BlockDevice.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,25 @@ build instance at launch using a specific non-default kms key:
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 Down

0 comments on commit 175e937

Please sign in to comment.