podman v3 container bindings

convert the golang container bindings to all use options so that changes
in the future are more managable.

Signed-off-by: baude <bbaude@redhat.com>
This commit is contained in:
baude
2020-12-17 12:07:13 -06:00
parent d6925182cd
commit 401dcff838
107 changed files with 4474 additions and 539 deletions

View File

@ -3,8 +3,6 @@ package containers
import (
"context"
"net/http"
"net/url"
"strconv"
"github.com/containers/podman/v2/pkg/api/handlers"
"github.com/containers/podman/v2/pkg/bindings"
@ -12,35 +10,20 @@ import (
// 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) (handlers.IDResponse, error) {
func Commit(ctx context.Context, nameOrID string, options *CommitOptions) (handlers.IDResponse, error) {
if options == nil {
options = new(CommitOptions)
}
id := handlers.IDResponse{}
conn, err := bindings.GetClient(ctx)
if err != nil {
return id, err
}
params := url.Values{}
params, err := options.ToParams()
if err != nil {
return handlers.IDResponse{}, err
}
params.Set("container", nameOrID)
if options.Author != nil {
params.Set("author", *options.Author)
}
for _, change := range options.Changes {
params.Set("changes", change)
}
if options.Comment != nil {
params.Set("comment", *options.Comment)
}
if options.Format != nil {
params.Set("format", *options.Format)
}
if options.Pause != nil {
params.Set("pause", strconv.FormatBool(*options.Pause))
}
if options.Repo != nil {
params.Set("repo", *options.Repo)
}
if options.Tag != nil {
params.Set("tag", *options.Tag)
}
response, err := conn.DoRequest(nil, http.MethodPost, "/commit", params, nil)
if err != nil {
return id, err