Skip to content

Commit

Permalink
helm2; Check configmap/secret struct for updating (#497) (#498)
Browse files Browse the repository at this point in the history
* Check configmap/secret struct for updating (#497)

* update go mode

* compare configmap data structure

* fix imports

* add changelog
  • Loading branch information
tomahawk28 authored Sep 21, 2020
1 parent cc02bdf commit 629064f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project's packages adheres to [Semantic Versioning](http://semver.org/s

## [Unreleased]

### Fixed

- Fix YAML comparison for chart configmaps and secrets.

## [1.0.11] - 2020-09-17

### Added
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/giantswarm/app-operator
go 1.13

require (
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
github.com/giantswarm/apiextensions v0.4.8
github.com/giantswarm/appcatalog v0.2.5
github.com/giantswarm/backoff v0.2.0
Expand Down
20 changes: 19 additions & 1 deletion service/controller/app/resource/configmap/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package configmap
import (
"reflect"

"github.com/ghodss/yaml"
"github.com/giantswarm/microerror"
"github.com/giantswarm/micrologger"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -90,7 +91,24 @@ func equals(a, b *corev1.ConfigMap) bool {
if !reflect.DeepEqual(a.Annotations, b.Annotations) {
return false
}
if !reflect.DeepEqual(a.Data, b.Data) {

var source, dest map[string]interface{}
{
source = make(map[string]interface{})
dest = make(map[string]interface{})

err := yaml.Unmarshal([]byte(a.Data["values"]), &source)
if err != nil {
return false
}

err = yaml.Unmarshal([]byte(b.Data["values"]), &dest)
if err != nil {
return false
}
}

if !reflect.DeepEqual(source, dest) {
return false
}
if !reflect.DeepEqual(a.Labels, b.Labels) {
Expand Down
20 changes: 19 additions & 1 deletion service/controller/app/resource/secret/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package secret
import (
"reflect"

"github.com/ghodss/yaml"
"github.com/giantswarm/microerror"
"github.com/giantswarm/micrologger"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -90,7 +91,24 @@ func equals(a, b *corev1.Secret) bool {
if !reflect.DeepEqual(a.Annotations, b.Annotations) {
return false
}
if !reflect.DeepEqual(a.Data, b.Data) {

var source, dest map[string]interface{}
{
source = make(map[string]interface{})
dest = make(map[string]interface{})

err := yaml.Unmarshal(a.Data["values"], &source)
if err != nil {
return false
}

err = yaml.Unmarshal(b.Data["values"], &dest)
if err != nil {
return false
}
}

if !reflect.DeepEqual(source, dest) {
return false
}
if !reflect.DeepEqual(a.Labels, b.Labels) {
Expand Down

0 comments on commit 629064f

Please sign in to comment.