Skip to content

Commit

Permalink
add in HCL support (#593)
Browse files Browse the repository at this point in the history
  • Loading branch information
boyter authored Feb 17, 2025
1 parent 9893e2c commit a05a76a
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 4 deletions.
1 change: 1 addition & 0 deletions LANGUAGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ Happy (y,ly)
Hare (ha)
Haskell (hs)
Haxe (hx)
HCL (hcl)
HEEx (heex)
HEX (hex)
hoon (hoon)
Expand Down
6 changes: 3 additions & 3 deletions SCC-OUTPUT-REPORT.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<th>431</th>
<th>7555</th>
<th>1387</th>
<th>253498</th>
<th>253662</th>
<th>4066</th>
</tr><tr>
<td>processor/workers_test.go</td>
Expand Down Expand Up @@ -268,7 +268,7 @@
<td>1</td>
<td>4</td>
<td>0</td>
<td>23411</td>
<td>23575</td>
<td>6</td>
</tr></tbody>
<tfoot><tr>
Expand All @@ -279,7 +279,7 @@
<th>431</th>
<th>7555</th>
<th>1387</th>
<th>253498</th>
<th>253662</th>
<th>4066</th>
</tr>
<tr>
Expand Down
134 changes: 134 additions & 0 deletions examples/language/hcl.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#!/usr/bin/env packer build --force
#
# Author: Hari Sekhon
# Date: 2023-06-13 02:46:59 +0100 (Tue, 13 Jun 2023)
#
# vim:ts=2:sts=2:sw=2:et:filetype=conf
#
# https://github.com/HariSekhon/Templates
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
#
# https://www.linkedin.com/in/HariSekhon
#

# Uses adjacent Debian Preseed from installers/
#
# 'packer' command must be run from the same directory as this file so the preseed.cfg provided is auto-served via HTTP

# ============================================================================ #
# P a c k e r - F e d o r a - Q e m u
# ============================================================================ #

packer {
# Data sources only available in 1.7+
required_version = ">= 1.7.0, < 2.0.0"
required_plugins {
qemu = {
version = "~> 1.1"
source = "github.com/hashicorp/qemu"
}
}
}

# https://alt.fedoraproject.org/alt/
variable "version" {
type = string
default = "38"
}

variable "iso" {
type = string
default = "Fedora-Server-dvd-x86_64-38-1.6.iso"
}

variable "checksum" {
type = string
default = "09dee2cd626a269aefc67b69e63a30bd0baa52d4"
}
locals {
name = "fedora"
url = "https://download.fedoraproject.org/pub/fedora/linux/releases/${var.version}/Server/x86_64/iso/${var.iso}"
vm_name = "${local.name}-${var.version}"
arch = "x86_64"
}

# https://developer.hashicorp.com/packer/plugins/builders/qemu
source "qemu" "fedora" {
vm_name = local.vm_name
qemu_binary = "qemu-system-x86_64"
machine_type = "pc"
iso_url = local.url
iso_checksum = var.checksum
cpus = 2
memory = 2048
net_device = "virtio-net"
disk_interface = "virtio-scsi" # or virtio?
format = "qcow2"
disk_discard = "unmap"
disk_image = true
disk_size = 40960
disk_additional_size = []
output_directory = "output-${local.vm_name}-${local.arch}"
headless = false
use_default_display = true # might be needed on Mac to avoid errors about sdl not being available
http_directory = "installers"
ssh_timeout = "30m"
ssh_password = "packer"
ssh_username = "packer"
shutdown_command = "echo 'packer' | sudo -S shutdown -P now"
boot_wait = "5s"
boot_command = [
"<up><wait>",
"e",
"<down><down><down><left>",
# leave a space from last arg
" inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/anaconda-ks.cfg <f10>"
]
qemuargs = [
#["-smbios", "type=1,serial=ds=nocloud-net;instance-id=packer;seedfrom=http://{{ .HTTPIP }}:{{ .HTTPPort }}/"],
# spice-app isn't respected despite doc https://www.qemu.org/docs/master/system/invocation.html#hxtool-3
# packer-builder-qemu plugin: Qemu stderr: qemu-system-x86_64: -display spice-app: Parameter 'type' does not accept value 'spice-app'
#["-display", "spice-app"],
#["-display", "cocoa"], # Mac only
#["-display", "vnc:0"], # starts VNC by default, but doesn't launch user's vncviewer - ubuntu-x86_64.qemu.pkr.hcl
]
# Only on ARM Macs
#machine_type = "virt" # packer-builder-qemu plugin: Qemu stderr: qemu-system-x86_64: unsupported machine type
}


build {
name = local.name

sources = ["source.qemu.fedora"]

# https://developer.hashicorp.com/packer/docs/provisioners/shell-local
#
#provisioner "shell-local" {
# environment_vars = [
# "VM_NAME=${local.vm_name}"
# ]
# script = "./scripts/local_vboxsf.sh"
#}

# https://developer.hashicorp.com/packer/docs/provisioners/shell
#
provisioner "shell" {
scripts = [
"./scripts/version.sh",
#"./scripts/mount_vboxsf.sh",
#"./scripts/collect_anaconda.sh",
"./scripts/final.sh",
]
execute_command = "{{ .Vars }} echo 'packer' | sudo -S -E bash '{{ .Path }}' '${packer.version}'"
}

post-processor "checksum" {
checksum_types = ["md5", "sha512"]
keep_input_artifact = true
output = "output-{{.BuildName}}/{{.BuildName}}.{{.ChecksumType}}"
}
}
23 changes: 23 additions & 0 deletions languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2704,6 +2704,29 @@
}
]
},
"HCL": {
"complexitychecks": [
"for_each ",
"for ",
"count ",
"coalesce(",
"== ",
"!= ",
"> ",
"< ",
"&& ",
"|| "
],
"extensions": ["hcl"],
"line_comment": ["#"],
"multi_line": [["/*", "*/"]],
"quotes": [
{
"end": "\"",
"start": "\""
}
]
},
"HAML": {
"extensions": ["haml"],
"line_comment": ["-#"],
Expand Down
2 changes: 1 addition & 1 deletion processor/constants.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,7 @@ specificLanguages=(
'Gwion '
'HAML '
'Hare '
'HCL '
'ignore '
'INI '
'Java '
Expand Down

0 comments on commit a05a76a

Please sign in to comment.