Skip to content

Commit b88e242

Browse files
committed
libct/cgroupv1: privatize [New]NotFoundError
Those two are not used outside of the package and should not be public. While at it, privatize the Subsystem field of NotFoundError. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
1 parent e39f8b5 commit b88e242

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

libcontainer/cgroups/cgroupv1/utils.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,25 @@ var (
2525
errUnified = errors.New("not implemented for cgroup v2 unified hierarchy")
2626
)
2727

28-
type NotFoundError struct {
29-
Subsystem string
28+
type notFoundError struct {
29+
subsystem string
3030
}
3131

32-
func (e *NotFoundError) Error() string {
33-
return fmt.Sprintf("mountpoint for %s not found", e.Subsystem)
32+
func (e *notFoundError) Error() string {
33+
return fmt.Sprintf("mountpoint for %s not found", e.subsystem)
3434
}
3535

36-
func NewNotFoundError(sub string) error {
37-
return &NotFoundError{
38-
Subsystem: sub,
36+
func newNotFoundError(sub string) error {
37+
return &notFoundError{
38+
subsystem: sub,
3939
}
4040
}
4141

4242
func IsNotFound(err error) bool {
4343
if err == nil {
4444
return false
4545
}
46-
_, ok := err.(*NotFoundError)
46+
_, ok := err.(*notFoundError)
4747
return ok
4848
}
4949

@@ -65,7 +65,7 @@ func FindCgroupMountpointAndRoot(cgroupPath, subsystem string) (string, string,
6565
// parsing it directly sped up x10 times because of not using Sscanf.
6666
// It was one of two major performance drawbacks in container start.
6767
if !isSubsystemAvailable(subsystem) {
68-
return "", "", NewNotFoundError(subsystem)
68+
return "", "", newNotFoundError(subsystem)
6969
}
7070

7171
f, err := os.Open("/proc/self/mountinfo")
@@ -97,7 +97,7 @@ func findCgroupMountpointAndRootFromReader(reader io.Reader, cgroupPath, subsyst
9797
return "", "", err
9898
}
9999

100-
return "", "", NewNotFoundError(subsystem)
100+
return "", "", newNotFoundError(subsystem)
101101
}
102102

103103
func isSubsystemAvailable(subsystem string) bool {
@@ -340,5 +340,5 @@ func getControllerPath(subsystem string, cgroups map[string]string) (string, err
340340
return p, nil
341341
}
342342

343-
return "", NewNotFoundError(subsystem)
343+
return "", newNotFoundError(subsystem)
344344
}

0 commit comments

Comments
 (0)