From d6771f81afd74e4f1a4a7ad5434f63d72c253de2 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Tue, 25 Jun 2024 11:36:14 -0400 Subject: [PATCH] imagebuildah.StageExecutor.Copy(): reject new flags for now Reject the new ADD --keep-git-dir, COPY --parents, and ADD/COPY --link and ADD/COPY --exclude flags. The behavior they ask for isn't implemented (yet), and rejecting the flags outright is far preferable to quietly ignoring them. Signed-off-by: Nalin Dahyabhai --- imagebuildah/stage_executor.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/imagebuildah/stage_executor.go b/imagebuildah/stage_executor.go index 1723c8aab96..4f89a0eb860 100644 --- a/imagebuildah/stage_executor.go +++ b/imagebuildah/stage_executor.go @@ -349,6 +349,26 @@ func (s *StageExecutor) volumeCacheRestore() error { // Copy copies data into the working tree. The "Download" field is how // imagebuilder tells us the instruction was "ADD" and not "COPY". func (s *StageExecutor) Copy(excludes []string, copies ...imagebuilder.Copy) error { + for _, cp := range copies { + if cp.KeepGitDir { + if cp.Download { + return errors.New("ADD --keep-git-dir is not supported") + } + return errors.New("COPY --keep-git-dir is not supported") + } + if cp.Link { + return errors.New("COPY --link is not supported") + } + if cp.Parents { + return errors.New("COPY --parents is not supported") + } + if len(cp.Excludes) > 0 { + if cp.Download { + return errors.New("ADD --excludes is not supported") + } + return errors.New("COPY --excludes is not supported") + } + } s.builder.ContentDigester.Restart() return s.performCopy(excludes, copies...) }