This introduces a key/value store for tags, with the keys being the
images and the values being JSON encoded versions of the tags.
The Badger data is stored in a PVC.
Signed-off-by: Kevin McDermott <bigkevmcd@gmail.com>
The convention appears to be to not record any metrics for objects
that are suspended (unless they are also being deleted).
Signed-off-by: Michael Bridgen <michael@weave.works>
The zero value of an ImageRepositoryStatus includes a struct value in
LastScanResult, which prevents it from being omitted when
serialised. The effect is that a freshly-constructed ImageRepository
will serialise like this:
```yaml
apiVersion: image.toolkit.fluxcd.io/v1alpha1
kind: ImageRepository
metadata:
name: foobar
namespace: flux-system
spec:
image: alpine
interval: 1m0s
status:
lastScanResult:
tagCount: 0
```
This commit changes the LastScanResult field to a pointer
type, so it can be `nil` when not set.
The ScanTime field is changed from a pointer to a value, since it
should be present in any scan result.
Signed-off-by: Michael Bridgen <michael@weave.works>
This is an attempt to bring the api and controller logic closer to what
the other controller components already have set as patterns.
1. Adopt the k8s standard Condition type.
2. Rename `ScanInterval` to `Interval` to be consistent with the
`Interval` attribute other Spec types have defined, translating to
reconciliation interval. This attribute is now required.
3. Add `ScanTime` attribute to the `ScanResult` type, enabling keeping
track of the last successful scan execution. Use this value for scan
frequency throttling.
4. Add optional `Timeout` attribute to allow custom scan timeout
handling. The default value is equal to that of the `Interval` attr.
Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
Despite the name, the contract of the reconcileAt mechanism is that
_changing it_ should trigger reconciliation outside the otherwise
specified schedule. To detect changes, this commit adds a field to the
status, and updates it when a scan has run.
The GOTK controllers all use an annotation to trigger syncing outside
of the schedule (e.g., when a webhook is indicates a new
revision). This commit makes the ImageRepository controller respect
the annotation, by checking it when examining an image repo object.
This works a little different to the other controllers, which tend to
assume that any incoming event means a sync is due. The image
reflector controller uses the ChangedPredicate to filter incoming
evetns, as they do, but goes further to check the annotation and
otherwise, the scheduled scan time.
It's mooted in https://github.com/fluxcd/toolkit/discussions/164 that
a distinct metric is used for not completing reconciliation, as
opposed to an unexpected error. Until that discussion has run its
course, we should just do what the other controllers do, and that's
returning an error when the controller is unable to reconcile to
completion.
This also adds a comment noting the purpose of the redundant `Requeue:
true` fields, for the avoidance of confusion later.
This adds the details of calculating the latest image for a policy. It
relies on the ImageRepository and ImagePolicy controllers having a
shared database of image tags. Usually, this sort of thing would be
objects in the Kubernetes database; but since tags (and images) can
number in the tens of thousands per image, I'm using a separate
database. For the minute, it's just a map.
In this commit I use the test registry implementation to check that
the controller will scan the tags of an image. This needs a bit more
scaffolding, since the test registry doesn't handle /tags/list.
This commit adds a little code to scan the image repository given in
an ImageRepository resource, and report the (number of) tags there. It
does so anonymously, so it'll only work for public repos for the
minute.
The next step is to introduce ImagePolicy resources and figure out the
interaction with them -- e.g., if they only care about semver, you
might only need to get the tags.