From c31a7c8e598a32f6808fbc3bc9841818be56939a Mon Sep 17 00:00:00 2001 From: Andy Goldstein Date: Wed, 31 Jul 2019 21:35:49 -0400 Subject: [PATCH] Fix jsonpatch go module Signed-off-by: Andy Goldstein --- go.sum | 4 +- hack/update-vendor.sh | 11 ++-- vendor/gomodules.xyz/jsonpatch/v2/.gitignore | 27 ++++++++++ vendor/gomodules.xyz/jsonpatch/v2/.travis.yml | 17 ++++++ .../gomodules.xyz/jsonpatch/v2/CHANGELOG.md | 37 +++++++++++++ vendor/gomodules.xyz/jsonpatch/v2/README.md | 52 +++++++++++++++++++ 6 files changed, 141 insertions(+), 7 deletions(-) create mode 100644 vendor/gomodules.xyz/jsonpatch/v2/.gitignore create mode 100644 vendor/gomodules.xyz/jsonpatch/v2/.travis.yml create mode 100644 vendor/gomodules.xyz/jsonpatch/v2/CHANGELOG.md create mode 100644 vendor/gomodules.xyz/jsonpatch/v2/README.md diff --git a/go.sum b/go.sum index 9cd271323804..cc28ae3e0985 100644 --- a/go.sum +++ b/go.sum @@ -63,7 +63,6 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -220,7 +219,7 @@ golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3 golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190501045030-23463209683d h1:D7DVZUZEUgsSIDTivnUtVeGfN5AvhDIKtdIZAqx0ieE= golang.org/x/tools v0.0.0-20190501045030-23463209683d/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -gomodules.xyz/jsonpatch/v2 v2.0.0 h1:OyHbl+7IOECpPKfVK42oFr6N7+Y2dR+Jsb/IiDV3hOo= +gomodules.xyz/jsonpatch/v2 v2.0.0 h1:lHNQverf0+Gm1TbSbVIDWVXOhZ2FpZopxRqpr2uIjs4= gomodules.xyz/jsonpatch/v2 v2.0.0/go.mod h1:IhYNNY4jnS53ZnfE4PAmpKtDpTCj1JFXc+3mwe7XcUU= google.golang.org/api v0.3.1 h1:oJra/lMfmtm13/rgY/8i3MzjFWYXvQIAKjQ3HqofMk8= google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= @@ -279,7 +278,6 @@ sigs.k8s.io/controller-runtime v0.2.0-beta.4 h1:S1XVfRWR1MuIXZdkYx3jN8JDw+bbQxmW sigs.k8s.io/controller-runtime v0.2.0-beta.4/go.mod h1:HweyYKQ8fBuzdu2bdaeBJvsFgAi/OqBBnrVGXcqKhME= sigs.k8s.io/controller-tools v0.2.0-beta.4 h1:W+coTe+nkVNclQrikwlRp6GJKwgcrHzvIQZ9kCaak5A= sigs.k8s.io/controller-tools v0.2.0-beta.4/go.mod h1:8t/X+FVWvk6TaBcsa+UKUBbn7GMtvyBKX30SGl4em6Y= -sigs.k8s.io/testing_frameworks v0.1.1 h1:cP2l8fkA3O9vekpy5Ks8mmA0NW/F7yBdXf8brkWhVrs= sigs.k8s.io/testing_frameworks v0.1.1/go.mod h1:VVBKrHmJ6Ekkfz284YKhQePcdycOzNH9qL6ht1zEr/U= sigs.k8s.io/testing_frameworks v0.1.2-0.20190130140139-57f07443c2d4 h1:GtDhkj3cF4A4IW+A9LScsuxvJqA9DE7G7PGH1f8B07U= sigs.k8s.io/testing_frameworks v0.1.2-0.20190130140139-57f07443c2d4/go.mod h1:VVBKrHmJ6Ekkfz284YKhQePcdycOzNH9qL6ht1zEr/U= diff --git a/hack/update-vendor.sh b/hack/update-vendor.sh index 5d6194655815..8f9a748c328b 100755 --- a/hack/update-vendor.sh +++ b/hack/update-vendor.sh @@ -19,17 +19,20 @@ set -o nounset set -o pipefail KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. +# shellcheck source=./ensure-go.sh source "${KUBE_ROOT}/hack/ensure-go.sh" +GOPROXY=$(go env GOPROXY) +export GOPROXY="${GOPROXY:-https://proxy.golang.org}" go mod tidy go mod vendor # Copy full dependencies if needed. -for dep in $(cat ${KUBE_ROOT}/go.vendor); do - src=$(go mod download -json ${dep} | jq -r .Dir) +while IFS= read -r dep; do + src="$(go mod download -json "${dep}" | jq -r .Dir)" dst="${KUBE_ROOT}/vendor/${dep}" cp -af "${src}/" "${dst}" - chmod -R +w ${dst} -done + chmod -R +w "${dst}" +done < "${KUBE_ROOT}/go.vendor" go mod verify diff --git a/vendor/gomodules.xyz/jsonpatch/v2/.gitignore b/vendor/gomodules.xyz/jsonpatch/v2/.gitignore new file mode 100644 index 000000000000..5f90593a043e --- /dev/null +++ b/vendor/gomodules.xyz/jsonpatch/v2/.gitignore @@ -0,0 +1,27 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof + +/.idea +/vendor diff --git a/vendor/gomodules.xyz/jsonpatch/v2/.travis.yml b/vendor/gomodules.xyz/jsonpatch/v2/.travis.yml new file mode 100644 index 000000000000..9e4597bca6e8 --- /dev/null +++ b/vendor/gomodules.xyz/jsonpatch/v2/.travis.yml @@ -0,0 +1,17 @@ +language: go +go: + - 1.x + - tip + +go_import_path: gomodules.xyz/jsonpatch + +cache: + directories: + - $HOME/.cache/go-build + - $GOPATH/pkg/mod + +env: + - GO111MODULE=on + +script: + - go test -v diff --git a/vendor/gomodules.xyz/jsonpatch/v2/CHANGELOG.md b/vendor/gomodules.xyz/jsonpatch/v2/CHANGELOG.md new file mode 100644 index 000000000000..579351906c78 --- /dev/null +++ b/vendor/gomodules.xyz/jsonpatch/v2/CHANGELOG.md @@ -0,0 +1,37 @@ +# Change Log + +## [v2.0.0](https://github.com/gomodules/jsonpatch/tree/v2.0.0) (2019-06-25) +[Full Changelog](https://github.com/gomodules/jsonpatch/compare/1.0.0...v2.0.0) + +**Merged pull requests:** + +- Update go.mod and remove vendor folder [\#18](https://github.com/gomodules/jsonpatch/pull/18) ([tamalsaha](https://github.com/tamalsaha)) +- Change package path to gomodules.xyz/jsonpath [\#17](https://github.com/gomodules/jsonpatch/pull/17) ([tamalsaha](https://github.com/tamalsaha)) +- \[Emergency\] correct array index in backtrace [\#16](https://github.com/gomodules/jsonpatch/pull/16) ([kdada](https://github.com/kdada)) +- Added support for arrays at the root [\#15](https://github.com/gomodules/jsonpatch/pull/15) ([e-nikolov](https://github.com/e-nikolov)) +- Fix the example code in readme [\#14](https://github.com/gomodules/jsonpatch/pull/14) ([pytimer](https://github.com/pytimer)) + +## [1.0.0](https://github.com/gomodules/jsonpatch/tree/1.0.0) (2019-01-08) +**Fixed bugs:** + +- Correctly generate patch for nested object [\#8](https://github.com/gomodules/jsonpatch/issues/8) + +**Closed issues:** + +- Do releases and in SemVer [\#12](https://github.com/gomodules/jsonpatch/issues/12) +- Generated patch incorrect for Array replacement [\#1](https://github.com/gomodules/jsonpatch/issues/1) + +**Merged pull requests:** + +- Add JsonPatchOperation as type alias for Operation [\#13](https://github.com/gomodules/jsonpatch/pull/13) ([tamalsaha](https://github.com/tamalsaha)) +- Migrate to go mod [\#10](https://github.com/gomodules/jsonpatch/pull/10) ([tamalsaha](https://github.com/tamalsaha)) +- Add test for nested object [\#9](https://github.com/gomodules/jsonpatch/pull/9) ([tamalsaha](https://github.com/tamalsaha)) +- Add test for edit distance computation [\#7](https://github.com/gomodules/jsonpatch/pull/7) ([tamalsaha](https://github.com/tamalsaha)) +- Append edit distance operations from end to start [\#6](https://github.com/gomodules/jsonpatch/pull/6) ([tamalsaha](https://github.com/tamalsaha)) +- Add travis file [\#4](https://github.com/gomodules/jsonpatch/pull/4) ([tamalsaha](https://github.com/tamalsaha)) +- Run go fmt [\#3](https://github.com/gomodules/jsonpatch/pull/3) ([tamalsaha](https://github.com/tamalsaha)) +- Fix array comparison [\#2](https://github.com/gomodules/jsonpatch/pull/2) ([tamalsaha](https://github.com/tamalsaha)) + + + +\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file diff --git a/vendor/gomodules.xyz/jsonpatch/v2/README.md b/vendor/gomodules.xyz/jsonpatch/v2/README.md new file mode 100644 index 000000000000..a51d95aa0264 --- /dev/null +++ b/vendor/gomodules.xyz/jsonpatch/v2/README.md @@ -0,0 +1,52 @@ +# jsonpatch + +[![Build Status](https://travis-ci.org/gomodules/jsonpatch.svg?branch=master)](https://travis-ci.org/gomodules/jsonpatch) +[![Go Report Card](https://goreportcard.com/badge/gomodules.xyz/jsonpatch "Go Report Card")](https://goreportcard.com/report/gomodules.xyz/jsonpatch) +[![GoDoc](https://godoc.org/gomodules.xyz/jsonpatch?status.svg "GoDoc")](https://godoc.org/gomodules.xyz/jsonpatch) + +As per http://jsonpatch.com JSON Patch is specified in RFC 6902 from the IETF. + +JSON Patch allows you to generate JSON that describes changes you want to make to a document, so you don't have to send the whole doc. JSON Patch format is supported by HTTP PATCH method, allowing for standards based partial updates via REST APIs. + +```console +go get gomodules.xyz/jsonpatch/v2 +``` + +I tried some of the other "jsonpatch" go implementations, but none of them could diff two json documents and generate format like jsonpatch.com specifies. Here's an example of the patch format: + +```json +[ + { "op": "replace", "path": "/baz", "value": "boo" }, + { "op": "add", "path": "/hello", "value": ["world"] }, + { "op": "remove", "path": "/foo"} +] + +``` +The API is super simple + +## example + +```go +package main + +import ( + "fmt" + "gomodules.xyz/jsonpatch/v2" +) + +var simpleA = `{"a":100, "b":200, "c":"hello"}` +var simpleB = `{"a":100, "b":200, "c":"goodbye"}` + +func main() { + patch, e := jsonpatch.CreatePatch([]byte(simpleA), []byte(simpleB)) + if e != nil { + fmt.Printf("Error creating JSON patch:%v", e) + return + } + for _, operation := range patch { + fmt.Printf("%s\n", operation.Json()) + } +} +``` + +This code needs more tests, as it's a highly recursive, type-fiddly monster. It's not a lot of code, but it has to deal with a lot of complexity.