Skip to content

Commit

Permalink
(feat) Lua methods
Browse files Browse the repository at this point in the history
Register those modules:
1. github.com/layeh/gopher-json
   - encode: expect a lua table, return the JSON encoded string
   - decode: expect a JSON encoded string, return a Lua table
   - to use this:
     . local ison = require("json")
     . encoded = json.encode(luaTable)
2. github.com/chai2010/glua-strings
   - Compare
   - Contains
   - HasPrefix
   - HasSuffix
   - Join
   - Replace
   - Split
   - ToLower
   - ToUpper
   - ... and more
   - to use this:
     . local strings = require("strings")
     . strings.ToUpper("mystring")

Register following methods:
- base64Encode: accept a string return, base64 encoded string
- base64Decode: accept a base64 encoded string, return the decoded version
- getLabel: lua Table representing a Kubernetes resource and a key, return label value (nil if key is not set)
- getAnnotation: lua Table representing a Kubernetes resource and a key, return annotation value (nil if key is not set)
  • Loading branch information
gianlucam76 committed Jan 20, 2025
1 parent a4c7de0 commit 480f5e7
Show file tree
Hide file tree
Showing 3 changed files with 404 additions and 0 deletions.
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ go 1.23.4
require (
github.com/BurntSushi/toml v1.4.0
github.com/Masterminds/sprig/v3 v3.3.0
github.com/chai2010/glua-strings v0.0.0-20200705094630-a37fb1f4ddeb
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/yuin/gopher-lua v1.1.1
golang.org/x/text v0.21.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.32.1
Expand All @@ -33,6 +36,7 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chai2010/glua-helper v0.0.0-20171228064744-0e9a290dbcdf // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chai2010/glua-helper v0.0.0-20171228064744-0e9a290dbcdf h1:83/SiZ9gCO63c1fSVuBlYsNMSwbzYw0nLT6BgU3IAbU=
github.com/chai2010/glua-helper v0.0.0-20171228064744-0e9a290dbcdf/go.mod h1:g4T7SP6g4zcVGZu2Xt2l9v+j8WRUKnrSFI13MYeQtD4=
github.com/chai2010/glua-strings v0.0.0-20200705094630-a37fb1f4ddeb h1:veL8m2ukpS0WornX1koriByiNIils7J+wB6urWgB18c=
github.com/chai2010/glua-strings v0.0.0-20200705094630-a37fb1f4ddeb/go.mod h1:Ujv8AWr5PquFfwTqGV6c8MP+tuG1q7SgYdkZ7umTUsQ=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -87,6 +91,8 @@ 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 Down Expand Up @@ -153,6 +159,8 @@ github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ=
github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo=
go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4=
go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g=
Expand Down
Loading

0 comments on commit 480f5e7

Please sign in to comment.