Skip to content

Commit

Permalink
Merge pull request #3332 from testwill/pkg-import
Browse files Browse the repository at this point in the history
chore: pkg imported more than once
  • Loading branch information
thallgren authored Sep 19, 2023
2 parents f147911 + 1ab1b18 commit cec477d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 deletions.
5 changes: 2 additions & 3 deletions cmd/traffic/cmd/manager/state/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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),
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 1 addition & 2 deletions pkg/authenticator/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions pkg/client/cli/connect/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/datawire/dlib/dlog"
"github.com/telepresenceio/telepresence/rpc/v2/connector"
Expand Down Expand Up @@ -265,7 +264,7 @@ func connectSession(ctx context.Context, useLine string, userD *daemon.UserClien

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
}
if ci.Error != connector.ConnectInfo_DISCONNECTED {
Expand Down
29 changes: 14 additions & 15 deletions pkg/client/rootd/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -123,15 +122,15 @@ 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(),
Name: client.DisplayName,
}, 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{
Expand All @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -260,20 +259,20 @@ 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
})
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 {
Expand Down

0 comments on commit cec477d

Please sign in to comment.