Pin kustomize and the plugins to kust Api v0.2.0

This commit is contained in:
Jeffrey Regan
2019-11-11 19:34:54 -08:00
parent bae6418ca2
commit 2dd148af24
55 changed files with 307 additions and 183 deletions

61
hack/pinUnpinPluginApiDep.sh Executable file
View File

@@ -0,0 +1,61 @@
#!/usr/bin/env bash
# Copyright 2019 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0
# This script unpins or repins the Go kustomize API dependence
# for all the plugins in the repo.
# Run from repo root, e.g.
#
# ./hack/pinUnpinPluginApiDep.sh pin v0.2.0
#
# or
#
# ./hack/pinUnpinPluginApiDep.sh unPin
#
set -o errexit
set -o nounset
set -o pipefail
operation=$1
version=$2
if [[ ("$operation" != "pin") && ("$operation" != "unPin") ]]; then
echo "unknown operation $operation"
exit 1
fi
function doUnPin {
oldV=$(grep -m 1 sigs.k8s.io/kustomize/api go.mod | awk '{print $2}')
go mod edit -replace=sigs.k8s.io/kustomize/api@${oldV}=$1
go mod tidy
}
function doPin {
oldV=$(grep -m 1 sigs.k8s.io/kustomize/api go.mod | awk '{print $2}')
go mod edit -dropreplace=sigs.k8s.io/kustomize/api@${oldV}
go mod edit -dropreplace=sigs.k8s.io/kustomize/api@v0.1.1
go mod edit -require=sigs.k8s.io/kustomize/api@$1
go mod tidy
}
function forEachGoMod {
for goMod in $(find $2 -name 'go.mod'); do
d=$(dirname "${goMod}")
echo $d
(cd $d; $1 $3)
done
}
function unPin {
forEachGoMod doUnPin ./plugin/builtin ../../../api
forEachGoMod doUnPin ./plugin/someteam.example.com ../../../../api
}
function pin {
forEachGoMod doPin ./plugin/builtin $version
forEachGoMod doPin ./plugin/someteam.example.com $version
}
$operation