From a1c54a9671e584802ed6d7eee53e68f1c2a4280f Mon Sep 17 00:00:00 2001 From: Joseph Marrero Date: Mon, 21 Nov 2022 14:00:54 -0500 Subject: [PATCH] Update go code with gofmt -w -s --- mantle/harness/_example/doc.go | 1 - mantle/harness/doc.go | 76 +++++++-------- mantle/kola/tests/misc/boot-mirror.go | 2 +- mantle/kola/tests/util/luks.go | 2 +- mantle/lang/natsort/cmp.go | 5 +- mantle/lang/worker/group.go | 9 +- mantle/network/ntp/protocol.go | 117 +++++++++++------------ mantle/platform/api/azure/storage_mit.go | 5 - mantle/platform/api/ibmcloud/s3.go | 2 +- mantle/platform/qemu.go | 8 +- 10 files changed, 108 insertions(+), 119 deletions(-) diff --git a/mantle/harness/_example/doc.go b/mantle/harness/_example/doc.go index 87a25e939a..e75c1448b4 100644 --- a/mantle/harness/_example/doc.go +++ b/mantle/harness/_example/doc.go @@ -27,5 +27,4 @@ // --- SKIP: SkipIt (0.00s) // main.go:40: Missing "TEST_DATA_else" in environment. // PASS -// package main diff --git a/mantle/harness/doc.go b/mantle/harness/doc.go index 7a1d077813..4650dcfbe0 100644 --- a/mantle/harness/doc.go +++ b/mantle/harness/doc.go @@ -23,27 +23,28 @@ // // Tests may be skipped if not applicable with a call to // the Skip method of *H: -// func NeedsSomeData(h *harness.H) { -// if os.Getenv("SOME_DATA") == "" { -// h.Skip("skipping test due to missing SOME_DATA") -// } -// ... -// } // -// Subtests +// func NeedsSomeData(h *harness.H) { +// if os.Getenv("SOME_DATA") == "" { +// h.Skip("skipping test due to missing SOME_DATA") +// } +// ... +// } +// +// # Subtests // // The Run method of H allow defining subtests, // without having to define separate functions for each. This enables uses // like table-driven and hierarchical tests. // It also provides a way to share common setup and tear-down code: // -// func Foo(h *harness.H) { -// // -// h.Run("A=1", func(h *harness.H) { ... }) -// h.Run("A=2", func(h *harness.H) { ... }) -// h.Run("B=1", func(h *harness.H) { ... }) -// // -// } +// func Foo(h *harness.H) { +// // +// h.Run("A=1", func(h *harness.H) { ... }) +// h.Run("A=2", func(h *harness.H) { ... }) +// h.Run("B=1", func(h *harness.H) { ... }) +// // +// } // // Each subtest has a unique name: the combination of the name // of the top-level test and the sequence of names passed to Run, separated by @@ -56,40 +57,40 @@ // empty expression matches any string. // For example, using "matching" to mean "whose name contains": // -// go run foo.go -harness.run '' # Run all tests. -// go run foo.go -harness.run Foo # Run top-level tests matching "Foo", such as "TestFooBar". -// go run foo.go -harness.run Foo/A= # For top-level tests matching "Foo", run subtests matching "A=". -// go run foo.go -harness.run /A=1 # For all top-level tests, run subtests matching "A=1". +// go run foo.go -harness.run '' # Run all tests. +// go run foo.go -harness.run Foo # Run top-level tests matching "Foo", such as "TestFooBar". +// go run foo.go -harness.run Foo/A= # For top-level tests matching "Foo", run subtests matching "A=". +// go run foo.go -harness.run /A=1 # For all top-level tests, run subtests matching "A=1". // // Subtests can also be used to control parallelism. A parent test will only // complete once all of its subtests complete. In this example, all tests are // run in parallel with each other, and only with each other, regardless of // other top-level tests that may be defined: // -// func GroupedParallel(h *harness.H) { -// for _, tc := range tests { -// tc := tc // capture range variable -// h.Run(tc.Name, func(h *harness.H) { -// h.Parallel() -// ... -// }) -// } -// } +// func GroupedParallel(h *harness.H) { +// for _, tc := range tests { +// tc := tc // capture range variable +// h.Run(tc.Name, func(h *harness.H) { +// h.Parallel() +// ... +// }) +// } +// } // // Run does not return until parallel subtests have completed, providing a way // to clean up after a group of parallel tests: // -// func TeardownParallel(h *harness.H) { -// // This Run will not return until the parallel tests finish. -// h.Run("group", func(h *harness.H) { -// h.Run("Test1", parallelTest1) -// h.Run("Test2", parallelTest2) -// h.Run("Test3", parallelTest3) -// }) -// // -// } +// func TeardownParallel(h *harness.H) { +// // This Run will not return until the parallel tests finish. +// h.Run("group", func(h *harness.H) { +// h.Run("Test1", parallelTest1) +// h.Run("Test2", parallelTest2) +// h.Run("Test3", parallelTest3) +// }) +// // +// } // -// Suite +// # Suite // // Individual tests are grouped into a test suite in order to execute them. // TODO: this part of the API deviates from the "testing" package and is TBD. @@ -111,5 +112,4 @@ // } // fmt.Println("PASS") // } -// package harness diff --git a/mantle/kola/tests/misc/boot-mirror.go b/mantle/kola/tests/misc/boot-mirror.go index d4a521743a..cb91218d14 100644 --- a/mantle/kola/tests/misc/boot-mirror.go +++ b/mantle/kola/tests/misc/boot-mirror.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/mantle/kola/tests/util/luks.go b/mantle/kola/tests/util/luks.go index a256930ee5..dd7968fd38 100644 --- a/mantle/kola/tests/util/luks.go +++ b/mantle/kola/tests/util/luks.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/mantle/lang/natsort/cmp.go b/mantle/lang/natsort/cmp.go index 4fb73072fb..029b04f57a 100644 --- a/mantle/lang/natsort/cmp.go +++ b/mantle/lang/natsort/cmp.go @@ -19,15 +19,14 @@ // Strings are sorted as usual, except that decimal integer substrings // are compared on their numeric value. For example: // -// a < a0 < a1 < a1a < a1b < a2 < a10 < a20 +// a < a0 < a1 < a1a < a1b < a2 < a10 < a20 // // All white space and control characters are ignored. // // Leading zeros are *not* ignored, which tends to give more // reasonable results on decimal fractions: // -// 1.001 < 1.002 < 1.010 < 1.02 < 1.1 < 1.3 -// +// 1.001 < 1.002 < 1.010 < 1.02 < 1.1 < 1.3 package natsort func isDigit(s string, i int) bool { diff --git a/mantle/lang/worker/group.go b/mantle/lang/worker/group.go index f9d625943f..4360e4d05e 100644 --- a/mantle/lang/worker/group.go +++ b/mantle/lang/worker/group.go @@ -26,10 +26,10 @@ type Worker func(context.Context) error // WorkerGroup is similar in principle to sync.WaitGroup but manages the // Workers itself. This allows it to provide a few helpful features: -// - Integration with the context library. -// - Limit the number of concurrent Workers. -// - Capture the errors returned by each Worker. -// - Abort everything after a single Worker reports an error. +// - Integration with the context library. +// - Limit the number of concurrent Workers. +// - Capture the errors returned by each Worker. +// - Abort everything after a single Worker reports an error. type WorkerGroup struct { ctx context.Context cancel context.CancelFunc @@ -98,7 +98,6 @@ func (wg *WorkerGroup) Wait() error { // if err := wg.Start(worker); err != nil { // return wg.WaitError(err) // } -// func (wg *WorkerGroup) WaitError(err error) error { if werr := wg.Wait(); werr != nil { return werr diff --git a/mantle/network/ntp/protocol.go b/mantle/network/ntp/protocol.go index d2e00601f5..3b7f85e103 100644 --- a/mantle/network/ntp/protocol.go +++ b/mantle/network/ntp/protocol.go @@ -32,12 +32,11 @@ var be = binary.BigEndian // NTP Short Format // -// 0 1 2 3 -// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | Seconds | Fraction | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// +// 0 1 2 3 +// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Seconds | Fraction | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ type Short struct { Seconds uint16 Fraction uint16 @@ -55,14 +54,13 @@ func (s *Short) unmarshalBinary(b []byte) { // NTP Timestamp Format // -// 0 1 2 3 -// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | Seconds | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | Fraction | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// +// 0 1 2 3 +// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Seconds | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Fraction | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ type Timestamp struct { Seconds uint32 Fraction uint32 @@ -134,52 +132,51 @@ const ( // NTP Packet Header Format // -// 0 1 2 3 -// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// |LI | VN |Mode | Stratum | Poll | Precision | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | Root Delay | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | Root Dispersion | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | Reference ID | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | | -// + Reference Timestamp (64) + -// | | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | | -// + Origin Timestamp (64) + -// | | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | | -// + Receive Timestamp (64) + -// | | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | | -// + Transmit Timestamp (64) + -// | | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | | -// . . -// . Extension Field 1 (variable) . -// . . -// | | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | | -// . . -// . Extension Field 2 (variable) . -// . . -// | | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | Key Identifier | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | | -// | dgst (128) | -// | | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// +// 0 1 2 3 +// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// |LI | VN |Mode | Stratum | Poll | Precision | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Root Delay | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Root Dispersion | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Reference ID | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | | +// + Reference Timestamp (64) + +// | | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | | +// + Origin Timestamp (64) + +// | | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | | +// + Receive Timestamp (64) + +// | | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | | +// + Transmit Timestamp (64) + +// | | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | | +// . . +// . Extension Field 1 (variable) . +// . . +// | | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | | +// . . +// . Extension Field 2 (variable) . +// . . +// | | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Key Identifier | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | | +// | dgst (128) | +// | | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ type Header struct { LeapIndicator LeapIndicator // 2 bits VersionNumber VersionNumber // 3 bits diff --git a/mantle/platform/api/azure/storage_mit.go b/mantle/platform/api/azure/storage_mit.go index d58e7a74fe..fbe926c8ff 100644 --- a/mantle/platform/api/azure/storage_mit.go +++ b/mantle/platform/api/azure/storage_mit.go @@ -182,7 +182,6 @@ func (a *API) UploadBlob(storageaccount, storagekey, vhd, container, blob string // in which the page blob resides, parameter blobName is name for the page blob // This method attempt to fetch the metadata only if MD5Hash is not set for the page blob, this method panic if the // MD5Hash is already set or if the custom metadata is absent. -// func getBlobMetaData(client storage.BlobStorageClient, containerName, blobName string) (*metadata.MetaData, error) { md5Hash, err := getBlobMD5Hash(client, containerName, blobName) if md5Hash != "" { @@ -205,7 +204,6 @@ func getBlobMetaData(client storage.BlobStorageClient, containerName, blobName s } // getLocalVHDMetaData returns the metadata of a local VHD -// func getLocalVHDMetaData(localVHDPath string) (*metadata.MetaData, error) { localMetaData, err := metadata.NewMetaDataFromLocalVHD(localVHDPath) if err != nil { @@ -218,7 +216,6 @@ func getLocalVHDMetaData(localVHDPath string) (*metadata.MetaData, error) { // The parameter client is the Azure blob service client, parameter containerName is the name of an existing container // in which the page blob needs to be created, parameter blobName is name for the new page blob, size is the size of // the new page blob in bytes and parameter vhdMetaData is the custom metadata to be associacted with the page blob -// func createBlob(client storage.BlobStorageClient, containerName, blobName string, size int64, vhdMetaData *metadata.MetaData) error { if err := client.PutPageBlob(containerName, blobName, size, nil); err != nil { return err @@ -234,7 +231,6 @@ func createBlob(client storage.BlobStorageClient, containerName, blobName string // getAlreadyUploadedBlobRanges returns the range slice containing ranges of a page blob those are already uploaded. // The parameter client is the Azure blob service client, parameter containerName is the name of an existing container // in which the page blob resides, parameter blobName is name for the page blob -// func getAlreadyUploadedBlobRanges(client storage.BlobStorageClient, containerName, blobName string) ([]*common.IndexRange, error) { existingRanges, err := client.GetPageRanges(containerName, blobName) if err != nil { @@ -250,7 +246,6 @@ func getAlreadyUploadedBlobRanges(client storage.BlobStorageClient, containerNam // getBlobMD5Hash returns the MD5Hash associated with a blob // The parameter client is the Azure blob service client, parameter containerName is the name of an existing container // in which the page blob resides, parameter blobName is name for the page blob -// func getBlobMD5Hash(client storage.BlobStorageClient, containerName, blobName string) (string, error) { properties, err := client.GetBlobProperties(containerName, blobName) if err != nil { diff --git a/mantle/platform/api/ibmcloud/s3.go b/mantle/platform/api/ibmcloud/s3.go index 5dcd03528f..ee57155618 100644 --- a/mantle/platform/api/ibmcloud/s3.go +++ b/mantle/platform/api/ibmcloud/s3.go @@ -134,7 +134,7 @@ func (a *API) checkIfObjectExists(objectName, bucketName string) bool { return err == nil } -//UploadObject - upload to s3 bucket +// UploadObject - upload to s3 bucket func (a *API) UploadObject(r io.Reader, objectName, bucketName string, force bool) error { // check if image exists and force is not set then bail if !force { diff --git a/mantle/platform/qemu.go b/mantle/platform/qemu.go index 08430bfa94..86dccf452a 100644 --- a/mantle/platform/qemu.go +++ b/mantle/platform/qemu.go @@ -1334,10 +1334,10 @@ func (builder *QemuBuilder) SerialPipe() (*os.File, error) { // VirtioJournal configures the OS and VM to stream the systemd journal // (post-switchroot) over a virtio-serial channel. -// - The first parameter is a poitner to the configuration of the target VM. -// - The second parameter is an optional queryArguments to filter the stream - -// see `man journalctl` for more information. -// - The return value is a file stream which will be newline-separated JSON. +// - The first parameter is a poitner to the configuration of the target VM. +// - The second parameter is an optional queryArguments to filter the stream - +// see `man journalctl` for more information. +// - The return value is a file stream which will be newline-separated JSON. func (builder *QemuBuilder) VirtioJournal(config *conf.Conf, queryArguments string) (*os.File, error) { stream, err := builder.VirtioChannelRead("mantlejournal") if err != nil {