support $INPUT_REMAP_FILE

This commit is contained in:
Bel LaPointe
2023-03-02 15:33:52 -07:00
parent b0767818e2
commit 74e54c4efa
4 changed files with 88 additions and 1 deletions

View File

@@ -12,7 +12,7 @@ type Input interface {
func New(ctx context.Context) Input {
foo := randomCharFromRange('a', 'g')
if p, ok := os.LookupEnv("INPUT_RANDOM_WEIGHT_FILE"); ok {
if p, ok := os.LookupEnv("INPUT_RANDOM_WEIGHT_FILE"); ok && len(p) > 0 {
foo = randomCharFromWeightFile(p)
}
var result Input = NewRandom(foo)
@@ -22,5 +22,8 @@ func New(ctx context.Context) Input {
if os.Getenv("INPUT_BUFFERED") == "true" {
result = NewBuffered(ctx, result)
}
if p, ok := os.LookupEnv("INPUT_REMAP_FILE"); ok && len(p) > 0 {
result = NewRemapFromFile(result, p)
}
return result
}