Skip to content

Conversation

kcreddy
Copy link
Contributor

@kcreddy kcreddy commented Aug 14, 2025

With glob + file helpers, we can read from multiple files matching a pattern.

Closes #161

@kcreddy kcreddy changed the title http mock server: Added globs template helper function for iterating over multiple files. http mock server: Added globs template helper function for iterating over multiple files Aug 14, 2025
@kcreddy kcreddy changed the title http mock server: Added globs template helper function for iterating over multiple files http mock server: Added glob template helper function for iterating over multiple files Aug 14, 2025
@kcreddy kcreddy changed the title http mock server: Added glob template helper function for iterating over multiple files http mock server: Added glob template helper function Aug 14, 2025
@kcreddy kcreddy requested a review from efd6 August 14, 2025 11:09
@kcreddy kcreddy self-assigned this Aug 14, 2025
@kcreddy kcreddy added Team:Security-Service Integrations Team:Security-Service Integrations enhancement New feature or request labels Aug 14, 2025
README.md Outdated
@@ -87,6 +87,7 @@ When using [Go templates](https://golang.org/pkg/text/template/) as part of the
- `env KEY`: function that returns the KEY from environment.
- `sum A B`: function that returns the sum of numbers A and B (only for integers).
- `file PATH`: function that returns the contents of the file at PATH.
- `glob PATTERN`: function that returns the names of all files matching PATTERN.
Copy link
Contributor

@efd6 efd6 Aug 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `glob PATTERN`: function that returns the names of all files matching PATTERN.
- `glob PATTERN`: function that returns the names of all files matching glob PATTERN (see [filepath.Match](https://pkg.go.dev/path/filepath#Match) for syntax).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in e832836

@@ -51,6 +52,7 @@ func (t *tpl) Unpack(in string) error {
"hostname": hostname,
"sum": sum,
"file": file,
"glob": glob,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could write:

			"glob":        filepath.Glob,

Copy link
Contributor Author

@kcreddy kcreddy Aug 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. Updated in e832836

@kcreddy kcreddy requested review from efd6 and andrewkroh August 16, 2025 16:32
@elasticmachine
Copy link

💚 Build Succeeded

History

cc @kcreddy

@kcreddy kcreddy merged commit f6cfcf2 into elastic:main Aug 19, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Team:Security-Service Integrations Team:Security-Service Integrations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add glob template helper function
4 participants