mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-15 23:03:40 +00:00
Fix update/verify-mocks.sh
There appears to be a bug in `go generate` for workspaces which will be fixed in the 1.22.1 release.
This commit is contained in:
parent
58ab5eea89
commit
b725fd20c2
@ -23,28 +23,24 @@ set -o pipefail
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||
source "${KUBE_ROOT}/hack/lib/init.sh"
|
||||
# Explicitly opt into go modules
|
||||
export GO111MODULE=on
|
||||
|
||||
kube::golang::verify_go_version
|
||||
kube::golang::old::setup_env
|
||||
kube::golang::new::setup_env
|
||||
|
||||
echo 'installing mockgen'
|
||||
pushd "${KUBE_ROOT}/hack/tools" >/dev/null
|
||||
go install github.com/golang/mock/mockgen
|
||||
popd >/dev/null
|
||||
|
||||
function git_find() {
|
||||
# Similar to find but faster and easier to understand. We want to include
|
||||
# modified and untracked files because this might be running against code
|
||||
# which is not tracked by git yet.
|
||||
git ls-files -cmo --exclude-standard \
|
||||
function git_grep() {
|
||||
git grep --untracked --exclude-standard \
|
||||
"$@" \
|
||||
':!:vendor/*' `# catches vendor/...` \
|
||||
':!:*/vendor/*' `# catches any subdir/vendor/...` \
|
||||
':!:third_party/*' `# catches third_party/...` \
|
||||
':!:*/third_party/*' `# catches third_party/...` \
|
||||
':!:*/testdata/*' \
|
||||
"$@"
|
||||
':!:*/testdata/*' `# catches any testdata` \
|
||||
':(glob)**/*.go'
|
||||
}
|
||||
|
||||
cd "${KUBE_ROOT}"
|
||||
@ -55,19 +51,12 @@ GENERATED_MOCK_FILE_REGEX="^// Code generated by MockGen. DO NOT EDIT.$"
|
||||
tmp=$(mktemp)
|
||||
kube::util::trap_add "rm -f ${tmp:?}" EXIT
|
||||
|
||||
# We use this pattern here rather than `git grep` because we don't really want
|
||||
# to encode the pathspec list in multiple places and anything more complicated
|
||||
# just isn't worth the effort.
|
||||
git_find -z ':(glob)**/*.go' \
|
||||
| { xargs -0 grep -l --null "${GENERATED_MOCK_FILE_REGEX}" || true; } \
|
||||
| xargs -0 rm -f
|
||||
git_grep -l -z "${GENERATED_MOCK_FILE_REGEX}" | xargs -0 rm -f
|
||||
|
||||
echo 'executing go generate command on below files'
|
||||
|
||||
git_find -z ':(glob)**/*.go' | while read -r -d $'\0' file; do
|
||||
test -f "$file" || continue
|
||||
grep -q "//go:generate mockgen" "$file" || continue
|
||||
|
||||
git_grep -l -z "//go:generate mockgen" | while read -r -d $'\0' file; do
|
||||
echo "- ${file}"
|
||||
temp_file_name="$(kube::realpath "$(mktemp -t "$(basename "$0").XXXXXX")")"
|
||||
|
||||
# search for build tag used in file
|
||||
@ -82,7 +71,9 @@ git_find -z ':(glob)**/*.go' | while read -r -d $'\0' file; do
|
||||
BUILD_TAG_FILE=$temp_file_name go generate -v "$file"
|
||||
else
|
||||
# if no +build tag is defined in interface file
|
||||
go generate -v "$file"
|
||||
# NOTE: This works around a bug in `go generate` with workspaces, which
|
||||
# should be fixed in Go 1.22.1.
|
||||
go -C "$(dirname "$file")" generate "$(basename "$file")"
|
||||
fi
|
||||
done
|
||||
|
||||
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
//go:generate mockgen -destination=testing/mock_manager.go -package=testing -build_flags=-mod=mod . Manager
|
||||
//go:generate mockgen -source=pod_manager.go -destination=testing/mock_manager.go -package=testing Manager
|
||||
package pod
|
||||
|
||||
import (
|
||||
|
@ -15,7 +15,7 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: k8s.io/kubernetes/pkg/kubelet/pod (interfaces: Manager)
|
||||
// Source: pod_manager.go
|
||||
|
||||
// Package testing is a generated GoMock package.
|
||||
package testing
|
||||
@ -53,15 +53,15 @@ func (m *MockManager) EXPECT() *MockManagerMockRecorder {
|
||||
}
|
||||
|
||||
// AddPod mocks base method.
|
||||
func (m *MockManager) AddPod(arg0 *v1.Pod) {
|
||||
func (m *MockManager) AddPod(pod *v1.Pod) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "AddPod", arg0)
|
||||
m.ctrl.Call(m, "AddPod", pod)
|
||||
}
|
||||
|
||||
// AddPod indicates an expected call of AddPod.
|
||||
func (mr *MockManagerMockRecorder) AddPod(arg0 interface{}) *gomock.Call {
|
||||
func (mr *MockManagerMockRecorder) AddPod(pod interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddPod", reflect.TypeOf((*MockManager)(nil).AddPod), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddPod", reflect.TypeOf((*MockManager)(nil).AddPod), pod)
|
||||
}
|
||||
|
||||
// GetMirrorPodByPod mocks base method.
|
||||
@ -96,18 +96,18 @@ func (mr *MockManagerMockRecorder) GetPodAndMirrorPod(arg0 interface{}) *gomock.
|
||||
}
|
||||
|
||||
// GetPodByFullName mocks base method.
|
||||
func (m *MockManager) GetPodByFullName(arg0 string) (*v1.Pod, bool) {
|
||||
func (m *MockManager) GetPodByFullName(podFullName string) (*v1.Pod, bool) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetPodByFullName", arg0)
|
||||
ret := m.ctrl.Call(m, "GetPodByFullName", podFullName)
|
||||
ret0, _ := ret[0].(*v1.Pod)
|
||||
ret1, _ := ret[1].(bool)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetPodByFullName indicates an expected call of GetPodByFullName.
|
||||
func (mr *MockManagerMockRecorder) GetPodByFullName(arg0 interface{}) *gomock.Call {
|
||||
func (mr *MockManagerMockRecorder) GetPodByFullName(podFullName interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPodByFullName", reflect.TypeOf((*MockManager)(nil).GetPodByFullName), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPodByFullName", reflect.TypeOf((*MockManager)(nil).GetPodByFullName), podFullName)
|
||||
}
|
||||
|
||||
// GetPodByMirrorPod mocks base method.
|
||||
@ -126,18 +126,18 @@ func (mr *MockManagerMockRecorder) GetPodByMirrorPod(arg0 interface{}) *gomock.C
|
||||
}
|
||||
|
||||
// GetPodByName mocks base method.
|
||||
func (m *MockManager) GetPodByName(arg0, arg1 string) (*v1.Pod, bool) {
|
||||
func (m *MockManager) GetPodByName(namespace, name string) (*v1.Pod, bool) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetPodByName", arg0, arg1)
|
||||
ret := m.ctrl.Call(m, "GetPodByName", namespace, name)
|
||||
ret0, _ := ret[0].(*v1.Pod)
|
||||
ret1, _ := ret[1].(bool)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetPodByName indicates an expected call of GetPodByName.
|
||||
func (mr *MockManagerMockRecorder) GetPodByName(arg0, arg1 interface{}) *gomock.Call {
|
||||
func (mr *MockManagerMockRecorder) GetPodByName(namespace, name interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPodByName", reflect.TypeOf((*MockManager)(nil).GetPodByName), arg0, arg1)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPodByName", reflect.TypeOf((*MockManager)(nil).GetPodByName), namespace, name)
|
||||
}
|
||||
|
||||
// GetPodByUID mocks base method.
|
||||
@ -201,51 +201,51 @@ func (mr *MockManagerMockRecorder) GetUIDTranslations() *gomock.Call {
|
||||
}
|
||||
|
||||
// RemovePod mocks base method.
|
||||
func (m *MockManager) RemovePod(arg0 *v1.Pod) {
|
||||
func (m *MockManager) RemovePod(pod *v1.Pod) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "RemovePod", arg0)
|
||||
m.ctrl.Call(m, "RemovePod", pod)
|
||||
}
|
||||
|
||||
// RemovePod indicates an expected call of RemovePod.
|
||||
func (mr *MockManagerMockRecorder) RemovePod(arg0 interface{}) *gomock.Call {
|
||||
func (mr *MockManagerMockRecorder) RemovePod(pod interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemovePod", reflect.TypeOf((*MockManager)(nil).RemovePod), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemovePod", reflect.TypeOf((*MockManager)(nil).RemovePod), pod)
|
||||
}
|
||||
|
||||
// SetPods mocks base method.
|
||||
func (m *MockManager) SetPods(arg0 []*v1.Pod) {
|
||||
func (m *MockManager) SetPods(pods []*v1.Pod) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "SetPods", arg0)
|
||||
m.ctrl.Call(m, "SetPods", pods)
|
||||
}
|
||||
|
||||
// SetPods indicates an expected call of SetPods.
|
||||
func (mr *MockManagerMockRecorder) SetPods(arg0 interface{}) *gomock.Call {
|
||||
func (mr *MockManagerMockRecorder) SetPods(pods interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetPods", reflect.TypeOf((*MockManager)(nil).SetPods), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetPods", reflect.TypeOf((*MockManager)(nil).SetPods), pods)
|
||||
}
|
||||
|
||||
// TranslatePodUID mocks base method.
|
||||
func (m *MockManager) TranslatePodUID(arg0 types.UID) types0.ResolvedPodUID {
|
||||
func (m *MockManager) TranslatePodUID(uid types.UID) types0.ResolvedPodUID {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "TranslatePodUID", arg0)
|
||||
ret := m.ctrl.Call(m, "TranslatePodUID", uid)
|
||||
ret0, _ := ret[0].(types0.ResolvedPodUID)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// TranslatePodUID indicates an expected call of TranslatePodUID.
|
||||
func (mr *MockManagerMockRecorder) TranslatePodUID(arg0 interface{}) *gomock.Call {
|
||||
func (mr *MockManagerMockRecorder) TranslatePodUID(uid interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TranslatePodUID", reflect.TypeOf((*MockManager)(nil).TranslatePodUID), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TranslatePodUID", reflect.TypeOf((*MockManager)(nil).TranslatePodUID), uid)
|
||||
}
|
||||
|
||||
// UpdatePod mocks base method.
|
||||
func (m *MockManager) UpdatePod(arg0 *v1.Pod) {
|
||||
func (m *MockManager) UpdatePod(pod *v1.Pod) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "UpdatePod", arg0)
|
||||
m.ctrl.Call(m, "UpdatePod", pod)
|
||||
}
|
||||
|
||||
// UpdatePod indicates an expected call of UpdatePod.
|
||||
func (mr *MockManagerMockRecorder) UpdatePod(arg0 interface{}) *gomock.Call {
|
||||
func (mr *MockManagerMockRecorder) UpdatePod(pod interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdatePod", reflect.TypeOf((*MockManager)(nil).UpdatePod), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdatePod", reflect.TypeOf((*MockManager)(nil).UpdatePod), pod)
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
//go:generate mockgen -package=driver -destination=driver.mock.go -build_flags=-mod=mod github.com/container-storage-interface/spec/lib/go/csi IdentityServer,ControllerServer,NodeServer
|
||||
//go:generate mockgen -package=driver -destination=driver.mock.go -build_flags=-mod=readonly github.com/container-storage-interface/spec/lib/go/csi IdentityServer,ControllerServer,NodeServer
|
||||
|
||||
package driver
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user