mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
pkg/sysinfo.New() move v1 code to a newV1() function
This makes it clearer that this code is the cgroups v1 equivalent of newV2(). Also moves the "options" handling to newV2() because it's currently only used for cgroupsv2. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
22d6671db2
commit
10ce0d84c2
2 changed files with 9 additions and 6 deletions
|
@ -14,11 +14,15 @@ import (
|
||||||
|
|
||||||
type infoCollectorV2 func(info *SysInfo, controllers map[string]struct{}, dirPath string) (warnings []string)
|
type infoCollectorV2 func(info *SysInfo, controllers map[string]struct{}, dirPath string) (warnings []string)
|
||||||
|
|
||||||
func newV2(quiet bool, opts *opts) *SysInfo {
|
func newV2(quiet bool, options ...Opt) *SysInfo {
|
||||||
var warnings []string
|
var warnings []string
|
||||||
sysInfo := &SysInfo{
|
sysInfo := &SysInfo{
|
||||||
CgroupUnified: true,
|
CgroupUnified: true,
|
||||||
}
|
}
|
||||||
|
var opts opts
|
||||||
|
for _, o := range options {
|
||||||
|
o(&opts)
|
||||||
|
}
|
||||||
g := opts.cg2GroupPath
|
g := opts.cg2GroupPath
|
||||||
if g == "" {
|
if g == "" {
|
||||||
g = "/"
|
g = "/"
|
||||||
|
|
|
@ -53,14 +53,13 @@ func WithCgroup2GroupPath(g string) Opt {
|
||||||
// the kernel supports. If `quiet` is `false` warnings are printed in logs
|
// the kernel supports. If `quiet` is `false` warnings are printed in logs
|
||||||
// whenever an error occurs or misconfigurations are present.
|
// whenever an error occurs or misconfigurations are present.
|
||||||
func New(quiet bool, options ...Opt) *SysInfo {
|
func New(quiet bool, options ...Opt) *SysInfo {
|
||||||
var opts opts
|
|
||||||
for _, o := range options {
|
|
||||||
o(&opts)
|
|
||||||
}
|
|
||||||
if cdcgroups.Mode() == cdcgroups.Unified {
|
if cdcgroups.Mode() == cdcgroups.Unified {
|
||||||
return newV2(quiet, &opts)
|
return newV2(quiet, options...)
|
||||||
}
|
}
|
||||||
|
return newV1(quiet)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newV1(quiet bool) *SysInfo {
|
||||||
var ops []infoCollector
|
var ops []infoCollector
|
||||||
var warnings []string
|
var warnings []string
|
||||||
sysInfo := &SysInfo{}
|
sysInfo := &SysInfo{}
|
||||||
|
|
Loading…
Add table
Reference in a new issue