Skip to content

Commit f5d0ee9

Browse files
committed
make the formatting errors based on go 1.19
Reference# kubernetes-csi/csi-release-tools#203 Signed-off-by: Humble Chirammal <[email protected]>
1 parent e21627d commit f5d0ee9

File tree

7 files changed

+68
-64
lines changed

7 files changed

+68
-64
lines changed

pkg/common-controller/framework_test.go

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ import (
7878
// function to call as the actual test. Available functions are:
7979
// - testSyncSnapshot - calls syncSnapshot on the first snapshot in initialSnapshots.
8080
// - testSyncSnapshotError - calls syncSnapshot on the first snapshot in initialSnapshots
81-
// and expects an error to be returned.
81+
// and expects an error to be returned.
8282
// - testSyncContent - calls syncContent on the first content in initialContents.
8383
// - any custom function for specialized tests.
84+
//
8485
// The test then contains list of contents/snapshots that are expected at the end
8586
// of the test and list of generated events.
8687
type controllerTest struct {
@@ -127,21 +128,21 @@ var (
127128

128129
// snapshotReactor is a core.Reactor that simulates etcd and API server. It
129130
// stores:
130-
// - Latest version of snapshots contents saved by the controller.
131-
// - Queue of all saves (to simulate "content/snapshot updated" events). This queue
132-
// contains all intermediate state of an object - e.g. a snapshot.VolumeName
133-
// is updated first and snapshot.Phase second. This queue will then contain both
134-
// updates as separate entries.
135-
// - Number of changes since the last call to snapshotReactor.syncAll().
136-
// - Optionally, content and snapshot fake watchers which should be the same ones
137-
// used by the controller. Any time an event function like deleteContentEvent
138-
// is called to simulate an event, the reactor's stores are updated and the
139-
// controller is sent the event via the fake watcher.
140-
// - Optionally, list of error that should be returned by reactor, simulating
141-
// etcd / API server failures. These errors are evaluated in order and every
142-
// error is returned only once. I.e. when the reactor finds matching
143-
// reactorError, it return appropriate error and removes the reactorError from
144-
// the list.
131+
// - Latest version of snapshots contents saved by the controller.
132+
// - Queue of all saves (to simulate "content/snapshot updated" events). This queue
133+
// contains all intermediate state of an object - e.g. a snapshot.VolumeName
134+
// is updated first and snapshot.Phase second. This queue will then contain both
135+
// updates as separate entries.
136+
// - Number of changes since the last call to snapshotReactor.syncAll().
137+
// - Optionally, content and snapshot fake watchers which should be the same ones
138+
// used by the controller. Any time an event function like deleteContentEvent
139+
// is called to simulate an event, the reactor's stores are updated and the
140+
// controller is sent the event via the fake watcher.
141+
// - Optionally, list of error that should be returned by reactor, simulating
142+
// etcd / API server failures. These errors are evaluated in order and every
143+
// error is returned only once. I.e. when the reactor finds matching
144+
// reactorError, it return appropriate error and removes the reactorError from
145+
// the list.
145146
type snapshotReactor struct {
146147
secrets map[string]*v1.Secret
147148
volumes map[string]*v1.PersistentVolume
@@ -1301,11 +1302,11 @@ var (
13011302
)
13021303

13031304
// wrapTestWithInjectedOperation returns a testCall that:
1304-
// - starts the controller and lets it run original testCall until
1305-
// scheduleOperation() call. It blocks the controller there and calls the
1306-
// injected function to simulate that something is happening when the
1307-
// controller waits for the operation lock. Controller is then resumed and we
1308-
// check how it behaves.
1305+
// - starts the controller and lets it run original testCall until
1306+
// scheduleOperation() call. It blocks the controller there and calls the
1307+
// injected function to simulate that something is happening when the
1308+
// controller waits for the operation lock. Controller is then resumed and we
1309+
// check how it behaves.
13091310
func wrapTestWithInjectedOperation(toWrap testCall, injectBeforeOperation func(ctrl *csiSnapshotCommonController, reactor *snapshotReactor)) testCall {
13101311
return func(ctrl *csiSnapshotCommonController, reactor *snapshotReactor, test controllerTest) error {
13111312
// Inject a hook before async operation starts
@@ -1348,10 +1349,10 @@ func evaluateTestResults(ctrl *csiSnapshotCommonController, reactor *snapshotRea
13481349

13491350
// Test single call to syncSnapshot and syncContent methods.
13501351
// For all tests:
1351-
// 1. Fill in the controller with initial data
1352-
// 2. Call the tested function (syncSnapshot/syncContent) via
1353-
// controllerTest.testCall *once*.
1354-
// 3. Compare resulting contents and snapshots with expected contents and snapshots.
1352+
// 1. Fill in the controller with initial data
1353+
// 2. Call the tested function (syncSnapshot/syncContent) via
1354+
// controllerTest.testCall *once*.
1355+
// 3. Compare resulting contents and snapshots with expected contents and snapshots.
13551356
func runSyncTests(t *testing.T, tests []controllerTest, snapshotClasses []*crdv1.VolumeSnapshotClass) {
13561357
snapshotscheme.AddToScheme(scheme.Scheme)
13571358
for _, test := range tests {

pkg/common-controller/snapshot_controller.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -782,11 +782,12 @@ func (ctrl *csiSnapshotCommonController) storeContentUpdate(content interface{})
782782
// given event on the snapshot. It saves the status and emits the event only when
783783
// the status has actually changed from the version saved in API server.
784784
// Parameters:
785-
// snapshot - snapshot to update
786-
// setReadyToFalse bool - indicates whether to set the snapshot's ReadyToUse status to false.
787-
// if true, ReadyToUse will be set to false;
788-
// otherwise, ReadyToUse will not be changed.
789-
// eventtype, reason, message - event to send, see EventRecorder.Event()
785+
//
786+
// * snapshot - snapshot to update
787+
// * setReadyToFalse bool - indicates whether to set the snapshot's ReadyToUse status to false.
788+
// if true, ReadyToUse will be set to false;
789+
// otherwise, ReadyToUse will not be changed.
790+
// * eventtype, reason, message - event to send, see EventRecorder.Event()
790791
func (ctrl *csiSnapshotCommonController) updateSnapshotErrorStatusWithEvent(snapshot *crdv1.VolumeSnapshot, setReadyToFalse bool, eventtype, reason, message string) error {
791792
klog.V(5).Infof("updateSnapshotErrorStatusWithEvent[%s]", utils.SnapshotKey(snapshot))
792793

pkg/common-controller/snapshot_update_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ var metaTimeNow = &metav1.Time{
3434
var emptyString = ""
3535

3636
// Test single call to syncSnapshot and syncContent methods.
37-
// 1. Fill in the controller with initial data
38-
// 2. Call the tested function (syncSnapshot/syncContent) via
39-
// controllerTest.testCall *once*.
40-
// 3. Compare resulting contents and snapshots with expected contents and snapshots.
37+
// 1. Fill in the controller with initial data
38+
// 2. Call the tested function (syncSnapshot/syncContent) via
39+
// controllerTest.testCall *once*.
40+
// 3. Compare resulting contents and snapshots with expected contents and snapshots.
4141
func TestSync(t *testing.T) {
4242
size := int64(1)
4343
snapshotErr := newVolumeError("Mock content error")

pkg/common-controller/snapshotclass_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ import (
2222
)
2323

2424
// Test single call to checkAndUpdateSnapshotClass.
25-
// 1. Fill in the controller with initial data
26-
// 2. Call the tested function checkAndUpdateSnapshotClass via
27-
// controllerTest.testCall *once*.
28-
// 3. Compare resulting snapshotclass.
25+
// 1. Fill in the controller with initial data
26+
// 2. Call the tested function checkAndUpdateSnapshotClass via
27+
// controllerTest.testCall *once*.
28+
// 3. Compare resulting snapshotclass.
2929
func TestUpdateSnapshotClass(t *testing.T) {
3030
tests := []controllerTest{
3131
{

pkg/sidecar-controller/framework_test.go

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ import (
7171
// function to call as the actual test. Available functions are:
7272
// - testSyncContent - calls syncContent on the first content in initialContents.
7373
// - any custom function for specialized tests.
74+
//
7475
// The test then contains list of contents that are expected at the end
7576
// of the test and list of generated events.
7677
type controllerTest struct {
@@ -114,20 +115,20 @@ var (
114115

115116
// snapshotReactor is a core.Reactor that simulates etcd and API server. It
116117
// stores:
117-
// - Latest version of snapshots contents saved by the controller.
118-
// - Queue of all saves (to simulate "content updated" events). This queue
119-
// contains all intermediate state of an object. This queue will then contain both
120-
// updates as separate entries.
121-
// - Number of changes since the last call to snapshotReactor.syncAll().
122-
// - Optionally, content watcher which should be the same ones
123-
// used by the controller. Any time an event function like deleteContentEvent
124-
// is called to simulate an event, the reactor's stores are updated and the
125-
// controller is sent the event via the fake watcher.
126-
// - Optionally, list of error that should be returned by reactor, simulating
127-
// etcd / API server failures. These errors are evaluated in order and every
128-
// error is returned only once. I.e. when the reactor finds matching
129-
// reactorError, it return appropriate error and removes the reactorError from
130-
// the list.
118+
// - Latest version of snapshots contents saved by the controller.
119+
// - Queue of all saves (to simulate "content updated" events). This queue
120+
// contains all intermediate state of an object. This queue will then contain both
121+
// updates as separate entries.
122+
// - Number of changes since the last call to snapshotReactor.syncAll().
123+
// - Optionally, content watcher which should be the same ones
124+
// used by the controller. Any time an event function like deleteContentEvent
125+
// is called to simulate an event, the reactor's stores are updated and the
126+
// controller is sent the event via the fake watcher.
127+
// - Optionally, list of error that should be returned by reactor, simulating
128+
// etcd / API server failures. These errors are evaluated in order and every
129+
// error is returned only once. I.e. when the reactor finds matching
130+
// reactorError, it return appropriate error and removes the reactorError from
131+
// the list.
131132
type snapshotReactor struct {
132133
secrets map[string]*v1.Secret
133134
snapshotClasses map[string]*crdv1.VolumeSnapshotClass
@@ -711,11 +712,11 @@ var (
711712
)
712713

713714
// wrapTestWithInjectedOperation returns a testCall that:
714-
// - starts the controller and lets it run original testCall until
715-
// scheduleOperation() call. It blocks the controller there and calls the
716-
// injected function to simulate that something is happening when the
717-
// controller waits for the operation lock. Controller is then resumed and we
718-
// check how it behaves.
715+
// - starts the controller and lets it run original testCall until
716+
// scheduleOperation() call. It blocks the controller there and calls the
717+
// injected function to simulate that something is happening when the
718+
// controller waits for the operation lock. Controller is then resumed and we
719+
// check how it behaves.
719720
func wrapTestWithInjectedOperation(toWrap testCall, injectBeforeOperation func(ctrl *csiSnapshotSideCarController, reactor *snapshotReactor)) testCall {
720721
return func(ctrl *csiSnapshotSideCarController, reactor *snapshotReactor, test controllerTest) error {
721722
// Inject a hook before async operation starts
@@ -757,10 +758,10 @@ func evaluateTestResults(ctrl *csiSnapshotSideCarController, reactor *snapshotRe
757758

758759
// Test single call to syncContent methods.
759760
// For all tests:
760-
// 1. Fill in the controller with initial data
761-
// 2. Call the tested function (syncContent) via
762-
// controllerTest.testCall *once*.
763-
// 3. Compare resulting contents and snapshots with expected contents and snapshots.
761+
// 1. Fill in the controller with initial data
762+
// 2. Call the tested function (syncContent) via
763+
// controllerTest.testCall *once*.
764+
// 3. Compare resulting contents and snapshots with expected contents and snapshots.
764765
func runSyncContentTests(t *testing.T, tests []controllerTest, snapshotClasses []*crdv1.VolumeSnapshotClass) {
765766
snapshotscheme.AddToScheme(scheme.Scheme)
766767
for _, test := range tests {

pkg/sidecar-controller/snapshot_controller.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,9 @@ func (ctrl *csiSnapshotSideCarController) checkandUpdateContentStatus(content *c
137137
// given event on the content. It saves the status and emits the event only when
138138
// the status has actually changed from the version saved in API server.
139139
// Parameters:
140-
// content - content to update
141-
// eventtype, reason, message - event to send, see EventRecorder.Event()
140+
//
141+
// * content - content to update
142+
// * eventtype, reason, message - event to send, see EventRecorder.Event()
142143
func (ctrl *csiSnapshotSideCarController) updateContentErrorStatusWithEvent(content *crdv1.VolumeSnapshotContent, eventtype, reason, message string) error {
143144
klog.V(5).Infof("updateContentStatusWithEvent[%s]", content.Name)
144145

pkg/utils/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func verifyAndGetSecretNameAndNamespaceTemplate(secret secretParamsMap, snapshot
268268
}
269269

270270
// getSecretReference returns a reference to the secret specified in the given nameTemplate
271-
// and namespaceTemplate, or an error if the templates are not specified correctly.
271+
// and namespaceTemplate, or an error if the templates are not specified correctly.
272272
// No lookup of the referenced secret is performed, and the secret may or may not exist.
273273
//
274274
// supported tokens for name resolution:

0 commit comments

Comments
 (0)