Two steps:
1. TestDiffDirectories did not check if the expected only return value
was correct; the intention was there to do so (judging by the
comment "change in order"), but my eye for detail failed me.
2. Reversing the directory comparison in the test revealed bugs in the
comparison code -- in general, it should skip any directory that is
not a directory in the comparator.
To make this easier, the code now keeps track of the expected files it
saw. That means the check for whether an actual file has an expected
counterpart only has two cases, yes or no (rather that trying to
account for whether it's a directory and so on). If a directory was
skipped while scanning the expected files, it won't be in the actual
files anyway.
Signed-off-by: Michael Bridgen <mikeb@weave.works>
In controller-runtime v0.10.0, the client is updated to clean any stale
data in the target object when performing any operation. This results in
test failure for the code that constructs an object with both spec and
status, and creates the object and updates status it with the same
object. The fix is to set the status separately on the object before
updating it.
Refer: https://github.com/kubernetes-sigs/controller-runtime/pull/1640
Signed-off-by: Sunny <darkowlzz@protonmail.com>
Add new testenv based TestMain in suite_test.go and move the ginkgo test
setup to legacy_suite_test.go. This helps to run both the ginkgo tests
and testenv based tests.
Signed-off-by: Sunny <darkowlzz@protonmail.com>
This commit replaces the explicit use of event recorder and metrics
with the helpers from github.com/fluxcd/pkg/runtime.
Doing so necessitated a few consts to represent the event "reasons",
so it is not a mechanical translation. Without thinking overly long
about it, I came up with a handful of reasons that I think will be
useful for filtering.
Signed-off-by: Michael Bridgen <michael@weave.works>
A pretty straight-forward change. NB the location of the `defer ...`
_after_ the exit if the object is suspended; this maintains the
invariant that the object will not be touched at all when suspended.
Signed-off-by: Michael Bridgen <michael@weave.works>
This commit rewrites the controller code so it uses the conditions
helpers from fluxcd/pkg/runtime/conditions.
It needs the fluxcd/source-controller/api module from the
reconcilers-dev branch, otherwise they will disagree on the methods in
fluxcd/pkg/apis/meta. Hence, variations on
go get github.com/fluxcd/source-controller{,api}@reconcilers-dev
until I got both ./go.mod and ./api/go.mod to use modules from the
branch.
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>
- Go 1.16
- `sigs.k8s.io/controller-runtime` to `v0.9.0`
- `fluxcd/source-controller` to `v0.14.0`
- `fluxcd/pkg/*` to packages compatible with Go 1.16 and
controller-runtime v0.9.0
Signed-off-by: Hidde Beydals <hello@hidde.co>