• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kubernetes-sigs / blob-csi-driver / 7412225870

04 Jan 2024 04:35PM UTC coverage: 77.871%. Remained the same
7412225870

Pull #1209

github

web-flow
chore(deps): bump golang.org/x/sync from 0.5.0 to 0.6.0

Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.5.0 to 0.6.0.
- [Commits](https://github.com/golang/sync/compare/v0.5.0...v0.6.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sync
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #1209: chore(deps): bump golang.org/x/sync from 0.5.0 to 0.6.0

2034 of 2612 relevant lines covered (77.87%)

7.29 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.12
/pkg/csi-common/utils.go
1
/*
2
Copyright 2017 The Kubernetes Authors.
3

4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
7

8
    http://www.apache.org/licenses/LICENSE-2.0
9

10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
15
*/
16

17
package csicommon
18

19
import (
20
        "fmt"
21
        "net"
22
        "os"
23
        "runtime"
24
        "strings"
25

26
        "github.com/container-storage-interface/spec/lib/go/csi"
27
        "github.com/kubernetes-csi/csi-lib-utils/protosanitizer"
28
        "golang.org/x/net/context"
29
        "google.golang.org/grpc"
30
        "k8s.io/klog/v2"
31
)
32

33
func ParseEndpoint(ep string) (string, string, error) {
15✔
34
        if strings.HasPrefix(strings.ToLower(ep), "unix://") || strings.HasPrefix(strings.ToLower(ep), "tcp://") {
25✔
35
                s := strings.SplitN(ep, "://", 2)
10✔
36
                if s[1] != "" {
19✔
37
                        return s[0], s[1], nil
9✔
38
                }
9✔
39
        }
40
        return "", "", fmt.Errorf("Invalid endpoint: %v", ep)
6✔
41
}
42

43
func Listen(ctx context.Context, endpoint string) (net.Listener, error) {
4✔
44
        proto, addr, err := ParseEndpoint(endpoint)
4✔
45
        if err != nil {
5✔
46
                klog.Errorf(err.Error())
1✔
47
                return nil, err
1✔
48
        }
1✔
49

50
        if proto == "unix" {
5✔
51
                if runtime.GOOS != "windows" {
4✔
52
                        addr = "/" + addr
2✔
53
                }
2✔
54
                if err := os.Remove(addr); err != nil && !os.IsNotExist(err) {
2✔
55
                        klog.Errorf("Failed to remove %s, error: %s", addr, err.Error())
×
56
                        return nil, err
×
57
                }
×
58
        }
59
        listenConfig := net.ListenConfig{}
3✔
60
        listener, err := listenConfig.Listen(ctx, proto, addr)
3✔
61
        if err != nil {
4✔
62
                klog.Errorf("Failed to listen: %v", err)
1✔
63
                return nil, err
1✔
64
        }
1✔
65
        return listener, nil
2✔
66
}
67

68
func NewVolumeCapabilityAccessMode(mode csi.VolumeCapability_AccessMode_Mode) *csi.VolumeCapability_AccessMode {
1✔
69
        return &csi.VolumeCapability_AccessMode{Mode: mode}
1✔
70
}
1✔
71

72
func NewControllerServiceCapability(cap csi.ControllerServiceCapability_RPC_Type) *csi.ControllerServiceCapability {
12✔
73
        return &csi.ControllerServiceCapability{
12✔
74
                Type: &csi.ControllerServiceCapability_Rpc{
12✔
75
                        Rpc: &csi.ControllerServiceCapability_RPC{
12✔
76
                                Type: cap,
12✔
77
                        },
12✔
78
                },
12✔
79
        }
12✔
80
}
12✔
81

82
func NewNodeServiceCapability(cap csi.NodeServiceCapability_RPC_Type) *csi.NodeServiceCapability {
8✔
83
        return &csi.NodeServiceCapability{
8✔
84
                Type: &csi.NodeServiceCapability_Rpc{
8✔
85
                        Rpc: &csi.NodeServiceCapability_RPC{
8✔
86
                                Type: cap,
8✔
87
                        },
8✔
88
                },
8✔
89
        }
8✔
90
}
8✔
91

92
func getLogLevel(method string) int32 {
7✔
93
        if method == "/csi.v1.Identity/Probe" ||
7✔
94
                method == "/csi.v1.Node/NodeGetCapabilities" ||
7✔
95
                method == "/csi.v1.Node/NodeGetVolumeStats" {
10✔
96
                return 6
3✔
97
        }
3✔
98
        return 2
4✔
99
}
100

101
func LogGRPC(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
2✔
102
        level := klog.Level(getLogLevel(info.FullMethod))
2✔
103
        klog.V(level).Infof("GRPC call: %s", info.FullMethod)
2✔
104
        klog.V(level).Infof("GRPC request: %s", protosanitizer.StripSecrets(req))
2✔
105

2✔
106
        resp, err := handler(ctx, req)
2✔
107
        if err != nil {
2✔
108
                klog.Errorf("GRPC error: %v", err)
×
109
        } else {
2✔
110
                klog.V(level).Infof("GRPC response: %s", protosanitizer.StripSecrets(resp))
2✔
111
        }
2✔
112
        return resp, err
2✔
113
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc