From be682de68c06582155b01976d3dacf4db948664c Mon Sep 17 00:00:00 2001 From: Aditya R Date: Mon, 15 May 2023 16:44:50 +0530 Subject: [PATCH] build: validate volumes on backend Validate build volumes on backend and not on frontend Closes: https://github.com/containers/podman/issues/17139 [NO NEW TESTS NEEDED] Exisiting volumes checks must pass. ( Tests might need retrofit in error message ) Signed-off-by: Aditya R --- imagebuildah/build.go | 5 ++++- pkg/parse/parse.go | 3 --- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/imagebuildah/build.go b/imagebuildah/build.go index 5cba467ee3..4e2d708414 100644 --- a/imagebuildah/build.go +++ b/imagebuildah/build.go @@ -17,6 +17,7 @@ import ( "github.com/containerd/containerd/platforms" "github.com/containers/buildah/define" internalUtil "github.com/containers/buildah/internal/util" + "github.com/containers/buildah/pkg/parse" "github.com/containers/buildah/util" "github.com/containers/common/libimage" "github.com/containers/common/pkg/config" @@ -65,7 +66,9 @@ func BuildDockerfiles(ctx context.Context, store storage.Store, options define.B if options.CommonBuildOpts == nil { options.CommonBuildOpts = &define.CommonBuildOptions{} } - + if err := parse.Volumes(options.CommonBuildOpts.Volumes); err != nil { + return "", nil, fmt.Errorf("validating volumes: %w", err) + } if len(paths) == 0 { return "", nil, errors.New("building: no dockerfiles specified") } diff --git a/pkg/parse/parse.go b/pkg/parse/parse.go index ad004c15d9..8719534388 100644 --- a/pkg/parse/parse.go +++ b/pkg/parse/parse.go @@ -154,9 +154,6 @@ func CommonBuildOptionsFromFlagSet(flags *pflag.FlagSet, findFlagFunc func(name return nil, fmt.Errorf("invalid --shm-size: %w", err) } volumes, _ := flags.GetStringArray("volume") - if err := Volumes(volumes); err != nil { - return nil, err - } cpuPeriod, _ := flags.GetUint64("cpu-period") cpuQuota, _ := flags.GetInt64("cpu-quota") cpuShares, _ := flags.GetUint64("cpu-shares")