evanlucas / gcr

A node gitlab-ci-runner
MIT License
51 stars 12 forks source link

add registerToken support #17

Open flipflopsimsommer opened 9 years ago

evanlucas commented 9 years ago

Thanks for the contribution! Can you please explain the change and why it is needed? Thanks!

flipflopsimsommer commented 9 years ago

why:

i want to deploy servers for projekts as needed, so the first time the server start i will execute ./bin/cmd -u <url> -r <projekttoken> to register it, later the token is in the config and the registertoken will not be needed.

how i understand it:

there are 2 tokens the runner token and the registertoken with wich you need to get a new runner token. since no runner token is provided in my cmd call it will look for registerToken and register the runner to get the runner toke.

what it does:

i wanted to register and start a new runner from cli without questions.

flipflopsimsommer commented 9 years ago

@evanlucas let me know if you have more questions or if i should chance something. imho what i added might also be usefull for others. BR

zartdinov commented 8 years ago

Actual for me! I prefer to configure container service once and then just scale up their number. Every gitlab runner is not so unique for me, I just need free one at some moment of time. For my runners config I must use "expect" command, cause need to pass reg. token to not friendly gcr dialog interface.

bushong1 commented 8 years ago

Hey @flipflopsimsommer. I'm trying to get these PRs taken care of. Can you clean up the conflicts and rebase off current master? I definitely think this is a good addition.

flipflopsimsommer commented 8 years ago

@bushong1 can do, i will look at it tomorrow

flipflopsimsommer commented 8 years ago

@bushong1 let me know if you need anything else, looking forward of using your repo again.

bushong1 commented 8 years ago

Okay, i added some comments on cleaning it up. I'm also trying to walk through the logic.

So, the main issue is that this application doesn't allow the user to manually set a "Registration Token", and GitLab doesn't allow the user to procure a single-use "Runner Token" outside of the API. To be clear, a Registration Token is what you receive from the gitlab project page/runner registration page. When the application connects the first time, it will take the Runner Token, make a request to api/v1/runners/register.json, and get a "Runner Token", then gcr stores that in the ~/.config/gcr.json.

This update is trying to allow a gcr instance to register without asking a human for input. Logic chart is as follows:

  1. Runner Token = true; Register Token = true OR false
    • Use the Runner Token to request Builds
  2. Runner Token = false; Register Token = true
    • Use the Register Token to request a Runner Token
    • Save Runner Token
    • Use the Runner Token to request Builds
  3. Runner Token = false; Register Token = false
    • Prompt the user for a Register Token
    • Use the Register Token to request a Runner Token
    • Save Runner Token
    • Use the Runner Token to request Builds

Does that sound right?