Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/vikashchauhan51/k6-jsonnet
- Owner: VikashChauhan51
- License: mit
- Created: 2024-03-03T01:27:39.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-03-03T08:08:42.000Z (10 months ago)
- Last Synced: 2024-06-21T14:22:06.398Z (7 months 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/[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)