diff --git a/cmd/buildah/build.go b/cmd/buildah/build.go index 4501b6d92d6..17324f31b27 100644 --- a/cmd/buildah/build.go +++ b/cmd/buildah/build.go @@ -43,7 +43,7 @@ func init() { namespaceResults := buildahcli.NameSpaceResults{} buildCommand := &cobra.Command{ - Use: "build", + Use: "build [CONTEXT]", Aliases: []string{"build-using-dockerfile", "bud"}, Short: "Build an image using instructions in a Containerfile", Long: buildDescription, @@ -57,6 +57,7 @@ func init() { } return buildCmd(cmd, args, br) }, + Args: cobra.MaximumNArgs(1), Example: `buildah build buildah bud -f Containerfile.simple . buildah bud --volume /home/test:/myvol:ro,Z -t imageName . @@ -199,11 +200,6 @@ func buildCmd(c *cobra.Command, inputArgs []string, iopts buildOptions) error { contextDir = absDir } } - cliArgs = Tail(cliArgs) - - if err := buildahcli.VerifyFlagsArgsOrder(cliArgs); err != nil { - return err - } if len(containerfiles) == 0 { // Try to find the Containerfile/Dockerfile within the contextDir diff --git a/tests/bud.bats b/tests/bud.bats index f0e92786007..86434d16dee 100644 --- a/tests/bud.bats +++ b/tests/bud.bats @@ -171,20 +171,6 @@ _EOF expect_output --substring $targetarch } -@test "bud-flags-order-verification" { - run_buildah 125 build /tmp/tmpdockerfile/ -t blabla - check_options_flag_err "-t" - - run_buildah 125 build /tmp/tmpdockerfile/ -q -t blabla - check_options_flag_err "-q" - - run_buildah 125 build /tmp/tmpdockerfile/ --force-rm - check_options_flag_err "--force-rm" - - run_buildah 125 build /tmp/tmpdockerfile/ --userns=cnt1 - check_options_flag_err "--userns=cnt1" -} - @test "bud with --layers and --no-cache flags" { cp -a ${TESTSDIR}/bud/use-layers ${TESTDIR}/use-layers @@ -3170,10 +3156,15 @@ from alpine run echo hello _EOF - run_buildah 1 build --signature-policy ${TESTSDIR}/policy.json --runtime-flag invalidflag -t build_test $mytmpdir . + run_buildah 1 build --signature-policy ${TESTSDIR}/policy.json --runtime-flag invalidflag -t build_test $mytmpdir assert "$output" =~ ".*invalidflag" "failed when passing undefined flags to the runtime" } +@test "bud - accept at most one arg" { + run_buildah 125 build --signature-policy ${TESTSDIR}/policy.json ${TESTSDIR}/bud/dns extraarg + assert "accepts at most 1 arg(s), received 2" "error while parsing arguments" +} + @test "bud with --add-host" { skip_if_no_runtime