This is a port of #431.
A new flag `--password-file` is added. This allows git-sync to read
password from file and this is considered as safer than reading from
env or flag directly.
Few more checks are added as well:
1. `--password` and `--password-file` can't be specified at the same
time.
2. If `--username` is specified, then one of `--password` or
`--password-file` must be specified.
When we fetch expecting a rev/hash to be present, defensively check and fail gracefully so that a subsequent sync would get it. Check for missing hash after a git fetch with shallow depth
They are using git-sync and have had a bunch of ideas for improvements.
I have had a hard time finding enough time to devote to this and they
offered to help.
This is to avoid wedge cases where the worktree was created but this function error'd without cleaning the worktree.
Next timearound, the sync loop fails to create the worktree and bails out.
We observed a case where due to #412, the next sync loop failed with this error:
" Run(git worktree add /repo/root/rev-nnnn origin/develop): exit status 128: { stdout: \"Preparing worktree (detached HEAD nnnn)\\n\", stderr: \"fatal: '/repo/root/rev-nnnn' already exists\\n\" }"
When endpoint returns non-200 status, include the body in the error
message since it can contain useful information for debugging. Also
defer closing the response body ReadCloser as this may have leaked in
the past.
The `git clone` command will create the root directory if it doesn't
exist, but if `git clone` fails, the root directory needs to be present
so that we can write the error to a file under the directory.
The current git-sync process outputs the error information to standard
out, which is inaccessible from outside the container. Users have to
dump the logs using kubectl logs in order to check the error details in
the git-sync process. This commit exports the error details to a file,
which provides users the capability to check the errors directly from
other sidecar containers.
proposal: https://github.com/kubernetes/git-sync/issues/326
As per discussion with Go team. it's hacky but it works.
create tools.go
git add tools.go
go mod vendor
git add vendor
go mod tidy
go mod vendor # again