Commit Graph

808 Commits

Author SHA1 Message Date
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
Tim Hockin a56f58dbe1
Drop distroless and DIY
Distroless is stuck on debian 11 - we can do the same thing, more or
less in our own script.  Sad that we have to, but here we are.

The net result is a about 8MB smaller and passes e2e and passes trivy.
2023-07-28 15:31:16 -07:00
Kubernetes Prow Robot e6249c2291
Merge pull request #778 from thockin/karlkfi_askpass_err_log
Handle errors from credential refresh
2023-07-28 12:15:45 -07:00
Karl Isenberg dd57eb0049
Handle errors from credential refresh
Previously, errors from askpass and credential storage were being
ignored, causing git clone/fetch to later error with hard-to-read
errors.

Now the error indicates the credential refresh as the problem, and
does not try to sync.
2023-07-28 12:09:47 -07:00
Kubernetes Prow Robot 2a7678a14c
Merge pull request #772 from Gemesil/patch-1
Update README.md
2023-07-19 14:04:04 -07:00
Ofek Buchnik 12fd9ccb56
Update README.md
Fix in README from "chan ges" to "changes"
2023-07-19 23:45:59 +03:00
Tim Hockin 54333f453f Update README.md
Update README to be less "dev branch hacky hacky"
2023-07-18 09:58:03 -07:00
Tim Hockin 0ae6c31b2e DNM 2023-07-16 12:10:55 -07:00
Tim Hockin 22b2e8e35a Update to use bookworm base image
This include symlinks from /bin -> /usr/bin (and lib, and ...), which
broke the build script.  See comments in there for details.
2023-07-16 12:10:55 -07:00
Tim Hockin 8981e7f5bb Document the / URL of the HTTP port 2023-07-16 12:10:40 -07:00
Tim Hockin ee27153186 Make 'make test' work 2023-07-11 11:47:12 -07:00
Tim Hockin df5924f904 gofmt tools.go 2023-07-11 11:47:12 -07:00
Kubernetes Prow Robot 5a9037f8c6
Merge pull request #765 from thockin/v4_fix_relative_submodules
Make relative-path submodules work, via origin
2023-07-10 11:44:52 -07:00
Tim Hockin 08296a48b0
Make relative-path submodules work, via origin
The "origin" remote is implicitly used as the basis for relative-paths
in submodules.  It's very subtly documented, and I have no idea if there
are other places where it is used.  It seems git really expects it to
exist, so let's just do that.
2023-07-10 10:46:34 -07:00
Tim Hockin 0753bd511f Use --no-install-recommends on bash install 2023-06-26 13:28:46 -07:00
Tim Hockin e603667224 Make container builds faster by not repeating work 2023-06-26 13:28:46 -07:00
Tim Hockin c4d5e9c531 Fix TAG usage for 'make release' 2023-06-26 11:27:31 -07:00
Tim Hockin 9ea8045b95 Update release notes and add 'make release' 2023-06-23 14:48:24 -07:00
Tim Hockin c1afd4d578 Fix off-by-one in max-failures and docs 2023-06-18 10:59:29 -07:00
Kubernetes Prow Robot b60eef6b30
Merge pull request #753 from thockin/v4_smaller_image
Make the container image smaller
2023-06-12 12:45:57 -07:00
Tim Hockin f037087d13
Make the container image smaller
For each package and binary we need, this pulls in all the files and
deps (shared libs, mostly).  The build is slower but the final image is
85 MB (versus 157 MB before).  e2e passes.  Hopefully less CVE surface.

This is based on scripts used in kubernetes and KinD.
2023-06-12 12:21:51 -07:00
Tim Hockin 1894192b0f Run hooks at startup
This ensures we do not miss events.  E.g.

before:
    t0: hash changes to X
    t1: send webhook(X), waiting for response
    t2: hash changes to Y
    t3: queue next webhook(Y) but can't send because previous is not done
    t4: crash
    t5: restart
    t6: find repo at hash Y

    no webhook(Y) was sent.

after:
    t0: hash changes to X
    t1: send webhook(X), waiting for response
    t2: hash changes to Y
    t3: queue next webhook(Y) but can't send because previous is not done
    t4: crash
    t5: restart
    t6: find repo at hash Y
    t7: send webhook(Y), waiting for response
2023-05-29 14:50:24 -07:00
Tim Hockin a4afa2f438 Improve logging levels a bit 2023-05-26 09:04:55 -07:00
Tim Hockin 7797e5d0e3 Log actual flags rather than args+env 2023-05-24 10:52:39 -07:00
Tim Hockin 9318041657 Better logging around hooks
This also returns stderr distinct from stdout.
2023-05-24 10:52:21 -07:00
Tim Hockin ed170912c9 Move main.go to root of repo
This allows `go install k8s.io/git-sync` which I like.
2023-05-22 08:40:24 -07:00
Tim Hockin f3565bf410 Move flag defs into main() 2023-05-16 16:11:03 -07:00
Tim Hockin 8ee0f7ef9a Update README and other docs 2023-05-16 16:10:50 -07:00
Tim Hockin e15c7a9695 Tighten up cleanup to be called once per loop 2023-05-16 16:10:23 -07:00
Tim Hockin 451ac415ea Add a unit test for touch() 2023-05-16 16:10:07 -07:00
Tim Hockin c3a49e9d46 Get rid of "must not start with ." logic
It serves very little purpose and isn't even correct as-is.
2023-05-14 11:11:24 -07:00
Tim Hockin ff1a913bab Reorganize flag definitions 2023-05-14 11:10:17 -07:00