Pass along containerd config as return value #4160
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Pass along containerd config as return value
Return the containerd config as a string instead of having the configurer write it to disk. This reduces the number of struct fields required by the configurer, and makes testing less dependent on the file system.
Let the containerd component write the file instead.
Remove the hard-coded string literal for the paths to containerd-cri.toml and use k0s' RunDir instead. This already takes into account the differences between Windows and UNIX-like operating systems, and also takes into account the different defaults when running as non-root user.
Remove the escapedPath function and inline it directly before the containerd component generates the template.
Use toml.Marshal to generate default CRI config
This is more convenient and removes the necessity to declare some one-shot writer variable to get the marshalled data. Moreover, make this a free-standing function, so it's more obvious that the default config is solely dependent on the pause image.
Simplify hasCRIPluginConfig
Refactor CRI config tests
The two tests "should merge CRI configs" and "should have single import for all CRI configs" were nearly doing the same. One of them was missing two assertions. Combine them into one test.
srvconfig
import alias to the more idiomaticserverconfig
require
toassert
in certain test assertions to continue execution after a failure, allowing for more comprehensive test feedback.Type of change
How Has This Been Tested?
Checklist: