Commit Graph

25 Commits

Author SHA1 Message Date
Hidde Beydals 4ac2c1a26c controllers: HelmChart Reconcile test
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-02-15 15:55:45 +05:30
Hidde Beydals 54150299a3 controllers: remove legacy test suite
As it no longer contains any test cases.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-02-15 15:55:44 +05:30
Hidde Beydals 7f4f80bab4 Rewrite `HelmRepositoryReconciler` to new standards
This commit rewrites the `HelmRepositoryReconciler` to new standards,
while implementing the newly introduced Condition types, and trying to
adhere better to Kubernetes API conventions.

More specifically it introduces:

- Implementation of more explicit Condition types to highlight
  abnormalities.
- Extensive usage of the `conditions` subpackage from `runtime`.
- Better and more conflict-resilient (status)patching of reconciled
  objects using the `patch` subpackage from runtime.
- Proper implementation of kstatus' `Reconciling` and `Stalled`
  conditions.
- Refactoring of some Helm elements to make them easier to use within
  the new reconciler logic.
- Integration tests that solely rely on `testenv` and do not
  use Ginkgo.

There are a couple of TODOs marked in-code, these are suggestions for
the future and should be non-blocking.
In addition to the TODOs, more complex and/or edge-case test scenarios
may be added as well.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-02-15 15:55:44 +05:30
Hidde Beydals e26a0c3b6a Rewrite `BucketReconciler` to new standards
This commit rewrites the `BucketReconciler` to new standards, while
implementing the newly introduced Condition types, and trying to
adhere better to Kubernetes API conventions.

More specifically it introduces:

- Implementation of more explicit Condition types to highlight
  abnormalities.
- Extensive usage of the `conditions` subpackage from `runtime`.
- Better and more conflict-resilient (status)patching of reconciled
  objects using the `patch` subpackage from runtime.
- Proper implementation of kstatus' `Reconciling` and `Stalled`
  conditions.
- Refactor of reconciler logic, including more efficient detection of
  changes to bucket objects by making use of the etag data available,
  and downloading of object files in parallel with a limited number of
  workers (4).
- Integration tests that solely rely on `testenv` and do not
  use Ginkgo.

There are a couple of TODOs marked in-code, these are suggestions for
the future and should be non-blocking.
In addition to the TODOs, more complex and/or edge-case test scenarios
may be added as well.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-02-15 15:55:44 +05:30
Hidde Beydals 29caae3fca Rewrite `GitRepositoryReconciler` to new standards
This commit rewrites the `GitRepositoryReconciler` to new standards,
while implementing the newly introduced Condition types, and trying
to adhere better to Kubernetes API conventions.

More specifically it introduces:

- Implementation of more explicit Condition types to highlight
  abnormalities.
- Extensive usage of the `conditions` subpackage from `runtime`.
- Better and more conflict-resilient (status)patching of reconciled
  objects using the `patch` subpackage from runtime.
- Proper implementation of kstatus' `Reconciling` and `Stalled`
  conditions.
- First (integration) tests that solely rely on `testenv` and do not
  use Ginkgo.

There are a couple of TODOs marked in-code, these are suggestions for
the future and should be non-blocking.
In addition to the TODOs, more complex and/or edge-case test scenarios
may be added as well.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-02-15 15:42:14 +05:30
Hidde Beydals 6ee2b95345 Implement new runtime interfaces, prepare testenv
This commit ensures all API objects implement the interfaces used by
the runtime package to work with conditions, etc., and prepares the
test suite to work with the `pkg/runtime/testenv` wrapper.

Changes are made in a backwards compatible way (that being: the
existing code can still be build and works as expected), but without
proper dependency boundaries. The result of this is that the API
package temporary depends on the runtime package, which is resolved
when all reconcilers have been refactored and the API package does
no longer contain condition modifying functions.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-02-15 15:40:57 +05:30
Hidde Beydals 78a63acd55 Switch to v1beta2 API package
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-02-15 15:40:57 +05:30
Paulo Gomes cd6d33c101
Increase gingko timeout to 60s
Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-02-08 17:49:51 +00:00
Paulo Gomes fa00ec8fc7
Migrate from deprecated ginkgo async testing
https://github.com/onsi/ginkgo/blob/ver2/docs/MIGRATING_TO_V2.md\#removed-async-testing

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-02-07 15:08:03 +00:00
Sanskar Jaiswal 2b8ede12cc fix makefile envtest and controller-gen usage
Refactor logic to install helper tools into one function in the
Makefile. Add support for envtest to help install tools like kubectl,
etcd which helps users run tests more conveniently.

Signed-off-by: Sanskar Jaiswal <sanskar.jaiswal@weave.works>
2022-01-13 16:48:04 +05:30
Hidde Beydals c4d7e46b90 Drop deprecated `io/ioutil`
The package has been deprecated since Go 1.16, see:
https://golang.org/doc/go1.16#ioutil

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-07-29 09:58:00 +02:00
Michael Bridgen 681ddd5db0 Test RecurseSubmodules
This commit adds a test specifically for RecurseSubmodules. It takes a
bit more preparation, since it needs a repo using submodules to start
with. go-git doesn't appear to support adding submodules
programmatically, so the preparation is done in part by execing `git`.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-03-31 12:22:10 +01:00
Hidde Beydals fda481efe9 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.0 to include `controller-runtime` changes.
- Loggers have been removed from the reconcilers and are 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
  `ReconcilateAtChangedPredicate`, 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 `client.MatchingField` function was deprecated, and has been
  replaced with `client.MatchingFields{}`.
- The `leader-election-role` was changed, as leader election now works
  via the `coordination/v1` API.

Other notable changes:

- `util.ObjectKey` was added to easily construct a `client.ObjectKey` /
  `types.NamespacedName` from a `metav1.Object`.
- The `SourceIndexKey` constant has been split out into
  `{GitRepository,HelmRepository,Bucket}IndexKey` constants.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-12-18 19:17:10 +01:00
Hidde Beydals 582c2092b6 Change copyright to Flux authors
Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-10-27 17:54:22 +01:00
stefanprodan f16e5f041a Promote API to v1beta1 2020-09-30 16:11:00 +03:00
Hidde Beydals 24f47ac183 Support Helm charts from GitRepository sources 2020-08-31 16:21:53 +02:00
Hidde Beydals c90be06345 Add constants for kind names 2020-07-10 12:07:54 +02:00
Hidde Beydals 77822bd4d1 controllers: simple GitRepository test 2020-05-29 14:24:31 +02:00
Hidde Beydals 6083d886ce controllers: add HelmChart reconciler tests 2020-04-17 19:21:48 +02:00
Hidde Beydals 3c70c8d333 controllers: test HelmRepository TLS auth 2020-04-17 10:41:24 +02:00
Hidde Beydals 1cc6464b73 controllers: test HelmRepository HTTP basic auth 2020-04-17 10:36:24 +02:00
Hidde Beydals a50ea436fa controllers: basic HelmRepository reconciler tests 2020-04-17 10:35:52 +02:00
Hidde Beydals d378bd1852 Introduce HelmChart API and controller
- Add the HelmChart types and controller
- Semver expressions are found by utilizing Helm repository index
  helpers. As Helm makes use of `masterminds/semver`, the support
  for i.e. ranges less mature than the `GitRepository` implementation.
- Recorded semver is as defined in the metadata of the chart. The
  used name for the artifact does however include the checksum of the
  chart archive, as chart maintainers may not always properly apply
  semver.
- Switches to `sigs.k8s.io/yaml` for YAML operations as this among
  other things is able to properly unmarshal embedded structures.
- Directly requeues on transient errors instead of using the defined
  interval as a back-off strategy is applied on repeated failures.
2020-04-12 18:44:37 +02:00
Hidde Beydals 4d30a82ef4 Rename project to source-controller 2020-04-08 16:12:17 +03:00
stefanprodan 92b7b1fe43 Scaffold repository controllers 2020-04-05 12:34:29 +03:00