Fix golint warning for pkg/util/procfs/procfs_linux.go

Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
This commit is contained in:
Guangwen Feng 2020-01-10 16:55:07 +08:00
parent 2da2c3b01b
commit e2e5bf5e0b

View File

@ -36,8 +36,10 @@ import (
"k8s.io/klog" "k8s.io/klog"
) )
// ProcFS provides a helper for getting container name via pid.
type ProcFS struct{} type ProcFS struct{}
// NewProcFS returns a ProcFS object.
func NewProcFS() ProcFSInterface { func NewProcFS() ProcFSInterface {
return &ProcFS{} return &ProcFS{}
} }
@ -53,7 +55,7 @@ func containerNameFromProcCgroup(content string) (string, error) {
return "", fmt.Errorf("could not find devices cgroup location") return "", fmt.Errorf("could not find devices cgroup location")
} }
// getFullContainerName gets the container name given the root process id of the container. // GetFullContainerName gets the container name given the root process id of the container.
// E.g. if the devices cgroup for the container is stored in /sys/fs/cgroup/devices/docker/nginx, // E.g. if the devices cgroup for the container is stored in /sys/fs/cgroup/devices/docker/nginx,
// return docker/nginx. Assumes that the process is part of exactly one cgroup hierarchy. // return docker/nginx. Assumes that the process is part of exactly one cgroup hierarchy.
func (pfs *ProcFS) GetFullContainerName(pid int) (string, error) { func (pfs *ProcFS) GetFullContainerName(pid int) (string, error) {
@ -68,8 +70,8 @@ func (pfs *ProcFS) GetFullContainerName(pid int) (string, error) {
return containerNameFromProcCgroup(string(content)) return containerNameFromProcCgroup(string(content))
} }
// Find process(es) using a regular expression and send a specified // PKill finds process(es) using a regular expression and send a specified
// signal to each process // signal to each process.
func PKill(name string, sig syscall.Signal) error { func PKill(name string, sig syscall.Signal) error {
if len(name) == 0 { if len(name) == 0 {
return fmt.Errorf("name should not be empty") return fmt.Errorf("name should not be empty")
@ -91,8 +93,8 @@ func PKill(name string, sig syscall.Signal) error {
return utilerrors.NewAggregate(errList) return utilerrors.NewAggregate(errList)
} }
// Find process(es) with a specified name (regexp match) // PidOf finds process(es) with a specified name (regexp match)
// and return their pid(s) // and return their pid(s).
func PidOf(name string) ([]int, error) { func PidOf(name string) ([]int, error) {
if len(name) == 0 { if len(name) == 0 {
return []int{}, fmt.Errorf("name should not be empty") return []int{}, fmt.Errorf("name should not be empty")