Skip to content

Commit

Permalink
upgrade to latest dependencies
Browse files Browse the repository at this point in the history
bumping knative.dev/serving 5e20e1e...becea87:
  > becea87 Update net-kourier nightly (# 14261)
  > 2cb31ee Update community files (# 14259)
  > 59cb3d3 Update net-contour nightly (# 14264)
  > 4931532 Update net-certmanager nightly (# 14262)
bumping knative.dev/pkg 6519aff...4f651e0:
  > 4f651e0 Bump gomodules.xyz/jsonpatch/v2 from 2.2.0 to 2.3.0 (# 2789)
bumping gomodules.xyz/jsonpatch/v2 93a4daf...13a9e4a:
  > 13a9e4a Merge pull request # 36 from howardjohn/v2/improvements
  > 62e0c90 Update repository config (# 33)
  > 6d5c3df Fully remove dead code
  > 0c26413 Update repository config (# 32)
  > 45186ed (hackily) remove inefficient optimization
  > e0f6c24 Fix known broken case
  > c616a48 Fix marshaling invalid chars
  > 2c05a51 Fix inputs with empty keys
  > 1f7eb13 Improve fuzz tests
  > 471fa30 Fix CI
  > 4844bbf Add fuzzing test
  > 87f8876 add benchmarks
  > a81e531 Go.mod for go 1.20
  > fc9e957 Update to Go 1.20
bumping knative.dev/client-pkg 38d2dc0...5abd129:
  > 5abd129 Update community files (# 116)

Signed-off-by: Knative Automation <automation@knative.team>
  • Loading branch information
knative-automation committed Aug 16, 2023
1 parent 2cdfd1f commit 3f3d412
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 144 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ require (
k8s.io/cli-runtime v0.25.2
k8s.io/client-go v0.26.5
k8s.io/code-generator v0.26.5
knative.dev/client-pkg v0.0.0-20230809014238-38d2dc0dd50a
knative.dev/client-pkg v0.0.0-20230815131440-5abd12981b4b
knative.dev/eventing v0.38.1-0.20230815095940-29ac3eee64a4
knative.dev/hack v0.0.0-20230815012940-044c02b7a447
knative.dev/networking v0.0.0-20230815014240-ed0534b4ef83
knative.dev/pkg v0.0.0-20230815012542-6519affc772b
knative.dev/serving v0.38.1-0.20230815122740-5e20e1e82550
knative.dev/pkg v0.0.0-20230815132840-4f651e092853
knative.dev/serving v0.38.1-0.20230815144447-becea87631d7
sigs.k8s.io/yaml v1.3.0
)

Expand Down Expand Up @@ -111,7 +111,7 @@ require (
golang.org/x/text v0.12.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.12.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
google.golang.org/api v0.136.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect
Expand Down
17 changes: 8 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5y
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ=
github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U=
github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww=
Expand Down Expand Up @@ -666,8 +665,8 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gomodules.xyz/jsonpatch/v2 v2.2.0 h1:4pT439QV83L+G9FkcCriY6EkpcK6r6bK+A5FBUMI7qY=
gomodules.xyz/jsonpatch/v2 v2.2.0/go.mod h1:WXp+iVDkoLQqPudfQ9GBlwB2eZ5DKOnjQZCYdOS8GPY=
gomodules.xyz/jsonpatch/v2 v2.3.0 h1:8NFhfS6gzxNqjLIYnZxg319wZ5Qjnx4m/CcX+Klzazc=
gomodules.xyz/jsonpatch/v2 v2.3.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY=
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
Expand Down Expand Up @@ -836,18 +835,18 @@ k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 h1:+70TFaan3hfJzs+7VK2o+O
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280/go.mod h1:+Axhij7bCpeqhklhUTe3xmOn6bWxolyZEeyaFpjGtl4=
k8s.io/utils v0.0.0-20221108210102-8e77b1f39fe2 h1:GfD9OzL11kvZN5iArC6oTS7RTj7oJOIfnislxYlqTj8=
k8s.io/utils v0.0.0-20221108210102-8e77b1f39fe2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
knative.dev/client-pkg v0.0.0-20230809014238-38d2dc0dd50a h1:h+8sIUP03mCGO8vYI4qwT1GD88824n73EpZS8IsihXw=
knative.dev/client-pkg v0.0.0-20230809014238-38d2dc0dd50a/go.mod h1:GRVZm1rKOy0lpPBGRM1ugK5joDbhXFEvULINHqPoA9U=
knative.dev/client-pkg v0.0.0-20230815131440-5abd12981b4b h1:Ln3mDUER89kC4sYHkCpoZVcwthGlMwjekQi2IdMH4vU=
knative.dev/client-pkg v0.0.0-20230815131440-5abd12981b4b/go.mod h1:GRVZm1rKOy0lpPBGRM1ugK5joDbhXFEvULINHqPoA9U=
knative.dev/eventing v0.38.1-0.20230815095940-29ac3eee64a4 h1:619xUZrwrv3xuterMgF8qKXLTJm1MosKwuTLcG5HTOk=
knative.dev/eventing v0.38.1-0.20230815095940-29ac3eee64a4/go.mod h1:InEIckt+XICxXXYy2P4kqEJ4nMDXqI1iCUZ84vGDRbM=
knative.dev/hack v0.0.0-20230815012940-044c02b7a447 h1:Lr4O/WEyZHuUBFbqATYdQlfLXvhPUCluF4zlgRi59T4=
knative.dev/hack v0.0.0-20230815012940-044c02b7a447/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q=
knative.dev/networking v0.0.0-20230815014240-ed0534b4ef83 h1:F1tP5OIXfk2YX/0KE+8DyuFw8bNrWzQSWXRba6k/aVQ=
knative.dev/networking v0.0.0-20230815014240-ed0534b4ef83/go.mod h1:Ao0oO/s5ARZP2jllEoGWbLgpCb2nI4OCUutylpSyxpw=
knative.dev/pkg v0.0.0-20230815012542-6519affc772b h1:Gr7PGAgYAMvihhoF7fskqRLmqX/Mt+/su2t81KFpgRc=
knative.dev/pkg v0.0.0-20230815012542-6519affc772b/go.mod h1:D9D8LkOtlJBC09i+6nbTdZ5LAKsAbTJkkGGXEh2BPYI=
knative.dev/serving v0.38.1-0.20230815122740-5e20e1e82550 h1:0+LkICVjcTWTUWvhPddxhmvxttwpBdGx92msRoTQ1pM=
knative.dev/serving v0.38.1-0.20230815122740-5e20e1e82550/go.mod h1:XNvj91QrfYWMMLSVo42q6P4X6XtNeOUKIEM5dwMjgGA=
knative.dev/pkg v0.0.0-20230815132840-4f651e092853 h1:OyAYpXLa/jQWClFxRegCccGySyX2/1BVRtKaAWRE/xM=
knative.dev/pkg v0.0.0-20230815132840-4f651e092853/go.mod h1:Y5Tis5nMoapB9iTZywW20Qnv/7LBahrtHz9Sm6+l3LE=
knative.dev/serving v0.38.1-0.20230815144447-becea87631d7 h1:RpSGiVTS6LhCvMZ1UxcL0ZRFW/KWCGhJLV3r6NCozb4=
knative.dev/serving v0.38.1-0.20230815144447-becea87631d7/go.mod h1:XNvj91QrfYWMMLSVo42q6P4X6XtNeOUKIEM5dwMjgGA=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
Expand Down
160 changes: 34 additions & 126 deletions vendor/gomodules.xyz/jsonpatch/v2/jsonpatch.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package jsonpatch

import (
"bytes"
"encoding/json"
"fmt"
"reflect"
Expand All @@ -24,21 +23,28 @@ func (j *Operation) Json() string {
}

func (j *Operation) MarshalJSON() ([]byte, error) {
var b bytes.Buffer
b.WriteString("{")
b.WriteString(fmt.Sprintf(`"op":"%s"`, j.Operation))
b.WriteString(fmt.Sprintf(`,"path":"%s"`, j.Path))
// Consider omitting Value for non-nullable operations.
if j.Value != nil || j.Operation == "replace" || j.Operation == "add" {
v, err := json.Marshal(j.Value)
if err != nil {
return nil, err
}
b.WriteString(`,"value":`)
b.Write(v)
}
b.WriteString("}")
return b.Bytes(), nil
// Ensure for add and replace we emit `value: null`
if j.Value == nil && (j.Operation == "replace" || j.Operation == "add") {
return json.Marshal(struct {
Operation string `json:"op"`
Path string `json:"path"`
Value interface{} `json:"value"`
}{
Operation: j.Operation,
Path: j.Path,
})
}
// otherwise just marshal normally. We cannot literally do json.Marshal(j) as it would be recursively
// calling this function.
return json.Marshal(struct {
Operation string `json:"op"`
Path string `json:"path"`
Value interface{} `json:"value,omitempty"`
}{
Operation: j.Operation,
Path: j.Path,
Value: j.Value,
})
}

type ByPath []Operation
Expand Down Expand Up @@ -149,9 +155,6 @@ func makePath(path string, newPart interface{}) string {
if path == "" {
return "/" + key
}
if strings.HasSuffix(path, "/") {
return path + key
}
return path + "/" + key
}

Expand Down Expand Up @@ -211,22 +214,18 @@ func handleValues(av, bv interface{}, p string, patch []Operation) ([]Operation,
}
case []interface{}:
bt := bv.([]interface{})
if isSimpleArray(at) && isSimpleArray(bt) {
patch = append(patch, compareEditDistance(at, bt, p)...)
} else {
n := min(len(at), len(bt))
for i := len(at) - 1; i >= n; i-- {
patch = append(patch, NewOperation("remove", makePath(p, i), nil))
}
for i := n; i < len(bt); i++ {
patch = append(patch, NewOperation("add", makePath(p, i), bt[i]))
}
for i := 0; i < n; i++ {
var err error
patch, err = handleValues(at[i], bt[i], makePath(p, i), patch)
if err != nil {
return nil, err
}
n := min(len(at), len(bt))
for i := len(at) - 1; i >= n; i-- {
patch = append(patch, NewOperation("remove", makePath(p, i), nil))
}
for i := n; i < len(bt); i++ {
patch = append(patch, NewOperation("add", makePath(p, i), bt[i]))
}
for i := 0; i < n; i++ {
var err error
patch, err = handleValues(at[i], bt[i], makePath(p, i), patch)
if err != nil {
return nil, err
}
}
default:
Expand All @@ -235,100 +234,9 @@ func handleValues(av, bv interface{}, p string, patch []Operation) ([]Operation,
return patch, nil
}

func isBasicType(a interface{}) bool {
switch a.(type) {
case string, float64, bool:
default:
return false
}
return true
}

func isSimpleArray(a []interface{}) bool {
for i := range a {
switch a[i].(type) {
case string, float64, bool:
default:
val := reflect.ValueOf(a[i])
if val.Kind() == reflect.Map {
for _, k := range val.MapKeys() {
av := val.MapIndex(k)
if av.Kind() == reflect.Ptr || av.Kind() == reflect.Interface {
if av.IsNil() {
continue
}
av = av.Elem()
}
if av.Kind() != reflect.String && av.Kind() != reflect.Float64 && av.Kind() != reflect.Bool {
return false
}
}
return true
}
return false
}
}
return true
}

// https://en.wikipedia.org/wiki/Wagner%E2%80%93Fischer_algorithm
// Adapted from https://github.com/texttheater/golang-levenshtein
func compareEditDistance(s, t []interface{}, p string) []Operation {
m := len(s)
n := len(t)

d := make([][]int, m+1)
for i := 0; i <= m; i++ {
d[i] = make([]int, n+1)
d[i][0] = i
}
for j := 0; j <= n; j++ {
d[0][j] = j
}

for j := 1; j <= n; j++ {
for i := 1; i <= m; i++ {
if reflect.DeepEqual(s[i-1], t[j-1]) {
d[i][j] = d[i-1][j-1] // no op required
} else {
del := d[i-1][j] + 1
add := d[i][j-1] + 1
rep := d[i-1][j-1] + 1
d[i][j] = min(rep, min(add, del))
}
}
}

return backtrace(s, t, p, m, n, d)
}

func min(x int, y int) int {
if y < x {
return y
}
return x
}

func backtrace(s, t []interface{}, p string, i int, j int, matrix [][]int) []Operation {
if i > 0 && matrix[i-1][j]+1 == matrix[i][j] {
op := NewOperation("remove", makePath(p, i-1), nil)
return append([]Operation{op}, backtrace(s, t, p, i-1, j, matrix)...)
}
if j > 0 && matrix[i][j-1]+1 == matrix[i][j] {
op := NewOperation("add", makePath(p, i), t[j-1])
return append([]Operation{op}, backtrace(s, t, p, i, j-1, matrix)...)
}
if i > 0 && j > 0 && matrix[i-1][j-1]+1 == matrix[i][j] {
if isBasicType(s[0]) {
op := NewOperation("replace", makePath(p, i-1), t[j-1])
return append([]Operation{op}, backtrace(s, t, p, i-1, j-1, matrix)...)
}

p2, _ := handleValues(s[i-1], t[j-1], makePath(p, i-1), []Operation{})
return append(p2, backtrace(s, t, p, i-1, j-1, matrix)...)
}
if i > 0 && j > 0 && matrix[i-1][j-1] == matrix[i][j] {
return backtrace(s, t, p, i-1, j-1, matrix)
}
return []Operation{}
}
10 changes: 5 additions & 5 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ golang.org/x/tools/internal/gocommand
golang.org/x/tools/internal/gopathwalk
golang.org/x/tools/internal/imports
golang.org/x/tools/internal/typeparams
# gomodules.xyz/jsonpatch/v2 v2.2.0
## explicit; go 1.12
# gomodules.xyz/jsonpatch/v2 v2.3.0
## explicit; go 1.20
gomodules.xyz/jsonpatch/v2
# google.golang.org/api v0.136.0
## explicit; go 1.19
Expand Down Expand Up @@ -939,7 +939,7 @@ k8s.io/utils/net
k8s.io/utils/pointer
k8s.io/utils/strings/slices
k8s.io/utils/trace
# knative.dev/client-pkg v0.0.0-20230809014238-38d2dc0dd50a
# knative.dev/client-pkg v0.0.0-20230815131440-5abd12981b4b
## explicit; go 1.18
knative.dev/client-pkg/pkg/kn/plugin
# knative.dev/eventing v0.38.1-0.20230815095940-29ac3eee64a4
Expand Down Expand Up @@ -989,7 +989,7 @@ knative.dev/networking/pkg/http/probe
knative.dev/networking/pkg/http/proxy
knative.dev/networking/pkg/http/stats
knative.dev/networking/pkg/k8s
# knative.dev/pkg v0.0.0-20230815012542-6519affc772b
# knative.dev/pkg v0.0.0-20230815132840-4f651e092853
## explicit; go 1.18
knative.dev/pkg/apis
knative.dev/pkg/apis/duck
Expand Down Expand Up @@ -1039,7 +1039,7 @@ knative.dev/pkg/tracing/config
knative.dev/pkg/tracing/propagation
knative.dev/pkg/tracing/propagation/tracecontextb3
knative.dev/pkg/tracker
# knative.dev/serving v0.38.1-0.20230815122740-5e20e1e82550
# knative.dev/serving v0.38.1-0.20230815144447-becea87631d7
## explicit; go 1.18
knative.dev/serving/pkg/apis/autoscaling
knative.dev/serving/pkg/apis/autoscaling/v1alpha1
Expand Down

0 comments on commit 3f3d412

Please sign in to comment.