Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into azr_required_plugin…
Browse files Browse the repository at this point in the history
…_block
  • Loading branch information
azr committed Jan 26, 2021
2 parents 54b6994 + fbbda0f commit c577a18
Show file tree
Hide file tree
Showing 59 changed files with 1,236 additions and 275 deletions.
33 changes: 28 additions & 5 deletions .github/workflows/linkchecker.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
on: [pull_request]
name: Check Markdown links for modified files
on:
pull_request:
paths:
- 'website/**'

name: Check markdown links on modified website files
jobs:
vercel-deployment-poll:
runs-on: ubuntu-latest
timeout-minutes: 3 #cancel job if no deployment is found within x minutes
outputs:
url: ${{ steps.waitForVercelPreviewDeployment.outputs.url }}
steps:
- name: Wait for Vercel preview deployment to be ready
uses: nywilken/wait-for-vercel-preview@master
id: waitForVercelPreviewDeployment
with:
token: ${{ secrets.GITHUB_TOKEN }}
max_timeout: 600 # in seconds, set really high to leverage job timeout-minutes values
allow_inactive: true # needed to ensure we get a URL for a previously released deployment
markdown-link-check:
needs: vercel-deployment-poll
if: ${{ needs.vercel-deployment-poll.outputs.url != '' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: gaurav-nelson/github-action-markdown-link-check@v1
- name: Get Deployment URL
run:
echo "DEPLOYMENT_URL=${{ needs.vercel-deployment-poll.outputs.url }}" >> $GITHUB_ENV
- name: Checkout source branch
uses: actions/checkout@master
- name: Check links
uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: 'yes'
file-extension: 'mdx'
check-modified-files-only: 'yes'
folder-path: 'website/content'

3 changes: 3 additions & 0 deletions .github/workflows/scheduled-link-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ jobs:
markdown-link-check:
runs-on: ubuntu-latest
steps:
- name: Set deployment URL env
run:
echo "DEPLOYMENT_URL=https://packer-git-master.hashicorp.vercel.app" >> $GITHUB_ENV
- uses: actions/checkout@master
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
Expand Down
18 changes: 9 additions & 9 deletions builder/amazon/common/block_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ type BlockDevice struct {
// See the documentation on
// [IOPs](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_EbsBlockDevice.html)
// for more information
IOPS int64 `mapstructure:"iops" required:"false"`
IOPS *int64 `mapstructure:"iops" required:"false"`
// Suppresses the specified device included in the block device mapping of
// the AMI.
NoDevice bool `mapstructure:"no_device" required:"false"`
Expand All @@ -86,7 +86,7 @@ type BlockDevice struct {
// See the documentation on
// [Throughput](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_EbsBlockDevice.html)
// for more information
Throughput int64 `mapstructure:"throughput" required:"false"`
Throughput *int64 `mapstructure:"throughput" required:"false"`
// The virtual device name. See the documentation on Block Device Mapping
// for more information.
VirtualName string `mapstructure:"virtual_name" required:"false"`
Expand Down Expand Up @@ -150,12 +150,12 @@ func (blockDevice BlockDevice) BuildEC2BlockDeviceMapping() *ec2.BlockDeviceMapp

switch blockDevice.VolumeType {
case "io1", "io2", "gp3":
ebsBlockDevice.Iops = aws.Int64(blockDevice.IOPS)
ebsBlockDevice.Iops = blockDevice.IOPS
}

// Throughput is only valid for gp3 types
if blockDevice.VolumeType == "gp3" {
ebsBlockDevice.Throughput = aws.Int64(blockDevice.Throughput)
ebsBlockDevice.Throughput = blockDevice.Throughput
}

// You cannot specify Encrypted if you specify a Snapshot ID
Expand Down Expand Up @@ -191,28 +191,28 @@ func (b *BlockDevice) Prepare(ctx *interpolate.Context) error {
}

if ratio, ok := iopsRatios[b.VolumeType]; b.VolumeSize != 0 && ok {
if b.IOPS/b.VolumeSize > ratio {
if b.IOPS != nil && (*b.IOPS/b.VolumeSize > ratio) {
return fmt.Errorf("%s: the maximum ratio of provisioned IOPS to requested volume size "+
"(in GiB) is %v:1 for %s volumes", b.DeviceName, ratio, b.VolumeType)
}

if b.IOPS < minIops || b.IOPS > maxIops {
if b.IOPS != nil && (*b.IOPS < minIops || *b.IOPS > maxIops) {
return fmt.Errorf("IOPS must be between %d and %d for device %s",
minIops, maxIops, b.DeviceName)
}
}

if b.VolumeType == "gp3" {
if b.Throughput < minThroughput || b.Throughput > maxThroughput {
if b.Throughput != nil && (*b.Throughput < minThroughput || *b.Throughput > maxThroughput) {
return fmt.Errorf("Throughput must be between %d and %d for device %s",
minThroughput, maxThroughput, b.DeviceName)
}

if b.IOPS < minIopsGp3 || b.IOPS > maxIopsGp3 {
if b.IOPS != nil && (*b.IOPS < minIopsGp3 || *b.IOPS > maxIopsGp3) {
return fmt.Errorf("IOPS must be between %d and %d for device %s",
minIopsGp3, maxIopsGp3, b.DeviceName)
}
} else if b.Throughput > 0 {
} else if b.Throughput != nil {
return fmt.Errorf("Throughput is not available for device %s",
b.DeviceName)
}
Expand Down
48 changes: 24 additions & 24 deletions builder/amazon/common/block_device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestBlockDevice(t *testing.T) {
VolumeType: "io1",
VolumeSize: 8,
DeleteOnTermination: true,
IOPS: 1000,
IOPS: aws.Int64(1000),
},

Result: &ec2.BlockDeviceMapping{
Expand All @@ -73,7 +73,7 @@ func TestBlockDevice(t *testing.T) {
VolumeType: "io2",
VolumeSize: 8,
DeleteOnTermination: true,
IOPS: 1000,
IOPS: aws.Int64(1000),
},

Result: &ec2.BlockDeviceMapping{
Expand Down Expand Up @@ -168,8 +168,8 @@ func TestBlockDevice(t *testing.T) {
DeviceName: "/dev/sdb",
VolumeType: "gp3",
VolumeSize: 8,
Throughput: 125,
IOPS: 3000,
Throughput: aws.Int64(125),
IOPS: aws.Int64(3000),
DeleteOnTermination: true,
Encrypted: config.TriTrue,
},
Expand Down Expand Up @@ -219,15 +219,15 @@ func TestIOPSValidation(t *testing.T) {
device: BlockDevice{
DeviceName: "/dev/sdb",
VolumeType: "io1",
IOPS: 1000,
IOPS: aws.Int64(1000),
},
ok: true,
},
{
device: BlockDevice{
DeviceName: "/dev/sdb",
VolumeType: "io2",
IOPS: 1000,
IOPS: aws.Int64(1000),
},
ok: true,
},
Expand All @@ -237,7 +237,7 @@ func TestIOPSValidation(t *testing.T) {
DeviceName: "/dev/sdb",
VolumeType: "io1",
VolumeSize: 50,
IOPS: 1000,
IOPS: aws.Int64(1000),
},
ok: true,
},
Expand All @@ -246,7 +246,7 @@ func TestIOPSValidation(t *testing.T) {
DeviceName: "/dev/sdb",
VolumeType: "io2",
VolumeSize: 100,
IOPS: 1000,
IOPS: aws.Int64(1000),
},
ok: true,
},
Expand All @@ -256,7 +256,7 @@ func TestIOPSValidation(t *testing.T) {
DeviceName: "/dev/sdb",
VolumeType: "io1",
VolumeSize: 10,
IOPS: 2000,
IOPS: aws.Int64(2000),
},
ok: false,
msg: "/dev/sdb: the maximum ratio of provisioned IOPS to requested volume size (in GiB) is 50:1 for io1 volumes",
Expand All @@ -266,7 +266,7 @@ func TestIOPSValidation(t *testing.T) {
DeviceName: "/dev/sdb",
VolumeType: "io2",
VolumeSize: 50,
IOPS: 30000,
IOPS: aws.Int64(30000),
},
ok: false,
msg: "/dev/sdb: the maximum ratio of provisioned IOPS to requested volume size (in GiB) is 500:1 for io2 volumes",
Expand All @@ -277,7 +277,7 @@ func TestIOPSValidation(t *testing.T) {
DeviceName: "/dev/sdb",
VolumeType: "io2",
VolumeSize: 500,
IOPS: 99999,
IOPS: aws.Int64(99999),
},
ok: false,
msg: "IOPS must be between 100 and 64000 for device /dev/sdb",
Expand All @@ -288,7 +288,7 @@ func TestIOPSValidation(t *testing.T) {
DeviceName: "/dev/sdb",
VolumeType: "io2",
VolumeSize: 50,
IOPS: 10,
IOPS: aws.Int64(10),
},
ok: false,
msg: "IOPS must be between 100 and 64000 for device /dev/sdb",
Expand All @@ -299,8 +299,8 @@ func TestIOPSValidation(t *testing.T) {
DeviceName: "/dev/sdb",
VolumeType: "gp3",
VolumeSize: 50,
Throughput: 125,
IOPS: 99999,
Throughput: aws.Int64(125),
IOPS: aws.Int64(99999),
},
ok: false,
msg: "IOPS must be between 3000 and 16000 for device /dev/sdb",
Expand All @@ -311,8 +311,8 @@ func TestIOPSValidation(t *testing.T) {
DeviceName: "/dev/sdb",
VolumeType: "gp3",
VolumeSize: 50,
Throughput: 125,
IOPS: 10,
Throughput: aws.Int64(125),
IOPS: aws.Int64(10),
},
ok: false,
msg: "IOPS must be between 3000 and 16000 for device /dev/sdb",
Expand Down Expand Up @@ -346,17 +346,17 @@ func TestThroughputValidation(t *testing.T) {
device: BlockDevice{
DeviceName: "/dev/sdb",
VolumeType: "gp3",
Throughput: 125,
IOPS: 3000,
Throughput: aws.Int64(125),
IOPS: aws.Int64(3000),
},
ok: true,
},
{
device: BlockDevice{
DeviceName: "/dev/sdb",
VolumeType: "gp3",
Throughput: 1000,
IOPS: 3000,
Throughput: aws.Int64(1000),
IOPS: aws.Int64(3000),
},
ok: true,
},
Expand All @@ -365,8 +365,8 @@ func TestThroughputValidation(t *testing.T) {
device: BlockDevice{
DeviceName: "/dev/sdb",
VolumeType: "gp3",
Throughput: 1001,
IOPS: 3000,
Throughput: aws.Int64(1001),
IOPS: aws.Int64(3000),
},
ok: false,
msg: "Throughput must be between 125 and 1000 for device /dev/sdb",
Expand All @@ -376,8 +376,8 @@ func TestThroughputValidation(t *testing.T) {
device: BlockDevice{
DeviceName: "/dev/sdb",
VolumeType: "gp3",
Throughput: 124,
IOPS: 3000,
Throughput: aws.Int64(124),
IOPS: aws.Int64(3000),
},
ok: false,
msg: "Throughput must be between 125 and 1000 for device /dev/sdb",
Expand Down
3 changes: 1 addition & 2 deletions builder/amazon/common/run_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ type RunConfig struct {
SecurityGroupIds []string `mapstructure:"security_group_ids" required:"false"`
// The source AMI whose root volume will be copied and
// provisioned on the currently running instance. This must be an EBS-backed
// AMI with a root volume snapshot that you have access to. Note: this is not
// used when from_scratch is set to true.
// AMI with a root volume snapshot that you have access to.
SourceAmi string `mapstructure:"source_ami" required:"true"`
// Filters used to populate the `source_ami`
// field. JSON Example:
Expand Down
2 changes: 1 addition & 1 deletion builder/qemu/step_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func (s *stepRun) getDeviceAndDriveArgs(config *Config, state multistep.StateBag
}
for i, cdPath := range cdPaths {
if config.CDROMInterface == "" {
driveArgs = append(driveArgs, fmt.Sprintf("file=%s,index=%d,media=cdrom", cdPath, i))
driveArgs = append(driveArgs, fmt.Sprintf("file=%s,media=cdrom", cdPath))
} else if config.CDROMInterface == "virtio-scsi" {
driveArgs = append(driveArgs, fmt.Sprintf("file=%s,if=none,index=%d,id=cdrom%d,media=cdrom", cdPath, i, i))
deviceArgs = append(deviceArgs, "virtio-scsi-device", fmt.Sprintf("scsi-cd,drive=cdrom%d", i))
Expand Down
Loading

0 comments on commit c577a18

Please sign in to comment.