@@ -78,7 +78,7 @@ type Reconciler struct {
78
78
skipDependentWatches bool
79
79
maxConcurrentReconciles int
80
80
reconcilePeriod time.Duration
81
- maxHistory int
81
+ maxReleaseHistory * int
82
82
skipPrimaryGVKSchemeRegistration bool
83
83
controllerSetupFuncs []ControllerSetupFunc
84
84
@@ -347,13 +347,15 @@ func WithReconcilePeriod(rp time.Duration) Option {
347
347
}
348
348
349
349
// WithMaxReleaseHistory specifies the maximum size of the Helm release history maintained
350
- // on upgrades/rollbacks. Zero (default) means unlimited.
350
+ // on upgrades/rollbacks. Zero means unlimited.
351
+ //
352
+ // Defaults is 10
351
353
func WithMaxReleaseHistory (maxHistory int ) Option {
352
354
return func (r * Reconciler ) error {
353
355
if maxHistory < 0 {
354
356
return errors .New ("maximum Helm release history size must not be negative" )
355
357
}
356
- r .maxHistory = maxHistory
358
+ r .maxReleaseHistory = & maxHistory
357
359
return nil
358
360
}
359
361
}
@@ -745,9 +747,9 @@ func (r *Reconciler) getReleaseState(client helmclient.ActionInterface, obj meta
745
747
}
746
748
747
749
var opts []helmclient.UpgradeOption
748
- if r . maxHistory > 0 {
750
+ if * r . maxReleaseHistory > 0 {
749
751
opts = append (opts , func (u * action.Upgrade ) error {
750
- u .MaxHistory = r . maxHistory
752
+ u .MaxHistory = * r . maxReleaseHistory
751
753
return nil
752
754
})
753
755
}
@@ -802,9 +804,9 @@ func (r *Reconciler) doInstall(actionClient helmclient.ActionInterface, u *updat
802
804
803
805
func (r * Reconciler ) doUpgrade (actionClient helmclient.ActionInterface , u * updater.Updater , obj * unstructured.Unstructured , vals map [string ]interface {}, log logr.Logger ) (* release.Release , error ) {
804
806
var opts []helmclient.UpgradeOption
805
- if r . maxHistory > 0 {
807
+ if * r . maxReleaseHistory > 0 {
806
808
opts = append (opts , func (u * action.Upgrade ) error {
807
- u .MaxHistory = r . maxHistory
809
+ u .MaxHistory = * r . maxReleaseHistory
808
810
return nil
809
811
})
810
812
}
@@ -936,6 +938,11 @@ func (r *Reconciler) addDefaults(mgr ctrl.Manager, controllerName string) error
936
938
if r .valueMapper == nil {
937
939
r .valueMapper = internalvalues .DefaultMapper
938
940
}
941
+
942
+ if r .maxReleaseHistory == nil {
943
+ r .maxReleaseHistory = & internalvalues .DefaultMaxReleaseHistory
944
+ }
945
+
939
946
return nil
940
947
}
941
948
0 commit comments