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: over 1 year ago
JSON representation
k6 jsonnet extension
- Host: GitHub
- URL: https://github.com/vikashchauhan51/k6-jsonnet
- Owner: VikashChauhan51
- License: mit
- Created: 2024-03-03T01:27:39.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-03T08:08:42.000Z (about 2 years ago)
- Last Synced: 2025-01-05T17:26:26.828Z (over 1 year ago)
- Topics: go, golang, jsonnet, jsonnet-lib, k6, k6-extension
- Language: Go
- Homepage:
- Size: 21.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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/k6-jsonnet@v0.1.0
or
# latest version
xk6 build --with github.com/VikashChauhan51/k6-jsonnet@latest
```
## Run sample script
```cmd
./k6 run examples/main.js
```
## Result
