Documentation
¶
Overview ¶
Package catalog defines the extension catalog
A catalog maps a dependency for k6 extension with optional semantic versioning constrains to the corresponding golang modules.
For example `k6/x/output-kafka:>0.1.0` ==> `github.com/grafana/xk6-output-kafka@v0.2.0`
The catalog is a json file with the following schema:
{ "<dependency>": { "module": "<module path>", "versions": ["<version>", "<version>", ... "<version>"], "cgo": <bool> }, }
where: <dependency>: is the import path for the dependency module: is the path to the go module that implements the dependency versions: is the list of supported versions cgo: is a boolean that indicates if the module requires cgo
Example:
{ "k6": {"module": "go.k6.io/k6", "versions": ["v0.50.0", "v0.51.0"]}, "k6/x/kubernetes": {"module": "github.com/grafana/xk6-kubernetes", "versions": ["v0.8.0","v0.9.0"]}, "k6/x/output-kafka": {"module": "github.com/grafana/xk6-output-kafka", "versions": ["v0.7.0"]}, "k6/x/xk6-sql-driver-sqlite3": {"module": "github.com/grafana/xk6-sql", "cgo": true, "versions": ["v0.1.0"]} }
Index ¶
- Constants
- Variables
- type Catalog
- func DefaultCatalog() (Catalog, error)
- func NewCatalog(ctx context.Context, location string) (Catalog, error)
- func NewCatalogFromFile(catalogFile string) (Catalog, error)
- func NewCatalogFromJSON(stream io.Reader) (Catalog, error)
- func NewCatalogFromURL(ctx context.Context, catalogURL string) (Catalog, error)
- type Dependency
- type Module
Constants ¶
const ( DefaultCatalogFile = "catalog.json" //nolint:revive DefaultCatalogURL = "https://registry.k6.io/catalog.json" //nolint:revive )
Variables ¶
var ( ErrCannotSatisfy = errors.New("cannot satisfy dependency") //nolint:revive ErrDownload = errors.New("downloading catalog") ErrInvalidConstrain = errors.New("invalid constrain") ErrInvalidCatalog = fmt.Errorf("invalid catalog") ErrOpening = errors.New("opening catalog") ErrUnknownDependency = errors.New("unknown dependency") )
Functions ¶
This section is empty.
Types ¶
type Catalog ¶
type Catalog interface { // Resolve returns a Module that satisfies a Dependency Resolve(ctx context.Context, dep Dependency) (Module, error) }
Catalog defines the interface of the extension catalog service
func DefaultCatalog ¶
DefaultCatalog creates a Catalog from the default catalog URL
func NewCatalog ¶
NewCatalog returns a catalog loaded from a location. The location can be a local path or an URL
func NewCatalogFromFile ¶
NewCatalogFromFile creates a Catalog from a json file
func NewCatalogFromJSON ¶
NewCatalogFromJSON creates a Catalog from a json file that follows the [schema](./schema.json):
type Dependency ¶
type Dependency struct { Name string `json:"name,omitempty"` Constrains string `json:"constrains,omitempty"` }
Dependency defines a Dependency with a version constrain Examples: Name: k6/x/k6-kubernetes Constrains * Name: k6/x/k6-output-kafka Constrains >v0.9.0