linter cleanup (#344)

* go fmt
* static check
This commit is contained in:
Malte Poll 2022-08-05 15:30:23 +02:00 committed by GitHub
parent 32a990b4f2
commit bf5816cc00
7 changed files with 18 additions and 15 deletions

View File

@ -2,7 +2,7 @@ package cmd
import (
"bytes"
"io/ioutil"
"io"
"net/http"
"net/url"
"testing"
@ -175,20 +175,20 @@ func TestConfigFetchMeasurements(t *testing.T) {
if req.URL.String() == "https://public-edgeless-constellation.s3.us-east-2.amazonaws.com/projects/constellation-images/global/images/constellation-coreos-1658216163/measurements.yaml" {
return &http.Response{
StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewBufferString(measurements)),
Body: io.NopCloser(bytes.NewBufferString(measurements)),
Header: make(http.Header),
}
}
if req.URL.String() == "https://public-edgeless-constellation.s3.us-east-2.amazonaws.com/projects/constellation-images/global/images/constellation-coreos-1658216163/measurements.yaml.sig" {
return &http.Response{
StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewBufferString(signature)),
Body: io.NopCloser(bytes.NewBufferString(signature)),
Header: make(http.Header),
}
}
return &http.Response{
StatusCode: http.StatusNotFound,
Body: ioutil.NopCloser(bytes.NewBufferString("Not found.")),
Body: io.NopCloser(bytes.NewBufferString("Not found.")),
Header: make(http.Header),
}
})

View File

@ -1,6 +1,7 @@
//go:generate docgen ./config.go ./config_doc.go Configuration
// This binary can be build from siderolabs/talos projects. Located at:
// https://github.com/siderolabs/talos/tree/master/hack/docgen
//
//go:generate docgen ./config.go ./config_doc.go Configuration
package config
import (

View File

@ -5,7 +5,7 @@ import (
"context"
"encoding/base64"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
@ -112,7 +112,7 @@ func getFromURL(ctx context.Context, client *http.Client, sourceURL *url.URL) ([
if resp.StatusCode != http.StatusOK {
return []byte{}, fmt.Errorf("http status code: %d", resp.StatusCode)
}
content, err := ioutil.ReadAll(resp.Body)
content, err := io.ReadAll(resp.Body)
if err != nil {
return []byte{}, err
}

View File

@ -3,7 +3,7 @@ package config
import (
"context"
"errors"
"io/ioutil"
"io"
"net/http"
"net/url"
"strings"
@ -282,20 +282,20 @@ func TestMeasurementsFetchAndVerify(t *testing.T) {
if req.URL.String() == measurementsURL.String() {
return &http.Response{
StatusCode: tc.measurementsStatus,
Body: ioutil.NopCloser(strings.NewReader(tc.measurements)),
Body: io.NopCloser(strings.NewReader(tc.measurements)),
Header: make(http.Header),
}
}
if req.URL.String() == signatureURL.String() {
return &http.Response{
StatusCode: tc.signatureStatus,
Body: ioutil.NopCloser(strings.NewReader(tc.signature)),
Body: io.NopCloser(strings.NewReader(tc.signature)),
Header: make(http.Header),
}
}
return &http.Response{
StatusCode: http.StatusNotFound,
Body: ioutil.NopCloser(strings.NewReader("Not found.")),
Body: io.NopCloser(strings.NewReader("Not found.")),
Header: make(http.Header),
}
})

View File

@ -3,7 +3,7 @@ Package logger provides logging functionality for Constellation services.
It is a thin wrapper around the zap package, providing a consistent interface for logging.
Use this package to implement logging for your Constellation services.
Usage
# Usage
1. Create a logger using New().
@ -18,7 +18,7 @@ This can also be used to add context to a single log message:
logger.With(zap.String("key", "value")).Infof("log message")
Log Levels
# Log Levels
Use Debugf() to log low level and detailed information that is useful for debugging.

View File

@ -31,7 +31,8 @@ const (
// packageLock is needed to block concurrent use of package functions, since libcryptsetup is not thread safe.
// See: https://gitlab.com/cryptsetup/cryptsetup/-/issues/710
// https://stackoverflow.com/questions/30553386/cryptsetup-backend-safe-with-multithreading
//
// https://stackoverflow.com/questions/30553386/cryptsetup-backend-safe-with-multithreading
var packageLock = sync.Mutex{}
func init() {

View File

@ -14,7 +14,8 @@ import (
// packageLock is needed to block concurrent use of package functions, since libcryptsetup is not thread safe.
// See: https://gitlab.com/cryptsetup/cryptsetup/-/issues/710
// https://stackoverflow.com/questions/30553386/cryptsetup-backend-safe-with-multithreading
//
// https://stackoverflow.com/questions/30553386/cryptsetup-backend-safe-with-multithreading
var packageLock = sync.Mutex{}
// Mapper handles actions for formating and mapping crypt devices.