k3d
k3d copied to clipboard
[REFACTOR] Cleanup Runtime interface and introduce functional options pattern
The Runtime interface is super convoluted and not pretty to extend.
It would be cooler to clean it up and introduce the functional options pattern for easier extensibility.
Example:
- Objective: Add functionality to handle volume lifecycle together with cluster
- Required additional functionality: Get all volumes belonging to this cluster by label
cluster=<clustername>
Now:
GetVolumedoesn't work as it expects a name and returns a single string- new
GetVolumesByLabelneeds to be introduced, adding even more cruft to the Runtime interface
Potential Solution:
GetVolumesorListVolumesshould replaceGetVolumeand have a variadicopt ...ListOptparameter that can be e.g.WithLabelFilterto return a list of volumes filtered by the label- the current
GetVolumefunctionality would then be represented byGetVolumes(WithNameFilter("volume-foo"))
- the current
Notes
- this would also replace the various implementations of different opts, e.g.
ClusterStartOpts