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

kubernetes-sigs / blob-csi-driver / 13386305256

18 Feb 2025 08:27AM UTC coverage: 77.861%. Remained the same
13386305256

Pull #1839

github

andyzhangx
feat: optimize azcopy perf in volume cloning scenario
Pull Request #1839: feat: optimize azcopy perf in volume cloning scenario

2286 of 2936 relevant lines covered (77.86%)

7.44 hits per line

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

93.1
/pkg/blob/version.go
1
/*
2
Copyright 2019 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 blob
18

19
import (
20
        "fmt"
21
        "runtime"
22
        "strings"
23

24
        "sigs.k8s.io/yaml"
25
)
26

27
// These are set during build time via -ldflags
28
var (
29
        driverVersion = "N/A"
30
        gitCommit     = "N/A"
31
        buildDate     = "N/A"
32
)
33

34
// VersionInfo holds the version information of the driver
35
type VersionInfo struct {
36
        DriverName    string `json:"Driver Name"`
37
        DriverVersion string `json:"Driver Version"`
38
        GitCommit     string `json:"Git Commit"`
39
        BuildDate     string `json:"Build Date"`
40
        GoVersion     string `json:"Go Version"`
41
        Compiler      string `json:"Compiler"`
42
        Platform      string `json:"Platform"`
43
}
44

45
// GetVersion returns the version information of the driver
46
func GetVersion(driverName string) VersionInfo {
5✔
47
        return VersionInfo{
5✔
48
                DriverName:    driverName,
5✔
49
                DriverVersion: driverVersion,
5✔
50
                GitCommit:     gitCommit,
5✔
51
                BuildDate:     buildDate,
5✔
52
                GoVersion:     runtime.Version(),
5✔
53
                Compiler:      runtime.Compiler,
5✔
54
                Platform:      fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
5✔
55
        }
5✔
56
}
5✔
57

58
// GetVersionYAML returns the version information of the driver
59
// in YAML format
60
func GetVersionYAML(driverName string) (string, error) {
3✔
61
        info := GetVersion(driverName)
3✔
62
        marshalled, err := yaml.Marshal(&info)
3✔
63
        if err != nil {
3✔
64
                return "", err
×
65
        }
×
66
        return strings.TrimSpace(string(marshalled)), nil
3✔
67
}
68

69
// GetUserAgent returns user agent of the driver
70
func GetUserAgent(driverName, customUserAgent, userAgentSuffix string) string {
3✔
71
        customUserAgent = strings.TrimSpace(customUserAgent)
3✔
72
        userAgent := customUserAgent
3✔
73
        if customUserAgent == "" {
5✔
74
                userAgent = fmt.Sprintf("%s/%s", driverName, driverVersion)
2✔
75
        }
2✔
76

77
        userAgentSuffix = strings.TrimSpace(userAgentSuffix)
3✔
78
        if userAgentSuffix != "" {
4✔
79
                userAgent = userAgent + " " + userAgentSuffix
1✔
80
        }
1✔
81
        return userAgent
3✔
82
}
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