Skip to content

Commit

Permalink
Update go code with gofmt -w -s
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarrero authored and dustymabe committed Nov 21, 2022
1 parent 09ef0cb commit a1c54a9
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 119 deletions.
1 change: 0 additions & 1 deletion mantle/harness/_example/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@
// --- SKIP: SkipIt (0.00s)
// main.go:40: Missing "TEST_DATA_else" in environment.
// PASS
//
package main
76 changes: 38 additions & 38 deletions mantle/harness/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
// // <setup code>
// h.Run("A=1", func(h *harness.H) { ... })
// h.Run("A=2", func(h *harness.H) { ... })
// h.Run("B=1", func(h *harness.H) { ... })
// // <tear-down code>
// }
// func Foo(h *harness.H) {
// // <setup code>
// h.Run("A=1", func(h *harness.H) { ... })
// h.Run("A=2", func(h *harness.H) { ... })
// h.Run("B=1", func(h *harness.H) { ... })
// // <tear-down code>
// }
//
// 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
Expand All @@ -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)
// })
// // <tear-down code>
// }
// 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)
// })
// // <tear-down code>
// }
//
// 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.
Expand All @@ -111,5 +112,4 @@
// }
// fmt.Println("PASS")
// }
//
package harness
2 changes: 1 addition & 1 deletion mantle/kola/tests/misc/boot-mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion mantle/kola/tests/util/luks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions mantle/lang/natsort/cmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 4 additions & 5 deletions mantle/lang/worker/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
117 changes: 57 additions & 60 deletions mantle/network/ntp/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions mantle/platform/api/azure/storage_mit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand All @@ -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 {
Expand All @@ -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
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion mantle/platform/api/ibmcloud/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions mantle/platform/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a1c54a9

Please sign in to comment.