lab icon indicating copy to clipboard operation
lab copied to clipboard

Multi account support

Open charliemaiors opened this issue 6 years ago • 12 comments

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.

charliemaiors avatar Jun 04 '19 07:06 charliemaiors

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.

letientai299 avatar Jun 04 '19 09:06 letientai299

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.

zaquestion avatar Jun 11 '19 21:06 zaquestion

Oh, congratulation.

letientai299 avatar Jun 11 '19 21:06 letientai299

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

charliemaiors avatar Jun 14 '19 15:06 charliemaiors

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 :-)

mfriedenhagen avatar Jun 15 '19 13:06 mfriedenhagen

Thanks for all the patience friends!

zaquestion avatar Jun 19 '19 16:06 zaquestion

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!

davinkevin avatar Aug 07 '19 10:08 davinkevin

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

zaquestion avatar Aug 07 '19 17:08 zaquestion

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.

WolleTD avatar Aug 10 '19 22:08 WolleTD

Agreed, PRs welcome ;)

zaquestion avatar Aug 13 '19 06:08 zaquestion

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.

ngirard avatar Aug 17 '19 11:08 ngirard

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

paride avatar Oct 22 '19 07:10 paride