blob: 5813a3114a57c78811fb1755643fdd1ad85c526a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#!/usr/bin/lua5.3
---
-- convert private yaml to a public json mirror file
-- dependencies:
-- lua5.3-cjson
-- lua5.3-lyaml
-- lua5.3-penlight
local json = require("cjson")
local yaml = require("lyaml")
local pfile = require("pl.file")
local input = assert(arg[1], "Please provide input yaml as first argument!")
local output = assert(arg[2], "Please provide output json as second argument!")
local mirrors = yaml.load(pfile.read(input))
local public_keys = { "name", "location", "bandwidth", "urls" }
local res = {}
for k,m in ipairs(mirrors) do
res[k] = {}
for _,pk in ipairs(public_keys) do
res[k][pk] = m[pk]
end
end
pfile.write(output, json.encode(res))
|