Skip to content
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
2 changes: 1 addition & 1 deletion extractor/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func New(jsonPaths []string, opts ...Option) (Extractor, error) {
}

for _, p := range jsonPaths {
parser, err := parseJsonPath(p)
parser, err := ParseJSONPath(p)
if err != nil {
return nil, fmt.Errorf("error in parsing path %q: %w", p, err)
}
Expand Down
4 changes: 2 additions & 2 deletions extractor/jsonpath_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type jsonPathTest struct {
}

func (t *jsonPathTest) Prepare(opts ...Option) (Extractor, error) {
parser, err := parseJsonPath(t.template)
parser, err := ParseJSONPath(t.template)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -178,7 +178,7 @@ func TestJSONPath(t *testing.T) {
}

func TestJSONPathReuse(t *testing.T) {
parser, err := parseJsonPath(`{.spec.containers[*]['name', 'image']}`)
parser, err := ParseJSONPath(`{.spec.containers[*]['name', 'image']}`)
require.NoError(t, err)
extractor := newJSONPatch(options{ignoreMissingKey: true}, parser)
got, err := extractor.Extract(podData)
Expand Down
4 changes: 2 additions & 2 deletions extractor/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ import (
"k8s.io/client-go/util/jsonpath"
)

// parseJsonPath is unlike the jsonpath.parseJsonPath, which supports multi-paths input.
// ParseJSONPath is unlike the jsonpath.ParseJSONPath, which supports multi-paths input.
// The input like `{.kind} {.apiVersion}` or
// `{range .spec.containers[*]}{.name}{end}` will result in an error.
//
// It also relaxes the JSONPath expressions internally,
// so inputs like `.kind` (without curly braces) are acceptable.
func parseJsonPath(text string) (*jsonpath.Parser, error) {
func ParseJSONPath(text string) (*jsonpath.Parser, error) {
relaxed, err := RelaxedJSONPathExpression(text)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion extractor/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestParse(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := parseJsonPath(tt.text)
got, err := ParseJSONPath(tt.text)
if tt.wantErr {
require.Error(t, err)
} else {
Expand Down
Loading