MCPcopy Create free account
hub / github.com/containerd/nerdctl / generateCapOpts

Function generateCapOpts

pkg/cmd/container/run_security_linux.go:208–236  ·  view source on GitHub ↗
(capAdd, capDrop []string)

Source from the content-addressed store, hash-verified

206}
207
208func generateCapOpts(capAdd, capDrop []string) ([]oci.SpecOpts, error) {
209 if len(capAdd) == 0 && len(capDrop) == 0 {
210 return nil, nil
211 }
212
213 var opts []oci.SpecOpts
214 if strutil.InStringSlice(capDrop, "ALL") {
215 opts = append(opts, oci.WithCapabilities(nil))
216 }
217
218 if strutil.InStringSlice(capAdd, "ALL") {
219 opts = append(opts, oci.WithAllCurrentCapabilities)
220 } else {
221 var capsAdd []string
222 for _, c := range capAdd {
223 capsAdd = append(capsAdd, canonicalizeCapName(c))
224 }
225 opts = append(opts, oci.WithAddedCapabilities(capsAdd))
226 }
227
228 if !strutil.InStringSlice(capDrop, "ALL") {
229 var capsDrop []string
230 for _, c := range capDrop {
231 capsDrop = append(capsDrop, canonicalizeCapName(c))
232 }
233 opts = append(opts, oci.WithDroppedCapabilities(capsDrop))
234 }
235 return opts, nil
236}

Callers 1

setPlatformOptionsFunction · 0.85

Calls 2

InStringSliceFunction · 0.92
canonicalizeCapNameFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…