Skip to content

Commit 39692c5

Browse files
Merge pull request containers#26230 from jankaluza/26078
Handle "Entrypoint":[] in compat containers/create API.
2 parents 82fcf45 + 3a98191 commit 39692c5

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

pkg/api/handlers/compat/containers_create.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,12 @@ func cliOpts(cc handlers.CreateContainerConfig, rtc *config.Config) (*entities.C
209209
jsonString := string(b)
210210
entrypoint = &jsonString
211211
}
212+
} else if cc.Config.Entrypoint != nil {
213+
// Entrypoint in HTTP request is set, but it is an empty slice.
214+
// Set the entrypoint to empty string slice, because keeping it set to nil
215+
// would later fallback to default entrypoint.
216+
emptySlice := "[]"
217+
entrypoint = &emptySlice
212218
}
213219

214220
// expose ports

test/apiv2/20-containers.at

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,26 @@ if root && test -e /dev/nullb0; then
811811
podman rm -f updateCtr
812812
fi
813813

814+
# test apiv2 create container with empty entrypoint
815+
# --data '{"Image":"quay.io/libpod/some:thing","Entrypoint": []}'
816+
# Fixes #26078
817+
podman image build -t test1:latest -<<EOF
818+
from alpine
819+
ENTRYPOINT ["echo", "test"]
820+
EOF
821+
822+
t POST containers/create \
823+
Image=test1:latest \
824+
Entrypoint=[] \
825+
201 \
826+
.Id~[0-9a-f]\\{64\\}
827+
cid=$(jq -r '.Id' <<<"$output")
828+
t GET containers/$cid/json 200 \
829+
.Config.Entrypoint[0]=null
830+
831+
t DELETE containers/$cid 204
832+
podman rmi test1
833+
814834

815835
# test if API support -1 for ulimits https://github.com/containers/podman/issues/24886
816836

test/apiv2/test-apiv2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ function jsonify() {
221221
local rhs
222222
IFS='=' read lhs rhs <<<"$i"
223223

224-
if [[ $rhs =~ \" || $rhs == true || $rhs == false || $rhs =~ ^-?[0-9]+$ ]]; then
224+
if [[ $rhs =~ \" || $rhs == true || $rhs == false || $rhs == "[]" || $rhs =~ ^-?[0-9]+$ ]]; then
225225
# rhs has been pre-formatted for JSON or a non-string, do not change it
226226
:
227227
elif [[ $rhs == False ]]; then

0 commit comments

Comments
 (0)