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

@ -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
}

View file

@ -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 {