Add config option for import timeout (#421)

Signed-off-by: Dan Luhring <dan.luhring@anchore.com>
This commit is contained in:
Dan Luhring
2021-05-25 15:01:02 -04:00
committed by GitHub
parent 17bbf840cf
commit 80e23bdb50
4 changed files with 17 additions and 2 deletions
+3 -1
View File
@@ -27,6 +27,7 @@ type ImportConfig struct {
Dockerfile []byte
OverwriteExistingUpload bool
Scope source.Scope
Timeout uint
}
func importProgress(source string) (*progress.Stage, *progress.Manual) {
@@ -54,7 +55,8 @@ func importProgress(source string) (*progress.Stage, *progress.Manual) {
func (c *Client) Import(ctx context.Context, cfg ImportConfig) error {
stage, prog := importProgress(c.config.BaseURL)
ctxWithTimeout, cancel := context.WithTimeout(ctx, time.Second*30)
timeout := time.Duration(cfg.Timeout) * time.Second
ctxWithTimeout, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
authedCtx := c.newRequestContext(ctxWithTimeout)