MCPcopy
hub / github.com/google/cadvisor / ValidateInfo

Function ValidateInfo

container/docker/docker.go:102–131  ·  view source on GitHub ↗

ValidateInfo checks whether the dockerInfo reflects a valid docker setup, and returns it if it does, or an error otherwise.

(GetInfo func() (*dockersystem.Info, error), ServerVersion func() (string, error))

Source from the content-addressed store, hash-verified

100// ValidateInfo checks whether the dockerInfo reflects a valid docker setup, and returns it if it does, or an
101// error otherwise.
102func ValidateInfo(GetInfo func() (*dockersystem.Info, error), ServerVersion func() (string, error)) (*dockersystem.Info, error) {
103 info, err := GetInfo()
104 if err != nil {
105 return nil, err
106 }
107
108 // Fall back to version API if ServerVersion is not set in info.
109 if info.ServerVersion == "" {
110 var err error
111 info.ServerVersion, err = ServerVersion()
112 if err != nil {
113 return nil, fmt.Errorf("unable to get runtime version: %v", err)
114 }
115 }
116
117 version, err := ParseVersion(info.ServerVersion, VersionRe, 3)
118 if err != nil {
119 return nil, err
120 }
121
122 if version[0] < 1 {
123 return nil, fmt.Errorf("cAdvisor requires runtime version %v or above but we have found version %v reported as %q", []int{1, 0, 0}, version, info.ServerVersion)
124 }
125
126 if info.Driver == "" {
127 return nil, fmt.Errorf("failed to find runtime storage driver")
128 }
129
130 return info, nil
131}
132
133func Info() (*dockersystem.Info, error) {
134 client, err := Client()

Callers 3

RegisterFunction · 0.92
validateDockerInfoFunction · 0.92
RegisterFunction · 0.85

Calls 3

ParseVersionFunction · 0.85
ErrorfMethod · 0.80
GetInfoFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…