Documentation
¶
Overview ¶
Package k6foundry contains logic for building k6 binary
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Error compiling binary ErrCompiling = errors.New("compiling") // Error executing go command ErrExecutingGoCommand = errors.New("executing go command") // Go toolchacin is not installed ErrNoGoToolchain = errors.New("go toolchain notfound") // Git is not installed ErrNoGit = errors.New("git notfound") // Error resolving dependency ErrResolvingDependency = errors.New("resolving dependency") // Error initiailizing go build environment ErrSettingGoEnv = errors.New("setting go environment") )
var (
ErrInvalidDependencyFormat = errors.New("invalid dependency format") //nolint:revive
)
var ErrInvalidPlatform = errors.New("invalid platform") //nolint:revive
Functions ¶
This section is empty.
Types ¶
type Foundry ¶ added in v0.4.0
type Foundry interface {
// Build returns a custom k6 binary for the given version including a set of dependencies
// The binary is build fo the given Platform
// The mods parameter is a list of modules to include in the build. Modules can specify its own
// replacement (for example, a local module).
// The replacements parameter is a list of modules to replace in the build. Allows for arbitrary
// replacement of dependencies, used for example in development environments.
// The buildOpts parameter is a list of additional build options to pass to the go build command.
Build(
ctx context.Context,
platform Platform,
k6Version string,
mods []Module,
replacements []Module,
buildOpts []string,
out io.Writer,
) (*BuildInfo, error)
}
Foundry defines the interface for building a k6 binary
func NewDefaultNativeFoundry ¶ added in v0.4.0
NewDefaultNativeFoundry creates a new native build environment with default options
func NewNativeFoundry ¶ added in v0.4.0
func NewNativeFoundry(_ context.Context, opts NativeFoundryOpts) (Foundry, error)
NewNativeFoundry creates a new native build environment with the given options
type GoOpts ¶
type GoOpts struct {
// Environment variables passed to the build service
// Can override variables copied from the current go environment
Env map[string]string
// Copy Environment variables to go build environment
CopyGoEnv bool
// Timeout for getting modules
GoGetTimeout time.Duration
// Timeout for building binary
GOBuildTimeout time.Duration
// Use an ephemeral cache. Ignores GoModCache and GoCache
TmpCache bool
}
GoOpts defines the options for the go build environment
type Module ¶
type Module struct {
// The name (import path) of the go module. If at a version > 1,
// it should contain semantic import version (i.e. "/v2").
// Used with `go get`.
Path string
// The version of the Go module, as used with `go get`.
Version string
// Module replacement
ReplacePath string
// Module replace version
ReplaceVersion string
}
Module reference a go module and its version
func ParseModule ¶
ParseModule parses a module from a string of the form path[@version][=replace[@version]]
type NativeFoundryOpts ¶ added in v0.4.0
type NativeFoundryOpts struct {
// options used for running go
GoOpts
// use alternative k6 repository
K6Repo string
// don't cleanup work environment (useful for debugging)
SkipCleanup bool
// redirect stdout
Stdout io.Writer
// redirect stderr
Stderr io.Writer
// set log level (INFO, WARN, ERROR)
Logger *slog.Logger
}
NativeFoundryOpts defines the options for the Native foundry
type Platform ¶
Platform defines a target OS and architecture for building a custom binary
func NewPlatform ¶
NewPlatform creates a new Platform given the os and arch
func ParsePlatform ¶
ParsePlatform parses a string of the format os/arch and returns the corresponding platform
func RuntimePlatform ¶
func RuntimePlatform() Platform
RuntimePlatform returns the Platform of the current executable
func SupportedPlatforms ¶
func SupportedPlatforms() []Platform
SupportedPlatforms returns a list of supported platforms
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cmd implements the k6foundry command nolint:forbidigo,funlen,nolintlint
|
Package cmd implements the k6foundry command nolint:forbidigo,funlen,nolintlint |
|
k6foundry
command
package main implements the CLI root command for the k6foundry tool
|
package main implements the CLI root command for the k6foundry tool |
|
pkg
|
|
|
testutils/goproxy
Package goproxy implements a go proxy that resolves requests from an in memory go mood cache
|
Package goproxy implements a go proxy that resolves requests from an in memory go mood cache |
|
util
Package util implements helper functions
|
Package util implements helper functions |