Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/vikashchauhan51/k6-jsonnet

k6 jsonnet extension
https://github.com/vikashchauhan51/k6-jsonnet

go golang jsonnet jsonnet-lib k6 k6-extension

Last synced: about 2 months ago
JSON representation

k6 jsonnet extension

Awesome Lists containing this project

README

        

# k6-jsonnet
k6 [jsonnet](https://jsonnet.org/) extension.

## Usage
```js
import jsonnet from 'k6/x/jsonnet';

export default function () {
const jsonnetTemplate = '{ "hello": "world" }';
const jsonStr = jsonnet.evaluateJsonnet(jsonnetTemplate);
console.log(jsonStr);
}

```

## API
Functions:
----
### evaluateJsonnet
- evaluateJsonnet(`jsonnetTemplate`: *string*): *string*
- It will take `jsonnet` template string and return `json` object string after evaluate the template.

## Build it
To build a `k6` binary with this extension, first ensure you have the prerequisites:
- [Go toolchain](https://go101.org/article/go-toolchain.html).
- [Git](https://git-scm.com/).

Then:

1. Install xk6:
```cmd
go install go.k6.io/xk6/cmd/xk6@latest
```
2. Build the binary:
```cmd
# specific tag version
xk6 build --with github.com/VikashChauhan51/[email protected]
or
# latest version
xk6 build --with github.com/VikashChauhan51/k6-jsonnet@latest
```

## Run sample script

```cmd
./k6 run examples/main.js

```

## Result
![image](https://github.com/VikashChauhan51/k6-jsonnet/assets/14816038/936550a2-c43f-4070-8f0c-103cef4188cc)