k8s.io/kube-openapi@v0.0.0-20240228011516-70dd3763d340/hack/update-json-library.sh (about) 1 #!/usr/bin/env bash 2 # This script can be called via ./hack/update-json-library.sh` to update the 3 # go-json-experiment fork in the repo. 4 5 # The HASH parameter may be set as part of the invocation to this script or 6 # the default hash from ./hack/JSON-EXPERIMENTAL-HASH will be used. 7 HASH="${HASH:-$(cat ./hack/JSON-EXPERIMENTAL-HASH)}" 8 GO_JSON_EXPERIMENT_DIR="pkg/internal/third_party/go-json-experiment/json" 9 rm -rf $GO_JSON_EXPERIMENT_DIR 10 git clone https://github.com/go-json-experiment/json $GO_JSON_EXPERIMENT_DIR 11 cd $GO_JSON_EXPERIMENT_DIR 12 git reset --hard $HASH 13 # If HASH was set to a keyword like HEAD, get the actual commit ID 14 HASH=$(git rev-parse HEAD) 15 cat <<EOF > ../README.md 16 Forked from: https://github.com/go-json-experiment/json 17 Commit Hash: $HASH 18 19 This internal fork exists to prevent dependency issues with go-json-experiment 20 until its API stabilizes. 21 EOF 22 23 # Remove git directories 24 rm -rf ".git" 25 rm -rf ".github" 26 # Remove images 27 rm *.png 28 # Remove go.{mod|sum} 29 # NOTE: go-json-experiment has no go mod dependencies at the moment. 30 # If this changes, the code will need to be updated. 31 rm go.mod go.sum 32 # Update references to point to the fork 33 find . -type f -name "*.go" -print0 | xargs -0 perl -pi -e "s#github.com/go-json-experiment/json#k8s.io/kube-openapi/${GO_JSON_EXPERIMENT_DIR}#g"