Skip to content

Commit

Permalink
Disable timeouts by default, make configurable (fix caddyserver#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
mholt committed May 7, 2020
1 parent 446eab4 commit 1eaff74
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 6 additions & 4 deletions builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 3 additions & 1 deletion environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -157,6 +158,7 @@ type environment struct {
plugins []Dependency
caddyModulePath string
tempFolder string
timeoutGoGet time.Duration
}

// Close cleans up the build environment, including deleting
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 1eaff74

Please sign in to comment.