refactor(update): clean up actions/update

- move common arguments to a shared struct
- remove unused fields
- fix outdated names
- improve logging/error handling
This commit is contained in:
nils måsén 2024-01-05 22:57:37 +01:00
parent cb8e86d705
commit a6949dede9
4 changed files with 112 additions and 102 deletions

View file

@ -396,7 +396,10 @@ func (client dockerClient) PullImage(ctx context.Context, container t.Container)
return err
}
defer response.Close()
defer func() {
_ = response.Close()
}()
// the pull request will be aborted prematurely unless the response is read
if _, err = io.ReadAll(response); err != nil {
log.Error(err)

View file

@ -6,29 +6,6 @@ import (
log "github.com/sirupsen/logrus"
)
type ExecCommandFunc func(client container.Client, container types.Container)
// ExecutePreCheckCommand tries to run the pre-check lifecycle hook for a single container.
func ExecutePreCheckCommand(client container.Client, container types.Container) {
err := ExecuteLifeCyclePhaseCommand(types.PreCheck, client, container)
if err != nil {
log.WithField("container", container.Name()).Error(err)
}
}
// ExecutePostCheckCommand tries to run the post-check lifecycle hook for a single container.
func ExecutePostCheckCommand(client container.Client, container types.Container) {
err := ExecuteLifeCyclePhaseCommand(types.PostCheck, client, container)
if err != nil {
log.WithField("container", container.Name()).Error(err)
}
}
// ExecutePreUpdateCommand tries to run the pre-update lifecycle hook for a single container.
func ExecutePreUpdateCommand(client container.Client, container types.Container) error {
return ExecuteLifeCyclePhaseCommand(types.PreUpdate, client, container)
}
// ExecutePostUpdateCommand tries to run the post-update lifecycle hook for a single container.
func ExecutePostUpdateCommand(client container.Client, newContainerID types.ContainerID) {
newContainer, err := client.GetContainer(newContainerID)