Commit Graph

839 Commits

Author SHA1 Message Date
Tim Hockin 8fa652dafa Break up main.go
Add new files for abspath, credential, and env functions.
2023-10-13 13:27:52 -07:00
Aleksandar Markovski ff51ca92dc fix: infinite bad loop caused by unexpected worktree directory removal 2023-10-13 13:20:54 -07:00
Tim Hockin 6426efe346 If --repo is not a URL, it's not an error 2023-10-13 12:35:13 -07:00
Tim Hockin fc5e065878 Only redact the URL password if it was provided 2023-10-13 12:35:13 -07:00
Tim Hockin bb1dc0b7a5 Update v3-v4 doc on ssh 2023-10-12 12:50:27 -07:00
Tim Hockin 162e543e05 Add --credential flag to spec multiple user/pass
* New flag is a JSON-encoded struct.
* Add test case for multiple HTTP passwd.
2023-10-08 14:46:41 -07:00
Tim Hockin 7da482e001 Add v4 note about change-permissions and exechook
This is sort of a regression in v4 vs, v3, but ths use case is pretty
niche, I think.
2023-10-01 15:31:43 -07:00
Tim Hockin 4ccf0633fb Deprecate --ssh - it's not really needed
As long as a repo uses SSH transport (user@host:path or ssh://...), SSH
is active.  This is true for the main repo or submodules.
2023-09-27 13:32:15 -07:00
Tim Hockin 32c3a0c2a7 e2e: Add assert_fail and simplify fail cases 2023-09-21 12:48:59 -07:00
Tim Hockin 627fe23a9a e2e: Always pre-write FUNCNAME into repo/file
This removes a few LOC from many cases
2023-09-21 09:09:58 -07:00
Tim Hockin 66e0ba3562 e2e: merge SSH fail and success cases 2023-09-20 14:30:28 -07:00
Tim Hockin a8d5675e1d Add e2e for password-file 2023-09-20 12:46:13 -07:00
Tim Hockin d4244a3424 e2e: reorder some flags for clarity 2023-09-20 09:31:15 -07:00
Tim Hockin 96b8e8a4fc Remove redundant username/password auth test
The HTTP test covers this without needing a hacky git command.
2023-09-20 09:31:15 -07:00
Tim Hockin 8310ee9ee8 Auth tests really only need to sync once
Except for URL tests which prove resilience to failure.
2023-09-20 09:31:15 -07:00
Tim Hockin 86725cb85e Reorder tests to put auth together
No other changes
2023-09-20 09:31:15 -07:00
Tim Hockin 9bf6d7778d Set core.askPass config for better auth-fail error
Instead of "No such device or address", which is pretty obtuse, we now
get "Authentication failed".
2023-09-20 09:31:02 -07:00
Tim Hockin af6b96ab74 Add e2e for username/password over HTTP 2023-09-19 14:57:41 -07:00
Tim Hockin dbd0567882 Use correct keys on env parsing of alt names
These names are back-compat
2023-09-19 14:18:30 -07:00
Tim Hockin 11b8d151d0 Clean up submodule cases to be a bit more readable 2023-09-19 13:40:40 -07:00
Tim Hockin 55f71d55ed Add a test case for submodules with diff SSH keys 2023-09-19 13:31:19 -07:00
Tim Hockin 29b291e9c2 Add support for multiple SSH keys
The --ssh-key-file flag can be specified more than once and the
GITSYNC_SSH_KEY_FILE env var will be parsed like PATH.

Also adds e2e coverage for wrong-key and for multiple keys.
2023-09-19 13:31:19 -07:00
Tim Hockin 50de3aaeab Dump logs when e2e fails in CI 2023-09-19 13:20:09 -07:00
Tim Hockin 310cbaea37 Add $GITSYNC_VERBOSE to set verbosity via env 2023-09-15 08:28:08 -07:00
Kubernetes Prow Robot 1cab59e22e
Merge pull request #800 from kubernetes/dependabot/github_actions/actions/checkout-4
Bump actions/checkout from 3 to 4
2023-09-08 12:24:30 -07:00
dependabot[bot] a6c813b84d
Bump actions/checkout from 3 to 4
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-04 13:18:24 +00:00
Kubernetes Prow Robot e0016481f7
Merge pull request #798 from phil-park/master
fix: Fix backward compatibility of environment variables with bool type
2023-08-31 16:06:30 -07:00
Jiwon Park 8bb3467a24 fix: Fix backward compatibility of environment variables with bool type
Signed-off-by: Jiwon Park <bakjeeone@hotmail.com>
2023-08-31 07:39:54 +09:00
Kubernetes Prow Robot 5e5035d029
Merge pull request #794 from thockin/master
Add /tmp to staging
2023-07-31 12:34:39 -07:00
Tim Hockin 7a72116ccc
Add /tmp to staging 2023-07-31 08:36:34 -07:00
justinsb f602004cd4 lint: Add golangci based on kubernetes/kubernetes.
Adapted the "strict" settings, but removed a few exclusions that
aren't relevant here (e.g. zz_generated), and removed the custom
logcheck linter (as we aren't currently using structured logging).
2023-07-29 16:43:25 -07:00
justinsb 8656ab6183 lint: Add linters to makefile / github CI
Not yet ready to make gating, but we can watch the progress.
2023-07-29 16:43:25 -07:00
Kubernetes Prow Robot d86e70f744
Merge pull request #792 from justinsb/fix_remaining_lint_issues
lint: fix remaining lint issues.
2023-07-29 16:34:00 -07:00
justinsb bb22144d4f lint: fix remaining lint issues.
These fix the issues identified by the k/k inspired linter
configuration that we will be adding:

```
pkg/pid1/pid1.go:72:14: ST1005: error strings should not end with punctuation or newlines (stylecheck)
                        return 0, fmt.Errorf("unhandled exit status: 0x%x\n", status)
                                  ^
pkg/pid1/pid1.go:86:21: ST1005: error strings should not end with punctuation or newlines (stylecheck)
                        return false, 0, fmt.Errorf("wait4(): %w\n", err)
                                         ^
main.go:480:34: Error return value of `pflag.CommandLine.MarkDeprecated` is not checked (errcheck)
        pflag.CommandLine.MarkDeprecated("branch", "use --ref instead")
                                        ^
main.go:483:34: Error return value of `pflag.CommandLine.MarkDeprecated` is not checked (errcheck)
        pflag.CommandLine.MarkDeprecated("change-permissions", "use --group-write instead")
                                        ^
main.go:486:34: Error return value of `pflag.CommandLine.MarkDeprecated` is not checked (errcheck)
        pflag.CommandLine.MarkDeprecated("dest", "use --link instead")
                                        ^
main.go:1897:16: Error return value of `io.WriteString` is not checked (errcheck)
        io.WriteString(h, s)
                      ^
main.go:555:2: ifElseChain: rewrite if-else to switch statement (gocritic)
        if *flDeprecatedBranch != "" && (*flDeprecatedRev == "" || *flDeprecatedRev == "HEAD") {
        ^
```
2023-07-29 16:41:23 -04:00
Kubernetes Prow Robot 41b71f5ce4
Merge pull request #788 from thockin/fix_git_option_parsing_goroutine_leak
Fix goroutine leak in git option parsing
2023-07-29 13:06:00 -07:00
Kubernetes Prow Robot 9163f8fac2
Merge pull request #791 from thockin/rename_ghaction_build_job
Rename github build workflow
2023-07-29 13:03:59 -07:00
Kubernetes Prow Robot ee35dad8bc
Merge pull request #789 from thockin/percent_w_for_errors
Replace all error %v with %w
2023-07-29 13:02:00 -07:00
Kubernetes Prow Robot 0971564436
Merge pull request #790 from thockin/add_dependabot_for_gh_actions
Add dependabot for github actions
2023-07-29 13:00:00 -07:00
Tim Hockin 251fd7b0b7
Rename github build workflow 2023-07-29 10:40:29 -07:00
Tim Hockin 7e8adfe87f
Add dependabot for github actions 2023-07-29 10:35:07 -07:00
Kubernetes Prow Robot 71a5542f75
Merge pull request #786 from justinsb/enable_github_actions
Enable github actions for CI
2023-07-29 10:28:00 -07:00
Tim Hockin a9b3f8965c
Replace all error %v with %w 2023-07-29 10:21:39 -07:00
Tim Hockin d4f0c07bf1
Fix goroutine leak in git option parsing 2023-07-29 10:18:02 -07:00
Kubernetes Prow Robot f973ce04e0
Merge pull request #783 from justinsb/fix_lint_1
Lint fixes (part 1)
2023-07-29 10:16:00 -07:00
Kubernetes Prow Robot 0e358a2e1f
Merge pull request #784 from justinsb/fix_error_string_newlines
Remove trailing newlines from errors
2023-07-29 10:14:00 -07:00
justinsb 91f41dc719 tests: don't rely on global git configuration in tests
Otherwise got:

```
test root is /tmp/git-sync-e2e.228068759

Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
```
2023-07-29 11:39:33 -04:00
justinsb abbccb07a5 Add simple github actions
Makes it easy for anyone to run tests on github, doesn't preclude us
using prow also.
2023-07-29 10:56:59 -04:00
justinsb 07033fe697 Remove trailing newlines from errors
I believe we print a new line anyway from e.g. envInt, which calls fmt.Fprintln.

Found by staticcheck:

main.go:127:17: error strings should not end with punctuation or newlines (ST1005)
main.go:157:13: error strings should not end with punctuation or newlines (ST1005)
main.go:187:13: error strings should not end with punctuation or newlines (ST1005)
main.go:217:13: error strings should not end with punctuation or newlines (ST1005)
2023-07-29 10:49:06 -04:00
justinsb 4aa9cd7487 Lint fixes (part 1)
Fix a few misc linter issues:

main_test.go:750:7: Error return value is not checked (errcheck)
        touch(dirPath)
             ^
main_test.go:759:7: Error return value is not checked (errcheck)
        touch(filePath)
             ^
main_test.go:768:7: Error return value is not checked (errcheck)
        touch(newfilePath)
             ^
main.go:2089:3: S1023: redundant `return` statement (gosimple)
                return
                ^
main.go:1935:13: S1039: unnecessary use of fmt.Sprintf (gosimple)
                sshCmd += fmt.Sprintf(" -o StrictHostKeyChecking=no")
                          ^
main.go:1152:33: SA1016: os.Kill cannot be trapped (did you mean syscall.SIGTERM?) (staticcheck)
        signal.Notify(c, os.Interrupt, os.Kill)
2023-07-29 10:44:16 -04:00
Kubernetes Prow Robot 71a7aca57e
Merge pull request #781 from thockin/v4_drop_distroless
Drop distroless and DIY
2023-07-29 07:38:00 -07:00