Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
jgwest committed Sep 30, 2024
1 parent b3ca7b9 commit e5611c6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions controllers/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,9 @@ func (r *RolloutManagerReconciler) reconcileRolloutsMetricsService(ctx context.C
fmt.Println("one", reflect.DeepEqual(normalizedLiveService.Labels, expectedSvc.Labels))
fmt.Println("two", reflect.DeepEqual(normalizedLiveService.Annotations, expectedSvc.Annotations))

fmt.Println("three", areStringMapsEqual(normalizedLiveService.Labels, expectedSvc.Labels))
fmt.Println("four", areStringMapsEqual(normalizedLiveService.Annotations, expectedSvc.Annotations))

fmt.Println(normalizedLiveService.Labels)
fmt.Println(expectedSvc.Labels)

Expand Down
23 changes: 23 additions & 0 deletions controllers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"os"
"reflect"
"sort"
"strings"

Expand Down Expand Up @@ -85,6 +86,28 @@ func appendStringMap(src map[string]string, add map[string]string) map[string]st
return res
}

func areStringMapsEqual(one map[string]string, two map[string]string) bool {

isOneEmpty := false

isTwoEmpty := false

if len(one) == 0 {
isOneEmpty = true
}

if len(two) == 0 {
isTwoEmpty = true
}

if isOneEmpty && isTwoEmpty {
return true
}

return reflect.DeepEqual(one, two)

}

// combineStringMaps will combine multiple maps: maps defined earlier in the 'maps' slice may have their values overriden by maps defined later in the 'maps' slice.
func combineStringMaps(maps ...map[string]string) map[string]string {

Expand Down

0 comments on commit e5611c6

Please sign in to comment.