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

Merge confgen & main models (#254) #267

Merged
merged 8 commits into from
Jul 29, 2022
Merged

Conversation

jotak
Copy link
Member

@jotak jotak commented Jul 26, 2022

Use main model in confgen, use pipeline builder

Note, changes required in NOO

Fixes #254

  • Confgen: init from options (avoid many globals, so it's less error prone on consumers)
  • Removed duplicated confgen model
  • Use PipelineBuilder to simplify pipeline generation
  • Make confgen easier to consume as a lib (e.g. for NOO)
    • Do not make it necessary to call "Run": parsing definition files
      should be sufficient
    • Do not make it necessary to work with files written on disk: work
      with []byte instead
  • SkipWithTags should not result in an error when a file is skipped
  • Add confgen tests

Copy link
Collaborator

@ronensc ronensc left a comment

Choose a reason for hiding this comment

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

Thanks for refactoring and cleaning up the code :)

pkg/config/pipeline_builder.go Show resolved Hide resolved
Comment on lines 56 to 59
return map[string]interface{}{
"log-level": "error",
"pipeline": pipeline.GetStages(),
"parameters": pipeline.GetStageParams(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we extract the field names to a struct? (something like the removed ConfigFileStruct)
It could also replace the Output type in the tests:

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point I'll take it back.

Copy link
Member Author

Choose a reason for hiding this comment

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

(but now I want to also remove globals from config 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the replacement of the Output type in the tests was missed.

pkg/confgen/confgen_test.go Outdated Show resolved Hide resolved
pkg/confgen/flowlogs2metrics_config.go Show resolved Hide resolved
@jotak
Copy link
Member Author

jotak commented Jul 27, 2022

@ronensc feedback addressed .. I actually ended up doing more changes in order to remove globals from config.go. They are replaced with explicit arguments, which helps to understand what's expected from the consuming side

@codecov-commenter
Copy link

codecov-commenter commented Jul 27, 2022

Codecov Report

Merging #267 (622c99e) into main (d104d33) will increase coverage by 6.31%.
The diff coverage is 72.98%.

@@            Coverage Diff             @@
##             main     #267      +/-   ##
==========================================
+ Coverage   60.40%   66.72%   +6.31%     
==========================================
  Files          72       73       +1     
  Lines        4213     4144      -69     
==========================================
+ Hits         2545     2765     +220     
+ Misses       1501     1199     -302     
- Partials      167      180      +13     
Flag Coverage Δ
unittests 66.72% <72.98%> (+6.31%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
cmd/confgenerator/main.go 0.00% <0.00%> (ø)
cmd/flowlogs-pipeline/main.go 0.00% <0.00%> (ø)
pkg/confgen/config.go 33.33% <0.00%> (ø)
pkg/confgen/grafana_jsonnet.go 44.44% <33.33%> (+44.44%) ⬆️
pkg/confgen/confgen.go 49.20% <61.29%> (+5.72%) ⬆️
pkg/pipeline/write/write_loki.go 66.11% <66.66%> (+1.27%) ⬆️
pkg/test/utils.go 64.70% <66.66%> (+1.74%) ⬆️
pkg/config/pipeline_builder.go 87.27% <69.56%> (-8.19%) ⬇️
pkg/config/config.go 55.55% <81.81%> (+5.55%) ⬆️
pkg/confgen/flowlogs2metrics_config.go 77.41% <90.69%> (+77.41%) ⬆️
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d104d33...622c99e. Read the comment docs.

pkg/config/config.go Outdated Show resolved Hide resolved
jotak and others added 8 commits July 29, 2022 09:55
Fixes netobserv#254

- Removed duplicated confgen model
- Use PipelineBuilder to simplify pipeline generation
- Make confgen easier to consume as a lib (e.g. for NOO)
  - Do not make it necessary to call "Run": parsing definition files
    should be sufficient
  - Do not make it necessary to work with files written on disk: work
    with []byte instead
- SkipWithTags should not result in an error when a file is skipped
- Add confgen tests
A side-effect of removing globals in write_loki is that it changes how
the config is read, and set with defaults. Instead of unmarshaling a
second time to automatically get defaults, we now call an explicit function
that sets the default. Also, now removing loki URL default, it now has
to be set explicitely
Also fixed jsonnet dir actually used as filename prefix rather than
directory
Co-authored-by: Ronen Schaffer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reuse API data structures in confgen
3 participants