mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-07-16 18:42:34 -04:00
Bumps [github.com/testcontainers/testcontainers-go/modules/opensearch](https://github.com/testcontainers/testcontainers-go) from 0.41.0 to 0.42.0. - [Release notes](https://github.com/testcontainers/testcontainers-go/releases) - [Commits](https://github.com/testcontainers/testcontainers-go/compare/v0.41.0...v0.42.0) --- updated-dependencies: - dependency-name: github.com/testcontainers/testcontainers-go/modules/opensearch dependency-version: 0.42.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
47 lines
1.3 KiB
Go
47 lines
1.3 KiB
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"github.com/moby/moby/api/types/container"
|
|
)
|
|
|
|
// ContainerUpdateOptions holds options for [Client.ContainerUpdate].
|
|
type ContainerUpdateOptions struct {
|
|
Resources *container.Resources
|
|
RestartPolicy *container.RestartPolicy
|
|
}
|
|
|
|
// ContainerUpdateResult is the result from updating a container.
|
|
type ContainerUpdateResult struct {
|
|
// Warnings encountered when updating the container.
|
|
Warnings []string
|
|
}
|
|
|
|
// ContainerUpdate updates the resources of a container.
|
|
func (cli *Client) ContainerUpdate(ctx context.Context, containerID string, options ContainerUpdateOptions) (ContainerUpdateResult, error) {
|
|
containerID, err := trimID("container", containerID)
|
|
if err != nil {
|
|
return ContainerUpdateResult{}, err
|
|
}
|
|
|
|
updateConfig := container.UpdateConfig{}
|
|
if options.Resources != nil {
|
|
updateConfig.Resources = *options.Resources
|
|
}
|
|
if options.RestartPolicy != nil {
|
|
updateConfig.RestartPolicy = *options.RestartPolicy
|
|
}
|
|
|
|
resp, err := cli.post(ctx, "/containers/"+containerID+"/update", nil, updateConfig, nil)
|
|
defer ensureReaderClosed(resp)
|
|
if err != nil {
|
|
return ContainerUpdateResult{}, err
|
|
}
|
|
|
|
var response container.UpdateResponse
|
|
err = json.NewDecoder(resp.Body).Decode(&response)
|
|
return ContainerUpdateResult{Warnings: response.Warnings}, err
|
|
}
|