janstuemmel / aws-role-switch

Browser plugin to quickly switch between aws roles
https://janstuemmel.de/aws-role-switch
MIT License
26 stars 2 forks source link

Fetch config from GitHub repo #278

Open tymik opened 1 year ago

tymik commented 1 year ago

I have used AWS Extend Switch Roles in past with an internal tool that was built to sync the config from the GitHub repository for easy team sharing and updating of the common config. It was pretty useful when working with multiple accounts across the team. The internal extension used GitHub API key and path to the config file in a repo to sync and it was doing the sync every 15 minutes or when forced. The extension also used the chrome extension ID to sync with proper extension - I guess it was meant to work only with AWS Extend Switch Roles and I haven't tried it with this extension (I might test it in a couple of days). Anyway, it would be really nice to see an embedded functionality like this here, making this extension even better and not needing some old internal extension that doesn't seem to be maintained for a very long time.

Of course, if that would be possible to achieve easily, support for other remote repos (GitLab, Bitbucket, AWS Code Commit, etc) would be even better, but I think that GitHub is a pretty good start.

janstuemmel commented 1 year ago

I already thought about this and even implemented some boilerplate (#254) due to #252.

I think it is a pretty neat idea to have a sidecar extension that pushes configuration into this extension while it seams a bit hacky at the same time. Please read the conversation in #252.

What i could imagine: This extension pulls configuration over a http endpoint. The user could define a curl request (or a simple form) with headers to retrieve the config by an intervall or a refresh button. I do not like the idea to implement authentication for github or something like this though.

tymik commented 1 year ago

I'm not sure if it would need to be a sidecar extension though, I was rather thinking about an embedded part of configuration here. You could provide the api url to github content, your api key and that would be all that's needed to work.

But as per #252 maybe it would make more sense to enable sidecars as then different extensions could be used without the need to embed additional functionality into this extension.

I do not like the idea to implement authentication for github or something like this though.

Why? There's an API key in GitHub one can generate to use with the extension and there's no other way to get config fetched from private repos.

janstuemmel commented 1 year ago

I'm not sure if it would need to be a sidecar extension though, I was rather thinking about an embedded part of configuration here. You could provide the api url to github content, your api key and that would be all that's needed to work.

That would be simple http request, right?

But as per #252 maybe it would make more sense to enable sidecars as then different extensions could be used without the need to embed additional functionality into this extension.

Maybe yes, it will take a while tho. I do not want to rush this idea.

I do not like the idea to implement authentication for github or something like this though.

Why? There's an API key in GitHub one can generate to use with the extension and there's no other way to get config fetched from private repos.

Can you provide an example of how it could look like? I think i do not understand you correctly.

tymik commented 1 year ago

That would be simple http request, right?

I suppose yes

Maybe yes, it will take a while tho. I do not want to rush this idea.

Sure! I'd contribute if I could but my coding skills are too poor, I'd need support :(

Can you provide an example of how it could look like? I think i do not understand you correctly.

I suppose that get repository content method would need to be used. Here's curl snippet:

curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/repos/OWNER/REPO/contents/PATH

token could be provided in settings to the plugin, together with the API URL to the file, and then there could be a button to trigger the request manually and some sort of cron (I don't know how automatic periodic actions are working in Chrome) to auto fetch the file.

nickjmv commented 11 months ago

Is there any progress on this? I'm very interested in this feature!