Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Dan Kortschak <[email protected]>
  • Loading branch information
mjwolf and efd6 authored Jan 17, 2024
1 parent 0f610cb commit c688f5a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (p *addSessionMetadata) enrich(ev *beat.Event) (*beat.Event, error) {
return result, nil
}

//pidToUInt32 converts PID value to uint32
// pidToUInt32 converts PID value to uint32
func pidToUInt32(value interface{}) (pid uint32, err error) {
switch v := value.(type) {
case string:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ func stringStartsWithEntryInList(str string, list []string) bool {
}

func isContainerRuntime(executable string) bool {
return stringStartsWithEntryInList(executable, containerRuntimes[:])
return slices.ContainsFunc(containerRuntimes[:], func(s string) bool {
return strings.HasPrefix(executable, s)
})
}

func isFilteredExecutable(executable string) bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (r *MockReader) GetProcess(pid uint32) (ProcessInfo, error) {
}

func (r *MockReader) GetAllProcesses() ([]ProcessInfo, error) {
ret := make([]ProcessInfo, 0)
ret := make([]ProcessInfo, 0, len(r.entries))

for _, entry := range r.entries {
ret = append(ret, entry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (r ProcfsReader) getProcessInfo(proc p.Proc) (ProcessInfo, error) {
// start time is needed to register the process in the database
stat, err := proc.Stat()
if err != nil {
return ProcessInfo{}, fmt.Errorf("failed to read /proc/%d/stat: %v", pid, err)
return ProcessInfo{}, fmt.Errorf("failed to read /proc/%d/stat: %w", pid, err)
}

argv, err := proc.CmdLine()
Expand Down

0 comments on commit c688f5a

Please sign in to comment.