Commit Graph

68 Commits

Author SHA1 Message Date
Kaden Nelson 518a846596
Add a finalizer to the ImagePolicy and ImageRepository resources
Fixes https://github.com/fluxcd/image-reflector-controller/issues/225

This PR adds a finalizer to the ImagePolicy and ImageRepository resources. This is to properly record the Deleted reconciliation status when the object is deleted from the cluster. Without this change, the resource would be deleted before the image reflector controller has a chance to properly report the resource's status in the metrics. As a result, end-users may see falsely reported metrics.

Signed-off-by: Kaden Nelson <kaden_l_nelson@apple.com>
2022-06-24 10:57:19 +03:00
Stefan Prodan beecbbcec8
Update dependencies
- k8s.io/* 0.24.1
- aws-sdk-go v1.44.29
- go-containerregistry v0.9.0
- fluxcd/pkg/apis/meta v0.14.2
- fluxcd/pkg/runtime v0.16.2

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-06-08 12:29:27 +03:00
Stefan Prodan 5967ee9f52
Update API package to go-yaml v3.0.0
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-05-27 12:31:07 +03:00
Paulo Gomes 7d08b5175f
Update dependencies
- github.com/fluxcd/pkg/apis/meta v0.14.1
- github.com/fluxcd/pkg/runtime v0.16.1
- github.com/aws/aws-sdk-go v1.44.23
- github.com/fluxcd/pkg/runtime 0.16.1
- gopkg.in/yaml.v3 v3.0.0

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-05-26 19:24:16 +01:00
Stefan Prodan 7278aa9725
Update dependencies
- fluxcd/pkg/apis/meta v0.14.0
- fluxcd/pkg/runtime v0.16.0
- k8s.io/* v0.24.0
- aws/aws-sdk-go v1.44.11

Note that fluxcd/pkg/runtime v0.16 comes with support for Kubernetes API Priority and Fairness feature.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-05-11 18:44:45 +03:00
Sanskar Jaiswal a089f86a88 Add `exclusionList` to enable excluding tags based on regex.
ExlusionList specifies a list of regex expressions, which is used to
filter out unwanted tags from being stored in the database. If the list
is empty, by default all tags ending with `.sig` are ignored.

Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
2022-05-10 13:45:06 +05:30
Stefan Prodan 6da7098a42
Update dependencies
- github.com/fluxcd/pkg/runtime v0.14.2
- github.com/fluxcd/pkg/apis/meta v0.13.0
- k8s.io/* v0.23.6
- github.com/aws/aws-sdk-go v1.44.5
- github.com/onsi/gomega v1.19.0

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-05-03 15:29:50 +03:00
Rashed Kamal 47a612cc79 Adds ServiceAccountName for ImageRepository API
Signed-off-by: Rashed Kamal <krashed@vmware.com>
2022-05-02 16:08:47 -04:00
Hidde Beydals d49506ca7d api: update dependencies
- github.com/fluxcd/pkg/apis/meta to v0.12.2
- k8s.io/apimachinery to v0.23.5
- sigs.k8s.io/controller-runtime to v0.11.2

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-19 14:57:07 +02:00
Hidde Beydals 66fa3dfe07 Implement `meta.ObjectWithConditions` interfaces
Follow up on #235 to fully implement new tooling requirements. By
implementing the interfaces, the `conditions` package can now be used.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-03-22 15:12:43 +01:00
Hidde Beydals 19aafec61b Update Go Modules with `-compat=1.17`
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-03-21 12:05:12 +01:00
Hidde Beydals 0adba3dd47 api: update dependencies
- sigs.k8s.io/controller-runtime to v0.11.1

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-03-18 15:50:03 +01:00
Sunny b696275eb6
use new standardized runtime and meta package
Signed-off-by: Sunny <darkowlzz@protonmail.com>
2022-03-18 00:10:18 +05:30
Michael Bridgen 42aa8ed657 Use fluxcd/pkg/{apis,runtime}/acl for ACLs
This commit replaces the local ACL-related API types, and the func for
checking access, with their standarised forms in fluxcd/pkg/apis/acl
and fluxcd/pkg/runtime/acl respectively.

The test case for "When the ACL is empty, it denies access" needed
adjustment because the zero value of acl.AccessFrom is not valid -- it
needs an explicit list of namespace selectors. Providing `nil` in the
test case is the equivalent of providing a zero value.

Signed-off-by: Michael Bridgen <michael@weave.works>
2022-01-27 17:20:27 +00:00
Aurel Canciu 8a46f14552
Update flux pkg components
Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
2022-01-06 23:11:14 +01:00
Aurel Canciu f1ea6b6bf5
Update Go to v1.17
Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
2022-01-06 22:00:18 +01:00
Tom Huang 293bf80588 Set default observedGeneration to -1
This ensures tools like `kstatus` do not consider the resource to be in
a `Ready` state premataturely due to `generation` and
`observedGeneration` equaling to `0` for a short period of time.

Signed-off-by: Tom Huang <tom.huang@weave.works>
2021-11-22 13:42:39 +01:00
Hidde Beydals 6ca3869a96 Update dependencies
- Update `github.com/aws/aws-sdk-go` to `v1.42.9`
- Update `github.com/dgraph-io/badger/v3` to `v3.2103.2`
- Update `github.com/google/go-containerregistry` to `v0.7.0`
- Update `k8s.io/*` to `v0.22.2`
- Update `sigs.k8s.io/controller-runtime` to `v0.10.2`

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-11-22 13:06:46 +01:00
Stefan Prodan 8f4ae31562
Add test for empty label selector and fix ACL name
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-08-06 16:44:37 +03:00
Stefan Prodan 52960ab911
Add image repository access control list to API
- add `AccessFrom` to ImageRepositorySpec for granting cross-namespace access to repositories
- change `ImageRepositoryRef` type from local reference to namespaced reference

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-08-06 11:54:55 +03:00
Stefan Prodan a186041467
Update dependencies
- k8s.io/* v0.21.3
- controller-runtime v0.9.5
- badger v3.2103.1

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-08-05 12:48:53 +03:00
Michael Bridgen 58e7a1539d Graduate v1alpha2 API to v1beta1
The schema is the same, which means this is a case of

 - copying over the type definitions;
 - changing the "stored" CRD version;
 - giving a CRD conversion of None, meaning just change the apiVersion;
 - using the new API package in the controller code;
 - moving the API docs to v1beta1

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-06-24 15:50:11 +01:00
Stefan Prodan 0539836ef3
Update dependencies
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-08 15:12:51 +03:00
Stefan Prodan dfd180ff03
Update Go to v1.16
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-03 11:33:11 +03:00
Michael Bridgen ced5d88fe6 Move from v1alpha1 to v1alpha2 API
The image automation part of the API has changed structure (see [1]),
and had a version bump from `v1alpha1` to `v1alpha2`. Since the types
here are also in `image.toolkit.fluxcd.io`, there will be less
complication if they also get a version bump even though they aren't
changing.

[1] https://github.com/fluxcd/image-automation-controller/pull/139

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-04-21 15:58:59 +02:00
Stefan Prodan 3eb929c0a1
Update fluxcd/pkg/runtime to v0.11.0
Followup https://github.com/fluxcd/pkg/pull/96

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-04-21 13:21:58 +03:00
Stefan Prodan 5bfd72632e
Update dependencies
- github.com/fluxcd/pkg/runtime v0.8.4
- sigs.k8s.io/controller-runtime v0.8.3

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-03-15 18:22:59 +02:00
Aurel Canciu 428594f3e5
Fix "last scan" print column for ImageRepository
Fixes #118

Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
2021-03-12 12:47:34 +02:00
Stefan Prodan ba4734a637
Update dependencies
- google/go-containerregistry v0.4.0
- sigs.k8s.io/controller-runtime v0.8.2
- fluxcd/pkg/apis/meta v0.8.0
- fluxcd/pkg/runtime v0.8.3

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-02-23 17:09:54 +02:00
Stefan Prodan 6dde733498
Add numerical policy to API docs
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-02-11 14:04:29 +02:00
Aurel Canciu 2def150710
Implement numerical ordering policy
Converts the given list of tags to floats and compares them based on the
ordering rule.
If a tag is not convertible, it will err and fail to compute the latest
version.

Fixes #102

Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
2021-02-11 13:06:50 +02:00
Michael Bridgen 482be97e88 Switch to fluxcd/pkg/meta.LocalObjectReference
This comes with less baggage than the corev1 original.

(While I was here, I updated the fallback controller-gen version to
0.4.1, which gives much better error messages.)

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-01-26 15:35:12 +00:00
Michael Bridgen bbd55c8a93 Implement use of certs from a secret
This implements the design in #89, so you can provide a TLS
certificate and key to use for authentication; and, a CA certificate
for when you are using self-signed certs.

Unlike other GOTK controllers, the certificate secret is separate to
the credentials secret. This is because the credentials secret is more
likely to be a dockerconfigjson secret (i.e., created with

    docker create secret docker-registry ...

or its equivalent).

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-01-26 15:35:12 +00:00
Stefan Prodan 539409d3db
Update fluxcd/pkg/runtime to v0.8.0
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-01-21 18:46:33 +02:00
Stefan Prodan 573568d0b0
Update Kubernetes packages to v1.20.2
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-01-16 15:48:25 +02:00
Aurel Canciu cbcad122f9
Implement policy-level tag regex filtering
Tag regex filtering allows the user to filter tags based on a regular
expression pattern and enables tag version extraction through capture
group replacement reference.

Fixes #73

Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
2021-01-13 16:42:40 +02:00
Hidde Beydals 6283fbb3da 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.
- 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
  `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 `leader-election-role` was changed, as leader election now works
  via the `coordination/v1` API.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-01-13 12:34:28 +01:00
Michael Bridgen 435b390391 Bump all fluxcd dependencies
Signed-off-by: Michael Bridgen <michael@weave.works>
2020-12-10 13:03:21 +00:00
Aurel Canciu 9be3bc2325
Implement Alphabetical order policy
This implementation allows one to set a `MatchTagPrefix` to filter a
list of tags and/or use `Order` to set the ordering rule by which tags
are evaluated.

Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
2020-12-09 21:02:42 +02:00
Michael Bridgen 379f2822db Give ImagePolicy objects a readiness condition
This adds the conventional Conditions field to the ImagePolicy status,
and sets the status in the controller as well as reporting readiness
metrics.

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-12-04 12:11:40 +00:00
Michael Bridgen e6de16930a Make the ImageRepositoryStatus empty when empty
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>
2020-12-03 11:43:26 +00:00
Michael Bridgen 24dc118ead Add generated API documentation
(after a couple of tweaks:)

    make api-docs

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-30 14:21:46 +00:00
Michael Bridgen 9cee16d37b Add API doc generation to Makefile
This is a close adaptation of what's in fluxcd/kustomize-controller.

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-30 14:01:50 +00:00
Aurel Canciu 5eec08d232
Refactor and align with stable components patterns
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>
2020-11-23 20:38:54 +02:00
Aurel Canciu 5f616499ed
Bump pkg/apis/meta to v0.4.0
Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
2020-11-20 17:28:23 +02:00
Aurel Canciu ff67c99ed3
Update golang version to 1.15
Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
2020-11-12 12:53:34 +02:00
Aurel Canciu 0b9d4ff3e9 Update pkg/apis/meta to v0.3.0
Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
2020-11-12 10:45:06 +00:00
Aurel Canciu ba7800eaf6 Adopt k8s standardized conditions
Use the newly introduced standardized Condition type kubernetes/enhancements#1624

Relates to fluxcd/flux2#225

Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
2020-11-12 10:44:57 +00:00
Michael Bridgen dcb88a2490 Add SecretRef field for credentials
This commit adds a field to the ImageRepository spec for referring to
a secret containing credentials. The credentials are then available to
use for scanning the registry.

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-10 17:25:10 +00:00
Aurel Canciu 5cfeb21ebc
Update pkg components and k8s to 1.19
Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
2020-11-01 18:18:00 +02:00