Documentation
¶
Overview ¶
Package k6provision contains a k6 binary provisioning library. The purpose of the k6provision library is to provision k6 executables with extensions based on dependencies.
Index ¶
Examples ¶
Constants ¶
View Source
const DefaultExtensionCatalogURL = "https://registry.k6.io/catalog.json"
DefaultExtensionCatalogURL contains the address of the default k6 extension catalog.
View Source
const ExeName = k6Exe
ExeName contains the name of the k6 executable. Its value is "k6.exe" for Windows, otherwise "k6".
Variables ¶
View Source
var ( // ErrDownload is returned if an error occurs during download. ErrDownload = errors.New("download error") // ErrBuild is returned if an error occurs during build. ErrBuild = errors.New("build error") // ErrCache is returned if an error occurs during cache handling. ErrCache = errors.New("cache error") )
Functions ¶
func Provision ¶
Provision provisions a k6 executable with extensions based on dependencies.
Example ¶
package main
import (
"bytes"
"context"
"os"
"os/exec"
"path/filepath"
"github.com/grafana/k6deps"
"github.com/grafana/k6provision"
)
const depsStr = `k6=0.56.0;k6/x/faker=0.4.1;k6/x/sql=1.0.1;k6/x/sql/driver/ramsql=0.1.0`
func main() {
deps := k6deps.Dependencies{}
_ = deps.UnmarshalText([]byte(depsStr))
exe, _ := filepath.Abs(k6provision.ExeName) // k6 or k6.exe
_ = k6provision.Provision(context.TODO(), deps, exe, nil)
cmd := exec.Command(exe, "version") //nolint
out, _ := cmd.CombinedOutput()
_, _ = os.Stdout.Write(out[bytes.Index(out, []byte("Extensions:")):]) //nolint
}
Output: Extensions: github.com/grafana/xk6-faker v0.4.1, k6/x/faker [js] github.com/grafana/xk6-sql v1.0.1, k6/x/sql [js] github.com/grafana/xk6-sql v1.0.1, k6/x/sql/driver/ramsql [js]
Types ¶
type Options ¶
type Options struct {
// AppName contains the name of the application. It is used to define the default value of CacheDir.
// If empty, it defaults to os.Args[0].
AppName string
// CacheDir specifies the name of the directory where the cacheable files can be cached.
// Its default is determined based on the XDG Base Directory Specification.
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
CacheDir string
// Client is used during HTTP communication with the build service.
// If absent, http.DefaultClient will be used.
Client *http.Client
// ExtensionCatalogURL contains the URL of the k6 extension catalog to be used.
// If absent, DefaultExtensionCatalogURL will be used.
ExtensionCatalogURL *url.URL
// BuildServiceURL contains the URL of the k6 build service to be used.
// If the value is not nil, the k6 binary is built using the build service instead of the local build.
BuildServiceURL *url.URL
}
Options contains the optional parameters of the Command function.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cmd contains k6provision cobra command factory function.
|
Package cmd contains k6provision cobra command factory function. |
|
k6provision
command
Package main contains the main function for k6deps CLI tool.
|
Package main contains the main function for k6deps CLI tool. |
|
tools
|
|
|
gendoc
command
Package main contains CLI documentation generator tool.
|
Package main contains CLI documentation generator tool. |
Click to show internal directories.
Click to hide internal directories.