Skip to content
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

Add git "safe directory" for tekton convention "/workspace/source" dockerfile entrypoint (like github_workspace) or generalize. #1766

Closed
janderssonse opened this issue Aug 19, 2022 · 2 comments · Fixed by #1770
Labels
enhancement New feature or request

Comments

@janderssonse
Copy link
Contributor

janderssonse commented Aug 19, 2022

Is your feature request related to a problem? Please describe.
When running megalinter docker in a tekton pipeline, one can stumble upon the quite recent git safe.directory problem so one has to add "git config --global --add safe.directory PATH". I see like you already added patch specifically for github_workspaces default path in entrypoint.sh. Note: An convention (many tekton examples shows this, so I guess other people than us will also use this path) is to use /workspace/source path, even if one does not have to of course.

Describe the solution you'd like
Either just add an extra setting also for TEKTON_WORKSPACE, in the entrypoint.sh, and set /workspace/source/ (fastest fix) or maybe even generalize it to handle all future cases including github, with something like
if [[ -d "${DEFAULT_WORKSPACE}" ]] ; then git config --global --add safe.directory "${DEFAULT_WORKSPACE}"; echo "Setting git safe dir ${DEFAULT_WORKSPACE}" ;~ | else echo 'no dir' ; fi

Further, if generic maybe make the setting configurable - Maybe an env to "SET_GIT_WORKSPACE_AS_GIT_SAFE_DIR" , or something like that.

Describe alternatives you've considered
We create our own image , so we can add this on our own, but,, if we have the problem, other surely has too. Would be nice to have "out of the box" and spare the enduser some possible error hunt.

@janderssonse janderssonse added the enhancement New feature or request label Aug 19, 2022
@nvuillam
Copy link
Member

Good catch, thanks for reporting :)
The solution with DEFAULT_WORKSPACE seems good, would you like to make a Pull Request?

@janderssonse
Copy link
Contributor Author

I'll give it a shot :) !

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

Successfully merging a pull request may close this issue.

2 participants