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

kubescape / sniffer / 4523547892

pending completion
4523547892

Pull #37

github

GitHub
Merge 25e24ac1e into ff771d64a
Pull Request #37: Add instance id to labels

15 of 15 new or added lines in 3 files covered. (100.0%)

684 of 932 relevant lines covered (73.39%)

2080.18 hits per line

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

81.25
/pkg/utils/utils.go
1
package utils
2

3
import (
4
        "path/filepath"
5
        "runtime"
6
        "strings"
7
)
8

9
func Between(value string, a string, b string) string {
4✔
10
        // Get substring between two strings.
4✔
11
        posFirst := strings.Index(value, a)
4✔
12
        if posFirst == -1 {
5✔
13
                return ""
1✔
14
        }
1✔
15
        substr := value[posFirst+len(a):]
3✔
16
        posLast := strings.Index(substr, b) + posFirst + len(a)
3✔
17
        if posLast == -1 {
3✔
18
                return ""
×
19
        }
×
20
        posFirstAdjusted := posFirst + len(a)
3✔
21
        if posFirstAdjusted >= posLast {
5✔
22
                return ""
2✔
23
        }
2✔
24
        return value[posFirstAdjusted:posLast]
1✔
25
}
26

27
func After(value string, a string) string {
1✔
28
        // Get substring after a string.
1✔
29
        pos := strings.LastIndex(value, a)
1✔
30
        if pos == -1 {
1✔
31
                return ""
×
32
        }
×
33
        adjustedPos := pos + len(a)
1✔
34
        if adjustedPos >= len(value) {
1✔
35
                return ""
×
36
        }
×
37
        return value[adjustedPos:len(value)]
1✔
38
}
39

40
func CurrentDir() string {
1✔
41
        _, filename, _, _ := runtime.Caller(1)
1✔
42

1✔
43
        return filepath.Dir(filename)
1✔
44
}
1✔
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

© 2026 Coveralls, Inc