Provide git repo as parameter
Hey! First of all, amazing product. I love it so much already and I’ve barely scratched the surface.
Right now I’m trying to create a baseline template for most of my projects, so naturally I want to be able to provide a repo as parameter to template and have it cloned on start.
I copied what’s in https://coder.com/docs/templates/open-in-coder but I thought it would work as it does when I connect to a workspace and can immediately clone my repositories, since I’ve already added the Coder key. But instead the startup script fails when using ssh url, with something in the lines of “can’t connect to remote” etc etc.
Why? 😄
20 Replies
<#1264503474188713985>
Category
Help needed
Product
Coder OSS (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
Look into https://registry.coder.com/modules/git-clone
And this example template to see how it's used.
https://github.com/coder/coder/blob/88d2dbd994cbb9eabbd3cd7d6a3e51fcb29d9fea/dogfood/main.tf#L30
Git Clone - Coder Registry
Clone a Git repository by URL and skip if it exists.
GitHub
coder/dogfood/main.tf at 88d2dbd994cbb9eabbd3cd7d6a3e51fcb29d9fea ·...
Provision remote development environments via Terraform - coder/coder
Glad that you are enjoying the product so far...
glad that you're enjoing the product, could you send a screenshot of the error if what Atif sent doesn't work ?
Key cropped but that’s the log 🪵
Oh missed the previous reply, will test that first
@Phorcys getting the same error with git_clone module
oh it's the known_hosts possibly?
try using the https git url
I think I’ve misunderstood how it works. To use git-clone I have to have git as a id provider?
I figured since I can immediately clone etc when using the workspace in VScode that my credentials where already there
not necessarily
if the repo is private then you have to set up external auth for github yes (or allow your personal SSH key on your GitHub account)
Yeah no it doesn’t work with public repositories either
hey @joenas, any luck?
Nah not really. Need to try again but in the meantime I found a work around with providing a github access token to the workspace via parameters and adding that to the git URL
You could also use the resource
coder_env
.What’s that @Atif ?
Ah yes I use that for other ENVs but unsure of which variable it would be in this case?
Git Config - Coder Registry
Stores Git configuration from Coder credentials
It's the
known_hosts
that's missing, if I never cloned anything in that workspace then I manually have to accept github.com on first clone.
https works with public repo but not ssh
I added this to my startup script
hey @joenas, sorry for the lack of answer, thanks for sharing your results though!
@Phorcys closed the thread.