mirror of
https://github.com/containers/buildah.git
synced 2026-02-05 09:45:38 +01:00
These experimental packages are now available in the Go standard library since Go 1.21: 1. golang.org/x/exp/slices -> slices [1] 2. golang.org/x/exp/maps -> maps [2] [1]: https://go.dev/doc/go1.21#slices [2]: https://go.dev/doc/go1.21#maps Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
29 lines
705 B
Go
29 lines
705 B
Go
package bind
|
|
|
|
import (
|
|
"slices"
|
|
|
|
"github.com/opencontainers/runtime-spec/specs-go"
|
|
)
|
|
|
|
const (
|
|
// NoBindOption is an option which, if present in a Mount structure's
|
|
// options list, will cause SetupIntermediateMountNamespace to not
|
|
// redirect it through a bind mount.
|
|
NoBindOption = "nobuildahbind"
|
|
)
|
|
|
|
func stripNoBindOption(spec *specs.Spec) {
|
|
for i := range spec.Mounts {
|
|
if slices.Contains(spec.Mounts[i].Options, NoBindOption) {
|
|
prunedOptions := make([]string, 0, len(spec.Mounts[i].Options))
|
|
for _, option := range spec.Mounts[i].Options {
|
|
if option != NoBindOption {
|
|
prunedOptions = append(prunedOptions, option)
|
|
}
|
|
}
|
|
spec.Mounts[i].Options = prunedOptions
|
|
}
|
|
}
|
|
}
|