@ -19,18 +19,10 @@ package action
import (
import (
"strings"
"strings"
"helm.sh/helm/v3/pkg/kube"
"helm.sh/helm/v3/pkg/releaseutil"
"helm.sh/helm/v3/pkg/releaseutil"
)
)
// resourcePolicyAnno is the annotation name for a resource policy
const resourcePolicyAnno = "helm.sh/resource-policy"
// keepPolicy is the resource policy type for keep
//
// This resource policy type allows resources to skip being deleted
// during an uninstallRelease action.
const keepPolicy = "keep"
func filterManifestsToKeep ( manifests [ ] releaseutil . Manifest ) ( keep , remaining [ ] releaseutil . Manifest ) {
func filterManifestsToKeep ( manifests [ ] releaseutil . Manifest ) ( keep , remaining [ ] releaseutil . Manifest ) {
for _ , m := range manifests {
for _ , m := range manifests {
if m . Head . Metadata == nil || m . Head . Metadata . Annotations == nil || len ( m . Head . Metadata . Annotations ) == 0 {
if m . Head . Metadata == nil || m . Head . Metadata . Annotations == nil || len ( m . Head . Metadata . Annotations ) == 0 {
@ -38,14 +30,14 @@ func filterManifestsToKeep(manifests []releaseutil.Manifest) (keep, remaining []
continue
continue
}
}
resourcePolicyType , ok := m . Head . Metadata . Annotations [ r esourcePolicyAnno]
resourcePolicyType , ok := m . Head . Metadata . Annotations [ kube. R esourcePolicyAnno]
if ! ok {
if ! ok {
remaining = append ( remaining , m )
remaining = append ( remaining , m )
continue
continue
}
}
resourcePolicyType = strings . ToLower ( strings . TrimSpace ( resourcePolicyType ) )
resourcePolicyType = strings . ToLower ( strings . TrimSpace ( resourcePolicyType ) )
if resourcePolicyType == k eepPolicy {
if resourcePolicyType == k ube. K eepPolicy {
keep = append ( keep , m )
keep = append ( keep , m )
}
}