@@ -29,6 +29,9 @@ var deploymentTempl, _ = template.New("deployment").Parse(
2929spec:
3030{{- if .Replicas }}
3131{{ .Replicas }}
32+ {{- end }}
33+ {{- if .RevisionHistoryLimit }}
34+ {{ .RevisionHistoryLimit }}
3235{{- end }}
3336 selector:
3437{{ .Selector }}
@@ -57,6 +60,7 @@ func (d deployment) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstr
5760 return false , nil , nil
5861 }
5962 depl := appsv1.Deployment {}
63+
6064 err := runtime .DefaultUnstructuredConverter .FromUnstructured (obj .Object , & depl )
6165 if err != nil {
6266 return true , nil , fmt .Errorf ("%w: unable to cast to deployment" , err )
@@ -74,6 +78,11 @@ func (d deployment) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstr
7478 return true , nil , err
7579 }
7680
81+ revisionHistoryLimit , err := processRevisionHistoryLimit (name , & depl , & values )
82+ if err != nil {
83+ return true , nil , err
84+ }
85+
7786 matchLabels , err := yamlformat .Marshal (map [string ]interface {}{"matchLabels" : depl .Spec .Selector .MatchLabels }, 0 )
7887 if err != nil {
7988 return true , nil , err
@@ -125,19 +134,21 @@ func (d deployment) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstr
125134 return true , & result {
126135 values : values ,
127136 data : struct {
128- Meta string
129- Replicas string
130- Selector string
131- PodLabels string
132- PodAnnotations string
133- Spec string
137+ Meta string
138+ Replicas string
139+ RevisionHistoryLimit string
140+ Selector string
141+ PodLabels string
142+ PodAnnotations string
143+ Spec string
134144 }{
135- Meta : meta ,
136- Replicas : replicas ,
137- Selector : selector ,
138- PodLabels : podLabels ,
139- PodAnnotations : podAnnotations ,
140- Spec : spec ,
145+ Meta : meta ,
146+ Replicas : replicas ,
147+ RevisionHistoryLimit : revisionHistoryLimit ,
148+ Selector : selector ,
149+ PodLabels : podLabels ,
150+ PodAnnotations : podAnnotations ,
151+ Spec : spec ,
141152 },
142153 }, nil
143154}
@@ -158,14 +169,31 @@ func processReplicas(name string, deployment *appsv1.Deployment, values *helmify
158169 return replicas , nil
159170}
160171
172+ func processRevisionHistoryLimit (name string , deployment * appsv1.Deployment , values * helmify.Values ) (string , error ) {
173+ if deployment .Spec .RevisionHistoryLimit == nil {
174+ return "" , nil
175+ }
176+ revisionHistoryLimitTpl , err := values .Add (int64 (* deployment .Spec .RevisionHistoryLimit ), name , "revisionHistoryLimit" )
177+ if err != nil {
178+ return "" , err
179+ }
180+ revisionHistoryLimit , err := yamlformat .Marshal (map [string ]interface {}{"revisionHistoryLimit" : revisionHistoryLimitTpl }, 2 )
181+ if err != nil {
182+ return "" , err
183+ }
184+ revisionHistoryLimit = strings .ReplaceAll (revisionHistoryLimit , "'" , "" )
185+ return revisionHistoryLimit , nil
186+ }
187+
161188type result struct {
162189 data struct {
163- Meta string
164- Replicas string
165- Selector string
166- PodLabels string
167- PodAnnotations string
168- Spec string
190+ Meta string
191+ Replicas string
192+ RevisionHistoryLimit string
193+ Selector string
194+ PodLabels string
195+ PodAnnotations string
196+ Spec string
169197 }
170198 values helmify.Values
171199}
0 commit comments