kube-object-storage / lib-bucket-provisioner

Library for the dynamic provisioning of object store buckets to be used by object store providers.
Apache License 2.0
20 stars 22 forks source link

Extensible Provisioner Constructor #113

Open copejon opened 5 years ago

copejon commented 5 years ago

As the library gains use, the provisioner constructor function's signature continues to change. This is due in large part to a desire to make the library more configurable. This also means that each new feature that requires a change to the function signature breaks existing callers.

Instead of configuration being handled via unique parameters, a more flexible method should be implemented. A simple solution would be a config struct which is passed as a parameter to the constructor. Nil values should have a default meaning. e.g.:

type Provisioner struct {
    config *config
}

type config struct {
    namespace string
    logger logr.Logger
    kubeconfig *rest.Config
    ...
}

func NewProvisioner(
    provisionerName string,
    provisioner api.Provisioner,
    config
) (*Provisioner, error) { ... }

There are also chaining solutions using simple functions to define the target config. Anything is better than the current implementation :smile: