Skip to content

Commit

Permalink
🌱 Add staticcheck ci action (koordinator-sh#72)
Browse files Browse the repository at this point in the history
* add staticcheck

Signed-off-by: Jason Liu <[email protected]>

* replace deprecated func grpc.WithTimeout & grpc.WithDialer

Signed-off-by: Jason Liu <[email protected]>
  • Loading branch information
jasonliu747 authored Apr 14, 2022
1 parent 83977dc commit 067458b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ jobs:
skip-pkg-cache: true
skip-build-cache: true

staticcheck:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: dominikh/[email protected]

unit-tests:
runs-on: ubuntu-18.04
steps:
Expand Down
17 changes: 9 additions & 8 deletions pkg/runtime/handler/containerd_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,18 @@ func getClientConnection(endpoint string) (*grpc.ClientConn, error) {
return nil, err
}

conn, err := grpc.Dial(addr,
grpc.WithInsecure(),
grpc.WithBlock(),
grpc.WithTimeout(defaultConnectionTimeout),
grpc.WithDialer(dialer))
ctx, cancel := context.WithTimeout(context.Background(), defaultConnectionTimeout)
defer cancel()

conn, err := grpc.DialContext(ctx, addr, grpc.WithInsecure(), grpc.WithBlock(), grpc.WithContextDialer(dialer))
if err != nil {
return nil, fmt.Errorf("failed to connect, make sure you are running as root and the runtime has been started: %v", err)
}

return conn, nil
}

func getAddressAndDialer(endpoint string) (string, func(addr string, timeout time.Duration) (net.Conn, error), error) {
func getAddressAndDialer(endpoint string) (string, func(context context.Context, addr string) (net.Conn, error), error) {
protocol, addr, err := parseEndpoint(endpoint)
if err != nil {
return "", nil, err
Expand All @@ -142,6 +142,7 @@ func parseEndpoint(endpoint string) (string, string, error) {
}
}

func dial(addr string, timeout time.Duration) (net.Conn, error) {
return net.DialTimeout(unixProtocol, addr, timeout)
func dial(context context.Context, addr string) (net.Conn, error) {
var d net.Dialer
return d.DialContext(context, unixProtocol, addr)
}

0 comments on commit 067458b

Please sign in to comment.