Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move jp extensions in a top level package #490

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/commands/jp/function/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

jpfunctions "github.com/jmespath-community/go-jmespath/pkg/functions"
"github.com/kyverno/kyverno-json/pkg/command"
"github.com/kyverno/kyverno-json/pkg/engine/template"
"github.com/kyverno/kyverno-json/pkg/jp"
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/util/sets"
)
Expand Down Expand Up @@ -59,7 +59,7 @@ func functionString(f jpfunctions.FunctionEntry) string {
}

func printFunctions(out io.Writer, names ...string) {
funcs := template.GetFunctions(context.Background())
funcs := jp.GetFunctions(context.Background())
slices.SortFunc(funcs, func(a, b jpfunctions.FunctionEntry) int {
return cmp.Compare(functionString(a), functionString(b))
})
Expand Down
3 changes: 2 additions & 1 deletion pkg/engine/assert/binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@

"github.com/jmespath-community/go-jmespath/pkg/binding"
"github.com/kyverno/kyverno-json/pkg/engine/template"
"github.com/kyverno/kyverno-json/pkg/jp"
"k8s.io/apimachinery/pkg/util/validation/field"
)

func NewContextBinding(path *field.Path, bindings binding.Bindings, value any, entry any, opts ...template.Option) binding.Binding {
return template.NewLazyBinding(
return jp.NewLazyBinding(

Check warning on line 13 in pkg/engine/assert/binding.go

View check run for this annotation

Codecov / codecov/patch

pkg/engine/assert/binding.go#L13

Added line #L13 was not covered by tests
func() (any, error) {
expression := parseExpression(context.TODO(), entry)
if expression != nil && expression.engine != "" {
Expand Down
3 changes: 2 additions & 1 deletion pkg/engine/template/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"context"

"github.com/jmespath-community/go-jmespath/pkg/interpreter"
"github.com/kyverno/kyverno-json/pkg/jp"
)

var (
funcs = GetFunctions(context.Background())
funcs = jp.GetFunctions(context.Background())
defaultCaller = interpreter.NewFunctionCaller(funcs...)
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/engine/template/binding.go → pkg/jp/binding.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package template
package jp

import (
"sync"
Expand Down
6 changes: 3 additions & 3 deletions pkg/engine/template/functions.go → pkg/jp/functions.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package template
package jp

import (
"context"

jpfunctions "github.com/jmespath-community/go-jmespath/pkg/functions"
"github.com/kyverno/kyverno-json/pkg/engine/template/functions"
kyvernofunctions "github.com/kyverno/kyverno-json/pkg/engine/template/kyverno"
"github.com/kyverno/kyverno-json/pkg/jp/functions"
kyvernofunctions "github.com/kyverno/kyverno-json/pkg/jp/kyverno"
)

func GetFunctions(ctx context.Context) []jpfunctions.FunctionEntry {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions website/jp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"strings"

jpfunctions "github.com/jmespath-community/go-jmespath/pkg/functions"
"github.com/kyverno/kyverno-json/pkg/engine/template/functions"
kyvernofunctions "github.com/kyverno/kyverno-json/pkg/engine/template/kyverno"
"github.com/kyverno/kyverno-json/pkg/jp/functions"
kyvernofunctions "github.com/kyverno/kyverno-json/pkg/jp/kyverno"
)

func main() {
Expand Down