...

Text file src/k8s.io/kube-openapi/hack/update-json-library.sh

Documentation: k8s.io/kube-openapi/hack

     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.
     7HASH="${HASH:-$(cat ./hack/JSON-EXPERIMENTAL-HASH)}"
     8GO_JSON_EXPERIMENT_DIR="pkg/internal/third_party/go-json-experiment/json"
     9rm -rf $GO_JSON_EXPERIMENT_DIR
    10git clone https://github.com/go-json-experiment/json $GO_JSON_EXPERIMENT_DIR
    11cd $GO_JSON_EXPERIMENT_DIR
    12git reset --hard $HASH
    13# If HASH was set to a keyword like HEAD, get the actual commit ID
    14HASH=$(git rev-parse HEAD)
    15cat <<EOF > ../README.md
    16Forked from: https://github.com/go-json-experiment/json
    17Commit Hash: $HASH
    18
    19This internal fork exists to prevent dependency issues with go-json-experiment
    20until its API stabilizes.
    21EOF
    22
    23# Remove git directories 
    24rm -rf ".git"
    25rm -rf ".github"
    26# Remove images
    27rm *.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.
    31rm go.mod go.sum
    32# Update references to point to the fork
    33find . -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"

View as plain text