spreadshirt/backstage-plugin-s3

Abstract to also allow GCS and Azure?

Opened this issue · 3 comments

Hey,

I recently forked your implementation and refactored it to work with Google Cloud Storage. Maybe we can collaborate and use some sort of file system abstraction library? I am not that into Typescript, so I am not aware of a good Abstraction Library. In the PHP World, we have very good ones and we use them for all kinds of storage abstractions.

WDYT?

Hi @dpfaffenbauer .

As we designed this plugin, it's definitely possible to add new providers apart from the current ones. Let me make a short explanation on the steps you might need to follow:

First, you will need to create a new CredentialsProvider, which can be placed inside the src/credentials-provider folder. Here, your method has to extend the interface CredentialsProvider and should read a new config object with the needed data to fetch the buckets from the Google Cloud Storage. You can follow the other 2 examples there. Then, you will need to extend the swtich case to also read that new configuration (currently the 2 supported methods are config and radosgw-admin).

Then, you will also need to create a new S3Api and BucketsProvider. Currently there's only 1 implementation, but you can create new ones implementing those 2 interfaces. To keep the code cleaner, I would suggest creating 2 new folders (one for the api and another for the providers), where the interfaces and the different implementations would be located. Once that is done, you might need to change a bit the S3Builder to pick the correct client and provider depending on the method selected in the configuration, like we do for the CredentialsProvider. I would expect the current interfaces to have enough data to work for other providers as well. If not, feel free to extend it. Of course, in your api implementation you can use the data you receive in a different way, depending on how it's used by the Google Cloud Storage provider.

And of course, feel free to create a MR when this is done, so we can review it and add it to the plugin.

My idea was to further abstract it so we don't need to implement every new provider, there are certain abstractions for bucket storages already.

Hm, haven't checked that. But being able to abstract the client at least would simplify the process, indeed. I don't have that much experience with those 2 technologies unfortunately. If you want you could give it a try and create a MR if it works.

If it helps, we used the kubernetes-backend plugin from backstage as inspiration, because it was designed in a way that adding new providers, clients, etc. was pretty easy. Maybe there you find something like what you want to achieve here 😄