mirror of
https://github.com/containers/podman.git
synced 2025-12-14 02:48:35 +08:00
Moving from Go module v4 to v5 prepares us for public releases. Move done using gomove [1] as with the v3 and v4 moves. [1] https://github.com/KSubedi/gomove Signed-off-by: Matt Heon <mheon@redhat.com>
32 lines
780 B
Go
32 lines
780 B
Go
package containers
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"strings"
|
|
|
|
"github.com/containers/podman/v5/pkg/bindings"
|
|
"github.com/containers/podman/v5/pkg/domain/entities/types"
|
|
jsoniter "github.com/json-iterator/go"
|
|
)
|
|
|
|
func Update(ctx context.Context, options *types.ContainerUpdateOptions) (string, error) {
|
|
conn, err := bindings.GetClient(ctx)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
resources, err := jsoniter.MarshalToString(options.Specgen.ResourceLimits)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
stringReader := strings.NewReader(resources)
|
|
response, err := conn.DoRequest(ctx, stringReader, http.MethodPost, "/containers/%s/update", nil, nil, options.NameOrID)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
defer response.Body.Close()
|
|
|
|
return options.NameOrID, response.Process(nil)
|
|
}
|