Commit Graph

5 Commits

Author SHA1 Message Date
Stefan Prodan 00785fbfa3
Promote `HelmRelease` API to v2 (GA)
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-05-03 16:25:14 +03:00
Hidde Beydals 479341461a
action: allow composed release name >=53 char
This solves the issue where a release name composed out of e.g.
the target namespace and name of the HelmRelease itself would exceed
the >=53 character length. By calculating the SHA256 checksum of the
release name, taking the first 12 characters of this checksum and
appending it to the release named trimmed to 40 characters separated
by a hyphen (`<long-release-name>-abcdef12345678`).

Signed-off-by: Hidde Beydals <hello@hidde.co>
2023-11-20 12:06:07 +01:00
Hidde Beydals 9e1eedcfa4
api: various changes to support new logic
- Change the map with Helm release test hooks to a pointer map. This
  allows (in combination with the constrains around JSON serialization)
  to distinguish a release _without_ a test run from a release _with_
  test run but no tests (an empty map).
- Add `GetTestHooks` and `SetTestHooks` methods to help circumvent some
  of the common problems around working with a pointer map in Go (e.g.
  not being capable of iterating over it using range).
- Add `HasBeenTested` and `HasTestInPhase` methods to help make
  observations on captured release information.
- Add `StorageNamespace` to Status to allow for observations of
  configuration changes which are mutating compared to the spec.
- Add `GetActiveRemediation` helper method to get the active
  remediation strategy based on the presence of Current and/or Previous
  release observations in the Status of the object.
- Add `ReleaseTargetChanged` helper method to determine if an immutable
  release target changed has occurred, in which case e.g. garbage
  collection needs to happen before performing any other action.
- Add `GetCurrent`, `HasCurrent`, `GetPrevious` and `HasPrevious`
  helper methods to ease access to their values nested in the Status.
- Add `FullReleaseName` and `VersionedChartName` helper methods to e.g.
  allow printing full name references in Condition and Event messages
  which can be placed in a point in time based on metadata more
  familiar to a user than for example the observed generation.
- Change `GetFailureCount` and `RetriesExhausted` signatures of
  `Remediation` interface to take a pointer. This eases use of the API,
  as generally speaking a (Kubernetes) API object is a pointer.
- Move methods from `HelmReleaseSpec` to `HelmRelease`, this is easier
  to access and matches `GetConditions`, etc.
- Remove `DeploymentAction` interface and `GetDescription` from
  `Remediation` interface as this is no longer of value.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2023-11-20 12:06:04 +01:00
Hidde Beydals 5843cc2ef0
action: allow passing of config options
This to allow the Flux CLI to e.g. enable the dry-run flag on an action
outside of the HelmRelease spec, and inject other (user input based)
modifications.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2023-11-20 12:06:02 +01:00
Hidde Beydals 89a6f497e5
Run individual Helm actions using HelmRelease
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>
2023-11-20 12:05:57 +01:00