From bf6e87eb0dc44e8e6f4401e7ae06e409798bb6c4 Mon Sep 17 00:00:00 2001 From: guoguangwu Date: Fri, 1 Sep 2023 10:08:03 +0800 Subject: [PATCH] chore: pkg imported more than once Signed-off-by: guoguangwu --- cmd/traffic/cmd/manager/state/state_test.go | 5 ++-- pkg/authenticator/exec_test.go | 3 +-- pkg/client/cli/connect/connector.go | 3 +-- pkg/client/rootd/service.go | 29 ++++++++++----------- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/cmd/traffic/cmd/manager/state/state_test.go b/cmd/traffic/cmd/manager/state/state_test.go index 69f1d2002c..863f61d0d2 100644 --- a/cmd/traffic/cmd/manager/state/state_test.go +++ b/cmd/traffic/cmd/manager/state/state_test.go @@ -11,7 +11,6 @@ import ( "github.com/datawire/dlib/dlog" "github.com/telepresenceio/telepresence/rpc/v2/manager" - rpc "github.com/telepresenceio/telepresence/rpc/v2/manager" testdata "github.com/telepresenceio/telepresence/v2/cmd/traffic/cmd/manager/test" "github.com/telepresenceio/telepresence/v2/pkg/log" ) @@ -28,7 +27,7 @@ func (s *suiteState) SetupTest() { s.state = &state{ ctx: s.ctx, sessions: make(map[string]SessionState), - agentsByName: make(map[string]map[string]*rpc.AgentInfo), + agentsByName: make(map[string]map[string]*manager.AgentInfo), cfgMapLocks: make(map[string]*sync.Mutex), interceptStates: make(map[string]*interceptState), timedLogLevel: log.NewTimedLevel("debug", log.SetLevel), @@ -161,7 +160,7 @@ func (s *suiteState) TestAddClient() { now := time.Now() // when - s.state.AddClient(&rpc.ClientInfo{ + s.state.AddClient(&manager.ClientInfo{ Name: "my-client", InstallId: "1234", Product: "5668", diff --git a/pkg/authenticator/exec_test.go b/pkg/authenticator/exec_test.go index 0ca41b9c1e..e6e2424fbd 100644 --- a/pkg/authenticator/exec_test.go +++ b/pkg/authenticator/exec_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/stretchr/testify/assert" - "k8s.io/client-go/tools/clientcmd/api" clientcmdapi "k8s.io/client-go/tools/clientcmd/api" ) @@ -27,7 +26,7 @@ func TestExecCredentialsYesLocalEnv(t *testing.T) { config := &clientcmdapi.ExecConfig{ Command: "sh", Args: []string{"-c", "echo $GLOBAL_ENV/$LOCAL_ENV"}, - Env: []api.ExecEnvVar{{Name: "LOCAL_ENV", Value: "local-val"}}, + Env: []clientcmdapi.ExecEnvVar{{Name: "LOCAL_ENV", Value: "local-val"}}, } result, err := execCredentialBinary{}.Resolve(context.Background(), config) assert.NoError(t, err) diff --git a/pkg/client/cli/connect/connector.go b/pkg/client/cli/connect/connector.go index e8c5a7c73f..925aa819cc 100644 --- a/pkg/client/cli/connect/connector.go +++ b/pkg/client/cli/connect/connector.go @@ -14,7 +14,6 @@ import ( "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/emptypb" - empty "google.golang.org/protobuf/types/known/emptypb" "github.com/telepresenceio/telepresence/rpc/v2/connector" "github.com/telepresenceio/telepresence/v2/pkg/client" @@ -238,7 +237,7 @@ func connectSession(cmd *cobra.Command, userD *daemon.UserClient, request *daemo ctx := cmd.Context() if request.Implicit { // implicit calls use the current Status instead of passing flags and mapped namespaces. - if ci, err = userD.Status(ctx, &empty.Empty{}); err != nil { + if ci, err = userD.Status(ctx, &emptypb.Empty{}); err != nil { return nil, err } switch ci.Error { diff --git a/pkg/client/rootd/service.go b/pkg/client/rootd/service.go index 67fdf355c4..26c84031c2 100644 --- a/pkg/client/rootd/service.go +++ b/pkg/client/rootd/service.go @@ -17,7 +17,6 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/emptypb" - empty "google.golang.org/protobuf/types/known/emptypb" "github.com/datawire/dlib/derror" "github.com/datawire/dlib/dgroup" @@ -123,7 +122,7 @@ func Command() *cobra.Command { return cmd } -func (s *Service) Version(_ context.Context, _ *empty.Empty) (*common.VersionInfo, error) { +func (s *Service) Version(_ context.Context, _ *emptypb.Empty) (*common.VersionInfo, error) { return &common.VersionInfo{ ApiVersion: client.APIVersion, Version: client.Version(), @@ -131,7 +130,7 @@ func (s *Service) Version(_ context.Context, _ *empty.Empty) (*common.VersionInf }, nil } -func (s *Service) Status(_ context.Context, _ *empty.Empty) (*rpc.DaemonStatus, error) { +func (s *Service) Status(_ context.Context, _ *emptypb.Empty) (*rpc.DaemonStatus, error) { s.sessionLock.RLock() defer s.sessionLock.RUnlock() r := &rpc.DaemonStatus{ @@ -147,28 +146,28 @@ func (s *Service) Status(_ context.Context, _ *empty.Empty) (*rpc.DaemonStatus, return r, nil } -func (s *Service) Quit(ctx context.Context, _ *empty.Empty) (*empty.Empty, error) { +func (s *Service) Quit(ctx context.Context, _ *emptypb.Empty) (*emptypb.Empty, error) { dlog.Debug(ctx, "Received gRPC Quit") if !s.sessionLock.TryRLock() { // A running session is blocking with a write-lock. Give it some time to quit, then kill it time.Sleep(2 * time.Second) if !s.sessionLock.TryRLock() { s.quit() - return &empty.Empty{}, nil + return &emptypb.Empty{}, nil } } defer s.sessionLock.RUnlock() s.cancelSessionReadLocked() s.quit() - return &empty.Empty{}, nil + return &emptypb.Empty{}, nil } -func (s *Service) SetDnsSearchPath(ctx context.Context, paths *rpc.Paths) (*empty.Empty, error) { +func (s *Service) SetDnsSearchPath(ctx context.Context, paths *rpc.Paths) (*emptypb.Empty, error) { err := s.WithSession(func(ctx context.Context, session *Session) error { session.SetSearchPath(ctx, paths.Paths, paths.Namespaces) return nil }) - return &empty.Empty{}, err + return &emptypb.Empty{}, err } func (s *Service) SetDNSExcludes(ctx context.Context, req *rpc.SetDNSExcludesRequest) (*emptypb.Empty, error) { @@ -211,20 +210,20 @@ func (s *Service) Connect(ctx context.Context, info *rpc.OutboundInfo) (*rpc.Dae } } -func (s *Service) Disconnect(ctx context.Context, _ *empty.Empty) (*empty.Empty, error) { +func (s *Service) Disconnect(ctx context.Context, _ *emptypb.Empty) (*emptypb.Empty, error) { dlog.Debug(ctx, "Received gRPC Disconnect") s.cancelSession() - return &empty.Empty{}, nil + return &emptypb.Empty{}, nil } -func (s *Service) WaitForNetwork(ctx context.Context, e *empty.Empty) (*empty.Empty, error) { +func (s *Service) WaitForNetwork(ctx context.Context, e *emptypb.Empty) (*emptypb.Empty, error) { err := s.WithSession(func(ctx context.Context, session *Session) error { if err, ok := <-session.networkReady(ctx); ok { return status.Error(codes.Unavailable, err.Error()) } return nil }) - return &empty.Empty{}, err + return &emptypb.Empty{}, err } func (s *Service) cancelSessionReadLocked() { @@ -260,7 +259,7 @@ func (s *Service) WithSession(f func(context.Context, *Session) error) error { return f(s.sessionContext, s.session) } -func (s *Service) GetNetworkConfig(ctx context.Context, e *empty.Empty) (nc *rpc.NetworkConfig, err error) { +func (s *Service) GetNetworkConfig(ctx context.Context, e *emptypb.Empty) (nc *rpc.NetworkConfig, err error) { err = s.WithSession(func(ctx context.Context, session *Session) error { nc = session.getNetworkConfig() return nil @@ -268,12 +267,12 @@ func (s *Service) GetNetworkConfig(ctx context.Context, e *empty.Empty) (nc *rpc return } -func (s *Service) SetLogLevel(ctx context.Context, request *manager.LogLevelRequest) (*empty.Empty, error) { +func (s *Service) SetLogLevel(ctx context.Context, request *manager.LogLevelRequest) (*emptypb.Empty, error) { duration := time.Duration(0) if request.Duration != nil { duration = request.Duration.AsDuration() } - return &empty.Empty{}, logging.SetAndStoreTimedLevel(ctx, s.timedLogLevel, request.LogLevel, duration, ProcessName) + return &emptypb.Empty{}, logging.SetAndStoreTimedLevel(ctx, s.timedLogLevel, request.LogLevel, duration, ProcessName) } func (s *Service) configReload(c context.Context) error {