Skip to content

Commit

Permalink
lint: Merge pull request kata-containers#491 from ganeshmaharaj/go-li…
Browse files Browse the repository at this point in the history
…nter-change

lint: Switch golang linter to golangci-lint
(cherry picked from commit 02cacde)

Fixes kata-containers#494

Signed-off-by: Ganesh Maharaj Mahalingam <ganesh.mahalingam@intel.com>
  • Loading branch information
Sebastien Boeuf authored and Ganesh Maharaj Mahalingam committed Apr 17, 2019
1 parent 200d8e4 commit ccc8b26
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ func (s *sandbox) deleteContainer(id string) {
}

func (s *sandbox) getProcess(cid, execID string) (*process, *container, error) {
if s.running == false {
if !s.running {
return nil, nil, grpcStatus.Error(codes.FailedPrecondition, "Sandbox not started")
}

Expand Down Expand Up @@ -967,7 +967,7 @@ func makeUnaryInterceptor() grpc.UnaryServerInterceptor {

if !tracing {
// Just log call details
elapsed = time.Now().Sub(start)
elapsed = time.Since(start)
message = resp.(proto.Message)

logger := agentLog.WithFields(logrus.Fields{
Expand Down
4 changes: 2 additions & 2 deletions channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (c *serialChannel) wait() error {
var events [1]unix.EpollEvent

fd := c.serialConn.Fd()
if fd <= 0 {
if fd == 0 {
return fmt.Errorf("serial port IO closed")
}

Expand Down Expand Up @@ -339,7 +339,7 @@ func findVirtualSerialPath(serialName string) (string, error) {
return "", err
}

if strings.Contains(string(content), serialName) == true {
if strings.Contains(string(content), serialName) {
return filepath.Join(devRootPath, port), nil
}
}
Expand Down
12 changes: 6 additions & 6 deletions grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func updateCpusetPath(cgroupPath string, newCpuset string, cookies cookie) error
cgroupParentPath = filepath.Join(cgroupParentPath, path)

// check if the cgroup was already updated.
if cookies[cgroupParentPath] == true {
if cookies[cgroupParentPath] {
agentLog.WithField("path", cgroupParentPath).Debug("cpuset cgroup already updated")
continue
}
Expand Down Expand Up @@ -374,7 +374,7 @@ func (a *agentGRPC) Version(ctx context.Context, req *pb.CheckRequest) (*pb.Vers
}

func (a *agentGRPC) getContainer(cid string) (*container, error) {
if a.sandbox.running == false {
if !a.sandbox.running {
return nil, grpcStatus.Error(codes.FailedPrecondition, "Sandbox not started")
}

Expand Down Expand Up @@ -794,7 +794,7 @@ func posixRlimitsToRlimits(posixRlimits []specs.POSIXRlimit) []configs.Rlimit {
}

func (a *agentGRPC) createContainerChecks(req *pb.CreateContainerRequest) (err error) {
if a.sandbox.running == false {
if !a.sandbox.running {
return grpcStatus.Error(codes.FailedPrecondition, "Sandbox not started, impossible to run a new container")
}

Expand Down Expand Up @@ -888,7 +888,7 @@ func (a *agentGRPC) ExecProcess(ctx context.Context, req *pb.ExecProcessRequest)
}

func (a *agentGRPC) SignalProcess(ctx context.Context, req *pb.SignalProcessRequest) (*gpb.Empty, error) {
if a.sandbox.running == false {
if !a.sandbox.running {
return emptyResp, grpcStatus.Error(codes.FailedPrecondition, "Sandbox not started, impossible to signal the container")
}

Expand Down Expand Up @@ -1387,7 +1387,7 @@ func (a *agentGRPC) TtyWinResize(ctx context.Context, req *pb.TtyWinResizeReques
}

func (a *agentGRPC) CreateSandbox(ctx context.Context, req *pb.CreateSandboxRequest) (*gpb.Empty, error) {
if a.sandbox.running == true {
if a.sandbox.running {
return emptyResp, grpcStatus.Error(codes.AlreadyExists, "Sandbox already started, impossible to start again")
}

Expand Down Expand Up @@ -1436,7 +1436,7 @@ func (a *agentGRPC) CreateSandbox(ctx context.Context, req *pb.CreateSandboxRequ
}

func (a *agentGRPC) DestroySandbox(ctx context.Context, req *pb.DestroySandboxRequest) (*gpb.Empty, error) {
if a.sandbox.running == false {
if !a.sandbox.running {
agentLog.Info("Sandbox not started, this is a no-op")
return emptyResp, nil
}
Expand Down
8 changes: 4 additions & 4 deletions grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -742,11 +742,11 @@ func testAgentDetails(assert *assert.Assertions, details *pb.AgentDetails, haveS
storages = append(storages, handler)
}

sort.Sort(sort.StringSlice(details.DeviceHandlers))
sort.Sort(sort.StringSlice(details.StorageHandlers))
sort.Strings(details.DeviceHandlers)
sort.Strings(details.StorageHandlers)

sort.Sort(sort.StringSlice(devices))
sort.Sort(sort.StringSlice(storages))
sort.Strings(devices)
sort.Strings(storages)

assert.Equal(details.DeviceHandlers, devices)
assert.Equal(details.StorageHandlers, storages)
Expand Down
4 changes: 2 additions & 2 deletions protocols/grpc/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ func assertIsEqual(t *testing.T, ociSpec *specs.Spec, grpcSpec *Spec) {
assert.Equal(len(grpcSpec.Linux.Namespaces), 5)

for i := range grpcSpec.Linux.Namespaces {
assert.Equal(grpcSpec.Linux.Namespaces[i].Type, (string)(ociSpec.Linux.Namespaces[i].Type))
assert.Equal(grpcSpec.Linux.Namespaces[i].Path, (string)(ociSpec.Linux.Namespaces[i].Path))
assert.Equal(grpcSpec.Linux.Namespaces[i].Type, (string)(ociSpec.Linux.Namespaces[i].Type)) //nolint:unconvert
assert.Equal(grpcSpec.Linux.Namespaces[i].Path, (string)(ociSpec.Linux.Namespaces[i].Path)) //nolint:unconvert
}
}

Expand Down

0 comments on commit ccc8b26

Please sign in to comment.