I have a use-case where I want to build Caddy with plugins from multiple disparate private repos (different accounts / organizations). As an example of why this might be useful, consider the scenario when xcaddy is used in an automated build environment where users can link their private repo via Oauth to create a custom Caddy build.
Retrieving a plugin from a single private repo is trivial (just set GOPRIVATE and do a replace on the git remote url host, or use SSH). Multiple private plugins from different organizations would require you to make the the aforementioned changes to the environment just before each go get call.
I'm not sure the best way to solve this. My idea is to have xcaddy accept a JSON file as a param. It could include an array of "private repo configs" which each consist of the following
- User name
- Password / token
- Repo url
xCaddy would use this info to
- Set
GOPRIVATE env var (used by go get to know when a repo is private),
- Assemble a temporary
.netrc before each go get call for a private plugin (the .netrc is used by the git command to authenticate with the git server.
The json config could be nice because would be simple to manage in a CI/CD environment or in your Dockerfile.
Caveat: Right now I'm only thinking about private Github repos, so there might be some minor nuances to supporting / authenticating with other Git servers.
Here's an article about go get and private repos for more context.
I have a use-case where I want to build Caddy with plugins from multiple disparate private repos (different accounts / organizations). As an example of why this might be useful, consider the scenario when xcaddy is used in an automated build environment where users can link their private repo via Oauth to create a custom Caddy build.
Retrieving a plugin from a single private repo is trivial (just set
GOPRIVATEand do a replace on the git remote url host, or use SSH). Multiple private plugins from different organizations would require you to make the the aforementioned changes to the environment just before eachgo getcall.I'm not sure the best way to solve this. My idea is to have
xcaddyaccept a JSON file as a param. It could include an array of "private repo configs" which each consist of the followingxCaddy would use this info to
GOPRIVATEenv var (used bygo getto know when a repo is private),.netrcbefore eachgo getcall for a private plugin (the.netrcis used by thegitcommand to authenticate with the git server.The json config could be nice because would be simple to manage in a CI/CD environment or in your Dockerfile.
Caveat: Right now I'm only thinking about private Github repos, so there might be some minor nuances to supporting / authenticating with other Git servers.
Here's an article about
go getand private repos for more context.