Commit Graph

128 Commits

Author SHA1 Message Date
Tim Hockin c410bb5610 Add a main struct, part 8
This commit encapsulates the authURL parameter.
2020-11-10 10:21:20 -08:00
Tim Hockin 4d808d47ed Add a main struct, part 7
This commit encapsulates the chmod and link parameters.
2020-11-10 10:21:20 -08:00
Tim Hockin 70dd821e7b Add a main struct, part 6
This commit encapsulates the submodules parameter.
2020-11-10 10:21:20 -08:00
Tim Hockin 8b321e3940 Add a main struct, part 5
This commit encapsulates the depth parameter.
2020-11-10 10:21:20 -08:00
Tim Hockin 3a1212da36 Add a main struct, part 4
This commit encapsulates the branch and rev parameters.
2020-11-10 10:21:20 -08:00
Tim Hockin b44dab6817 Add a main struct, part 3
This commit encapsulates the repo parameter.
2020-11-10 10:21:20 -08:00
Tim Hockin a80afb427d Add a main struct, part 2
This commit encapsulates the root parameter.

This exposed a bug where we do not reset the root of the workspace.
2020-11-10 10:21:20 -08:00
Tim Hockin 2dd4705c1b Add a main struct, part 1
Start the process of encapsulating most of the flags and not using them
as global variables.  This commit JUST does the git command flag, which
is now only accessed from main()
2020-11-10 10:21:20 -08:00
Tim Hockin 047593b40a Clarify logging vs printf for fatal messages
Also log when HTTP serving fails.
2020-11-10 09:15:17 -08:00
Tim Hockin 24c06a5b48 Normalize the root path
This makes sure there's never any confusion about whether it is an
absolute path or has symlinks or whatever.  Add e2e cases to cover.
2020-11-09 09:20:24 -08:00
Tim Hockin 0e802450ee Don't allow --dest to start with a dot
BREAKING CHANGE

It's useful to reserve names that start with a dot.
2020-11-09 08:36:10 -08:00
Tim Hockin af2ae5b533 Make the --root flag required, no default
BREAKING CHANGE

The default of $HOME has caused problems for people playing with
git-sync, so this change makes it a required argument.
2020-11-09 08:30:29 -08:00
Tim Hockin fa0e8696e2 Change time-related flags to durations
Add '--period' to replace '--wait', which is now obsolete.

Add '--sync-timeout' to replace '--timeout', which is now obsolete.

Both of these new flags take a Go-style time string, rather than a bare
number. For example "1s" for 1 second or "1m" for one minute.

The old flags have been kept and will take precedence if specified.
2020-11-05 16:46:09 -08:00
Tim Hockin 20696689f3 Add help and manual flags, use pflag
THIS IS A BREAKING CHANGE

Switch flags implementation to use pflag.  This means that long flags
like `-username` must now use 2 dashes: `--username`.

The `-v` flag (verbose) used to accept `-v` or `--v`.  Now it only
accepts `-v.

The `--help` and `-h` flags are new.

The `--man` flag is new (print a man-page like help message).

Several glog flags which used to be exposed (e.g. --logtostderr) are no
longer exposed.  Logs always go to stderr.
2020-10-31 00:50:51 -07:00
unknowingknow 26cd942b2a change to a command name with no args 2020-10-02 19:29:03 +09:00
unknowingknow e1c4717de6 add an option to run the command when the repository is updated 2020-10-02 19:28:25 +09:00
Tim Hockin 44e94a16b0 Fix webhook regression: allow -1 to ignore status 2020-09-25 11:17:56 -07:00
Kubernetes Prow Robot 66320a6b92
Merge pull request #243 from killuazhu/kyle-relax-wait
Relax wait between sync
2020-09-25 10:30:26 -07:00
Tim Hockin 4225d000e0 Clean up askpass function to take url as arg 2020-09-07 17:16:56 -07:00
Kubernetes Prow Robot ed57c29d83
Merge pull request #275 from thockin/7-askpass-metric
Add metric for askpass, noop sync != success
2020-09-07 17:11:42 -07:00
Tim Hockin 9cef5f8ced Improve flag input checking and errors 2020-09-05 10:30:25 -07:00
Kubernetes Prow Robot f67c13654e
Merge pull request #277 from thockin/9-better-logs
Better logs and errors
2020-09-05 10:27:40 -07:00
Kubernetes Prow Robot 9c56b25591
Merge pull request #276 from thockin/8-use-filepath
use filepath.Join, drop dep on path
2020-09-05 10:25:41 -07:00
Tim Hockin 04c85ee1dc Add metric for askpass, noop sync != success 2020-09-05 10:24:08 -07:00
Kubernetes Prow Robot 37f74f46fe
Merge pull request #274 from thockin/6-better-run-logs
Improve logs when running a command
2020-09-05 10:21:41 -07:00
Kubernetes Prow Robot 7d63180e78
Merge pull request #272 from thockin/4-move-setFlagDefaults
Move setFlagDefaults closer to flag code
2020-09-05 10:17:41 -07:00
Tim Hockin e43fb2513e Better logs and errors 2020-09-04 20:14:51 -07:00
Tim Hockin 07b1ab7572 use filepth.Join, drop dep on path 2020-09-04 20:13:22 -07:00
Tim Hockin 5ac2975ec4 Improve logs when running a command 2020-09-04 20:11:34 -07:00
Tim Hockin af755fbe99 Move setFlagDefaults closer to flag code 2020-09-04 20:07:47 -07:00
Tim Hockin 89aad82a31 Minor tweaks to submodules strings & consts
Rename consts internally and shorten help string a bit.
2020-09-04 20:06:44 -07:00
Tim Hockin 366e08ff40 Trivial comment change 2020-09-04 20:03:04 -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
Kyle Zhu 1546e3415f
Reduce wait time 2020-04-24 17:32:32 -04:00
Kyle Zhu c1d4d77216
Relax wait between sync 2020-04-24 15:21:09 -04:00
Tim Hockin 82cd91958b Split stdout/stderr in runCommand()
Sometimes git emits things on stderr that are not errors but not part of
the programmatic output either.  Don't combine the output.
2020-03-20 13:44:33 -07:00
Tim Hockin 95a1690e6f Fix 2 bugs in pid1
1) Was calling Wait() on the child process, but also calling Wait4,
which would race, causing an occasional error or panic.

2) In testing (1), I observed occasional hangs.  Tracing it down to a
SIGWINCH, which masked a SIGCHLD, causing it to hang.  Both seem fixed.

Added a manual test script.
2020-03-20 13:44:27 -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 5154ace66d Add --add-user to write UID/GID to passwd 2020-01-03 16:16:15 -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 31f276dd58 fix comments 2019-12-18 10:59:20 -08:00
Chuanying Du 6c6c354c72 update docs from auth-url to askpass-url 2019-12-17 11:02:03 -08:00
Chuanying Du 67a0788aa2 Rename to GIT_ASKPASS_URL and also update related examples. 2019-12-17 10:48:20 -08:00
Chuanying Du 9cae624f8c Add a new authentiate method GIT_SYNC_AUTH_URL.
It specifies a HTTP URL which will return username&password which will
be used to authenticate access to the git repo.

This is mainly used for git repo accecpt dynamic password (for example
oauth bare token). Because the dynamic password might expire very soon,
so it's added to the main syncRepo loop.

Typical usage case is work with a sidecar called gce-node-auth on GKE,
it uses the GCE service account's oauth token as password to access
Cloud Source Repo.

Please see the repo below for how it worked.
https://github.com/cydu-cloud/gce-node-auth/blob/master/git-sync-with-gce-node-auth.yaml
2019-12-16 23:45:37 -08:00
Kubernetes Prow Robot a2a8f72733
Merge pull request #211 from thockin/log-cleanups
Log before running commands, not after
2019-11-27 23:33:03 -08:00
Tim Hockin eac27f505e Log before actions 2019-11-26 13:45:18 -08:00
Tim Hockin fc700779be Log chmod operation 2019-11-26 13:45:18 -08:00
Tim Hockin e97eff010f trivial comments 2019-11-26 13:42:15 -08:00
Tim Hockin 287a0e5464 var renames for readability 2019-11-26 13:42:15 -08:00