From 44ef39da2f63de817444bf798383e59d3ab25aaa Mon Sep 17 00:00:00 2001 From: Brandon Palm Date: Thu, 13 Nov 2025 17:15:22 -0600 Subject: [PATCH 1/2] mockgen deprecated: use uber-go/mock instead --- go.mod | 1 + go.sum | 2 ++ pkg/asset/config/env_config.go | 2 +- pkg/executer/mock_executer.go | 3 ++- pkg/ignition/mock_ignition.go | 14 ++++++++---- pkg/release/mock_release.go | 40 ++++++++++++++++++++-------------- 6 files changed, 40 insertions(+), 22 deletions(-) diff --git a/go.mod b/go.mod index 3a3870c1..94424b76 100644 --- a/go.mod +++ b/go.mod @@ -33,6 +33,7 @@ require ( github.com/spf13/cobra v1.10.2 github.com/thedevsaddam/retry v1.2.1 github.com/thoas/go-funk v0.9.3 + go.uber.org/mock v0.6.0 golang.org/x/crypto v0.47.0 golang.org/x/term v0.39.0 k8s.io/api v0.30.3 diff --git a/go.sum b/go.sum index 26a24e22..ca3b29ce 100644 --- a/go.sum +++ b/go.sum @@ -1288,6 +1288,8 @@ go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= +go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= diff --git a/pkg/asset/config/env_config.go b/pkg/asset/config/env_config.go index 16e69f4e..9fca0879 100644 --- a/pkg/asset/config/env_config.go +++ b/pkg/asset/config/env_config.go @@ -138,7 +138,7 @@ func (e *EnvConfig) FindInAssets(filePattern string) string { } // FindFilesInCache returns the files from cache whose name match the given regexp. -func (e *EnvConfig) FindFilesInCache(pattern string) (files []*asset.File, err error) { +func (e *EnvConfig) FindFilesInCache(pattern string) (files []*asset.File, err error) { matches, err := filepath.Glob(filepath.Join(e.CacheDir, pattern)) if err != nil { return nil, err diff --git a/pkg/executer/mock_executer.go b/pkg/executer/mock_executer.go index f49feb58..be876b10 100644 --- a/pkg/executer/mock_executer.go +++ b/pkg/executer/mock_executer.go @@ -13,13 +13,14 @@ import ( os "os" reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockExecuter is a mock of Executer interface. type MockExecuter struct { ctrl *gomock.Controller recorder *MockExecuterMockRecorder + isgomock struct{} } // MockExecuterMockRecorder is the mock recorder for MockExecuter. diff --git a/pkg/ignition/mock_ignition.go b/pkg/ignition/mock_ignition.go index c89f8523..5d273c38 100644 --- a/pkg/ignition/mock_ignition.go +++ b/pkg/ignition/mock_ignition.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: ignition.go +// +// Generated by this command: +// +// mockgen -source=ignition.go -package=ignitionutil -destination=mock_ignition.go +// // Package ignitionutil is a generated GoMock package. package ignitionutil @@ -8,13 +13,14 @@ import ( reflect "reflect" types "github.com/coreos/ignition/v2/config/v3_2/types" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockIgnition is a mock of Ignition interface. type MockIgnition struct { ctrl *gomock.Controller recorder *MockIgnitionMockRecorder + isgomock struct{} } // MockIgnitionMockRecorder is the mock recorder for MockIgnition. @@ -44,7 +50,7 @@ func (m *MockIgnition) MergeIgnitionConfig(base, overrides *types.Config) (*type } // MergeIgnitionConfig indicates an expected call of MergeIgnitionConfig. -func (mr *MockIgnitionMockRecorder) MergeIgnitionConfig(base, overrides interface{}) *gomock.Call { +func (mr *MockIgnitionMockRecorder) MergeIgnitionConfig(base, overrides any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MergeIgnitionConfig", reflect.TypeOf((*MockIgnition)(nil).MergeIgnitionConfig), base, overrides) } @@ -59,7 +65,7 @@ func (m *MockIgnition) ParseIgnitionFile(path string) (*types.Config, error) { } // ParseIgnitionFile indicates an expected call of ParseIgnitionFile. -func (mr *MockIgnitionMockRecorder) ParseIgnitionFile(path interface{}) *gomock.Call { +func (mr *MockIgnitionMockRecorder) ParseIgnitionFile(path any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ParseIgnitionFile", reflect.TypeOf((*MockIgnition)(nil).ParseIgnitionFile), path) } @@ -73,7 +79,7 @@ func (m *MockIgnition) WriteIgnitionFile(path string, config *types.Config) erro } // WriteIgnitionFile indicates an expected call of WriteIgnitionFile. -func (mr *MockIgnitionMockRecorder) WriteIgnitionFile(path, config interface{}) *gomock.Call { +func (mr *MockIgnitionMockRecorder) WriteIgnitionFile(path, config any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteIgnitionFile", reflect.TypeOf((*MockIgnition)(nil).WriteIgnitionFile), path, config) } diff --git a/pkg/release/mock_release.go b/pkg/release/mock_release.go index c49432f6..674055bb 100644 --- a/pkg/release/mock_release.go +++ b/pkg/release/mock_release.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: release.go +// +// Generated by this command: +// +// mockgen -source=release.go -package=release -destination=mock_release.go +// // Package release is a generated GoMock package. package release @@ -7,13 +12,14 @@ package release import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockRelease is a mock of Release interface. type MockRelease struct { ctrl *gomock.Controller recorder *MockReleaseMockRecorder + isgomock struct{} } // MockReleaseMockRecorder is the mock recorder for MockRelease. @@ -33,32 +39,34 @@ func (m *MockRelease) EXPECT() *MockReleaseMockRecorder { return m.recorder } -// ExtractFile mocks base method. -func (m *MockRelease) ExtractFile(image, filename string) (string, error) { +// ExtractCommand mocks base method. +func (m *MockRelease) ExtractCommand(command, dest string) (string, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ExtractFile", image, filename) + ret := m.ctrl.Call(m, "ExtractCommand", command, dest) ret0, _ := ret[0].(string) ret1, _ := ret[1].(error) return ret0, ret1 } -// ExtractFile indicates an expected call of ExtractFile. -func (mr *MockReleaseMockRecorder) ExtractFile(image, filename interface{}) *gomock.Call { +// ExtractCommand indicates an expected call of ExtractCommand. +func (mr *MockReleaseMockRecorder) ExtractCommand(command, dest any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExtractFile", reflect.TypeOf((*MockRelease)(nil).ExtractFile), image, filename) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExtractCommand", reflect.TypeOf((*MockRelease)(nil).ExtractCommand), command, dest) } -func (m *MockRelease) ExtractCommand(command string, dest string) (string, error) { +// ExtractFile mocks base method. +func (m *MockRelease) ExtractFile(image, filename string) (string, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ExtractCommand", command, dest) + ret := m.ctrl.Call(m, "ExtractFile", image, filename) ret0, _ := ret[0].(string) ret1, _ := ret[1].(error) return ret0, ret1 } -func (mr *MockReleaseMockRecorder) ExtractCommand(command string, dest string) *gomock.Call { +// ExtractFile indicates an expected call of ExtractFile. +func (mr *MockReleaseMockRecorder) ExtractFile(image, filename any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExtractCommand", reflect.TypeOf((*MockRelease)(nil).ExtractCommand), command, dest) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExtractFile", reflect.TypeOf((*MockRelease)(nil).ExtractFile), image, filename) } // GetImageFromRelease mocks base method. @@ -71,7 +79,7 @@ func (m *MockRelease) GetImageFromRelease(imageName string) (string, error) { } // GetImageFromRelease indicates an expected call of GetImageFromRelease. -func (mr *MockReleaseMockRecorder) GetImageFromRelease(imageName interface{}) *gomock.Call { +func (mr *MockReleaseMockRecorder) GetImageFromRelease(imageName any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetImageFromRelease", reflect.TypeOf((*MockRelease)(nil).GetImageFromRelease), imageName) } @@ -79,15 +87,15 @@ func (mr *MockReleaseMockRecorder) GetImageFromRelease(imageName interface{}) *g // MirrorInstallImages mocks base method. func (m *MockRelease) MirrorInstallImages() error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "MirrorReleaseImages") + ret := m.ctrl.Call(m, "MirrorInstallImages") ret0, _ := ret[0].(error) return ret0 } -// MirrorReleaseImages indicates an expected call of MirrorReleaseImages. -func (mr *MockReleaseMockRecorder) MirrorReleaseImages() *gomock.Call { +// MirrorInstallImages indicates an expected call of MirrorInstallImages. +func (mr *MockReleaseMockRecorder) MirrorInstallImages() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MirrorReleaseImages", reflect.TypeOf((*MockRelease)(nil).MirrorInstallImages)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MirrorInstallImages", reflect.TypeOf((*MockRelease)(nil).MirrorInstallImages)) } // GetMappingFile mocks base method. From 9a92161c855ffd7d5198d7eea103054135013f98 Mon Sep 17 00:00:00 2001 From: Brandon Palm Date: Wed, 28 Jan 2026 14:16:58 -0600 Subject: [PATCH 2/2] Update test files to use uber-go/mock import The test files were still importing github.com/golang/mock/gomock instead of go.uber.org/mock/gomock, causing type mismatch errors when the mocks were regenerated with uber-go/mock. --- pkg/coreos/coreos_test.go | 2 +- pkg/genisoimage/genisoimage_test.go | 2 +- pkg/installer/installer_test.go | 2 +- pkg/registry/registry_test.go | 2 +- pkg/release/release_test.go | 2 +- pkg/skopeo/skopeo_test.go | 2 +- pkg/syslinux/syslinux_test.go | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/coreos/coreos_test.go b/pkg/coreos/coreos_test.go index 0b222a73..0cdc2e0c 100644 --- a/pkg/coreos/coreos_test.go +++ b/pkg/coreos/coreos_test.go @@ -8,7 +8,7 @@ import ( "github.com/go-openapi/swag" "github.com/openshift/appliance/pkg/types" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" . "github.com/onsi/ginkgo/v2/dsl/core" . "github.com/onsi/gomega" "github.com/openshift/appliance/pkg/asset/config" diff --git a/pkg/genisoimage/genisoimage_test.go b/pkg/genisoimage/genisoimage_test.go index df7f42eb..fc95702d 100644 --- a/pkg/genisoimage/genisoimage_test.go +++ b/pkg/genisoimage/genisoimage_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" . "github.com/onsi/ginkgo/v2/dsl/core" . "github.com/onsi/gomega" "github.com/openshift/appliance/pkg/executer" diff --git a/pkg/installer/installer_test.go b/pkg/installer/installer_test.go index d1688195..c7e1c7fc 100644 --- a/pkg/installer/installer_test.go +++ b/pkg/installer/installer_test.go @@ -10,7 +10,7 @@ import ( "github.com/openshift/appliance/pkg/release" "github.com/openshift/appliance/pkg/types" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" . "github.com/onsi/ginkgo/v2/dsl/core" . "github.com/onsi/gomega" "github.com/openshift/appliance/pkg/asset/config" diff --git a/pkg/registry/registry_test.go b/pkg/registry/registry_test.go index 13cb7331..e7d59464 100644 --- a/pkg/registry/registry_test.go +++ b/pkg/registry/registry_test.go @@ -7,7 +7,7 @@ import ( "strings" "testing" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" . "github.com/onsi/ginkgo/v2/dsl/core" . "github.com/onsi/ginkgo/v2/dsl/table" . "github.com/onsi/gomega" diff --git a/pkg/release/release_test.go b/pkg/release/release_test.go index 0d7e09b9..c07490ab 100644 --- a/pkg/release/release_test.go +++ b/pkg/release/release_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/go-openapi/swag" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" . "github.com/onsi/ginkgo/v2/dsl/core" . "github.com/onsi/gomega" "github.com/openshift/appliance/pkg/asset/config" diff --git a/pkg/skopeo/skopeo_test.go b/pkg/skopeo/skopeo_test.go index f30604d6..392b4887 100644 --- a/pkg/skopeo/skopeo_test.go +++ b/pkg/skopeo/skopeo_test.go @@ -7,7 +7,7 @@ import ( "github.com/openshift/appliance/pkg/consts" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" . "github.com/onsi/ginkgo/v2/dsl/core" . "github.com/onsi/gomega" "github.com/openshift/appliance/pkg/executer" diff --git a/pkg/syslinux/syslinux_test.go b/pkg/syslinux/syslinux_test.go index 65e7ff16..f329f12c 100644 --- a/pkg/syslinux/syslinux_test.go +++ b/pkg/syslinux/syslinux_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" . "github.com/onsi/ginkgo/v2/dsl/core" . "github.com/onsi/gomega" "github.com/openshift/appliance/pkg/executer"