ZupIT / ritchie-cli

Ritchie CLI is an open-source tool that allows to create, store and share any kind of automation, executing them through command lines, to run operations or start workflows ⚙️ 🖥 💡
https://docs.ritchiecli.io
Apache License 2.0
559 stars 102 forks source link

Save and reuse repo credentials for private repos #800

Closed henriquemoraeszup closed 3 years ago

henriquemoraeszup commented 3 years ago

What would you like to be added: When adding a private repo, the token is asked for every time. Ritchie could try to fetch the credential from the saved file. If there is no credential, prompt and save it

IMPORTANT: We should have a specific dedicated credential value for this token and In case a 401 is found (i.e.: user has more than 1 private repo requiring more than 1 different tokens), we should instruct the user about the fail and how he/she can proceed by either overwriting the current token or by switching to a new env

Why is this needed: For better DevEx and so people do not need to regenerate private tokens every time they add a repo

matheussn commented 3 years ago

hello @henriquemoraeszup, can i work on this? :smile:

GuillaumeFalourd commented 3 years ago

I've assigned you the issue @matheussn 👍🏼 Thanks for helping once again 🚀

henriquemoraeszup commented 3 years ago

Sorry for the delay, please go ahead! You have been an active contributor and we appreciate it! @matheussn would you be willing to have a chat with the team next week so we get your feedback on ritchie?

matheussn commented 3 years ago

Hello @henriquemoraeszup! These are my first contributions to Open Source projects. I am very happy to contribute to the project, and happier for the recognition! And I would love to participate in this chat!

henriquemoraeszup commented 3 years ago

Wassup @matheussn! I will schedule 30min shortly. Also we have updated the user flow on the description on how this command should behave

lucasdittrichzup commented 3 years ago

hello @matheussn, how are you? if you need any help i am on hand to assist in whatever is necessary.

matheussn commented 3 years ago

Hi! I did an implementation, but I didn't like some details hehehe 😄 Even so, I will open the PR for you to help me

matheussn commented 3 years ago

@lucasdittrichzup Currently, I'm getting the token like this: token, err = ad.Resolve (" CREDENTIAL_ "+ provider +" -add-repo_token ") "github-add-repo" and "gitlab-add-repo", would be the new credentials, as agreed. As I understand it, this Resolve method is used to get information from credentials that are not necessarily listed as Ritchie" default credentials ". Since the credentials listed above will be listed in Ritchie's "default credentials", I believe that using this method is not ideal.

I was thinking of creating a method to abstract the part of asking the user for the fields of standard credentials. Where I say "Create credential X" And regardless of the number of fields and types, he creates the structure for that credential.

Some questions:

  1. Is there already a method that does something similar?
  2. Is going this way unnecessarily excessive work, or does it make sense?
GuillaumeFalourd commented 3 years ago

I was thinking of creating a method to abstract the part of asking the user for the fields of standard credentials. Where I say "Create credential X" And regardless of the number of fields and types, he creates the structure for that credential.

Would the set credential class help with this part @matheussn ?

matheussn commented 3 years ago

Would the set credential class help with this part @matheussn ?

Yes, the idea would be to abstract the user input part of that class, so that I could use it in the add repo command. And don't use the Resolve method, since in the set credential class I would also be able to create the "github-add-repo" and "gitlab-add-repo" credentials.

GuillaumeFalourd commented 3 years ago

There is the runStdin() method in that class that could work informing the input parameters directly. But the stdin method is deprecated as everything will migrate to the input flag method, as used for formulas.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it hasn't had any activity in 60 days. It will be closed in 7 days if no further activity occurs (e.g. changing labels, comments, commits, etc.). Please feel free to tag a maintainer and ask them to remove the label if you think it doesn't apply. Thank you for submitting this issue and helping make Ritchie a better product!