Unpin transformers from kyaml.

This commit is contained in:
jregan
2020-08-22 17:03:52 -07:00
parent a0b7288329
commit 1dffc7577b
49 changed files with 151 additions and 102 deletions

View File

@@ -6,13 +6,13 @@
# released version of the kustomize API,
# run this from the repo root:
#
# ./hack/pinUnpinPluginApiDep.sh pin v0.2.0
# ./hack/pinUnpinPluginApiDep.sh pin api v0.2.0
#
# To replace fixed dependence with
# dependence on local filesystem (HEAD)
# run this from the repo root:
#
# ./hack/pinUnpinPluginApiDep.sh unPin
# ./hack/pinUnpinPluginApiDep.sh unPin api
#
# All plugins, even plugins not written in Go,
# have a unit test written in Go that depends
@@ -30,29 +30,26 @@
# they are just examples - but likely should
# remain unpinned too. Nothing in the outside
# world should depend on these plugin modules,
# so there's no reason for them to be properly
# pinned.
#
# An external plugin author will obviously
# want to pin their plugin to some set of fixed
# dependencies, and the go.mod files for the
# plugins in this repo are just examples of how
# to do so.
# so there's no reason for them to be pinned.
set -o errexit
set -o nounset
set -o pipefail
#set -o pipefail
function doUnPin {
oldV=$(grep -m 1 sigs.k8s.io/kustomize/api go.mod | awk '{print $NF}')
go mod edit -replace=sigs.k8s.io/kustomize/api@${oldV}=$1
oldV=$(grep -m 1 sigs.k8s.io/kustomize/${module} go.mod | awk '{print $NF}')
if [ ! -z $oldV ]; then
go mod edit -replace=sigs.k8s.io/kustomize/${module}@${oldV}=$1
fi
go mod tidy
}
function doPin {
oldV=$(grep -m 1 sigs.k8s.io/kustomize/api go.mod | awk '{print $NF}')
go mod edit -dropreplace=sigs.k8s.io/kustomize/api@${oldV}
go mod edit -require=sigs.k8s.io/kustomize/api@$1
oldV=$(grep -m 1 sigs.k8s.io/kustomize/${module} go.mod | awk '{print $NF}')
if [ ! -z $oldV ]; then
go mod edit -dropreplace=sigs.k8s.io/kustomize/${module}@${oldV}
go mod edit -require=sigs.k8s.io/kustomize/${module}@$1
fi
go mod tidy
}
@@ -65,28 +62,46 @@ function forEachGoMod {
}
function unPin {
forEachGoMod doUnPin ./plugin/builtin ../../../api
forEachGoMod doUnPin ./plugin/someteam.example.com/v1 ../../../../api
echo "Unpinning $module"
forEachGoMod doUnPin ./plugin/builtin ../../../${module}
forEachGoMod doUnPin ./plugin/someteam.example.com/v1 ../../../../${module}
}
function pin {
forEachGoMod doPin ./plugin/builtin $version
forEachGoMod doPin ./plugin/someteam.example.com/v1 $version
echo "Pinning $module to $version"
forEachGoMod doPin ./plugin/builtin ${version}
forEachGoMod doPin ./plugin/someteam.example.com/v1 ${version}
}
if [ "$#" -eq 0 ]; then
echo "Pin or unpin plugins, e.g."
echo " "
echo " ./hack/pinUnpinPluginApiDep.sh pin api v0.2.0"
echo " "
echo " ./hack/pinUnpinPluginApiDep.sh unPin api"
echo " "
exit 1
fi
operation=$1
if [[ ("$operation" != "pin") && ("$operation" != "unPin") ]]; then
echo "unknown operation $operation"
exit 1
fi
module=$2
if [[ ("$module" != "api") && ("$module" != "kyaml") ]]; then
echo "unknown module $module"
exit 1
fi
version="unnecessary"
if [ "$operation" == "pin" ]; then
if [ "$#" -le 1 ]; then
if [ "$#" -le 2 ]; then
echo "Specify version to pin, e.g. '$0 pin v0.2.0'"
exit 1
fi
version=$2
version=$3
fi
$operation