Skip to content

Commit

Permalink
fix: ensure validate supports map[string] (#22)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?

- This ensures validates doesn't fail on maps, in support of the Headers
field.

## Short description of the changes

- add `map[string]any` as a valid type to the validation function.

Signed-off-by: Alex Boten <[email protected]>
  • Loading branch information
codeboten authored Jan 24, 2025
1 parent 4ce90d4 commit afa8361
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/hpsf/hpsfTypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ func (c *Component) Validate() []error {
case string:
case int:
case bool:
case map[string]any:
default:
results = append(results, validator.NewErrorf("Component %s Property %s Value must be a string, number, or bool", c.Name, p.Name))
results = append(results, validator.NewErrorf("Component %s Property %s Value must be a string, number, bool, or map[string]any", c.Name, p.Name))
}
}
return results
Expand Down
3 changes: 3 additions & 0 deletions pkg/hpsf/hpsfTypes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ func TestHPSF_Validate(t *testing.T) {
value: myhost.com
- name: Port
value: 1234
- name: Headers
value:
"header1": "1234"
connections:
- source:
component: otlp_in
Expand Down

0 comments on commit afa8361

Please sign in to comment.