From 41ecaadc821db56e59b038a3f7396d2b149afafa Mon Sep 17 00:00:00 2001 From: Humble Chirammal Date: Fri, 25 Jun 2021 18:32:50 +0530 Subject: [PATCH] e2e: reformat long lines in this package to 120 chars We have many declarations and invocations..etc with long lines which are very difficult to follow while doing code reading. This address the issues in 'e2e/staticpvc.go' and 'e2e/snapshot.go' files to restrict the line length to 120 chars. Signed-off-by: Humble Chirammal --- e2e/snapshot.go | 32 +++++++++++++++++++++++++------- e2e/staticpvc.go | 22 +++++++++++++++++++--- 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/e2e/snapshot.go b/e2e/snapshot.go index e55055b24..312b31c8a 100644 --- a/e2e/snapshot.go +++ b/e2e/snapshot.go @@ -47,7 +47,10 @@ func createSnapshot(snap *snapapi.VolumeSnapshot, t int) error { if err != nil { return err } - _, err = sclient.VolumeSnapshots(snap.Namespace).Create(context.TODO(), snap, metav1.CreateOptions{}) + + _, err = sclient. + VolumeSnapshots(snap.Namespace). + Create(context.TODO(), snap, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("failed to create volumesnapshot: %w", err) } @@ -60,7 +63,9 @@ func createSnapshot(snap *snapapi.VolumeSnapshot, t int) error { return wait.PollImmediate(poll, timeout, func() (bool, error) { e2elog.Logf("waiting for snapshot %s (%d seconds elapsed)", snap.Name, int(time.Since(start).Seconds())) - snaps, err := sclient.VolumeSnapshots(snap.Namespace).Get(context.TODO(), name, metav1.GetOptions{}) + snaps, err := sclient. + VolumeSnapshots(snap.Namespace). + Get(context.TODO(), name, metav1.GetOptions{}) if err != nil { e2elog.Logf("Error getting snapshot in namespace: '%s': %v", snap.Namespace, err) if isRetryableAPIError(err) { @@ -87,7 +92,10 @@ func deleteSnapshot(snap *snapapi.VolumeSnapshot, t int) error { if err != nil { return err } - err = sclient.VolumeSnapshots(snap.Namespace).Delete(context.TODO(), snap.Name, metav1.DeleteOptions{}) + + err = sclient. + VolumeSnapshots(snap.Namespace). + Delete(context.TODO(), snap.Name, metav1.DeleteOptions{}) if err != nil { return fmt.Errorf("failed to delete volumesnapshot: %w", err) } @@ -99,13 +107,18 @@ func deleteSnapshot(snap *snapapi.VolumeSnapshot, t int) error { return wait.PollImmediate(poll, timeout, func() (bool, error) { e2elog.Logf("deleting snapshot %s (%d seconds elapsed)", name, int(time.Since(start).Seconds())) - _, err := sclient.VolumeSnapshots(snap.Namespace).Get(context.TODO(), name, metav1.GetOptions{}) + _, err := sclient. + VolumeSnapshots(snap.Namespace). + Get(context.TODO(), name, metav1.GetOptions{}) if err == nil { return false, nil } if !apierrs.IsNotFound(err) { - return false, fmt.Errorf("get on deleted snapshot %v failed with error other than \"not found\": %v", name, err) + return false, fmt.Errorf( + "get on deleted snapshot %v failed with error other than \"not found\": %v", + name, + err) } return true, nil @@ -177,12 +190,17 @@ func getVolumeSnapshotContent(namespace, snapshotName string) (*snapapi.VolumeSn if err != nil { return nil, err } - snapshot, err := sclient.VolumeSnapshots(namespace).Get(context.TODO(), snapshotName, metav1.GetOptions{}) + + snapshot, err := sclient. + VolumeSnapshots(namespace). + Get(context.TODO(), snapshotName, metav1.GetOptions{}) if err != nil { return nil, fmt.Errorf("failed to get volumesnapshot: %w", err) } - volumeSnapshotContent, err := sclient.VolumeSnapshotContents().Get(context.TODO(), *snapshot.Status.BoundVolumeSnapshotContentName, metav1.GetOptions{}) + volumeSnapshotContent, err := sclient. + VolumeSnapshotContents(). + Get(context.TODO(), *snapshot.Status.BoundVolumeSnapshotContentName, metav1.GetOptions{}) if err != nil { return nil, fmt.Errorf("failed to get volumesnapshotcontent: %w", err) } diff --git a/e2e/staticpvc.go b/e2e/staticpvc.go index f64af8131..b596c726d 100644 --- a/e2e/staticpvc.go +++ b/e2e/staticpvc.go @@ -11,7 +11,10 @@ import ( "k8s.io/kubernetes/test/e2e/framework" ) -func getStaticPV(name, volName, size, secretName, secretNS, sc, driverName string, blockPV bool, options map[string]string) *v1.PersistentVolume { +func getStaticPV( + name, volName, size, secretName, secretNS, sc, driverName string, + blockPV bool, + options map[string]string) *v1.PersistentVolume { pv := &v1.PersistentVolume{ ObjectMeta: metav1.ObjectMeta{ Name: name, @@ -102,7 +105,11 @@ func validateRBDStaticPV(f *framework.Framework, appPath string, isBlock, checkI fsID = strings.Trim(fsID, "\n") size := "4Gi" // create rbd image - cmd := fmt.Sprintf("rbd create %s --size=%d --image-feature=layering %s", rbdImageName, 4096, rbdOptions(defaultRBDPool)) + cmd := fmt.Sprintf( + "rbd create %s --size=%d --image-feature=layering %s", + rbdImageName, + 4096, + rbdOptions(defaultRBDPool)) _, e, err = execCommandInToolBoxPod(f, cmd, rookNamespace) if err != nil { @@ -121,7 +128,16 @@ func validateRBDStaticPV(f *framework.Framework, appPath string, isBlock, checkI opt["radosNamespace"] = radosNamespace } - pv := getStaticPV(pvName, rbdImageName, size, rbdNodePluginSecretName, cephCSINamespace, sc, "rbd.csi.ceph.com", isBlock, opt) + pv := getStaticPV( + pvName, + rbdImageName, + size, + rbdNodePluginSecretName, + cephCSINamespace, + sc, + "rbd.csi.ceph.com", + isBlock, + opt) _, err = c.CoreV1().PersistentVolumes().Create(context.TODO(), pv, metav1.CreateOptions{}) if err != nil {