Skip to content

Commit

Permalink
chore: make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
JGAntunes committed Nov 7, 2024
1 parent a9b9483 commit e561b55
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions pkg/collect/host_sysctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,16 @@ func parseSysctlParameters(output []byte) map[string]string {
l := scanner.Text()
// <1:key> <2:separator> <3:value>
matches := sysctlLineRegex.FindStringSubmatch(l)

switch len(matches) {
// there are no matches for the value and separator, ignore and log
if len(matches) < 3 {
case 0, 1, 2:
klog.V(2).Infof("skipping sysctl line since we found no matches for it: %s", l)
// key exists but value could be empty, register as an empty string value but log something for reference
} else if len(matches) < 4 {
// key exists but value could be empty, register as an empty string value but log something for reference
case 3:
klog.V(2).Infof("found no value for sysctl line, keeping it with an empty value: %s", l)
result[matches[1]] = ""
} else {
default:
result[matches[1]] = matches[3]
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/collect/host_sysctl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestCollectHostSysctl_(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
req := require.New(t)

setExecStub(exec.Command("echo", "-n", test.cmdOut))
setExecStub(exec.Command("echo", "-n", test.cmdOut)) // #nosec G204

tmpDir := t.TempDir()
c := &CollectHostSysctl{
Expand Down

0 comments on commit e561b55

Please sign in to comment.