MatthewJohn / terrareg

Open source Terraform module registry with UI, optional Git integration and deep analysis
https://gitlab.dockstudios.co.uk/pub/terrareg
GNU General Public License v3.0
268 stars 20 forks source link

Support for Azure DevOps ssh git clone URLs #58

Closed frittsy closed 1 month ago

frittsy commented 1 month ago

Azure DevOps has an unusual URL format for cloning git repositories via ssh. As an example from their documentation:

git clone git@ssh.dev.azure.com:v3/fabrikam-fiber/FabrikamFiber/FabrikamFiber

Using v3 effectively as a port number is incompatible with terrareg and produces an error saying the "URL contains a invalid port". I tried both removing it and using port 22 in place of v3, but both fail to connect to the repository. Granted this could be user error of some other sort (I did set SSH_PRIVATE_KEY and it appears to be setup correctly), but I'm thinking that Azure DevOps may require v3 in the URL for this to work properly.

There is an alternative (preferred) authentication method for cloning which is to use a personal access token in the https url, such as:

https://{pat}@dev.azure.com/fabrikam-fiber/FabrikamFiber/_git/FabrikamFiber

where {pat} would be replaced with the token. But I don't think terrareg would support that template replacement and I don't want to hardcode/leak my PAT in every git clone url either, so I'm trying to make SSH work.

Any ideas would be appreciated! ❤️

MatthewJohn commented 1 month ago

Created gitlab issue: https://gitlab.dockstudios.co.uk/pub/terrareg/-/issues/536 gitlab-issue-id:536

frittsy commented 1 month ago

Apologies, I just discovered that support for PATs was (conveniently) added in v3.10.0, through the use of UPSTREAM_GIT_CREDENTIALS_PASSWORD. This more than suffices for my need and is preferred to ssh, so I'm going to close this issue.

MatthewJohn commented 1 month ago

Hey @frittsy,

You should also be able to provide the URL in the format hinted to on the module creation page:

ssh://git@ssh.dev.azure.com/v3/fabrikam-fiber/FabrikamFiber/FabrikamFiber

Hope this helps

Thanks Matt