This ensures the Dockerfile used for testing is making use of the
same scratch image to compile `libgit2` as the actual application
image.
In a future iteration we should restructure our GitHub Action
workflows to re-use the application image, saving us an additional
Dockerfile and a duplicate build. Inspiration for this (which makes
use of a local registry for the duration of the build) can be found
at: https://github.com/fluxcd/golang-with-libgit2/blob/main/.github/workflows/build.yaml
Signed-off-by: Hidde Beydals <hello@hidde.co>
This moves the `libgit2` compilation to the image, to ensure it
can be build on builders that aren't backed by AMD64.
The image is structured in such a way that e.g. running nightly
builds targeting a different Go version, or targeting a different
OS vendor would be possible in the future via build arguments.
Signed-off-by: Hidde Beydals <hello@hidde.co>
This commit updates `github.com/libgit2/git2go` to `v31.6.1` (with
`libgit2` `1.1.1`), and changes the container image build process so
that it makes use of `ghcr.io/hiddeco/golang-with-libgit2`.
This image provides a pre-build dynamic `libgit2` dependency linked
against OpenSSL and LibSSH2 (without gcrypt), and a set of cross-compile
build tools (see
[rationale](https://github.com/hiddeco/golang-with-libgit2#rationale) and
[usage](https://github.com/hiddeco/golang-with-libgit2#usage) for more
detailed information).
The linked set of dependency should solve most known issues around
unsupport private key types, but does not resolve the issues with ECDSA*
and ED25519 hostkeys yet. Solving this requires a newer version of
`libgit2` (`>=1.2.0`), which currently does not seem to work properly
with `git2go/v32`.
Signed-off-by: Hidde Beydals <hello@hidde.co>
- Detection of the system version of `libgit2` is attempted using
`pkg-config`. If this fails, or does not match the version as defined
in the `Makefile` (or configured using `LIBGIT2_VER=1.x.y`), the
library is compiled using the instructions from the `BASE_IMG`, and
installed to `REPOSITORY_ROOT/hack/libgit2`.
- Where `libgit2` is required as a dependency, `LD_LIBRARY_PATH` and/or
`PKG_CONFIG_PATH` instructions are added as a prefix to the command.
This works for system libraries as well, because the paths are
ignored if they do not exist.
Signed-off-by: Hidde Beydals <hello@hidde.co>
github.com/fluxcd/pkg/runtime/logger now supports the trace log level,
and has consts for the V(...) argument to supply. This commit updates
that module so to use those consts.
Previously, trace messages were output at the debug level; after this
commit they will be in their own level, so you need
--log-level=trace
to see them.
Signed-off-by: Michael Bridgen <michael@weave.works>
libgit2's Push method will succeed even when ref updates are rejected,
meaning it can silently fail if you e.g., use branch protection in
GitHub.
To make these errors visible, a callback is supplied to Push, which
checks for a non-empty status (on the advice of
https://libgit2.org/libgit2/#HEAD/group/callback/git_push_update_reference_cb).
For whatever reason, gogit seems overly sensitive to hook errors (in a
way that `git` and libgit2 aren't), and reports "invalid pkg-len
found" when it sees a rejected ref message. This doesn't affect the
runtime code, since that uses libgit2 -- but it does affect the test
code, which initialises the git repo used in many tests, so more care
is needed to push only the main branch, so as not to trigger a
rejection.
Signed-off-by: Michael Bridgen <michael@weave.works>
This bumps the version of the image reflector types to v1beta1. This
doesn't technically make a difference for the minute, since the
Kubernetes API server would convert between versions, but is tidier.
Signed-off-by: Michael Bridgen <michael@weave.works>
This bumps the image reflector CRDs, used in tests, to the release
including v1beta1.
It also removes a long-standing, occasional annoyance, which is that
the downloaded CRDs would conflict with each other unless you
remembered to do `make clean-test-deps`. Though you will have to do
that once more.
Signed-off-by: Michael Bridgen <michael@weave.works>
The guides are kept in versioned directories, but only one version
appears to make it to the documentation website. For that reason,
rather than trying to refer to the previous version's migration guide,
I've just copied it and adapted it minimally to the new version.
Signed-off-by: Michael Bridgen <michael@weave.works>
This does the following:
- copies the type definitions from v1alpha2 to v1beta1
- changes the "stored" version to v1beta1
- gives the CRD a conversion strategy of None, meaning just rewrite the version
- switches the controller to use v1beta1
- moves the generated documentation to v1beta1
This effectively rebadges the v1alpha2 version of this part of the
image API to v1beta1. The v1alpha2 version is left in place; there are
no conversion issues, as with v1alpha1->v1alpha2. The CRD specifies
that converting between v1alpha2 and v1beta1 just means changing the
version (i.e., the schema and semantics are the same).
Signed-off-by: Michael Bridgen <michael@weave.works>
The controller is now working with 4 concurrent workers by default.
This value is configurable through the `--concurrent` flag.
Signed-off-by: Max Jonas Werner <mail@makk.es>
- trace different code paths, e.g., how the push branch is chosen
- move debug output so it records things not already covered by e.g.,
errors, events
Signed-off-by: Michael Bridgen <michael@weave.works>
This commit finesses the use of the debug log a little, and introduces
a trace log. The trace log gets threaded through calls to utility
procedures -- it's a little awkward putting loggers into func
parameters and structs, but it always is.
Signed-off-by: Michael Bridgen <michael@weave.works>
It's useful to be able to run with debug logging, which you can do now
with:
make run LOG_LEVEL=debug
As a companion change, logging from `make run` is now explicitly set
to console format, since the expectation is it will be run from a
console.
Signed-off-by: Michael Bridgen <michael@weave.works>