From ff08808a1b43c21a3625d23f3af7c79615e6558f Mon Sep 17 00:00:00 2001 From: Ivan Osipov Date: Thu, 31 Aug 2023 23:13:37 +0400 Subject: [PATCH 1/7] Add unit-test for registration from env Signed-off-by: Ivan Osipov --- main.go | 74 ++++++++++++++++++++++++++++------------------------ main_test.go | 52 ++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 34 deletions(-) create mode 100644 main_test.go diff --git a/main.go b/main.go index 121f53f..aa5db95 100644 --- a/main.go +++ b/main.go @@ -33,11 +33,11 @@ import ( "time" "github.com/google/uuid" + "github.com/kelseyhightower/envconfig" + "github.com/pkg/errors" nested "github.com/antonfisher/nested-logrus-formatter" "github.com/edwarnicke/grpcfd" - "github.com/kelseyhightower/envconfig" - "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/spiffe/go-spiffe/v2/spiffetls/tlsconfig" "github.com/spiffe/go-spiffe/v2/workloadapi" @@ -65,7 +65,6 @@ import ( registryauthorize "github.com/networkservicemesh/sdk/pkg/registry/common/authorize" "github.com/networkservicemesh/sdk/pkg/registry/common/clientinfo" "github.com/networkservicemesh/sdk/pkg/registry/common/dnsresolve" - registrysendfd "github.com/networkservicemesh/sdk/pkg/registry/common/sendfd" "github.com/networkservicemesh/sdk/pkg/tools/debug" "github.com/networkservicemesh/sdk/pkg/tools/grpcutils" "github.com/networkservicemesh/sdk/pkg/tools/interdomain" @@ -107,8 +106,8 @@ type Config struct { TunnelIP net.IP `desc:"IP to use for tunnels" split_words:"true"` Vl3Prefix string `default:"169.254.0.0/16" desc:"vl3 prefix"` InterfaceName string `default:"nsm" desc:"Name of the nsm network interface"` - FederatesWith string `default:"k8s.nsm" desc:"Name of the federated domain"` - TrustDomain string `default:"docker.nsm" desc:"Name of the trust domain"` + FederatesWith string `default:"k8s.nsm" desc:"Name of the federated domain" split_words:"true"` + TrustDomain string `default:"docker.nsm" desc:"Name of the trust domain" split_words:"true"` LogLevel string `default:"INFO" desc:"Log level" split_words:"true"` } @@ -309,18 +308,7 @@ func main() { // ******************************************************************************** log.FromContext(ctx).Infof("executing phase 7: register nse with nsm") // ******************************************************************************** - nseRegistryClient := registryclient.NewNetworkServiceEndpointRegistryClient( - ctx, - registryclient.WithNSEClientURLResolver(dnsresolve.NewNetworkServiceEndpointRegistryClient()), - registryclient.WithDialOptions(clientOptions...), - registryclient.WithNSEAdditionalFunctionality( - clientinfo.NewNetworkServiceEndpointRegistryClient(), - registrysendfd.NewNetworkServiceEndpointRegistryClient(), - ), - registryclient.WithAuthorizeNSERegistryClient(registryauthorize.NewNetworkServiceEndpointRegistryClient( - registryauthorize.WithPolicies(config.RegistryClientPolicies...), - )), - ) + if config.RegisterService { for _, serviceName := range config.ServiceNames { nsRegistryClient := registryclient.NewNetworkServiceRegistryClient(ctx, @@ -340,23 +328,7 @@ func main() { } } - var RegisterAsURL *url.URL - if config.RegisterAsURL.Scheme == "" { - RegisterAsURL = listenOn - } else { - RegisterAsURL = &config.RegisterAsURL - } - - nseRegistration := ®istryapi.NetworkServiceEndpoint{ - Name: config.Name, - NetworkServiceNames: config.ServiceNames, - NetworkServiceLabels: make(map[string]*registryapi.NetworkServiceLabels), - Url: RegisterAsURL.String(), - } - for _, serviceName := range config.ServiceNames { - nseRegistration.NetworkServiceLabels[serviceName] = ®istryapi.NetworkServiceLabels{Labels: config.Labels} - } - nseRegistration, err = nseRegistryClient.Register(ctx, nseRegistration) + nseRegistration, err := RegisterNetworkServiceEndpoint(ctx, config, net.DefaultResolver, listenOn, clientOptions) log.FromContext(ctx).Infof("registered nse: %+v", nseRegistration) if err != nil { @@ -445,3 +417,37 @@ func exitOnErr(ctx context.Context, cancel context.CancelFunc, errCh <-chan erro cancel() }(ctx, errCh) } + +func RegisterNetworkServiceEndpoint(ctx context.Context, config *Config, resolver dnsresolve.Resolver, listenOn *url.URL, clientOptions []grpc.DialOption) (*registryapi.NetworkServiceEndpoint, error) { + nseRegistryClient := registryclient.NewNetworkServiceEndpointRegistryClient( + ctx, + registryclient.WithNSEClientURLResolver(dnsresolve.NewNetworkServiceEndpointRegistryClient(dnsresolve.WithResolver(resolver))), + registryclient.WithDialOptions(clientOptions...), + registryclient.WithNSEAdditionalFunctionality( + clientinfo.NewNetworkServiceEndpointRegistryClient(), + ), + registryclient.WithAuthorizeNSERegistryClient(registryauthorize.NewNetworkServiceEndpointRegistryClient( + registryauthorize.WithPolicies(config.RegistryClientPolicies...), + )), + ) + + var registerAsURL *url.URL + if config.RegisterAsURL.Scheme == "" { + registerAsURL = listenOn + } else { + registerAsURL = &config.RegisterAsURL + } + + nseRegistration := ®istryapi.NetworkServiceEndpoint{ + Name: config.Name, + NetworkServiceNames: config.ServiceNames, + NetworkServiceLabels: make(map[string]*registryapi.NetworkServiceLabels), + Url: registerAsURL.String(), + } + for _, serviceName := range config.ServiceNames { + nseRegistration.NetworkServiceLabels[serviceName] = ®istryapi.NetworkServiceLabels{Labels: config.Labels} + } + nseRegistration, err := nseRegistryClient.Register(ctx, nseRegistration) + + return nseRegistration, err +} diff --git a/main_test.go b/main_test.go new file mode 100644 index 0000000..d96b3a2 --- /dev/null +++ b/main_test.go @@ -0,0 +1,52 @@ +// Copyright (c) 2022-2023 Cisco and/or its affiliates. +// +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build linux +// +build linux + +package main_test + +import ( + "context" + "net/url" + "os" + "testing" + + main "github.com/networkservicemesh/cmd-nse-simple-vl3-docker" + "github.com/networkservicemesh/sdk/pkg/tools/sandbox" + "github.com/stretchr/testify/require" +) + +func TestEndpointRegister(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + const RegisterAsURL = "tcp://10.10.10.10:10101" + + dnsServer := sandbox.NewFakeResolver() + domain := sandbox.NewBuilder(ctx, t).SetDNSResolver(dnsServer).Build() + require.NoError(t, sandbox.AddSRVEntry(dnsServer, "nsm-system.", "registry", domain.Registry.URL)) + listenOn := &(url.URL{Scheme: "tcp", Host: "127.0.0.1:"}) + os.Setenv("NSM_REGISTER_AS_URL", RegisterAsURL) + os.Setenv("NSM_REGISTRY_CLIENT_POLICIES", "") + config := new(main.Config) + err := config.Process() + require.Nil(t, err) + + nseRegistration, err := main.RegisterNetworkServiceEndpoint(ctx, config, dnsServer, listenOn, sandbox.DialOptions()) + require.Nil(t, err) + require.NotNil(t, nseRegistration) + require.Equal(t, nseRegistration.Url, RegisterAsURL) +} From b06ca190521c53c7adb8d44bb8fa5f7cc08703ad Mon Sep 17 00:00:00 2001 From: Ivan Osipov Date: Thu, 31 Aug 2023 23:17:46 +0400 Subject: [PATCH 2/7] Update go.mod, go.sum, imports_linux.go Signed-off-by: Ivan Osipov --- go.mod | 5 +++++ go.sum | 4 ++++ internal/imports/imports_linux.go | 4 +++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index e59b752..117b47b 100644 --- a/go.mod +++ b/go.mod @@ -17,6 +17,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.9.0 github.com/spiffe/go-spiffe/v2 v2.0.0 + github.com/stretchr/testify v1.8.3 github.com/vishvananda/netlink v1.2.1-beta.2.0.20220630165224-c591ada0fb2b google.golang.org/grpc v1.55.0 ) @@ -25,6 +26,7 @@ require ( github.com/OneOfOne/xxhash v1.2.8 // indirect github.com/agnivade/levenshtein v1.1.1 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/edwarnicke/exechelper v1.0.2 // indirect github.com/edwarnicke/genericsync v0.0.0-20220910010113-61a344f9bc29 // indirect github.com/edwarnicke/log v1.0.0 // indirect @@ -36,10 +38,12 @@ require ( github.com/gobwas/glob v0.2.3 // indirect github.com/golang-jwt/jwt/v4 v4.2.0 // indirect github.com/golang/protobuf v1.5.3 // indirect + github.com/google/go-cmp v0.5.9 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 // indirect github.com/lunixbochs/struc v0.0.0-20200521075829-a4cb8d33dbbe // indirect github.com/open-policy-agent/opa v0.44.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/tchap/go-patricia/v2 v2.3.1 // indirect github.com/thanhpk/randstr v1.0.4 // indirect @@ -71,4 +75,5 @@ require ( gopkg.in/fsnotify.v1 v1.4.7 // indirect gopkg.in/square/go-jose.v2 v2.5.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 8325e2e..ecea896 100644 --- a/go.sum +++ b/go.sum @@ -165,6 +165,7 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -240,6 +241,7 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1: github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE= github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= +github.com/r3labs/diff v1.1.0 h1:V53xhrbTHrWFWq3gI4b94AjgEJOerO1+1l0xyHOBi8M= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= @@ -259,6 +261,7 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= +github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tchap/go-patricia/v2 v2.3.1 h1:6rQp39lgIYZ+MHmdEq4xzuk1t7OdC35z/xm0BGhTkes= github.com/tchap/go-patricia/v2 v2.3.1/go.mod h1:VZRHKAb53DLaG+nA9EaYYiaEx6YztwDlLElMsnSHD4k= github.com/thanhpk/randstr v1.0.4 h1:IN78qu/bR+My+gHCvMEXhR/i5oriVHcTB/BJJIRTsNo= @@ -612,6 +615,7 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/internal/imports/imports_linux.go b/internal/imports/imports_linux.go index 276807b..d63b186 100644 --- a/internal/imports/imports_linux.go +++ b/internal/imports/imports_linux.go @@ -51,12 +51,12 @@ import ( _ "github.com/networkservicemesh/sdk/pkg/registry/common/authorize" _ "github.com/networkservicemesh/sdk/pkg/registry/common/clientinfo" _ "github.com/networkservicemesh/sdk/pkg/registry/common/dnsresolve" - _ "github.com/networkservicemesh/sdk/pkg/registry/common/sendfd" _ "github.com/networkservicemesh/sdk/pkg/tools/debug" _ "github.com/networkservicemesh/sdk/pkg/tools/grpcutils" _ "github.com/networkservicemesh/sdk/pkg/tools/interdomain" _ "github.com/networkservicemesh/sdk/pkg/tools/log" _ "github.com/networkservicemesh/sdk/pkg/tools/log/logruslogger" + _ "github.com/networkservicemesh/sdk/pkg/tools/sandbox" _ "github.com/networkservicemesh/sdk/pkg/tools/spiffejwt" _ "github.com/networkservicemesh/sdk/pkg/tools/spire" _ "github.com/networkservicemesh/sdk/pkg/tools/token" @@ -66,6 +66,7 @@ import ( _ "github.com/sirupsen/logrus" _ "github.com/spiffe/go-spiffe/v2/spiffetls/tlsconfig" _ "github.com/spiffe/go-spiffe/v2/workloadapi" + _ "github.com/stretchr/testify/require" _ "github.com/vishvananda/netlink" _ "google.golang.org/grpc" _ "google.golang.org/grpc/credentials" @@ -75,5 +76,6 @@ import ( _ "os/signal" _ "path/filepath" _ "syscall" + _ "testing" _ "time" ) From e65a178719a515b0410f53c6702603e1345ece8b Mon Sep 17 00:00:00 2001 From: Ivan Osipov Date: Fri, 1 Sep 2023 01:47:01 +0400 Subject: [PATCH 3/7] Fix linting errors Signed-off-by: Ivan Osipov --- main_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main_test.go b/main_test.go index d96b3a2..3ea8975 100644 --- a/main_test.go +++ b/main_test.go @@ -39,8 +39,8 @@ func TestEndpointRegister(t *testing.T) { domain := sandbox.NewBuilder(ctx, t).SetDNSResolver(dnsServer).Build() require.NoError(t, sandbox.AddSRVEntry(dnsServer, "nsm-system.", "registry", domain.Registry.URL)) listenOn := &(url.URL{Scheme: "tcp", Host: "127.0.0.1:"}) - os.Setenv("NSM_REGISTER_AS_URL", RegisterAsURL) - os.Setenv("NSM_REGISTRY_CLIENT_POLICIES", "") + require.Nil(t, os.Setenv("NSM_REGISTER_AS_URL", RegisterAsURL)) + require.Nil(t, os.Setenv("NSM_REGISTRY_CLIENT_POLICIES", "")) config := new(main.Config) err := config.Process() require.Nil(t, err) From 058e4a2ee9c004aa2365a57f4c28aa250f64feb0 Mon Sep 17 00:00:00 2001 From: Ivan Osipov Date: Fri, 1 Sep 2023 01:54:11 +0400 Subject: [PATCH 4/7] Fix linter error Signed-off-by: Ivan Osipov --- internal/imports/imports_linux.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/internal/imports/imports_linux.go b/internal/imports/imports_linux.go index d63b186..08ab882 100644 --- a/internal/imports/imports_linux.go +++ b/internal/imports/imports_linux.go @@ -5,6 +5,15 @@ import ( _ "context" _ "crypto/tls" _ "fmt" + _ "net" + _ "net/url" + _ "os" + _ "os/signal" + _ "path/filepath" + _ "syscall" + _ "testing" + _ "time" + _ "git.fd.io/govpp.git/api" _ "github.com/antonfisher/nested-logrus-formatter" _ "github.com/edwarnicke/grpcfd" @@ -70,12 +79,4 @@ import ( _ "github.com/vishvananda/netlink" _ "google.golang.org/grpc" _ "google.golang.org/grpc/credentials" - _ "net" - _ "net/url" - _ "os" - _ "os/signal" - _ "path/filepath" - _ "syscall" - _ "testing" - _ "time" ) From 3c7ef4ee18ce4bed35cff75fec7817a65330241d Mon Sep 17 00:00:00 2001 From: Ivan Osipov Date: Fri, 1 Sep 2023 01:58:08 +0400 Subject: [PATCH 5/7] Revert "Fix linter error" This reverts commit fc569de2b05ee89be030a93fdf74af7f21ae6245. Signed-off-by: Ivan Osipov --- internal/imports/imports_linux.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/internal/imports/imports_linux.go b/internal/imports/imports_linux.go index 08ab882..d63b186 100644 --- a/internal/imports/imports_linux.go +++ b/internal/imports/imports_linux.go @@ -5,15 +5,6 @@ import ( _ "context" _ "crypto/tls" _ "fmt" - _ "net" - _ "net/url" - _ "os" - _ "os/signal" - _ "path/filepath" - _ "syscall" - _ "testing" - _ "time" - _ "git.fd.io/govpp.git/api" _ "github.com/antonfisher/nested-logrus-formatter" _ "github.com/edwarnicke/grpcfd" @@ -79,4 +70,12 @@ import ( _ "github.com/vishvananda/netlink" _ "google.golang.org/grpc" _ "google.golang.org/grpc/credentials" + _ "net" + _ "net/url" + _ "os" + _ "os/signal" + _ "path/filepath" + _ "syscall" + _ "testing" + _ "time" ) From 6fceedc89ebb6c38781618c5216f74766bd72bdd Mon Sep 17 00:00:00 2001 From: Ivan Osipov Date: Fri, 1 Sep 2023 02:48:01 +0400 Subject: [PATCH 6/7] Fix linting errors Signed-off-by: Ivan Osipov --- internal/imports/imports_linux.go | 34 ++++++++++++++++--------------- main_test.go | 3 ++- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/internal/imports/imports_linux.go b/internal/imports/imports_linux.go index d63b186..68fea77 100644 --- a/internal/imports/imports_linux.go +++ b/internal/imports/imports_linux.go @@ -5,11 +5,29 @@ import ( _ "context" _ "crypto/tls" _ "fmt" + _ "net" + _ "net/url" + _ "os" + _ "os/signal" + _ "path/filepath" + _ "syscall" + _ "testing" + _ "time" + _ "git.fd.io/govpp.git/api" _ "github.com/antonfisher/nested-logrus-formatter" _ "github.com/edwarnicke/grpcfd" _ "github.com/google/uuid" _ "github.com/kelseyhightower/envconfig" + _ "github.com/pkg/errors" + _ "github.com/sirupsen/logrus" + _ "github.com/spiffe/go-spiffe/v2/spiffetls/tlsconfig" + _ "github.com/spiffe/go-spiffe/v2/workloadapi" + _ "github.com/stretchr/testify/require" + _ "github.com/vishvananda/netlink" + _ "google.golang.org/grpc" + _ "google.golang.org/grpc/credentials" + _ "github.com/networkservicemesh/api/pkg/api/ipam" _ "github.com/networkservicemesh/api/pkg/api/networkservice" _ "github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/cls" @@ -62,20 +80,4 @@ import ( _ "github.com/networkservicemesh/sdk/pkg/tools/token" _ "github.com/networkservicemesh/sdk/pkg/tools/tracing" _ "github.com/networkservicemesh/vpphelper" - _ "github.com/pkg/errors" - _ "github.com/sirupsen/logrus" - _ "github.com/spiffe/go-spiffe/v2/spiffetls/tlsconfig" - _ "github.com/spiffe/go-spiffe/v2/workloadapi" - _ "github.com/stretchr/testify/require" - _ "github.com/vishvananda/netlink" - _ "google.golang.org/grpc" - _ "google.golang.org/grpc/credentials" - _ "net" - _ "net/url" - _ "os" - _ "os/signal" - _ "path/filepath" - _ "syscall" - _ "testing" - _ "time" ) diff --git a/main_test.go b/main_test.go index 3ea8975..276fab8 100644 --- a/main_test.go +++ b/main_test.go @@ -25,9 +25,10 @@ import ( "os" "testing" + "github.com/stretchr/testify/require" + main "github.com/networkservicemesh/cmd-nse-simple-vl3-docker" "github.com/networkservicemesh/sdk/pkg/tools/sandbox" - "github.com/stretchr/testify/require" ) func TestEndpointRegister(t *testing.T) { From 05b7125586c1313642a8e76cc6090e975c076c75 Mon Sep 17 00:00:00 2001 From: Ivan Osipov Date: Fri, 1 Sep 2023 02:55:13 +0400 Subject: [PATCH 7/7] Fix linting errors Signed-off-by: Ivan Osipov --- internal/imports/imports_linux.go | 34 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/internal/imports/imports_linux.go b/internal/imports/imports_linux.go index 68fea77..d63b186 100644 --- a/internal/imports/imports_linux.go +++ b/internal/imports/imports_linux.go @@ -5,29 +5,11 @@ import ( _ "context" _ "crypto/tls" _ "fmt" - _ "net" - _ "net/url" - _ "os" - _ "os/signal" - _ "path/filepath" - _ "syscall" - _ "testing" - _ "time" - _ "git.fd.io/govpp.git/api" _ "github.com/antonfisher/nested-logrus-formatter" _ "github.com/edwarnicke/grpcfd" _ "github.com/google/uuid" _ "github.com/kelseyhightower/envconfig" - _ "github.com/pkg/errors" - _ "github.com/sirupsen/logrus" - _ "github.com/spiffe/go-spiffe/v2/spiffetls/tlsconfig" - _ "github.com/spiffe/go-spiffe/v2/workloadapi" - _ "github.com/stretchr/testify/require" - _ "github.com/vishvananda/netlink" - _ "google.golang.org/grpc" - _ "google.golang.org/grpc/credentials" - _ "github.com/networkservicemesh/api/pkg/api/ipam" _ "github.com/networkservicemesh/api/pkg/api/networkservice" _ "github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/cls" @@ -80,4 +62,20 @@ import ( _ "github.com/networkservicemesh/sdk/pkg/tools/token" _ "github.com/networkservicemesh/sdk/pkg/tools/tracing" _ "github.com/networkservicemesh/vpphelper" + _ "github.com/pkg/errors" + _ "github.com/sirupsen/logrus" + _ "github.com/spiffe/go-spiffe/v2/spiffetls/tlsconfig" + _ "github.com/spiffe/go-spiffe/v2/workloadapi" + _ "github.com/stretchr/testify/require" + _ "github.com/vishvananda/netlink" + _ "google.golang.org/grpc" + _ "google.golang.org/grpc/credentials" + _ "net" + _ "net/url" + _ "os" + _ "os/signal" + _ "path/filepath" + _ "syscall" + _ "testing" + _ "time" )