From 4f1b6146c5931e682c7a2fc8d1e712e2afbdc642 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Sat, 25 Jun 2022 19:19:07 +0200 Subject: [PATCH] parse: support copy and nocopy it is needed for supporting -v volume:/to:nocopy. Signed-off-by: Giuseppe Scrivano --- pkg/parse/parse.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/parse/parse.go b/pkg/parse/parse.go index 6c4958cc2..43b783e0c 100644 --- a/pkg/parse/parse.go +++ b/pkg/parse/parse.go @@ -14,7 +14,7 @@ import ( // ValidateVolumeOpts validates a volume's options func ValidateVolumeOpts(options []string) ([]string, error) { - var foundRootPropagation, foundRWRO, foundLabelChange, bindType, foundExec, foundDev, foundSuid, foundChown, foundUpperDir, foundWorkDir int + var foundRootPropagation, foundRWRO, foundLabelChange, bindType, foundExec, foundDev, foundSuid, foundChown, foundUpperDir, foundWorkDir, foundCopy int finalOpts := make([]string, 0, len(options)) for _, opt := range options { // support advanced options like upperdir=/path, workdir=/path @@ -88,6 +88,11 @@ func ValidateVolumeOpts(options []string) ([]string, error) { // are intended to be always safe to use, even not on OS // X). continue + case "copy", "nocopy": + foundCopy++ + if foundCopy > 1 { + return nil, errors.Errorf("invalid options %q, can only specify 1 'copy' or 'nocopy' option", strings.Join(options, ", ")) + } default: return nil, errors.Errorf("invalid option type %q", opt) }