Documentation
¶
Index ¶
- Constants
- func CreateBuildContext(functionName string, handler string, language string, copyExtraPaths []string, ...) (string, error)
- func MakeTar(tarPath string, context string, buildConfig *BuildConfig) error
- type BuildConfig
- type BuildContextConfig
- type BuildContextOption
- type BuildResult
- type BuilderOption
- type FunctionBuilder
Constants ¶
const ( DefaultTemplateDir = "./template" DefaultTemplateHandler = "function" DefaultBuildDir = "./build" )
const BuilderConfigFileName = "com.openfaas.docker.config"
Variables ¶
This section is empty.
Functions ¶
func CreateBuildContext ¶
func CreateBuildContext(functionName string, handler string, language string, copyExtraPaths []string, options ...BuildContextOption) (string, error)
CreateBuildContext create a Docker build context using the provided function handler and language template.
Parameters:
- functionName: name of the function.
- handler: path to the function handler.
- language: name of the language template to use.
- copyExtraPaths: additional paths to copy into the function handler folder. Paths should be relative to the current directory. Any paths outside if this directory will be skipped.
By default templates are looked up in the `./template` directory. The path the the template directory can be overridden by setting the `builder.WithTemplateDir` option. CreateBuildContext overlays the function handler in the `function` folder of the template by default. This setting can be overridden by setting the `builder.WithHandlerOverlay` option.
The function returns the path to the build context, `./build/<functionName>` by default. The build directory can be overridden by setting the `builder.WithBuildDir` option. An error is returned if creating the build context fails.
Types ¶
type BuildConfig ¶
type BuildContextConfig ¶
type BuildContextOption ¶
type BuildContextOption func(*BuildContextConfig)
func WithBuildDir ¶
func WithBuildDir(path string) BuildContextOption
WithBuildDir is an option to configure the directory the build context is created in. If this options is not set a default path `./build` is used.
func WithHandlerOverlay ¶
func WithHandlerOverlay(path string) BuildContextOption
WithHandlerOverlay is an option to configure the path where the function handler needs to be overlayed in the template. If this option is not set a default overlay path `function` is used.
func WithTemplateDir ¶
func WithTemplateDir(path string) BuildContextOption
WithTemplateDir is an option to configure the directory where the build template is looked up. If this option is not set a default path `./template` is used.
type BuildResult ¶
type BuilderOption ¶
type BuilderOption func(*FunctionBuilder)
func WithHmacAuth ¶
func WithHmacAuth(secret string) BuilderOption
WithHmacAuth configures the HMAC secret used to sign request payloads to the builder API.
type FunctionBuilder ¶
type FunctionBuilder struct {
// URL of the OpenFaaS Builder API.
URL *url.URL
// contains filtered or unexported fields
}
func NewFunctionBuilder ¶
func NewFunctionBuilder(url *url.URL, client *http.Client, options ...BuilderOption) *FunctionBuilder
NewFunctionBuilder create a new builder for building OpenFaaS functions using the Function Builder API.
func (*FunctionBuilder) Build ¶
func (b *FunctionBuilder) Build(tarPath string) (BuildResult, error)
Build invokes the function builder API with the provided tar archive containing the build config and context to build and push a function image.