Skip to content

Commit

Permalink
Merge pull request #447 from s3rj1k/lua-utils
Browse files Browse the repository at this point in the history
(feat) Use `github.com/projectsveltos/lua-utils` for `json`, `runes`
  • Loading branch information
gianlucam76 authored Feb 18, 2025
2 parents 9a4b97d + 2b661b4 commit 5dd770f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ require (
github.com/Masterminds/sprig/v3 v3.3.0
github.com/go-logr/logr v1.4.2
github.com/google/gofuzz v1.2.0
github.com/layeh/gopher-json v0.0.0-20201124131017-552bb3c4c3bf
github.com/mocktools/go-smtp-mock/v2 v2.4.0
github.com/onsi/ginkgo/v2 v2.22.2
github.com/onsi/gomega v1.36.2
github.com/pkg/errors v0.9.1
github.com/projectsveltos/lua-utils/glua-json v0.0.0-20250215155204-2e8364e9ce73
github.com/projectsveltos/lua-utils/glua-runes v0.0.0-20250215155204-2e8364e9ce73
github.com/projectsveltos/lua-utils/glua-strings v0.0.0-20250215155204-2e8364e9ce73
github.com/yuin/gopher-lua v1.1.1
golang.org/x/text v0.22.0
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/layeh/gopher-json v0.0.0-20201124131017-552bb3c4c3bf h1:bg6J/5S/AeTz7K9i/luJRj31BJ8f+LgYwKQBSOZxSEM=
github.com/layeh/gopher-json v0.0.0-20201124131017-552bb3c4c3bf/go.mod h1:E/q28EyUVBgBQnONAVPIdwvEsv4Ve0vaCA9JWim4+3I=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
Expand All @@ -115,6 +113,10 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/projectsveltos/lua-utils/glua-json v0.0.0-20250215155204-2e8364e9ce73 h1:Sgh71mZil6CXZXcRPrzfl7XuetK+CyvruWOajU95qhs=
github.com/projectsveltos/lua-utils/glua-json v0.0.0-20250215155204-2e8364e9ce73/go.mod h1:AIzg+JWbfrFWazyM5Ka2fX69r9aFr3+o2Mvn9SfKDYU=
github.com/projectsveltos/lua-utils/glua-runes v0.0.0-20250215155204-2e8364e9ce73 h1:VdjrXW3hU6JPP9kUtUC6K8ulW82uAjPyiMKf4iJGIXg=
github.com/projectsveltos/lua-utils/glua-runes v0.0.0-20250215155204-2e8364e9ce73/go.mod h1:IvieeooskPIhNS4ddMfNjvS6NrXfwLkGRb/qHLBnnX8=
github.com/projectsveltos/lua-utils/glua-strings v0.0.0-20250215155204-2e8364e9ce73 h1:VmuIB2nCSHYhTmTL5g2WqN2i0pQxfoEQt0b+OLPCWDU=
github.com/projectsveltos/lua-utils/glua-strings v0.0.0-20250215155204-2e8364e9ce73/go.mod h1:L5waR6GvgOHVQ/YnDxHW4p53DDQ/sF3ACZhtSpDARMw=
github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=
Expand Down
4 changes: 3 additions & 1 deletion lib/lua/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ import (
"fmt"
"time"

luajson "github.com/layeh/gopher-json"
lua "github.com/yuin/gopher-lua"

luajson "github.com/projectsveltos/lua-utils/glua-json"
luarunes "github.com/projectsveltos/lua-utils/glua-runes"
luastrings "github.com/projectsveltos/lua-utils/glua-strings"
)

Expand All @@ -35,6 +36,7 @@ const (
func LoadModulesAndRegisterMethods(l *lua.LState) {
l.PreloadModule("json", luajson.Loader)
l.PreloadModule("strings", luastrings.Loader)
l.PreloadModule("runes", luarunes.Loader)

l.SetGlobal("base64Encode", l.NewFunction(base64Encode))
l.SetGlobal("base64Decode", l.NewFunction(base64Decode))
Expand Down
1 change: 1 addition & 0 deletions lib/lua/methods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func TestLoadModulesAndRegisterMethods(t *testing.T) {
modules := []string{
"json",
"strings",
"runes",
}

for _, module := range modules {
Expand Down

0 comments on commit 5dd770f

Please sign in to comment.