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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>