RemoveIDMapOption copies and removes the uidmap/gidmap options on any of the mounts using it.
(mounts []Mount)
| 107 | |
| 108 | // RemoveIDMapOption copies and removes the uidmap/gidmap options on any of the mounts using it. |
| 109 | func RemoveIDMapOption(mounts []Mount) []Mount { |
| 110 | var out []Mount |
| 111 | for i, m := range mounts { |
| 112 | for j, opt := range m.Options { |
| 113 | if strings.HasPrefix(opt, "uidmap") || strings.HasPrefix(opt, "gidmap") { |
| 114 | if out == nil { |
| 115 | out = copyMounts(mounts) |
| 116 | } |
| 117 | out[i].Options = append(out[i].Options[:j], out[i].Options[j+1:]...) |
| 118 | } |
| 119 | } |
| 120 | } |
| 121 | if out != nil { |
| 122 | return out |
| 123 | } |
| 124 | return mounts |
| 125 | } |
| 126 | |
| 127 | // copyMounts creates a copy of the original slice to allow for modification and not altering the original |
| 128 | func copyMounts(in []Mount) []Mount { |
no test coverage detected
searching dependent graphs…