Skip to content

Commit

Permalink
stage_executor: inline network add default string
Browse files Browse the repository at this point in the history
Inline `RUN --network=default` should do nothing. This matches
buildkit's behaviour here: https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/reference.md#run---networkdefault

Also added to podman's document here: containers/common#1366

Signed-off-by: Aditya R <arajan@redhat.com>
  • Loading branch information
flouthoc committed Apr 4, 2023
1 parent 40dff19 commit af15efa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion imagebuildah/stage_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ func (s *StageExecutor) Run(run imagebuilder.Run, config docker.Config) error {
options.ConfigureNetwork = define.NetworkEnabled
case "none":
options.ConfigureNetwork = define.NetworkDisabled
case "":
case "", "default":
// do nothing
default:
return fmt.Errorf(`unsupported value %q for "RUN --network", must be either "host" or "none"`, run.Network)
Expand Down
13 changes: 13 additions & 0 deletions tests/bud.bats
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ load helpers
expect_output --substring "unsupported value"
}

@test "build with inline default RUN --network=default" {
_prefetch alpine
run readlink /proc/self/ns/net
hostns=$output
run_buildah build --network=host $WITH_POLICY_JSON -t source -f $BUDFILES/inline-network/Dockerfile4
firstns=${lines[2]}
assert "${hostns}" == "$firstns"
run_buildah build --network=private $WITH_POLICY_JSON -t source -f $BUDFILES/inline-network/Dockerfile4
secondns=${lines[2]}
assert "$secondns" != "$firstns"
assert "$secondns" != "$hostns"
}


@test "bud with ignoresymlink on default file" {
cat > /tmp/private_file << _EOF
Expand Down
2 changes: 2 additions & 0 deletions tests/bud/inline-network/Dockerfile4
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM alpine
RUN --network=default readlink /proc/self/ns/net

0 comments on commit af15efa

Please sign in to comment.