diff --git a/snapshot_policy.go b/snapshot_policy.go index eaa04ba..89b8da8 100644 --- a/snapshot_policy.go +++ b/snapshot_policy.go @@ -21,12 +21,12 @@ import ( ) // CreateSnapshotPolicy creates a snapshot policy on the PowerFlex array -func (system *System) CreateSnapshotPolicy(snapPolicy *types.SnapshotPolicyCreateParam) (string, error) { +func (s *System) CreateSnapshotPolicy(snapPolicy *types.SnapshotPolicyCreateParam) (string, error) { defer TimeSpent("crate snapshot policy", time.Now()) path := fmt.Sprintf("/api/types/SnapshotPolicy/instances") snapResp := types.SnapShotPolicyCreateResp{} - err := system.client.getJSONWithRetry( + err := s.client.getJSONWithRetry( http.MethodPost, path, snapPolicy, &snapResp) if err != nil { return "", err @@ -35,10 +35,10 @@ func (system *System) CreateSnapshotPolicy(snapPolicy *types.SnapshotPolicyCreat } // RemoveSnapshotPolicy removes a snapshot policy from the PowerFlex array -func (system *System) RemoveSnapshotPolicy(id string) error { +func (s *System) RemoveSnapshotPolicy(id string) error { path := fmt.Sprintf("/api/instances/SnapshotPolicy::%v/action/removeSnapshotPolicy", id) removeParam := &types.EmptyPayload{} - err := system.client.getJSONWithRetry( + err := s.client.getJSONWithRetry( http.MethodPost, path, removeParam, nil) if err != nil { return err @@ -47,12 +47,12 @@ func (system *System) RemoveSnapshotPolicy(id string) error { } // RenameSnapshotPolicy renames a snapshot policy -func (system *System) RenameSnapshotPolicy(id, name string) error { +func (s *System) RenameSnapshotPolicy(id, name string) error { path := fmt.Sprintf("/api/instances/SnapshotPolicy::%v/action/renameSnapshotPolicy", id) renameSnap := &types.SnapshotPolicyRenameParam{ NewName: name, } - err := system.client.getJSONWithRetry( + err := s.client.getJSONWithRetry( http.MethodPost, path, renameSnap, nil) if err != nil { return err @@ -61,9 +61,9 @@ func (system *System) RenameSnapshotPolicy(id, name string) error { } // ModifySnapshotPolicy modifies a snapshot policy -func (system *System) ModifySnapshotPolicy(modifysnapPolicy *types.SnapshotPolicyModifyParam, id string) error { +func (s *System) ModifySnapshotPolicy(modifysnapPolicy *types.SnapshotPolicyModifyParam, id string) error { path := fmt.Sprintf("/api/instances/SnapshotPolicy::%v/action/modifySnapshotPolicy", id) - err := system.client.getJSONWithRetry( + err := s.client.getJSONWithRetry( http.MethodPost, path, modifysnapPolicy, nil) if err != nil { return err @@ -72,9 +72,9 @@ func (system *System) ModifySnapshotPolicy(modifysnapPolicy *types.SnapshotPolic } // AssignVolumeToSnapshotPolicy assigns volume to a snapshot policy -func (system *System) AssignVolumeToSnapshotPolicy(assignVoltoSnap *types.AssignVolumeToSnapshotPolicyParam, id string) error { +func (s *System) AssignVolumeToSnapshotPolicy(assignVoltoSnap *types.AssignVolumeToSnapshotPolicyParam, id string) error { path := fmt.Sprintf("/api/instances/SnapshotPolicy::%v/action/addSourceVolumeToSnapshotPolicy", id) - err := system.client.getJSONWithRetry( + err := s.client.getJSONWithRetry( http.MethodPost, path, assignVoltoSnap, nil) if err != nil { return err @@ -83,9 +83,9 @@ func (system *System) AssignVolumeToSnapshotPolicy(assignVoltoSnap *types.Assign } // UnassignVolumeFromSnapshotPolicy unassigns volume from a snapshot policy -func (system *System) UnassignVolumeFromSnapshotPolicy(UnassignVolFromSnap *types.AssignVolumeToSnapshotPolicyParam, id string) error { +func (s *System) UnassignVolumeFromSnapshotPolicy(UnassignVolFromSnap *types.AssignVolumeToSnapshotPolicyParam, id string) error { path := fmt.Sprintf("/api/instances/SnapshotPolicy::%v/action/removeSourceVolumeFromSnapshotPolicy", id) - err := system.client.getJSONWithRetry( + err := s.client.getJSONWithRetry( http.MethodPost, path, UnassignVolFromSnap, nil) if err != nil { return err @@ -94,10 +94,10 @@ func (system *System) UnassignVolumeFromSnapshotPolicy(UnassignVolFromSnap *type } // PauseSnapshotPolicy pause a snapshot policy -func (system *System) PauseSnapshotPolicy(id string) error { +func (s *System) PauseSnapshotPolicy(id string) error { path := fmt.Sprintf("/api/instances/SnapshotPolicy::%v/action/pauseSnapshotPolicy", id) pauseParam := &types.EmptyPayload{} - err := system.client.getJSONWithRetry( + err := s.client.getJSONWithRetry( http.MethodPost, path, pauseParam, nil) if err != nil { return err @@ -106,10 +106,10 @@ func (system *System) PauseSnapshotPolicy(id string) error { } // ResumeSnapshotPolicy resume a snapshot policy which was paused -func (system *System) ResumeSnapshotPolicy(id string) error { +func (s *System) ResumeSnapshotPolicy(id string) error { path := fmt.Sprintf("/api/instances/SnapshotPolicy::%v/action/resumeSnapshotPolicy", id) resumeParam := &types.EmptyPayload{} - err := system.client.getJSONWithRetry( + err := s.client.getJSONWithRetry( http.MethodPost, path, resumeParam, nil) if err != nil { return err @@ -118,10 +118,10 @@ func (system *System) ResumeSnapshotPolicy(id string) error { } // GetSourceVolume returns a list of volumes assigned to snapshot policy -func (system *System) GetSourceVolume(id string) ([]*types.Volume, error) { +func (s *System) GetSourceVolume(id string) ([]*types.Volume, error) { var volumes []*types.Volume path := fmt.Sprintf("/api/instances/SnapshotPolicy::%v/relationships/SourceVolume", id) - err := system.client.getJSONWithRetry( + err := s.client.getJSONWithRetry( http.MethodGet, path, nil, &volumes) if err != nil { return nil, err diff --git a/snapshot_policy_test.go b/snapshot_policy_test.go index e2b4987..9b51f22 100644 --- a/snapshot_policy_test.go +++ b/snapshot_policy_test.go @@ -48,16 +48,16 @@ func TestCreateSnapshotPolicy(t *testing.T) { NumOfRetainedSnapshotsPerLevel: []string{"1"}, SnapshotAccessMode: "Invalid", }, - expected: errors.New("accessMode should get one of the following values: ReadWrite, ReadOnly, but its value is Invalid."), + expected: errors.New("accessMode should get one of the following values: ReadWrite, ReadOnly, but its value is Invalid"), }, } - svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + svr := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) { })) defer svr.Close() for _, tc := range cases { tc := tc - t.Run("", func(ts *testing.T) { + t.Run("", func(_ *testing.T) { client, err := NewClientWithArgs(svr.URL, "", math.MaxInt64, true, false) if err != nil { t.Fatal(err) @@ -96,16 +96,16 @@ func TestModifySnapshotPolicyName(t *testing.T) { { id: "1234", name: "renameSnapshotPolicy", - expected: errors.New("id (Invalid) must be a hexadecimal number (unsigned long)."), + expected: errors.New("id (Invalid) must be a hexadecimal number (unsigned long)"), }, } - svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + svr := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) { })) defer svr.Close() for _, tc := range cases { tc := tc - t.Run("", func(ts *testing.T) { + t.Run("", func(_ *testing.T) { client, err := NewClientWithArgs(svr.URL, "", math.MaxInt64, true, false) if err != nil { t.Fatal(err) @@ -149,16 +149,16 @@ func TestModifySnapshotPolicy(t *testing.T) { AutoSnapshotCreationCadenceInMin: "6", NumOfRetainedSnapshotsPerLevel: []string{"2", "3"}, }, - expected: errors.New("id (Invalid) must be a hexadecimal number (unsigned long)."), + expected: errors.New("id (Invalid) must be a hexadecimal number (unsigned long)"), }, } - svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + svr := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) { })) defer svr.Close() for _, tc := range cases { tc := tc - t.Run("", func(ts *testing.T) { + t.Run("", func(_ *testing.T) { client, err := NewClientWithArgs(svr.URL, "", math.MaxInt64, true, false) if err != nil { t.Fatal(err) @@ -201,23 +201,23 @@ func TestAssignSnapshotPolicy(t *testing.T) { snap: &types.AssignVolumeToSnapshotPolicyParam{ SourceVolumeID: "edba1bff00000001", }, - expected: errors.New("id (Invalid) must be a hexadecimal number (unsigned long)."), + expected: errors.New("id (Invalid) must be a hexadecimal number (unsigned long)"), }, { id: ID2, snap: &types.AssignVolumeToSnapshotPolicyParam{ SourceVolumeID: "edba1bff000000", }, - expected: errors.New("Invalid volume. Please try again with a valid ID or name."), + expected: errors.New("Invalid volume. Please try again with a valid ID or name"), }, } - svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + svr := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) { })) defer svr.Close() for _, tc := range cases { tc := tc - t.Run("", func(ts *testing.T) { + t.Run("", func(_ *testing.T) { client, err := NewClientWithArgs(svr.URL, "", math.MaxInt64, true, false) if err != nil { t.Fatal(err) @@ -262,7 +262,7 @@ func TestUnassignSnapshotPolicy(t *testing.T) { SourceVolumeID: "edba1bff00000001", AutoSnapshotRemovalAction: "Remove", }, - expected: errors.New("id (Invalid) must be a hexadecimal number (unsigned long)."), + expected: errors.New("id (Invalid) must be a hexadecimal number (unsigned long)"), }, { id: ID2, @@ -270,7 +270,7 @@ func TestUnassignSnapshotPolicy(t *testing.T) { SourceVolumeID: "edba1bff000000", AutoSnapshotRemovalAction: "Remove", }, - expected: errors.New("Invalid volume. Please try again with a valid ID or name."), + expected: errors.New("Invalid volume. Please try again with a valid ID or name"), }, { id: ID2, @@ -278,16 +278,16 @@ func TestUnassignSnapshotPolicy(t *testing.T) { SourceVolumeID: "edba1bff000000", AutoSnapshotRemovalAction: "Invalid", }, - expected: errors.New("autoSnapshotRemovalAction should get one of the following values: Remove, Detach, but its value is Invalid."), + expected: errors.New("autoSnapshotRemovalAction should get one of the following values: Remove, Detach, but its value is Invalid"), }, } - svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + svr := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) { })) defer svr.Close() for _, tc := range cases { tc := tc - t.Run("", func(ts *testing.T) { + t.Run("", func(_ *testing.T) { client, err := NewClientWithArgs(svr.URL, "", math.MaxInt64, true, false) if err != nil { t.Fatal(err) @@ -323,16 +323,16 @@ func TestPauseSnapshotPolicy(t *testing.T) { }, { id: "Invalid", - expected: errors.New("id (Invalid) must be a hexadecimal number (unsigned long)."), + expected: errors.New("id (Invalid) must be a hexadecimal number (unsigned long)"), }, } - svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + svr := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) { })) defer svr.Close() for _, tc := range cases { tc := tc - t.Run("", func(ts *testing.T) { + t.Run("", func(_ *testing.T) { client, err := NewClientWithArgs(svr.URL, "", math.MaxInt64, true, false) if err != nil { t.Fatal(err) @@ -368,16 +368,16 @@ func TestResumeSnapshotPolicy(t *testing.T) { }, { id: "Invalid", - expected: errors.New("id (Invalid) must be a hexadecimal number (unsigned long)."), + expected: errors.New("id (Invalid) must be a hexadecimal number (unsigned long)"), }, } - svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + svr := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) { })) defer svr.Close() for _, tc := range cases { tc := tc - t.Run("", func(ts *testing.T) { + t.Run("", func(_ *testing.T) { client, err := NewClientWithArgs(svr.URL, "", math.MaxInt64, true, false) if err != nil { t.Fatal(err) @@ -413,16 +413,16 @@ func TestDeleteSnapshotPolicy(t *testing.T) { }, { id: "Invalid", - expected: errors.New("id (Invalid) must be a hexadecimal number (unsigned long)."), + expected: errors.New("id (Invalid) must be a hexadecimal number (unsigned long)"), }, } - svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + svr := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) { })) defer svr.Close() for _, tc := range cases { tc := tc - t.Run("", func(ts *testing.T) { + t.Run("", func(_ *testing.T) { client, err := NewClientWithArgs(svr.URL, "", math.MaxInt64, true, false) if err != nil { t.Fatal(err) @@ -458,16 +458,16 @@ func TestGetSourceVolume(t *testing.T) { }, { id: "Invalid", - expected: errors.New("id (Invalid) must be a hexadecimal number (unsigned long)."), + expected: errors.New("id (Invalid) must be a hexadecimal number (unsigned long)"), }, } - svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + svr := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) { })) defer svr.Close() for _, tc := range cases { tc := tc - t.Run("", func(ts *testing.T) { + t.Run("", func(_ *testing.T) { client, err := NewClientWithArgs(svr.URL, "", math.MaxInt64, true, false) if err != nil { t.Fatal(err) diff --git a/storagepool.go b/storagepool.go index e3fdc64..b3f5bf1 100644 --- a/storagepool.go +++ b/storagepool.go @@ -419,13 +419,13 @@ func (sp *StoragePool) GetSDSStoragePool() ([]types.Sds, error) { } // GetStoragePoolByID returns a Storagepool by ID -func (sys *System) GetStoragePoolByID(id string) (*types.StoragePool, error) { +func (s *System) GetStoragePoolByID(id string) (*types.StoragePool, error) { defer TimeSpent("GetStoragePoolByID", time.Now()) path := fmt.Sprintf("/api/instances/StoragePool::%s", id) var storagepool *types.StoragePool - err := sys.client.getJSONWithRetry( + err := s.client.getJSONWithRetry( http.MethodGet, path, nil, &storagepool) if err != nil { return nil, err @@ -435,12 +435,12 @@ func (sys *System) GetStoragePoolByID(id string) (*types.StoragePool, error) { } // GetAllStoragePools returns all Storage pools on the system -func (sys *System) GetAllStoragePools() ([]types.StoragePool, error) { +func (s *System) GetAllStoragePools() ([]types.StoragePool, error) { defer TimeSpent("GetStoragepool", time.Now()) path := "/api/types/StoragePool/instances" var storagepools []types.StoragePool - err := sys.client.getJSONWithRetry( + err := s.client.getJSONWithRetry( http.MethodGet, path, nil, &storagepools) if err != nil { return nil, err