deserializeLinuxIDMapping unmarshals a string to a LinuxIDMapping object
(str string)
| 157 | |
| 158 | // deserializeLinuxIDMapping unmarshals a string to a LinuxIDMapping object |
| 159 | func deserializeLinuxIDMapping(str string) (specs.LinuxIDMapping, error) { |
| 160 | var ( |
| 161 | hostID, ctrID, length int64 |
| 162 | ) |
| 163 | _, err := fmt.Sscanf(str, "%d:%d:%d", &ctrID, &hostID, &length) |
| 164 | if err != nil { |
| 165 | return specs.LinuxIDMapping{}, fmt.Errorf("input value %s unparsable: %w", str, err) |
| 166 | } |
| 167 | if ctrID < 0 || ctrID >= invalidID || hostID < 0 || hostID >= invalidID || length < 0 || length >= invalidID { |
| 168 | return specs.LinuxIDMapping{}, fmt.Errorf("invalid mapping \"%s\"", str) |
| 169 | } |
| 170 | return specs.LinuxIDMapping{ |
| 171 | ContainerID: uint32(ctrID), |
| 172 | HostID: uint32(hostID), |
| 173 | Size: uint32(length), |
| 174 | }, nil |
| 175 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…