zaquestion / lab

Lab wraps Git or Hub, making it simple to clone, fork, and interact with repositories on GitLab
https://zaquestion.github.io/lab
Creative Commons Zero v1.0 Universal
1.1k stars 102 forks source link

Multi account support #311

Open charliemaiors opened 5 years ago

charliemaiors commented 5 years ago

It would be nice if you can configure more than one Gitlab repository, for instance, the master gitlab.com and the on-premise Gitlab for something different.

letientai299 commented 5 years ago

I'm gonna share how I have multiple account support with lab. Since lab can read the token from env, this can be archived via direnv.

For example, you can have an .envrc file in one folder for your own project, that use master gitlab, and another one for your company projects that use on-premise.

├── company
│   ├── .envrc
│   └── project-a
└── my-project
    └── .envrc

3 directories, 2 files

Content of .envrc file:

export LAB_CORE_HOST="https://git.garena.com"
export LAB_CORE_TOKEN="xxxx"
export LAB_CORE_USER="xxx"

Lab can support this by checking for its config file on every folder from the working dir up to root, though.

zaquestion commented 5 years ago

Yeah this seems like the way to do it, at least its likely to be the easiest to implement. I'm getting married this week, but I'll see if I can find some time to implement searching parent directories for the config sometime next week.

letientai299 commented 5 years ago

Oh, congratulation.

charliemaiors commented 5 years ago

Oh, congratulations all the best :) I will use the configuration suggested by @letientai299

mfriedenhagen commented 5 years ago

I now use direnv as suggested by @letientai299 as well. Together with https://github.com/motemen/ghq this is a good fit as ghq automatically clones repositories into folders named like github.com/ORG/PROJECT, so e.g. putting an .envrc file on the ORG level is a perfect match for me :-)

zaquestion commented 5 years ago

Thanks for all the patience friends!

davinkevin commented 5 years ago

I've made the same! 😍

This worth to be inside the documentation

BTW, @zaquestion, thanks for your awesome work on this tool!. With K9S, this is one of my favorite tool I use everyday!

zaquestion commented 5 years ago

I started implementing the behavior in lab, so hopefully will have time to release that soon and can document that behavior.

WolleTD commented 5 years ago

Sorry I'm late, but I'd suggest another solution: Allow multiple pairs of host and token in the global config file. If the remote of the repository matches a host entry, use it, otherwise, throw an error.

This can coexist with the local config file change, which isn't a bad thing.

This would require reading the git remote information before initialization; then again, initializing this early (even when only passing commands to git) seems unneccesary anyway.

zaquestion commented 5 years ago

Agreed, PRs welcome ;)

ngirard commented 5 years ago

I'd suggest another solution: Allow multiple pairs of host and token in the global config file.

Please take inspiration from the https://github.com/lighttiger2505/lab project, which provides such feature.

paride commented 4 years ago

Isn't this issue mostly a duplicate of #151?