diff options
author | Brent Baude <bbaude@redhat.com> | 2020-06-16 15:09:20 -0500 |
---|---|---|
committer | Brent Baude <bbaude@redhat.com> | 2020-06-17 09:01:43 -0500 |
commit | 65c3a56602f50856c6d4b8df212f046d53ba52c1 (patch) | |
tree | 926069a574c1f2e61d391e60c8ee1cf106e1af73 /pkg/api | |
parent | 38391ed25fdb1cc53b70a75ee4fbe7ea0fa782c3 (diff) | |
download | podman-65c3a56602f50856c6d4b8df212f046d53ba52c1.tar.gz podman-65c3a56602f50856c6d4b8df212f046d53ba52c1.tar.bz2 podman-65c3a56602f50856c6d4b8df212f046d53ba52c1.zip |
fix misc remote build issues
address problem when multiple -t were sent. and rework remote build's tarball if a context dir is given other than ".".
Fixes: #6578
Fixes: #6577
Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/api')
-rw-r--r-- | pkg/api/handlers/compat/images_build.go | 73 | ||||
-rw-r--r-- | pkg/api/server/register_images.go | 6 |
2 files changed, 39 insertions, 40 deletions
diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index 913994f46..f967acf32 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -48,34 +48,34 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { defer os.RemoveAll(anchorDir) query := struct { - Dockerfile string `schema:"dockerfile"` - Tag string `schema:"t"` - ExtraHosts string `schema:"extrahosts"` - Remote string `schema:"remote"` - Quiet bool `schema:"q"` - NoCache bool `schema:"nocache"` - CacheFrom string `schema:"cachefrom"` - Pull bool `schema:"pull"` - Rm bool `schema:"rm"` - ForceRm bool `schema:"forcerm"` - Memory int64 `schema:"memory"` - MemSwap int64 `schema:"memswap"` - CpuShares uint64 `schema:"cpushares"` //nolint - CpuSetCpus string `schema:"cpusetcpus"` //nolint - CpuPeriod uint64 `schema:"cpuperiod"` //nolint - CpuQuota int64 `schema:"cpuquota"` //nolint - BuildArgs string `schema:"buildargs"` - ShmSize int `schema:"shmsize"` - Squash bool `schema:"squash"` - Labels string `schema:"labels"` - NetworkMode string `schema:"networkmode"` - Platform string `schema:"platform"` - Target string `schema:"target"` - Outputs string `schema:"outputs"` - Registry string `schema:"registry"` + Dockerfile string `schema:"dockerfile"` + Tag []string `schema:"t"` + ExtraHosts string `schema:"extrahosts"` + Remote string `schema:"remote"` + Quiet bool `schema:"q"` + NoCache bool `schema:"nocache"` + CacheFrom string `schema:"cachefrom"` + Pull bool `schema:"pull"` + Rm bool `schema:"rm"` + ForceRm bool `schema:"forcerm"` + Memory int64 `schema:"memory"` + MemSwap int64 `schema:"memswap"` + CpuShares uint64 `schema:"cpushares"` //nolint + CpuSetCpus string `schema:"cpusetcpus"` //nolint + CpuPeriod uint64 `schema:"cpuperiod"` //nolint + CpuQuota int64 `schema:"cpuquota"` //nolint + BuildArgs string `schema:"buildargs"` + ShmSize int `schema:"shmsize"` + Squash bool `schema:"squash"` + Labels string `schema:"labels"` + NetworkMode string `schema:"networkmode"` + Platform string `schema:"platform"` + Target string `schema:"target"` + Outputs string `schema:"outputs"` + Registry string `schema:"registry"` }{ Dockerfile: "Dockerfile", - Tag: "", + Tag: []string{}, ExtraHosts: "", Remote: "", Quiet: false, @@ -107,20 +107,19 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { } var ( - // Tag is the name with optional tag... - name = query.Tag - tag = "latest" + output string + additionalNames []string ) - if strings.Contains(query.Tag, ":") { - tokens := strings.SplitN(query.Tag, ":", 2) - name = tokens[0] - tag = tokens[1] + if len(query.Tag) > 0 { + output = query.Tag[0] + } + if len(query.Tag) > 1 { + additionalNames = query.Tag[1:] } if _, found := r.URL.Query()["target"]; found { - name = query.Target + output = query.Target } - var buildArgs = map[string]string{} if _, found := r.URL.Query()["buildargs"]; found { if err := json.Unmarshal([]byte(query.BuildArgs), &buildArgs); err != nil { @@ -168,8 +167,8 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { TransientMounts: nil, Compression: archive.Gzip, Args: buildArgs, - Output: name, - AdditionalTags: []string{tag}, + Output: output, + AdditionalTags: additionalNames, Log: func(format string, args ...interface{}) { buildEvents = append(buildEvents, fmt.Sprintf(format, args...)) }, diff --git a/pkg/api/server/register_images.go b/pkg/api/server/register_images.go index 83584d0f3..754cb1b75 100644 --- a/pkg/api/server/register_images.go +++ b/pkg/api/server/register_images.go @@ -410,7 +410,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // swagger:operation POST /build compat buildImage // --- // tags: - // - images + // - images (compat) // summary: Create image // description: Build an image from the given Dockerfile(s) // parameters: @@ -425,7 +425,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // name: t // type: string // default: latest - // description: A name and optional tag to apply to the image in the `name:tag` format. + // description: A name and optional tag to apply to the image in the `name:tag` format. If you omit the tag the default latest value is assumed. You can provide several t parameters. // - in: query // name: extrahosts // type: string @@ -1211,7 +1211,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // name: t // type: string // default: latest - // description: A name and optional tag to apply to the image in the `name:tag` format. + // description: A name and optional tag to apply to the image in the `name:tag` format. If you omit the tag the default latest value is assumed. You can provide several t parameters. // - in: query // name: extrahosts // type: string |