Disable timeouts by default, make configurable (fix #15)

This commit is contained in:
Matthew Holt 2020-05-07 10:21:12 -06:00
parent 446eab4eb6
commit 1eaff742db
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5
2 changed files with 9 additions and 5 deletions

View file

@ -38,6 +38,8 @@ type Builder struct {
CaddyVersion string `json:"caddy_version,omitempty"` CaddyVersion string `json:"caddy_version,omitempty"`
Plugins []Dependency `json:"plugins,omitempty"` Plugins []Dependency `json:"plugins,omitempty"`
Replacements []Replace `json:"replacements,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 // Build builds Caddy at the configured version with the
@ -91,7 +93,7 @@ func (b Builder) Build(ctx context.Context, outputFile string) error {
"-trimpath", "-trimpath",
) )
cmd.Env = env cmd.Env = env
err = buildEnv.runCommand(ctx, cmd, 5*time.Minute) err = buildEnv.runCommand(ctx, cmd, b.TimeoutBuild)
if err != nil { if err != nil {
return err return err
} }

View file

@ -94,6 +94,7 @@ func (b Builder) newEnvironment(ctx context.Context) (*environment, error) {
plugins: b.Plugins, plugins: b.Plugins,
caddyModulePath: caddyModulePath, caddyModulePath: caddyModulePath,
tempFolder: tempFolder, tempFolder: tempFolder,
timeoutGoGet: b.TimeoutGet,
} }
// initialize the go module // initialize the go module
@ -157,6 +158,7 @@ type environment struct {
plugins []Dependency plugins []Dependency
caddyModulePath string caddyModulePath string
tempFolder string tempFolder string
timeoutGoGet time.Duration
} }
// Close cleans up the build environment, including deleting // Close cleans up the build environment, including deleting
@ -226,7 +228,7 @@ func (env environment) execGoGet(ctx context.Context, modulePath, moduleVersion
mod += "@" + moduleVersion mod += "@" + moduleVersion
} }
cmd := env.newCommand("go", "get", "-d", "-v", mod) 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 { type goModTemplateContext struct {