Simplify conditionals/DRY up the k3d dev script
Main change in this MR is an incremental build of the k3d cluster create
command. This saves us from a mess of nested conditionals and handling every combination of options. It prevents a lot of repetition in the commands used and makes it easier to extend with other k3d options if needed.
Assuming I changed things properly this shouldn't change any behavior, just the under the hood code.
Merge request reports
Activity
added kinddocs label
requested review from @kevin.wilder and @BrandenCobb
assigned to @micah.nagel
added statusreview label
requested review from @brettcharrier
Main driver for this change - Brett was planning to add support for a
-t
option which would modify k3d to add the required mounts for Twistlock defenders.The previous way of handling each option would double the amount of code we need each time we want to add a new option for k3d (you would have to add an
if
/else
every spot that ak3d cluster create
command is). By switching to an incrementally built command we can share the common k3d settings across all cases and add unique parameters with single conditionals without having to worry about combinations of conditionals. This should extend fairly well unless we run into cases where multiple parameters affect the same k3d argument.Edited by Micah Nagelat some point in the future would like to switch the k3d create to a yaml config file.
These changes will make that refactor easier.Edited by kevin.wildermentioned in commit 90dd3f9c