Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
(GH-35) Add timeout duration to context used by Docker client
Browse files Browse the repository at this point in the history
  • Loading branch information
da-ar committed Dec 9, 2021
1 parent 4085db8 commit 2b8d763
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/prm/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"path/filepath"
"strings"
"time"

"github.com/Masterminds/semver"
"github.com/docker/docker/api/types"
Expand All @@ -24,8 +25,9 @@ import (

type Docker struct {
// We need to be able to mock the docker client in testing
Client DockerClientI
Context context.Context
Client DockerClientI
Context context.Context
ContextCancel func()
}

type DockerClientI interface {
Expand Down Expand Up @@ -316,8 +318,11 @@ func (d *Docker) initClient() (err error) {
return err
}

ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)

d.Client = cli
d.Context = context.Background()
d.Context = ctx
d.ContextCancel = cancel
}
return nil
}
Expand Down

0 comments on commit 2b8d763

Please sign in to comment.