This adds a `reconcile` package with the reconciliation and (status)
observation logic for individual Helm actions, but no glue to loop
through them till desired state.
All actions have individual `ActionReconciler` implementations which
construct their `action.Configuration` out of a factory, so the Helm
client can be shared between sub-reconcilers. They all present a
`ReconcilerType`, allowing an iterator to e.g. stop after running
every type just once.
The observation model can be explained as follows, but may lack some
minor details:
- The observed release has to match the release target of the
HelmRelease object
- ActionReconcilers of type "release" move Current to Previous
when they see a higher release revision. They then write the
new release to Current, and continue to observe writes to
revisions that match either version
- Remediation only updates Current
- Test updates Current and Current.TestHooks
- Unlock updates Current
After running the action, the reconcilers observe both the action
result and the state of the object. This allows them to distinguish
certain types of errors which are otherwise hard to detect.
For example, errors which do not cause drift to the Helm storage, or a
change of release version compared to Current for actions which do not
provide a version target flag.
Signed-off-by: Hidde Beydals <hello@hidde.co>
This commit introduces an `action` package which allows the consumer to
run Helm actions using the instructions from a `HelmRelease` v2beta2
API object.
The actions do not determine if there is a desire be run, nor do they
record state on the object. This can however be injected by the caller
using the simplified observing Helm storage driver, which now iterates
over a list of callback functions after persisting an object instead
of keeping state.
This separation of concerns would allow e.g. the Flux CLI later on
to run actions (but with a dry-run flag or different storage
configuration) using the object in the same manner as the controller.
Some minor changes have been made to the `postrender` and `runner`
package to allow the code to co-exist while we are inbetween API
versions.
Signed-off-by: Hidde Beydals <hello@hidde.co>
This adds an observer which wraps around a Helm storage driver, to keep
track of the release metadata as written to the storage. This enables
you to work with, and compare release data as persisted by Helm.
Without having to rely on the result as returned by the Helm SDK. Which
at times of an error, may differ from last written state.
The observer does at present expect to be watching a single namespace,
and was designed without working with multiple releases simultianiously
into account, although this should theoretically still work.
The releases are at stored in a simple map by index storage key, which
are unique to the namespace. The `ObservedRelease` objects the keys hold are
overwritten on sequential writes to the same release object, and
returned by getter methods as deep copies.
This could theoretically be changed to observing e.g. all writes, I have
left this as a refinement TODO while actually implementing it in the
reconciler. The same goes for the included metadata, which might be not
all relevant.
Signed-off-by: Hidde Beydals <hello@hidde.co>