forked from kube-burner/kube-burner
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add method to import custom template rendering functions (kube-burner…
…#727) ## Type of change - [ ] Refactor - [x] New feature - [ ] Bug fix - [ ] Optimization - [ ] Documentation Update ## Description New method to import custom rendering template functions from external implementations. ## Related Tickets & Documents - Related Issue # - Closes # --------- Signed-off-by: Raul Sevilla <[email protected]>
- Loading branch information
1 parent
da1ae46
commit 14015b0
Showing
3 changed files
with
43 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Kube-burner wrappers | ||
|
||
It's possible to extend and take advantage of the kube-burner's features by developing wrappers. A kube-burner wrapper is basically a new binary that uses some of the exposed functions and interfaces of kube-burner. | ||
|
||
## Helper functions | ||
|
||
There're some helper functions meant to be consumed by wrappers in the `workloads` package. These functions provide some shortcuts to incorporate workloads in golang embedded filesystems. | ||
|
||
## Customizing template rendering | ||
|
||
It's possible to provide custom template rendering functions from a wrapper, this can be done by calling the function `AddRenderingFunction()` of the util package. For example: | ||
|
||
```golang | ||
util.AddRenderingFunction("isEven", func(n int) bool { | ||
return n%2 == 0 | ||
}) | ||
``` | ||
|
||
With the above code snippet we're provisioning a new template rendering function `isEven`, that basically returns true or false depending if the provided number is even. This function can be consumed in any of the kube-burner configuration files, for example | ||
|
||
```yaml | ||
jobs: | ||
- name: job | ||
podWait: {{ isEven 5 }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters