port: bring output-template, outputRef, health check services from Liminix upstream #28

Open
rlahfa wants to merge 4 commits from port-upstream-liminix into main
12 changed files with 10 additions and 9 deletions
Showing only changes of commit 1896d9d70c - Show all commits

View file

@ -1,3 +1,3 @@
check:
./output-template ./example-output/ '{{' '}}' < example.ini > output
./output-template '{{' '}}' < example.ini > output
diff -u output example.ini.expected

View file

@ -1,3 +1,3 @@
wpa_passphrase={{ secret "colours/black" }}
think = {{ string.format("%q", secret("colours/blue")) }}
wpa_passphrase={{ output("./example-service","colours/black") }}
think = {{ string.format("%q", output("./example-service","colours/blue")) }}
argonaut = {{ json_quote "hello\ngoodbye\tnext\027" }}

View file

@ -20,11 +20,14 @@
(fn [x] (string.format "\\u%04X" (string.byte x))))))
(fn substitute [text service opening closing]
(fn substitute [text opening closing]
(let [delim (.. opening "(.-)" closing)
myenv {
: string
:secret (fn [x] (service:output x))
:output
(fn [service-path path]
(let [s (assert (svc.open (.. service-path "/.outputs")))]
(s:output path)))
:lua_quote #(string.format "%q" %1)
:json_quote (fn [x] (.. "\"" (json-escape x) "\""))
}]
@ -34,10 +37,8 @@
(string.format "missing value for %q" x))))))
(fn run []
(let [[service-dir opening closing] arg
service (assert (svc.open service-dir))
out (substitute (: (io.input) :read "*a") service opening closing)]
(let [[opening closing] arg
out (substitute (: (io.input) :read "*a") opening closing)]
(io.write out)))
{ : run }