Add fleet reserved variable validation#1134
Add fleet reserved variable validation#1134MichelLosier wants to merge 7 commits intoelastic:mainfrom
Conversation
|
test integrations |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
✅ Files skipped from review due to trivial changes (5)
📝 WalkthroughWalkthroughA new semantic validator 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@code/go/internal/validator/spec.go`:
- Line 233: The semantic validator registration for ValidateFleetReservedVars is
currently unconditional; update its entry in the validator registrations list
(the slice containing {fn: semantic.ValidateFleetReservedVars}) to include the
package types it applies to (e.g., types.Integration or the appropriate types
enum) via a types field and add the since field with the spec version when this
validator was introduced (e.g., "vX.Y.Z"), so the rule is only enforced for the
intended package type(s) and for specs at or after that version.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4c6725de-024d-40e3-b069-bd15b3c09c76
📒 Files selected for processing (29)
code/go/internal/validator/semantic/validate_fleet_reserved_vars.gocode/go/internal/validator/semantic/validate_fleet_reserved_vars_test.gocode/go/internal/validator/spec.gocode/go/pkg/validator/validator_test.gotest/packages/bad_input_fleet_reserved_vars/agent/input/input.yml.hbstest/packages/bad_input_fleet_reserved_vars/changelog.ymltest/packages/bad_input_fleet_reserved_vars/docs/README.mdtest/packages/bad_input_fleet_reserved_vars/manifest.ymltest/packages/bad_integration_fleet_reserved_vars/LICENSE.txttest/packages/bad_integration_fleet_reserved_vars/changelog.ymltest/packages/bad_integration_fleet_reserved_vars/data_stream/sample/agent/stream/stream.yml.hbstest/packages/bad_integration_fleet_reserved_vars/data_stream/sample/fields/base-fields.ymltest/packages/bad_integration_fleet_reserved_vars/data_stream/sample/manifest.ymltest/packages/bad_integration_fleet_reserved_vars/docs/README.mdtest/packages/bad_integration_fleet_reserved_vars/manifest.ymltest/packages/good_input_fleet_reserved_vars/agent/input/input.yml.hbstest/packages/good_input_fleet_reserved_vars/changelog.ymltest/packages/good_input_fleet_reserved_vars/docs/README.mdtest/packages/good_input_fleet_reserved_vars/manifest.ymltest/packages/good_integration_fleet_reserved_vars/LICENSE.txttest/packages/good_integration_fleet_reserved_vars/changelog.ymltest/packages/good_integration_fleet_reserved_vars/data_stream/log/agent/stream/stream.yml.hbstest/packages/good_integration_fleet_reserved_vars/data_stream/log/fields/base-fields.ymltest/packages/good_integration_fleet_reserved_vars/data_stream/log/manifest.ymltest/packages/good_integration_fleet_reserved_vars/data_stream/otel/agent/stream/stream.yml.hbstest/packages/good_integration_fleet_reserved_vars/data_stream/otel/fields/base-fields.ymltest/packages/good_integration_fleet_reserved_vars/data_stream/otel/manifest.ymltest/packages/good_integration_fleet_reserved_vars/docs/README.mdtest/packages/good_integration_fleet_reserved_vars/manifest.yml
|
Created or updated PR in integrations repository to test this version. Check elastic/integrations#18319 |
💚 Build Succeeded
History
|
| } | ||
|
|
||
| for _, ds := range dataStreams { | ||
| manifestPath := dataStreamDir + "/" + ds + "/manifest.yml" |
There was a problem hiding this comment.
i always struggle with path construction between linux/windows. use path.Join instead to avoid slash errors between platforms
There was a problem hiding this comment.
i see the tests passed with this config 🤔 interesting
There was a problem hiding this comment.
oof yes, good catch! 😄
teresaromero
left a comment
There was a problem hiding this comment.
looks good! couple thoughts:
- variables for integrations can be defined also at package root level (vars) and policy template input level (vars), i think we are missing these cases. for input packages is also a vars at root level and the one at the policy templates
- i was thinking if perhaps instead of creating the streams variables and then running again a loop, we could run validation on the only loop when normalizing. this way we just go through once and we can append validation errors on the go, skipping the variables we are not interested. if i read correctly, the streams list have variables we dont even care. wdyt?
What does this PR do?
use_apm, anddata_stream.datasetvariable overrides, which fleet already injects automatically if not present.use_apmboolotelcolinputs of streams that are traces or dynamic_signal_typesdata_stream.datasettextWhere we do injection in fleet, but defer to existing declarations:
Why is it important?
While already allowing integrations to decide on the default value of these special handled variables, these validations make sure that the expected variable types and constraints are observed.
Checklist
test/packagesthat prove my change is effective.spec/changelog.yml.Related issues
use_apmvariable in integration type packages #1100