Skip to content

Commit a3c0e88

Browse files
committed
Align lint checks with containerd
Signed-off-by: Derek McGowan <[email protected]>
1 parent 83e6efc commit a3c0e88

11 files changed

Lines changed: 107 additions & 111 deletions

.golangci.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ linters:
1515
- errcheck
1616

1717
run:
18-
deadline: 2m
18+
timeout: 3m
1919
skip-dirs:
20-
- integration
21-
- pkg/api
22-
skip-files:
23-
- ".*_test.go"
20+
- docs

integration/containerd_image_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
package integration
1818

1919
import (
20-
"golang.org/x/net/context"
2120
"testing"
2221
"time"
2322

23+
"golang.org/x/net/context"
24+
2425
"github.com/containerd/containerd"
2526
"github.com/containerd/containerd/errdefs"
2627
"github.com/containerd/containerd/namespaces"

integration/main_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import (
3434
"github.com/stretchr/testify/assert"
3535
"github.com/stretchr/testify/require"
3636
"google.golang.org/grpc"
37-
"k8s.io/cri-api/pkg/apis"
37+
cri "k8s.io/cri-api/pkg/apis"
3838
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
3939

4040
"github.com/containerd/cri/integration/remote"
@@ -74,11 +74,11 @@ func TestMain(m *testing.M) {
7474
// ConnectDaemons connect cri plugin and containerd, and initialize the clients.
7575
func ConnectDaemons() error {
7676
var err error
77-
runtimeService, err = remote.NewRemoteRuntimeService(*criEndpoint, timeout)
77+
runtimeService, err = remote.NewRuntimeService(*criEndpoint, timeout)
7878
if err != nil {
7979
return errors.Wrap(err, "failed to create runtime service")
8080
}
81-
imageService, err = remote.NewRemoteImageService(*criEndpoint, timeout)
81+
imageService, err = remote.NewImageService(*criEndpoint, timeout)
8282
if err != nil {
8383
return errors.Wrap(err, "failed to create image service")
8484
}

integration/pod_hostname_test.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,14 @@ func TestPodHostname(t *testing.T) {
7070
t.Fatalf("Unexpected RunPodSandbox error: %v", err)
7171
}
7272
return
73-
} else {
74-
// Make sure the sandbox is cleaned up.
75-
defer func() {
76-
assert.NoError(t, runtimeService.StopPodSandbox(sb))
77-
assert.NoError(t, runtimeService.RemovePodSandbox(sb))
78-
}()
79-
if test.expectErr {
80-
t.Fatalf("Expected RunPodSandbox to return error")
81-
}
73+
}
74+
// Make sure the sandbox is cleaned up.
75+
defer func() {
76+
assert.NoError(t, runtimeService.StopPodSandbox(sb))
77+
assert.NoError(t, runtimeService.RemovePodSandbox(sb))
78+
}()
79+
if test.expectErr {
80+
t.Fatalf("Expected RunPodSandbox to return error")
8281
}
8382

8483
const (

integration/remote/remote_image.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ import (
4747
"github.com/containerd/cri/integration/remote/util"
4848
)
4949

50-
// RemoteImageService is a gRPC implementation of internalapi.ImageManagerService.
51-
type RemoteImageService struct {
50+
// ImageService is a gRPC implementation of internalapi.ImageManagerService.
51+
type ImageService struct {
5252
timeout time.Duration
5353
imageClient runtimeapi.ImageServiceClient
5454
}
5555

56-
// NewRemoteImageService creates a new internalapi.ImageManagerService.
57-
func NewRemoteImageService(endpoint string, connectionTimeout time.Duration) (internalapi.ImageManagerService, error) {
56+
// NewImageService creates a new internalapi.ImageManagerService.
57+
func NewImageService(endpoint string, connectionTimeout time.Duration) (internalapi.ImageManagerService, error) {
5858
klog.V(3).Infof("Connecting to image service %s", endpoint)
5959
addr, dialer, err := util.GetAddressAndDialer(endpoint)
6060
if err != nil {
@@ -70,14 +70,14 @@ func NewRemoteImageService(endpoint string, connectionTimeout time.Duration) (in
7070
return nil, err
7171
}
7272

73-
return &RemoteImageService{
73+
return &ImageService{
7474
timeout: connectionTimeout,
7575
imageClient: runtimeapi.NewImageServiceClient(conn),
7676
}, nil
7777
}
7878

7979
// ListImages lists available images.
80-
func (r *RemoteImageService) ListImages(filter *runtimeapi.ImageFilter) ([]*runtimeapi.Image, error) {
80+
func (r *ImageService) ListImages(filter *runtimeapi.ImageFilter) ([]*runtimeapi.Image, error) {
8181
ctx, cancel := getContextWithTimeout(r.timeout)
8282
defer cancel()
8383

@@ -93,7 +93,7 @@ func (r *RemoteImageService) ListImages(filter *runtimeapi.ImageFilter) ([]*runt
9393
}
9494

9595
// ImageStatus returns the status of the image.
96-
func (r *RemoteImageService) ImageStatus(image *runtimeapi.ImageSpec) (*runtimeapi.Image, error) {
96+
func (r *ImageService) ImageStatus(image *runtimeapi.ImageSpec) (*runtimeapi.Image, error) {
9797
ctx, cancel := getContextWithTimeout(r.timeout)
9898
defer cancel()
9999

@@ -117,7 +117,7 @@ func (r *RemoteImageService) ImageStatus(image *runtimeapi.ImageSpec) (*runtimea
117117
}
118118

119119
// PullImage pulls an image with authentication config.
120-
func (r *RemoteImageService) PullImage(image *runtimeapi.ImageSpec, auth *runtimeapi.AuthConfig, podSandboxConfig *runtimeapi.PodSandboxConfig) (string, error) {
120+
func (r *ImageService) PullImage(image *runtimeapi.ImageSpec, auth *runtimeapi.AuthConfig, podSandboxConfig *runtimeapi.PodSandboxConfig) (string, error) {
121121
ctx, cancel := getContextWithCancel()
122122
defer cancel()
123123

@@ -141,7 +141,7 @@ func (r *RemoteImageService) PullImage(image *runtimeapi.ImageSpec, auth *runtim
141141
}
142142

143143
// RemoveImage removes the image.
144-
func (r *RemoteImageService) RemoveImage(image *runtimeapi.ImageSpec) error {
144+
func (r *ImageService) RemoveImage(image *runtimeapi.ImageSpec) error {
145145
ctx, cancel := getContextWithTimeout(r.timeout)
146146
defer cancel()
147147

@@ -157,7 +157,7 @@ func (r *RemoteImageService) RemoveImage(image *runtimeapi.ImageSpec) error {
157157
}
158158

159159
// ImageFsInfo returns information of the filesystem that is used to store images.
160-
func (r *RemoteImageService) ImageFsInfo() ([]*runtimeapi.FilesystemUsage, error) {
160+
func (r *ImageService) ImageFsInfo() ([]*runtimeapi.FilesystemUsage, error) {
161161
// Do not set timeout, because `ImageFsInfo` takes time.
162162
// TODO(random-liu): Should we assume runtime should cache the result, and set timeout here?
163163
ctx, cancel := getContextWithCancel()

0 commit comments

Comments
 (0)