MCPcopy Create free account
hub / github.com/containerd/containerd / remappedGID

Function remappedGID

core/runtime/v2/bundle_linux.go:59–74  ·  view source on GitHub ↗

remappedGID reads the remapped GID 0 from the OCI spec, if it exists. If there is no remapping, remappedGID returns 0. If the spec cannot be parsed, remappedGID returns an error.

(spec []byte)

Source from the content-addressed store, hash-verified

57// there is no remapping, remappedGID returns 0. If the spec cannot be parsed,
58// remappedGID returns an error.
59func remappedGID(spec []byte) (uint32, error) {
60 var ociSpec ociSpecUserNS
61 err := json.Unmarshal(spec, &ociSpec)
62 if err != nil {
63 return 0, err
64 }
65 if ociSpec.Linux == nil || len(ociSpec.Linux.GIDMappings) == 0 {
66 return 0, nil
67 }
68 for _, mapping := range ociSpec.Linux.GIDMappings {
69 if mapping.ContainerID == 0 {
70 return mapping.HostID, nil
71 }
72 }
73 return 0, nil
74}

Callers 2

TestRemappedGIDFunction · 0.85

Calls 1

UnmarshalMethod · 0.80

Tested by 1

TestRemappedGIDFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…