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>
This commit is contained in:
Hidde Beydals 2022-09-15 11:17:27 +00:00 committed by Hidde Beydals
parent 8cefed19fd
commit 9e1eedcfa4
No known key found for this signature in database
GPG Key ID: 979F380FC2341744
11 changed files with 215 additions and 126 deletions

View File

@ -18,6 +18,7 @@ package v2beta2
import (
"encoding/json"
"fmt"
"strings"
"time"
@ -190,50 +191,6 @@ type HelmReleaseSpec struct {
PostRenderers []PostRenderer `json:"postRenderers,omitempty"`
}
// GetInstall returns the configuration for Helm install actions for the
// HelmRelease.
func (in HelmReleaseSpec) GetInstall() Install {
if in.Install == nil {
return Install{}
}
return *in.Install
}
// GetUpgrade returns the configuration for Helm upgrade actions for this
// HelmRelease.
func (in HelmReleaseSpec) GetUpgrade() Upgrade {
if in.Upgrade == nil {
return Upgrade{}
}
return *in.Upgrade
}
// GetTest returns the configuration for Helm test actions for this HelmRelease.
func (in HelmReleaseSpec) GetTest() Test {
if in.Test == nil {
return Test{}
}
return *in.Test
}
// GetRollback returns the configuration for Helm rollback actions for this
// HelmRelease.
func (in HelmReleaseSpec) GetRollback() Rollback {
if in.Rollback == nil {
return Rollback{}
}
return *in.Rollback
}
// GetUninstall returns the configuration for Helm uninstall actions for this
// HelmRelease.
func (in HelmReleaseSpec) GetUninstall() Uninstall {
if in.Uninstall == nil {
return Uninstall{}
}
return *in.Uninstall
}
// HelmChartTemplate defines the template from which the controller will
// generate a v1beta2.HelmChart object in the same namespace as the referenced
// v1.Source.
@ -353,13 +310,6 @@ type HelmChartTemplateVerification struct {
SecretRef *meta.LocalObjectReference `json:"secretRef,omitempty"`
}
// DeploymentAction defines a consistent interface for Install and Upgrade.
// +kubebuilder:object:generate=false
type DeploymentAction interface {
GetDescription() string
GetRemediation() Remediation
}
// Remediation defines a consistent interface for InstallRemediation and
// UpgradeRemediation.
// +kubebuilder:object:generate=false
@ -368,9 +318,9 @@ type Remediation interface {
MustIgnoreTestFailures(bool) bool
MustRemediateLastFailure() bool
GetStrategy() RemediationStrategy
GetFailureCount(hr HelmRelease) int64
GetFailureCount(hr *HelmRelease) int64
IncrementFailureCount(hr *HelmRelease)
RetriesExhausted(hr HelmRelease) bool
RetriesExhausted(hr *HelmRelease) bool
}
// Install holds the configuration for Helm install actions performed for this
@ -459,11 +409,6 @@ func (in Install) GetTimeout(defaultTimeout metav1.Duration) metav1.Duration {
return *in.Timeout
}
// GetDescription returns a description for the Helm install action.
func (in Install) GetDescription() string {
return "install"
}
// GetRemediation returns the configured Remediation for the Helm install action.
func (in Install) GetRemediation() Remediation {
if in.Remediation == nil {
@ -522,7 +467,7 @@ func (in InstallRemediation) GetStrategy() RemediationStrategy {
}
// GetFailureCount gets the failure count.
func (in InstallRemediation) GetFailureCount(hr HelmRelease) int64 {
func (in InstallRemediation) GetFailureCount(hr *HelmRelease) int64 {
return hr.Status.InstallFailures
}
@ -532,7 +477,7 @@ func (in InstallRemediation) IncrementFailureCount(hr *HelmRelease) {
}
// RetriesExhausted returns true if there are no remaining retries.
func (in InstallRemediation) RetriesExhausted(hr HelmRelease) bool {
func (in InstallRemediation) RetriesExhausted(hr *HelmRelease) bool {
return in.Retries >= 0 && in.GetFailureCount(hr) > int64(in.Retries)
}
@ -631,11 +576,6 @@ func (in Upgrade) GetTimeout(defaultTimeout metav1.Duration) metav1.Duration {
return *in.Timeout
}
// GetDescription returns a description for the Helm upgrade action.
func (in Upgrade) GetDescription() string {
return "upgrade"
}
// GetRemediation returns the configured Remediation for the Helm upgrade
// action.
func (in Upgrade) GetRemediation() Remediation {
@ -703,7 +643,7 @@ func (in UpgradeRemediation) GetStrategy() RemediationStrategy {
}
// GetFailureCount gets the failure count.
func (in UpgradeRemediation) GetFailureCount(hr HelmRelease) int64 {
func (in UpgradeRemediation) GetFailureCount(hr *HelmRelease) int64 {
return hr.Status.UpgradeFailures
}
@ -713,7 +653,7 @@ func (in UpgradeRemediation) IncrementFailureCount(hr *HelmRelease) {
}
// RetriesExhausted returns true if there are no remaining retries.
func (in UpgradeRemediation) RetriesExhausted(hr HelmRelease) bool {
func (in UpgradeRemediation) RetriesExhausted(hr *HelmRelease) bool {
return in.Retries >= 0 && in.GetFailureCount(hr) > int64(in.Retries)
}
@ -764,7 +704,7 @@ func (in Test) GetTimeout(defaultTimeout metav1.Duration) metav1.Duration {
return *in.Timeout
}
// Filters holds the configuration for individual Helm test filters.
// Filter holds the configuration for individual Helm test filters.
type Filter struct {
// Name is the name of the test.
Name string `json:"name"`
@ -908,7 +848,50 @@ type HelmReleaseInfo struct {
// TestHooks is the list of test hooks for the release as observed to be
// run by the controller.
// +optional
TestHooks map[string]*HelmReleaseTestHook `json:"testHooks,omitempty"`
TestHooks *map[string]*HelmReleaseTestHook `json:"testHooks,omitempty"`
}
// FullReleaseName returns the full name of the release in the format
// of '<namespace>/<name>.<version>
func (in *HelmReleaseInfo) FullReleaseName() string {
return fmt.Sprintf("%s/%s.%d", in.Namespace, in.Name, in.Version)
}
// VersionedChartName returns the full name of the chart in the format of
// '<name>@<version>'.
func (in *HelmReleaseInfo) VersionedChartName() string {
return fmt.Sprintf("%s@%s", in.ChartName, in.ChartVersion)
}
// HasBeenTested returns true if TestHooks is not nil. This includes an empty
// map, which indicates the chart has no tests.
func (in *HelmReleaseInfo) HasBeenTested() bool {
return in != nil && in.TestHooks != nil
}
// GetTestHooks returns the TestHooks for the release if not nil.
func (in *HelmReleaseInfo) GetTestHooks() map[string]*HelmReleaseTestHook {
if in == nil {
return nil
}
return *in.TestHooks
}
// HasTestInPhase returns true if any of the TestHooks is in the given phase.
func (in *HelmReleaseInfo) HasTestInPhase(phase string) bool {
if in != nil {
for _, h := range in.GetTestHooks() {
if h.Phase == phase {
return true
}
}
}
return false
}
// SetTestHooks sets the TestHooks for the release.
func (in *HelmReleaseInfo) SetTestHooks(hooks map[string]*HelmReleaseTestHook) {
in.TestHooks = &hooks
}
// HelmReleaseTestHook holds the status information for a test hook as observed
@ -940,6 +923,10 @@ type HelmReleaseStatus struct {
// +optional
HelmChart string `json:"helmChart,omitempty"`
// StorageNamespace is the namespace of the Helm release storage for the
// Current release.
StorageNamespace string `json:"storageNamespace,omitempty"`
// Current holds the latest observed HelmReleaseInfo for the current
// release.
// +optional
@ -1014,6 +1001,101 @@ type HelmRelease struct {
Status HelmReleaseStatus `json:"status,omitempty"`
}
// GetInstall returns the configuration for Helm install actions for the
// HelmRelease.
func (in *HelmRelease) GetInstall() Install {
if in.Spec.Install == nil {
return Install{}
}
return *in.Spec.Install
}
// GetUpgrade returns the configuration for Helm upgrade actions for this
// HelmRelease.
func (in *HelmRelease) GetUpgrade() Upgrade {
if in.Spec.Upgrade == nil {
return Upgrade{}
}
return *in.Spec.Upgrade
}
// GetTest returns the configuration for Helm test actions for this HelmRelease.
func (in *HelmRelease) GetTest() Test {
if in.Spec.Test == nil {
return Test{}
}
return *in.Spec.Test
}
// GetRollback returns the configuration for Helm rollback actions for this
// HelmRelease.
func (in *HelmRelease) GetRollback() Rollback {
if in.Spec.Rollback == nil {
return Rollback{}
}
return *in.Spec.Rollback
}
// GetUninstall returns the configuration for Helm uninstall actions for this
// HelmRelease.
func (in *HelmRelease) GetUninstall() Uninstall {
if in.Spec.Uninstall == nil {
return Uninstall{}
}
return *in.Spec.Uninstall
}
// GetCurrent returns HelmReleaseStatus.Current.
func (in HelmRelease) GetCurrent() *HelmReleaseInfo {
if in.HasCurrent() {
return in.Status.Current
}
return nil
}
// HasCurrent returns true if the HelmRelease has a HelmReleaseStatus.Current.
func (in HelmRelease) HasCurrent() bool {
return in.Status.Current != nil
}
// GetPrevious returns HelmReleaseStatus.Previous.
func (in HelmRelease) GetPrevious() *HelmReleaseInfo {
if in.HasPrevious() {
return in.Status.Previous
}
return nil
}
// HasPrevious returns true if the HelmRelease has a HelmReleaseStatus.Previous.
func (in HelmRelease) HasPrevious() bool {
return in.Status.Previous != nil
}
// ReleaseTargetChanged returns true if the HelmReleaseSpec has been mutated in
// such a way that it no longer targets the same release as the
// HelmReleaseStatus.Current.
func (in HelmRelease) ReleaseTargetChanged() bool {
switch {
case in.Status.StorageNamespace == "", in.Status.Current == nil:
return false
case in.GetStorageNamespace() != in.Status.StorageNamespace,
in.GetReleaseNamespace() != in.Status.Current.Namespace,
in.GetReleaseName() != in.Status.Current.Name,
in.GetHelmChartName() != in.Status.Current.ChartName:
return true
default:
return false
}
}
// GetActiveRemediation returns the active Remediation for the HelmRelease.
func (in HelmRelease) GetActiveRemediation() Remediation {
if in.Status.Previous != nil {
return in.GetUpgrade().GetRemediation()
}
return in.GetInstall().GetRemediation()
}
// GetRequeueAfter returns the duration after which the HelmRelease
// must be reconciled again.
func (in HelmRelease) GetRequeueAfter() time.Duration {

View File

@ -195,17 +195,21 @@ func (in *HelmReleaseInfo) DeepCopyInto(out *HelmReleaseInfo) {
in.Deleted.DeepCopyInto(&out.Deleted)
if in.TestHooks != nil {
in, out := &in.TestHooks, &out.TestHooks
*out = make(map[string]*HelmReleaseTestHook, len(*in))
for key, val := range *in {
var outVal *HelmReleaseTestHook
if val == nil {
(*out)[key] = nil
} else {
in, out := &val, &outVal
*out = new(HelmReleaseTestHook)
(*in).DeepCopyInto(*out)
*out = new(map[string]*HelmReleaseTestHook)
if **in != nil {
in, out := *in, *out
*out = make(map[string]*HelmReleaseTestHook, len(*in))
for key, val := range *in {
var outVal *HelmReleaseTestHook
if val == nil {
(*out)[key] = nil
} else {
in, out := &val, &outVal
*out = new(HelmReleaseTestHook)
(*in).DeepCopyInto(*out)
}
(*out)[key] = outVal
}
(*out)[key] = outVal
}
}
}

View File

@ -1512,8 +1512,8 @@ spec:
description: Filters is a list of tests to run or exclude from
running.
items:
description: Filters holds the configuration for individual
Helm test filters.
description: Filter holds the configuration for individual Helm
test filters.
properties:
exclude:
description: Exclude is specifies whether the named test
@ -1974,6 +1974,10 @@ spec:
- status
- version
type: object
storageNamespace:
description: StorageNamespace is the namespace of the Helm release
storage for the Current release.
type: string
upgradeFailures:
description: UpgradeFailures is the upgrade failure count against
the latest desired state. It is reset after a successful reconciliation.

View File

@ -50,7 +50,7 @@ func Install(ctx context.Context, config *helmaction.Configuration, obj *v2.Helm
chrt *helmchart.Chart, vals helmchartutil.Values, opts ...InstallOption) (*helmrelease.Release, error) {
install := newInstall(config, obj, opts)
policy, err := crdPolicyOrDefault(obj.Spec.GetInstall().CRDs)
policy, err := crdPolicyOrDefault(obj.GetInstall().CRDs)
if err != nil {
return nil, err
}
@ -66,17 +66,17 @@ func newInstall(config *helmaction.Configuration, obj *v2.HelmRelease, opts []In
install.ReleaseName = obj.GetReleaseName()
install.Namespace = obj.GetReleaseNamespace()
install.Timeout = obj.Spec.GetInstall().GetTimeout(obj.GetTimeout()).Duration
install.Wait = !obj.Spec.GetInstall().DisableWait
install.WaitForJobs = !obj.Spec.GetInstall().DisableWaitForJobs
install.DisableHooks = obj.Spec.GetInstall().DisableHooks
install.DisableOpenAPIValidation = obj.Spec.GetInstall().DisableOpenAPIValidation
install.Replace = obj.Spec.GetInstall().Replace
install.Timeout = obj.GetInstall().GetTimeout(obj.GetTimeout()).Duration
install.Wait = !obj.GetInstall().DisableWait
install.WaitForJobs = !obj.GetInstall().DisableWaitForJobs
install.DisableHooks = obj.GetInstall().DisableHooks
install.DisableOpenAPIValidation = obj.GetInstall().DisableOpenAPIValidation
install.Replace = obj.GetInstall().Replace
install.Devel = true
install.SkipCRDs = true
if obj.Spec.TargetNamespace != "" {
install.CreateNamespace = obj.Spec.GetInstall().CreateNamespace
install.CreateNamespace = obj.GetInstall().CreateNamespace
}
// If the user opted-in to allow DNS lookups, enable it.

View File

@ -43,13 +43,13 @@ func Rollback(config *helmaction.Configuration, obj *v2.HelmRelease, opts ...Rol
func newRollback(config *helmaction.Configuration, obj *v2.HelmRelease, opts []RollbackOption) *helmaction.Rollback {
rollback := helmaction.NewRollback(config)
rollback.Timeout = obj.Spec.GetRollback().GetTimeout(obj.GetTimeout()).Duration
rollback.Wait = !obj.Spec.GetRollback().DisableWait
rollback.WaitForJobs = !obj.Spec.GetRollback().DisableWaitForJobs
rollback.DisableHooks = obj.Spec.GetRollback().DisableHooks
rollback.Force = obj.Spec.GetRollback().Force
rollback.Recreate = obj.Spec.GetRollback().Recreate
rollback.CleanupOnFail = obj.Spec.GetRollback().CleanupOnFail
rollback.Timeout = obj.GetRollback().GetTimeout(obj.GetTimeout()).Duration
rollback.Wait = !obj.GetRollback().DisableWait
rollback.WaitForJobs = !obj.GetRollback().DisableWaitForJobs
rollback.DisableHooks = obj.GetRollback().DisableHooks
rollback.Force = obj.GetRollback().Force
rollback.Recreate = obj.GetRollback().Recreate
rollback.CleanupOnFail = obj.GetRollback().CleanupOnFail
if prev := obj.Status.Previous; prev != nil && prev.Name == obj.GetReleaseName() && prev.Namespace == obj.GetReleaseNamespace() {
rollback.Version = prev.Version

View File

@ -47,11 +47,11 @@ func newTest(config *helmaction.Configuration, obj *v2.HelmRelease, opts []TestO
test := helmaction.NewReleaseTesting(config)
test.Namespace = obj.GetReleaseNamespace()
test.Timeout = obj.Spec.GetTest().GetTimeout(obj.GetTimeout()).Duration
test.Timeout = obj.GetTest().GetTimeout(obj.GetTimeout()).Duration
filters := make(map[string][]string)
for _, f := range obj.Spec.GetTest().GetFilters() {
for _, f := range obj.GetTest().GetFilters() {
name := "name"
if f.Exclude {

View File

@ -46,10 +46,10 @@ func Uninstall(_ context.Context, config *helmaction.Configuration, obj *v2.Helm
func newUninstall(config *helmaction.Configuration, obj *v2.HelmRelease, opts []UninstallOption) *helmaction.Uninstall {
uninstall := helmaction.NewUninstall(config)
uninstall.Timeout = obj.Spec.GetUninstall().GetTimeout(obj.GetTimeout()).Duration
uninstall.DisableHooks = obj.Spec.GetUninstall().DisableHooks
uninstall.KeepHistory = obj.Spec.GetUninstall().KeepHistory
uninstall.Wait = !obj.Spec.GetUninstall().DisableWait
uninstall.Timeout = obj.GetUninstall().GetTimeout(obj.GetTimeout()).Duration
uninstall.DisableHooks = obj.GetUninstall().DisableHooks
uninstall.KeepHistory = obj.GetUninstall().KeepHistory
uninstall.Wait = !obj.GetUninstall().DisableWait
for _, opt := range opts {
opt(uninstall)

View File

@ -50,7 +50,7 @@ func Upgrade(ctx context.Context, config *helmaction.Configuration, obj *v2.Helm
vals helmchartutil.Values, opts ...UpgradeOption) (*helmrelease.Release, error) {
upgrade := newUpgrade(config, obj, opts)
policy, err := crdPolicyOrDefault(obj.Spec.GetInstall().CRDs)
policy, err := crdPolicyOrDefault(obj.GetInstall().CRDs)
if err != nil {
return nil, err
}
@ -65,16 +65,16 @@ func newUpgrade(config *helmaction.Configuration, obj *v2.HelmRelease, opts []Up
upgrade := helmaction.NewUpgrade(config)
upgrade.Namespace = obj.GetReleaseNamespace()
upgrade.ResetValues = !obj.Spec.GetUpgrade().PreserveValues
upgrade.ReuseValues = obj.Spec.GetUpgrade().PreserveValues
upgrade.ResetValues = !obj.GetUpgrade().PreserveValues
upgrade.ReuseValues = obj.GetUpgrade().PreserveValues
upgrade.MaxHistory = obj.GetMaxHistory()
upgrade.Timeout = obj.Spec.GetUpgrade().GetTimeout(obj.GetTimeout()).Duration
upgrade.Wait = !obj.Spec.GetUpgrade().DisableWait
upgrade.WaitForJobs = !obj.Spec.GetUpgrade().DisableWaitForJobs
upgrade.DisableHooks = obj.Spec.GetUpgrade().DisableHooks
upgrade.DisableOpenAPIValidation = obj.Spec.GetUpgrade().DisableOpenAPIValidation
upgrade.Force = obj.Spec.GetUpgrade().Force
upgrade.CleanupOnFail = obj.Spec.GetUpgrade().CleanupOnFail
upgrade.Timeout = obj.GetUpgrade().GetTimeout(obj.GetTimeout()).Duration
upgrade.Wait = !obj.GetUpgrade().DisableWait
upgrade.WaitForJobs = !obj.GetUpgrade().DisableWaitForJobs
upgrade.DisableHooks = obj.GetUpgrade().DisableHooks
upgrade.DisableOpenAPIValidation = obj.GetUpgrade().DisableOpenAPIValidation
upgrade.Force = obj.GetUpgrade().Force
upgrade.CleanupOnFail = obj.GetUpgrade().CleanupOnFail
upgrade.Devel = true
// If the user opted-in to allow DNS lookups, enable it.

View File

@ -54,9 +54,9 @@ func NextAction(factory *action.ConfigFactory, req *Request) (ActionReconciler,
return &Unlock{configFactory: factory}, nil
}
remediation := req.Object.Spec.GetInstall().GetRemediation()
remediation := req.Object.GetInstall().GetRemediation()
if req.Object.Status.Previous != nil {
remediation = req.Object.Spec.GetUpgrade().GetRemediation()
remediation = req.Object.GetUpgrade().GetRemediation()
}
// TODO(hidde): the logic below lacks some implementation details. E.g.
@ -80,12 +80,12 @@ func NextAction(factory *action.ConfigFactory, req *Request) (ActionReconciler,
}
}
if testSpec := req.Object.Spec.GetTest(); testSpec.Enable {
if testSpec := req.Object.GetTest(); testSpec.Enable {
if !release.HasBeenTested(rls) {
return &Test{configFactory: factory}, nil
}
if release.HasFailedTests(rls) {
if !remediation.MustIgnoreTestFailures(req.Object.Spec.GetTest().IgnoreFailures) {
if !remediation.MustIgnoreTestFailures(req.Object.GetTest().IgnoreFailures) {
return rollbackOrUninstall(factory, req)
}
}
@ -95,15 +95,15 @@ func NextAction(factory *action.ConfigFactory, req *Request) (ActionReconciler,
}
func rollbackOrUninstall(factory *action.ConfigFactory, req *Request) (ActionReconciler, error) {
remediation := req.Object.Spec.GetInstall().GetRemediation()
remediation := req.Object.GetInstall().GetRemediation()
if req.Object.Status.Previous != nil {
// TODO: determine if previous is still in storage and unmodified
remediation = req.Object.Spec.GetUpgrade().GetRemediation()
remediation = req.Object.GetUpgrade().GetRemediation()
}
// TODO: remove dependency on counter, as this shouldn't be used to determine
// if it's enabled.
remediation.IncrementFailureCount(req.Object)
if !remediation.RetriesExhausted(*req.Object) || remediation.MustRemediateLastFailure() {
if !remediation.RetriesExhausted(req.Object) || remediation.MustRemediateLastFailure() {
switch remediation.GetStrategy() {
case v2.RollbackRemediationStrategy:
return &Rollback{configFactory: factory}, nil

View File

@ -72,7 +72,7 @@ func (r *Test) Reconcile(ctx context.Context, req *Request) error {
// Compose success condition message.
condMsg := "No test hooks."
if hookLen := len(req.Object.Status.Current.TestHooks); hookLen > 0 {
if hookLen := len(req.Object.Status.Current.GetTestHooks()); hookLen > 0 {
condMsg = fmt.Sprintf("%d test hook(s) completed successfully.", hookLen)
}
conditions.MarkTrue(req.Object, v2.TestSuccessCondition, v2.TestSucceededReason, condMsg)
@ -93,9 +93,7 @@ func observeTest(obj *v2.HelmRelease) storage.ObserveFunc {
obs := release.ObserveRelease(rls)
if obs.Targets(cur.Name, cur.Namespace, cur.Version) {
obj.Status.Current = release.ObservedToInfo(obs)
if hooks := release.TestHooksFromRelease(rls); len(hooks) > 0 {
obj.Status.Current.TestHooks = hooks
}
obj.GetCurrent().SetTestHooks(release.TestHooksFromRelease(rls))
}
}
}

View File

@ -129,7 +129,7 @@ func TestTest_Reconcile(t *testing.T) {
},
expectCurrent: func(releases []*helmrelease.Release) *v2.HelmReleaseInfo {
info := release.ObservedToInfo(release.ObserveRelease(releases[0]))
info.TestHooks = release.TestHooksFromRelease(releases[0])
info.SetTestHooks(release.TestHooksFromRelease(releases[0]))
return info
},
},
@ -157,6 +157,7 @@ func TestTest_Reconcile(t *testing.T) {
},
expectCurrent: func(releases []*helmrelease.Release) *v2.HelmReleaseInfo {
info := release.ObservedToInfo(release.ObserveRelease(releases[0]))
info.SetTestHooks(release.TestHooksFromRelease(releases[0]))
return info
},
},
@ -184,7 +185,7 @@ func TestTest_Reconcile(t *testing.T) {
},
expectCurrent: func(releases []*helmrelease.Release) *v2.HelmReleaseInfo {
info := release.ObservedToInfo(release.ObserveRelease(releases[0]))
info.TestHooks = release.TestHooksFromRelease(releases[0])
info.SetTestHooks(release.TestHooksFromRelease(releases[0]))
return info
},
expectFailures: 1,
@ -343,7 +344,7 @@ func Test_observeTest(t *testing.T) {
}, testutil.ReleaseWithHooks(testHookFixtures))
expect := release.ObservedToInfo(release.ObserveRelease(rls))
expect.TestHooks = release.TestHooksFromRelease(rls)
expect.SetTestHooks(release.TestHooksFromRelease(rls))
observeTest(obj)(rls)
g.Expect(obj.Status.Current).To(Equal(expect))