-
Notifications
You must be signed in to change notification settings - Fork 95
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
refactor(template): Introduce new File and InMemory Templates #1197
Conversation
5a647eb
to
547de17
Compare
Test Results 2 files ± 0 220 suites ±0 16s ⏱️ ±0s Results for commit 99b1022. ± Comparison against base commit 44d82db. This pull request removes 10 and adds 2 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
ac502f0
to
6127a30
Compare
6127a30
to
d2a838a
Compare
d2a838a
to
2f21fe1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having ID()
method that returns differnet value for different implementation for me is problematic
7342ab1
to
99b1022
Compare
99b1022
to
7b87e56
Compare
Unit Test Results 2 files ± 0 220 suites ±0 17s ⏱️ ±0s Results for commit a4511cf. ± Comparison against base commit de70797. This pull request removes 10 and adds 2 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
The updated FileBasedTemplate loads file contents only when required, instead of at creation, reducing the long term in-use memory footprint of configurations. The new InMemoryTemplate replaces the Download specific template, as well as some dedicated test implementations of templates. It currently carries an optional filepath, which is used for writing converted templates to the desired target file.
Method signatures are refactored to return now possible teplate read/write errors. Additionally unused coordinate returns are removed.
%q does not only quote the variable's content, but also makes it 'safe'. It's not clearly defined in the golang docs, but backslashes are escaped as well. To properly render the error, we need to quote the string ourselves and print the string using %s
Also fix spelling of Id() to ID()
…er persisted FileBasedTemplate is only used when a config was loaded from a file (in deployments), and these types of Templates will never be passed to the config writer. Only download and conversion will ever persist their configurations, and both create InMemoryTemplates. To simplify the persistence code and don't make it look like we ever persist FileBasedTemplates, the codepath is simply removed. If an unexpected type of Template still get's passed to the Writer, an error is returned. If we ever extend Templates and don't implement persistence logic, we'll get an error. As the interface already includes an error return and we won't notice this on compile, an error was chosen over a hard-exit by panicking.
7b87e56
to
a4511cf
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
What this PR does / Why we need it:
The updated FileBasedTemplate loads file contents only when required, instead of at creation, reducing the long term in-use memory footprint
of configurations.
The new InMemoryTemplate replaces the Download specific template, as well as some dedicated test implementations of templates. It currently carries an optional filepath, which is used for writing converted templates to the desired target file. This may be split off.
Special notes for your reviewer:
It might instead make sense to have dedicated template implementations in
Does this PR introduce a user-facing change?
No visible change, template files are loaded from disk later.