Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Trigger a Helm upgrade only when FHR values changed
Browse files Browse the repository at this point in the history
 - fix unwanted upgrades on K8s 1.11
  • Loading branch information
stefanprodan committed Jul 3, 2018
1 parent 9b545a4 commit 4ce6f69
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions integrations/helm/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,7 @@ func (c *Controller) enqueueUpateJob(old, new interface{}) {
return
}

oldResVer := oldFhr.ResourceVersion
newResVer := newFhr.ResourceVersion
if newResVer != oldResVer {
if needsUpdate(oldFhr, newFhr) {
c.logger.Log("info", "UPGRADING release")
c.logger.Log("info", "Custom Resource driven release upgrade")
c.enqueueJob(new)
Expand All @@ -343,3 +341,31 @@ func (c *Controller) deleteRelease(fhr ifv1.FluxHelmRelease) {
}
return
}

// needsUpdate compares two FluxHelmRelease and determines if any changes occurred
func needsUpdate(old, new ifv1.FluxHelmRelease) bool {

oldValues, err := old.Spec.Values.YAML()
if err != nil {
return false
}

newValues, err := new.Spec.Values.YAML()
if err != nil {
return false
}

if oldValues != newValues {
return true
}

if old.Spec.ReleaseName != new.Spec.ReleaseName {
return true
}

if old.Spec.ChartGitPath != new.Spec.ChartGitPath {
return true
}

return false
}

0 comments on commit 4ce6f69

Please sign in to comment.