MCPcopy
hub / github.com/databus23/helm-diff / backcastHelm3

Method backcastHelm3

cmd/rollback.go:72–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

70}
71
72func (d *rollback) backcastHelm3() error {
73 namespace := os.Getenv("HELM_NAMESPACE")
74 excludes := []string{manifest.Helm3TestHook, manifest.Helm2TestSuccessHook}
75 if d.includeTests {
76 excludes = []string{}
77 }
78 // get manifest of the latest release
79 releaseResponse, err := getRelease(d.release, namespace, d.kubeContext)
80
81 if err != nil {
82 return err
83 }
84
85 // get manifest of the release to rollback
86 revision, _ := strconv.Atoi(d.revisions[0])
87 revisionResponse, err := getRevision(d.release, revision, namespace, d.kubeContext)
88 if err != nil {
89 return err
90 }
91
92 // create a diff between the current manifest and the version of the manifest that a user is intended to rollback
93 oldSpecs := manifest.Parse(releaseResponse, namespace, d.normalizeManifests, excludes...)
94 newSpecs := manifest.Parse(revisionResponse, namespace, d.normalizeManifests, excludes...)
95 releaseResponse = nil //nolint:ineffassign // nil to allow GC to reclaim raw bytes before diff computation
96 revisionResponse = nil //nolint:ineffassign // nil to allow GC to reclaim raw bytes before diff computation
97
98 seenAnyChanges := diff.Manifests(
99 oldSpecs,
100 newSpecs,
101 &d.Options,
102 os.Stdout)
103
104 if d.detailedExitCode && seenAnyChanges {
105 return Error{
106 error: errors.New("identified at least one change, exiting with non-zero exit code (detailed-exitcode parameter enabled)"),
107 Code: 2,
108 }
109 }
110
111 return nil
112}

Callers 1

rollbackCmdFunction · 0.95

Calls 4

ParseFunction · 0.92
ManifestsFunction · 0.92
getReleaseFunction · 0.85
getRevisionFunction · 0.85

Tested by

no test coverage detected