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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ package main
import (
"fmt"
"github.com/pb33f/jsonpath/pkg/jsonpath"
"go.yaml.in/yaml/v4"
"github.com/pb33f/go-yaml"
)

func main() {
Expand Down Expand Up @@ -415,7 +415,7 @@ package main
import (
"fmt"
"github.com/pb33f/jsonpath/pkg/overlay"
"go.yaml.in/yaml/v4"
"github.com/pb33f/go-yaml"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/wasm/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/pb33f/jsonpath/pkg/jsonpath/config"
"github.com/pb33f/jsonpath/pkg/jsonpath/token"
"github.com/pb33f/jsonpath/pkg/overlay"
"go.yaml.in/yaml/v4"
"github.com/pb33f/go-yaml"
"reflect"
"syscall/js"
)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module github.com/pb33f/jsonpath
go 1.24

require (
github.com/pb33f/go-yaml v0.1.0
github.com/pmezard/go-difflib v1.0.0
github.com/stretchr/testify v1.11.1
go.yaml.in/yaml/v4 v4.0.0-rc.4
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pb33f/go-yaml v0.1.0 h1:zZ6Gg+ATbumXlXZNLMHIe7+zTkVqe20lx+TSYRrXEuY=
github.com/pb33f/go-yaml v0.1.0/go.mod h1:QvWdkHP5VjFYAeHMQUkaPQqREaQnBNOXmWzAjNrnSdo=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
go.yaml.in/yaml/v4 v4.0.0-rc.4 h1:UP4+v6fFrBIb1l934bDl//mmnoIZEDK0idg1+AIvX5U=
go.yaml.in/yaml/v4 v4.0.0-rc.4/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
2 changes: 1 addition & 1 deletion integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/pmezard/go-difflib/difflib"
"github.com/pb33f/jsonpath/pkg/jsonpath"
"github.com/stretchr/testify/require"
"go.yaml.in/yaml/v4"
"github.com/pb33f/go-yaml"
)

type FullTestSuite struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/jsonpath/context_usage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package jsonpath
import (
"testing"

"go.yaml.in/yaml/v4"
"github.com/pb33f/go-yaml"
)

func TestContextUsageAndPropertyReferenceDetection(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/jsonpath/filter.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package jsonpath

import (
"go.yaml.in/yaml/v4"
"github.com/pb33f/go-yaml"
"strconv"
"strings"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/jsonpath/filter_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strconv"
"strings"

"go.yaml.in/yaml/v4"
"github.com/pb33f/go-yaml"
)

// FilterContext provides rich context during filter evaluation for JSONPath Plus extensions.
Expand Down
2 changes: 1 addition & 1 deletion pkg/jsonpath/filter_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package jsonpath
import (
"testing"

"go.yaml.in/yaml/v4"
"github.com/pb33f/go-yaml"
)

func TestFilterContextLazyGuardsAndTrackingFlags(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/jsonpath/jsonpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package jsonpath

import (
"fmt"
"github.com/pb33f/go-yaml"
"github.com/pb33f/jsonpath/pkg/jsonpath/config"
"github.com/pb33f/jsonpath/pkg/jsonpath/token"
"go.yaml.in/yaml/v4"
)

// NewPath compiles input into a reusable JSONPath using the supplied options.
Expand Down
2 changes: 1 addition & 1 deletion pkg/jsonpath/jsonpath_plus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/pb33f/jsonpath/pkg/jsonpath/config"
"github.com/stretchr/testify/assert"
"go.yaml.in/yaml/v4"
"github.com/pb33f/go-yaml"
)

// TestPropertyContextVariable tests @property filter context variable
Expand Down
2 changes: 1 addition & 1 deletion pkg/jsonpath/lazy_context_tracking_stress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"os"
"testing"

"github.com/pb33f/go-yaml"
"github.com/pb33f/jsonpath/pkg/jsonpath/config"
"github.com/pb33f/jsonpath/pkg/jsonpath/token"
"go.yaml.in/yaml/v4"
)

func BenchmarkLazyContextTrackingStress(b *testing.B) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/jsonpath/lazy_context_tracking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
package jsonpath

import (
"github.com/pb33f/go-yaml"
"github.com/pb33f/jsonpath/pkg/jsonpath/config"
"github.com/pb33f/jsonpath/pkg/jsonpath/token"
"go.yaml.in/yaml/v4"
"testing"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/jsonpath/segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package jsonpath

import (
"fmt"
"go.yaml.in/yaml/v4"
"github.com/pb33f/go-yaml"
"strings"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/jsonpath/spectral_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"strings"
"testing"

"github.com/pb33f/go-yaml"
"github.com/pb33f/jsonpath/pkg/jsonpath/config"
"go.yaml.in/yaml/v4"
)

func BenchmarkSpectralRegexFilter(b *testing.B) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/jsonpath/spectral_corpus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"strings"
"testing"

"github.com/pb33f/go-yaml"
"github.com/pb33f/jsonpath/pkg/jsonpath/config"
"go.yaml.in/yaml/v4"
)

type spectralCorpus struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/jsonpath/spectral_eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"strconv"
"unicode/utf16"

"github.com/pb33f/go-yaml"
"github.com/pb33f/jsonpath/pkg/jsonpath/token"
"go.yaml.in/yaml/v4"
)

type spectralRuntimeKind uint8
Expand Down
2 changes: 1 addition & 1 deletion pkg/jsonpath/spectral_eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package jsonpath
import (
"testing"

"go.yaml.in/yaml/v4"
"github.com/pb33f/go-yaml"
)

func TestSpectralTruthinessAllValueKinds(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/jsonpath/spectral_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"strings"
"testing"

"github.com/pb33f/go-yaml"
"github.com/pb33f/jsonpath/pkg/jsonpath/config"
"go.yaml.in/yaml/v4"
)

func parseSpectralTestYAML(t *testing.T, source string) *yaml.Node {
Expand Down
2 changes: 1 addition & 1 deletion pkg/jsonpath/testdata/spectral/generate/collect_public.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"strings"
"time"

"github.com/pb33f/go-yaml"
"github.com/pb33f/jsonpath/pkg/jsonpath"
"github.com/pb33f/jsonpath/pkg/jsonpath/config"
"go.yaml.in/yaml/v4"
)

type publicSource struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"sort"
"testing"

"go.yaml.in/yaml/v4"
"github.com/pb33f/go-yaml"
)

func TestCollectPublicSelectorsExpandsAliasesAndLists(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/jsonpath/yaml_eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strconv"
"unicode/utf8"

"go.yaml.in/yaml/v4"
"github.com/pb33f/go-yaml"
)

// Pre-allocated boolean literals to avoid repeated allocations
Expand Down
2 changes: 1 addition & 1 deletion pkg/jsonpath/yaml_eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"reflect"
"testing"

"go.yaml.in/yaml/v4"
"github.com/pb33f/go-yaml"
)

func TestLiteralEquals(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/jsonpath/yaml_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package jsonpath
import (
"strconv"

"go.yaml.in/yaml/v4"
"github.com/pb33f/go-yaml"
)

type Evaluator interface {
Expand Down
2 changes: 1 addition & 1 deletion pkg/jsonpath/yaml_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"github.com/pb33f/jsonpath/pkg/jsonpath/config"
"github.com/pb33f/jsonpath/pkg/jsonpath/token"
"go.yaml.in/yaml/v4"
"github.com/pb33f/go-yaml"
"reflect"
"strings"
"testing"
Expand Down
2 changes: 1 addition & 1 deletion pkg/overlay/apply.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package overlay

import (
"github.com/pb33f/go-yaml"
"github.com/pb33f/jsonpath/pkg/jsonpath"
"github.com/pb33f/jsonpath/pkg/jsonpath/config"
"go.yaml.in/yaml/v4"
)

// ApplyTo will take an overlay and apply its changes to the given YAML
Expand Down
9 changes: 5 additions & 4 deletions pkg/overlay/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"errors"
"testing"

"github.com/pb33f/go-yaml"
"github.com/pb33f/jsonpath/pkg/overlay"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.yaml.in/yaml/v4"
"os"
"strings"
)
Expand All @@ -24,10 +24,11 @@ func NodeMatchesFile(
variadoc := func(pre ...any) []any { return append(msgAndArgs, pre...) }

var actualBuf bytes.Buffer
enc := yaml.NewEncoder(&actualBuf)
enc.SetIndent(2)
err := enc.Encode(actual)
enc, err := yaml.NewDumper(&actualBuf, yaml.WithV3Defaults(), yaml.WithIndent(2), yaml.WithLineWidth(-1))
require.NoError(t, err, variadoc("failed to create dumper: ")...)
err = enc.Dump(actual)
require.NoError(t, err, variadoc("failed to marshal node: ")...)
require.NoError(t, enc.Close(), variadoc("failed to flush node: ")...)

expectedBytes, err := os.ReadFile(expectedFile)
require.NoError(t, err, variadoc("failed to read expected file: ")...)
Expand Down
2 changes: 1 addition & 1 deletion pkg/overlay/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"log"
"strings"

"go.yaml.in/yaml/v4"
"github.com/pb33f/go-yaml"
)

// Compare compares input specifications from two files and returns an overlay
Expand Down
2 changes: 1 addition & 1 deletion pkg/overlay/compare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package overlay_test

import (
"fmt"
"github.com/pb33f/go-yaml"
"github.com/pb33f/jsonpath/pkg/overlay"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.yaml.in/yaml/v4"
"os"
"strings"
"testing"
Expand Down
2 changes: 1 addition & 1 deletion pkg/overlay/parents.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package overlay

import "go.yaml.in/yaml/v4"
import "github.com/pb33f/go-yaml"

type parentIndex map[*yaml.Node]*yaml.Node

Expand Down
16 changes: 11 additions & 5 deletions pkg/overlay/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package overlay

import (
"fmt"
"go.yaml.in/yaml/v4"
"github.com/pb33f/go-yaml"
"io"
"os"
"path/filepath"
Expand Down Expand Up @@ -50,9 +50,15 @@ func Format(path string) error {
return os.WriteFile(filePath, []byte(formatted), 0644)
}

// Format writes the file back out as YAML.
// Format writes the file back out as YAML, with two space indentation and no line wrapping: the
// layout overlays have always been written in.
func (o *Overlay) Format(w io.Writer) error {
enc := yaml.NewEncoder(w)
enc.SetIndent(2)
return enc.Encode(o)
enc, err := yaml.NewDumper(w, yaml.WithV3Defaults(), yaml.WithIndent(2), yaml.WithLineWidth(-1))
if err != nil {
return err
}
if err := enc.Dump(o); err != nil {
return err
}
return enc.Close()
}
6 changes: 2 additions & 4 deletions pkg/overlay/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package overlay

import (
"bytes"
"go.yaml.in/yaml/v4"
"github.com/pb33f/go-yaml"
)

// Extensible provides a place for extensions to be added to components of the
Expand Down Expand Up @@ -31,9 +31,7 @@ type Overlay struct {

func (o *Overlay) ToString() (string, error) {
buf := bytes.NewBuffer([]byte{})
decoder := yaml.NewEncoder(buf)
decoder.SetIndent(2)
err := decoder.Encode(o)
err := o.Format(buf)
return buf.String(), err
}

Expand Down
Loading