-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
Summary
Please add native YAML support to Sveltos Lua: yaml.decode(string) and yaml.encode(table).
Motivation
We want to use a kubeconfig stored in a Kubernetes Secret as the source and parse it directly in Lua without converting to JSON first. Native YAML I/O would simplify scripts, improve readability, and remove external conversion steps.
Example
-- Extract current cluster server URL and CA data from a kubeconfig YAML.
local function extract_kubeconfig_info(kubeconfig_yaml)
local cfg = yaml.decode(kubeconfig_yaml)
local current = cfg["current-context"]
local function get_cluster_by_name(name)
for _, c in ipairs(cfg.clusters or {}) do
if c.name == name then return c.cluster end
end
end
for _, ctx in ipairs(cfg.contexts or {}) do
if ctx.name == current and ctx.context and ctx.context.cluster then
local cl = get_cluster_by_name(ctx.context.cluster)
if cl then
return {
server = cl.server,
ca_data = cl["certificate-authority-data"],
}
end
end
end
-- Not found
return { server = nil, ca_data = nil }
end
-- usage:
-- local info = extract_kubeconfig_info(kubeconfig_yaml)
-- return infoExpected Behavior
yaml.decode/encodeavailable in the Lua runtime- Handles single and multi‑document YAML
Metadata
Metadata
Assignees
Labels
No labels