func (in UpgradeRemediation) RetriesExhausted(hr HelmRelease) bool {
	return in.Retries >= 0 && in.GetFailureCount(hr) > int64(in.Retries)
}
RetriesExhausted returns true if there are no remaining retries.
package v2beta1
import (
	"encoding/json"
	"strings"
	"time"
	apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/types"
	"github.com/fluxcd/pkg/apis/kustomize"
	"github.com/fluxcd/pkg/apis/meta"
	"github.com/fluxcd/pkg/runtime/dependency"
)
const HelmReleaseKind = "HelmRelease"
const HelmReleaseFinalizer = "finalizers.fluxcd.io"
type Kustomize struct {
	PatchesStrategicMerge []apiextensionsv1.JSON `json:"patchesStrategicMerge,omitempty"`
	PatchesJSON6902 []kustomize.JSON6902Patch `json:"patchesJson6902,omitempty"`
	Images []kustomize.Image `json:"images,omitempty" yaml:"images,omitempty"`
}
type PostRenderer struct {
	Kustomize *Kustomize `json:"kustomize,omitempty"`
}
type HelmReleaseSpec struct {
	Chart HelmChartTemplate `json:"chart"`
	Interval metav1.Duration `json:"interval"`
	KubeConfig *KubeConfig `json:"kubeConfig,omitempty"`
	Suspend bool `json:"suspend,omitempty"`
	ReleaseName string `json:"releaseName,omitempty"`
	TargetNamespace string `json:"targetNamespace,omitempty"`
	StorageNamespace string `json:"storageNamespace,omitempty"`
	DependsOn []dependency.CrossNamespaceDependencyReference `json:"dependsOn,omitempty"`
	Timeout *metav1.Duration `json:"timeout,omitempty"`
	MaxHistory *int `json:"maxHistory,omitempty"`
	ServiceAccountName string `json:"serviceAccountName,omitempty"`
	Install *Install `json:"install,omitempty"`
	Upgrade *Upgrade `json:"upgrade,omitempty"`
	Test *Test `json:"test,omitempty"`
	Rollback *Rollback `json:"rollback,omitempty"`
	Uninstall *Uninstall `json:"uninstall,omitempty"`
	ValuesFrom []ValuesReference `json:"valuesFrom,omitempty"`
	Values *apiextensionsv1.JSON `json:"values,omitempty"`
	PostRenderers []PostRenderer `json:"postRenderers,omitempty"`
}
func (in HelmReleaseSpec) GetInstall() Install {
	if in.Install == nil {
		return Install{}
	}
	return *in.Install
}
func (in HelmReleaseSpec) GetUpgrade() Upgrade {
	if in.Upgrade == nil {
		return Upgrade{}
	}
	return *in.Upgrade
}
func (in HelmReleaseSpec) GetTest() Test {
	if in.Test == nil {
		return Test{}
	}
	return *in.Test
}
func (in HelmReleaseSpec) GetRollback() Rollback {
	if in.Rollback == nil {
		return Rollback{}
	}
	return *in.Rollback
}
func (in HelmReleaseSpec) GetUninstall() Uninstall {
	if in.Uninstall == nil {
		return Uninstall{}
	}
	return *in.Uninstall
}
type KubeConfig struct {
	SecretRef meta.LocalObjectReference `json:"secretRef,omitempty"`
}
type HelmChartTemplate struct {
	Spec HelmChartTemplateSpec `json:"spec"`
}
type HelmChartTemplateSpec struct {
	Chart string `json:"chart"`
	Version string `json:"version,omitempty"`
	SourceRef CrossNamespaceObjectReference `json:"sourceRef"`
	Interval *metav1.Duration `json:"interval,omitempty"`
	ReconcileStrategy string `json:"reconcileStrategy,omitempty"`
	ValuesFiles []string `json:"valuesFiles,omitempty"`
	ValuesFile string `json:"valuesFile,omitempty"`
}
func (in HelmChartTemplate) GetInterval(defaultInterval metav1.Duration) metav1.Duration {
	if in.Spec.Interval == nil {
		return defaultInterval
	}
	return *in.Spec.Interval
}
func (in HelmChartTemplate) GetNamespace(defaultNamespace string) string {
	if in.Spec.SourceRef.Namespace == "" {
		return defaultNamespace
	}
	return in.Spec.SourceRef.Namespace
}
type DeploymentAction interface {
	GetDescription() string
	GetRemediation() Remediation
}
type Remediation interface {
	GetRetries() int
	MustIgnoreTestFailures(bool) bool
	MustRemediateLastFailure() bool
	GetStrategy() RemediationStrategy
	GetFailureCount(hr HelmRelease) int64
	IncrementFailureCount(hr *HelmRelease)
	RetriesExhausted(hr HelmRelease) bool
}
type Install struct {
	Timeout *metav1.Duration `json:"timeout,omitempty"`
	Remediation *InstallRemediation `json:"remediation,omitempty"`
	DisableWait bool `json:"disableWait,omitempty"`
	DisableWaitForJobs bool `json:"disableWaitForJobs,omitempty"`
	DisableHooks bool `json:"disableHooks,omitempty"`
	DisableOpenAPIValidation bool `json:"disableOpenAPIValidation,omitempty"`
	Replace bool `json:"replace,omitempty"`
	SkipCRDs bool `json:"skipCRDs,omitempty"`
	CRDs CRDsPolicy `json:"crds,omitempty"`
	CreateNamespace bool `json:"createNamespace,omitempty"`
}
func (in Install) GetTimeout(defaultTimeout metav1.Duration) metav1.Duration {
	if in.Timeout == nil {
		return defaultTimeout
	}
	return *in.Timeout
}
func (in Install) GetDescription() string {
	return "install"
}
func (in Install) GetRemediation() Remediation {
	if in.Remediation == nil {
		return InstallRemediation{}
	}
	return *in.Remediation
}
type InstallRemediation struct {
	Retries int `json:"retries,omitempty"`
	IgnoreTestFailures *bool `json:"ignoreTestFailures,omitempty"`
	RemediateLastFailure *bool `json:"remediateLastFailure,omitempty"`
}
func (in InstallRemediation) GetRetries() int {
	return in.Retries
}
func (in InstallRemediation) MustIgnoreTestFailures(def bool) bool {
	if in.IgnoreTestFailures == nil {
		return def
	}
	return *in.IgnoreTestFailures
}
func (in InstallRemediation) MustRemediateLastFailure() bool {
	if in.RemediateLastFailure == nil {
		return false
	}
	return *in.RemediateLastFailure
}
func (in InstallRemediation) GetStrategy() RemediationStrategy {
	return UninstallRemediationStrategy
}
func (in InstallRemediation) GetFailureCount(hr HelmRelease) int64 {
	return hr.Status.InstallFailures
}
func (in InstallRemediation) IncrementFailureCount(hr *HelmRelease) {
	hr.Status.InstallFailures++
}
func (in InstallRemediation) RetriesExhausted(hr HelmRelease) bool {
	return in.Retries >= 0 && in.GetFailureCount(hr) > int64(in.Retries)
}
type CRDsPolicy string
const (
	Skip CRDsPolicy = "Skip"
	Create CRDsPolicy = "Create"
	CreateReplace CRDsPolicy = "CreateReplace"
)
type Upgrade struct {
	Timeout *metav1.Duration `json:"timeout,omitempty"`
	Remediation *UpgradeRemediation `json:"remediation,omitempty"`
	DisableWait bool `json:"disableWait,omitempty"`
	DisableWaitForJobs bool `json:"disableWaitForJobs,omitempty"`
	DisableHooks bool `json:"disableHooks,omitempty"`
	DisableOpenAPIValidation bool `json:"disableOpenAPIValidation,omitempty"`
	Force bool `json:"force,omitempty"`
	PreserveValues bool `json:"preserveValues,omitempty"`
	CleanupOnFail bool `json:"cleanupOnFail,omitempty"`
	CRDs CRDsPolicy `json:"crds,omitempty"`
}
func (in Upgrade) GetTimeout(defaultTimeout metav1.Duration) metav1.Duration {
	if in.Timeout == nil {
		return defaultTimeout
	}
	return *in.Timeout
}
func (in Upgrade) GetDescription() string {
	return "upgrade"
}
func (in Upgrade) GetRemediation() Remediation {
	if in.Remediation == nil {
		return UpgradeRemediation{}
	}
	return *in.Remediation
}
type UpgradeRemediation struct {
	Retries int `json:"retries,omitempty"`
	IgnoreTestFailures *bool `json:"ignoreTestFailures,omitempty"`
	RemediateLastFailure *bool `json:"remediateLastFailure,omitempty"`
	Strategy *RemediationStrategy `json:"strategy,omitempty"`
}
func (in UpgradeRemediation) GetRetries() int {
	return in.Retries
}
func (in UpgradeRemediation) MustIgnoreTestFailures(def bool) bool {
	if in.IgnoreTestFailures == nil {
		return def
	}
	return *in.IgnoreTestFailures
}
func (in UpgradeRemediation) MustRemediateLastFailure() bool {
	if in.RemediateLastFailure == nil {
		return in.Retries > 0
	}
	return *in.RemediateLastFailure
}
func (in UpgradeRemediation) GetStrategy() RemediationStrategy {
	if in.Strategy == nil {
		return RollbackRemediationStrategy
	}
	return *in.Strategy
}
func (in UpgradeRemediation) GetFailureCount(hr HelmRelease) int64 {
	return hr.Status.UpgradeFailures
}
func (in UpgradeRemediation) IncrementFailureCount(hr *HelmRelease) {
	hr.Status.UpgradeFailures++
}