From 1eaff742dbcf4caa1a3bb7553de191d6e3d61f6d Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Thu, 7 May 2020 10:21:12 -0600 Subject: [PATCH] Disable timeouts by default, make configurable (fix #15) --- builder.go | 10 ++++++---- environment.go | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/builder.go b/builder.go index a235d7f..e8f3247 100644 --- a/builder.go +++ b/builder.go @@ -35,9 +35,11 @@ import ( // configuration it represents. type Builder struct { Compile - CaddyVersion string `json:"caddy_version,omitempty"` - Plugins []Dependency `json:"plugins,omitempty"` - Replacements []Replace `json:"replacements,omitempty"` + CaddyVersion string `json:"caddy_version,omitempty"` + Plugins []Dependency `json:"plugins,omitempty"` + Replacements []Replace `json:"replacements,omitempty"` + TimeoutGet time.Duration `json:"timeout_get,omitempty"` + TimeoutBuild time.Duration `json:"timeout_build,omitempty"` } // Build builds Caddy at the configured version with the @@ -91,7 +93,7 @@ func (b Builder) Build(ctx context.Context, outputFile string) error { "-trimpath", ) cmd.Env = env - err = buildEnv.runCommand(ctx, cmd, 5*time.Minute) + err = buildEnv.runCommand(ctx, cmd, b.TimeoutBuild) if err != nil { return err } diff --git a/environment.go b/environment.go index 4c34700..b3ca474 100644 --- a/environment.go +++ b/environment.go @@ -94,6 +94,7 @@ func (b Builder) newEnvironment(ctx context.Context) (*environment, error) { plugins: b.Plugins, caddyModulePath: caddyModulePath, tempFolder: tempFolder, + timeoutGoGet: b.TimeoutGet, } // initialize the go module @@ -157,6 +158,7 @@ type environment struct { plugins []Dependency caddyModulePath string tempFolder string + timeoutGoGet time.Duration } // Close cleans up the build environment, including deleting @@ -226,7 +228,7 @@ func (env environment) execGoGet(ctx context.Context, modulePath, moduleVersion mod += "@" + moduleVersion } cmd := env.newCommand("go", "get", "-d", "-v", mod) - return env.runCommand(ctx, cmd, 5*time.Minute) + return env.runCommand(ctx, cmd, env.timeoutGoGet) } type goModTemplateContext struct {