From 7eaaf3f45703d49e494f6dd0555633cf6b355817 Mon Sep 17 00:00:00 2001 From: Matus Goljer Date: Tue, 20 May 2025 01:42:52 +0200 Subject: feat: add nomad formatter (#361) This is a more specific formatter than `hclfmt` for nomad files. --- CHANGELOG.md | 2 ++ apheleia-formatters.el | 2 ++ test/formatters/installers/nomad.bash | 5 +++++ test/formatters/samplecode/nomad/in.nomad | 20 ++++++++++++++++++++ test/formatters/samplecode/nomad/out.nomad | 20 ++++++++++++++++++++ 5 files changed, 49 insertions(+) create mode 100644 test/formatters/installers/nomad.bash create mode 100644 test/formatters/samplecode/nomad/in.nomad create mode 100644 test/formatters/samplecode/nomad/out.nomad diff --git a/CHANGELOG.md b/CHANGELOG.md index e0c6db9..c09323b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ The format is based on [Keep a Changelog]. ### Formatters * Format Bazel files according to their type +* `nomad fmt` official formatter for + [HashiCorp Nomad](https://developer.hashicorp.com/nomad) ([#361]). [#299]: https://github.com/radian-software/apheleia/issues/299 diff --git a/apheleia-formatters.el b/apheleia-formatters.el index 75374fa..c49c18e 100644 --- a/apheleia-formatters.el +++ b/apheleia-formatters.el @@ -104,6 +104,7 @@ (mix-format . ("apheleia-from-project-root" ".formatter.exs" "apheleia-mix-format" filepath)) (nixfmt . ("nixfmt")) + (nomad . ("nomad" "fmt" "-")) (ocamlformat . ("ocamlformat" "-" "--name" filepath "--enable-outside-detected-project")) (ocp-indent . ("ocp-indent")) @@ -370,6 +371,7 @@ rather than using this system." (nasm-mode . asmfmt) (nix-mode . nixfmt) (nix-ts-mode . nixfmt) + (nomad-mode . nomad) (perl-mode . perltidy) (php-mode . phpcs) (purescript-mode . purs-tidy) diff --git a/test/formatters/installers/nomad.bash b/test/formatters/installers/nomad.bash new file mode 100644 index 0000000..80215cc --- /dev/null +++ b/test/formatters/installers/nomad.bash @@ -0,0 +1,5 @@ +curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add - +echo "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" > /etc/apt/sources.list.d/nomad.list + +apt-get update +apt-get install -y nomad diff --git a/test/formatters/samplecode/nomad/in.nomad b/test/formatters/samplecode/nomad/in.nomad new file mode 100644 index 0000000..95cac05 --- /dev/null +++ b/test/formatters/samplecode/nomad/in.nomad @@ -0,0 +1,20 @@ +job "mongo-jwt" { + namespace = "default" + + group "db" { + network { + port "db" { + static = 27017 + } + } + +task "mongo" { +driver = "docker" + + config { + image = "mongo:7" + ports = ["db"] + } + } + } +} diff --git a/test/formatters/samplecode/nomad/out.nomad b/test/formatters/samplecode/nomad/out.nomad new file mode 100644 index 0000000..3107f5b --- /dev/null +++ b/test/formatters/samplecode/nomad/out.nomad @@ -0,0 +1,20 @@ +job "mongo-jwt" { + namespace = "default" + + group "db" { + network { + port "db" { + static = 27017 + } + } + + task "mongo" { + driver = "docker" + + config { + image = "mongo:7" + ports = ["db"] + } + } + } +} -- cgit v1.0