go-ipam icon indicating copy to clipboard operation
go-ipam copied to clipboard

Storage cannot be implemented by others

Open ulrichSchreiner opened this issue 6 years ago • 1 comments

The current Storage interface returns Prefix structs. But the Prefix struct contains private fields which cannot be filled/returned by external implementations as they do not see this fields. But the Prefix implementation relies on these fields and their correctness.

i see the following options:

  • extend the Storage interface with methods for manipulating the current private fields
  • create a new StoragePrefix which is returned/consumed by a storage and contains only the data from the storage. the Prefix always copies the data to it's own fields.
  • make the interface private and remove the NewWithStorage fuction. new storage backends have to be provided by the library and must provided as PR's

i'd propose the third option as atm i cannot see any other implementations for Storage from outside of our project.

ulrichSchreiner avatar Aug 28 '19 07:08 ulrichSchreiner

I agree with your findings and propose the third option as well, having support for different storages was introduced more from the abstraction and testing perspective.

majst01 avatar Aug 28 '19 08:08 majst01

As we already have support for plenty of databases implemented, i am closing this.

majst01 avatar Aug 26 '23 09:08 majst01