pull/10853/merge
zze 3 years ago committed by GitHub
commit f3061520fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -80,6 +80,13 @@ build: $(BINDIR)/$(BINNAME)
$(BINDIR)/$(BINNAME): $(SRC)
GO111MODULE=on CGO_ENABLED=$(CGO_ENABLED) go build $(GOFLAGS) -trimpath -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o '$(BINDIR)'/$(BINNAME) ./cmd/helm
.PHONY: build-linux-amd64
build-linux-amd64: $(BINDIR)/$(BINNAME)-linux-amd64
$(BINDIR)/$(BINNAME)-linux-amd64: $(SRC)
GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(GOFLAGS) -trimpath -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o '$(BINDIR)'/$(BINNAME) ./cmd/helm
# ------------------------------------------------------------------------------
# install

@ -68,6 +68,7 @@ func newUninstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
}
f := cmd.Flags()
f.BoolVar(&client.OnlyRelease, "only-release", false, "keep all k8s resources when uninstall")
f.BoolVar(&client.DryRun, "dry-run", false, "simulate a uninstall")
f.BoolVar(&client.DisableHooks, "no-hooks", false, "prevent hooks from running during uninstallation")
f.BoolVar(&client.KeepHistory, "keep-history", false, "remove all associated resources and mark the release as deleted, but retain the release history")

@ -1,4 +1,4 @@
module helm.sh/helm/v3
module github.com/zze326/helm
go 1.19

@ -23,8 +23,14 @@ import (
"helm.sh/helm/v3/pkg/releaseutil"
)
func filterManifestsToKeep(manifests []releaseutil.Manifest) (keep, remaining []releaseutil.Manifest) {
func filterManifestsToKeep(manifests []releaseutil.Manifest, onlyRelease bool) (keep, remaining []releaseutil.Manifest) {
for _, m := range manifests {
if onlyRelease {
if m.Head.Metadata != nil {
keep = append(keep, m)
}
continue
}
if m.Head.Metadata == nil || m.Head.Metadata.Annotations == nil || len(m.Head.Metadata.Annotations) == 0 {
remaining = append(remaining, m)
continue

@ -36,6 +36,7 @@ type Uninstall struct {
cfg *Configuration
DisableHooks bool
OnlyRelease bool
DryRun bool
KeepHistory bool
Wait bool
@ -204,7 +205,7 @@ func (u *Uninstall) deleteRelease(rel *release.Release) (kube.ResourceList, stri
return nil, rel.Manifest, []error{errors.Wrap(err, "corrupted release record. You must manually delete the resources")}
}
filesToKeep, filesToDelete := filterManifestsToKeep(files)
filesToKeep, filesToDelete := filterManifestsToKeep(files, u.OnlyRelease)
var kept string
for _, f := range filesToKeep {
kept += "[" + f.Head.Kind + "] " + f.Head.Metadata.Name + "\n"

Loading…
Cancel
Save