port: bring output-template
, outputRef
, health check services from Liminix upstream #28
3 changed files with 23 additions and 0 deletions
|
@ -1,2 +1,3 @@
|
||||||
wpa_passphrase={{ secret "colours/black" }}
|
wpa_passphrase={{ secret "colours/black" }}
|
||||||
think = {{ string.format("%q", secret("colours/blue")) }}
|
think = {{ string.format("%q", secret("colours/blue")) }}
|
||||||
|
argonaut = {{ json_quote "hello\ngoodbye\tnext\027" }}
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
wpa_passphrase=000000
|
wpa_passphrase=000000
|
||||||
think = "0000ff"
|
think = "0000ff"
|
||||||
|
argonaut = "hello\ngoodbye\tnext\u001B"
|
||||||
|
|
|
@ -1,11 +1,32 @@
|
||||||
(local svc (require :anoia.svc))
|
(local svc (require :anoia.svc))
|
||||||
|
|
||||||
|
(fn json-escape [s]
|
||||||
|
;; All Unicode characters may be placed within the quotation marks,
|
||||||
|
;; except for the characters that MUST be escaped:
|
||||||
|
;; quotation mark, reverse solidus, and the control characters (U+0000
|
||||||
|
;; through U+001F). (RFC 8259)
|
||||||
|
(-> s
|
||||||
|
(string.gsub
|
||||||
|
"[\"\b\f\n\r\t]" {
|
||||||
|
"\b" "\\b"
|
||||||
|
"\"" "\\\""
|
||||||
|
"\f" "\\f"
|
||||||
|
"\n" "\\n"
|
||||||
|
"\r" "\\r"
|
||||||
|
"\t" "\\t"
|
||||||
|
})
|
||||||
|
(string.gsub
|
||||||
|
"([\x00-\x1b])"
|
||||||
|
(fn [x] (string.format "\\u%04X" (string.byte x))))))
|
||||||
|
|
||||||
|
|
||||||
(fn substitute [text service opening closing]
|
(fn substitute [text service opening closing]
|
||||||
(let [delim (.. opening "(.-)" closing)
|
(let [delim (.. opening "(.-)" closing)
|
||||||
myenv {
|
myenv {
|
||||||
: string
|
: string
|
||||||
:secret (fn [x] (service:output x))
|
:secret (fn [x] (service:output x))
|
||||||
:lua_quote #(string.format "%q" %1)
|
:lua_quote #(string.format "%q" %1)
|
||||||
|
:json_quote (fn [x] (.. "\"" (json-escape x) "\""))
|
||||||
}]
|
}]
|
||||||
(string.gsub text delim
|
(string.gsub text delim
|
||||||
(fn [x]
|
(fn [x]
|
||||||
|
|
Loading…
Reference in a new issue