Close docker client (#789)
* Close docker client! * Fix nil dereference * Update run_context.go * Bump Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
@@ -38,6 +38,7 @@ func NewDockerBuildExecutor(input NewDockerBuildExecutorInput) common.Executor {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer cli.Close()
|
||||
|
||||
logger.Debugf("Building image from '%v'", input.ContextDir)
|
||||
|
||||
|
@@ -15,6 +15,7 @@ func ImageExistsLocally(ctx context.Context, imageName string, platform string)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer cli.Close()
|
||||
|
||||
filters := filters.NewArgs()
|
||||
filters.Add("reference", imageName)
|
||||
|
@@ -57,6 +57,7 @@ func NewDockerPullExecutor(input NewDockerPullExecutorInput) common.Executor {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer cli.Close()
|
||||
|
||||
imagePullOptions, err := getImagePullOptions(ctx, input)
|
||||
if err != nil {
|
||||
|
@@ -76,6 +76,7 @@ type Container interface {
|
||||
UpdateFromImageEnv(env *map[string]string) common.Executor
|
||||
UpdateFromPath(env *map[string]string) common.Executor
|
||||
Remove() common.Executor
|
||||
Close() common.Executor
|
||||
}
|
||||
|
||||
// NewContainer creates a reference to a container
|
||||
@@ -246,6 +247,16 @@ func (cr *containerReference) connect() common.Executor {
|
||||
}
|
||||
}
|
||||
|
||||
func (cr *containerReference) Close() common.Executor {
|
||||
return func(ctx context.Context) error {
|
||||
if cr.cli != nil {
|
||||
cr.cli.Close()
|
||||
cr.cli = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (cr *containerReference) find() common.Executor {
|
||||
return func(ctx context.Context) error {
|
||||
if cr.id != "" {
|
||||
|
@@ -13,6 +13,7 @@ func NewDockerVolumeRemoveExecutor(volume string, force bool) common.Executor {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer cli.Close()
|
||||
|
||||
list, err := cli.VolumeList(ctx, filters.NewArgs())
|
||||
if err != nil {
|
||||
@@ -43,6 +44,7 @@ func removeExecutor(volume string, force bool) common.Executor {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer cli.Close()
|
||||
|
||||
return cli.VolumeRemove(ctx, volume, force)
|
||||
}
|
||||
|
Reference in New Issue
Block a user