Merge pull request #23103 from Luap99/build-platform

build API: accept platform comma separated
This commit is contained in:
openshift-merge-bot[bot] 2024-06-25 22:06:07 +00:00 committed by GitHub
commit 5e27243935
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 1 deletions

View File

@ -738,7 +738,12 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
UnsetLabels: query.UnsetLabels, UnsetLabels: query.UnsetLabels,
} }
for _, platformSpec := range query.Platform { platforms := query.Platform
if len(platforms) == 1 {
// Docker API uses comma sperated platform arg so match this here
platforms = strings.Split(query.Platform[0], ",")
}
for _, platformSpec := range platforms {
os, arch, variant, err := parse.Platform(platformSpec) os, arch, variant, err := parse.Platform(platformSpec)
if err != nil { if err != nil {
utils.BadRequest(w, "platform", platformSpec, err) utils.BadRequest(w, "platform", platformSpec, err)

View File

@ -667,6 +667,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
// default: // default:
// description: | // description: |
// Platform format os[/arch[/variant]] // Platform format os[/arch[/variant]]
// Can be comma separated list for multi arch builds.
// (As of version 1.xx) // (As of version 1.xx)
// - in: query // - in: query
// name: target // name: target

View File

@ -274,6 +274,12 @@ else
_show_ok 1 "compat quiet build" _show_ok 1 "compat quiet build"
fi fi
# Do not try a real build here to tests the comma separated syntax as emulation
# is slow and may not work everywhere, checking the error is good enough to know
# we parsed it correctly on the server I would say
t POST "/build?q=1&dockerfile=containerfile&platform=linux/amd64,test" $CONTAINERFILE_WITH_ERR_TAR 400 \
.message="failed to parse query parameter 'platform': \"test\": invalid platform syntax for --platform=\"test\": \"test\": unknown operating system or architecture: invalid argument"
cleanBuildTest cleanBuildTest
# compat API vs libpod API event differences: # compat API vs libpod API event differences: