Files
Jhon Honce 5b79cf15a0 Swagger refactor/cleanup
* Remove duplicate or unused types and constants
* Move all documetation-only models and responses into swagger package
* Remove all unecessary names, go-swagger will determine names from
  struct declarations
* Use Libpod suffix to differentiate between compat and libpod models
  and responses. Taken from swagger:operation declarations.
* Models and responses that start with lowercase are for swagger use
  only while uppercase are used "as is" in the code and swagger comments
* Used gofumpt on new code

```release-note

```

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2022-05-19 15:24:18 -07:00

35 lines
922 B
Go

package containers
import (
"context"
"net/http"
"github.com/containers/podman/v4/pkg/bindings"
"github.com/containers/podman/v4/pkg/domain/entities"
)
// Commit creates a container image from a container. The container is defined by nameOrID. Use
// the CommitOptions for finer grain control on characteristics of the resulting image.
func Commit(ctx context.Context, nameOrID string, options *CommitOptions) (entities.IDResponse, error) {
if options == nil {
options = new(CommitOptions)
}
id := entities.IDResponse{}
conn, err := bindings.GetClient(ctx)
if err != nil {
return id, err
}
params, err := options.ToParams()
if err != nil {
return entities.IDResponse{}, err
}
params.Set("container", nameOrID)
response, err := conn.DoRequest(ctx, nil, http.MethodPost, "/commit", params, nil)
if err != nil {
return id, err
}
defer response.Body.Close()
return id, response.Process(&id)
}