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:
		@@ -23,28 +23,24 @@ set -o pipefail
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
 | 
					KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
 | 
				
			||||||
source "${KUBE_ROOT}/hack/lib/init.sh"
 | 
					source "${KUBE_ROOT}/hack/lib/init.sh"
 | 
				
			||||||
# Explicitly opt into go modules
 | 
					 | 
				
			||||||
export GO111MODULE=on
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
kube::golang::verify_go_version
 | 
					kube::golang::verify_go_version
 | 
				
			||||||
kube::golang::old::setup_env
 | 
					kube::golang::new::setup_env
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo 'installing mockgen'
 | 
					echo 'installing mockgen'
 | 
				
			||||||
pushd "${KUBE_ROOT}/hack/tools" >/dev/null
 | 
					pushd "${KUBE_ROOT}/hack/tools" >/dev/null
 | 
				
			||||||
  go install github.com/golang/mock/mockgen
 | 
					  go install github.com/golang/mock/mockgen
 | 
				
			||||||
popd >/dev/null
 | 
					popd >/dev/null
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function git_find() {
 | 
					function git_grep() {
 | 
				
			||||||
  # Similar to find but faster and easier to understand.  We want to include
 | 
					  git grep --untracked --exclude-standard \
 | 
				
			||||||
  # modified and untracked files because this might be running against code
 | 
					      "$@" \
 | 
				
			||||||
  # which is not tracked by git yet.
 | 
					 | 
				
			||||||
  git ls-files -cmo --exclude-standard \
 | 
					 | 
				
			||||||
      ':!:vendor/*'        `# catches vendor/...` \
 | 
					      ':!:vendor/*'        `# catches vendor/...` \
 | 
				
			||||||
      ':!:*/vendor/*'      `# catches any subdir/vendor/...` \
 | 
					      ':!:*/vendor/*'      `# catches any subdir/vendor/...` \
 | 
				
			||||||
      ':!:third_party/*'   `# catches third_party/...` \
 | 
					      ':!:third_party/*'   `# catches third_party/...` \
 | 
				
			||||||
      ':!:*/third_party/*' `# catches third_party/...` \
 | 
					      ':!:*/third_party/*' `# catches third_party/...` \
 | 
				
			||||||
      ':!:*/testdata/*' \
 | 
					      ':!:*/testdata/*'    `# catches any testdata` \
 | 
				
			||||||
      "$@"
 | 
					      ':(glob)**/*.go'
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cd "${KUBE_ROOT}"
 | 
					cd "${KUBE_ROOT}"
 | 
				
			||||||
@@ -55,19 +51,12 @@ GENERATED_MOCK_FILE_REGEX="^// Code generated by MockGen. DO NOT EDIT.$"
 | 
				
			|||||||
tmp=$(mktemp)
 | 
					tmp=$(mktemp)
 | 
				
			||||||
kube::util::trap_add "rm -f ${tmp:?}" EXIT
 | 
					kube::util::trap_add "rm -f ${tmp:?}" EXIT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# We use this pattern here rather than `git grep` because we don't really want
 | 
					git_grep -l -z "${GENERATED_MOCK_FILE_REGEX}" | xargs -0 rm -f
 | 
				
			||||||
# 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
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo 'executing go generate command on below files'
 | 
					echo 'executing go generate command on below files'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
git_find -z ':(glob)**/*.go' | while read -r -d $'\0' file; do
 | 
					git_grep -l -z "//go:generate mockgen" | while read -r -d $'\0' file; do
 | 
				
			||||||
  test -f "$file" || continue
 | 
					  echo "- ${file}"
 | 
				
			||||||
  grep -q "//go:generate mockgen" "$file" || continue
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  temp_file_name="$(kube::realpath "$(mktemp -t "$(basename "$0").XXXXXX")")"
 | 
					  temp_file_name="$(kube::realpath "$(mktemp -t "$(basename "$0").XXXXXX")")"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # search for build tag used in file
 | 
					  # 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"
 | 
					    BUILD_TAG_FILE=$temp_file_name go generate -v "$file"
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    # if no +build tag is defined in interface file
 | 
					    # 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
 | 
					  fi
 | 
				
			||||||
done
 | 
					done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
 | 
				
			|||||||
limitations under the License.
 | 
					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
 | 
					package pod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,7 +15,7 @@ limitations under the License.
 | 
				
			|||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Code generated by MockGen. DO NOT EDIT.
 | 
					// 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 is a generated GoMock package.
 | 
				
			||||||
package testing
 | 
					package testing
 | 
				
			||||||
@@ -53,15 +53,15 @@ func (m *MockManager) EXPECT() *MockManagerMockRecorder {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// AddPod mocks base method.
 | 
					// AddPod mocks base method.
 | 
				
			||||||
func (m *MockManager) AddPod(arg0 *v1.Pod) {
 | 
					func (m *MockManager) AddPod(pod *v1.Pod) {
 | 
				
			||||||
	m.ctrl.T.Helper()
 | 
						m.ctrl.T.Helper()
 | 
				
			||||||
	m.ctrl.Call(m, "AddPod", arg0)
 | 
						m.ctrl.Call(m, "AddPod", pod)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// AddPod indicates an expected call of AddPod.
 | 
					// 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()
 | 
						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.
 | 
					// GetMirrorPodByPod mocks base method.
 | 
				
			||||||
@@ -96,18 +96,18 @@ func (mr *MockManagerMockRecorder) GetPodAndMirrorPod(arg0 interface{}) *gomock.
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetPodByFullName mocks base method.
 | 
					// 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()
 | 
						m.ctrl.T.Helper()
 | 
				
			||||||
	ret := m.ctrl.Call(m, "GetPodByFullName", arg0)
 | 
						ret := m.ctrl.Call(m, "GetPodByFullName", podFullName)
 | 
				
			||||||
	ret0, _ := ret[0].(*v1.Pod)
 | 
						ret0, _ := ret[0].(*v1.Pod)
 | 
				
			||||||
	ret1, _ := ret[1].(bool)
 | 
						ret1, _ := ret[1].(bool)
 | 
				
			||||||
	return ret0, ret1
 | 
						return ret0, ret1
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetPodByFullName indicates an expected call of GetPodByFullName.
 | 
					// 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()
 | 
						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.
 | 
					// GetPodByMirrorPod mocks base method.
 | 
				
			||||||
@@ -126,18 +126,18 @@ func (mr *MockManagerMockRecorder) GetPodByMirrorPod(arg0 interface{}) *gomock.C
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetPodByName mocks base method.
 | 
					// 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()
 | 
						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)
 | 
						ret0, _ := ret[0].(*v1.Pod)
 | 
				
			||||||
	ret1, _ := ret[1].(bool)
 | 
						ret1, _ := ret[1].(bool)
 | 
				
			||||||
	return ret0, ret1
 | 
						return ret0, ret1
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetPodByName indicates an expected call of GetPodByName.
 | 
					// 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()
 | 
						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.
 | 
					// GetPodByUID mocks base method.
 | 
				
			||||||
@@ -201,51 +201,51 @@ func (mr *MockManagerMockRecorder) GetUIDTranslations() *gomock.Call {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// RemovePod mocks base method.
 | 
					// RemovePod mocks base method.
 | 
				
			||||||
func (m *MockManager) RemovePod(arg0 *v1.Pod) {
 | 
					func (m *MockManager) RemovePod(pod *v1.Pod) {
 | 
				
			||||||
	m.ctrl.T.Helper()
 | 
						m.ctrl.T.Helper()
 | 
				
			||||||
	m.ctrl.Call(m, "RemovePod", arg0)
 | 
						m.ctrl.Call(m, "RemovePod", pod)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// RemovePod indicates an expected call of RemovePod.
 | 
					// 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()
 | 
						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.
 | 
					// SetPods mocks base method.
 | 
				
			||||||
func (m *MockManager) SetPods(arg0 []*v1.Pod) {
 | 
					func (m *MockManager) SetPods(pods []*v1.Pod) {
 | 
				
			||||||
	m.ctrl.T.Helper()
 | 
						m.ctrl.T.Helper()
 | 
				
			||||||
	m.ctrl.Call(m, "SetPods", arg0)
 | 
						m.ctrl.Call(m, "SetPods", pods)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// SetPods indicates an expected call of SetPods.
 | 
					// 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()
 | 
						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.
 | 
					// 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()
 | 
						m.ctrl.T.Helper()
 | 
				
			||||||
	ret := m.ctrl.Call(m, "TranslatePodUID", arg0)
 | 
						ret := m.ctrl.Call(m, "TranslatePodUID", uid)
 | 
				
			||||||
	ret0, _ := ret[0].(types0.ResolvedPodUID)
 | 
						ret0, _ := ret[0].(types0.ResolvedPodUID)
 | 
				
			||||||
	return ret0
 | 
						return ret0
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TranslatePodUID indicates an expected call of TranslatePodUID.
 | 
					// 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()
 | 
						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.
 | 
					// UpdatePod mocks base method.
 | 
				
			||||||
func (m *MockManager) UpdatePod(arg0 *v1.Pod) {
 | 
					func (m *MockManager) UpdatePod(pod *v1.Pod) {
 | 
				
			||||||
	m.ctrl.T.Helper()
 | 
						m.ctrl.T.Helper()
 | 
				
			||||||
	m.ctrl.Call(m, "UpdatePod", arg0)
 | 
						m.ctrl.Call(m, "UpdatePod", pod)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// UpdatePod indicates an expected call of UpdatePod.
 | 
					// 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()
 | 
						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.
 | 
					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
 | 
					package driver
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user