Skip to content

how can I clone repos to /home/coder? #384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bpmct opened this issue Oct 14, 2024 · 9 comments · Fixed by #406
Closed

how can I clone repos to /home/coder? #384

bpmct opened this issue Oct 14, 2024 · 9 comments · Fixed by #406
Assignees

Comments

@bpmct
Copy link
Member

bpmct commented Oct 14, 2024

By default, envbuilder will clone workspaces to /workspaces/<repo-name>. However, when I configure ENVBUILDER_WORKSPACE_FOLDER to /home/coder, it clones it directly in that folder, not /home/coder/<repo-name>.

What can I do here?

@coder-labeler coder-labeler bot added the question Further information is requested label Oct 14, 2024
@bpmct
Copy link
Member Author

bpmct commented Oct 23, 2024

@johnstcn @mafredri is this possible?

@johnstcn
Copy link
Member

johnstcn commented Oct 23, 2024

I think we need to append path.Base(parsed.Path) to options.WorkspaceFolder like we do for DefaultWorkspaceFolder https://github.com/coder/envbuilder/blob/main/options/defaults.go#L21-L38

Given:

User specifies ENVBUILDER_GIT_REPO=https://host.tld/path/to/myrepo and ENVBUILDER_WORKSPACE_FOLDER=/home/myuser

When:

Envbuilder runs

Then:

Git repo located at https://host.tld.path/to/myrepo is cloned to /home/myuser/myrepo

@johnstcn johnstcn removed the question Further information is requested label Oct 23, 2024
@bpmct
Copy link
Member Author

bpmct commented Oct 23, 2024

Gotcha... I think this will be a must for folks who maintain images where they wish to store projects in a single PVC with customizations (e.g. vs code settings) and repos. Unless they want to always clone to /home/repo or the TF provider can give a good folder name based on repo name

@johnstcn
Copy link
Member

Adding to next sprint

@mafredri
Copy link
Member

mafredri commented Nov 4, 2024

I started looking at this and I realized the feature is behaving exactly as documented: https://github.com/coder/envbuilder/blob/c16ae9fb1b24445b17439f9b5222940e26903d14/docs/using-local-files.md

Do we want to:

  1. keep this behavior
  2. update the docs and turn this into a breaking change
  3. add a new option that changes the default workspace_s_ folder from /workspace

Thoughts @bpmct?

@bpmct
Copy link
Member Author

bpmct commented Nov 4, 2024

Could we support the repo-name as a wildcard? So the default workspaces folder changes to /workspace/$REPO (unsure what is best syntax) so someone can change it to /home/$REPO? That way, it can stay hardcoded to a folder or create a folder for the repo if it doesn't exist if wildcard is used

@bpmct
Copy link
Member Author

bpmct commented Nov 4, 2024 via email

@mafredri
Copy link
Member

mafredri commented Nov 4, 2024

@bpmct I think it's best to avoid introducing magic syntax if we can avoid it. The $REPO could be especially weird if run in a shell where it's evaluated into empty due to double quoting.

Perhaps we just introduce a new option called: ENVBULDER_WORKSPACES_FOLDER=/workspaces (observe "S" in workspaces, better naming suggestions welcome) and define this one as ENVBULDER_WORKSPACE_FOLDER="$ENVBULDER_WORKSPACES_FOLDER/reponame".

I would like to keep ENVBULDER_WORKSPACE_FOLDER and it's current behavior because it mimics workspaceFolder in the spec: https://containers.dev/implementors/json_reference/#image-specific

(In the spec you see /workspace as the default value, and it means the code is directly in /workspace, not a sub folder)

@bpmct
Copy link
Member Author

bpmct commented Nov 4, 2024

Sounds good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants