Commit Graph

16 Commits

Author SHA1 Message Date
Sunny e3be50e586 controllers/update_test.go: Update to use testenv
Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-09-28 18:28:36 +05:30
Sunny 2eb00a6107 Add testenv TestMain and move ginkgo to legacy
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>
2021-09-23 02:10:47 +05:30
Michael Bridgen fd52463ac5 Use v1beta1 of the API from image reflector
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>
2021-06-28 13:59:34 +01:00
Michael Bridgen 5b9631327f Graduate v1alpha2 API to v1beta1
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>
2021-06-28 11:26:59 +01:00
Max Jonas Werner 93782755ef
feat: add controller concurrency
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>
2021-06-24 20:15:00 +02:00
Stefan Prodan 833b50fdee
Move to ImagePolicy v1alpha2
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-04-22 10:03:22 +03:00
Michael Bridgen cd8a2e97b8 Flip the controller and tests to API v1alpha2
This finishes the v1alpha2 API, and rewrites everything needed so that
the controller supports it and the tests pass. For the most part, that
is just changing the location of fields. However, there's a few
notable extras:

 - check that the `sourceRef` is a git repo (that's the default), and
   that a `.spec.git` is supplied;

 - change a test that blindly patched an update object, so that it
   first gets the object it's patching. Previously, it succeeded
   because it was OK to patch everything to empty strings, but that's
   no longer the case since SourceReference.Kind is an enum.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-04-13 10:45:58 +01:00
Stefan Prodan 7c5d7b81a6
Add update path test
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-03-16 15:31:34 +02:00
Hidde Beydals 0531deaaed Upgrade controller-runtime to v0.7.0
This commit upgrades the `controller-runtime` dependency to `v0.7.0`,
including all changes required to make all wiring work again.

- Upgrade `runtime` to v0.6.2 to include `controller-runtime` changes.
- Logger has been removed from the reconciler, and is now retrieved
  from the `context.Context` passed to the `Reconcile` method and
  downwards functions.
- Logger configuration flags are now bound to the flag set using
  `BindFlags` from `runtime/logger`, ensuring the same contract across
  GitOps Toolkit controllers, and the `--log-json` flag has been
  deprecated in favour of the `--log-encoding=json` default.
- The `ChangePredicate` from `runtime` has changed to a
  `ReconcileRequestedPredicate`, and is now chained with the
  `GenerationChangedPredicate` from `controller-runtime` using
  `predicate.Or`.
- Signatures that made use of `runtime.Object` have changed to
  `client.Object`, removing the requirement to e.g. call
  `runtime.Object#Object`.
- The `leader-election-role` was changed, as leader election now works
  via the `coordination/v1` API.

Other notable changes:

- Upgrade of `image-reflector-controller` API package to include
  controller-runtime changes.
- Upgrade of `source-controller` API package to v0.6.1.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-01-14 13:48:37 +01:00
Michael Bridgen 7d816f3e69 Exit without updating status if suspended
The convention is now to simply exit, when a GOTK object is
suspended. Previously this would update the status to indicate that it
was unready; now it just leaves it in whichever state it was before.

This also applies to the reconcile request annotation; it will _not_
be marked as seen if the object is suspended. The effect of this is
any change to the object will be passed by the predicate and therefore
reach Reconcile, until the object is unsuspended. Since it will _also_
exit early until unsuspended, this is harmless except for some extra
log lines. (But changing that ordering might be worth considering in
the future.)

This change required a few changes to tests:

 - to check that suspend makes the reconciliation exit without doing
   anything, explicitly run `r.Reconcile(...)`.

 - to avoid waiting for the reconciler's caching client to see
   changes, use an uncached client.

 - (fix a problem caused by comparing a time pointer with its alias)

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-30 15:15:34 +00:00
Hidde Beydals bf8c2deeb7 Make the API package a dedicated module
This includes changes to:

* Bump the Kubernetes dependencies to v1.19.3 to align
  with the other toolkit controllers.
* Update controller-runtime dependency to v0.6.3 to align
  with the other toolkit controllers.
* Update the source-controller dependency to the most recent
  v0.2.2 version to include the v1beta1 API.
* Add the `pkg/gittestserver` dependency for the Git tests,
  as this package was removed in a newer source-controller version.
* Bump the Go version to v1.15.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-11-19 12:16:17 +01:00
Hidde Beydals 29c60ecc6e Change copyright to Flux authors
Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-10-27 17:57:31 +01:00
Michael Bridgen ab4a963d50 Change package name and fixup imports and paths 2020-08-10 18:09:57 +01:00
Michael Bridgen 48aac78343 Reassign copyright to Flux project 2020-08-10 17:48:24 +01:00
Michael Bridgen 97393366da Test controller to the point of committing changes
This adds a test for the controller, checking that it will commit and
push a change, with the given commit message. I think checking it made
the right change will need a bit of rejigging tests elsewhere, so I
can compare directory contents (as with pkg/update tests).
2020-07-23 18:20:35 +01:00
Michael Bridgen a048169819 Add ImageUpdateAutomation type and controller
kubebuilder create api --group image --version v1alpha1 \
      --kind ImageUpdateAutomation
2020-07-23 18:14:28 +01:00