diff --git a/bundle/manifests/lvms-operator.clusterserviceversion.yaml b/bundle/manifests/lvms-operator.clusterserviceversion.yaml index 7121d1e92..ef2b2bad4 100644 --- a/bundle/manifests/lvms-operator.clusterserviceversion.yaml +++ b/bundle/manifests/lvms-operator.clusterserviceversion.yaml @@ -679,18 +679,6 @@ spec: - create - patch - update - - apiGroups: - - "" - resources: - - configmaps - verbs: - - create - - delete - - get - - list - - patch - - update - - watch serviceAccountName: vg-manager strategy: deployment installModes: diff --git a/cmd/vgmanager/vgmanager.go b/cmd/vgmanager/vgmanager.go index d5da46a20..06e90348d 100644 --- a/cmd/vgmanager/vgmanager.go +++ b/cmd/vgmanager/vgmanager.go @@ -144,7 +144,7 @@ func run(cmd *cobra.Command, _ []string, opts *Options) error { } lvmdConfig := &lvmd.Config{} - if err := loadConfFile(ctx, lvmdConfig, constants.LVMDDefaultFileConfigPath); err != nil { + if err := loadConfFile(ctx, lvmdConfig, lvmd.DefaultFileConfigPath); err != nil { opts.SetupLog.Error(err, "lvmd config could not be loaded, starting without topolvm components and attempting bootstrap") if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil { return fmt.Errorf("unable to set up ready check: %w", err) @@ -199,7 +199,7 @@ func run(cmd *cobra.Command, _ []string, opts *Options) error { if err = (&vgmanager.Reconciler{ Client: mgr.GetClient(), EventRecorder: mgr.GetEventRecorderFor(vgmanager.ControllerName), - LVMD: lvmd.NewFileConfigurator(mgr.GetClient(), operatorNamespace), + LVMD: lvmd.DefaultConfigurator(), Scheme: mgr.GetScheme(), LSBLK: lsblk.NewDefaultHostLSBLK(), Wipefs: wipefs.NewDefaultHostWipefs(), @@ -238,7 +238,7 @@ func run(cmd *cobra.Command, _ []string, opts *Options) error { fileNotExist := false for { // check if file exists, otherwise the watcher errors - _, err := os.Lstat(constants.LVMDDefaultFileConfigPath) + _, err := os.Lstat(lvmd.DefaultFileConfigPath) if err != nil { if os.IsNotExist(err) { time.Sleep(100 * time.Millisecond) @@ -251,7 +251,7 @@ func run(cmd *cobra.Command, _ []string, opts *Options) error { if fileNotExist { cancel() } - err = watcher.Add(constants.LVMDDefaultFileConfigPath) + err = watcher.Add(lvmd.DefaultFileConfigPath) if err != nil { opts.SetupLog.Error(err, "unable to add file path to watcher") } diff --git a/config/rbac/vg_manager_role.yaml b/config/rbac/vg_manager_role.yaml index 4e8cde82f..8cc42ecdf 100644 --- a/config/rbac/vg_manager_role.yaml +++ b/config/rbac/vg_manager_role.yaml @@ -66,15 +66,3 @@ rules: - create - patch - update -- apiGroups: - - "" - resources: - - configmaps - verbs: - - create - - delete - - get - - list - - patch - - update - - watch diff --git a/internal/controllers/constants/constants.go b/internal/controllers/constants/constants.go index e4a0df337..ab6f6230e 100644 --- a/internal/controllers/constants/constants.go +++ b/internal/controllers/constants/constants.go @@ -32,10 +32,6 @@ const ( DeviceClassKey = "topolvm.io/device-class" DefaultPluginRegistrationPath = "/registration" - LVMDConfigMapName = "lvmd-config" - LVMDDefaultConfigDir = "/etc/topolvm" - LVMDDefaultFileConfigPath = "/etc/topolvm/lvmd.yaml" - // name of the lvm-operator container LVMOperatorContainerName = "manager" diff --git a/internal/controllers/lvmcluster/resource/vgmanager_daemonset.go b/internal/controllers/lvmcluster/resource/vgmanager_daemonset.go index 1b4a66394..c365884ba 100644 --- a/internal/controllers/lvmcluster/resource/vgmanager_daemonset.go +++ b/internal/controllers/lvmcluster/resource/vgmanager_daemonset.go @@ -24,6 +24,7 @@ import ( lvmv1alpha1 "github.com/openshift/lvm-operator/api/v1alpha1" "github.com/openshift/lvm-operator/internal/controllers/constants" "github.com/openshift/lvm-operator/internal/controllers/lvmcluster/selector" + "github.com/openshift/lvm-operator/internal/controllers/vgmanager/lvmd" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" @@ -109,16 +110,15 @@ var ( LVMDConfMapVol = corev1.Volume{ Name: LVMDConfMapVolName, VolumeSource: corev1.VolumeSource{ - ConfigMap: &corev1.ConfigMapVolumeSource{ - Optional: ptr.To(true), - LocalObjectReference: corev1.LocalObjectReference{ - Name: constants.LVMDConfigMapName, - }, - }, + HostPath: &corev1.HostPathVolumeSource{ + Path: filepath.Dir(lvmd.DefaultFileConfigPath), + Type: &HostPathDirectoryOrCreate}, }, } LVMDConfMapVolMount = corev1.VolumeMount{ - Name: LVMDConfMapVolName, MountPath: constants.LVMDDefaultConfigDir, + Name: LVMDConfMapVolName, + MountPath: filepath.Dir(lvmd.DefaultFileConfigPath), + MountPropagation: &hostContainerPropagation, } ) diff --git a/internal/controllers/vgmanager/controller.go b/internal/controllers/vgmanager/controller.go index ebd911c95..d589bad31 100644 --- a/internal/controllers/vgmanager/controller.go +++ b/internal/controllers/vgmanager/controller.go @@ -43,10 +43,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/predicate" - "sigs.k8s.io/controller-runtime/pkg/reconcile" ) const ( @@ -82,38 +80,9 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). For(&lvmv1alpha1.LVMVolumeGroup{}). Owns(&lvmv1alpha1.LVMVolumeGroupNodeStatus{}, builder.MatchEveryOwner, builder.WithPredicates(predicate.GenerationChangedPredicate{})). - Watches(&corev1.ConfigMap{}, handler.EnqueueRequestsFromMapFunc(r.getObjsInNamespaceForReconcile)). Complete(r) } -// getObjsInNamespaceForReconcile reconciles the object anytime the given object is in the same namespace -// as the available LVMVolumeGroups. -func (r *Reconciler) getObjsInNamespaceForReconcile(ctx context.Context, obj client.Object) []reconcile.Request { - foundLVMVolumeGroupList := &lvmv1alpha1.LVMVolumeGroupList{} - listOps := &client.ListOptions{ - Namespace: obj.GetNamespace(), - } - - if err := r.List(ctx, foundLVMVolumeGroupList, listOps); err != nil { - log.FromContext(ctx).Error(err, "getObjsInNamespaceForReconcile: Failed to get LVMVolumeGroup objs") - return []reconcile.Request{} - } - if len(foundLVMVolumeGroupList.Items) < 1 { - return []reconcile.Request{} - } - - var requests []reconcile.Request - for _, lvmVG := range foundLVMVolumeGroupList.Items { - requests = append(requests, reconcile.Request{ - NamespacedName: types.NamespacedName{ - Name: lvmVG.GetName(), - Namespace: lvmVG.GetNamespace(), - }, - }) - } - return requests -} - type Reconciler struct { client.Client Scheme *runtime.Scheme @@ -348,7 +317,7 @@ func (r *Reconciler) applyLVMDConfig(ctx context.Context, volumeGroup *lvmv1alph logger := log.FromContext(ctx).WithValues("VGName", volumeGroup.Name) // Read the lvmd config file - lvmdConfig, err := r.LVMD.Load(ctx) + lvmdConfig, err := r.LVMD.Load() if err != nil { err = fmt.Errorf("failed to read the lvmd config file: %w", err) if _, err := r.setVolumeGroupFailedStatus(ctx, volumeGroup, vgs, devices, err); err != nil { @@ -414,7 +383,7 @@ func (r *Reconciler) updateLVMDConfigAfterReconcile( r.NormalEvent(ctx, volumeGroup, EventReasonLVMDConfigMissing, msg) } - if err := r.LVMD.Save(ctx, newCFG); err != nil { + if err := r.LVMD.Save(newCFG); err != nil { return fmt.Errorf("failed to update lvmd config file to update volume group %s: %w", volumeGroup.GetName(), err) } msg := "updated lvmd config with new deviceClasses, now restarting.." @@ -431,7 +400,7 @@ func (r *Reconciler) processDelete(ctx context.Context, volumeGroup *lvmv1alpha1 logger.Info("deleting") // Read the lvmd config file - lvmdConfig, err := r.LVMD.Load(ctx) + lvmdConfig, err := r.LVMD.Load() if err != nil { // Failed to read lvmdconfig file. Reconcile again return fmt.Errorf("failed to read the lvmd config file: %w", err) @@ -509,14 +478,14 @@ func (r *Reconciler) processDelete(ctx context.Context, volumeGroup *lvmv1alpha1 // if there was no config file in the first place, nothing has to be removed. if lvmdConfig != nil { if len(lvmdConfig.DeviceClasses) > 0 { - if err = r.LVMD.Save(ctx, lvmdConfig); err != nil { + if err = r.LVMD.Save(lvmdConfig); err != nil { return fmt.Errorf("failed to update lvmd.conf file for volume group %s: %w", volumeGroup.GetName(), err) } msg := "updated lvmd config after deviceClass was removed" logger.Info(msg) r.NormalEvent(ctx, volumeGroup, EventReasonLVMDConfigUpdated, msg) } else { - if err = r.LVMD.Delete(ctx); err != nil { + if err = r.LVMD.Delete(); err != nil { return fmt.Errorf("failed to delete lvmd.conf file for volume group %s: %w", volumeGroup.GetName(), err) } msg := "removed lvmd config after last deviceClass was removed" diff --git a/internal/controllers/vgmanager/controller_test.go b/internal/controllers/vgmanager/controller_test.go index 1ba6e3182..ba68ef9e4 100644 --- a/internal/controllers/vgmanager/controller_test.go +++ b/internal/controllers/vgmanager/controller_test.go @@ -24,7 +24,6 @@ import ( "github.com/openshift/lvm-operator/internal/controllers/vgmanager/lvmd" lvmdmocks "github.com/openshift/lvm-operator/internal/controllers/vgmanager/lvmd/mocks" wipefsmocks "github.com/openshift/lvm-operator/internal/controllers/vgmanager/wipefs/mocks" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" topolvmv1 "github.com/topolvm/topolvm/api/v1" "sigs.k8s.io/controller-runtime/pkg/client/apiutil" @@ -32,8 +31,6 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" @@ -112,6 +109,7 @@ func setupInstances() testInstances { mockLSBLK := lsblkmocks.NewMockLSBLK(t) mockLVM := lvmmocks.NewMockLVM(t) mockWipefs := wipefsmocks.NewMockWipefs(t) + testLVMD := lvmd.NewFileConfigurator(filepath.Join(t.TempDir(), "lvmd.yaml")) hostname := "test-host.vgmanager.test.io" hostnameLabelKey := "kubernetes.io/hostname" @@ -127,8 +125,6 @@ func setupInstances() testInstances { fakeRecorder := record.NewFakeRecorder(100) fakeRecorder.IncludeObject = true - testLVMD := lvmd.NewFileConfigurator(fakeClient, namespace.GetName()) - return testInstances{ LVM: mockLVM, LSBLK: mockLSBLK, @@ -319,7 +315,7 @@ func testMockedBlockDeviceOnHost(ctx context.Context) { By("verifying the lvmd config generation", func() { checkDistributedEvent(corev1.EventTypeNormal, "lvmd config file doesn't exist, will attempt to create a fresh config") checkDistributedEvent(corev1.EventTypeNormal, "updated lvmd config with new deviceClasses") - lvmdConfig, err := instances.LVMD.Load(ctx) + lvmdConfig, err := instances.LVMD.Load() Expect(err).ToNot(HaveOccurred()) Expect(lvmdConfig).ToNot(BeNil()) Expect(lvmdConfig.DeviceClasses).ToNot(BeNil()) @@ -409,7 +405,7 @@ func testMockedBlockDeviceOnHost(ctx context.Context) { _, err := instances.Reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: client.ObjectKeyFromObject(vg)}) Expect(err).ToNot(HaveOccurred()) Expect(instances.client.Get(ctx, client.ObjectKeyFromObject(vg), vg)).ToNot(Succeed()) - lvmdConfig, err := instances.LVMD.Load(ctx) + lvmdConfig, err := instances.LVMD.Load() Expect(err).ToNot(HaveOccurred()) Expect(lvmdConfig).To(Not(BeNil()), "cached lvmd config is still present") }) @@ -566,12 +562,12 @@ func testLVMD(ctx context.Context) { mockLVM := lvmmocks.NewMockLVM(GinkgoT()) r.LVM = mockLVM - mockLVMD.EXPECT().Load(ctx).Once().Return(nil, fmt.Errorf("mock load failure")) + mockLVMD.EXPECT().Load().Once().Return(nil, fmt.Errorf("mock load failure")) err := r.applyLVMDConfig(ctx, vg, []lvm.VolumeGroup{}, devices) Expect(err).To(HaveOccurred(), "should error if lvmd config cannot be loaded") - mockLVMD.EXPECT().Load(ctx).Once().Return(&lvmd.Config{}, nil) - mockLVMD.EXPECT().Save(ctx, mock.Anything).Once().Return(fmt.Errorf("mock save failure")) + mockLVMD.EXPECT().Load().Once().Return(&lvmd.Config{}, nil) + mockLVMD.EXPECT().Save(mock.Anything).Once().Return(fmt.Errorf("mock save failure")) err = r.applyLVMDConfig(ctx, vg, []lvm.VolumeGroup{}, devices) Expect(err).To(HaveOccurred(), "should error if lvmd config cannot be saved") } @@ -836,52 +832,3 @@ func testReconcileFailure(ctx context.Context) { Expect(err).To(MatchError(expectedError)) }) } - -func TestGetObjsInNamespaceForReconcile(t *testing.T) { - tests := []struct { - name string - objs []client.Object - list error - expect []reconcile.Request - }{ - { - name: "test lvmvolumegroup not fetch error", - list: assert.AnError, - }, - { - name: "test lvmvolumegroup found in a different namespace", - objs: []client.Object{ - &lvmv1alpha1.LVMVolumeGroup{ObjectMeta: metav1.ObjectMeta{Name: "test-vg", Namespace: "not-test"}}, - }, - }, - { - name: "test lvmvolumegroup found in the same namespace", - objs: []client.Object{ - &lvmv1alpha1.LVMVolumeGroup{ObjectMeta: metav1.ObjectMeta{Name: "test-vg", Namespace: "test"}}, - }, - expect: []reconcile.Request{{NamespacedName: types.NamespacedName{Name: "test-vg", Namespace: "test"}}}, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - newScheme := runtime.NewScheme() - assert.NoError(t, lvmv1alpha1.AddToScheme(newScheme)) - assert.NoError(t, corev1.AddToScheme(newScheme)) - clnt := fake.NewClientBuilder().WithObjects(tt.objs...). - WithScheme(newScheme).WithInterceptorFuncs(interceptor.Funcs{ - List: func(ctx context.Context, client client.WithWatch, list client.ObjectList, opts ...client.ListOption) error { - if tt.list != nil { - return tt.list - } - return client.List(ctx, list, opts...) - }, - }).Build() - - r := &Reconciler{Client: clnt} - requests := r.getObjsInNamespaceForReconcile(context.Background(), - &corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Name: "test-vg", Namespace: "test"}}) - assert.ElementsMatch(t, tt.expect, requests) - }) - } -} diff --git a/internal/controllers/vgmanager/lvmd/lvmd.go b/internal/controllers/vgmanager/lvmd/lvmd.go index 0456ac24e..b7537faa4 100644 --- a/internal/controllers/vgmanager/lvmd/lvmd.go +++ b/internal/controllers/vgmanager/lvmd/lvmd.go @@ -1,19 +1,12 @@ package lvmd import ( - "context" "fmt" + "os" - "github.com/openshift/lvm-operator/internal/controllers/constants" "github.com/topolvm/topolvm/lvmd" lvmdCMD "github.com/topolvm/topolvm/pkg/lvmd/cmd" - corev1 "k8s.io/api/core/v1" - k8serrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/yaml" ) @@ -24,16 +17,22 @@ type ThinPoolConfig = lvmd.ThinPoolConfig var TypeThin = lvmd.TypeThin -func NewFileConfigurator(client client.Client, namespace string) *CachedFileConfig { +const DefaultFileConfigPath = "/etc/topolvm/lvmd.yaml" + +func DefaultConfigurator() *CachedFileConfig { + return NewFileConfigurator(DefaultFileConfigPath) +} + +func NewFileConfigurator(path string) *CachedFileConfig { return &CachedFileConfig{ - FileConfig: FileConfig{Client: client, Namespace: namespace}, + FileConfig: FileConfig{path: path}, } } type Configurator interface { - Load(ctx context.Context) (*Config, error) - Save(ctx context.Context, config *Config) error - Delete(ctx context.Context) error + Load() (*Config, error) + Save(config *Config) error + Delete() error } type CachedFileConfig struct { @@ -41,12 +40,11 @@ type CachedFileConfig struct { FileConfig } -func (c *CachedFileConfig) Load(ctx context.Context) (*Config, error) { +func (c *CachedFileConfig) Load() (*Config, error) { if c.Config != nil { return c.Config, nil } - log.FromContext(ctx).Info("lvmd config not found in cache, loading from store") - conf, err := c.FileConfig.Load(ctx) + conf, err := c.FileConfig.Load() if err != nil { return nil, err } @@ -54,76 +52,46 @@ func (c *CachedFileConfig) Load(ctx context.Context) (*Config, error) { return conf, nil } -func (c *CachedFileConfig) Save(ctx context.Context, config *Config) error { +func (c *CachedFileConfig) Save(config *Config) error { c.Config = config - log.FromContext(ctx).Info("saving lvmd config to cache and store") - return c.FileConfig.Save(ctx, config) + return c.FileConfig.Save(config) } type FileConfig struct { - client.Client - Namespace string + path string } -func (c FileConfig) Load(ctx context.Context) (*Config, error) { - cm := &corev1.ConfigMap{ - ObjectMeta: metav1.ObjectMeta{ - Name: constants.LVMDConfigMapName, - Namespace: c.Namespace, - }, - } - err := c.Client.Get(ctx, client.ObjectKeyFromObject(cm), cm) - if k8serrors.IsNotFound(err) { +func (c FileConfig) Load() (*Config, error) { + cfgBytes, err := os.ReadFile(c.path) + if os.IsNotExist(err) { // If the file does not exist, return nil for both return nil, nil } else if err != nil { - return nil, fmt.Errorf("failed to get ConfigMap %s: %w", cm.Name, err) - } - - config := &Config{} - if err = yaml.Unmarshal([]byte(cm.Data["lvmd.yaml"]), config); err != nil { - return nil, fmt.Errorf("failed to unmarshal config file: %w", err) + return nil, fmt.Errorf("failed to load config file %s: %w", c.path, err) + } else { + config := &Config{} + if err = yaml.Unmarshal(cfgBytes, config); err != nil { + return nil, fmt.Errorf("failed to unmarshal config file %s: %w", c.path, err) + } + return config, nil } - return config, nil } -func (c FileConfig) Save(ctx context.Context, config *Config) error { +func (c FileConfig) Save(config *Config) error { out, err := yaml.Marshal(config) - if err != nil { - return fmt.Errorf("failed to marshal config file: %w", err) + if err == nil { + err = os.WriteFile(c.path, out, 0600) } - - cm := &corev1.ConfigMap{ - ObjectMeta: metav1.ObjectMeta{ - Name: constants.LVMDConfigMapName, - Namespace: c.Namespace, - }, - } - _, err = ctrl.CreateOrUpdate(ctx, c.Client, cm, func() error { - cm.Data = map[string]string{"lvmd.yaml": string(out)} - return nil - }) if err != nil { - return fmt.Errorf("failed to apply ConfigMap %s: %w", cm.GetName(), err) + return fmt.Errorf("failed to save config file %s: %w", c.path, err) } - return nil } -func (c FileConfig) Delete(ctx context.Context) error { - cm := &corev1.ConfigMap{ - ObjectMeta: metav1.ObjectMeta{ - Name: constants.LVMDConfigMapName, - Namespace: c.Namespace, - }, - } - if err := c.Client.Delete(ctx, cm); err != nil { - if k8serrors.IsNotFound(err) { - // If the file does not exist, return nil - return nil - } - return fmt.Errorf("failed to delete ConfigMap: %w", err) +func (c FileConfig) Delete() error { + err := os.Remove(c.path) + if err != nil { + return fmt.Errorf("failed to delete config file %s: %w", c.path, err) } - - return nil + return err } diff --git a/internal/controllers/vgmanager/lvmd/mocks/mock_configurator.go b/internal/controllers/vgmanager/lvmd/mocks/mock_configurator.go index d6c522c84..6d473a515 100644 --- a/internal/controllers/vgmanager/lvmd/mocks/mock_configurator.go +++ b/internal/controllers/vgmanager/lvmd/mocks/mock_configurator.go @@ -3,8 +3,6 @@ package lvmd import ( - context "context" - cmd "github.com/topolvm/topolvm/pkg/lvmd/cmd" mock "github.com/stretchr/testify/mock" @@ -23,17 +21,17 @@ func (_m *MockConfigurator) EXPECT() *MockConfigurator_Expecter { return &MockConfigurator_Expecter{mock: &_m.Mock} } -// Delete provides a mock function with given fields: ctx -func (_m *MockConfigurator) Delete(ctx context.Context) error { - ret := _m.Called(ctx) +// Delete provides a mock function with given fields: +func (_m *MockConfigurator) Delete() error { + ret := _m.Called() if len(ret) == 0 { panic("no return value specified for Delete") } var r0 error - if rf, ok := ret.Get(0).(func(context.Context) error); ok { - r0 = rf(ctx) + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() } else { r0 = ret.Error(0) } @@ -47,14 +45,13 @@ type MockConfigurator_Delete_Call struct { } // Delete is a helper method to define mock.On call -// - ctx context.Context -func (_e *MockConfigurator_Expecter) Delete(ctx interface{}) *MockConfigurator_Delete_Call { - return &MockConfigurator_Delete_Call{Call: _e.mock.On("Delete", ctx)} +func (_e *MockConfigurator_Expecter) Delete() *MockConfigurator_Delete_Call { + return &MockConfigurator_Delete_Call{Call: _e.mock.On("Delete")} } -func (_c *MockConfigurator_Delete_Call) Run(run func(ctx context.Context)) *MockConfigurator_Delete_Call { +func (_c *MockConfigurator_Delete_Call) Run(run func()) *MockConfigurator_Delete_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context)) + run() }) return _c } @@ -64,14 +61,14 @@ func (_c *MockConfigurator_Delete_Call) Return(_a0 error) *MockConfigurator_Dele return _c } -func (_c *MockConfigurator_Delete_Call) RunAndReturn(run func(context.Context) error) *MockConfigurator_Delete_Call { +func (_c *MockConfigurator_Delete_Call) RunAndReturn(run func() error) *MockConfigurator_Delete_Call { _c.Call.Return(run) return _c } -// Load provides a mock function with given fields: ctx -func (_m *MockConfigurator) Load(ctx context.Context) (*cmd.Config, error) { - ret := _m.Called(ctx) +// Load provides a mock function with given fields: +func (_m *MockConfigurator) Load() (*cmd.Config, error) { + ret := _m.Called() if len(ret) == 0 { panic("no return value specified for Load") @@ -79,19 +76,19 @@ func (_m *MockConfigurator) Load(ctx context.Context) (*cmd.Config, error) { var r0 *cmd.Config var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (*cmd.Config, error)); ok { - return rf(ctx) + if rf, ok := ret.Get(0).(func() (*cmd.Config, error)); ok { + return rf() } - if rf, ok := ret.Get(0).(func(context.Context) *cmd.Config); ok { - r0 = rf(ctx) + if rf, ok := ret.Get(0).(func() *cmd.Config); ok { + r0 = rf() } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*cmd.Config) } } - if rf, ok := ret.Get(1).(func(context.Context) error); ok { - r1 = rf(ctx) + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() } else { r1 = ret.Error(1) } @@ -105,14 +102,13 @@ type MockConfigurator_Load_Call struct { } // Load is a helper method to define mock.On call -// - ctx context.Context -func (_e *MockConfigurator_Expecter) Load(ctx interface{}) *MockConfigurator_Load_Call { - return &MockConfigurator_Load_Call{Call: _e.mock.On("Load", ctx)} +func (_e *MockConfigurator_Expecter) Load() *MockConfigurator_Load_Call { + return &MockConfigurator_Load_Call{Call: _e.mock.On("Load")} } -func (_c *MockConfigurator_Load_Call) Run(run func(ctx context.Context)) *MockConfigurator_Load_Call { +func (_c *MockConfigurator_Load_Call) Run(run func()) *MockConfigurator_Load_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context)) + run() }) return _c } @@ -122,22 +118,22 @@ func (_c *MockConfigurator_Load_Call) Return(_a0 *cmd.Config, _a1 error) *MockCo return _c } -func (_c *MockConfigurator_Load_Call) RunAndReturn(run func(context.Context) (*cmd.Config, error)) *MockConfigurator_Load_Call { +func (_c *MockConfigurator_Load_Call) RunAndReturn(run func() (*cmd.Config, error)) *MockConfigurator_Load_Call { _c.Call.Return(run) return _c } -// Save provides a mock function with given fields: ctx, config -func (_m *MockConfigurator) Save(ctx context.Context, config *cmd.Config) error { - ret := _m.Called(ctx, config) +// Save provides a mock function with given fields: config +func (_m *MockConfigurator) Save(config *cmd.Config) error { + ret := _m.Called(config) if len(ret) == 0 { panic("no return value specified for Save") } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *cmd.Config) error); ok { - r0 = rf(ctx, config) + if rf, ok := ret.Get(0).(func(*cmd.Config) error); ok { + r0 = rf(config) } else { r0 = ret.Error(0) } @@ -151,15 +147,14 @@ type MockConfigurator_Save_Call struct { } // Save is a helper method to define mock.On call -// - ctx context.Context // - config *cmd.Config -func (_e *MockConfigurator_Expecter) Save(ctx interface{}, config interface{}) *MockConfigurator_Save_Call { - return &MockConfigurator_Save_Call{Call: _e.mock.On("Save", ctx, config)} +func (_e *MockConfigurator_Expecter) Save(config interface{}) *MockConfigurator_Save_Call { + return &MockConfigurator_Save_Call{Call: _e.mock.On("Save", config)} } -func (_c *MockConfigurator_Save_Call) Run(run func(ctx context.Context, config *cmd.Config)) *MockConfigurator_Save_Call { +func (_c *MockConfigurator_Save_Call) Run(run func(config *cmd.Config)) *MockConfigurator_Save_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*cmd.Config)) + run(args[0].(*cmd.Config)) }) return _c } @@ -169,7 +164,7 @@ func (_c *MockConfigurator_Save_Call) Return(_a0 error) *MockConfigurator_Save_C return _c } -func (_c *MockConfigurator_Save_Call) RunAndReturn(run func(context.Context, *cmd.Config) error) *MockConfigurator_Save_Call { +func (_c *MockConfigurator_Save_Call) RunAndReturn(run func(*cmd.Config) error) *MockConfigurator_Save_Call { _c.Call.Return(run) return _c }