Commit Graph

69 Commits

Author SHA1 Message Date
Tim Hockin 62830c2a19 E2E: always use '[[ ]]' 2021-10-18 09:38:06 -07:00
Tim Hockin 722ad23e60 Fix e2e cases to not destroy logs 2021-10-18 09:38:06 -07:00
Natalie Baker 2c3bb035f6 Use hash for branch when adding a new worktree 2021-10-04 16:55:32 -04:00
ugurkenar df69fab365 cmd,hook and logging package 2021-08-16 12:40:27 +03:00
barney-s 6baccb4c5d Check for rev to be present after a fetch
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
2021-06-23 14:56:39 -04:00
Kubernetes Prow Robot 9cd1e24966
Merge pull request #414 from barney-s/411
Cleanup worktree defensively
2021-06-22 14:36:10 -07:00
barney-s fe9c059828 Cleanup worktree defensively
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\" }"
2021-06-22 16:40:58 -04:00
Tim Hockin 80a9d54ae0 unbreak e2e for github 2021-06-22 08:28:59 -07:00
Tim Hockin 3f0d678d19 Add a testcase for github HTTPS 2021-05-28 14:18:20 -07:00
Tim Hockin 4765eb5b14 Make sure all code files have headers 2021-05-27 08:45:36 -07:00
Tim Hockin fd481d0a16 move test cleanup to the end 2021-05-26 14:30:01 -07:00
Kubernetes Prow Robot a3affe9040
Merge pull request #372 from SpencerMalone/sparse-checkouts
Add support for sparse-checkout
2021-04-23 08:32:02 -07:00
Spencer Malone 07e552b506 Add support for sparse-checkout 2021-04-23 08:17:58 -07:00
Nan Yu 8ea449292b Export the error details to an error file
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
2021-04-09 11:00:52 -07:00
Tim Hockin d508f04bbe Move sync-hook to after symlink flip 2021-04-05 17:04:44 -07:00
Tim Hockin 11c2a1fd7b Fix exit non-zero exit codes when running as pid1
Prior to this we would swallow the exit code and always exit(0).
2021-03-15 09:30:46 -07:00
Kubernetes Prow Robot de2a216922
Merge pull request #341 from thockin/add-git-configs-flag-3.x
Add --git-config flag
2021-03-15 07:45:05 -07:00
Tim Hockin 770314995f Change the symlink targets to just the SHA
This allows users to call readlink() on the link and learn the current
checked out SHA.
2021-03-11 22:07:07 -08:00
Tim Hockin 45bba183ca Add --git-config flag
This allows arbitrary git configs to be passed in.  For example:

`git config --global http.postBuffer 1048576000`

`git config --global http.sslCAInfo /path/to/cert/file`

`git config --global http.sslVerify false`

This flag takes a comma-separated list of `key:val` pairs.  The key part
is passed to `git config` and must be a valid gitconfig section header
and variable name.  The val part can be either a quoted or unquoted
value.  For all values the following escape sequences are supported:
   * `\n` => [newline]
   * `\t` => [tab]
   * `\"` => `"`
   * `\,` => `,`
   * `\\` => `\`

Within unquoted values, commas MUST be escaped. Within quoted values,
commas MAY be escaped, but are not required to be.  Any other escape
sequence is an error.

Example:

`--git-config=foo.one:val1,foo.two:"quoted val",foo.three:12345`

This commit exposed a bug in runCommand() which modified its args when
they had an embedded space.
2021-03-10 19:07:05 -08:00
Tim Hockin a524d5eacd Use docker to run helper servers in e2e
Reliably cleaning up leftover things like nc processes is surprisingly
difficult in pure shell. e2e passes on the 3.x branch now.
2021-01-23 15:56:08 -08:00
Tim Hockin a37a672b40 Fix e2e to always specify branch name
As git changes the default from "master" to "main", it's not
predictable.  Now the test owns the decision.
2021-01-07 09:44:34 -08:00
Tim Hockin 771011f0cc Move --v into e2e framework (always same) 2020-10-02 14:38:19 -07:00
unknowingknow 9661d3132e add e2e test for --sync-hook-command 2020-10-02 19:29:21 +09:00
Tim Hockin 1992a2bfab logtostderr defaults to true: don't set it in test 2020-09-28 16:31:33 -07:00
Tim Hockin 44e94a16b0 Fix webhook regression: allow -1 to ignore status 2020-09-25 11:17:56 -07:00
Tim Hockin a29fab5bfa Remove useless test case 2020-09-04 20:03:37 -07:00
alix.cook11 dcf169c10a
add option to NOT recursively clone submodules (#246)
* add option to NOT recursively clone submodules

* Add "shallow" and "off" modes to submodule clone

* update readme to reflect new flag

* wording and such feedback
2020-07-30 21:29:07 -07:00
Tim Hockin ef8f5cf703 Bump to debian-base 2.0.0 (buster)
This changed `git fetch` to require a `-f` the way we use it.

Also fix a flaky test case for SSH.
2020-01-31 09:20:54 -08:00
Tim Hockin 72deefcec3 Make health check meaningful 2020-01-09 17:20:11 -08:00
Tim Hockin 1a1dd1cbe0 e2e: Add test for SSH
This requires having a docker image for git-over-ssh.
2020-01-07 08:25:36 -08:00
Tim Hockin fbdeead461 e2e: quote variables 2019-12-30 15:32:52 -08:00
Tim Hockin 9303c920d7 e2e: Use docker labels for cleanup 2019-12-30 15:32:52 -08:00
Tim Hockin a6cce7b757 e2e: move code around 2019-12-30 15:32:52 -08:00
Tim Hockin b56ea3796a e2e: reinit repo for each testcase 2019-12-30 15:32:52 -08:00
Tim Hockin ece56840f8 Fix askpass tests 2019-12-30 15:32:52 -08:00
Chuanying Du 5c70f02656 Verify both username and password in the askpass_git test. 2019-12-19 16:48:23 -08:00
Chuanying Du 0851cc5916 use free port 2019-12-19 16:26:46 -08:00
Chuanying Du 0b0f0a62d5 use random port for nc 2019-12-18 22:30:42 -08:00
Chuanying 27864c32cd
Merge branch 'master' into master 2019-12-18 22:11:57 -08:00
Chuanying Du d8d9ff72b8 add e2e test for askpasswd_url 2019-12-18 21:07:01 -08:00
Chuanying Du b0bdc02e8b manually merge https://github.com/kubernetes/git-sync/pull/217 2019-12-18 20:05:51 -08:00
Chuanying Du 66244108ed fix tests 2019-12-18 17:57:28 -08:00
Chuanying Du d58a241648 add comments; use --one-time for testing 2019-12-18 17:13:37 -08:00
Chuanying Du ac70751767 Change git credential from cache to store and also add test for
username/password case.

For cache to store change:
* By default, cache only last 900 seconds, gitsync will break after
  that. See https://git-scm.com/docs/git-credential-cache.
* The test won't work with cache since the test don't have access to
  the default unix socket location; XDG_CACHE_HOME override also can
  pre-create a socket in advance.
* `store` put the credential into a file, much easier to debug than cache.
* Considering anyone have access to the pod already able to get the
  credential via environment variables or yaml configs, so put it in
  file won't make it less secure.

For the new password test:
1. askpass_git.sh provided to simulate a git with password challenge.
2. Need and only need to similate "clone" action, need to bypass other
  actions like config/credential setup.
3. See `credential fill` is the official git action to ask password,
  see https://git-scm.com/docs/git-credential.

This change resolved issue #196.
2019-12-18 09:55:01 -08:00
Tim Hockin 27b43e624b e2e: move flags and better errors 2019-11-19 07:44:02 -08:00
Tim Hockin 2b11e078b0 Remove default-value flags in e2e 2019-11-19 07:44:02 -08:00
Tim Hockin 5a73199cf7 all e2e should use file://repo 2019-11-19 07:44:02 -08:00
Tim Hockin 405bfefdc2 e2e: don't pass one-time and wait 2019-11-19 07:44:02 -08:00
Tim Hockin 5e82e574ac e2e more random (I actually hit this) 2019-11-19 07:44:02 -08:00
Tim Hockin c94c8087de e2e --one-time tests can be sync 2019-11-19 07:44:02 -08:00