Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore core. properties in validator #106

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func ValidateSectionWithSchema(kind SectionKind, props property.Properties, sche
}

for _, p := range props {
if isCommonProperty(p.Key) || isCloudVariable(p.Key) || isCloudVariable(p.Value) {
if isCommonProperty(p.Key) || isCloudVariable(p.Key) || isCloudVariable(p.Value) || isCoreProperty(p.Key) {
continue
}

Expand Down Expand Up @@ -134,6 +134,13 @@ func areProcessors(key string) bool {
return strings.ToLower(key) == "processors"
}

// isCoreProperty tells whether the property is from Core.
// Core properties start with `core.` and are ignored.
// See https://github.com/chronosphereio/calyptia-core-fluent-bit/blob/71795c472bcb1f7e09a7ea121366d5f91df4263f/patches/pwhelan-flb_config-ignore-core-namespaced-properties.patch#L22-L25
func isCoreProperty(key string) bool {
return strings.HasPrefix(key, "core.")
}

func validateProcessorsSectionMaps(sectionMaps []interface{}) error {
for _, section := range sectionMaps {
props := property.Properties{}
Expand Down
10 changes: 10 additions & 0 deletions validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,16 @@ func TestConfig_Validate(t *testing.T) {
query SELECT 'hello from sqldb' AS message
`,
},
{
name: "custom_core_property",
ini: `
[INPUT]
Name dummy
[OUTPUT]
Name s3
core.metadata name=foo
`,
},
}
for _, tc := range tt {
t.Run(tc.name, func(t *testing.T) {
Expand Down