Skip to content

Commit

Permalink
feat: move tinyyaml to lyaml
Browse files Browse the repository at this point in the history
  • Loading branch information
bzp2010 committed Jun 1, 2024
1 parent 55eeb6b commit f89d78b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions apisix/cli/file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
-- limitations under the License.
--

local yaml = require("tinyyaml")
local lyaml = require("lyaml")
local profile = require("apisix.core.profile")
local util = require("apisix.cli.util")
local dkjson = require("dkjson")
Expand Down Expand Up @@ -243,7 +243,7 @@ function _M.read_yaml_conf(apisix_home)
return nil, err
end

local default_conf = yaml.parse(default_conf_yaml)
local default_conf = lyaml.load(default_conf_yaml)
if not default_conf then
return nil, "invalid config-default.yaml file"
end
Expand All @@ -266,7 +266,7 @@ function _M.read_yaml_conf(apisix_home)
end

if not is_empty_file then
local user_conf = yaml.parse(user_conf_yaml)
local user_conf = lyaml.load(user_conf_yaml)
if not user_conf then
return nil, "invalid config.yaml file"
end
Expand Down Expand Up @@ -306,7 +306,7 @@ function _M.read_yaml_conf(apisix_home)
local apisix_conf_path = profile:yaml_path("apisix")
local apisix_conf_yaml, _ = util.read_file(apisix_conf_path)
if apisix_conf_yaml then
local apisix_conf = yaml.parse(apisix_conf_yaml)
local apisix_conf = lyaml.load(apisix_conf_yaml)
if apisix_conf then
local ok, err = resolve_conf_var(apisix_conf)
if not ok then
Expand Down
4 changes: 2 additions & 2 deletions apisix/core/config_yaml.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

local config_local = require("apisix.core.config_local")
local config_util = require("apisix.core.config_util")
local yaml = require("tinyyaml")
local lyaml = require("lyaml")
local log = require("apisix.core.log")
local json = require("apisix.core.json")
local new_tab = require("table.new")
Expand Down Expand Up @@ -100,7 +100,7 @@ local function read_apisix_yaml(premature, pre_mtime)
local yaml_config = f:read("*a")
f:close()

local apisix_yaml_new = yaml.parse(yaml_config)
local apisix_yaml_new = lyaml.load(yaml_config)
if not apisix_yaml_new then
log.error("failed to parse the content of file " .. apisix_yaml_path)
return
Expand Down
4 changes: 2 additions & 2 deletions apisix/debug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
-- limitations under the License.
--
local require = require
local yaml = require("tinyyaml")
local lyaml = require("lyaml")
local log = require("apisix.core.log")
local profile = require("apisix.core.profile")
local lfs = require("lfs")
Expand Down Expand Up @@ -130,7 +130,7 @@ local function read_debug_yaml()
local yaml_config = f:read("*a")
f:close()

local debug_yaml_new = yaml.parse(yaml_config)
local debug_yaml_new = lyaml.load(yaml_config)
if not debug_yaml_new then
log.error("failed to parse the content of file " .. debug_yaml_path)
return
Expand Down
4 changes: 2 additions & 2 deletions docs/en/latest/plugins/body-transformer.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ For example, parse YAML to JSON yourself:

```
{%
local yaml = require("tinyyaml")
local body = yaml.parse(_body)
local lyaml = require("lyaml")
local body = lyaml.load(_body)
%}
{"foobar":"{{body.foobar.foo .. " " .. body.foobar.bar}}"}
```
Expand Down
4 changes: 2 additions & 2 deletions t/plugin/body-transformer.t
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,8 @@ qr/attempt to call global 'name' \(a string value\)/
local core = require("apisix.core")
local req_template = [[
{%
local yaml = require("tinyyaml")
local body = yaml.parse(_body)
local lyaml = require("lyaml")
local body = lyaml.load(_body)
%}
{"foobar":"{{body.foobar.foo .. " " .. body.foobar.bar}}"}
]]
Expand Down

0 comments on commit f89d78b

Please sign in to comment.