Linter fixes numero 2 (#4408)
This commit is contained in:
1 parent
25bce9e8ff
commit
49803e653c
23 files changed
+172
-109
No files matched your search
@@ -10,7 +10,6 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/signal"
|
||||
"regexp"
|
||||
@@ -517,7 +516,7 @@ func NewFlagSets(ui cli.Ui) *FlagSets {
|
||||
|
||||
// Errors and usage are controlled by the CLI.
|
||||
mainSet.Usage = func() {}
|
||||
mainSet.SetOutput(ioutil.Discard)
|
||||
mainSet.SetOutput(io.Discard)
|
||||
|
||||
return &FlagSets{
|
||||
flagSets: make([]*FlagSet, 0, 6),
|
||||
|
||||
@@ -6,7 +6,6 @@ package base
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"sync"
|
||||
"testing"
|
||||
@@ -52,7 +51,7 @@ func Test_oidcLogger_Errorf(t *testing.T) {
|
||||
l.Errorf(tt.fmt, tt.args...)
|
||||
sinkFileName := c.AllEvents.Name()
|
||||
defer func() { _ = os.WriteFile(sinkFileName, nil, 0o666) }()
|
||||
b, err := ioutil.ReadFile(sinkFileName)
|
||||
b, err := os.ReadFile(sinkFileName)
|
||||
require.NoError(err)
|
||||
gotEvent := &cloudevents.Event{}
|
||||
err = json.Unmarshal(b, gotEvent)
|
||||
@@ -98,7 +97,7 @@ func Test_oidcLogger_Infof(t *testing.T) {
|
||||
l.Infof(tt.fmt, tt.args...)
|
||||
sinkFileName := c.AllEvents.Name()
|
||||
defer func() { _ = os.WriteFile(sinkFileName, nil, 0o666) }()
|
||||
b, err := ioutil.ReadFile(sinkFileName)
|
||||
b, err := os.ReadFile(sinkFileName)
|
||||
require.NoError(err)
|
||||
gotEvent := &cloudevents.Event{}
|
||||
err = json.Unmarshal(b, gotEvent)
|
||||
|
||||
@@ -79,20 +79,60 @@ func (g *GRPCLogFaker) Fatalln(args ...any) {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func (g *GRPCLogFaker) Print(args ...any) {
|
||||
func (g *GRPCLogFaker) Info(args ...any) {
|
||||
if g.Log && g.Logger.IsDebug() {
|
||||
g.Logger.Debug(fmt.Sprint(args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (g *GRPCLogFaker) Printf(format string, args ...any) {
|
||||
func (g *GRPCLogFaker) Infof(format string, args ...any) {
|
||||
if g.Log && g.Logger.IsDebug() {
|
||||
g.Logger.Debug(fmt.Sprintf(format, args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (g *GRPCLogFaker) Println(args ...any) {
|
||||
func (g *GRPCLogFaker) Infoln(args ...any) {
|
||||
if g.Log && g.Logger.IsDebug() {
|
||||
g.Logger.Debug(fmt.Sprintln(args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (g *GRPCLogFaker) Warning(args ...any) {
|
||||
if g.Log && g.Logger.IsDebug() {
|
||||
g.Logger.Debug(fmt.Sprint(args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (g *GRPCLogFaker) Warningf(format string, args ...any) {
|
||||
if g.Log && g.Logger.IsDebug() {
|
||||
g.Logger.Debug(fmt.Sprintf(format, args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (g *GRPCLogFaker) Warningln(args ...any) {
|
||||
if g.Log && g.Logger.IsDebug() {
|
||||
g.Logger.Debug(fmt.Sprintln(args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (g *GRPCLogFaker) Error(args ...any) {
|
||||
if g.Log && g.Logger.IsDebug() {
|
||||
g.Logger.Debug(fmt.Sprint(args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (g *GRPCLogFaker) Errorf(format string, args ...any) {
|
||||
if g.Log && g.Logger.IsDebug() {
|
||||
g.Logger.Debug(fmt.Sprintf(format, args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (g *GRPCLogFaker) Errorln(args ...any) {
|
||||
if g.Log && g.Logger.IsDebug() {
|
||||
g.Logger.Debug(fmt.Sprintln(args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (g *GRPCLogFaker) V(l int) bool {
|
||||
return true
|
||||
}
|
||||
@@ -285,7 +285,7 @@ func (b *Server) SetupLogging(flagLogLevel, flagLogFormat, configLogLevel, confi
|
||||
|
||||
// create GRPC logger
|
||||
namedGRPCLogFaker := b.Logger.Named("grpclogfaker")
|
||||
grpclog.SetLogger(&GRPCLogFaker{
|
||||
grpclog.SetLoggerV2(&GRPCLogFaker{
|
||||
Logger: namedGRPCLogFaker,
|
||||
Log: os.Getenv("BOUNDARY_GRPC_LOGGING") != "",
|
||||
})
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/textproto"
|
||||
"os"
|
||||
"strings"
|
||||
@@ -195,7 +194,7 @@ func (c *EncryptDecryptCommand) Run(args []string) (ret int) {
|
||||
}()
|
||||
}
|
||||
|
||||
d, err := ioutil.ReadFile(c.flagConfig)
|
||||
d, err := os.ReadFile(c.flagConfig)
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Errorf("Error reading config file: %w", err).Error())
|
||||
return base.CommandUserError
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -96,7 +95,7 @@ func TestEncryptDecrypt(t *testing.T) {
|
||||
// there are many tests on the underlying codebase for that. If it's not
|
||||
// encrypting, compare it to the cleartext to verify because we can.
|
||||
if c.f == "decrypt" {
|
||||
expected, err := ioutil.ReadFile(c.exp)
|
||||
expected, err := os.ReadFile(c.exp)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, strings.TrimSpace(string(expected)), strings.TrimSpace(string(got)))
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
"net"
|
||||
"net/http"
|
||||
@@ -21,7 +20,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/golang/protobuf/jsonpb"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller"
|
||||
@@ -38,6 +36,7 @@ import (
|
||||
"github.com/mitchellh/cli"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
"google.golang.org/protobuf/testing/protocmp"
|
||||
"google.golang.org/protobuf/types/known/wrapperspb"
|
||||
)
|
||||
@@ -721,7 +720,9 @@ func TestCreateOpsHandler(t *testing.T) {
|
||||
require.NoError(t, err) // We can do the GET request
|
||||
require.Equal(t, http.StatusOK, rsp.StatusCode) // And the endpoint exists
|
||||
pbResp := &pbs.GetHealthResponse{}
|
||||
require.NoError(t, jsonpb.Unmarshal(rsp.Body, pbResp))
|
||||
body, err = io.ReadAll(rsp.Body)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, protojson.Unmarshal(body, pbResp))
|
||||
want := &pbs.GetHealthResponse{WorkerProcessInfo: &pbhealth.HealthInfo{
|
||||
State: server.ActiveOperationalState.String(),
|
||||
ActiveSessionCount: wrapperspb.UInt32(0),
|
||||
@@ -752,7 +753,9 @@ func TestCreateOpsHandler(t *testing.T) {
|
||||
require.NoError(t, err) // We can do the GET request
|
||||
require.Equal(t, http.StatusOK, rsp.StatusCode) // And the endpoint exists
|
||||
pbResp := &pbs.GetHealthResponse{}
|
||||
require.NoError(t, jsonpb.Unmarshal(rsp.Body, pbResp))
|
||||
body, err = io.ReadAll(rsp.Body)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, protojson.Unmarshal(body, pbResp))
|
||||
want := &pbs.GetHealthResponse{WorkerProcessInfo: &pbhealth.HealthInfo{
|
||||
State: server.ActiveOperationalState.String(),
|
||||
ActiveSessionCount: wrapperspb.UInt32(0),
|
||||
@@ -932,7 +935,7 @@ func testTlsHttpClient(t *testing.T, certPath string) *http.Client {
|
||||
f, err := os.Open(certPath)
|
||||
require.NoError(t, err)
|
||||
|
||||
certBytes, err := ioutil.ReadAll(f)
|
||||
certBytes, err := io.ReadAll(f)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, f.Close())
|
||||
|
||||
|
||||
Reference in new issue
Block a user