Files
podman/pkg/api/handlers/compat/containers_start.go
Paul Holzinger 942f789a88 set !remote build tags where needed
The new golangci-lint version 1.60.1 has problems with typecheck when
linting remote files. We have certain pakcages that should never be
inlcuded in remote but the typecheck tries to compile all of them but
this never works and it seems to ignore the exclude files we gave it.

To fix this the proper way is to mark all packages we only use locally
with !remote tags. This is a bit ugly but more correct. I also moved the
DecodeChanges() code around as it is called from the client so the
handles package which should only be remote doesn't really fit anyway.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-08-19 11:41:28 +02:00

49 lines
1.3 KiB
Go

//go:build !remote
package compat
import (
"errors"
"net/http"
api "github.com/containers/podman/v5/pkg/api/types"
"github.com/sirupsen/logrus"
"github.com/containers/podman/v5/libpod"
"github.com/containers/podman/v5/libpod/define"
"github.com/containers/podman/v5/pkg/api/handlers/utils"
)
func StartContainer(w http.ResponseWriter, r *http.Request) {
decoder := utils.GetDecoder(r)
query := struct {
DetachKeys string `schema:"detachKeys"`
}{
// Override golang default values for types
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
utils.BadRequest(w, "url", r.URL.String(), err)
return
}
if len(query.DetachKeys) > 0 {
// TODO - start does not support adding detach keys
logrus.Info("The detach keys parameter is not supported on start container")
}
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
name := utils.GetName(r)
con, err := runtime.LookupContainer(name)
if err != nil {
utils.ContainerNotFound(w, name, err)
return
}
if err := con.Start(r.Context(), true); err != nil {
if errors.Is(err, define.ErrCtrStateRunning) {
utils.WriteResponse(w, http.StatusNotModified, nil)
return
}
utils.InternalServerError(w, err)
return
}
utils.WriteResponse(w, http.StatusNoContent, nil)
}