Commit Graph

25 Commits

Author SHA1 Message Date
kane8n 3999c651b1
SparseCheckout when Spec.Update.Path specified
Signed-off-by: kane8n <takumi.kaneda@zozo.com>
2025-06-17 18:00:07 +09:00
Matheus Pimenta 806d41081a
Update digest of latest image
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-05-28 10:13:23 +01:00
Matheus Pimenta 68b9bc7d0d
Update to Kubernetes 1.33.0 and Go 1.24.0
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-05-03 16:47:50 +01:00
Matheus Pimenta 640aa7a79b
Delete cache entries on object deletion
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-05-02 12:44:54 +01:00
lukas8219 93534085af fix(imageupdateautomation_controller.go): fixed tag parsing logic misinterpreting [host:port] registry url
Signed-off-by: lukas8219 <lucas.c4d@gmail.com>
2025-04-29 11:43:00 -03:00
Matheus Pimenta 8414fa2aa0
Introduce token cache and use it for GitHub App tokens
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-03-12 14:47:30 +00:00
Dipti Pai c1c5cc14a8 Fix image update automation RBAC
Signed-off-by: Dipti Pai <diptipai89@outlook.com>
2024-09-10 08:13:35 -07:00
Max Jonas Werner dc1a6154b8
Bump API deps; bump remaining main deps
Signed-off-by: Max Jonas Werner <max.werner@associmates.eu>
2024-08-15 11:05:51 +02:00
Florian Forster 25730b122d
Fix incorrect use of format strings with the `conditions` package.
The `Mark…` functions in the `conditions` package accept a format string and
(optional) arguments, just like `fmt.Printf` and friends.

In many places, the code passed an error message as the format string, causing
it to be interpreted as a format string by the `fmt` package. This leads to
issues when the message contains percent signs, e.g. URL-encoded values.

This PR adds a format string and shortens `err.Error()` to `err`, which yields
the same output.

This change is identical in principle to fluxcd/source-controller#1529.

Signed-off-by: Florian Forster <fforster@gitlab.com>
2024-07-12 09:24:37 +02:00
Maxim Samoilov d0a24940d6 Add support to limit applied policies in automation by specifying a selector
Signed-off-by: Maxim Samoilov <nitive@icloud.com>
2024-04-18 16:37:12 +05:30
Sunny edc5cee43d Add new reconciler using new v1beta2 API
Introduce the rewritten reconciler which uses v1beta2 API and the new
internal/policy and internal/source packages for performing all the
operations. The reconciliation model is written similar to the other
flux controller, with simplified events and logs, and kstatus support.
The reconciliation result computation similar to
image-reflector-controller, using the same reconciler helpers from
pkg/runtime repo.

With the new status fields ObservedPolicies and ObservedSourceRevision,
the reconciler now avoid full sync of the source which involves cloning
the source every time. If the policies and the remote source have not
changed since the last reconciliation, the reconciliation is returned
early without cloning and apply the updates. This is only applicable
when the checkout branch and the push branch are the same. For a
different push branch and refspec, full sync is always performed as
before.

Notifications are now only sent when there's something new to inform
about. If there is no change, an source up-to-date notification is sent.
When there's an update, the details about the pushed commit with any
rendered commit template is send. When there's a failure, the error is
sent in the notification. And when there's an error recovery, a success
notification is sent to rely that the automation has recovered.

Signed-off-by: Sunny <github@darkowlzz.space>
2024-04-18 16:16:09 +05:30
Sunny d810aa6a46 Remove old imageupdateautomation_controller.go
Since the reconciler is being completely rewritten, remove the old
controller file. A new controller file with the new implemementation
will be added in the following commit.

Signed-off-by: Sunny <github@darkowlzz.space>
2024-04-18 16:16:09 +05:30
Sunny b424607308
Add predicates for GitRepo and ImagePolicy watches
ImageUpdateAutomationReconciler watches GitRepository and ImagePolicy
kinds for every event. This leads to unnecessary extra reconciliations
at times. For example when the controller starts with existing
resources, the same ImageUpdateAutomation object gets reconciled at
least twice, once due to the watch on ImageUpdateAutomation startup
and again due to the watches on GitRepository and ImagePolicy for create
event, as they get registered in the cache.

Add predicates to filter the ImagePolicy to only allow events for latest
image update, and GitRepository to only allow events for change in the
source configuration.

Signed-off-by: Sunny <github@darkowlzz.space>
2024-02-26 22:27:20 +00:00
Sanskar Jaiswal db8a2577c7
add tests to check object's status message
Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
2023-09-18 14:01:37 +05:30
Sanskar Jaiswal 73466b6a5a
fix push branch reporting if its equal to checkout branch
Fix the push branch reported in the logs and status if
`.spec.git.push.branch==.spec.git.checkout.branch`.

Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
2023-09-18 14:01:36 +05:30
Sanskar Jaiswal 1dd0e63924
add support for specifying push options
Add `.spec.git.push.options` to allow specifying the push options to be
sent to the upstream Git server during a push operation. For more info,
see: https://git-scm.com/docs/git-push#Documentation/git-push.txt---push-optionltoptiongt

This is useful for platforms like GitLab when used with
image-automation-controller by enabling the creation of MRs automatically
upon a push operation (ref: https://docs.gitlab.com/ee/user/project/push_options.html#push-options-for-merge-requests)

Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
2023-08-23 20:48:09 +05:30
Sanskar Jaiswal 6f07aad390
add proxy support for Git operations
Add proxy support for Git operations using the proxy configuration
specified in the source GitRepository's `.spec.proxySecretRef`.

Refactor the Git client building process to make it more testable.

Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
2023-08-23 18:31:40 +05:30
Sanskar Jaiswal 68ad71b1b3
git: add push.refspec to push using a refspec
Add `.spec.git.push.refspec` to allow specifying a refspec to be used
for performing a push operation. If specified alongside
`.spec.git.push.branch`, two push operations, one for each specified
push configuration will be performed.

Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
2023-08-23 17:39:40 +05:30
Sunny e27a9e2482
Delete stale metrics on object delete
The metrics helper now accepts owned finalizers to determine if an
object is no longer managed by the controller and is being deleted, and
deletes the metrics associated with the object.

Call the metrics recording defer function in controller early to be able
to record the object in deleting state.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-08-11 19:46:58 +05:30
Sunny eabd20bef8 Handle delete before adding finalizer
In Reconcile() method, move the object deletion above add finalizer.
Finalizers can't be set when an object is being deleted.

Introduce a cacheless client in suite_test to use for testing this
change. It ensures that the Reconcile() call always operates on the
latest version of the object which has the deletion timestamp and
existing finalizer.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-07-31 15:32:48 +05:30
Sanskar Jaiswal faf265e79b
check if GPG private key is nil before decrypting
Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
2023-06-06 18:42:52 +05:30
Hidde Beydals 76a9b2381d Return signing entity parsing error
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-05-31 13:24:25 +02:00
Hidde Beydals bfb2a978ad Set controller package name
Set package name in the files under internal/controller to have the
base name of the directory.

This style is recommended by Go, and certain text editors/IDEs get
confused when the names don't match.

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-05-31 13:15:46 +02:00
Hidde Beydals 2f82afbf55 Drop go-git fork in favor of go-git v5.7.0
This replaces the `fluxcd/go-git` fork with official go-git v5.7.0
release, after all patches from the fork have been included
upstream.

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-05-25 14:11:08 +02:00
Hidde Beydals 7cc9c9c5f4 Rename controllers to controller
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-05-25 10:08:03 +02:00