Skip to content

Commit

Permalink
Merge pull request helm#8682 from liuming-dev/remove-duplicate-variab…
Browse files Browse the repository at this point in the history
…le-definition

Remove duplicate variable definition
  • Loading branch information
mattfarina committed Sep 3, 2020
2 parents 36d9311 + 3176164 commit e454e6a
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions pkg/action/resource_policy.go
Expand Up @@ -19,33 +19,25 @@ package action
import (
"strings"

"helm.sh/helm/v3/pkg/kube"
"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) {
for _, m := range manifests {
if m.Head.Metadata == nil || m.Head.Metadata.Annotations == nil || len(m.Head.Metadata.Annotations) == 0 {
remaining = append(remaining, m)
continue
}

resourcePolicyType, ok := m.Head.Metadata.Annotations[resourcePolicyAnno]
resourcePolicyType, ok := m.Head.Metadata.Annotations[kube.ResourcePolicyAnno]
if !ok {
remaining = append(remaining, m)
continue
}

resourcePolicyType = strings.ToLower(strings.TrimSpace(resourcePolicyType))
if resourcePolicyType == keepPolicy {
if resourcePolicyType == kube.KeepPolicy {
keep = append(keep, m)
}

Expand Down

0 comments on commit e454e6a

Please sign in to comment.