mirror of
https://github.com/containers/podman.git
synced 2025-07-03 09:17:15 +08:00
Merge pull request #25828 from IAmJSD/patch-1
Make Go not panic on a partial update
This commit is contained in:
@ -26,13 +26,21 @@ func Update(ctx context.Context, options *types.ContainerUpdateOptions) (string,
|
|||||||
params.Set("restartRetries", strconv.Itoa(int(*options.RestartRetries)))
|
params.Set("restartRetries", strconv.Itoa(int(*options.RestartRetries)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateEntities := &handlers.UpdateEntities{
|
updateEntities := &handlers.UpdateEntities{
|
||||||
LinuxResources: *options.Resources,
|
Env: options.Env,
|
||||||
UpdateHealthCheckConfig: *options.ChangedHealthCheckConfiguration,
|
UnsetEnv: options.UnsetEnv,
|
||||||
UpdateContainerDevicesLimits: *options.DevicesLimits,
|
|
||||||
Env: options.Env,
|
|
||||||
UnsetEnv: options.UnsetEnv,
|
|
||||||
}
|
}
|
||||||
|
if options.Resources != nil {
|
||||||
|
updateEntities.LinuxResources = *options.Resources
|
||||||
|
}
|
||||||
|
if options.ChangedHealthCheckConfiguration != nil {
|
||||||
|
updateEntities.UpdateHealthCheckConfig = *options.ChangedHealthCheckConfiguration
|
||||||
|
}
|
||||||
|
if options.DevicesLimits != nil {
|
||||||
|
updateEntities.UpdateContainerDevicesLimits = *options.DevicesLimits
|
||||||
|
}
|
||||||
|
|
||||||
requestData, err := jsoniter.MarshalToString(updateEntities)
|
requestData, err := jsoniter.MarshalToString(updateEntities)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/containers/podman/v5/pkg/bindings"
|
"github.com/containers/podman/v5/pkg/bindings"
|
||||||
"github.com/containers/podman/v5/pkg/bindings/containers"
|
"github.com/containers/podman/v5/pkg/bindings/containers"
|
||||||
"github.com/containers/podman/v5/pkg/domain/entities/reports"
|
"github.com/containers/podman/v5/pkg/domain/entities/reports"
|
||||||
|
"github.com/containers/podman/v5/pkg/domain/entities/types"
|
||||||
"github.com/containers/podman/v5/pkg/specgen"
|
"github.com/containers/podman/v5/pkg/specgen"
|
||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
@ -802,4 +803,15 @@ var _ = Describe("Podman containers ", func() {
|
|||||||
Expect(c).To(HaveLen(1))
|
Expect(c).To(HaveLen(1))
|
||||||
Expect(c[0].PodName).To(Equal(podName))
|
Expect(c[0].PodName).To(Equal(podName))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("Update container allows for partial updates", func() {
|
||||||
|
var name = "top"
|
||||||
|
_, err := bt.RunTopContainer(&name, nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
_, err = containers.Update(bt.conn, &types.ContainerUpdateOptions{
|
||||||
|
NameOrID: name,
|
||||||
|
})
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user