Skip to content

Commit

Permalink
added any support to inject
Browse files Browse the repository at this point in the history
  • Loading branch information
ugol committed Jul 19, 2024
1 parent 74db1ed commit 3878383
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions pkg/functions/functionsDescription.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,10 +558,10 @@ var funcDesc = map[string]FunctionDescription{
Name: "inject",
Category: "utilities",
Description: "inject a string with a given probability between 0 (never) and 1 (always): useful to inject errors",
Parameters: "probability float64, injected string, original string",
Parameters: "probability float64, injected any, original any",
Localizable: false,
Return: "string",
Example: "jr template run --embedded '{{$bad:=regex \"[A-Z]{5}\"}}{{city | inject 0.5 $bad }}'",
Return: "any",
Example: "jr template run --embedded '{{$bad_city:=regex \"[A-Z]{5}\"}}{{city | inject 0.5 $bad_city}}'",
Output: "Portland|ZPTAC",
},
"integer": {
Expand Down
4 changes: 2 additions & 2 deletions pkg/functions/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ func Contains(s []string, str string) bool {
return false
}

// Inject is used to inject a different string value with a given probability, typically used to generate a bad value
func Inject(probability float64, injected, original string) string {
// Inject is used to inject a different value with a given probability, typically used to generate a bad value
func Inject(probability float64, injected, original any) any {
if Random.Float64() < probability {
return injected
}
Expand Down

0 comments on commit 3878383

Please sign in to comment.