Skip to content

Commit

Permalink
Merge pull request containers#3901 from Luap99/build-args
Browse files Browse the repository at this point in the history
buildah build should accept at most one arg
  • Loading branch information
openshift-merge-robot authored Apr 6, 2022
2 parents d56c2e1 + 3351617 commit 2a1af04
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
8 changes: 2 additions & 6 deletions cmd/buildah/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 .
Expand Down Expand Up @@ -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
Expand Down
21 changes: 6 additions & 15 deletions tests/bud.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 2a1af04

Please sign in to comment.