Beispiel #1
0
// PrepareBuild prepares a custombuild.Builder for generating a custom binary using
// plugins. A call to Build on the returned builder will generate the binary.
// If error is not nil, the returned Builder should be ignored.
func PrepareBuild(plugins features.Plugins, pullLatest bool) (custombuild.Builder, error) {
	// create builder
	builder, err := custombuild.NewUnready(CaddyPackage, gen(plugins), plugins.Packages())
	if err != nil {
		return builder, err
	}

	builder.UseNetworkForAll(pullLatest) // if true, run go get -u for all dependencies before each build

	err = builder.Setup()
	if err != nil {
		// not useful, clear assets
		go builder.Teardown()
		return builder, err
	}

	// necessary to ensure import "github.com/mholt/caddy..." is referencing
	// this code.
	err = builder.SetImportPath(CaddyPackage)
	if err != nil {
		// not useful, clear assets
		go builder.Teardown()
		return builder, err
	}

	// set subpackage
	builder.SubPackage = "caddy"
	return builder, nil
}
Beispiel #2
0
// PrepareBuild prepares a custombuild.Builder for generating a custom binary using
// middlewares. A call to Build on the returned builder will generate the binary.
// If error is not nil, the returned Builder should be ignored.
func PrepareBuild(middlewares features.Middlewares) (custombuild.Builder, error) {
	// create builder
	builder, err := custombuild.NewUnready(CaddyPackage, gen(middlewares), middlewares.Packages())
	if err != nil {
		return builder, err
	}

	// TODO make this configurable and enable only for dev
	builder.UseNetworkForAll(false)

	err = builder.Setup()
	if err != nil {
		// not useful, clear assets
		go builder.Teardown()
		return builder, err
	}

	// necessary to ensure import "github.com/mholt/caddy..." is referencing
	// this code.
	err = builder.SetImportPath(CaddyPackage)
	if err != nil {
		// not useful, clear assets
		go builder.Teardown()
		return builder, err
	}

	return builder, nil
}