Skip to content

Commit a05a76a

Browse files
authored
add in HCL support (#593)
1 parent 9893e2c commit a05a76a

File tree

6 files changed

+163
-4
lines changed

6 files changed

+163
-4
lines changed

LANGUAGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ Happy (y,ly)
125125
Hare (ha)
126126
Haskell (hs)
127127
Haxe (hx)
128+
HCL (hcl)
128129
HEEx (heex)
129130
HEX (hex)
130131
hoon (hoon)

SCC-OUTPUT-REPORT.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<th>431</th>
1919
<th>7555</th>
2020
<th>1387</th>
21-
<th>253498</th>
21+
<th>253662</th>
2222
<th>4066</th>
2323
</tr><tr>
2424
<td>processor/workers_test.go</td>
@@ -268,7 +268,7 @@
268268
<td>1</td>
269269
<td>4</td>
270270
<td>0</td>
271-
<td>23411</td>
271+
<td>23575</td>
272272
<td>6</td>
273273
</tr></tbody>
274274
<tfoot><tr>
@@ -279,7 +279,7 @@
279279
<th>431</th>
280280
<th>7555</th>
281281
<th>1387</th>
282-
<th>253498</th>
282+
<th>253662</th>
283283
<th>4066</th>
284284
</tr>
285285
<tr>

examples/language/hcl.hcl

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
#!/usr/bin/env packer build --force
2+
#
3+
# Author: Hari Sekhon
4+
# Date: 2023-06-13 02:46:59 +0100 (Tue, 13 Jun 2023)
5+
#
6+
# vim:ts=2:sts=2:sw=2:et:filetype=conf
7+
#
8+
# https://github.com/HariSekhon/Templates
9+
#
10+
# License: see accompanying Hari Sekhon LICENSE file
11+
#
12+
# 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
13+
#
14+
# https://www.linkedin.com/in/HariSekhon
15+
#
16+
17+
# Uses adjacent Debian Preseed from installers/
18+
#
19+
# 'packer' command must be run from the same directory as this file so the preseed.cfg provided is auto-served via HTTP
20+
21+
# ============================================================================ #
22+
# P a c k e r - F e d o r a - Q e m u
23+
# ============================================================================ #
24+
25+
packer {
26+
# Data sources only available in 1.7+
27+
required_version = ">= 1.7.0, < 2.0.0"
28+
required_plugins {
29+
qemu = {
30+
version = "~> 1.1"
31+
source = "github.com/hashicorp/qemu"
32+
}
33+
}
34+
}
35+
36+
# https://alt.fedoraproject.org/alt/
37+
variable "version" {
38+
type = string
39+
default = "38"
40+
}
41+
42+
variable "iso" {
43+
type = string
44+
default = "Fedora-Server-dvd-x86_64-38-1.6.iso"
45+
}
46+
47+
variable "checksum" {
48+
type = string
49+
default = "09dee2cd626a269aefc67b69e63a30bd0baa52d4"
50+
}
51+
locals {
52+
name = "fedora"
53+
url = "https://download.fedoraproject.org/pub/fedora/linux/releases/${var.version}/Server/x86_64/iso/${var.iso}"
54+
vm_name = "${local.name}-${var.version}"
55+
arch = "x86_64"
56+
}
57+
58+
# https://developer.hashicorp.com/packer/plugins/builders/qemu
59+
source "qemu" "fedora" {
60+
vm_name = local.vm_name
61+
qemu_binary = "qemu-system-x86_64"
62+
machine_type = "pc"
63+
iso_url = local.url
64+
iso_checksum = var.checksum
65+
cpus = 2
66+
memory = 2048
67+
net_device = "virtio-net"
68+
disk_interface = "virtio-scsi" # or virtio?
69+
format = "qcow2"
70+
disk_discard = "unmap"
71+
disk_image = true
72+
disk_size = 40960
73+
disk_additional_size = []
74+
output_directory = "output-${local.vm_name}-${local.arch}"
75+
headless = false
76+
use_default_display = true # might be needed on Mac to avoid errors about sdl not being available
77+
http_directory = "installers"
78+
ssh_timeout = "30m"
79+
ssh_password = "packer"
80+
ssh_username = "packer"
81+
shutdown_command = "echo 'packer' | sudo -S shutdown -P now"
82+
boot_wait = "5s"
83+
boot_command = [
84+
"<up><wait>",
85+
"e",
86+
"<down><down><down><left>",
87+
# leave a space from last arg
88+
" inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/anaconda-ks.cfg <f10>"
89+
]
90+
qemuargs = [
91+
#["-smbios", "type=1,serial=ds=nocloud-net;instance-id=packer;seedfrom=http://{{ .HTTPIP }}:{{ .HTTPPort }}/"],
92+
# spice-app isn't respected despite doc https://www.qemu.org/docs/master/system/invocation.html#hxtool-3
93+
# packer-builder-qemu plugin: Qemu stderr: qemu-system-x86_64: -display spice-app: Parameter 'type' does not accept value 'spice-app'
94+
#["-display", "spice-app"],
95+
#["-display", "cocoa"], # Mac only
96+
#["-display", "vnc:0"], # starts VNC by default, but doesn't launch user's vncviewer - ubuntu-x86_64.qemu.pkr.hcl
97+
]
98+
# Only on ARM Macs
99+
#machine_type = "virt" # packer-builder-qemu plugin: Qemu stderr: qemu-system-x86_64: unsupported machine type
100+
}
101+
102+
103+
build {
104+
name = local.name
105+
106+
sources = ["source.qemu.fedora"]
107+
108+
# https://developer.hashicorp.com/packer/docs/provisioners/shell-local
109+
#
110+
#provisioner "shell-local" {
111+
# environment_vars = [
112+
# "VM_NAME=${local.vm_name}"
113+
# ]
114+
# script = "./scripts/local_vboxsf.sh"
115+
#}
116+
117+
# https://developer.hashicorp.com/packer/docs/provisioners/shell
118+
#
119+
provisioner "shell" {
120+
scripts = [
121+
"./scripts/version.sh",
122+
#"./scripts/mount_vboxsf.sh",
123+
#"./scripts/collect_anaconda.sh",
124+
"./scripts/final.sh",
125+
]
126+
execute_command = "{{ .Vars }} echo 'packer' | sudo -S -E bash '{{ .Path }}' '${packer.version}'"
127+
}
128+
129+
post-processor "checksum" {
130+
checksum_types = ["md5", "sha512"]
131+
keep_input_artifact = true
132+
output = "output-{{.BuildName}}/{{.BuildName}}.{{.ChecksumType}}"
133+
}
134+
}

languages.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2704,6 +2704,29 @@
27042704
}
27052705
]
27062706
},
2707+
"HCL": {
2708+
"complexitychecks": [
2709+
"for_each ",
2710+
"for ",
2711+
"count ",
2712+
"coalesce(",
2713+
"== ",
2714+
"!= ",
2715+
"> ",
2716+
"< ",
2717+
"&& ",
2718+
"|| "
2719+
],
2720+
"extensions": ["hcl"],
2721+
"line_comment": ["#"],
2722+
"multi_line": [["/*", "*/"]],
2723+
"quotes": [
2724+
{
2725+
"end": "\"",
2726+
"start": "\""
2727+
}
2728+
]
2729+
},
27072730
"HAML": {
27082731
"extensions": ["haml"],
27092732
"line_comment": ["-#"],

processor/constants.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test-all.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,7 @@ specificLanguages=(
958958
'Gwion '
959959
'HAML '
960960
'Hare '
961+
'HCL '
961962
'ignore '
962963
'INI '
963964
'Java '

0 commit comments

Comments
 (0)