@@ -33,6 +33,10 @@ const (
33
33
MergeValue = "Merge"
34
34
IfNotPresentValue = "IfNotPresent"
35
35
IgnoreValue = "Ignore"
36
+
37
+ DeletionPolicyMirrorPrune = "MirrorPrune"
38
+ DeletionPolicyDelete = "Delete"
39
+ DeletionPolicyOrphan = "Orphan"
36
40
)
37
41
38
42
// KustomizationSpec defines the configuration to calculate the desired state
@@ -95,6 +99,14 @@ type KustomizationSpec struct {
95
99
// +required
96
100
Prune bool `json:"prune"`
97
101
102
+ // DeletionPolicy can be used to control garbage collection when this
103
+ // Kustomization is deleted. Valid values are ('MirrorPrune', 'Delete',
104
+ // 'Orphan'). 'MirrorPrune' mirrors the Prune field (false = 'Ophan',
105
+ // true = 'Delete'). Defaults to 'MirrorPrune'.
106
+ // +kubebuilder:validation:Enum=MirrorPrune;Delete;Orphan
107
+ // +optional
108
+ DeletionPolicy string `json:"deletionPolicy,omitempty"`
109
+
98
110
// A list of resources to be included in the health assessment.
99
111
// +optional
100
112
HealthChecks []meta.NamespacedObjectKindReference `json:"healthChecks,omitempty"`
@@ -287,6 +299,14 @@ func (in Kustomization) GetRequeueAfter() time.Duration {
287
299
return in .Spec .Interval .Duration
288
300
}
289
301
302
+ // GetDeletionPolicy returns the deletion policy and default value if not specified.
303
+ func (in Kustomization ) GetDeletionPolicy () string {
304
+ if in .Spec .DeletionPolicy == "" {
305
+ return DeletionPolicyMirrorPrune
306
+ }
307
+ return in .Spec .DeletionPolicy
308
+ }
309
+
290
310
// GetDependsOn returns the list of dependencies across-namespaces.
291
311
func (in Kustomization ) GetDependsOn () []meta.NamespacedObjectReference {
292
312
return in .Spec .DependsOn
0 commit comments