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

kubernetes-sigs / blob-csi-driver / 4961304539

12 May 2023 05:20PM UTC coverage: 80.672%. First build
4961304539

push

github

GitHub
chore(deps): bump golang.org/x/net from 0.9.0 to 0.10.0

1824 of 2261 relevant lines covered (80.67%)

5.29 hits per line

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

97.87
/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
        "strings"
22

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

30
func ParseEndpoint(ep string) (string, string, error) {
13✔
31
        if strings.HasPrefix(strings.ToLower(ep), "unix://") || strings.HasPrefix(strings.ToLower(ep), "tcp://") {
22✔
32
                s := strings.SplitN(ep, "://", 2)
9✔
33
                if s[1] != "" {
17✔
34
                        return s[0], s[1], nil
8✔
35
                }
8✔
36
        }
37
        return "", "", fmt.Errorf("Invalid endpoint: %v", ep)
5✔
38
}
39

40
func NewVolumeCapabilityAccessMode(mode csi.VolumeCapability_AccessMode_Mode) *csi.VolumeCapability_AccessMode {
1✔
41
        return &csi.VolumeCapability_AccessMode{Mode: mode}
1✔
42
}
1✔
43

44
func NewControllerServiceCapability(cap csi.ControllerServiceCapability_RPC_Type) *csi.ControllerServiceCapability {
10✔
45
        return &csi.ControllerServiceCapability{
10✔
46
                Type: &csi.ControllerServiceCapability_Rpc{
10✔
47
                        Rpc: &csi.ControllerServiceCapability_RPC{
10✔
48
                                Type: cap,
10✔
49
                        },
10✔
50
                },
10✔
51
        }
10✔
52
}
10✔
53

54
func NewNodeServiceCapability(cap csi.NodeServiceCapability_RPC_Type) *csi.NodeServiceCapability {
8✔
55
        return &csi.NodeServiceCapability{
8✔
56
                Type: &csi.NodeServiceCapability_Rpc{
8✔
57
                        Rpc: &csi.NodeServiceCapability_RPC{
8✔
58
                                Type: cap,
8✔
59
                        },
8✔
60
                },
8✔
61
        }
8✔
62
}
8✔
63

64
func getLogLevel(method string) int32 {
7✔
65
        if method == "/csi.v1.Identity/Probe" ||
7✔
66
                method == "/csi.v1.Node/NodeGetCapabilities" ||
7✔
67
                method == "/csi.v1.Node/NodeGetVolumeStats" {
10✔
68
                return 6
3✔
69
        }
3✔
70
        return 2
4✔
71
}
72

73
func logGRPC(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
2✔
74
        level := klog.Level(getLogLevel(info.FullMethod))
2✔
75
        klog.V(level).Infof("GRPC call: %s", info.FullMethod)
2✔
76
        klog.V(level).Infof("GRPC request: %s", protosanitizer.StripSecrets(req))
2✔
77

2✔
78
        resp, err := handler(ctx, req)
2✔
79
        if err != nil {
2✔
80
                klog.Errorf("GRPC error: %v", err)
×
81
        } else {
2✔
82
                klog.V(level).Infof("GRPC response: %s", protosanitizer.StripSecrets(resp))
2✔
83
        }
2✔
84
        return resp, err
2✔
85
}
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