Skip to content

Commit

Permalink
fix linter issue
Browse files Browse the repository at this point in the history
Signed-off-by: Nikita Skrynnik <nikita.skrynnik@xored.com>
  • Loading branch information
NikitaSkrynnik committed Feb 22, 2022
1 parent 23c70b9 commit b1a40ef
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ linters-settings:
threshold: 150
funlen:
Lines: 110
Statements: 50
Statements: 60
goconst:
min-len: 2
min-occurrences: 2
Expand Down
9 changes: 4 additions & 5 deletions pkg/networkservice/chains/nsmgr/forwarder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"testing"
"time"

"github.com/networkservicemesh/api/pkg/api/registry"
registryapi "github.com/networkservicemesh/api/pkg/api/registry"
"github.com/networkservicemesh/sdk/pkg/tools/sandbox"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -50,12 +49,12 @@ func Test_RemoteForwarderShouldBeSelectedCorrectlyOnNSMgrRestart(t *testing.T) {

nsRegistryClient := domain.NewNSRegistryClient(ctx, sandbox.GenerateTestToken)

_, err := nsRegistryClient.Register(ctx, &registry.NetworkService{
_, err := nsRegistryClient.Register(ctx, &registryapi.NetworkService{
Name: "my-ns",
})
require.NoError(t, err)

nseReg := &registry.NetworkServiceEndpoint{
nseReg := &registryapi.NetworkServiceEndpoint{
Name: "my-nse-1",
NetworkServiceNames: []string{"my-ns"},
}
Expand Down Expand Up @@ -115,12 +114,12 @@ func Test_LocalForwarderShouldBeSelectedCorrectlyOnNSMgrRestart(t *testing.T) {

nsRegistryClient := domain.NewNSRegistryClient(ctx, sandbox.GenerateTestToken)

_, err := nsRegistryClient.Register(ctx, &registry.NetworkService{
_, err := nsRegistryClient.Register(ctx, &registryapi.NetworkService{
Name: "my-ns",
})
require.NoError(t, err)

nseReg := &registry.NetworkServiceEndpoint{
nseReg := &registryapi.NetworkServiceEndpoint{
Name: "my-nse-1",
NetworkServiceNames: []string{"my-ns"},
}
Expand Down
29 changes: 15 additions & 14 deletions pkg/networkservice/common/discoverforwarder/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,23 @@ func (d *discoverForwarderServer) Request(ctx context.Context, request *networks
}

for _, candidate := range nses {
if candidate.Name == datapathForwarder {
u, err := url.Parse(candidate.Url)

if err != nil {
logger.Errorf("can not parse forwarder=%v url=%v error=%v", nses[0].Name, u, err.Error())
return nil, errors.WithStack(err)
}

conn, err := next.Server(ctx).Request(clienturlctx.WithClientURL(ctx, u), request)
if err != nil {
continue
}
storeForwarderName(ctx, candidate.Name)
if candidate.Name != datapathForwarder {
continue
}

u, err := url.Parse(candidate.Url)

if err != nil {
logger.Errorf("can not parse forwarder=%v url=%v error=%v", candidate.Name, u, err.Error())
return nil, errors.WithStack(err)
}

return conn, err
resp, err := next.Server(ctx).Request(clienturlctx.WithClientURL(ctx, u), request)
if err == nil {
storeForwarderName(ctx, candidate.Name)
return resp, nil
}
return nil, err
}

if len(nses) == 0 {
Expand Down

0 comments on commit b1a40ef

Please sign in to comment.