Skip to content

Commit 5c7d414

Browse files
committed
splited procesSelector into two
On-behalf-of: @SAP [email protected] Signed-off-by: Artem Shcherbatiuk <[email protected]>
1 parent 4df60a4 commit 5c7d414

File tree

2 files changed

+20
-271
lines changed

2 files changed

+20
-271
lines changed

gateway/resolver/dotted_keys.go

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func processSpecToArrays(spec any) any {
8383
if k == "nodeSelector" && v != nil {
8484
specMap[k] = mapToArray(v)
8585
} else if k == "selector" && v != nil {
86-
specMap[k] = processSelector(v, true)
86+
specMap[k] = processSelectorToArrays(v)
8787
}
8888
}
8989
return spec
@@ -100,26 +100,37 @@ func processSpecToMaps(spec any) any {
100100
if k == "nodeSelector" && v != nil {
101101
specMap[k] = arrayToMap(v)
102102
} else if k == "selector" && v != nil {
103-
specMap[k] = processSelector(v, false)
103+
specMap[k] = processSelectorToMaps(v)
104104
}
105105
}
106106
return spec
107107
}
108108

109-
// processSelector handles spec.selector.matchLabels conversion
110-
func processSelector(selector any, toArray bool) any {
109+
// processSelectorToArrays handles spec.selector.matchLabels conversion to arrays
110+
func processSelectorToArrays(selector any) any {
111111
selectorMap, ok := selector.(map[string]interface{})
112112
if !ok {
113113
return selector
114114
}
115115

116116
for k, v := range selectorMap {
117117
if k == "matchLabels" && v != nil {
118-
if toArray {
119-
selectorMap[k] = mapToArray(v)
120-
} else {
121-
selectorMap[k] = arrayToMap(v)
122-
}
118+
selectorMap[k] = mapToArray(v)
119+
}
120+
}
121+
return selector
122+
}
123+
124+
// processSelectorToMaps handles spec.selector.matchLabels conversion to maps
125+
func processSelectorToMaps(selector any) any {
126+
selectorMap, ok := selector.(map[string]interface{})
127+
if !ok {
128+
return selector
129+
}
130+
131+
for k, v := range selectorMap {
132+
if k == "matchLabels" && v != nil {
133+
selectorMap[k] = arrayToMap(v)
123134
}
124135
}
125136
return selector

gateway/resolver/dotted_keys_test.go

Lines changed: 0 additions & 262 deletions
This file was deleted.

0 commit comments

Comments
 (0)