k3d icon indicating copy to clipboard operation
k3d copied to clipboard

[REFACTOR] Cleanup Runtime interface and introduce functional options pattern

Open iwilltry42 opened this issue 3 years ago • 0 comments

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:

  • GetVolume doesn't work as it expects a name and returns a single string
  • new GetVolumesByLabel needs to be introduced, adding even more cruft to the Runtime interface

Potential Solution:

  • GetVolumes or ListVolumes should replace GetVolume and have a variadic opt ...ListOpt parameter that can be e.g. WithLabelFilter to return a list of volumes filtered by the label
    • the current GetVolume functionality would then be represented by GetVolumes(WithNameFilter("volume-foo"))

Notes

  • this would also replace the various implementations of different opts, e.g. ClusterStartOpts

iwilltry42 avatar Jan 03 '22 10:01 iwilltry42