Skip to content

Commit

Permalink
Fix lint issues
Browse files Browse the repository at this point in the history
Signed-off-by: amaslennikov <amaslennikov@nvidia.com>
  • Loading branch information
almaslennikov committed Jan 29, 2024
1 parent f58645c commit 81c07f5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions pkg/resources/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type resourceServer struct {
const (
rsWatchInterval = 5 * time.Second
serverStartTimeout = 5 * time.Second
unix = "unix"
)

// NewResourceServer returns an instance of ResourceServer
Expand All @@ -77,7 +78,7 @@ func NewResourceServer(prefix, suffix string, pluginWatch, useCdi bool, rp types
}

func (rs *resourceServer) register() error {
kubeletEndpoint := "unix:" + filepath.Join(types.DeprecatedSockDir, types.KubeEndPoint)
kubeletEndpoint := unix + ":" + filepath.Join(types.DeprecatedSockDir, types.KubeEndPoint)
conn, err := grpc.Dial(kubeletEndpoint, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
glog.Errorf("%s device plugin unable connect to Kubelet : %v", rs.resourcePool.GetResourceName(), err)
Expand Down Expand Up @@ -252,7 +253,7 @@ func (rs *resourceServer) Start() error {
}

glog.Infof("starting %s device plugin endpoint at: %s\n", resourceName, rs.endPoint)
lis, err := net.Listen("unix", rs.sockPath)
lis, err := net.Listen(unix, rs.sockPath)
if err != nil {
glog.Errorf("error starting %s device plugin endpoint: %v", resourceName, err)
return err
Expand All @@ -273,7 +274,7 @@ func (rs *resourceServer) Start() error {
// Wait for server to start by launching a blocking connection
ctx, _ := context.WithTimeout(context.TODO(), serverStartTimeout)
conn, err := grpc.DialContext(
ctx, "unix:"+rs.sockPath, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock())
ctx, unix+":"+rs.sockPath, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock())

if err != nil {
glog.Errorf("error. unable to establish test connection with %s gRPC server: %v", resourceName, err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/resources/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (s *fakeRegistrationServer) Register(
}

func (s *fakeRegistrationServer) start() {
l, err := net.Listen("unix", path.Join(s.sockDir, types.KubeEndPoint))
l, err := net.Listen(unix, path.Join(s.sockDir, types.KubeEndPoint))
if err != nil {
panic(err)
}
Expand All @@ -145,7 +145,7 @@ func (s *fakeRegistrationServer) waitForServer(timeout time.Duration) error {
if time.Now().After(maxWaitTime) {
return fmt.Errorf("waiting for the fake registration server timed out")
}
c, err := net.DialTimeout("unix", path.Join(s.sockDir, types.KubeEndPoint), time.Second)
c, err := net.DialTimeout(unix, path.Join(s.sockDir, types.KubeEndPoint), time.Second)
if err == nil {
return c.Close()
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const (
classIDBitSize = 64
maxVendorName = 20
maxProductName = 40
ellipsis = "..."
)

// DetectPluginWatchMode returns true if plugins registry directory exist
Expand Down Expand Up @@ -504,7 +505,7 @@ func HasDefaultRoute(pciAddr string) (bool, error) {
func NormalizeVendorName(vendor string) string {
vendorName := vendor
if len(vendor) > maxVendorName {
vendorName = string([]byte(vendorName)[0:17]) + "..."
vendorName = string([]byte(vendorName)[0:17]) + ellipsis
}
return vendorName
}
Expand All @@ -513,7 +514,7 @@ func NormalizeVendorName(vendor string) string {
func NormalizeProductName(product string) string {
productName := product
if len(product) > maxProductName {
productName = string([]byte(productName)[0:37]) + "..."
productName = string([]byte(productName)[0:37]) + ellipsis
}
return productName
}
Expand Down

0 comments on commit 81c07f5

Please sign in to comment.