mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
Script to update pseudo references
This commit is contained in:
78
pseudo/update-fork-references.sh
Executable file
78
pseudo/update-fork-references.sh
Executable file
@@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -o xtrace
|
||||
|
||||
# replace the module name with the new module name
|
||||
function replaceModuleName {
|
||||
find . -name *.go | xargs sed -i -e "s!k8s.io/$1!sigs.k8s.io/kustomize/pseudo/k8s/$1!g"
|
||||
find . -name *.proto | xargs sed -i -e "s!k8s.io/$1!sigs.k8s.io/kustomize/pseudo/k8s/$1!g"
|
||||
find . -name *.md | xargs sed -i -e "s!k8s.io/$1!sigs.k8s.io/kustomize/pseudo/k8s/$1!g"
|
||||
}
|
||||
|
||||
# update the go.mod file, dropping the old module
|
||||
function updateGoModFile {
|
||||
go mod edit -droprequire=k8s.io/$1 || echo ""
|
||||
rm go.sum || echo ""
|
||||
}
|
||||
|
||||
# test the module
|
||||
function testGoMod {
|
||||
go test ./...
|
||||
gofmt -s -w .
|
||||
go mod tidy
|
||||
}
|
||||
|
||||
# update all go.mod files
|
||||
function updateAllGoModFiles {
|
||||
(cd api; updateGoModFile $1 )
|
||||
(cd kustomize; updateGoModFile $1 )
|
||||
(cd hack/crawl; updateGoModFile $1 )
|
||||
(cd pluginator; updateGoModFile $1 )
|
||||
|
||||
for goMod in $(find ./plugin/builtin -name 'go.mod'); do
|
||||
dir=$(dirname "${goMod}")
|
||||
(cd $dir; updateGoModFile $1 )
|
||||
done
|
||||
|
||||
for goMod in $(find ./plugin/someteam.example.com/v1 -name 'go.mod'); do
|
||||
dir=$(dirname "${goMod}")
|
||||
(cd $dir; updateGoModFile $1 )
|
||||
done
|
||||
}
|
||||
|
||||
# test all go modules
|
||||
function testAllModules {
|
||||
(cd api; testGoMod)
|
||||
(cd kustomize; testGoMod)
|
||||
(cd hack/crawl; testGoMod)
|
||||
(cd pluginator; testGoMod )
|
||||
|
||||
for goMod in $(find ./plugin/builtin -name 'go.mod'); do
|
||||
dir=$(dirname "${goMod}")
|
||||
(cd $dir; testGoMod )
|
||||
done
|
||||
|
||||
# Uncomment this when tests are added for this module
|
||||
# for goMod in $(find ./plugin/someteam.example.com/v1 -name 'go.mod'); do
|
||||
# dir=$(dirname "${goMod}")
|
||||
# (cd $dir; testGoMod )
|
||||
# done
|
||||
}
|
||||
|
||||
# update the names of the modules
|
||||
for item in api apimachinery client-go
|
||||
do
|
||||
replaceModuleName $item
|
||||
done
|
||||
|
||||
# update the go.mod files
|
||||
for item in api apimachinery client-go
|
||||
do
|
||||
updateAllGoModFiles $item
|
||||
done
|
||||
|
||||
# test all of the modules still work
|
||||
testAllModules
|
||||
|
||||
./travis/verify-deps.sh
|
||||
@@ -2,15 +2,17 @@
|
||||
|
||||
set -o xtrace
|
||||
|
||||
for item in api apimachinery client-go
|
||||
for dir in api kustomize pseudo kyaml plugin
|
||||
do
|
||||
if find pseudo -name 'go.*' | xargs grep "k8s.io/${item}" ; then
|
||||
echo "forbidden deps"
|
||||
exit 1
|
||||
fi
|
||||
if find pseudo -name '*.go' | xargs grep "k8s.io/${item}" ; then
|
||||
echo "forbidden deps"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
for item in api apimachinery client-go
|
||||
do
|
||||
if find $dir -name 'go.*' | xargs grep "k8s.io/${item}" ; then
|
||||
echo "forbidden deps"
|
||||
exit 1
|
||||
fi
|
||||
if find $dir -name '*.go' | xargs grep "k8s.io/${item}" ; then
|
||||
echo "forbidden deps"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
done
|
||||
Reference in New Issue
Block a user