func equalExcept()

in operatortrace-go/pkg/predicates/ignore_trace_annotation_update.go [110:131]


func equalExcept(a, b map[string]string, keysToIgnore ...string) bool {
	ignored := make(map[string]struct{})
	for _, key := range keysToIgnore {
		ignored[key] = struct{}{}
	}

	for key, aValue := range a {
		if _, isIgnored := ignored[key]; !isIgnored {
			if bValue, exists := b[key]; !exists || aValue != bValue {
				return false
			}
		}
	}
	for key := range b {
		if _, exists := a[key]; !exists {
			if _, isIgnored := ignored[key]; !isIgnored {
				return false
			}
		}
	}
	return true
}